Commit Graph

39 Commits

Author SHA1 Message Date
Gioacchino Mazzurco
a43ac94e96 Prepare for merging 2019-11-27 18:44:10 +01:00
csoler
c5db6aa214 fixes required by review of pr1700 2019-11-25 22:16:32 +01:00
csoler
2192ace149 using static resources for webui 2019-11-24 10:50:58 +01:00
csoler
c6756db3ea fixed compilation by modifying wrappers to account for the shared_ptr mService 2019-11-23 15:11:22 +01:00
csoler
7e1513ed0b changed layout of restbed/json/webui so that JsonApi is the only server (with thread functionality in a separate class) and webui is a resource provider 2019-11-23 00:17:17 +01:00
csoler
3ebc79e621 fixed retroshare_service with embedded webui 2019-11-17 22:01:49 +01:00
csoler
7852b1d56b fixed interactions between webui and jsonapi in GUI 2019-11-16 18:19:07 +01:00
csoler
7ef2a287d2 fixed start/stop of jsonapi in GUI 2019-11-16 14:30:36 +01:00
csoler
438a586552 converted JsonAPI with public api and using RestbedService system 2019-11-16 00:02:02 +01:00
csoler
4ef78fe9d4 fixed typo 2019-11-13 21:54:11 +01:00
csoler
5f0a0acdf5 improved UI for jsonapi and webui pages 2019-11-13 21:35:57 +01:00
csoler
d7f76518f4 fixed start/stop of webinterface from GUI 2019-11-13 21:06:20 +01:00
csoler
b7e3213417 made JsonApiServer an singleton through static method instance() 2019-11-12 22:32:18 +01:00
csoler
5cf84d59af added user-based token management to jsonApiServer 2019-11-11 22:48:35 +01:00
Gioacchino Mazzurco
881d629df9 Fix sporadic crash in JSON API async calls
In Restbed one is not supposed to call session->yield outside the
  threads controlled by Restbed. RetroShare JSON API async call were
  calling session->yield from threads controlled by RetroShare all the
  times, this caused crashes in some cases, like when the JSON API
  socket timed out concurrently with the session->yield call .
  To solve this problem session->yield from async
  calls are now wrapped insto mService->schedule to ensure they are
  executed on the right thread (aka one of the threads controlled by
  Restbed).
While solving this issue I realized also that passing RsEvents as const
  references around was quite limiting in cases where the event need to
  be finally handled in another thread, in that case passing by const
  reference the RsEvent needed to be copied by value into the thread
  that process it, in this copy by value process the information of
  which was the original specific type is lost, and then only the data
  and methods from general RsEvents are available, unless the handler
  does tricky stuff with type coercion etc. To solve this limitation
  pass the events as std::shared_ptr<const RsEvent> seems the safer and
  more elegant solution.
2019-08-27 11:59:38 +02:00
Gioacchino Mazzurco
a41d720bdc Fix a couple compliler warnings in JSON API 2019-08-23 12:02:25 +02:00
Gioacchino Mazzurco
b8cb1c5771 Implement a JSON API friendly notification system
This should bit by bit substitute RsNotify which would be very difficult
  to support properly in JSON API.
The new system is much simpler to use also from the C++ side of the
  moon.
BroadcastDiscovery take advantage of the new system to notify about new
  non friend peer discovered, tested successfully also in JSON API.
2019-04-15 00:31:49 +02:00
Gioacchino Mazzurco
089265bd7e Fix licensing in broadcast discovery and JSON API 2019-04-14 12:34:01 +02:00
Gioacchino Mazzurco
032173b705 Initial work on Broadcast Domain Discovery
Discover peers on the same broadcast domain/LAN
Implements own node announcement
Implements others announcement listening
Implements API to get notifiend when other nodes get discovered
Implements API to get discovered nodes
Add discovered peer locator to rsPeers if it is already friend

Yet a bunch of things to do to take full advantage of this new
implementation
2019-04-12 02:53:39 +02:00
Gioacchino Mazzurco
a677d72c73 JSON API fix OPTION method handling for authenticated methods 2018-12-06 20:49:51 +01:00
csoler
3a215a0f67 fixed missing licenses in libretroshare 2018-11-11 14:24:47 +01:00
Gioacchino Mazzurco
c9b371d725 JSON API authorize token in createLocation
Solve uncoherent 401 behaviour at first use without login
2018-10-19 15:10:15 +02:00
Gioacchino Mazzurco
84efbdf595 Merge branch 'master' into jsonapi 2018-10-10 22:23:28 +02:00
Gioacchino Mazzurco
077b03f85e Add missing rstime include in jsonapi 2018-10-08 11:56:47 +02:00
Gioacchino Mazzurco
0f8640886e Allow CORS in JsonApiServer 2018-10-06 18:57:14 +02:00
Gioacchino Mazzurco
62fd00e549 Fix warnings 2018-10-05 01:55:18 +02:00
Gioacchino Mazzurco
3f10583fa9 JsonApiServer::isAuthTokenValid avoid timing attack
Thanks Cyril for review :)
2018-09-25 17:27:54 +02:00
Gioacchino Mazzurco
3865a8f1f6 Implement JSON API HTTP Basic authentication
jsonapi-generator is now capable of generating API for headers outside
  retroshare/ directory
