Commit Graph

38 Commits

Author SHA1 Message Date
Andrew Bettison
798e34cc5b Add strbuf_json_integer() 2018-03-29 15:19:54 +10:30
Andrew Bettison
9ef7d33d69 Log more debug in MDP_ROUTE_TABLE request 2018-03-27 09:06:41 +10:30
Andrew Bettison
29ce8994f2 Improve HTTP Content-Type handling
Undo a change from late 2015 that allowed the format=text+binarysig
parameter of the rhizome/manifest MIME content-type to be optional -- it
is easy to provide that parameter via libcurl, and the lbard code has
just been updated to provide it.

Make Content-Type handling consistent throughout the Serval DNA code by
using 'struct mime_content_type' to represent both parsed (request) and
sent (response) Content-Type fields, replacing ad-hoc in-line string
literals.

Fix some TODOs by adding the "serval/sid", "rhizome/bid" and
"rhizome/bundlesecret" MIME types, which remain optional for the time
being to preserve REST API compatibility with clients that do not set
the Content-Type of their 'bundle-author', 'bundle-id' and
'bundle-secret' parameters.
2017-10-20 09:55:21 +10:30
Andrew Bettison
1efe6686fc Use config.h instead of -DHAVE_FOO=1
swiftc(1) requires every -D option to be prefixed with -Xcc, which
is not easy to achieve using autoconf.

Now instead of setting configuration macros like HAVE_LSEEK64 on the
command line using -D, they are defined in config.h, which is generated
by ./configure, ignored by Git, and included by all headers and source
files that use any configuration macro.

The dependency on Makefile has been replaced with a dependency on
Makefile.in and config.h, which helps avoid some redundant full
recompiles after running ./configure, because the configure script
does not overwrit config.h if its content does not change.
2016-10-19 16:27:20 +10:30
Andrew Bettison
c8bf8a7733 Refactor JNI out of CLI and server main loop
The CLI and server main loop now have no conditional JNI code.  All JNI
code has been moved into separate source files, which #include the new
"jni_common.h" instead of <jni.h>.  The "cli.h" header no longer
includes <jni.h>, so the rest of the Serval source code is now
unaffected by JNI definitions.

The 'cf_limbo' global variable is now thread-local, so that each thread
has its own independent copy of the loaded configuration.  The JNI
server entry point now calls cf_init() once.  The new 'cf_initialised'
flag prevents clobbering the config state by redundant calls to
cf_init().

The CLI "stop" command now sends SIGHUP to the specific thread in which
the server is running.  This is achieved by writing the PID and TID
(Linux Thread ID) into the pidfile, separated by a space, on systems
that support the Linux gettid() and tgkill() system calls.  The server's
signal handler has been overhauled, and its logging improved.
2016-10-13 16:23:18 +10:30
Jeremy Lakeman
75df3bd4ec Format network addresses using posix API 2015-09-28 11:58:48 +09:30
Andrew Bettison
71c7a4f870 strbuf_json_atom() supports JSON objects and arrays 2015-08-31 19:16:30 +09:30
Andrew Bettison
8d799840df Add alloca_sourceloc(), refactored from log.c 2015-06-29 15:39:19 +09:30
Andrew Bettison
2c0efc6334 Set up SEGV crash handler in main() not server()
Now all commands will attempt to log a GDB backtrace on a crash, not
just the server daemon process.

Added strbuf_append_signal_name()
2014-05-08 14:24:00 +09:30
Andrew Bettison
60201d78c9 Fix Android compile failure: st_mtim, UTIME_OMIT
Use utimes(2) instead of utimensat(2), use struct timeval instead of
struct timespec

Add strbuf helper functions for struct timeval and time_ms_t
2014-05-02 15:47:51 +09:30
Andrew Bettison
684735b11c Fix config file timestamp bug
Ensure that timestamp always advances by at least one second every time
the config file is modified, add test case

Refactor test defs: detecting started HTTPD is not specific to Rhizome

Refactor struct file_meta and associated functions into "io.h" and io.c

