Commit Graph

475 Commits

Author SHA1 Message Date
Andrew Bettison
2d09ec545e Improve configuration dump to log
Refactor much of the new code in log.c

Add new functions: cf_load_strict() and cf_reload_strict() for use by the
server, which does not want to overwrite its in-memory config at all if there
is any defect in the config file.  However, commands always want to overwrite
the default in-memory config, even with a defective config file, so that
logging has a chance to succeed.

Added `log_format.dump_config` boolean config option
2013-03-29 00:22:08 +10:30
Andrew Bettison
95b0c028f2 Log to file, Android and stderr simultaneously
Indepent configuration of show_pid, show_time and log level for each
destination

Update test scripts for new config options

Include xprintf.c in MDP client source files (now used by log.c)
2013-03-27 16:17:38 +10:30
Andrew Bettison
a88234ce9d Add optional filter args to 'help' command 2013-03-25 12:05:26 +10:30
Andrew Bettison
300ec986f1 Fix warnings from gcc 4.6.3 2013-03-18 16:48:15 +10:30
Andrew Bettison
b17f5a6f63 Servald version string from git describe 2013-03-12 14:03:33 +10:30
Andrew Bettison
1d1f7a37a4 Fix Solaris SIGBUS bug in MDP ping
Also fixed non-portable (endian dependent) code
2013-03-07 14:54:40 +10:30
Andrew Bettison
8771d6181b Merge branch 'naf2-logging' into 'development' 2013-03-01 17:32:57 +10:30
Andrew Bettison
ae787339ec Improve "config dump" command
All STRUCT cf_fmt_config_xxx() functions omit invalid values, silently
if the invalid value is the default, otherwise with a non-CFOK return
value.

The "config dump --full" option includes all options with valid values,
otherwise omits options having default values.
2013-02-28 15:18:48 +10:30
Andrew Bettison
46eeacb823 Improve new "config dump" command
No more SEGV.  Omits invalid (default) values.  Logs unconditional DEBUG
output, to be removed before merging into development.  Still missing
cf_cmp_ functions to prune out default values.

Improved config Object Model iterator logic to barf on internal NULL
nodes.
2013-02-27 16:26:07 +10:30
Jeremy Lakeman
ee95e47d1f Add rhizome export commands that don't try to decrypt file contents
export [bundle/manifest/file]
extract [bundle/file]

"dump file" has been replaced with "export file".
2013-02-27 11:39:23 +10:30
Andrew Bettison
6eb08ae805 Add new "config dump" command - not working yet
Add cf_fmt_xxx() functions for converting configuration structs into a
config object model tree.
2013-02-26 18:09:08 +10:30
Andrew Bettison
5ac6bd8834 Fix compile error on Linux 2013-02-22 12:06:21 +10:30
Jeremy Lakeman
90386ce1b1 Merge remote-tracking branch 'origin/development' into serial
Conflicts:
	rhizome.h
	rhizome_database.c
	rhizome_fetch.c
	rhizome_store.c
2013-02-20 17:23:03 +10:30
Jeremy Lakeman
e5fa357f07 Add slip test to automated testing 2013-02-20 16:18:59 +10:30
Jeremy Lakeman
bb8b3d6376 Add new mdp trace command 2013-02-20 16:18:58 +10:30
Jeremy Lakeman
10234018b0 Add interface name to route print output 2013-02-20 16:18:58 +10:30
gardners
f52214e229 make return codes of "servald stop" discriminate between different
failure modes (makes it easier to debug some test failures)
2013-02-20 16:18:57 +10:30
gardners
2252fdcaa7 created tool for automatically finding IN()s without matching
OUT()s or where return() is used instead of RETURN().
Added OUT() to end of all functions using IN() that lacked it to
make it easier to statically analyse this invariant.
Fixed several return instead of RETURNs detected through use of
this tool. #49
2013-02-20 16:18:56 +10:30
Andrew Bettison
390655580d Add 'rhizome delete' and 'rhizome clean' commands
sqlite_void_exec() and its ilk now return the count of changed rows, not
just zero, on success

sqlite_exec_prepared() and its ilk now return the count of rows (number
of step results SQLITE_ROW), instead of just zero, on success

rhizome_clean() function now produces an optional report of its changes

rhizome_fail_write() and rhizome_finish_write() now log WARNings not
ERRORs if the SQL DELETE FROM FILES or DELETE FROM FILEBLOBS statements
fail

Refactor rhizome_open_read() to use sqlite_exec_int64()

Ensure that 'rhizome extract' and 'rhizome dump' commands return exit
status of 1 in "not found" conditions, not 255, which is reserved for
errors

Test cases for four new commands: 'rhizome delete bundle', 'rhizome
delete manifest', 'rhizome delete payload' and 'rhizome delete file'
(no test case for 'rhizome clean' yet)
2013-02-20 15:37:09 +10:30
gardners
f465f3a9ee Add lots of profiling to assist in debugging
- made some debug output conditional.
- make it possible to debug slip decoding without getting swamped by other output.
- Improve reporting of unnamed schedule() calls.
- always collect performance statistics, and report on any excess
  use (>1sec in every 3), even if debug.timing is not enabled.
