Close connections if the local address is no longer valid.
When we detect that there are changes on the network interfaces, check for
each active connection whether the local side of the connection has an
address that exists on at least one network interface. If not, then
communication via that connection is not possible. Instead of waiting for
a timeout, immediately terminate those connections.
Speed up reconnections on network interface changes.
Catta informs us whenever an interface comes online or goes offline. If we
detect that there are no online interfaces, immediately terminate all meta-
connections. Otherwise, reset the ping timers and reconnection timers for
outgoing connections.
Inform UTCP when a node is offline, so it will start connection timeouts.
When there are open channels to a node that is offline for longer than the
connection timeout, the channels will be marked closed, and callbacks will
be fired.
Guus Sliepen [Thu, 30 May 2019 21:34:35 +0000 (23:34 +0200)]
Speed up initial autoconnect after joining a mesh.
When we just joined a mesh, we quickly want to establish redundant
connections. We do this by resetting the outgoing timer if we receive a
public key for a node that we are trying to connect to, and by speeding up
the autoconnect algorithm if we don't have 3 connections (in progress) yet.
Guus Sliepen [Thu, 23 May 2019 21:20:01 +0000 (23:20 +0200)]
Autoconnect to reachable nodes without known public keys
We must allow the autoconnect algorithm to try connections to nodes that
are online but for which we don't have a public key, otherwise we risk
that no connections are formed at all, except to the inviting node.
Guus Sliepen [Wed, 13 Mar 2019 22:13:06 +0000 (23:13 +0100)]
Various fixes for the encrypted storage support.
- create_initial_config_files() and node_write_config() are now the only
functions that generate the content of new config files from scratch.
- All public API functions that change config files now immediately
write them out.
- Config files of nodes that join using an invitation file are immediately
written out.
- Ensure nodes marked dirty have their config files written out in
periodic_handler(), and on meshlink_stop().
- Fix some memory leaks.
- Write out updated config files, and recreate mesh->self in meshlink_set_port().
Guus Sliepen [Fri, 14 Dec 2018 21:21:17 +0000 (22:21 +0100)]
Add support for encrypted storage.
This is a large overhaul of how configuration files are handled. All files
are now in PackMessage format, and are read from disk in to memory in one
go, and also saved to disk from memory in one go, using functions in conf.c.
Guus Sliepen [Sun, 17 Mar 2019 21:01:43 +0000 (22:01 +0100)]
Add functions to get the amount of bytes in chanenl send and receive buffers.
meshlink_channel_get_sendq() and meshlink_channel_get_recvq() call the
underlying UTCP connection's utcp_get_sendq() and utcp_get_recvq().
These return the amount of bytes waiting in the send and receive buffers.
In particular, a non-zero value for sendq means that sent data has not been
ACKed by the peer yet.
Guus Sliepen [Tue, 12 Mar 2019 19:56:20 +0000 (20:56 +0100)]
Check for astyle version 3 before formatting the code.
Unfortunately, code formatters change their behaviour between versions.
The code currently requires astyle version 3.x, so check this before
running astyle. If the wrong version is installed, print an error.
Guus Sliepen [Sat, 26 Jan 2019 20:38:53 +0000 (21:38 +0100)]
Provide a way to open MeshLink in its own network namespace.
This causes all sockets from MeshLink to be opened in the given network
namespace, without affecting the application's namespace. Note that since
callback functions run inside MeshLink's own thread, the callback functions
inherit MeshLink's network namespace.
Guus Sliepen [Tue, 20 Nov 2018 15:10:17 +0000 (16:10 +0100)]
Fix discovering node addresses from edges.
The logic always skipped the first unique address found via edges, and since
in most cases there is only one such address, this would skip them altogether.
Guus Sliepen [Tue, 20 Nov 2018 15:07:44 +0000 (16:07 +0100)]
Simplify rate limiting of incoming connections.
We now really allow max_connection_burst connections per second, rather
than only allowing one second per connection on average, but allowing
a burst of max_connection_burst connections to go through.
This test suite uses LXC containers to simulate various nodes connected
to each other in different network topologies, and allows for realistic
testing of the MeshLink library.
Guus Sliepen [Thu, 30 Aug 2018 17:45:13 +0000 (19:45 +0200)]
Always add both CanonicalAddress and any local address to the invitation URL.
We don't know in advance if the invitee will be on the LAN or outside
the LAN, and because hairpin routing is not working on many home
routers, it is safer to add all possible addresses.
Also, add the port number to each individual address in the URL, instead
of allowing only one port number.
Guus Sliepen [Sun, 12 Aug 2018 15:09:20 +0000 (17:09 +0200)]
Add duplicate node detection callback.
MeshLink can detect if two nodes are online simultaneously using the same
Name. Normally, one or both of the duplicate nodes will terminate its
connection. Now there is a duplicate node callback that will be called when
the local node detects a duplicate node. One use for this is to blacklist
the duplicate node and/or notify the user of the problem.
Add COPYING.README, detailing license obligations for users of MeshLink.
MeshLink itself depends on other libraries, and this document mainly
summarizes what obligations users of the MeshLink library have when they
distribute their software in binary form.
Guus Sliepen [Tue, 26 Jun 2018 14:42:57 +0000 (16:42 +0200)]
Add meshlink_set_invitation_timeout().
This sets a global timeout for invitation files. If a node tries to join
with an invitation whose file is older than the timeout, the invitation is
rejected.
Guus Sliepen [Tue, 26 Jun 2018 14:12:28 +0000 (16:12 +0200)]
Add meshlink_set_canonical_address().
This introduces the concept of a canonical address for a node, which is
its "official" address/port. It is only set manually, and never updated
or removed when other addresses have been discovered for this node.
Also, this changed meshlink_add_address(mesh, address) to be equivalent to
meshlink_set_canonical_address(mesh, meshlink_get_self(mesh), address, NULL).
While not strictly equivalent to the old behaviour, it matches the
documented intent of this function.
Guus Sliepen [Mon, 21 May 2018 20:03:47 +0000 (22:03 +0200)]
Use getsockname() to get a listening sockets actual address in meshlink_stop().
This should be better than sending a packet to the listening address,
which might be a link-local address for which a valid scope-id is
necessary, and which might not be in listen_socket.sa.
Guus Sliepen [Tue, 8 May 2018 15:05:00 +0000 (17:05 +0200)]
Ensure -export-symbols-regex is not lost.
An earlier commit accidentily caused libmeshlink_la_LDFLAGS to be
overwritten later in src/Makefile.am, and this caused
-export-symbols-regex to be dropped, thereby exposing internal symbols
of the library.
Guus Sliepen [Sun, 6 May 2018 20:46:36 +0000 (22:46 +0200)]
Try to be smarter generating invitation URLs.
If we have a symbol hostname associated with us, use that. Otherwise, try
to find out which external addresses we have for both IPv4 and IPv6. If we
cannot connect to www.meshlink.io, then use the local address used for
outgoing connections as a fallback. Also, don't forget to add a port number
in all cases.
The generated invitation URL can now contain two addresses in the hostname
part, separated by a comma.