chiark / gitweb /
tripe
5 years agoserver/, mon/: Introduce transport of TrIPE over IPv6.
Mark Wooding [Fri, 29 Sep 2017 09:08:52 +0000 (10:08 +0100)]
server/, mon/: Introduce transport of TrIPE over IPv6.

This depends on ADNS for IPv6 name resolution.

5 years agoserver/addrmap.c (hash): Visually tighten the arithmetic.
Mark Wooding [Fri, 29 Sep 2017 09:06:13 +0000 (10:06 +0100)]
server/addrmap.c (hash): Visually tighten the arithmetic.

5 years agoserver/: Eliminate the remaining address-family-specific knowledge.
Mark Wooding [Fri, 29 Sep 2017 08:58:08 +0000 (09:58 +0100)]
server/: Eliminate the remaining address-family-specific knowledge.

Outside of a few functions in `addrmap.c' and `servutil.c'.  Name
resolution now fails softly if it encounters an unexpected address
family (which can happen because of numeric conversion through
`getaddrinfo'), and the ADNS query flags are now set via the `aftab'.

5 years agoserver/: Maybe use GNU ADNS rather than mLib's `bres' for name resolution.
Mark Wooding [Fri, 29 Sep 2017 08:51:58 +0000 (09:51 +0100)]
server/: Maybe use GNU ADNS rather than mLib's `bres' for name resolution.

This will let us do IPv6 resolution later.  For now, very little looks
like it's changed.

5 years agoserver/: Use modern functions for address/text conversions.
Mark Wooding [Sat, 16 Sep 2017 18:21:28 +0000 (19:21 +0100)]
server/: Use modern functions for address/text conversions.

The tricky part is the change to the `p_init' function, which now takes
a list of `addrinfo' structures and goes through the motions of matching
the addresses up to `udpsock' slots, but actually everything is rigged
so that there's only the IPv4 entry.

5 years agoserver/admin.c (a_resolve): Parse using the `aftab' table.
Mark Wooding [Sat, 16 Sep 2017 18:09:40 +0000 (19:09 +0100)]
server/admin.c (a_resolve): Parse using the `aftab' table.

Also, introduce a new `ANY' pseudo-family which does the right thing
using the resolver.

5 years agoserver/: Introduce accessor functions for reading and writing port numbers.
Mark Wooding [Sat, 16 Sep 2017 16:38:32 +0000 (17:38 +0100)]
server/: Introduce accessor functions for reading and writing port numbers.

There are still some raw accesses to port numbers outside of address-
family switches, but these are all concerned with conversions between
address structures and strings, and this will be fixed in a later
change.

5 years agoserver/admin.h: Consolidate address construction during resolution.
Mark Wooding [Sat, 16 Sep 2017 16:06:41 +0000 (17:06 +0100)]
server/admin.h: Consolidate address construction during resolution.

Previously, setting up the socket address was kind of scattered
throughout the resolver code: the address family was set up front; the
port number stashed a bit later; and then the address plugged in once
the resolution job finished.

Instead, keep the port number separate once we've worked out what it is,
and build the entire socket address in one go at each site (once in the
background-resolver callback, and once for parsing a numerical address).

5 years agoserver/admin.c (acmd_addr): Don't assert about the address family.
Mark Wooding [Sat, 16 Sep 2017 15:44:40 +0000 (16:44 +0100)]
server/admin.c (acmd_addr): Don't assert about the address family.

The `?ADDR' formatting directive can look after itself.

5 years agoserver/admin.c: Tweak tracing of background resolver jobs.
Mark Wooding [Sat, 16 Sep 2017 15:42:49 +0000 (16:42 +0100)]
server/admin.c: Tweak tracing of background resolver jobs.

This will make more sense later.

5 years agoserver/: Institute `address family table'; contemplate multiple sockets.
Mark Wooding [Sat, 16 Sep 2017 14:30:42 +0000 (15:30 +0100)]
server/: Institute `address family table'; contemplate multiple sockets.

This is a slightly oddly-shaped change which lays important groundwork
for the future.

  * Firstly, it creates a table of address families, currently not very
    interestingly since there's only one, but this will be an essential
    tool for adding IPv6 support later.

  * Secondly, it turns the peer module's `sock' into a global vector
    `udpsock' of UDP sockets, possibly one for each of the supported
    address families.  There's no real change here, because there's only
    one address family known, but the `port' command has grown an
    address-family argument in case they have different ports.  To make
    this work, each peer now keeps track of the index of the socket it
    should use for transmitting messages.

5 years agopathmtu/pathmtu.c: Support IPv6 in the `raw' probing strategy.
Mark Wooding [Fri, 15 Sep 2017 00:52:47 +0000 (01:52 +0100)]
pathmtu/pathmtu.c: Support IPv6 in the `raw' probing strategy.

Add code for constructing and parsing IPv6 packets.  This is rather
annoying and fiddly, in ways which are excitingly different from the
ways in which raw sockets are exciting and fiddly with IPv4.

5 years agopathmtu/pathmtu.c (raw): Switchify the code.
Mark Wooding [Fri, 15 Sep 2017 00:51:07 +0000 (01:51 +0100)]
pathmtu/pathmtu.c (raw): Switchify the code.

This is mostly an exercise in re-indenting things.  There's no
functional change; here, we just ease the transition to the next commit.

5 years agopathmtu/pathmtu.c (raw): Maintain the port numbers separately.
Mark Wooding [Fri, 15 Sep 2017 00:46:31 +0000 (01:46 +0100)]
pathmtu/pathmtu.c (raw): Maintain the port numbers separately.

The Linux raw-IPv6-sockets machinery doesn't like port numbers in socket
addresses, so keep track of the ports separately and clear out the port
numbers in the address structures.

5 years agopathmtu/pathmtu.c: Check against UDP header length, not pointer size.
Mark Wooding [Thu, 14 Sep 2017 12:25:12 +0000 (13:25 +0100)]
pathmtu/pathmtu.c: Check against UDP header length, not pointer size.

5 years agopathmtu/pathmtu.c: Use newer-style type names in pseudoheader struct.
Mark Wooding [Thu, 14 Sep 2017 10:32:18 +0000 (11:32 +0100)]
pathmtu/pathmtu.c: Use newer-style type names in pseudoheader struct.

5 years agopathmtu/pathmtu.c: Support IPv6 in Linux probing method.
Mark Wooding [Thu, 14 Sep 2017 09:14:59 +0000 (10:14 +0100)]
pathmtu/pathmtu.c: Support IPv6 in Linux probing method.

5 years agopathmtu/pathmtu.c: Support IPv6 addresses in the generic code.
Mark Wooding [Thu, 14 Sep 2017 08:57:32 +0000 (09:57 +0100)]
pathmtu/pathmtu.c: Support IPv6 addresses in the generic code.

They don't work in any of the low-level methods yet.  That's going to
come later.

5 years agopathmtu/pathmtu.c: Replace explicit `sockaddr_in' structures with union.
Mark Wooding [Thu, 14 Sep 2017 08:25:33 +0000 (09:25 +0100)]
pathmtu/pathmtu.c: Replace explicit `sockaddr_in' structures with union.

First steps towards IPv6 support.  There's no functional change, just a
bunch of refactoring and some extra checking which isn't currently
exercised.

5 years agopathmtu/pathmtu.c (raw): Check the UDP packet signature.
Mark Wooding [Tue, 19 Sep 2017 09:02:25 +0000 (10:02 +0100)]
pathmtu/pathmtu.c (raw): Check the UDP packet signature.

5 years agopathmtu/pathmtu.c: Document the `--verbose' option.
Mark Wooding [Thu, 14 Sep 2017 08:38:04 +0000 (09:38 +0100)]
pathmtu/pathmtu.c: Document the `--verbose' option.

It wasn't supposed to be a secret.

5 years agopathmtu/pathmtu.c: Document the correct short option for `--version'.
Mark Wooding [Thu, 14 Sep 2017 08:56:11 +0000 (09:56 +0100)]
pathmtu/pathmtu.c: Document the correct short option for `--version'.

5 years agoproxy/tripe-mitm.c: Support for IPv6.
Mark Wooding [Wed, 13 Sep 2017 10:11:01 +0000 (11:11 +0100)]
proxy/tripe-mitm.c: Support for IPv6.

Now we're using getaddrinfo(3), we can also allow service names for
ports, but this is rather incidental.

5 years agoproxy/tripe-mitm.c: Allow user control over the delimiter.
Mark Wooding [Wed, 13 Sep 2017 09:19:56 +0000 (10:19 +0100)]
proxy/tripe-mitm.c: Allow user control over the delimiter.

It turns out that `:' was a terrible choice given the syntax of IPv6
addresses.  I probably knew this at the time, even.

5 years agoproxy/tripe-mitm.c: Abolish use of RC4.
Mark Wooding [Wed, 13 Sep 2017 09:04:46 +0000 (10:04 +0100)]
proxy/tripe-mitm.c: Abolish use of RC4.

5 years agoproxy/tripe-mitm.c: Reformat.
Mark Wooding [Wed, 13 Sep 2017 09:19:02 +0000 (10:19 +0100)]
proxy/tripe-mitm.c: Reformat.

5 years agopkstream/pkstream.c: Enable IPv6 address support.
Mark Wooding [Thu, 28 Sep 2017 01:04:53 +0000 (02:04 +0100)]
pkstream/pkstream.c: Enable IPv6 address support.

Implement the address-helper branches for IPv6, and set the default
address family to `AF_UNSPEC'.  Also, introduce command-line switches
for limiting address resolution.

5 years agopkstream/pkstream.c (parseaddr): Allow address literals in brackets.
Mark Wooding [Thu, 28 Sep 2017 01:02:03 +0000 (02:02 +0100)]
pkstream/pkstream.c (parseaddr): Allow address literals in brackets.

Actually, they don't have to be literals.  Don't tell anyone.

5 years agopkstream/pkstream.c: Be more careful about handling address families.
Mark Wooding [Thu, 28 Sep 2017 00:52:03 +0000 (01:52 +0100)]
pkstream/pkstream.c: Be more careful about handling address families.

  * Introduce a concept of `known' address families.  Currently, only
    `AF_INET' is known.

  * Filter `struct addrinfo' chains for known address families.  If we
    come up short, complain.

  * Tweak `aihints' to arrange that addresses which are supposed to
    match up actually will do: so server peer and bind addresses should
    match; client bind and connect addresses should match; and UDP local
    and remote addresses should match.

  * Initialize address structures using the `ai_family' slot from the
    appropriate `struct addrinfo' structure.

5 years agopkstream/pkstream.c: Introduce an `initsock' function which does nothing.
Mark Wooding [Thu, 28 Sep 2017 00:47:43 +0000 (01:47 +0100)]
pkstream/pkstream.c: Introduce an `initsock' function which does nothing.

Only it checks the address family first.  This will be important because
IPv6 sockets /do/ need a little special initialization.

5 years agopkstream/pkstream.c: Use `getaddrinfo' to resolve addresses and services.
Mark Wooding [Thu, 28 Sep 2017 00:41:43 +0000 (01:41 +0100)]
pkstream/pkstream.c: Use `getaddrinfo' to resolve addresses and services.

This will give us multiple addresses for simple queries, which we must
do something sensible with:

  * for server bind and peer addresses, we accumulate them in our
    address vectors as before;

  * for client bind addresses, and local UDP addresses, we just take
    the first match, and hope that's good enough; and

  * for client connect addresses, and remote UDP addresses, we try to
    connect to each address in turn and take the first one that works.

Some utility functions have been added or enhanced:

  * `pushaddr' has become `pushaddrs', and its job is now to push the
    addresses from a `struct addrinfo' chain onto an address vector; and

  * `copyaddr' has been introduced to do possible partial copies of
    addresses.

Note that everything is still strictly IPv4 throughout.  But almost all
of the pieces are now in place...

5 years agopkstream/pkstream.c: Allow multiple listening and peer addresses.
Mark Wooding [Wed, 27 Sep 2017 23:38:58 +0000 (00:38 +0100)]
pkstream/pkstream.c: Allow multiple listening and peer addresses.

When being a TCP server.

  * Accept multiple `-b' and `-p' options, and accumulate their values
    into string vectors;

  * expand the `connwait' addresses into vectors;

  * when resolving addresses, accumulate the addresses into the
    appropriate result vectors;

  * maintain multiple `sel_file' objects waiting for their respective
    listening sockets;

  * and search the vector of peers when accepting incoming
    connections (an empty vector means that all remote addresses are
    permitted, so we no longer need to dig into the address structure
    here).

5 years agopkstream/pkstream.c: Fetch protocol family codes from addresses.
Mark Wooding [Wed, 27 Sep 2017 22:56:07 +0000 (23:56 +0100)]
pkstream/pkstream.c: Fetch protocol family codes from addresses.

Now the only mentions of `AF_INET' are in the address-handling
functions.

5 years agopkstream/pkstream.c: Introduce helper functions to fiddle with addresses.
Mark Wooding [Wed, 27 Sep 2017 22:49:01 +0000 (23:49 +0100)]
pkstream/pkstream.c: Introduce helper functions to fiddle with addresses.

The remaining places where pieces of addresses are fiddled with
directly, outside of these new functions, are:

  * in `doaccept', where we continue inspect the peer address to see if
    it's a wildcard, because we'll handle this in a very different way
    later; and

  * in `parseaddr', which needs to fill in addresses and port numbers.

5 years agopkstream/pkstream.c: Wrap addresses up in a union.
Mark Wooding [Wed, 27 Sep 2017 22:38:38 +0000 (23:38 +0100)]
pkstream/pkstream.c: Wrap addresses up in a union.

This makes casting to `struct sockaddr' pointers more pleasant, but
doesn't do anything else of use yet.  No functional change.

5 years agopkstream/pkstream.c: Set a flag if we're listening.
Mark Wooding [Wed, 27 Sep 2017 22:30:30 +0000 (23:30 +0100)]
pkstream/pkstream.c: Set a flag if we're listening.

Rather than having to check the address.  This means that we don't need
to initialize `cw.me' if we /aren't/ listening, so don't.

5 years agopkstream/pkstream.c: Rearrange socket setup, particularly `parseaddr'.
Mark Wooding [Wed, 27 Sep 2017 19:49:00 +0000 (20:49 +0100)]
pkstream/pkstream.c: Rearrange socket setup, particularly `parseaddr'.

  * Have `parseaddr' fill in a socket address structure directly.

  * Change the interface to pass in either separate host and
    service (does this remind you of anything?) names, or a single
    combined string to be parsed apart, as indicated by a new flag
    `paf_parse'.

  * Have `main' keep track of the various host and service name strings
    and then sort everything out at the end, rather than exercising the
    resolver during option parsing.  Take advantage of this by
    diagnosing incompatible option combinations.

  * To make this work, upgrade `cw.peer' to be full socket address.

  * Factor out socket-address initialization, and initialize the
    structures on demand rather than in advance.

5 years agopkstream/pkstream.c: Reformat to my current conventions.
Mark Wooding [Wed, 27 Sep 2017 09:49:38 +0000 (10:49 +0100)]
pkstream/pkstream.c: Reformat to my current conventions.

Squash tightly related instructions onto single lines where they fit.
Hoist variable declarations from inner scopes up to the function scope.

5 years agopeerdb/tripe-newpeers.in: Add a new resolver based on adnshost(1).
Mark Wooding [Wed, 27 Sep 2017 09:03:06 +0000 (10:03 +0100)]
peerdb/tripe-newpeers.in: Add a new resolver based on adnshost(1).

This can resolve names to IPv6 addresses, so use it if it's available.

5 years agopeerdb/tripe-newpeers.in: Split out a resolver base class.
Mark Wooding [Wed, 27 Sep 2017 08:51:04 +0000 (09:51 +0100)]
peerdb/tripe-newpeers.in: Split out a resolver base class.

Now we can add different kinds of resolvers a bit more easily, and
choose which one we want to use.

5 years agopeerdb/tripe-newpeers.in: Add support for v4 and v6 address literals.
Mark Wooding [Wed, 27 Sep 2017 08:07:20 +0000 (09:07 +0100)]
peerdb/tripe-newpeers.in: Add support for v4 and v6 address literals.

At least they get canonified now.  I think v4 literals should have
worked before, but it seems that they didn't.  This adds a `6' flag to
request only the v6 addresses for a name, but currently you can predict
which addresses you get pretty well.

5 years agopeerdb/tripe-newpeers.in: Split `prepare' in twain.
Mark Wooding [Wed, 27 Sep 2017 08:40:01 +0000 (09:40 +0100)]
peerdb/tripe-newpeers.in: Split `prepare' in twain.

There's now a front-end, still called `prepare', which establishes the
`ResolvingHost' if necessary, and a back-end, `_prepare' which actually
does the work.

You might well think that this is preparatory work for splitting out a
superclass.  I couldn't possibly comment.

5 years agopeerdb/tripe-newpeers.in: Introduce the idea of multiple address families.
Mark Wooding [Tue, 26 Sep 2017 22:06:42 +0000 (23:06 +0100)]
peerdb/tripe-newpeers.in: Introduce the idea of multiple address families.

Have `ResolvingHost' track a list per address family.  Add a `4' flag
requesting just the IPv4 address(es), as if we had any other kind to
return.

5 years agopeerdb/tripe-newpeers.in: Keep track of the canonical hostname too.
Mark Wooding [Tue, 26 Sep 2017 21:56:19 +0000 (22:56 +0100)]
peerdb/tripe-newpeers.in: Keep track of the canonical hostname too.

Not that I plan to do anything useful with that.

5 years agopeerdb/tripe-newpeers.in: Enhance addr-lookup syntax; return multiple addrs.
Mark Wooding [Tue, 26 Sep 2017 21:51:59 +0000 (22:51 +0100)]
peerdb/tripe-newpeers.in: Enhance addr-lookup syntax; return multiple addrs.

Keep track of multiple addresses for each host.  Extend the $[...]
syntax to allow substitution of all of the addresses, rather than just
the first.

5 years agopeerdb/tripe-newpeers.in: Split out a class for a host's resolved names.
Mark Wooding [Tue, 26 Sep 2017 21:37:16 +0000 (22:37 +0100)]
peerdb/tripe-newpeers.in: Split out a class for a host's resolved names.

This becomes the primary kind of object maintained in the resolver's
dictionary.

Also formalize the arrangements for reporting whether name resolution
failed.

This is an initial step towards introducing IPv6 support, initially in
this program, and later across the entire project.

5 years agoAdd new `knock' protocol.
Mark Wooding [Thu, 24 Aug 2017 20:31:43 +0000 (21:31 +0100)]
Add new `knock' protocol.

  * Add a new option to the `ADD' command giving the knock string to
    send.

  * Add new protocol messages `token-rq', `token', and `knock', which
    together allow a possibly unknown peer to collect a single-use
    token (`token-rq' and `token') which it can use to identify itself,
    and use this to introduce itself to its (presumably) static
    peer (`knock').  This last message can either provoke a `KNOCK'
    notification to a service, or initiate key-exchange using a
    piggybacked `pre-challenge', possibly after having updated the
    peer's address.

  * Update the `connect' service to collect the necessary knock strings
    from the peer database, and to respond to `KNOCK' notifications.

  * Update the Wireshark dissector to recognize and dissect the new
    messages.  (The `cap.knock' file sneakily includes a message from
    the future, to be dissected in a later modification.)