- include file size information in Rhizome transfer messages.
- reduce output when debug.rhizome_rx is set.
2013-02-20 15:36:30 +10:30
gardners
042cfc3fa1 add debug.rejecteddata option for reporting bad packets/manifests
etc.
2013-02-20 15:36:26 +10:30
gardners
6a620fe221 added command line test for serial encapsulation.
renamed "crypt test" to "test crypt" for consistency.
2013-02-20 15:36:26 +10:30
Andrew Bettison
c176d23726 Add 'sid:' field to output of "reverse lookup"
Use sid_t in more places
2013-02-15 19:34:24 +10:30
Andrew Bettison
788b3e37b2 Fix JNI argv parsing: throw exception on NULL
Add new 'jni' test case to ensure this works
2013-02-15 19:33:12 +10:30
Andrew Bettison
c42260f5f9 Replace "add did" command with improved "keyring add did"
Output is same format as "keyring add" command

Fixed minor bug in rolling a random DID -- last byte was not random

Some code improvements, including better support for sid_t
2013-02-14 16:06:01 +10:30
Andrew Bettison
e86a129d49 Refactor: rename some cli.h structs
Now all symbols defined in cli.h start with or contain "cli_"
2013-02-13 17:43:24 +10:30
Andrew Bettison
f66a894a63 Improve keyring PIN handling
Replace explicit [<pin,pin...>] command-line arguments with --entry-pin=<pin>
options.  Update test scripts accordlingly.

Add --keyring-pin=<pin> option (with one test case).
2013-02-13 16:49:52 +10:30
Andrew Bettison
fcb6600cd6 Rewrite command-line parser
Now supports optional args followed by non-optional.
2013-02-12 18:00:37 +10:30
Jeremy Lakeman
3a93fee8a5 New JNI interface to better support cursor result sets 2013-01-23 14:43:50 +10:30
Jeremy Lakeman
ad01836d0e Use database query to respond to rhizome list, add name argument 2013-01-17 11:45:45 +10:30
Jeremy Lakeman
b25ff45438 Importing the same bundle twice returns duplicate flag 2013-01-15 10:32:48 +10:30
Jeremy Lakeman
2d66a150b8 Output manifest version for consistency 2013-01-14 09:23:29 +10:30
Jeremy Lakeman
5a82bfcf31 Add support for importing and exporting a file with an appended manifest 2013-01-11 14:30:52 +10:30
Jeremy Lakeman
7825f9dbd2 Combine manifest and file extraction into one method that can also do both 2013-01-11 14:30:51 +10:30
Jeremy Lakeman
9d6b1ae660 Treat empty bsk the same as null 2013-01-11 14:29:40 +10:30
Jeremy Lakeman
2b480c1d1a Reinstate filesize and hash file extract output 2013-01-04 12:01:40 +10:30
Jeremy Lakeman
fd96c5bd76 Add bsk to correct command 2013-01-04 12:01:39 +10:30
Jeremy Lakeman
28a05baa54 Enable encryption of rhizome payloads 2013-01-03 16:12:24 +10:30
Jeremy Lakeman
dc43b83c80 Tidy up rhizome secret handling to improve reusability 2013-01-03 12:14:13 +10:30
Jeremy Lakeman
8b045dd1a6 Extract files based on the manifest id
Renamed rhizome extract file to rhizome dump file
Added rhizome extract file [manifest] [filepath] [pins]
Modified tests to use the appropriate command, assuming that MeshMS payloads will be encrypted
2013-01-02 12:58:05 +10:30
Jeremy Lakeman
6c7ba438a3 Refactor rhizome extract manifest into more useful methods 2013-01-02 11:15:03 +10:30
Jeremy Lakeman
898cddfcd3 Tidy up rhizome extract return code 2012-12-31 13:21:37 +10:30
Jeremy Lakeman
72bc597e92 Add encryption support to writing of rhizome content 2012-12-27 09:39:10 +10:30
Jeremy Lakeman
f64de66b34 Refactor add via HTTP to be equivalent to command line add 2012-12-20 15:36:07 +10:30
Jeremy Lakeman
181d1363f1 Migrate command line import to new storage api 2012-12-19 16:16:49 +10:30
Jeremy Lakeman
c5d76a057f Add storage api for importing files 2012-12-18 10:51:12 +10:30
Jeremy Lakeman
b2a0f8caf5 Rhizome add streams directly into the database 2012-12-17 15:41:27 +10:30
Andrew Bettison
8d5862d599 Server daemon reloads config every 1 sec 2012-12-14 16:48:12 +10:30
Andrew Bettison
fe3e7da5c6 Fix configuration loading logic
If configuration is bad, do not execute commands except those with the
PERMISSIVE_CONFIG property.

Flush log buffer immediately after clearing cf_limbo flag, in case there are no
further log messages that would cause the flush.  (Fixes bug that an unrecognised
command produced no log output.)

