Commit Graph

75 Commits

Author SHA1 Message Date
Jeremy Lakeman
619c17a191 Refactor meshms cli to separate c file 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
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
e15e332072 Swap from included nacl to host libsodium 2016-05-09 10:32:04 +09:30
Andrew Bettison
3f8f0f6fc7 Improve Rhizome HTTP API diagnostics
Add RHIZOME_BUNDLE_STATUS_MANIFEST_TOO_BIG enum option to indicate
that the manifest exceeded 8 KiB in size.

Refactor rhizome_add_manifest() and rhizome_manifest_finalise()
to return 'struct rhizome_bundle_result' instead of 'enum
rhizome_bundle_status', so that that their detailed failure messages
can reach the HTTP API layer instead of just being logged.

Fix HTTP response status codes produced Rhizome direct HTTP requests
to be consistent with the Rhizome RESTful API.
2015-12-07 22:35:42 +10:30
Andrew Bettison
aabb1c5547 Call rhizome_bundle_result_free() in meshms.c
Otherwise there may be a memory leak.
2015-12-07 11:25:40 +10:30
Andrew Bettison
98ed0406c5 Refactor Rhizome result handling
- Introduce the new 'struct rhizome_bundle_result' that contains a
  rhizome_bundle_status enum value and an optional, nul-terminated
  string that provides an explanation of the cause of the status; add
  functions to construct, query, and free the struct

- Replace 'enum rhizome_add_result' with 'struct rhizome_bundle_result',
  removing an unnecessary level of enum interpretation

- Make rhizome_fill_manifest() return 'struct rhizome_bundle_result' and
  add logic to check that the supplied author SID is correct (previous
  behaviour was: if an incorrect author SID was supplied but the correct
  author could be found in the keyring, then the incorrect one was
  silently ignored)

- Simplify the response code in rhizome_restful.cc to take advantage of
  the new 'struct rhizome_bundle_result'; in particular, the mapping
  from 'enum rhizome_bundle_status' codes to HTTP status codes is now
  expressed in a single switch statement

- Fix some minor failures in test scripts revealed by the changes
2015-12-01 00:51:15 +10:30
Andrew Bettison
27d98a29fa Reimplement strlcpy() using strncpy_nul() 2015-11-02 10:11:41 +10:30
Andrew Bettison
52106b5026 Move DEBUGF() from "log.h" to "debug.h"
Include "debug.h" in lots of places (not all)
New macro IDEBUGF() for indirect debug flag, used in HTTP server
2015-07-13 18:24:04 +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
4d5cded047 Change return type of rhizome_fill_manifest()
To help improve diagnostic feedback through APIs
2015-03-16 22:40:08 +10:30
Andrew Bettison
b7b2ad845c Refactor meshms seed string generation 2014-11-14 13:11:43 +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
1848493468 New messages bump the conversation to the top 2014-10-27 11:08:02 +10:30
Jeremy Lakeman
2c72875508 Ensure sql lock failures are returned. 2014-09-12 15:24:23 +09:30
Jeremy Lakeman
2ec63b371a Build the array of console commands by using linkage tricks 2014-08-22 10:36:52 +09:30
Jeremy Lakeman
eaf069e1c3 Dont treat database lock errors the same as missing records 2014-07-14 15:26:50 +09:30
Jeremy Lakeman
bc87f8c7c0 Add timestamps to meshms messages and acks 2014-07-14 13:43:37 +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
7736a4ceb1 New HTTP RESTful requests: MeshMS read message(s) 2014-06-24 12:11:58 +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
Andrew Bettison
21f51965c1 Overhaul Makefile and header files
Make .o files in separate subdirectories for servald and library
Factor struct __sourceloc and __WHENCE__ from "log.h" into "whence.h"
Factor sid_t etc from "serval.h" into "serval_types.h"
Factor rhizome_bid_t etc from "rhizome.h" into "rhizome_types.h"
Do not include "serval.h" in library sources
Add log_stderr.c and logMessage.c for stand-alone executables
2014-05-26 15:36:26 +09:30
Jeremy Lakeman
9e267ece21 Always set keyring to NULL after use. 2014-05-15 16:32:46 +09:30
Jeremy Lakeman
348fc5f23b Fix meshms conversations parsing when looking for a single SID 2014-02-12 15:08:24 +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
f1ceffbc4e Remove unused MeshMS record type constant 2014-02-05 14:28:44 +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
f4249707a4 Implement HTTP GET /restful/meshms/<SID>/<SID>/newsince/<token>/messagelist.json
Two new test cases
2014-01-31 14:58:30 +10:30
Andrew Bettison
c73bc49cf0 Improve MeshMS RESTful HTTP requests
Include local (my) and remote (their) SIDs in JSON responses for
conversationlist.json and messagelist.json, so that the same JSON
structures can be used in future for non-SID-specific queries.

Refactor MeshMS message iterator, rename "sender" and "recipient" fields
to "my" and "their", for consistency with the rest of the MeshMS source
code, and because "sender" and "recipient" are properties that apply to
a single message or single ply, not to a message thread (conversation).
2014-01-31 14:29:57 +10:30
Andrew Bettison
b1992b3905 Refactor MeshMS ply-reading functions
Rename functions to use _prev instead of _next to mean reading
"backwards" ie, from newest to oldest, aka, from higher offsets
to lower offsets
2014-01-31 14:24:29 +10:30
Andrew Bettison
879395b121 Refactor MeshMS message-list code to use iterator 2014-01-24 17:25:55 +10:30
Andrew Bettison
cb420c61e3 meshms.h
Rename exposed MeshMS types and functions by adding "meshms_" prefix