5 years agoserver/{keyexch,peer}.c: Maybe key-exchange messages come out of the blue.
Mark Wooding [Mon, 4 Sep 2017 00:15:35 +0000 (01:15 +0100)]
server/{keyexch,peer}.c: Maybe key-exchange messages come out of the blue.

Don't insist in `p_read' that key-exchange messages always come from a
known address.  Instead, leave this to `kx_message' to sort out.

This involves a change of interface to `kx_message', passing in the
sender address, and passing out an indication as to whether the address
was recognized.  It also means that there's a little extra fancy
footwork involved because `kx_message' might not have a key-exchange
control block conveniently to hand.

5 years agoserver/keyexch.c (kx_message): Squish vertically.
Mark Wooding [Mon, 4 Sep 2017 00:06:36 +0000 (01:06 +0100)]
server/keyexch.c (kx_message): Squish vertically.

This will make it look more like the new code I'm going to add.

5 years agoserver/keyexch.c: Abstract out the common message-handling behaviour.
Mark Wooding [Mon, 4 Sep 2017 00:02:02 +0000 (01:02 +0100)]
server/keyexch.c: Abstract out the common message-handling behaviour.

Add new functions for resetting the key-exchange state on reception, and
updating the statistics on send and receive.

5 years agoserver/keymgmt.c: Track and find keys by their 32-bit IDs.
Mark Wooding [Sun, 3 Sep 2017 23:17:40 +0000 (00:17 +0100)]
server/keymgmt.c: Track and find keys by their 32-bit IDs.

5 years agoserver/test.c: Add a program to assist unit tests.
Mark Wooding [Sat, 2 Sep 2017 21:04:42 +0000 (22:04 +0100)]
server/test.c: Add a program to assist unit tests.

5 years agoserver/servutil.c: Add utilities for plain asymmetric encryption.
Mark Wooding [Thu, 24 Aug 2017 20:25:53 +0000 (21:25 +0100)]
server/servutil.c: Add utilities for plain asymmetric encryption.

The encryption is standard KEM/DEM fare, using a Diffie--Hellman KEM and
a TrIPE bulk-crypto transform as a (very heavyweight) DEM.

5 years agoserver/servutil.c: Add utilities for simple leaky-bucket rate limiting.
Mark Wooding [Sat, 2 Sep 2017 13:59:53 +0000 (14:59 +0100)]
server/servutil.c: Add utilities for simple leaky-bucket rate limiting.

5 years agoserver/keyexch.c: Rename kx_init => kx_setup.
Mark Wooding [Sun, 3 Sep 2017 23:16:33 +0000 (00:16 +0100)]
server/keyexch.c: Rename kx_init => kx_setup.

I need the name for startup-time initialization of the key-exchange
code.

5 years agoserver/: Augment challenges to allow a payload.
Mark Wooding [Mon, 4 Sep 2017 08:36:10 +0000 (09:36 +0100)]
server/: Augment challenges to allow a payload.

  * Augment the external interface to take a pointer/length pair
    designating the payload.

  * Change the bulk-crypto interface to pass the sequence number in
    separately from the (repurposed) payload buffer.

  * Modify the `naclbox' challenge handling to hash the payload using
    Poly1305, rather than just producing some Salsa20 output.