More block comments in log.c.
2012-12-14 16:48:12 +10:30
Andrew Bettison
476479cdb4 Permissive log file loading for 'stop' and 'help' commands 2012-12-13 17:36:14 +10:30
Andrew Bettison
5985df751d Overhaul debug flags
Replace debugflags_t and DEBUG_XXX bit masks with config schema "debug.xxx"
entries.

No more support for "debug.all".
2012-12-11 15:59:46 +10:30
Andrew Bettison
96d524200c Support 'config get' var pattern matching 2012-12-10 15:26:35 +10:30
Andrew Bettison
96e686c680 servald 'stop' command loads config permissively 2012-12-07 15:57:40 +10:30
Andrew Bettison
8425882ffc Merge branch 'newconfig' into 'master'
Conflicts:
	commandline.c
	conf.h
	dataformats.c
	log.h
	overlay_address.c
	overlay_interface.c
	packetformats.c
	rhizome.c
	serval.h
	tests/directory_service
	vomp_console.c
2012-12-07 14:09:55 +10:30
Andrew Bettison
b4f6aa5ea2 Improve 'config schema' output to include NODE parsing functions 2012-12-07 10:57:05 +10:30
Andrew Bettison
21509e0b67 Add 'config schema' command to dump schema
That was easy.
2012-12-06 17:54:30 +10:30
Andrew Bettison
fe042bfa64 Servald 'config [ set|del ... ] ... ' command
Update all test scripts to avoid repetitive executeOk_servald invocations.
2012-12-06 12:31:19 +10:30
Jeremy Lakeman
3dfd64f4da Add manually triggered network scan command 2012-12-05 15:13:47 +10:30
Andrew Bettison
93c38a764d Improve servald 'config' 'set' and 'del' commands
Return exit status 2 if the new config is invalid in any way.
2012-12-04 18:20:53 +10:30
Andrew Bettison
71ed78e058 Make all 'config' tests pass
Change a test case: configuration options are now case sensitive.

Fix config file load and parse logic in conf.c, always copy 'debug' flags
from config.debug.

The config schema 'interfaces' option is no longer MANDATORY.

Introduce new CLIFLAG_PERMISSIVE_CONFIG to supress bad-config ERROR messages
from the 'config set' and 'config get' commands.

Refactor cli_execute() into cli_parse() and cli_invoke().  Use *const* struct
command_line_option everywhere.
2012-12-04 16:52:49 +10:30
Andrew Bettison
caa209fc1d Integrate new config into servald
Not passing any tests yet, but compiles and links and simple uses do not
SEGV.
2012-12-04 14:12:28 +10:30
Jeremy Lakeman
d5f78bcffe Rework reachable link flags for simpler bitmask tests 2012-11-30 14:38:09 +10:30
Jeremy Lakeman
e0878644fe Add command to dump routing table 2012-11-28 15:43:58 +10:30
Jeremy Lakeman
f159e15901 Simplify payload length storage 2012-11-28 15:43:57 +10:30
Jeremy Lakeman
7322fbce71 Fix ping message format 2012-11-20 10:25:33 +10:30
Andrew Bettison
21a0f31ae4 Merge branch 'whacktmps' into 'master' 2012-11-15 13:41:45 +10:30
Andrew Bettison
6395f757cc Fix bugs in earlier conf/log recursion logic
Reinstate better recursion control in conf.c, remove from log.c.

Add <kludge> comment to "config set" code, add the same kludge to "config
del".
2012-11-15 12:38:17 +10:30
Andrew Bettison
f2d6c6d522 Kludge "config set" to fix Batphone upgrade bug 2012-11-14 13:16:23 +10:30
Jeremy Lakeman
7c6cdac1b2 Improve command line usage information 2012-11-14 12:27:47 +10:30
Jeremy Lakeman
10bde11918 Remove resolution of peer details from node info command 2012-11-14 12:17:41 +10:30
Jeremy Lakeman
dd93f201e3 Add separate reverse lookup command 2012-11-14 12:17:14 +10:30
Andrew Bettison
5751569b59 Rhizome extract manifest to '-' writes to output
Instead of specifying a file path, if the file is given as '-' then the content
of the manifest is output in the 'manifest' key-value pair instead of written
to a file.
2012-11-07 20:29:12 +10:30
Andrew Bettison
00f9130f16 Get rid of unwanted DEBUG line 2012-11-07 17:27:40 +10:30
Andrew Bettison
5185c944c9 JNI interface returns byte[] instead of String
This allows the output fields of any command to contain nul characters, which
paves the way for extracting a manifest or other binary data directly instead
of having to write it into a temporary file.
2012-11-07 17:12:04 +10:30
Andrew Bettison
4450116472 Refactor string functions, add str_fromprint()
Move lots of non-Serval-specific string functions from "serval.h"/dataformats.c
to "str.h"/str.c.

