Commit Graph

349 Commits

Author SHA1 Message Date
Andrew Bettison
cf9e0b4730 Keep AF_UNIX and file-based interfaces up whenever config re-loads
Whenever the daemon re-loads its config, it keeps any socket-based
(AF_INET) SOCK_DGRAM interfaces open that are matched by the new config,
but it used to close and then re-open all local (AF_UNIX) interfaces and
file-based interfaces such as SOCK_FILE dummy files and SOCK_STREAM
device files.  This made it very difficult to develop the new
'routejava' test suite, because the Java API test harness always causes
a config re-load when it sets the REST API user/password in the config,
which caused the local socket interfaces to bounce, which interfered
with the reachability of nodes.

Now, local socket and file-based interfaces remain up after a config
re-load, as long as they are still matched by the new configuration.

Added INFO messages for interfaces that remain up after a config
re-load, and tweak interface up/down INFO messages to be consistent.
2018-04-05 18:12:23 +09:30
Jeremy Lakeman
d844b0f6bd Reduce coupling with console, dna_helper, monitor & directory_client features 2018-04-03 14:32:06 +09:30
Andrew Bettison
9ef7d33d69 Log more debug in MDP_ROUTE_TABLE request 2018-03-27 09:06:41 +10:30
Andrew Bettison
98ec1c9608 Redesign the Keyring REST API (fixes #132)
The new API follows REST rules by using the proper request verbs:
POST, PUT, PATCH and DELETE, instead of just GET.

The legacy GET-only API is still supported for backward compatibility,
but not longer tested or documented.

Add a new query-single-identity operation.

Implement the lock-single-identity operation, which until now had been
documented but not yet implemented.  Whenever a single identity is
locked (released), any other unlocked identities with the same PIN are
flagged to indicate that the PIN is not "fully" unlocked, so that the
next time the PIN is entered, the slot decryption is re-tried for
non-loaded identities, and the locked identity will be unlocked again.

Update the 'keyring' and 'keyringrestful' test scripts:
- refactored to reduce curl command-line clutter in test cases
- now tests the redesigned request verbs and paths
- added a test for GET /restful/keyring/SID
- added a test for PUT /restful/keyring/SID/lock
2018-03-19 18:06:23 +10:30
Andrew Bettison
8242ca0a00 Fix a bug in MDP_IDENTITY request handling
The LOCK and UNLOCK by PIN requests were acting on the supplied PIN
and also the empty PIN, due to a bug in ob_get_str_ptr(), which returned
an empty string instead of NULL after reaching the end of the string
list.
2018-03-09 16:56:36 +10: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
Jeremy Lakeman
0382e7990e Enable a more graceful shutdown of the server in most cases 2017-09-12 15:37:52 +09:30
Jeremy Lakeman
e158a38137 Clean up a number of memory leaks, as revealed by clang's sanitiser 2017-09-11 14:09:27 +09:30
Jeremy Lakeman
5f1c476249 Fix fd in log message 2017-06-28 15:09:52 +09:30
Jeremy Lakeman
2540c9e633 Cause rhizome add to poke the daemon and trigger all bundle add notifications 2017-03-06 16:12:55 +10:30
Jeremy Lakeman
39fbcc475e Track call stats of mdp port handlers 2017-02-28 14:32:08 +10:30
Andrew Bettison
ccacd19dfa Add global keyring assertions
Many functions require that the global 'keyring' pointer is set,
but there were no assertions to document this precondition.
2016-11-14 11:28:08 +10:30
Jeremy Lakeman
5b75221c91 Fix compiler warnings when building with android ndk 13b 2016-11-07 10:38:23 +10:30
Jeremy Lakeman
9feda5258c Allow client to specify external interface name in config match expression 2016-10-25 16:04:41 +10:30
Jeremy Lakeman
65831e31d4 Report the state of each network interface in routing table 2016-10-20 08:48:35 -04:00
Jeremy Lakeman
4e50b1716c Test reachable bit flags about ourself 2016-09-20 15:04:28 +09:30
Jeremy Lakeman
ecb79d818f Refactor storage of binary values to enable reuse 2016-09-13 15:25:39 +09:30
Andrew Bettison
2cfdafdb56 Add some MDP client DEBUG trace statements 2016-09-06 13:31:38 +09:30
Jeremy Lakeman
b6256ea89a Add identity_t type & rename signing key api to identity. 2016-08-16 12:22:13 +09:30
Jeremy Lakeman
83b6ecb453 Roll an in memory identity when the keyring is empty 2016-08-02 11:01:32 +09:30
Jeremy Lakeman
a71c7ce698 Add signing key to routing messages 2016-07-25 15:50:52 +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
6feaddf24d Rework route print command to use newer mdp api, show live updates & deprecate monitor messages 2016-05-10 10:28:14 +09:30
Jeremy Lakeman
9b5b82d972 Allow port reuse for mdp bindings 2016-05-09 11:10:50 +09:30
Jeremy Lakeman
5feb67512c Generate encryption key from signing key for new identities 2016-05-09 10:51:52 +09:30
Jeremy Lakeman
bd47a8eb60 Use libsodium for retrieving random bytes 2016-05-09 10:32:04 +09:30
Jeremy Lakeman
e15e332072 Swap from included nacl to host libsodium 2016-05-09 10:32:04 +09:30
Jeremy Lakeman
231ab257e4 Define internal port bindings with section linking tricks 2016-03-07 15:50:34 +10:30
Jeremy Lakeman
c1947cf774 Add prior hop SID to route print output 2016-03-02 10:51:16 +10:30
Andrew Bettison
c3375d0501 Fix MDP client packet receive bug on OSX
Was failing because recvmsg(2) on OSX does not nul terminate the
pathname of local (AF_UNIX) sockets in the returned sockaddr buffer.
Zerofilling the buffer before calling recvmsg() does the trick.

In the process, improved debug and error logging, replacing
recvwithttl() with recv_message() and recv_message_frag().  The
mdp_net.c source file was retired.
2016-01-19 04:05:46 +10:30
Andrew Bettison
a060642fdb Add strbuf_local_buf() macro 2015-11-02 10:11:41 +10:30
Jeremy Lakeman
298849b25b Add buffer space for MDP MTU & headers for MDP_INTERFACE 2015-07-20 16:48:17 +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
Jeremy Lakeman
e97f7c4e29 Fix vomp stun tests
- Don't trust stun responses about 3rd parties
- Only ack neighbour links via 1hop destinations (not multi-hop routes)
- Don't override network destinations that were manually supplied
2015-06-22 14:50:28 +09:30
Jeremy Lakeman
9658d4527b Don't attempt to retransmit routing link information 2015-06-15 15:35:25 +09:30
Jeremy Lakeman
51ed6162dd Add support for running and stopping servald from a JVM thread
fdpoll will now run a callback when about to sleep / woke up.
A new Java interface to indicate server started / sleeping / waking up.
An android implementation may allow the CPU to sleep.
If there's a java exception the server will try to shutdown.
Calling servald stop is currently undefined.
2015-05-25 11:46:37 +09:30
Jeremy Lakeman
a9b9f51a9f Add support for mdp clients to provide a link layer packet transport 2015-03-02 15:44:34 +10:30
Andrew Bettison
005489ab40 Improve overlay_mdp.c log error messages 2014-11-11 12:57:15 +10:30
Jeremy Lakeman
851144ea0a Refactor keyring identity iteration 2014-10-31 15:19:59 +10:30
Jeremy Lakeman
bcd9575b54 Fix minor compilation issues on CentOS.
- ensure size_t is defined when compiling xprintf.h
- declare overlay_route_record as a union field in overlay_route_record to avoid alignment issues
- set the result of fwrite and fputs
- support slightly older git version
2014-10-20 12:35:21 +10:30
Jeremy Lakeman
7474e8afea Fix mdp support and Java API for binding to all keys in the keyring 2014-09-16 11:22:26 +09:30
Jeremy Lakeman
6aa6aa69eb Immediately register unlocked identities 2014-09-08 11:25:35 +09:30
Jeremy Lakeman
a37db8e958 Move most console commands to other files 2014-08-25 16:03:30 +09:30
Jeremy Lakeman
a9545ea004 Display where packets came from in debug messages 2014-06-26 16:47:23 +09:30
Jeremy Lakeman
afd31fe12c Ensure a race condition while starting servald only starts one process 2014-06-11 09:01:56 +09:30
Jeremy Lakeman
66f266a0c0 Fix OSX specific issues 2014-06-05 14:57:53 +09:30
Jeremy Lakeman
6d4ad0e150 Rework scheduler to allow for lazy but important alarms 2014-06-04 17:13:08 +09:30
Jeremy Lakeman
b6de3fcd34 Only send rhizome sync packets when we have neighbours 2014-05-30 15:03:22 +09:30