5 years agoserver/chal.c: Capture `master->algs.bulk' in a variable.
Mark Wooding [Sun, 3 Sep 2017 12:15:03 +0000 (13:15 +0100)]
server/chal.c: Capture `master->algs.bulk' in a variable.

Makes the code a bit less noisy.

5 years agoserver/chal.c: Rename bulk => bchal.
Mark Wooding [Sun, 3 Sep 2017 10:57:49 +0000 (11:57 +0100)]
server/chal.c: Rename bulk => bchal.

This makes space for other bulk-crypto objects in this file.  Also,
sneakily, rename the code section with the idea that there might be
another one later.

5 years agoserver/: Expose and enhance the bulk-key-derivation protocol.
Mark Wooding [Thu, 24 Aug 2017 21:24:07 +0000 (22:24 +0100)]
server/: Expose and enhance the bulk-key-derivation protocol.

  * Rename `struct rawkey' to `deriveargs', and document it;

  * make `ks_derivekey' private in `bulkcrypto.c', and rename it
    `derivekey';

  * make the various contributions to the derived keys be optional and
    handle them not existing sensibly; and

  * cope with the idea that a caller might only want incoming or
    outgoing keys, but not both.

This lays the groundwork for a separately usable public-key encryption
scheme based on the existing machinery, but this will come a bit later.

5 years agoserver/tripe-admin.5.in: Add missing docs about `PRIVSEP' warnings.
Mark Wooding [Sun, 13 May 2018 01:02:05 +0000 (02:02 +0100)]
server/tripe-admin.5.in: Add missing docs about `PRIVSEP' warnings.

I don't know where these went.

5 years agokeys/tripe-keys.conf.5.in: Fix typoed signature scheme name.
Mark Wooding [Wed, 13 Jun 2018 10:21:21 +0000 (11:21 +0100)]
keys/tripe-keys.conf.5.in: Fix typoed signature scheme name.

5 years agoserver/admin.c: Delete a redundant ignoring of `SIGPIPE'.
Mark Wooding [Sat, 12 May 2018 10:38:08 +0000 (11:38 +0100)]
server/admin.c: Delete a redundant ignoring of `SIGPIPE'.

The real one is in `main' in `tripe.c'.

