32 Commits

Author SHA1 Message Date
Jeija
6128dc7a07 Add Lua interface to HTTPFetchRequest
This allows mods to perform both asynchronous and synchronous HTTP
requests. Mods are only granted access to HTTP APIs if either mod
security is disabled or if they are whitelisted in any of the
the secure.http_mods and secure.trusted_mods settings.

Adds httpfetch_caller_alloc_secure to generate random, non-predictable
caller IDs so that lua mods cannot spy on each others HTTP queries.
2016-02-22 15:39:41 +01:00
Jeija
88819c1689 Fix HTTPFetchRequest performing a GET request if post_data is supplied
Instead, perform a POST request with post_data.
2016-02-22 15:39:19 +01:00
ShadowNinja
85dbe50ec1 Rename macros with two leading underscores
These names are reserved for the compiler/library implementations.
2015-10-14 02:39:37 -04:00
ShadowNinja
324f309a49 Always use errorstream for DEBUG_EXCEPTION_HANDLER 2015-10-14 02:33:30 -04:00
ShadowNinja
098d28aa5e Clean up threading
* Rename everything.
    * Strip J prefix.
    * Change UpperCamelCase functions to lowerCamelCase.
  * Remove global (!) semaphore count mutex on OSX.
  * Remove semaphore count getter (unused, unsafe, depended on internal
    API functions on Windows, and used a hack on OSX).
  * Add `Atomic<type>`.
  * Make `Thread` handle thread names.
  * Add support for C++11 multi-threading.
  * Combine pthread and win32 sources.
  * Remove `ThreadStarted` (unused, unneeded).
  * Move some includes from the headers to the sources.
  * Move all of `Event` into its header (allows inlining with no new includes).
  * Make `Event` use `Semaphore` (except on Windows).
  * Move some porting functions into `Thread`.
  * Integrate logging with `Thread`.
  * Add threading test.
2015-08-23 22:04:06 -04:00
kwolekr
4df33b90e5 Replace instances of std::map<std::string, std::string> with StringMap
Also, clean up surrounding code style
Replace by-value parameter passing with const refs when possible
Fix post-increment of iterators
2015-05-19 16:10:49 -04:00
sfan5
023fd295d5 Revert the upper-case PROJECT_NAME nonsense that was part of #2402 2015-04-27 16:24:49 +02:00
Craig Robbins
0731f9ed2a Move globals from main.cpp to more sane locations
Move debug streams to log.cpp|h

Move GUI-related globals to clientlauncher

Move g_settings and g_settings_path to settings.cpp|h

Move g_menuclouds to clouds.cpp|h

Move g_profiler to profiler.cpp|h
2015-04-01 23:04:25 +10:00
ShadowNinja
2de60ae349 Clean up and tweak build system
* Combine client and server man pages.
  * Update unit test options and available databases in man page.
  * Add `--worldname` to man page.
  * Fix a bunch of places where `"Minetest"` was used directly instead of `PROJECT_NAME`.
  * Disable server build by default on all operating systems.
  * Make `ENABLE_FREETYPE` not fail if FreeType isn't found.
  * Enable LevelDB, Redis, and FreeType detection by default.
  * Remove the `VERSION_PATCH_ORIG` hack.
  * Add option to search for and use system JSONCPP.
  * Remove broken LuaJIT version detection.
  * Rename `DISABLE_LUAJIT` to `ENABLE_LUAJIT`.
  * Rename `minetest_*` variables in `version.{h,cpp}` to `g_*`.
  * Clean up style of CMake files.
