Commit Graph

40 Commits

Author SHA1 Message Date
Jeremy Lakeman
f4210e06d8 Make sure all restful newsince responses can be sorted by the front end 2016-10-31 10:56:10 +10:30
Jeremy Lakeman
09d04d7c8f Add restful api for listing broadcast messages 2016-10-26 13:08:19 +10:30
Jeremy Lakeman
c2956568d6 Send a meshmb message via restful api 2016-10-26 13:08:13 +10:30
Jeremy Lakeman
75dfcff213 Fix meshms restful newsince with empty conversation 2016-10-20 08:37:24 -04:00
Andrew Bettison
71cbe86566 Switch to feature-driven linking
This introduces a new way of linking Serval executables and dynamic
libraries from static libraries like libservald.a -- called
"feature-driven" linking.

The Makefile now links servald and serval-tests from libservald.a,
rather than from an explicit list of object (.o) files.  Thanks to the
section-based method for registering functions such as HTTP handlers,
CLI commands and MDP handlers, these object files had become
"stand-alone" and hence were no longer included in the link because
there was no unresolved reference that required them to be linked in.

The new "feature.h" provides the DECLARE_FEATURE(name) macro that each
stand-alone source file uses to declare the named feature(s) it
provides.  Each executable can call the USE_FEATURE(name) macro in any
of its explicitly-linked source files to cause the corresponding
object(s) to be included in the link, eg, servald_features.c.

The DEFINE_BINDING() macro has been extended so that every individual
MDP binding is given a feature name based on its port number macro, eg,
"mdp_binding_MDP_PORT_ECHO".

Some features have been factored into their own separate source files so
they can be omitted or included in a build independently of each other:
- the MDP bindings for MDP_PORT_DNALOOKUP, MDP_PORT_ECHO,
  MDP_PORT_TRACE, MDP_PORT_KEYMAPREQUEST, MDP_PORT_RHIZOME_xxx,
  MDP_PORT_PROBE, MDP_PORT_STUN, MDP_PORT_STUNREQ
- the CLI "log" and "echo" commands
- the CLI "rhizome direct" command

The JNI source files are only compiled if the <jni.h> header is present,
otherwise they are omitted from libservald.so.
2016-10-19 09:33:01 +10:30
Andrew Bettison
6e65a2399f Add missing #include "str.h" 2016-09-21 18:47:49 +09:30
Andrew Bettison
5b3d997896 Move Base64 conversions from "str.h" to "base64.h" 2016-09-21 18:47:49 +09:30
Andrew Bettison
cd766cd480 Move numeric conversions from "str.h" to "numeric_str.h" 2016-09-21 18:47:49 +09:30
Jeremy Lakeman
e13b9c3c94 Reduce redundant reading of message ply's 2016-08-23 14:28:13 +09:30
Jeremy Lakeman
30167ce4ed Add meshms newsince support for starting with an empty conversation 2016-08-02 13:29:31 +09:30
Jeremy Lakeman
a854105598 Support rhizome newsince request on an empty store 2016-07-25 16:54:11 +09:30
Jeremy Lakeman
dbded493c1 Refactor meshms ply handling into separate source file 2016-07-25 16:54:11 +09:30
Jeremy Lakeman
16a14269af Encrypt payloads without needing a sender
- reworked keyring identity handling to reduce memory searching
2016-05-31 12:50:32 +09:30
Andrew Bettison
518740bcf2 Report missing Content-Disposition header 2016-02-22 18:14:53 +10:30
Andrew Bettison
419364b5a9 Improve REST HTTP response status codes
List all the HTTP status codes in the REST API tech doc.

Only use 403 Forbidden for requests originating from a disallowed
origin (ie, not localhost).

- Return 400 for missing, unknown, duplicate and out-of-order form
  parts in POST requests.
- Return 415 Unsupported Media Type for unsupported form part
  Content-Disposition and Content-Type (including unsupported
  charset).
- Return 414 Request-URI Too Long for any buffer exhaustion while
  parsing request.
- Return 419 Authentication Timeout for missing crypto secret.
2015-11-02 12:26:40 +10:30
Jeremy Lakeman
84caf21969 Use section linking to define httpd pages 2015-08-24 12:49:09 +09:30
Andrew Bettison
7d9a5faa4e Move if(config.debug.xxx) tests into DEBUGF()
Original DEBUG() and DEBUGF() macros renamed to _DEBUG() and _DEBUGF()
New DEBUG() and DEBUGF() macros, first argument is flagname
New DEBUGF2(foo, bar, ...) macro does if(config.debug.foo||config.debug.bar) test
Replace almost all config.debug.xxx references to IF_DEBUG(xxx)
2015-07-13 16:00:05 +09:30
Andrew Bettison
abb2a39330 Fix MeshMS REST newsince race condition
During GET /restful/meshms/SID1/SID2/newsince/messagelist.json, if a new
message was received before the request reached the end of its message
iterator and paused, then the new message did not make it into the
output.
2015-06-29 15:39:19 +09:30
Andrew Bettison
6febcc350d Replace RESTful newsince polling with triggers
Remove the 'api.restful.newsince_poll_ms' config option, no longer
needed.
2015-06-02 02:23:06 +09:30
Andrew Bettison
7f564e4dcf Make strn_to_xxx() functions consistent
All strn_to_xxx() functions should take a 'size_t len' parameter