5 years agoserver/tripe.h: Fix indentation of a preprocessor directive.
Mark Wooding [Sat, 19 May 2018 19:41:45 +0000 (20:41 +0100)]
server/tripe.h: Fix indentation of a preprocessor directive.

This appears to have been broken since 2005.

5 years agopeerdb/tripe-newpeers.in (MissingSectionException): Fix constructor.
Mark Wooding [Mon, 11 Jun 2018 12:09:33 +0000 (13:09 +0100)]
peerdb/tripe-newpeers.in (MissingSectionException): Fix constructor.

5 years agosvc/connect.in (addpeer): Use `boolean' filter rather than a local hack.
Mark Wooding [Mon, 11 Jun 2018 12:02:03 +0000 (13:02 +0100)]
svc/connect.in (addpeer): Use `boolean' filter rather than a local hack.

Now that `Peer.get' actually works properly, this is safe.

5 years agosvc/connect.in (Peer.get): Don't apply filter to default value.
Mark Wooding [Mon, 11 Jun 2018 12:00:07 +0000 (13:00 +0100)]
svc/connect.in (Peer.get): Don't apply filter to default value.

Callers don't expect this, and there will be unfortunate behaviour.  For
example, `T.timespec' explodes if handed a literal integer rather than a
string.

5 years agoserver/tripe-admin.5.in: Add missing documentation for error messages.
Mark Wooding [Mon, 11 Jun 2018 11:58:01 +0000 (12:58 +0100)]
server/tripe-admin.5.in: Add missing documentation for error messages.

