Commit Graph

125 Commits

Author SHA1 Message Date
Andrew Bettison
faa0f392c5 Improve Rhizome DB path configuration
Change the default 'rhizome.datastore_path' to "rhizome", ie, a sub-
directory of the instance directory.

Add a new erename() operation to "os.h".

Clean up the code around the fix 39f582cca (two commits ago) for a bug
introduced in 2014: the 'rhizome.db' file was always being created in
the instance directory, regardless of the setting of the
'rhizome.datastore_path' config option.

Whenever the Rhizome database is opened (by the server or by a CLI
invocation), if the database file does not exist but there is a
'rhizome.db' file in the legacy location, then move that file (and any
accompanying "blob" and "hash" sub-directories) to the configured
location.

Update copyright notices.
2018-04-17 12:01:02 +09:30
Andrew Bettison
c35af0617a Fix header files for Xcode iOS build
- make "debug.h" a private header so that the DEBUG() macro does not
  interfere with Xcode Debug builds, which set DEBUG=1
- move all #include "debug.h" from headers into .c files
- move 'struct idebug' into a new public header "idebug.h" so that
  "log.h" can be public
- move HTTPD port number defs from "httpd.h" to "constants.h", so that
  "httpd.h" can be private and "conf.h" can be public
- add missing nested includes so each header compiles stand-alone
  without error
- #include "sodium.h" instead of <sodium.h>
- #include "sqlite3.h" instead of <sqlite3.h>
- add header guard to "fifo.h"
- fix header guard in "sync_keys.h"
2018-03-06 15:29:29 +10:30
Andrew Bettison
92fa6c196a Rewrite logging system
Rename the logging primitive functions and utility functions, prefixing
all with 'serval_log', eg: logMessage() -> serval_logf() etc.

Add an XPRINTF xhexdump() function and use it to implement the
serval_log_hexdump() utility, renamed from dump().  Add macros
WHY_dump(), WARN_dump(), HINT_dump() and DEBUG_dump(), and use them
everywhere.

Remove the 'log.console.dump_config' and 'log.file.dump_config'
configuration options; configuration is now dumped in every log prolog.

The logging system now constructs the log prolog by invoking the new
'log_prolog' trigger, so that it no longer depends on the version string
and configuration system.  Any system that wants to present a message in
the log prolog can define its own trigger, which calls standard log
primitives to print the message.

Split the logging system into a front-end (log.c) that provides the
logging primitives and is independent of the configuration system, and a
set of back-end "outputters" (log_output_console.c, log_output_file.c,
log_output_android.c) that may depend on the configuration system and
are decoupled from the front-end using the 'logoutput' link section.

These log outputters are explicitly linked into executables by the
Makefile rules, but could also be linked in using USE_FEATURE().  The
USE_FEATURE() calls have _not_ been added to servald_features.c, so that
different daemon executables can be built with the same feature set but
different log outputs.
2018-03-06 15:16:56 +10:30
Jeremy Lakeman
ce2c276570 Detect Wifi and cabled ethernet on linux systems, allow matching by type in config 2017-11-07 16:53:19 +10:30
Andrew Bettison
24266b5f3b Add 'api.restful.authorization' config option 2016-11-07 11:38:20 +10:30
Jeremy Lakeman
c2956568d6 Send a meshmb message via restful api 2016-10-26 13:08:13 +10:30
Andrew Bettison
95cce9109f Fix Android server thread start bug
Was failing to start if a stale pidfile was present.

Introduced the 'debug.server' config option to help diagnose pidfile
issues.
2016-10-20 13:29:01 +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
Andrew Bettison
43bd0bd33f Fix a failing keyring test
The in-memory identity creation test was failing intermittently because
the server only creates the in-memory identity on the first tick, and
under load the server sometimes does not tick for a while, leading to a
race with the "servald id self" command.

The test case now waits for the server to emit a tick before running the
"id self" command.  This necessitated a new DEBUG() statement and a new
debug flag 'overlaytick'.

