Commit graph

2277 commits

Author SHA1 Message Date
Guus Sliepen
e16ab7b899 Force nul-termination of strings after vsnprintf().
Apparently, on Windows this function might not always be properly
terminated.
2016-06-23 15:26:58 +02:00
Guus Sliepen
2de5d866b5 Use EVP_MD_CTX_destroy() instead of _free().
Thanks to azrdev for pointing out the build failure on Fedora 23.
2016-06-22 23:08:30 +02:00
Guus Sliepen
9b148fd844 Check return value of RSA_generate_key_ex(). 2016-06-22 17:42:25 +02:00
Guus Sliepen
323c17e232 Ensure compatibility with OpenSSL 1.1.0. 2016-06-22 16:32:05 +02:00
thorkill
6e6bc9f443 Merge remote-tracking branch 'guus/1.1' into thkr-1.1-ponyhof 2016-06-06 22:00:58 +02:00
thorkill
8ac16a5cf2 Merge remote-tracking branch 'guus/1.1' into thkr-1.1-ponyhof 2016-06-05 15:34:46 +02:00
Guus Sliepen
74eb4cc974 Fix the previous commit. 2016-06-05 15:20:57 +02:00
Guus Sliepen
ab13c14a14 Preserve IPv6 scope_id in edges.
When creating an edge after authenticating a peer, we copy the
address used for the TCP connection, but change the port to that used
for UDP. But the way we did it discarded the scope_id for IPv6
addresses. This prevented UDP communication from working correctly when
connecting to a peer on the same LAN using an IPv6 link-local address.

Thanks to Rafał Leśniak for pointing out this issue.
2016-06-05 14:47:21 +02:00
thorkill
9a550ff4e3 Remove code commited by mistake 2016-05-30 23:11:50 +02:00
thorkill
6bd518935f Moved SLPD related #define to slpd.h 2016-05-26 16:12:03 +02:00
thorkill
fb15bef4c0 Change misleading comment - 1.1 node does have source ID in the packet 2016-05-25 22:47:18 +02:00
thorkill
e51ce69079 Change scope of len 2016-05-25 22:45:07 +02:00
thorkill
9ab8d025ca Initialize struct ip and icmp 2016-05-25 22:44:21 +02:00
thorkill
3b3bdf72d4 Initialize outoging->config_tree 2016-05-25 22:42:48 +02:00
thorkill
dbddbc2dd7 Remove debug 2016-05-25 21:38:03 +02:00
thorkill
37c128580a Remove debug output from try_harder() 2016-05-25 20:29:13 +02:00
thorkill
649b55d988 SLPD refactor - cleanup net.h 2016-05-25 19:27:40 +02:00
thorkill
0fbde0e5a0 Continue SLPD refactor 2016-05-25 19:26:53 +02:00
thorkill
26a7e51cbe Moved SLPD related code to slpd.c
- Added setup_slpd()
2016-05-25 19:18:32 +02:00
thorkill
62b63fff8b Do not include rsa.h when DISABLE_LEGACY 2016-05-25 19:13:34 +02:00
thorkill
3327feb025 Refactor of do_outgoing_connection - make it use config_address2addrinfo
This means: setup_outgoing_connection() has to prepare fake
Address = "ip port" config based on the actuall configuration file

Prefer the addresses discovered via SLDP while making outgoing connections
2016-05-25 18:30:33 +02:00
thorkill
69bb848f59 Let choose_local_address() prefer addresses discovered via SLPD 2016-05-25 18:25:28 +02:00
thorkill
11b8eb81b9 Refactor of SLPD - moved most of the SLPD related code into slpd.{c,h} 2016-05-25 18:23:42 +02:00
thorkill
299b223bba Added new function config_address2addrinfo
This function takes an "Address" config string, splits it into
address and port, then calls str2addinfo() on it returning addrinfo.