5 years agoserver/tripe-admin.5.in: Fix markup for error messages.
Mark Wooding [Mon, 11 Jun 2018 11:45:29 +0000 (12:45 +0100)]
server/tripe-admin.5.in: Fix markup for error messages.

5 years agopeerdb/tripe-newpeers.in: Mark expected errors and report appropriately.
Mark Wooding [Sun, 27 May 2018 15:43:16 +0000 (16:43 +0100)]
peerdb/tripe-newpeers.in: Mark expected errors and report appropriately.

Introduce an `ExpectedError' class and catch it at top level, reporting
the error message in the traditional Unix style.

5 years agopeerdb/tripe-newpeers.in (BulkResolver): Add exception for resolution failure.
Mark Wooding [Sun, 27 May 2018 17:14:42 +0000 (18:14 +0100)]
peerdb/tripe-newpeers.in (BulkResolver): Add exception for resolution failure.

There's a space for describing the error properly, but we can't do that
at the moment because mLib's background resolver isn't loved.

5 years agopeerdb/tripe-newpeers.in (ConfigSection.items): Report `name'.
Mark Wooding [Sun, 27 May 2018 13:49:24 +0000 (14:49 +0100)]
peerdb/tripe-newpeers.in (ConfigSection.items): Report `name'.

It's always there, even if it's synthetic.  This changes the output,
including a `name' item in each host, but this is harmless (or possibly
even useful).