Check binary tree integrity during meshms_free_conversations()
2014-01-22 16:41:22 +10:30
Andrew Bettison
5c1ebc71a9 Refactor MeshMS conversation list
Use an iterator structure, not recursion, to traverse the binary tree of
conversations
2014-01-21 18:24:53 +10:30
Andrew Bettison
72040517e1 New enum rhizome_payload_status
Refactor a lot of Rhizome bundle storage code to use the new "enum
rhizome_payload_status" instead of mysterious int values to represent
the outcome of the operation.
2013-12-30 16:30:35 +10:30
Andrew Bettison
9ebef81a49 Formalise "rhizome add file" exit status
Formalise add-bundle result in "enum rhizome_bundle_status"

Rewrite rhizome_manifest_finalise(), rhizome_find_duplicate() and
rhizome_add_manifest() to return enum rhizome_bundle_status

New function rhizome_manifest_check_stored() that compares a manifest
with its stored counterpart and returns enum rhizome_bundle_status

Remove redundant rhizome_manifest_check_sanity(), consolidating all
manifest validation rules in rhizome_manifest_validate(), which now
checks the 'id' field is present, and that 'sender' and 'recipient' are
both present for MeshMS

Correct manifest finalisation logic: set the 'finalised' flag in
rhizome_manifest_validate(), not in rhizome_manifest_verify() (which
sets 'selfSigned'), and consistently clear 'finalised' flag in all
attribute setter functions

Remove manifest 'ttl' field and all references thereof (leaving unused
space in Rhizome BAR)

Rename some payload functions for clarity
2013-12-21 14:37:18 +10:30
Andrew Bettison
b5f7a088b2 Fix rhizome_fill_manifest() 'name' semantics
Only set 'name' field if the given pathname is valid

Do not set 'name' field if no pathname supplied
2013-12-18 18:02:46 +10:30
Andrew Bettison
075f9c7c27 Use uint64_t for Rhizome manifest version
Instead of int64_t.  Fixes some -Wsign-compare warnings.

Replace sqlite_exec_int64() with sqlite_exec_uint64().

Also store rowid as uint64_t, and use 0 not -1 to indicate
unset.
2013-12-11 11:11:34 +10:30
Andrew Bettison
476a538ef7 Fix -Wsign-compare warnings in keyring: unsigned cn,in,kp 2013-12-10 16:34:35 +10:30
Andrew Bettison
30b2059608 Fix -Wunused-parameter warnings
New UNUSED(param) macro suppresses the warning for a specific parameter

In some cases, removed the unused parameters.  In others, used the
parameter in a DEBUGF() or assert() statement to document the intent.
2013-12-09 18:22:18 +10:30
Andrew Bettison
9b64bb87e0 Uniform copyright notices
Added some missing copyright/license block comments
2013-12-04 17:15:36 +10:30
Andrew Bettison
42ab9aec4c Merge branch 'development' into 'naf4'
Remove two redundant calls to rhizome_retrieve_manifest() in meshms.c,
revealed by an assert() in the stricter manifest parsing code

Fix header files included by socket.h
2013-12-02 17:17:47 +10:30
Jeremy Lakeman
99d5d9fa1f Refactor dataformats into separate header 2013-11-27 13:11:42 +10:30
Andrew Bettison
67a724b29d Fix Android compiler warnings ("%zd" and ssize_t)
Also squash some unconditional DEBUG statements
2013-11-21 17:32:58 +10:30
Andrew Bettison
7564d529a1 Add missing copyright/license comment blocks
Update a few existing copyright notices to reflect recent work
2013-11-21 16:05:18 +10:30
Jeremy Lakeman
4434b1b65d Create keyring.h and move definitions there 2013-11-13 11:55:12 +10:30
Andrew Bettison
e00c945fd1 Merge branch 'naf4' into 'development'
Big refactor of Rhizome author and bundle secret handling.
2013-11-07 00:42:42 +10:30
Andrew Bettison
45442d3eb4 Rewrite bundle author authentication
Replaced 'int has_author' manifest element with new 'enum authorship'
element to record the result of author authentication, to avoid
repeating expensive crypto operations.

Separated the handling of bundle secret arguments from author lookup and
authentication.  The new rhizome_apply_bundle_secret(m,bsk) is now
called at the top level to set the manifest secret key (if it
validates), and thereafter there is no need to pass the 'bsk' argument
to any other functions, as they can simply check the 'haveSecret' field
of the manifest.

Removed rhizome_extract_privatekey() which combined author lookup and
bundle secret validation, and replaced it with functions that only deal
with the author: rhizome_lookup_author() and rhizome_authenticate_author().

Renamed other functions to make their purpose and effect clearer.

Formalised the semantics of only storing AUTHENTICATED author SIDs in
the 'author' column of the MANIFESTS table, which necessitated a change
to a 'rhizomeops' test case: when adding a file using a BK-less
manifest, the author column is set to null, so the Rhizome list output
does not show the bundle as ".fromhere" and does not give an author for
that bundle.
2013-11-06 23:58:17 +10:30