jsonapi-generator do a bit of methods parameter sanity check
JsonApiServer is now integrated in the rsinit hell like other services
Add *::exportGPGKeyPairToString to a bunch of classes in cascade
RsControl is now capable of calling back a function when retroshare is almost
  completely stopped, this is useful when running retroshare toghether with
  externally managed runloop such as QCoreApplication
Expose a bunch of methods through JSON API
retroshare-nogui remove some dead code and fix stopping from the RetroShare API
2018-09-19 21:28:26 +02:00
Gioacchino Mazzurco
af2435f864 JSON API export version extra too 2018-09-15 21:53:46 +02:00
Gioacchino Mazzurco
a3b8c74310 JSON API accessible via HTTP GET method
This is useful in cases where the client cannot use POST method.
/jsonApiServer/shutdown now reply before shutting down the core.
2018-09-12 23:40:34 +02:00
Gioacchino Mazzurco
e44a812139 JSON API expose retroshare version
Added a couple of macro to reduce boilerplate in manually written API
wrappers, use them in auto-generated wrappers too
2018-09-12 10:49:37 +02:00
Gioacchino Mazzurco
92f1abf46c Make JSON API server bind address configurable
Enforce it being 127.0.0.1 by default, I assumed 127.0.0.1 was restbed
default, but as reported by sehraf is not alwayd the case

JSON API bind address now is also configurable via commandline on
retroshare-android-service and retroshare-nogui, while it obey the
configuration of webui (execept for that port is incremented by 2)
in retroshare-gui
2018-09-05 00:08:56 +02:00
Gioacchino Mazzurco
46266c8575 JSON API close restbed session before shutting down 2018-09-01 15:54:11 +02:00
Gioacchino Mazzurco
2b2069d1c4 Prevent crash calling uninitialized service via JSON API 2018-09-01 15:29:09 +02:00
Gioacchino Mazzurco
041afcc74d Improve API
Manually expose /rsFiles/getFileData to stream/preview files
Automatically expose a bunch of methods via JSON API
Implement serial_process for std::pair
2018-08-23 01:39:26 +02:00
Gioacchino Mazzurco
f8f49d849f Implement JSON API generation for async API calls
Move JSON helpers to util/rsjson.* for better usability
Implement JSON ostream manipulator to print compact and pretty JSON
Use lambdas for API wrappers, integrate better and avoid namespace
  pollution
Removed experimental JSON API for notify client wrapper, notifications
  can be implemented automatically with moderns async API calls
Implement and automatically expose to JSON API
  RsGxsChannels::turtleSearchRequest(
        const std::string& matchString,
        const std::function<void (const RsGxsGroupSummary&)>& multiCallback,
        std::time_t maxWait )
2018-08-16 23:48:21 +02:00
Gioacchino Mazzurco
d2742f9583 Experiment of notification via NotifyClient + JSON API 2018-07-23 14:52:17 +02:00
Gioacchino Mazzurco
21fdabe005 Extend JSON API to shutdown retroshare gracefully 2018-06-28 15:04:06 +02:00
Gioacchino Mazzurco
16eacb36d1 Implement automatic JSON API generation
qmake file add jsonapi-generator target to compile JSON API generator
qmake files add rs_jsonapi CONFIG option to enable/disable JSON API at compile
  time
RsTypeSerializer pass down same serialization flags when creating new context
  for nested objects serial job
RsGxsChannels expose a few methods through JSON API as example
Derive a few GXS types (RsGxsChannelGroup, RsGxsChannelPost, RsGxsFile,
  RsMsgMetaData) from RsSerializables so they can be used for the JSON API
Create RsGenericSerializer::SERIALIZATION_FLAG_YIELDING so JSON objects that
  miss some fields can be still deserialized, this improve API usability
SerializeContext offer friendly constructor with default paramethers
Add restbed 4.6 library as git submodule as most systems doesn't have it yet
Add a bit of documentation about JSON API into jsonapi-generator/README.adoc
Add JsonApiServer class to expose the JSON API via HTTP protocol
2018-06-24 16:28:33 +02:00