Add str_fromprint() function that reverses the effect of toprint(): interprets
escape sequences in the source string "\n\t\r\0\xHH\\" and replaces them with a
single char in the destination string.
2012-11-07 16:42:45 +10:30
Jeremy Lakeman
de95bb3971 Gracefully disable rhizome if the database cannot be opened
- close database after every command line operation
- don't cache rhizome enabled configuration
- don't send advertisements unless the database is open and the web server is running
- don't provess advertisements unless the database is open
2012-10-29 13:05:03 +10:30
gardners
499c4018bf Imported ref10/ implementation of crypto_sign from supercop-20120525
as recommended a while back by Dan Bernstein as offering the fastest
implementation of the crypto_sign() primitives for ARM.
Indeed this implementation IS faster. See comparison below for a
Rock 500 handset (800MHz(?) ARM6, no NEON):

Original ref/ implementation on an R500 stock rom (non-rooted)::
mean signature generation time = 96.80ms
mean signature verification time = 272.20ms

ref10/ implementations on an R500 stock rom (non-rooted):
mean signature generation time = 4.00ms
mean signature verification time = 13.00ms

Approximately 20x speed up, just like that :)
2012-10-18 17:26:48 +10:30
Andrew Bettison
c43a7ba8e6 Issue #17, improve "rhizome extract manifest" command
Add ".readonly" output field, add logic to detect bundle author and update
MANIFESTS table 'author' column accordingly.

Add two 'rhizomeops' test cases to deal with authorless logic.

Rename some 'rhizomeops' test cases for consistency and to help filtering.
2012-10-15 16:48:04 +10:30
Andrew Bettison
eff3e9ec8f Issue #17, fix new 'rhizomeops' test
Was incorrectly supplying bundle secret to "rhizome add" command.
2012-10-15 14:01:48 +10:30
Andrew Bettison
3f1f495d68 Issue #17, overhaul manifest author crypto logic
Add test case for new feature of the "rhizome add" command: if the author SID
is not specified (empty arg) then it searches the keyring for the author.

Removed "authorSid" argument from several functions that also take a struct
rhizome_manifest * arg, since the author, if known, is now supplied in the
struct.

Improve return value handling and refactored some rhizome crypto code.
2012-10-11 17:58:24 +10:30
Jeremy Lakeman
b22e3f1964 Add hop count to mdp ping
- Allow mdp client to specify ttl
- Copy ttl into and out of overlay frame
2012-10-10 16:22:31 +10:30
Andrew Bettison
3678522872 Issue #17, add AUTHOR column to Rhizome MANIFESTS table
Replace ".selfsigned" column with ".author" and ".fromhere" columns in
output of "rhizome list" command.  (Note that a "sender" column is
already present.)

Add 'author' field to struct rhizome_manifest.

Log all fully rendered SQL statements on DEBUG_RHIZOME.

Update 'rhizomeops' test cases and improve the assert_rhizome_list()
test function to be able to assert authorship of files.
2012-10-09 17:48:06 +10:30
Jeremy Lakeman
1de2bc8f23 Fix replying to broadcast mdp ping 2012-10-09 17:03:17 +10:30
Jeremy Lakeman
1f379ea209 Add and preserve QOS bit flags in packet header 2012-10-09 16:17:07 +10:30
Andrew Bettison
6954325b04 Server process no longer becomes a zombie on Android
Fixes #21.  The problem was caused when the double-fork logic used in "servald
start" was clobbered in 5103176.  This meant that the servald daemon process on
Android no longer had a PPID=1, but the PID of the long-lived
"org.servalproject" parent process which called the JNI entry point.  Killing
the servald process then caused it to become a zombie process, since the
org.servalproject does not habitually call wait(2).  That caused the "servald
stop" logic to send five SIGHUPs to the zombie without any error, making it
appear that the process was not dying.