The aim is to refactor the code an allow simple translation
of addresses listed in configuration or generated on demand
in other places in the code.
2016-05-25 18:16:45 +02:00
thorkill
deccb83a29 try_harder() in only needed in legacy-protocol 2016-05-24 13:35:30 +02:00
thorkill
b7fe5910d6 Add information about sending address in try_harder() 2016-05-24 13:13:35 +02:00
thorkill
20df09ef89 Fix compile error 2016-05-23 21:27:53 +02:00
thorkill
06350df9ee Change scope of *closest variable 2016-05-23 21:19:52 +02:00
thorkill
f922b1c1e1 merged with guus/1.1 2016-05-23 21:17:42 +02:00
thorkill
a429889bed Added replaywin into logger 2016-05-23 13:08:31 +02:00
thorkill
6369a4157b Revert the order of seqno check and decryption in sptps_receive_data_datagram
the late seqno check changes the sequence numbers!
2016-05-23 12:52:18 +02:00
thorkill
b5593abe05 Extend sptps logging to farfuture and check the seqno before decryption in sptps_receive_data_datagram 2016-05-23 12:38:49 +02:00
thorkill
9c2170ed43 Changed ping_h - assume node is live when it pinged us
On larger networks with almost the same ping interval
nodes will ping each other at the same time, of course
it doesn't makes much traffic but the main reason why
we have PING/PONG is to check if other side is still
online. So, when we got PING from the other node then
it is alive.
2016-05-23 09:58:32 +02:00
Sean McVeigh
e47fe48aed fix check in cmd_pid() for failure to connect to tincd 2016-05-21 17:38:14 -04:00
thorkill
0bab833f76 Lower log level for "Ignore multicast" log messages 2016-05-21 23:35:26 +02:00
Sean McVeigh
4314df644e check for daemon pid existence before trying to connect to the control socket, and clean up stale files otherwise. 2016-05-21 17:25:18 -04:00
thorkill
1f34493be4 Changed comment in node.h for SLPD 2016-05-21 22:57:46 +02:00
lemoer
9d0e86683c Added comments and unfold deep "if"-construct in timeout_handler 2016-05-21 12:54:02 +02:00
thorkill
af0c289290 Initialize buffer for decryption 2016-05-20 23:19:21 +02:00
thorkill
44c065ba26 Additional log message about failed try_mac() 2016-05-20 21:12:18 +02:00
thorkill
fca59a36de Rephase a log message 2016-05-19 23:35:20 +02:00
thorkill
19177f823c Merged src/net.c wigth guus/1.1 2016-05-19 23:27:44 +02:00
thorkill
738e9ad8d8 Register SLPD-Variables in tincctl 2016-05-19 16:47:46 +02:00
thorkill
5baecfd11b Prevent tincd from sending packets to unexpecting nodes
Make tincd recognize when it was asleep and close connections to it's
peers. This happens when e.g. RoadWarrior has been suspended for
"longer" time period. After resume, it will start to communicate
with it's peers using the contextes it had before suspend.

On the other side, the nodes closed the connections since PingTimeout
and/or TCP connection went down.

Sending data to such unaware (sptps mostly) nodes will cause
havoc in the logs. Misleading the developers to wrong assumptions
that something is wrong with sptps.

# Conflicts:
#	src/net.c
2016-05-19 15:58:29 +02:00
thorkill
ae7bcad221 Prevent tincd from sending packets to unexpecting nodes
Make tincd recognize when it was asleep and close connections to it's
peers. This happens when e.g. RoadWarrior has been suspended for
"longer" time period. After resume, it will start to communicate
with it's peers using the contextes it had before suspend.

On the other side, the nodes closed the connections since PingTimeout
and/or TCP connection went down.

Sending data to such unaware (sptps mostly) nodes will cause
havoc in the logs. Misleading the developers to wrong assumptions
that something is wrong with sptps.
2016-05-19 15:48:15 +02:00
thorkill
931e5dbea9 Cleanup buffer and try to detect anomalies in sptps on ans_key_h 2016-05-19 00:21:59 +02:00
thorkill
c6e34c3b8c Tracking "Invalid session state zero" 2016-05-18 23:52:52 +02:00
thorkill
08eb93ff91 Make it compile on FreeBSD on 32bit CPU 2016-05-18 23:24:07 +02:00
Rafał Leśniak
b3607cd5f9 Merge pull request #4 from lemoer/patch-fix-pong-handler
Patchset to improve the pong handler

It seem that we have some troll in the network or something is broken.
2016-05-18 22:53:45 +02:00
thorkill
ad540d0c09 Lower message level on SLPD expire 2016-05-18 22:41:09 +02:00
lemoer
532b9ca451 pong handler: fix incorrect calculation for rtt
Before this fix seconds were treated as milliseconds.

Example:

A ping of 1.001s resulted in current_rtt = 2 (ms)
where a ping of 0.999s resulted in current_rtt = 999 (ms).
2016-05-18 22:21:37 +02:00
lemoer
762dc69a59 pong handler: rtt and timestamps are always positive 2016-05-18 22:21:29 +02:00
lemoer
25317983c7 pong handler: add warning if we receive pong without ping 2016-05-18 21:22:03 +02:00
lemoer
8f21a5da81 pong handler: add sanity check for rtt 2016-05-18 21:20:47 +02:00
thorkill
9deb664a94 Added .dir-locals.el for the emacs devs 2016-05-18 21:02:24 +02:00
thorkill
a6543c144d Cleanup dynamically allocated buffer before use 2016-05-18 01:08:05 +02:00
thorkill
68beb519b4 Turn -Wformat to -Werror=format, got some wrong habits 2016-05-17 23:34:07 +02:00
thorkill
90c1341626 Initialize buffer for decryption - just in case 2016-05-17 23:06:53 +02:00
thorkill
3e9638b0cb msg buffer may contain random data - just clean it up 2016-05-17 22:55:16 +02:00
thorkill
ff8f57c130 Implemented SLPD information expiration and added support for port 2016-05-17 14:46:19 +02:00
lemoer
7b220b1464 Fix type conversation warnings for gcc in slpd. 2016-05-17 11:30:03 +02:00
thorkill
d28dece937 Proper length validation in handle_incoming_slpd_packet
- refactor and cleanup of unused variables
2016-05-17 11:12:55 +02:00
thorkill
4cb85c00a8 First attempt to sign and verify the SLPD data 2016-05-16 23:21:02 +02:00
thorkill
43ed440176 SLPD rewrite for IPv6 - IPv4 has been dropped
After first tests it came out, that RoadWarriors with multiple
active Interfaces hat problems with receiving on/ and sending SLPD
packets to specific interfaces.

Here the solution:
- Define SLPDInterface in your tinc.conf (multiple definitions are allowed)
  On those interfaces tincd will send and receive SLPD packetes
- You have to have IPv6 support on - link-local addresses configured
- tincd must listen on IPv6 on your SLPDInterfaces
- Define SLPDGroup to something like ff02::42:1
- Define SLPDPort for your group
- Define SLPDInterval to some sane number of seconds (0 is default,
meaning SLPD is disabled, 30 seconds should be enough for average
users)

SLPDGroup and SLPDPort should be unique for your network.

Fingerprinting, message signing is yet to be implemented.
Discovered address should also expire periodically.
2016-05-16 20:11:08 +02:00
thorkill
057ccb8da6 recvfrom return size_t not len 2016-05-15 19:12:41 +02:00
thorkill
e36af42ce4 Change type of the packet. 2016-05-15 18:48:24 +02:00
thorkill
99e0f5777c Small typo fix and set slpd sockt O_NONBLOCK 2016-05-15 17:24:07 +02:00
thorkill
756a6607e1 Silence log output 2016-05-15 00:39:18 +02:00
thorkill
cdd148204f Introduction to Simple Local Peer Discovery Protocol (SLPD)
Full functionality of tinc mesh relays on having at least one node,
accessible, with known address to which all other nodes must connect
in order to exchange information about other peers.

Sometimes, however, in smaller networks or if two or more peers are
located in the same LAN segment without access to any of the nodes with
known address, there is no way of establishing a functional mesh
without manually changing the configuration.

SLPD addresses this problem utilizing multicast groups and autoconnect.
- Node sends periodically simple message to multicast group
  (default 224.0.42.23 port 1655) in this format:
   "sLPD 0 1 nodename port publickey"

   "0 1" is the "major minior" version of the protocol

- Node listens to the multicast group for messages on all interfaces:
  - if the nodename is known and the publickey matches the
    node's public key the source address of the packet
    will be stored as learned ip address

- at this point setup_outgoing_connection() will be able to
  choose the learned ip for connect

Configarion example:
* Roadwarriors: SLPDInterval = 30
* Router on your home network or in your hackerspace:
 - It should broadcast only in the direction of the LAN thus you should
   set SLPDInterface = eth0 and SLPDInterval = 10
* Defaults:
 SLPDGroup = "224.0.42.23"
 SLPDPort = 1655
 SLPDInterval = 0 (means SLPD is disabled)