Add various strbuf helper functions for formatting struct timespec
and struct file_meta to assist debug logging
2014-04-29 15:04:20 +09:30
Andrew Bettison
67e3079aa3 Fix return value of mdp_send() 2014-04-16 19:28:11 +09:30
Andrew Bettison
5d9e3f1287 New config option: 'debug.config'
Logs some information about configuration file loading and re-loading
2014-04-16 19:12:01 +09:30
Andrew Bettison
116389b589 "struct json_atom" with strbuf helper functions 2014-02-07 15:59:34 +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
de46223cc4 strbuf_json_boolean() 2014-01-20 15:43:37 +10:30
Jeremy Lakeman
0d5d878521 Refactor socket name and address length handling 2013-11-27 13:08:37 +10:30
Andrew Bettison
39d6c4fc3a strbuf_append_sockaddr_in() 2013-11-26 15:33:54 +10:30
Andrew Bettison
9ecf9891fb Add strbuf JSON helper functions 2013-11-07 23:39:53 +10:30
Andrew Bettison
b9faf54c91 Support more HTTP multipart inner headers
Now Content-Length and Content-Type are parsed as well as
Content-Disposition
2013-10-28 22:27:27 +10:30
Andrew Bettison
8f60a4ceb5 Fix bugs in new HTTP server MIME body parsing code
Fixes 'rhizomeprotocol' test 24 HttpAddLocal.  Four tests still fail.
2013-10-28 12:08:57 +10:30
Andrew Bettison
2a9329c0c8 Fix bugs in new HTTP server MIME body parsing code
Fixes 'rhizomeprotocol' test 24 HttpImport.  Five tests still fail.
2013-10-27 13:19:23 +10:30
Andrew Bettison
e82d22d765 Add alloca_poll_events() macro 2013-10-25 00:19:58 +10:30
Andrew Bettison
fa21bec880 Rewrite HTTP server 2013-10-25 00:19:37 +10:30
Andrew Bettison
0437e4adbb Add writev_all() function
Use it in rhizome_write_manifest_file() instead of two separate write(2)
system calls or buffered stdio.
2013-10-12 03:54:18 +10:30
Andrew Bettison
2b3119b49b Issue #20: merge branch 'sockets' into 'development'
Daniel's improvements to the local file/abstract socket code, with many
improvements to bring it up to date.
2013-09-19 04:30:14 +09:30
Andrew Bettison
c6666387e8 Add strbuf_append_strftime() 2013-04-04 17:40:58 +10:30
Andrew Bettison
f995a2a42d More strbuf helper functions
strbuf_append_argv()

strbuf_path_join()
2012-12-04 09:47:39 +10:30
Andrew Bettison
0e435683f7 Move toprint functions from log.h to str.h
Move alloca_sockaddr() to strbuf_helpers.h

So that stand-alone executables can use them without pulling in the entire
logging framework.
2012-11-20 18:10:08 +10:30
Andrew Bettison
5d62be7b0f Issue #30, easy logging of struct sockaddr 2012-10-23 18:07:56 +10:30
Andrew Bettison
62f8d223ea Improve alloca_toprint() functions
Replace "..." quoting with `...` quoting in output, to avoid slosh-escaping the
common double-quote character (") in log output.

Introduce alloca_str_toprint() function that produces an entire null-terminated
string in printable form.

Change various toprint strbuf helper functions to take two optional quote chars
instead of one mandatory.
2012-09-28 17:46:40 +09:30
Andrew Bettison
07349c3aea Improve copyright attributions and comments 2012-07-30 16:15:42 +09:30
Andrew Bettison
bbd28eed45 Add strbuf_toprint(), strbuf_toprint_quoted(), etc. 2012-07-27 18:04:46 +09:30
Andrew Bettison
99ead3b9b1 Add strbuf_append_shell_quote() function 2012-07-26 18:30:24 +09:30
Andrew Bettison
04b95d2590 Merge branch 'andrew' into 'master' 2012-07-25 18:04:16 +09:30
Andrew Bettison
6de247e576 Improve diagnosis of SEGV failures in tests 2012-07-24 15:39:36 +09:30
Andrew Bettison
5aac5a3854 Unfinished dnahelper implementation 2012-07-18 19:16:30 +09:30
Andrew Bettison
c7488de510 Add strbuf_helpers.[ch]
Functions to help assemble strbuf contents.
2012-07-11 14:11:59 +09:30