Maybe this should have been `@name', but it's too late for that now.

5 years agopeerdb/tripe-newpeers.in (ConfigSection): Fix handling of `@inherits'.
Mark Wooding [Sun, 27 May 2018 13:00:02 +0000 (14:00 +0100)]
peerdb/tripe-newpeers.in (ConfigSection): Fix handling of `@inherits'.

  * Make `get' return it properly -- unexpanded (because that wouldn't
    make sense).

  * Make `items' mention it if applicable.

This doesn't affect the final output, since the CDB writing stage omits
keys whose name begins with `@'.

5 years agopeerdb/tripe-newpeers.in (ConfigSection.items): Push more cautiously.
Mark Wooding [Sun, 27 May 2018 12:51:45 +0000 (13:51 +0100)]
peerdb/tripe-newpeers.in (ConfigSection.items): Push more cautiously.

Instead of recording which sections have been visited, record all
sections which have been pushed and avoid pushing them again.  This
reduces pointless stack activity.

5 years agopeerdb/tripe-newpeers.in (ConfigSection.items): Rename `d' to `seen'.
Mark Wooding [Sun, 27 May 2018 11:57:53 +0000 (12:57 +0100)]
peerdb/tripe-newpeers.in (ConfigSection.items): Rename `d' to `seen'.

We haven't tried to store useful values in this dictionary for a long
time.  Give it a more useful name.

See?  I do think about this.