2015-03-27 15:00:48 -04:00
Craig Robbins
27791ee1aa For usages of assert() that are meant to persist in Release builds (when NDEBUG is defined), replace those usages with persistent alternatives 2015-03-07 22:41:47 +10:00
Loic Blot
b7ba9742e7 Use std::queue for HTTPFetchRequest and std::vector for log_output instead of std::list 2015-03-05 16:21:10 +01:00
Loic Blot
690c0d8f3f Remove unused variables to make clang happy 2015-02-12 11:13:27 +01:00
ShadowNinja
75346d743a Use configured bind_address for HTTPFetch 2014-09-18 21:54:23 -04:00
ShadowNinja
4359238906 Reduce indentation of HTTPFetchOngoing
Also clean up some related things.
2014-09-18 21:54:22 -04:00
ShadowNinja
fc86c213aa Add support for multipart/form-data to HTTPFetch for server announcing 2014-06-30 13:23:09 -04:00
sapier
268ff61168 Add support for Android 2.3+
There have been plenty of ppl involved in creating this version.
I don't wanna mention names as I'm sure I'd forget someone so I
just tell where help has been done:
- The partial android versions done by various ppl
- Testing on different android devices
- reviewing code (especially the in core changes)
- testing controls
- reviewing texts

A big thank you to everyone helping this to be completed!
2014-06-29 18:17:56 +02:00
ShadowNinja
5805a3dc4c Remove dependency on marshal and many other async changes
This makes a number of changes:
  * Remove the dependency on marshal by using string.dump and loadstring.
  * Use lua_tolstring rather than having Lua functions pass string lengths to C++.
  * Move lua_api/l_async_events.* to cpp_api/s_async.*, where it belongs.
  * Make AsyncWorkerThread a child of ScriptApiBase, this removes some duplicate functionality.
  * Don't wait for async threads to shut down.  (Is this safe?  Might result in corruption if the thread is writing to a file.)
  * Pop more unused items from the stack
  * Code style fixes
  * Other misc changes
2014-04-27 16:15:53 -04:00
sapier
607f617471 Add support for named threads (atm linux only) 2014-04-09 21:32:21 +02:00
Sfan5
01878f22cd Include system info in the HTTP user agent on Windows 2014-01-23 22:27:13 +01:00
ShadowNinja
9c2916e60f Deindent HTTPFetchRequest::HTTPFetchRequest() 2014-01-16 20:14:55 -05:00
ShadowNinja
cc3028ada5 Make default User-agent follow RFC 2616 2014-01-15 12:10:53 -05:00
Sfan5
afce24f084 Fix building with MinGW 2014-01-15 17:35:00 +01:00
sapier
fcc2dda8c0 Fix check for max_fd == -1 should actually be max_fd != -1 2014-01-10 19:19:16 +01:00
sapier
f04d2ad9e3 Make MutexQueue use jsemaphore for signaling 2014-01-10 10:10:45 +01:00
proller
3116d1d531 Send long announce as POST, show OS in useragent
Add lag reporting to masterserver (average dtime)
StyledWriter  -> FastWriter in masterserver announce
2014-01-07 02:50:45 +04:00
Kahrl
45c3088d27 Use sleep_ms instead of select in httpfetch when max_fd == -1, fixes WSAEINVAL 2013-12-24 19:28:09 +01:00
sapier
297f41851e Fix broken httpfetch due to SimpleThread removal 2013-12-16 23:31:56 +01:00
BlockMen
1c08484f25 Fix MSVC compiling issue 2013-12-16 01:13:08 +01:00
sapier
6474caa15f Replace SimpleThread by JThread now implementing same features 2013-12-15 13:39:42 +01:00
sapier
656c7f2683 Replace any direct curl usage by httpfetch 2013-12-13 18:05:46 +01:00
Kahrl
149e07900a Use httpfetch_async in serverlist announce code 2013-12-13 18:05:39 +01:00
Kahrl
e9737be595 Implement httpfetch module and initialize it from main()
Add curl_parallel_limit setting that will replace media_fetch_threads in
a later commit.

Fix a typo in MutexedQueue::pop_back() that made it impossible to compile
code that used this function. (Noticed this while implementing httpfetch.)
2013-12-13 18:05:10 +01:00