The check of the publickey is not implemented yet. IPv6 support
must be implemented. This is the first commit - highly experimental.
2016-05-15 00:24:35 +02:00
thorkill
4401c645ab Silence log messages on autoconnect 2016-05-14 23:21:36 +02:00
thorkill
39b23f7a11 Make edge update work when compiled with --disable-legacy 2016-05-14 23:18:44 +02:00
thorkill
ddc74678b2 Fixed log message - it is destination not source address 2016-05-12 13:16:01 +02:00
thorkill
0cf943753a Send PKT_PROBE only when handshake has been done already. 2016-05-12 11:20:41 +02:00
thorkill
3ec36e6432 We still need excessive sptps logging 2016-05-11 23:39:09 +02:00
thorkill
3558ab5499 Removed additional debug output 2016-05-11 23:39:03 +02:00
thorkill
ae199d9f2b Removed type check and debug output.
We will send PKT_PROBE in send_sptps_packet only if handshake has been completed.
2016-05-11 19:30:58 +02:00
thorkill
62064cc5ef Send PKT_PROBE only when handshake has been done already. 2016-05-11 19:30:07 +02:00
thorkill
a84019cf10 Split error handling for accurate log messages in sptps_verify_datagram
"Received short packet" was misleading.
2016-05-11 18:51:57 +02:00
thorkill
fe18e0ed29 Reverted changes to try_tx_sptps
- should fix the problem with unknown source
at the beginning of communication between nodes
2016-05-11 18:39:15 +02:00
thorkill
41e801cbbd Revert "Temporal fix for 'unknown source' and broken direct UDP links."
This reverts commit 157bc90e64.
2016-05-10 23:51:22 +02:00
thorkill
0e6265f546 Removed backtrace callback function 2016-05-10 13:43:25 +02:00
thorkill
bd95c231ce Merge branch 'thkr-1.1-20160510-fix-receive_tcppacket_sptps' into thkr-1.1-ponyhof 2016-05-10 12:01:06 +02:00
thorkill
dc8ee9e6d1 Prevent receive_tcppacket_sptps from forwarding data when we are in handshake phase with those nodes
Forwarding data to node which does not have vaildkey yet would destroy
the running handshake.
2016-05-10 11:43:14 +02:00
thorkill
73ae43199c Allow PKT_PROBE in sptps_send_record
sptps_send_record prevented PKT_PROBE to be send in send_sptps_packet.
This occurred mostly when data was on "the wire" for some subnet.
route() would then trigger try_tx/try_udp which would be dropped by
sptps_send_record producing annoying amount of "Handshake phase
not finished yet" log messages.
2016-05-10 00:43:43 +02:00
thorkill
c5f46d3efb Removed backtrace callback 2016-05-10 00:37:39 +02:00
thorkill
75bca2543d Tabs vs spaces cleanup. 2016-05-10 00:17:38 +02:00
thorkill
c7d838eb41 Fixed autoconnect after merge 2016-05-08 16:46:29 +02:00
thorkill
08f1fd2f8d Fixes after merge with guus/1.1 2016-05-08 16:14:20 +02:00
thorkill
e6b85158f0 Added symbols necessary to link with logger.o 2016-05-08 16:12:41 +02:00
thorkill
4be26caf4e Merge remote-tracking branch 'guus/1.1' into thkr-foor2Vup 2016-05-08 15:58:29 +02:00
Guus Sliepen
2055c3e21d AutoConnect now only chooses from nodes for which we know an address.
Based partially on work from Rafał Leśniak.
2016-04-30 20:11:55 +02:00
Guus Sliepen
8377d0b856 Fix BSD tun device support.
This was broken by a botched merge from the master branch in commit d7f6737.
2016-04-27 20:30:36 +02:00
Guus Sliepen
390d25f0b8 Releasing 1.1pre12. 2016-04-24 13:23:06 +02:00
Guus Sliepen
5a7c6546a4 Don't check file permissions on Windows during fsck. 2016-04-23 21:39:53 +02:00
Guus Sliepen
83fa44ce42 Fix starting tinc as a service on Windows.
Don't assume tincd.exe is in the working directory, especially now that
chdir() is called very early. We use GetModuleFileName() instead.
2016-04-23 21:32:42 +02:00
Guus Sliepen
9a66d7499a Fix a compiler warning on Windows. 2016-04-23 21:32:29 +02:00
Guus Sliepen
ab5f4cbdc6 Fix possible read of freed memory when verifying the signature of a file. 2016-04-23 17:28:30 +02:00
Guus Sliepen
76955a6c8b Have "tinc fsck" recognize Ed25519PublicKey statements. 2016-04-23 17:20:08 +02:00
Guus Sliepen
51a0dc5145 Fix the "network" command in tinc shell. 2016-04-17 18:11:04 +02:00
Guus Sliepen
b6b302cee9 Speed up AutoConnect at startup.
Call periodic_handler() immediately at startup. Also, don't try to
connect to ourself.
2016-04-17 17:06:11 +02:00