5 years agopeerdb/tripe-newpeers.in: Fix memoization while resolving inheritance.
Mark Wooding [Sun, 27 May 2018 01:28:20 +0000 (02:28 +0100)]
peerdb/tripe-newpeers.in: Fix memoization while resolving inheritance.

The memoization never worked properly.  It's clear, because the code
tries to store old values in the `map' dictionary, that it /wants/ to
optimize repeated visits to the same parent section, but unfortunately
nothing actually picks these saved values up again.  I can't tell any
more, but I think this is because the memoization map never stored the
path, so a second visit would return an unhelpful truncated path.

Also, the per-lookup memoization isn't really very effective: we
pointlessly walk the inheritance graph afresh for each `get' call.

Replace this with a per-section cache of inheritance-resolved lookups,
complete with path information.

5 years agopeerdb/tripe-newpeers.in: Factor out calculating the parent-section list.
Mark Wooding [Sun, 27 May 2018 01:20:47 +0000 (02:20 +0100)]
peerdb/tripe-newpeers.in: Factor out calculating the parent-section list.

5 years agopeerdb/tripe-newpeers.in: Remove (undocumented) whitespace fixing.
Mark Wooding [Sat, 26 May 2018 13:48:11 +0000 (14:48 +0100)]
peerdb/tripe-newpeers.in: Remove (undocumented) whitespace fixing.

I don't think we ever needed this, except that there's a longstanding
mLib bug which means that newlines (and other whitespace other than
actual space characters) aren't escaped in `lax' mode, which would have
caused the `cdb-map' output to be broken.

Easy fix: turn off lax mode.

5 years agopeerdb/tripe-newpeers.in (ConfigSection.items): Just return names.
Mark Wooding [Sat, 26 May 2018 13:47:06 +0000 (14:47 +0100)]
peerdb/tripe-newpeers.in (ConfigSection.items): Just return names.

It has to do a full `get' for each one anyway, which the caller can do
just as well if they actually want to.  Sometimes they don't, which
saves some effort.

5 years agopeerdb/tripe-newpeers.in: Abolish `ConfigSection.has_option'.
Mark Wooding [Sat, 26 May 2018 13:42:36 +0000 (14:42 +0100)]
peerdb/tripe-newpeers.in: Abolish `ConfigSection.has_option'.

Instead, the caller just catches `MissingKeyException'.

5 years agopeerdb/tripe-newpeers.in: Split out a class for config sections.
Mark Wooding [Sat, 26 May 2018 13:38:03 +0000 (14:38 +0100)]
peerdb/tripe-newpeers.in: Split out a class for config sections.

This looks like a mess, but it mostly involves moving a bunch of methods
from `MyConfigParser' into the new `ConfigSection' class and fiddling
with callers.

5 years agopeerdb/tripe-newpeers.in (MyConfigParser): Abandon Python `ConfigParser'.
Mark Wooding [Sat, 26 May 2018 12:55:02 +0000 (13:55 +0100)]
peerdb/tripe-newpeers.in (MyConfigParser): Abandon Python `ConfigParser'.

Instead, just parse the input by hand.  This makes the behaviour easier
to specify properly.  The language accepted is now actually as described
in the manpage, rather than also, say, stripping `;' comments (but not
`#' comments) from assignment and continuation lines, or interpreting a
`""' as an empty value.

Fortunately, the rest of the program doesn't make much use of the
`ConfigParser' protocol, so this isn't missed.

5 years agopeerdb/tripe-newpeers.in: Upper-case the compiled regexp names.
Mark Wooding [Sat, 26 May 2018 11:22:22 +0000 (12:22 +0100)]
peerdb/tripe-newpeers.in: Upper-case the compiled regexp names.

Just a cosmetic change.

5 years agopeerdb/tripe-newpeers.in (MyConfigParser._get): Compress vertically.
Mark Wooding [Sat, 26 May 2018 11:14:41 +0000 (12:14 +0100)]
peerdb/tripe-newpeers.in (MyConfigParser._get): Compress vertically.

Just a cosmetic change.

5 years agopeerdb/tripe-newpeers.in (MyConfigParser._get): Automate path maintenance.
Mark Wooding [Sat, 26 May 2018 11:01:29 +0000 (12:01 +0100)]
peerdb/tripe-newpeers.in (MyConfigParser._get): Automate path maintenance.

Rather than having lots of `path.pop()' calls, and hoping that
everything balances, wrap `try ... finally ...' around the method body.
Remove the explicit poppings, and simplify.

We still need to copy the path if we find a local result or raise an
exception.

5 years agopeerdb/tripe-newpeers.in: Count enhancements correctly.
Mark Wooding [Sat, 26 May 2018 10:53:11 +0000 (11:53 +0100)]
peerdb/tripe-newpeers.in: Count enhancements correctly.

I'll come in again.

5 years ago(Python): Use more modern `raise' syntax.
Mark Wooding [Sun, 27 May 2018 14:59:13 +0000 (15:59 +0100)]
(Python): Use more modern `raise' syntax.