Reinstated the double-fork logic and added a new test case to ensure that the
daemon process does not become a zombie on being killed prematurely.
2012-10-08 17:20:19 +10:30
Jeremy Lakeman
c47e99d097 Fix issue #23, regression in 'id' command 2012-10-08 14:59:58 +10:30
Jeremy Lakeman
7af919b02b Merge commit 'ad3b31677540b638430eba0242457d788e8e5915'
Work on devices without sdcards
2012-10-08 09:40:43 +10:30
Andrew Bettison
89343c69cd Merge branch 'rhizomedirect' into 'master' 2012-10-05 17:45:30 +09:30
Romain Vimont (®om)
ad3b316775 Do not try to open rhizome database if rhizome is disabled 2012-10-04 12:34:49 +02:00
gardners
dc3137707f rhizome import bundle from file sans-manifest via http now works.
Must be enabled by using rhizome.api.addfile.*
Certainly polishing to be done, including using filename supplied
during HTTP POST.  Now to fix that, and make it all work with
final rhizomeprotocol test case.
rhizomeprotocol test cases 8 and 9 currently fail post-merge. #9
2012-10-03 16:13:06 +02:00
gardners
92a5423b17 Moved rhizome direct imports to be in-process instead of
out-of-process. rhizomeprotocol push test still fails.
Investigating. #9
2012-10-03 12:28:21 +02:00
gardners
d11109bca5 Improve rhizome direct push/pull/sync command line parsing and
use of configuration. Not yet finished, but allows multiple
rhizome direct peers and non-http URLs. #9
2012-10-03 12:24:22 +02:00
Jeremy Lakeman
4340d97475 Add simple peer count command 2012-10-03 16:21:47 +09:30
Jeremy Lakeman
32cd46c165 Simplify id peers command, hide mdp implementation details from node info 2012-10-03 16:21:06 +09:30
Jeremy Lakeman
9a7c18c9f6 Only parse incoming packets with port numbers matching our expected responses 2012-10-02 16:15:30 +09:30
Jeremy Lakeman
fa7719fbe8 Write simple vomp console client 2012-09-28 15:23:50 +09:30
Jeremy Lakeman
2a7bd28e51 Extend packet queue to allow sending multiple copies of the same payload for reliability 2012-09-28 11:28:01 +09:30
Andrew Bettison
14721fab19 Merge branch 'solaris' into rhizomedirect
All test cases pass on Solaris (see issue #16) except the 'jni' tests because
there is no Java compiler available on Solaris, and the new 'rhizomeprotocol'
tests from the rhizomedirect branch, which have always failed.
2012-09-27 17:38:16 +09:30
Jeremy Lakeman
ac3864ff20 Reuse command line parsing framework with monitor interface 2012-09-25 13:31:34 +09:30
Jeremy Lakeman
dc8a453b7f Add please explain message
- non-tick packets now include a poorly formed SELF_ANNOUNCE to correctly identify every packet sender
2012-09-20 10:28:01 +09:30
Jeremy Lakeman
481dc9218d Return an error code if ping didn't hear any responses, always log statistics 2012-09-19 14:16:06 +09:30
Jeremy Lakeman
23f1110120 Add optional ping counter 2012-09-19 09:48:12 +09:30
Jeremy Lakeman
f845a18312 Send DNA lookup requests to configured directory service 2012-09-14 17:04:36 +09:30
Jeremy Lakeman
6483d9e0ae Split client mdp functions so they can be built separately 2012-09-14 11:47:48 +09:30
gardners
6d725535f9 starting work on the actual synchronisation code for rhizome direct. 2012-09-07 22:53:16 +09:30
Jeremy Lakeman
cd67868d2a Reduce spam from lookups 2012-09-07 13:07:59 +09:30
gardners
d3f5c6e598 Merged rhizome direct httpd back into main rhizome httpd server.
bundles can be imported via HTTP POST multi-part form. #9
2012-09-06 13:21:13 +09:30
Paul Gardner-Stephen
bba6839656 Initial stab at porting to Solaris.
It compiles without warning (with CC=gcc) but doesn't link
because NaCL doesn't build yet.
2012-09-05 20:42:50 +09:30
Jeremy Lakeman
e05806f25e Separate routing calculation from resulting rules, refactor more code to use subscriber structure 2012-08-31 15:11:18 +09:30
Jeremy Lakeman
f6c899e107 Refactor overlay buffer interface to support simple parsing 2012-08-31 15:03:07 +09:30
Jeremy Lakeman
aa5706f9d7 Refactor routing node information to use new subscriber tree 2012-08-31 15:03:07 +09:30
gardners
2b29893a02 Initial work towards rhizome direct syncrhonisation functions #9 2012-08-31 12:58:37 +09:30
Andrew Bettison
d8fd9fa411 Refactor nanosleep(2) calls into sleep_ms() function 2012-08-21 13:35:33 +09:30
Daniel O'Connor
fc20a4768d Use get_self_executable_path to resolve our name when calling
exec otherwise it will fail when given a relative path as we
chdir to / before trying it.
2012-08-20 15:02:00 +09:30
Jeremy Lakeman
3ab79d8e5b Pass phone numbers in vomp call initiation 2012-08-13 14:01:57 +09:30
Daniel O'Connor
f453071251 Fix compilation in the non-JNI case 2012-08-10 16:55:38 +09:30
Jeremy Lakeman
f77e055988 Add timeout argument for dna lookup 2012-08-10 15:29:19 +09:30
Andrew Bettison
12d8bc0c12 Use new typedef time_ms_t everywhere 2012-08-09 12:14:32 +09:30
Andrew Bettison
f37ec5af09 Reduce use of stderr in many places
serval_packetvisualise() is now replaced by DEBUG_packet_visualise() which uses
logging system not stderr (so now it will appear in Android log).

Replaced several fprintf(stderr,...) with DEBUGF(...).

Command line only prints a full help message on "help" command -- a command
parse failure simply informs the user about the "help" command.
2012-08-01 17:54:02 +09:30
Andrew Bettison
240be25793 Replace overlay_gettime_ms() with gettime_ms() 2012-07-30 17:22:38 +09:30
Daniel O'Connor
09d0fecf28 Remove carnal knowledge of conf.c from serval.h and commandline.c by providing a function to set the instance path override. 2012-07-29 18:58:41 +09:30
Andrew Bettison
8db737ee6f Quieten startup logging a bit 2012-07-27 19:59:16 +09:30
Andrew Bettison
2152c9267f DEBUG_VERBOSE log messages for all command-line commands 2012-07-27 18:04:46 +09:30
Andrew Bettison
04b95d2590 Merge branch 'andrew' into 'master' 2012-07-25 18:04:16 +09:30
Jeremy Lakeman
5ec739c712 Add performance timing debug option 2012-07-25 13:33:30 +09:30
Andrew Bettison
6de247e576 Improve diagnosis of SEGV failures in tests 2012-07-24 15:39:36 +09:30
Andrew Bettison
f472ac9a8d Lots of 'dnahelper' tests, all pass but one
Test fails because DNA helper logic does not yet impose a timeout on receiving
the "DONE" ACK after a request.
2012-07-23 18:29:57 +09:30
Andrew Bettison
3e0f8df18a Fix bug in DID parsing, affects "set did" command 2012-07-23 15:17:21 +09:30
Andrew Bettison
30567c1d34 Start writing systematic 'dnahelper' tests 2012-07-23 12:23:17 +09:30
Andrew Bettison
0e5c5e0e98 More work on dnahelper, almost done
Servald starts DNA helper, receives startup ACK, sends requests, receives
responses, handles malformed helper responses, echoes dnahelper stderr lines to
log, sends MDP reply packet, waits for dead helper process, all asynchronously.
Shuts down helper process during servald shutdown.

Remaining issues:
 - Does not impose a timeout on helper responses.
 - Only the first URI is reported by the "dna lookup" command.
2012-07-20 18:17:43 +09:30
Andrew Bettison
5aac5a3854 Unfinished dnahelper implementation 2012-07-18 19:16:30 +09:30
Andrew Bettison
b50943d09c Fix handling of empty payload (filesize = 0)
Do not add 'filehash' var to manifest if filesize=0
Do not accept 'filehash' var when parsing manifest with filesize=0
When responding to a new rhizome advertisement, do not try to HTTP
request a payload if filesize=0, just import the manifest directly
Various operations, eg "rhizome file add", do not report 'filehash'
fields where 'filesize' is zero
Do not delete rows from MANIFESTS table which have empty filehash
Various related bug fixes
2012-07-16 18:40:30 +09:30
Andrew Bettison
208a95a233 Replace validateSid() with str_is_subscriber_id() 2012-07-12 16:14:25 +09:30
Andrew Bettison
d2898ee22c Add output fields to 'keyring add' command 2012-07-06 13:17:53 +09:30
Andrew Bettison
ab64b08ceb Rewrite config file code
Gets rid of rotor in confValueGet() and duplicate config file parsing code
Currently fails three tests
2012-07-04 18:57:02 +09:30
Andrew Bettison
68ef34c119 Add 'id allpeers' command to facilitate testing 2012-07-04 12:06:15 +09:30
Andrew Bettison
2c87039307 Replace overlay_render_sid() with alloca_tohex_sid()
To eliminate timebomb bugs caused by rotor wraparound
2012-07-03 17:59:30 +09:30
gardners
02ca21a601 CHANGED DNA REPLY PACKET FORMAT BREAKING BACKWARDS COMPATIBILITY
... as part of working on work on DNA helper callout facility.
(DNA replies now contain a token that can be used to match them
against DNA requests as a happy side-effect).
2012-07-03 16:45:03 +09:30
Jeremy Lakeman
495de9e0ec Add more profiling instrumentation 2012-07-03 15:50:04 +09:30
Andrew Bettison
8020ea3b74 Merge branch 'eventscheduler' into master
Conflicts:
	commandline.c
	monitor.c
	overlay.c
	overlay_interface.c
	overlay_packetformats.c
	rhizome_fetch.c
	rhizome_http.c
	rhizome_packetformats.c
	serval.h
	server.c
	testdefs.sh
	testframework.sh
	tests/dnaprotocol
	tests/server
2012-07-03 10:26:22 +09:30
Andrew Bettison
fc8df7d5d4 Config options for tick duration 2012-07-02 12:26:01 +09:30
Andrew Bettison
b368a3aab4 Add confValueGetInt64() function 2012-06-28 18:19:36 +09:30
Andrew Bettison
b9836af8a2 Fix debug logging in overlay_interface.c
Also fix bug that closed the logfile when forking the server process.
2012-06-28 17:34:21 +09:30
Andrew Bettison
9625190c6a Improve debug code:
Debug bit mask is unsigned int everywhere.
Refactor DEBUG() macros a bit.
Add SERVALD_DEBUG_FILE env var to support test scripts.
Test defs put instance directories under $TFWVAR not $TFWTMP.
2012-06-28 15:24:43 +09:30
Andrew Bettison
3822d067e7 Remove unnecessary double-fork from server start 2012-06-26 17:27:19 +09:30
Andrew Bettison
889f9c4628 Re-instate prior server start code
Do not use server_probe().
Use setsid() instead of setpgrp().
Still uses double-fork technique, as advised in setsid(2) man page.
Return exit status 10 if already running, instead of logging an error and exit
status 255.
2012-06-26 16:07:24 +09:30
Andrew Bettison
19f7e32ba7 Re-instate prior server start code
Uses setsid() instead of setpgrp().
Still uses double-fork technique, as advised in setsid(2) man page.
Does not use server_probe().
2012-06-26 15:46:10 +09:30
Jeremy Lakeman
0ca4c16f39 Refactor node info to ignore stale responses without sending another request 2012-06-26 11:20:00 +09:30
gardners
b40a468276 Merge branch 'eventscheduler'
Conflicts:
	monitor.c
	serval.h
2012-06-25 16:50:23 +09:30
Andrew Bettison
1fbf957a9d Clean up compiler warnings in commandline.c 2012-06-25 15:06:35 +09:30
Daniel O'Connor
05d8ac5d05 Don't treat the server already running as an error otherwise the Java code complains.
Emit a useful error if we couldn't get the PID.
2012-06-25 14:14:33 +09:30
Daniel O'Connor
8ad51554b4 Use the right variable to display the PID. 2012-06-25 14:11:16 +09:30
Daniel O'Connor
b0dad81b0c Don't call daemon as the parent can't exit in JNI otherwise bad things will happen.
Copy the code for daemon from FreeBSD 8.x instead of the flying circus that was there before.
2012-06-25 14:01:50 +09:30
Daniel O'Connor
5103176d39 Remove server_probe() and use daemon() instead of a hand rolled version.
- server_probe() assumes abstract name space sockets.
- The hand rolled daemon doesn't work properly on BSD.
2012-06-22 16:05:43 +09:30
Andrew Bettison
274e5c007c Merge branch 'master' into andrew
Conflicts:
	log.c
2012-06-22 11:18:48 +09:30
gardners
0254ca0ab8 made dnaprotocol test more rigorous to ensure it really returns
results from each SID/servald instance.
Fixed bug in "keyring list" that was returning keyrings in
lower case instead of normalised form using overlay_render_sid()
2012-06-21 16:36:38 +09:30
gardners
2cb84bb8db various fixes to new DNA URI response relating to parsing replies
that lacked DID and/or name field.
2012-06-21 16:36:37 +09:30
gardners
e5394dd143 added stubs for DNA lookup helper app (not yet complete).
cleaned up some unused variables.
2012-06-21 16:35:28 +09:30
gardners
3281f2c652 fixed introduced bug where "node info" failed to provide automatic
resolution of DIDs and names for local identities.
2012-06-21 11:45:20 +09:30
gardners
30e254560a node info now understands new dna response packet format. 2012-06-21 11:45:07 +09:30
gardners
8ea37af64d servald now can return arbitrary URIs in response to DNA requests. 2012-06-21 11:44:49 +09:30
gardners
b48fdb6567 added deeper timing checks to reveal that rhizome advertisements
are the slowest part -- need to add caching of manifests so that
we don't hit the database every interface tick.
2012-06-21 11:33:43 +09:30
Andrew Bettison
50ed301ccc Fix failing tests from addition of rhizome list '_selfsigned' column 2012-06-12 11:48:15 +09:30
Andrew Bettison
7be0d9d00d Pass author SID parameters in binary, not hex 2012-06-08 18:32:14 +09:30
Andrew Bettison
637ef02f30 Add _selfsigned column to "rhizome list" output
Add <pin,pin...> arg1 to "rhizome list" command, so it can open the keyring

Some tests in tests/rhizome fail
2012-06-08 18:25:43 +09:30
Andrew Bettison
7a71a521f8 Pass author SID parameters in binary, not hex 2012-06-08 15:27:15 +09:30
Andrew Bettison
a9ad1b6afc Add <bsk> optional arg to "rhizome add file"
Improve regular expressions for common data types in test scripts

Revert column count field delimiter in "rhizome list" from ":" to "\n"

Add a few more test cases
2012-06-05 13:58:59 +09:30
Andrew Bettison
304db6e5f4 Fix SEGV bug in "rhizome extract file" command
Add optional <key> argument, validate and parse it properly.
2012-06-01 18:12:59 +09:30
Daniel O'Connor
8f409cc7c5 Remove unused variables. 2012-05-29 09:45:24 +09:30
Jeremy Lakeman
b3819835ca Allow for huge result sets 2012-05-27 15:04:37 +09:30
gardners
4b96860535 prevent segfault in libserval.so 2012-05-26 15:46:08 +02:00
gardners
cf42cf08a4 cleanup some debugging. 2012-05-26 14:56:58 +02:00
gardners
b1e1a36898 fixed typo. 2012-05-26 14:36:00 +02:00
gardners
94d17a9260 more work on encrypting bundles. code passes all 23 rhizome tests. 2012-05-26 11:36:19 +02:00
gardners
2de6bb025a rhizome_extract_file can now decrypt a file, and also uses
progressive blob operations so that we can extract files of
unlimited size.
2012-05-26 11:36:19 +02:00
gardners
5c40edb55d Fixed bugs with importing files using user-supplied manifest
(was not decoding BKs)
2012-05-26 11:36:18 +02:00
gardners
04cc05d6e1 refactored manifest verification into a separate function
that is called only when needed, and marks a manifest as finalised
if the verifcation fails.  reading a manifest now never sets
finalised flag, as either _finalise() or _verify() must be called.
2012-05-26 11:36:18 +02:00
gardners
9c62f07154 fixed some bugs with manifest preperation in new factored
manifest handling sequence.
2012-05-26 11:36:18 +02:00
gardners
e473e5b6df some fixes to new refactored bundle handling code. 2012-05-26 11:36:18 +02:00
gardners
b0dca7e03f merged in latest changes from team. 2012-05-26 11:36:18 +02:00
Andrew Bettison
8ec2fe53d4 Silence 'status unused' compiler warning 2012-05-25 15:59:57 +09:30
Andrew Bettison
49aec4d331 Improve rhizome manifest debugging
Move rhizome_new_manifest() out of rhizome_read_manifest_file() so that the
out-of-manifest report shows the names of the functions where the manifests
were really allocated.
2012-05-25 15:38:13 +09:30
Andrew Bettison
1af238a4f9 Rhizome extract commands handle missing pathnames properly 2012-05-25 11:52:49 +09:30
Jeremy Lakeman
26f3966002 Ignore node info results from incorrect sid's 2012-05-25 09:55:56 +09:30
Andrew Bettison
0ec3feaa29 Expunge setReason()
Replace with WHY() or WHYF() everywhere

Improve logMessage() to handle file/line/function printing internally

Mainly so that log messages from manifest alloc/free in rhizome_bundle.c
can make it into the Android log
2012-05-24 17:11:55 +09:30
Andrew Bettison
59e58da2f4 More fixes for varargs stuff
But still no luck on Android
2012-05-23 16:07:52 +09:30
Andrew Bettison
1af9125392 All rhizome database keys are uppercase hex
FILES.id, MANIFESTS.id, FILEMANIFESTS.fileid, FILEMANIFESTS.manifestid
Named constants for hex and binary ID sizes
2012-05-23 16:04:00 +09:30
Andrew Bettison
29502d8c81 Varargs and strbuf fixes
Add missing va_end() for all va_copy()
strbuf_sprintf() adds precautionary nul to end of string after vsnprintf()
2012-05-22 14:58:05 +09:30
gardners
740a64ed51 "servald stop" now checks monitor interface, and can kill the PID
even if there is no PID file, and the server process is stuck.
Now to find out how the process gets stuck to begin with ...
2012-05-21 20:57:31 +09:30
gardners
165ac03c7a added use of server_probe() to "servald start" command.
Tries to kill existing server if present, and will abort if
there is an existing instance.
Old pid code not cleaned out.
2012-05-21 20:54:17 +09:30
gardners
e44294ea66 implemented server_probe(int *pid) that used monitor interface
to probe server status.  Also returns PID if running (Linux only).
2012-05-21 20:45:07 +09:30
Andrew Bettison
f4293e8ab3 Add "rhizome hash file" command
Also fixed a file descriptor leak in rhizome_hash_file() -- missing fclose()
2012-05-21 14:42:53 +09:30
Daniel O'Connor
990a8f3057 Add support for srtuct ucred on BSD.
This requires building with _GNU_SOURCE to get access to struct ucred on Linux. Previously the test failed on every platform except glibc <2.8 or so.

Building with _GNU_SOURCE causes TRUE to be defined so we can't use this as a variable anymore, and MIN/MAX so don't define our own.
2012-05-21 12:22:50 +09:30
Andrew Bettison
ddd17db1c4 Make "rhizome add file" work for MeshMS 2012-05-21 00:09:14 +09:30
Andrew Bettison
e6575cb369 Introduce macro constants for Rhizome service names
Use "MeshMS1" instead of "MeshMS"... version 2 won't be far away
2012-05-20 16:07:22 +09:30
Andrew Bettison
41583c1011 Fix bug in "rhizome add file" command
Was not opening keyring file properly
2012-05-20 15:25:19 +09:30
Andrew Bettison
345b2c1c4c Fix SEGV bug using new strbuf operations 2012-05-20 13:02:41 +09:30
Andrew Bettison
4b5e179841 Start support for MeshMS manifests 2012-05-19 14:09:50 +09:30
Andrew Bettison
0f65028a0b Clean up keyring_open_with_pins() error reporting 2012-05-19 10:38:29 +09:30
Andrew Bettison
5ae14ad7bc Fix bugs in rhizome_opendb()
Was calling exit() instead of returning -1 on error, which was causing
the serval app to exit in the JNI "start" command if rhizome could not
create its db file.

Use DEBUGF() instead of fprintf(stderr) in many places.

confValueGet() was not stripping \r\n off end of returned string.

rhizome_set_datastore_path() was keeping the pointer it was given (from
conValueGet()'s rotor) instead of making a strdup() copy.
2012-05-18 18:55:52 +09:30