Also disabled Rhizome for all the keyring tests, as unnecessary Rhizome
DB creation was slowing down the fixtures.
2016-09-06 15:00:21 +09:30
Jeremy Lakeman
802310c6f1 Don't append meshms timestamps if the clock is considered unreliable 2016-05-31 13:00:48 +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
Jeremy Lakeman
b55926b081 Add configuration for idle_tick_ms so tests can complete faster without wasting power 2016-05-10 11:19:49 +09:30
Jeremy Lakeman
6b7aa800e4 Start syncing rhizome based on manifest hashes 2016-05-09 11:10:50 +09:30
gardners
52bd428c09 make rhizome http port number configurable via serval.conf 2015-08-24 16:06:25 +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
819fa8bee4 No time stamps in Android log by default 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
30f4a398ea Merge RESTful Rhizome journal append into development
Support for appending to Rhizome journals using the RESTful API
2015-04-13 16:59:06 +09:30
Andrew Bettison
dbe0cf862f Remove 'debug.manifests' option
Use existing 'debug.rhizome_manifest' instead
Improve format of manifest alloc/free log messages
2015-03-30 18:19:26 +10:30
Jeremy Lakeman
943bca3bea Add transmit timeout config per network destination for low bandwidth links 2015-03-30 14:15:08 +10:30
Jeremy Lakeman
f7dbe06836 Rearrange interface config to support unicast settings 2015-03-23 13:35:22 +10:30
gardners
2296196f7b Add config option to select packet radio type. 2014-10-01 15:52:14 +09:30
Andrew Bettison
ccece93309 Refactor "conf_schema.h" to fix compile warnings
In STRUCT() and ARRAY() declarations, change the optional "validator"
arg from taking a bare function name to enclose the function name in
VALIDATOR(function)
2014-08-14 16:40:30 +09:30
Andrew Bettison
11e9d38299 Rename config 'rhizome.api.restful' to 'api.restful' 2014-06-30 11:11:01 +09:30
Jeremy Lakeman
31dbfa4e58 Improve debug info for rhizome sync 2014-06-28 20:27:29 +09:30
Jeremy Lakeman
75d488b339 Add new debug flag to show what payloads are being included in network packets 2014-06-28 20:17:26 +09:30
Jeremy Lakeman
ca8f651b8d Cleanup the rhizome database every 30 minutes or so 2014-06-23 13:49:58 +09:30
Jeremy Lakeman
2ef73884a1 Add configurable limit to ensure a minimum amount of free space is preserved
- default to 100MB of free space
- currently disabled on android due to missing sys/statvfs.h
2014-06-23 13:06:21 +09:30
Jeremy Lakeman
7ff89afcf4 Reinstate rhizome database storage limit
- old / large payloads should be evicted to fit more payloads
- if there isn't enough space, new payloads will not be added
2014-06-19 11:09:09 +09:30
Jeremy Lakeman
f4e6841ed7 Ensure directory service tests aren't creating a global routing table 2014-06-16 17:22:46 +09:30
Jeremy Lakeman
c1fc33542d Default to using unicast link layer packets 2014-05-26 14:36:58 +09:30
Jeremy Lakeman
b94378ae97 Remove unused debug flags 2014-05-26 14:01:34 +09:30
Jeremy Lakeman
ca9faeef9b Remove respawn_on_crash behaviour, we aren't using or testing it 2014-05-12 13:44:51 +09:30
Andrew Bettison
ea9de737a2 MDP packet filter rules configuration
Configurable rules file path: mdp.filter_rules_path

Add filter rules parsing code, add filtering to outgoing as well as
incoming packets

New test script: tests/mdp with two test cases

Improve test defs: new execute_servald() function

Widen MDP port number format from 8 to ten chars to accommodate leading
"0x"
2014-04-29 15:31:50 +09:30
Andrew Bettison
e80cce72a0 Configurable MOTD (Message of the Day) on HTTPD root page
Also improve root page HTML: change <br> to <br />
2014-04-29 13:57:29 +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
d022bbdf27 New config option: server.config_reload_interval_ms 2014-04-16 18:24:16 +09:30
Andrew Bettison
2716228074 Add server watchdog and config reload test 2014-04-16 18:06:27 +09:30
Jeremy Lakeman
23cb4600e2 Improve VOMP testing 2014-04-10 11:14:46 +09:30
Andrew Bettison
53c1b1c04c Filesystem Heirarchy Standard (FHS) paths
If no instance directory specified, then use paths like
/etc/serval/serval.conf
/var/cache/serval
/var/log/serval
/var/run/serval
etc. for files, instead of all in a single directory.

Log all directory creation as INFO messages.

Interpretation of log.file.directory_path has changed slightly.

Updated servald configuration tech doc.
2014-03-26 15:35:43 +10:30
Jeremy Lakeman
ee68856878 Reduce log spam from debug.rhizome 2014-03-12 14:32:59 +10:30
Andrew Bettison
0bef066949 Store Rhizome external blob files in "blob" subdirectory
This will make issue #50 a bit easier to tackle
2014-03-07 16:55:38 +10:30
Jeremy Lakeman
33cbc98300 Add proc files for http server & mdp udp ports 2014-02-24 17:15:28 +10:30
Jeremy Lakeman
7ed6be3690 Introduce basic vomp console test 2014-02-19 16:39:05 +10:30
Andrew Bettison
015ed0b181 Refactor to rename "Rhizome HTTP server" to "HTTPD server"
Move HTTPD start/stop/dispatch logic from rhizome_httpd.c into new
httpd.c

Rename config.debug.httpd -> config.debug.http_server
Rename config.debug.rhizome_httpd -> config.debug.httpd
Rename config.debug.rhizome_nohttptx -> config.debug.nohttptx
2014-02-03 15:56:07 +10:30
Jeremy Lakeman
68421db114 Add msp debug flag 2014-01-09 15:06:35 +10:30
Andrew Bettison
34188fa489 Replace config 'rhizome.external_blobs' with 'rhizome.max_blob_size' 2013-12-30 16:30:43 +10:30
Jeremy Lakeman
d45470ce81 Refactor radio link for better encapsulation 2013-11-27 13:13:08 +10:30
Jeremy Lakeman
1681abd620 Increase default mdp timeout & make it configurable 2013-11-27 13:10:11 +10:30
Jeremy Lakeman
ad33264834 Rename mavlink to radio_link
- split link state from slip structures and encapsulate it completely
- allocate interface specific buffers on demand
2013-11-27 13:09:26 +10:30