All functions that take a 'const char **endp' parameter should
be named parse_xxx(), and should also have a 'ssize_t len' parameter
which can be -1 to indicate a null-terminated string
2015-03-28 04:53:09 +10:30
Andrew Bettison
c5bf770c20 Fix bug in new RESTful MeshMS newsince logic
Introduced in a4be1b0, caused malformed JSON (missing comma)
2014-11-19 22:57:16 +10:30
Andrew Bettison
a4be1b0b0c Fix RESTful MeshMS newsince ACK logic
/restful/meshms/newsince/SID1/SID2/newsince/TOKEN/messagelist.json now
always lists an ACK as soon as it is received, instead of waiting for a
message to arrive as well.
2014-11-12 23:09:00 +10:30
Jeremy Lakeman
851144ea0a Refactor keyring identity iteration 2014-10-31 15:19:59 +10:30
Jeremy Lakeman
31cf3a67b5 Allow lcal http servers to perform cross site scripting of restful APIs 2014-07-28 12:54:57 +09:30
Andrew Bettison
d436705e64 Fix conflict on UNUSED() macro from OpenJDK 7
The OpenJDK 7 recently introduced the UNUSED() macro in their jni_md.h
header file, which is included from <jni.h>.  This causes a
compile-error if "constants.h", which defines our own UNUSED() macro, is
included as well as <jni.h>.

The OpenJDK UNUSED() macro is unsuitable for our own use, because it
prefixes the unused identifier with "UNUSED_" whereas we depend on the
parameter name remaining unchanged.

I have reported this as a Request for Enhancement with Oracle Java,
asking them to remove the UNUSED() macro, since it is not used by any
JNI or Java extension header files.  Review ID: JI-9013689.

In the meantime, constants.h now undefines UNUSED before defining it, so
including <jni.h> before "constants.h" will avoid a compile error.
2014-07-23 11:55:55 +09:30
Jeremy Lakeman
435ffecfa8 Add message timestamps to restful meshms 2014-07-18 14:11:57 +09:30
Jeremy Lakeman
d275a34802 Don't just straight to LIST_END when there's an end time in the future 2014-07-14 15:28:30 +09:30
Andrew Bettison
d16be8f42d Improve MeshMS HTTP RESTful interface
Provide "meshms_status_message" in returned JSON status content
2014-07-10 06:30:50 +09:30
Andrew Bettison
cf43635789 Improve Rhizome HTTP RESTful interface
Add RHIZOME_BUNDLE_STATUS_READONLY enum value

Tighten up switch statements on bundle and payload status enums (no
default labels)

Rename some recently added enum entries

Return bundle status and payload status in HTTP responses

Add test for failing to decrypt a foreign encrypted bundle payload,
fix bug that caused an assertion failure

Add tests for fetching a non-existent manifest and fetching bundles
whose payload blob is not in the store
2014-07-10 06:29:51 +09:30
Andrew Bettison
067340bbba Change HTTP Authorization realm to "Serval RESTful API"
Was "Serval Rhizome", which is not accurate
2014-06-30 11:11:01 +09:30
Andrew Bettison
11e9d38299 Rename config 'rhizome.api.restful' to 'api.restful' 2014-06-30 11:11:01 +09:30
Andrew Bettison
6c16b95a38 Fix SEGV on empty /restful/meshms/.../conversationlist.json 2014-06-26 15:08:48 +09:30
Andrew Bettison
7736a4ceb1 New HTTP RESTful requests: MeshMS read message(s) 2014-06-24 12:11:58 +09:30
Andrew Bettison
819b8dc9e7 MeshMS RESTful API stricter on incoming form data
/restful/meshms/SID/SID/sendmessage now enforces Content-Disposition:
form-data (was ignoring), and enforces Content-Type: text/plain;
charset=utf-8 (was ignoring)

New negative test cases to ensure that these are treated strictly
2014-06-23 12:27:09 +09:30
Andrew Bettison
008dd6ab21 Add size_t arg to strn_to_sid_t() 2014-04-29 13:39:21 +09:30
Jeremy Lakeman
800d3c6120 Fix 64bit printf formatting 2014-02-12 15:09:07 +10:30
Andrew Bettison
0769fa54e8 Improve MeshMS RESTful HTTP failure reporting
Add "meshms_status_code" element to simple JSON responses
2014-02-07 16:28:40 +10:30
Andrew Bettison
5dd9ea7a6b Improve MeshMS failure handling
Introduce "enum meshms_status" to replace int -1,0,1 for return values
from MeshMS internal functions

Add test cases to check that status 2 is returned when attempting to
send a message from an identity that is not known (unlocked)
2014-02-06 18:10:00 +10:30
Andrew Bettison
fd86a3d17f Implement HTTP POST /restful/meshms/<SID>/<SID>/sendmessage
Rename struct meshms_ply fields from "buffer" to "record" for
consistency with comment terminology
2014-02-05 14:28:15 +10:30
Andrew Bettison
fb2709d10c Create rhizome_restful.c, meshms_restful.c
Move code from rhizome_http.c into rhizome_restful.c and
meshms_restful.c
2014-02-03 23:05:15 +10:30