5 years agopeerdb/peers.in.5.in: It's not just `@inherits' which is excluded.
Mark Wooding [Sun, 27 May 2018 13:11:43 +0000 (14:11 +0100)]
peerdb/peers.in.5.in: It's not just `@inherits' which is excluded.

It has always been thus: keys which start with `@' are omitted.  Fix the
manual so that it tells the truth.

5 years agopeerdb/peers.in (@PASSIVE): Remove redundant `@GLOBAL' parent.
Mark Wooding [Sun, 27 May 2018 13:08:19 +0000 (14:08 +0100)]
peerdb/peers.in (@PASSIVE): Remove redundant `@GLOBAL' parent.

It's not as if the order of direct parents makes any difference to the
resolution algorithm.

5 years ago(manpages): Fix inclusion of `defs.man'.
Mark Wooding [Fri, 25 May 2018 23:23:13 +0000 (00:23 +0100)]
(manpages): Fix inclusion of `defs.man'.

When the manpage machinery was last turned upside-down, way back in
2008 (commit e99aedcf9373b3305c32e510c086bf3357b4736a), all of the
manpages were fixed to say `.so ../common/defs.man' instead of `.so
../defs.man.in'.  Inexplicably, all but one of the manpages added since
then have had the wrong include request.  Fix this silliness.

Note that this only affects formatting the manpages directly from the
source tree: there's build machinery which embeds the common definitions
in the built manpages which are installed or packaged, and that works
just fine.  But it's still good to get this stuff right.

Just maybe I can avoid introducing more broken manpages in the future.

5 years agosvc/connect.in: Compress the code a bit.
Mark Wooding [Fri, 11 May 2018 23:45:59 +0000 (00:45 +0100)]
svc/connect.in: Compress the code a bit.

Only whitespace changes.

5 years agosvc/connect.in: Add a backstop exception handler to the pinger loop.
Mark Wooding [Fri, 11 May 2018 23:45:14 +0000 (00:45 +0100)]
svc/connect.in: Add a backstop exception handler to the pinger loop.

It'll moan, but it won't actually kill the loop any more.

5 years agosvc/connect.in: Cope if a peer vanishes when we're trying to reconnect.
Mark Wooding [Fri, 11 May 2018 23:44:27 +0000 (00:44 +0100)]
svc/connect.in: Cope if a peer vanishes when we're trying to reconnect.

5 years agosvc/connect.in: Export the admin-socket name to inferior processes.
Mark Wooding [Sun, 1 Oct 2017 11:48:36 +0000 (12:48 +0100)]
svc/connect.in: Export the admin-socket name to inferior processes.

This way, if `connect' is run with a nonstandard `-a' option, it will
pass that along to `tripe-ifup' or whatever, so that, when it in turn
runs `tripectl', it'll be able to talk to the correct server.

5 years agoserver/keyset.c: Present message types in hex.
Mark Wooding [Sat, 16 Sep 2017 15:22:36 +0000 (16:22 +0100)]
server/keyset.c: Present message types in hex.

5 years agoserver/peer.c: Abstract out updating a peer's address.
Mark Wooding [Sun, 3 Sep 2017 23:18:41 +0000 (00:18 +0100)]
server/peer.c: Abstract out updating a peer's address.

5 years agoserver/: Calculate address size on demand, rather than tracking it.
Mark Wooding [Mon, 4 Sep 2017 01:25:41 +0000 (02:25 +0100)]
server/: Calculate address size on demand, rather than tracking it.

It's fine when the address is just in the peer spec, but this isn't
going to be the case forever.

5 years agoserver/servutil.c: Reorder and categorize the functions.
Mark Wooding [Tue, 22 Aug 2017 23:10:49 +0000 (00:10 +0100)]
server/servutil.c: Reorder and categorize the functions.

Might be more coming.  Not saying yet. :-)

5 years agoserver/tripe.h: Fix commentary markup.
Mark Wooding [Tue, 22 Aug 2017 23:08:54 +0000 (00:08 +0100)]
server/tripe.h: Fix commentary markup.

5 years agoserver/tripe.8.in: The default port is the IANA-assigned one.
Mark Wooding [Tue, 19 Sep 2017 09:01:18 +0000 (10:01 +0100)]
server/tripe.8.in: The default port is the IANA-assigned one.

To get a kernel-assigned port, pass `-p0' explicitly.  Fix the manpage
so that it doesn't tell lies any more.

5 years agoserver/keyset.c, server/tripe.h: Fix commentary for `ks_gen'.
Mark Wooding [Tue, 22 Aug 2017 23:07:16 +0000 (00:07 +0100)]
server/keyset.c, server/tripe.h: Fix commentary for `ks_gen'.

Part of the point of this interface is that we no longer assume that
there are distinct secrecy and integrity keys.  And, indeed, the `iiv'
transform also has the IV-derivation blockcipher to deal with.