From 10b8518c221ebc3c74fd849bc43ca452f4ee68e9 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Mon, 26 Aug 2019 13:52:00 +0200 Subject: [PATCH] New upstream version 1.0.36 --- AUTHORS | 20 +- COPYING | 2 +- COPYING.README | 20 +- ChangeLog | 24881 +++--------------------- Makefile.am | 31 +- Makefile.in | 59 +- NEWS | 1062 +- README | 149 +- README.android | 38 +- THANKS | 12 +- aclocal.m4 | 5 - config.h.in | 99 +- configure | 1532 +- configure.ac | 106 +- doc/Makefile.am | 25 +- doc/Makefile.in | 47 +- doc/sample-config/tinc.conf | 6 +- doc/tinc-gui.8.in | 57 - doc/tinc.8.in | 345 - doc/tinc.conf.5.in | 324 +- doc/tinc.info | 2582 +-- doc/tinc.texi | 1569 +- doc/tincd.8.in | 50 +- doc/tincinclude.texi | 2 +- m4/ax_append_flag.m4 | 30 +- m4/ax_code_coverage.m4 | 264 - m4/curses.m4 | 44 - m4/libgcrypt.m4 | 33 - m4/miniupnpc.m4 | 40 - m4/openssl.m4 | 5 +- m4/readline.m4 | 42 - src/Makefile.am | 222 +- src/Makefile.in | 836 +- src/address_cache.c | 277 - src/address_cache.h | 50 - src/autoconnect.c | 195 - src/autoconnect.h | 25 - src/avl_tree.c | 757 + src/avl_tree.h | 142 + src/bsd/device.c | 168 +- src/bsd/tunemu.c | 6 +- src/buffer.c | 110 - src/buffer.h | 18 - src/chacha-poly1305/chacha-poly1305.c | 106 - src/chacha-poly1305/chacha-poly1305.h | 15 - src/chacha-poly1305/chacha.c | 224 - src/chacha-poly1305/chacha.h | 24 - src/chacha-poly1305/poly1305.c | 205 - src/chacha-poly1305/poly1305.h | 16 - src/cipher.h | 46 - src/conf.c | 257 +- src/conf.h | 41 +- src/connection.c | 137 +- src/connection.h | 106 +- src/control.c | 241 - src/control.h | 27 - src/control_common.h | 48 - src/crypto.h | 27 - src/cygwin/device.c | 69 +- src/device.h | 9 +- src/digest.h | 42 - src/dropin.c | 22 +- src/dropin.h | 50 +- src/dummy_device.c | 18 +- src/ecdh.h | 34 - src/ecdsa.h | 37 - src/ecdsagen.h | 29 - src/ed25519/ecdh.c | 51 - src/ed25519/ecdsa.c | 168 - src/ed25519/ecdsagen.c | 73 - src/ed25519/ed25519.h | 37 - src/ed25519/fe.c | 1511 -- src/ed25519/fe.h | 41 - src/ed25519/fixedint.h | 91 - src/ed25519/ge.c | 467 - src/ed25519/ge.h | 74 - src/ed25519/key_exchange.c | 80 - src/ed25519/keypair.c | 16 - src/ed25519/precomp_data.h | 1391 -- src/ed25519/sc.c | 785 - src/ed25519/sc.h | 12 - src/ed25519/sha512.c | 303 - src/ed25519/sha512.h | 21 - src/ed25519/sign.c | 31 - src/ed25519/verify.c | 77 - src/edge.c | 60 +- src/edge.h | 21 +- src/ethernet.h | 19 +- src/event.c | 484 +- src/event.h | 69 +- src/fake-getaddrinfo.c | 108 + src/fake-getaddrinfo.h | 57 + src/fake-getnameinfo.c | 64 + src/fake-getnameinfo.h | 16 + src/fd_device.c | 125 - src/fsck.c | 603 - src/fsck.h | 25 - src/gcrypt/cipher.c | 284 - src/gcrypt/crypto.c | 34 - src/gcrypt/digest.c | 182 - src/gcrypt/digest.h | 45 - src/gcrypt/prf.c | 121 - src/gcrypt/rsa.c | 327 - src/gcrypt/rsagen.c | 239 - src/getopt.c | 40 +- src/getopt.h | 139 +- src/graph.c | 262 +- src/hash.c | 128 - src/hash.h | 42 - src/have.h | 52 +- src/ifconfig.c | 304 - src/ifconfig.h | 31 - src/info.c | 357 - src/info.h | 26 - src/invitation.c | 1351 -- src/invitation.h | 26 - src/ipv4.h | 4 +- src/ipv6.h | 39 +- src/linux/device.c | 153 +- src/list.c | 80 +- src/list.h | 20 +- src/logger.c | 199 +- src/logger.h | 31 +- src/meta.c | 367 +- src/meta.h | 10 +- src/mingw/common.h | 5 - src/mingw/device.c | 253 +- src/multicast_device.c | 127 +- src/names.c | 180 - src/names.h | 38 - src/net.c | 914 +- src/net.h | 130 +- src/net_packet.c | 1743 +- src/net_setup.c | 1430 +- src/net_socket.c | 672 +- src/netutl.c | 118 +- src/netutl.h | 12 +- src/node.c | 204 +- src/node.h | 76 +- src/nolegacy/crypto.c | 94 - src/nolegacy/prf.c | 121 - src/openssl/cipher.c | 215 - src/openssl/crypto.c | 114 - src/openssl/digest.c | 171 - src/openssl/digest.h | 33 - src/openssl/prf.c | 86 - src/openssl/rsa.c | 146 - src/openssl/rsagen.c | 119 - src/pidfile.c | 142 + src/pidfile.h | 57 + src/prf.h | 25 - src/process.c | 534 +- src/process.h | 7 +- src/protocol.c | 229 +- src/protocol.h | 77 +- src/protocol_auth.c | 919 +- src/protocol_edge.c | 172 +- src/protocol_key.c | 461 +- src/protocol_misc.c | 308 +- src/protocol_subnet.c | 68 +- src/proxy.c | 366 + src/{upnp.h => proxy.h} | 26 +- src/raw_socket_device.c | 57 +- src/route.c | 489 +- src/route.h | 2 +- src/rsa.h | 36 - src/rsagen.h | 29 - src/script.c | 232 - src/script.h | 38 - src/solaris/device.c | 96 +- src/splay_tree.c | 630 - src/splay_tree.h | 117 - src/sptps.c | 767 - src/sptps.h | 95 - src/sptps_keypair.c | 123 - src/sptps_speed.c | 308 - src/sptps_test.c | 471 - src/subnet.c | 533 +- src/subnet.h | 30 +- src/subnet_parse.c | 490 - src/system.h | 8 +- src/tincctl.c | 3352 ---- src/tincctl.h | 55 - src/tincd.c | 603 +- src/top.c | 396 - src/top.h | 25 - src/uml_device.c | 114 +- src/upnp.c | 185 - src/utils.c | 238 +- src/utils.h | 21 +- src/vde_device.c | 45 +- src/version.c | 31 - src/version.h | 27 - src/xalloc.h | 8 +- systemd/Makefile.in | 22 +- systemd/tinc@.service.in | 2 +- test-driver | 148 - test/Makefile.am | 30 - test/Makefile.in | 951 - test/basic.test | 20 - test/commandline.test | 50 - test/executables.test | 10 - test/import-export.test | 64 - test/invite-join.test | 46 - test/invite-offline.test | 49 - test/invite-tinc-up.test | 51 - test/legacy-protocol.test | 79 - test/ns-ping.test | 70 - test/scripts.test | 112 - test/security.test | 98 - test/splice.c | 144 - test/sptps-basic.test | 32 - test/testlib.sh | 41 - test/variables.test | 86 - 214 files changed, 12416 insertions(+), 59622 deletions(-) delete mode 100644 doc/tinc-gui.8.in delete mode 100644 doc/tinc.8.in delete mode 100644 m4/ax_code_coverage.m4 delete mode 100644 m4/curses.m4 delete mode 100644 m4/libgcrypt.m4 delete mode 100644 m4/miniupnpc.m4 delete mode 100644 m4/readline.m4 delete mode 100644 src/address_cache.c delete mode 100644 src/address_cache.h delete mode 100644 src/autoconnect.c delete mode 100644 src/autoconnect.h create mode 100644 src/avl_tree.c create mode 100644 src/avl_tree.h delete mode 100644 src/buffer.c delete mode 100644 src/buffer.h delete mode 100644 src/chacha-poly1305/chacha-poly1305.c delete mode 100644 src/chacha-poly1305/chacha-poly1305.h delete mode 100644 src/chacha-poly1305/chacha.c delete mode 100644 src/chacha-poly1305/chacha.h delete mode 100644 src/chacha-poly1305/poly1305.c delete mode 100644 src/chacha-poly1305/poly1305.h delete mode 100644 src/cipher.h delete mode 100644 src/control.c delete mode 100644 src/control.h delete mode 100644 src/control_common.h delete mode 100644 src/crypto.h delete mode 100644 src/digest.h delete mode 100644 src/ecdh.h delete mode 100644 src/ecdsa.h delete mode 100644 src/ecdsagen.h delete mode 100644 src/ed25519/ecdh.c delete mode 100644 src/ed25519/ecdsa.c delete mode 100644 src/ed25519/ecdsagen.c delete mode 100644 src/ed25519/ed25519.h delete mode 100644 src/ed25519/fe.c delete mode 100644 src/ed25519/fe.h delete mode 100644 src/ed25519/fixedint.h delete mode 100644 src/ed25519/ge.c delete mode 100644 src/ed25519/ge.h delete mode 100644 src/ed25519/key_exchange.c delete mode 100644 src/ed25519/keypair.c delete mode 100644 src/ed25519/precomp_data.h delete mode 100644 src/ed25519/sc.c delete mode 100644 src/ed25519/sc.h delete mode 100644 src/ed25519/sha512.c delete mode 100644 src/ed25519/sha512.h delete mode 100644 src/ed25519/sign.c delete mode 100644 src/ed25519/verify.c create mode 100644 src/fake-getaddrinfo.c create mode 100644 src/fake-getaddrinfo.h create mode 100644 src/fake-getnameinfo.c create mode 100644 src/fake-getnameinfo.h delete mode 100644 src/fd_device.c delete mode 100644 src/fsck.c delete mode 100644 src/fsck.h delete mode 100644 src/gcrypt/cipher.c delete mode 100644 src/gcrypt/crypto.c delete mode 100644 src/gcrypt/digest.c delete mode 100644 src/gcrypt/digest.h delete mode 100644 src/gcrypt/prf.c delete mode 100644 src/gcrypt/rsa.c delete mode 100644 src/gcrypt/rsagen.c delete mode 100644 src/hash.c delete mode 100644 src/hash.h delete mode 100644 src/ifconfig.c delete mode 100644 src/ifconfig.h delete mode 100644 src/info.c delete mode 100644 src/info.h delete mode 100644 src/invitation.c delete mode 100644 src/invitation.h delete mode 100644 src/names.c delete mode 100644 src/names.h delete mode 100644 src/nolegacy/crypto.c delete mode 100644 src/nolegacy/prf.c delete mode 100644 src/openssl/cipher.c delete mode 100644 src/openssl/crypto.c delete mode 100644 src/openssl/digest.c delete mode 100644 src/openssl/digest.h delete mode 100644 src/openssl/prf.c delete mode 100644 src/openssl/rsa.c delete mode 100644 src/openssl/rsagen.c create mode 100644 src/pidfile.c create mode 100644 src/pidfile.h delete mode 100644 src/prf.h create mode 100644 src/proxy.c rename src/{upnp.h => proxy.h} (62%) delete mode 100644 src/rsa.h delete mode 100644 src/rsagen.h delete mode 100644 src/script.c delete mode 100644 src/script.h delete mode 100644 src/splay_tree.c delete mode 100644 src/splay_tree.h delete mode 100644 src/sptps.c delete mode 100644 src/sptps.h delete mode 100644 src/sptps_keypair.c delete mode 100644 src/sptps_speed.c delete mode 100644 src/sptps_test.c delete mode 100644 src/subnet_parse.c delete mode 100644 src/tincctl.c delete mode 100644 src/tincctl.h delete mode 100644 src/top.c delete mode 100644 src/top.h delete mode 100644 src/upnp.c delete mode 100644 src/version.c delete mode 100644 src/version.h delete mode 100755 test-driver delete mode 100644 test/Makefile.am delete mode 100644 test/Makefile.in delete mode 100755 test/basic.test delete mode 100755 test/commandline.test delete mode 100755 test/executables.test delete mode 100755 test/import-export.test delete mode 100755 test/invite-join.test delete mode 100755 test/invite-offline.test delete mode 100755 test/invite-tinc-up.test delete mode 100755 test/legacy-protocol.test delete mode 100755 test/ns-ping.test delete mode 100755 test/scripts.test delete mode 100755 test/security.test delete mode 100644 test/splice.c delete mode 100755 test/sptps-basic.test delete mode 100644 test/testlib.sh delete mode 100755 test/variables.test diff --git a/AUTHORS b/AUTHORS index 07939e8..af11393 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,25 +1,20 @@ Main tinc authors: - - Guus Sliepen - Ivo Timmermans (inactive) -Significant code contributions from: - -- Brandon Black -- Etienne Dechamps +Significant contributions from: +- Michael Tokarev - Florian Forster - Grzegorz Dymarek -- Julien Muchembled -- Loïc Grenié - Max Rijevski -- Michael Tokarev - Scott Lamb -- Sven-Haegar Koch +- Julien Muchembled - Timothy Redaelli +- Brandon Black +- Loïc Grenié These files are from other sources: - -* lib/pidfile.h and lib/pidfile.c are by Martin Schulze, taken from + * lib/pidfile.h and lib/pidfile.c are by Martin Schulze, taken from the syslog 1.3 sources. * src/bsd/tunemu.c and tunemu.h are by Friedrich Schöller @@ -28,4 +23,5 @@ These files are from other sources: Also some of the macro files in the directory m4, and their accompanying files in lib, were taken from GNU fileutils. -Please see the file THANKS for a list of all contributors to tinc. +Please see the file THANKS for more information on contributions from +users. diff --git a/COPYING b/COPYING index 1a88dcf..1384f46 100644 --- a/COPYING +++ b/COPYING @@ -1,4 +1,4 @@ -Copyright (C) 1998-2018 Ivo Timmermans, Guus Sliepen and others. +Copyright (C) 1998-2019 Ivo Timmermans, Guus Sliepen and others. See the AUTHORS file for a complete list. This program is free software; you can redistribute it and/or modify it under diff --git a/COPYING.README b/COPYING.README index 166102b..2eb9c1f 100644 --- a/COPYING.README +++ b/COPYING.README @@ -1,17 +1,19 @@ The following applies to tinc: -> This program is released under the GPL with the additional exemption that -> compiling, linking, and/or using OpenSSL is allowed. You may provide binary -> packages linked to the OpenSSL libraries, provided that all other requirements -> of the GPL are met. +This program is released under the GPL with the additional exemption that +compiling, linking, and/or using OpenSSL is allowed. You may provide binary +packages linked to the OpenSSL libraries, provided that all other requirements +of the GPL are met. The following applies to the LZO library: -> Hereby I grant a special exception to the tinc VPN project -> (https://www.tinc-vpn.org/) to link the LZO library with the OpenSSL library -> (https://openssl.org). -> -> Markus F.X.J. Oberhumer + Hereby I grant a special exception to the tinc VPN project + (http://tinc.nl.linux.org/) to link the LZO library with the OpenSSL library + (http://www.openssl.org). + + Markus F.X.J. Oberhumer When tinc is compiled with the --enable-tunemu option, the resulting binary falls under the GPL version 3 or later. + + diff --git a/ChangeLog b/ChangeLog index e28cde2..041bf3f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,22659 +1,2224 @@ -commit 2b74e1b01af2d56d6e7ebc135143fbe81f6ca455 -Author: Guus Sliepen -Date: Mon Oct 8 11:00:01 2018 +0200 +Version 1.0.36 August 26 2019 +------------------------------------------------------------------------ + +Guus Sliepen (8): + Remove the call to RAND_load_file(). + Update THANKS. + Backport tinc 1.1's str2net() function. + Update THANKS. + Fix spelling errors found by codespell. + Reformat all code using astyle. + Add a missing check for a pathname being too long. + Releasing 1.0.36. + +Rosen Penev (2): + Fix compilation when OpenSSL has no ENGINE support + Fix compilation without deprecated OpenSSL APIs + +Quentin Rameau (1): + Double-quote nodes in graphviz network file + +Werner Schreiber (1): + Fix segfault when dest->mtu is 0. + +Version 1.0.35 October 05 2018 +------------------------------------------------------------------------ + +Guus Sliepen (12): + Prevent oracle attacks (CVE-2018-16737, CVE-2018-16738) + Prevent a MITM from forcing a NULL cipher for UDP (CVE-2018-16758) + Check the return value from snprintf(). + Check the return values from BN_hex2bn() and RAND_load_file(). + Fix all warnings when compiling with -Wall -W -pedantic. + Fix two small memory leaks. + Don't check for NULL-pointers before calling free(). + Update THANKS. + Fix checks for Cygwin-related macros. + Fix spelling errors. + Update README and links to required libraries. + Releasing 1.0.35. + +AMRI Amine (1): + Fixing typo + +Rafael Sadowski (1): + OpenBSD has a proper tap device. + +Version 1.0.34 June 12 2018 +------------------------------------------------------------------------ + +Guus Sliepen (10): + Add missing thanks to the NEWS message. + Fix building documentation when using OpenBSD's make. + Fix #ifdefs that were broken due to commit d178b58. + Don't use SOL_IP and SOL_IPV6. + Make systemd service file handling identical to tinc 1.1. + Rename distro/ to systemd/. + Document how to enable tinc at boot time using systemd. + Fix all spelling errors found by codespell. + Properly implement tinc.texi's dependency on tincinclude.texi. + Releasing 1.0.34. + +Maximilian Stein (1): + Fix SEGFAULT when trying to connect to IPv6 peer in non-IPv6 environment + +wangliushuai (1): + Remove redundant 'break'. + +Version 1.0.33 November 04 2017 +------------------------------------------------------------------------ + +Guus Sliepen (31): + Udpate THANKS. + Fix a potential memory leak. + Use AC_CONFIG_MACRO_DIR(). + Give absolute path for #include to AC_CHECK_HEADERS(). + Prepare for automatic code formatting using Artistic Style. + Never remove items from cmdline_conf. + Use stack-allocated strings for temporary filenames. + Fix a few minor memory leaks. + Remove unused/obsolete checks from configure.ac. + Use getcwd() instead of get_current_dir_name(). + Remove xmalloc.c, backport xalloc.h from tinc 1.1. + Update all header guards. + Convert sizeof foo to sizeof(foo). + Reformat all code using astyle. + Don't call ERR_remove_state(). + Unconditionally include stdbool.h and inttypes.h. + Remove more obsolete autoconf checks. + Remove obsolete m4/README. + Fix some "make distcheck" errors. + Add some information about the requirements of a chroot environment. + Handle tun/tap device returning EPERM or EBUSY. + Disable PMTU discovery when TCPOnly is used. + Fix all -Wall -W compiler warnings. + Realign comments. + Remove unused functions. + Ensure all parameters have names in header files. + Support autoconf's --runstatedir option. + Const correctness. + Fix compilation errors when --enable-uml is used. + Update THANKS. + Releasing 1.0.33. + +Rafael Sadowski (1): + fix tinc.conf for OpenBSD + +nemunaire (1): + Allow compilation from a build directory + +Version 1.0.32 September 02 2017 +------------------------------------------------------------------------ + +Guus Sliepen (13): + Don't dereference myself->incipher if it's NULL. + Merge remote-tracking branch 'VittGam/master' + Use /dev/udp instead of /dev/ip on Solaris. + Use getmsg()/putmsg() instead of read()/write() on Solaris. + Fix Solaris DeviceType = tap in router Mode. + Bind outgoing TCP sockets. + Move logging of "would block" messages to debug level 4. + Set KillMode=mixed in the systemd service file. + Don't forget about outgoing connections on host file read errors. + Fix Proxy = exec. + Set status.proxy_passed early for Proxy = exec. + Don't try to bind Proxy = exec sockets to an address. + Releasing 1.0.32. + +Vittorio Gambaletta (VittGam) (1): + route: Support ToS/DiffServ priority inheritance when routing IPv6 packets. + +Version 1.0.31 January 15 2017 +------------------------------------------------------------------------ + +Guus Sliepen (1): + Releasing 1.0.31. + +Élie Bouttier (1): + Remove ExecStop in tinc@.service + +Version 1.0.30 October 30 2016 +------------------------------------------------------------------------ + +Guus Sliepen (11): + Allow non-empty lines after status code from a HTTP proxy. + Fix proxy reply parsing broken by the previous commit. + Log only the first line of a proxy request rejection message. + Delay sending the real ID request until after a proxy request is granted. + Use AES256 and SHA256 by default, also for the meta-connections. + Enforce maximum amount of bytes sent/received on meta-connections. + Fix bit shifting arithmetic so the code actually does what the last commit message says. + Really fix byte budget calculation. + Use AES in CTR mode instead of OFB mode for meta-connections. + Use CFB mode for meta-connections to improve security. + Releasing 1.0.30. + +Version 1.0.29 October 09 2016 +------------------------------------------------------------------------ + +Guus Sliepen (11): + Preserve IPv6 scope_id in edges. + Ensure compatibility with OpenSSL 1.1.0. + Add -Wall to CFLAGS. + Check return value of RSA_generate_key_ex(). + Force nul-termination of strings after vsnprintf(). + Log warnings about dropped packets only with debug level 5 or higher. + Add a copy of ax_append_flag.m4. + Add ax_require_defined.m4. + Fix possibly unitialized variable. + Fix compiler warnings about format string errors on BSD. + Releasing 1.0.29. + +Version 1.0.28 April 10 2016 +------------------------------------------------------------------------ + +Guus Sliepen (8): + Fix compiling bsd/device.c on systems without utun. + Really remove use of __DATE__ and __TIME__ to facilitate reproducible builds. + Add systemd service files. + Update .gitignore. + Ensure the service files are in the tarball. + Explicitly mention that LibreSSL can be used as well. + Update links in the documentation. + Releasing 1.0.28. + +Version 1.0.27 April 10 2016 +------------------------------------------------------------------------ + +Guus Sliepen (26): + Add missing AM_PROG_CC_C_O to configure.ac. + Attribution for various contributors. + Update "now" after connect() when making outgoing connections. + Add ability to use proxies to connect to hostnames when there is no nameserver. + Only add a reflexive address when we're sure it's working. + Fix compatibility with TAP-Win32 9.0.0.21 and later. + Fix warnings from the Clang Static Analyzer. + Improve performance of edge updates. + Clarify that scripts are called synchronously. + Small fixes for the documentation. + Add warnings for bad combinations of Device and Interface. + Fix forwarding of edge updates. + Don't compile getopt*.c if the system provides getopt_long(). + Update .gitignore. + Update THANKS. + Use iface instead of interface. + Update copyright notices. + Remove use of __DATE__ and __TIME__ to facilitate reproducible builds. + Cast 0xff to char before comparing it to another char. + Get rid of a warning when compiling tinc using MinGW. + Every BSD flavor has a tap device nowadays. + Use devname() if available to support devfs cloning on BSD. + Use SIOCGIFADDR on BSDs that support it. + Enable silent builds by default. + Add support for OS X utun interfaces. + Releasing 1.0.27. + +Vittorio Gambaletta (VittGam) (6): + Fix DecrementTTL option. + Fix source IP address for ICMP unreachable packets generated by tinc. + Try to reply with node address only when decrementing the TTL. + Fix DecrementTTL option for packets destined to the local node. + s/broadcast_packet_helper/route_broadcast/ + Remove forward declaration for do_decrement_ttl. + +LunarShaddow (3): + fix typo + re-arrange include sequence to avoid a mingw introduced bug. + Proofing README. + +Florian Weik (1): + Fix NAME variable in subnet-* scripts for local subnets. + +Nathan Stratton Treadway (1): + Fix invalid checksum generation. + +Version 1.0.26 July 05 2015 +------------------------------------------------------------------------ + +Guus Sliepen (14): + Use VittGam's real name. + Attribution for Saverio Proto. + Always call res_init() before getaddrinfo(). + Fix --logfile without a filename on Windows. + Never call putenv() with data on the stack. + Return non-zero exit code when encountering configuration errors during startup. + Fix autoconf check for function attributes. + Fix spelling of FORTIFY_SOURCE. + Update copyright notices. + Attribution for various contributors. + Only check for -fno-strict-overflow if -fwrapv does not work. + Fix unputenv() on Windows. + Don't try to call res_init() if ./configure told us it doesn't exist. + Releasing 1.0.26. + +Jo-Philipp Wich (1): + fix musl compatibility + +Version 1.0.25 December 22 2014 +------------------------------------------------------------------------ + +Guus Sliepen (7): + Fix date of last NEWS entry. + Remember ToS/Diffserv priority for each socket individually. + Attribution for various contributors. + Automatically choose a tap device on Mac OS X when using switch Mode. + Update documentation for Mac OS X. + Check whether res_init() really lives in libresolv. + Releasing 1.0.25. + +Borg (3): + Fixed scripts calling under Win32. + Get MAC of TAP device. + Fixed tinc-up script calling on Win32. + +Alexis Hildebrandt (1): + Add support to link against libresolv Mac OS X + +Baptiste Jonglez (1): + Use the description from the 1.1 man page for the IndirectData option + +David Pflug (1): + Update README.android + +Jochen Voss (1): + Fix some typos in the manual. + +Tomislav Čohar (1): + Configure minimum reconnect timeouts. + +VittGam (1): + Support ToS/DiffServ priority handling for IPv6 meta and UDP connections. + +Version 1.0.24 May 11 2014 +------------------------------------------------------------------------ + +Guus Sliepen (13): + Remove useless variable 'hard' from try_harder(). + Merge pull request #14 from luckyhacky/master + Add an autoconf check for res_init(). + Nexthop calculation should always use the shortest path. + Fix issues found by Coverity. + Fix warnings found by GCC 4.9. + Fix a few more issues found by Coverity. + Fix a few more issues found by Coverity. + Drop h and hh length modifiers from printf format strings. + Fix a bug that could prevent tinc from starting correctly on Windows. + FIx the autoconf checks for res_init(). + Remove the warnings when IP_DONTFRAGMENT/IPV6-DONTFRAG is not supported. + Releasing 1.0.24. + +Steffan Karger (3): + Use constant time memcmp() when comparing packet HMACs. + Use cryptographically strong random when generating keys. + Check RAND_bytes() return value, fail when getting random fails. + +Armin Fisslthaler (1): + reload /etc/resolv.conf in SIGALRM handler + +Loic Dachary (1): + fix documentation typo + +luckyhacky (1): + update to openssl version 1.0.1g due to lack of heartbleed bug in prior version of openssl + +refs/tags/1.0.23-android-1 March 11 2014 +------------------------------------------------------------------------ + +Guus Sliepen (13): + Mention in the manual that multiple Address staments are allowed. + If no Port is specified, set myport to actual port of first listening socket. + Enable compiler hardening flags by default. + Update support for Solaris. + Include for PATH_MAX. + Stricter check for raw socket support. + Use hardcoded value for TUNNEWPPA if net/if_tun.h is missing on Solaris. + Fix incorrectly merged bits from 80cd2ff73071941a5356555b85a00ee90dfd0e16. + Don't enable -fstack-protector-all. + Remove or lower the priority of some debug messages. + Clarify StrictSubnets. + Attribution for various contributors. + Handle errors from TAP-Win32/64 adapter in a better way. + +Florent Clairambault (2): + Adding "conf.d" configuration dir support. + Adding some documentation around the /etc/tinc/$NET/conf.d directory. + +Vilbrekin (1): + Update android build instructions. Disable PIE as this is not supported on some devices. + +Version 1.0.23 October 19 2013 +------------------------------------------------------------------------ + +Guus Sliepen (9): + Check for writability when waiting for a socket to finish connecting. + Don't send PING requests on connections which are not active yet. + Fix segfault when Name = $HOST but $HOST is not set. + Fix typos in the documentation. + Modernize the build system. + Get rid of the splay tree implementation. + Add description of IffOneQueue and MaxTimeout to the info manual. + Clean up child processes from proxy type exec. + Releasing 1.0.23. + +Version 1.0.22 August 13 2013 +------------------------------------------------------------------------ + +Guus Sliepen (7): + Better optional argument handling. + Fix a typo. + Set $NAME when calling host-up/down and subnet-up/down scripts. + Don't use vasprintf() anymore on Windows. + Don't echo broadcast packets back when Broadcast = direct. + Update copyright notices. + Releasing 1.0.22. + +Etienne Dechamps (1): + Fix combination of Mode = router and DeviceType = tap on Linux. + +Version 1.0.21 April 22 2013 +------------------------------------------------------------------------ + +Guus Sliepen (2): + Drop packets forwarded via TCP if they are too big (CVE-2013-1428). + Releasing 1.0.21. + +Version 1.0.20 March 03 2013 +------------------------------------------------------------------------ + +Guus Sliepen (30): + Use /dev/tap0 by default on FreeBSD and NetBSD when using Mode = switch. + Document how to load the tap driver on FreeBSD. + Update THANKS file. + Also clarify hostnames=[yes|no] in tinc.conf(5). + Attribution for Vil Brekin and some code style cleanups. + Don't ignore Makefile.am. + Fix links in documenation. + Attribution for Martin Schürrer. + Add strict checks to hex to binary conversions. + Clear connection options and status fields in free_connection_partially(). + Fix warnings from cppcheck. + Clear Ethernet header when reading packets from a tun device. + Clear status and options fields of unreachable nodes. + Fix warnings from groff. + Using alloca() for a constant sized buffer is very silly. + Make sure PMTU discovery works in switch mode with VLAN tags. + Mention in the manual that support for LZO and zlib can be disabled. + Fix configure script help text for --enable options. + Don't take the address of a variable whose scope is about to disappear. + Send broadcast packets using a random socket, and properly support IPv6. + Remove text saying you must have one of PrivateKey or PrivateKeyFile in tinc.conf. + Fix support for tunemu on iOS devices. + Make sure PriorityInheritance also works in switch mode. + Detect increases in PMTU. + Fix a compiler warning. + Fix segmentation fault when trying to connect via a SOCKS5 proxy. + Don't send proxy requests for incoming connections. + Fix compiler warnings on Windows. + Fix detection of rejected SOCKS5 proxy requests. + Releasing 1.0.20. + +Vilbrekin (5): + Basic patch for android cross-compilation. + Replace hard-code with new ScriptsInterpreter configuration property. + Add basic .gitignore file, cleaning (most) files generated by autotools. + Use __ANDROID__ define rather than dirty hard-code to allow android NDK cross-compilation. + Android cross-compilation instructions. + +Martin Schürrer (1): + Output details of encryption errors + +Mesar Hameed (1): + Minor clarification, tinc.conf hostnames=[yes|no] variable only resolves names for logging purposes. + +Version 1.0.19 June 25 2012 +------------------------------------------------------------------------ + +Guus Sliepen (14): + Support :: in IPv6 Subnets. + Remove newline from log message. + Add support for systemd style socket activation. + Allow environment variables to be used for Name. + Allow broadcast packets to be sent directly instead of via the MST. + Add basic support for SOCKS 4 and HTTP CONNECT proxies. + Add support for SOCKS 5 proxies. + Add support for proxying through an external command. + Document new proxy types. + Small fixes in proxy code. + #include on Windows. + Fix compiler warnings. + Fix crash when using Broadcast = direct. + Releasing 1.0.19. + +Anthony G. Basile (1): + configure.in: fix AC_ARG_ENABLE and AC_ARG_WITH + +Michael Tokarev (1): + add (errnum) in front of windows error messages + +Version 1.0.18 March 25 2012 +------------------------------------------------------------------------ + +Guus Sliepen (13): + Always try next Address when an outgoing connection fails to authenticate. + Allow a port to be specified in BindToAddress statements. + Add support for multicast communication with UML/QEMU/KVM. + Set default value of DecrementTTL to "no". + Add #ifdefs in case not all platforms support IPv4 and IPv6 multicast. + Allow scoped addresses to be used for IPv6 multicast socket. + Fix compiler warnings. + Fix return value type of vde_send(). + Fix some more compiler warnings. + Document OpenBSD "ifconfig link0" and Linux "ip tuntap" commands. + Fix return type of vde_recv() as well. + Mark DecrementTTL option experimental. + Releasing 1.0.18. + +Version 1.0.17 March 10 2012 +------------------------------------------------------------------------ + +Guus Sliepen (32): + Prevent read_rsa_public_key() from returning an uninitialized RSA structure. + Return false instead of void when there is an error. + Fix compilation of VDE and UML interfaces. + Add vde/device.c to the tarball. + Fix a few small memory leaks. + Allow linking with multiple device drivers. + Set FD_CLOEXEC flag on all sockets. + Allow multiple BindToAddress statements. + Merge branch 'master' of black:tinc + Send packets back using the same socket as they were received on. + Allow setting DeviceType to tun or tap on Linux. + Merge branch 'master' of black:tinc + Only compile raw socket code when it is supported on that platform. + Decrement TTL of incoming packets. + Don't bind outgoing TCP sockets anymore. + Rename connection_t *broadcast to everyone. + Allow disabling of broadcast packets. + Move initialization of char *priority up to prevent freeing an uninitialized pointer. + Document the command line flag -o and provide --option as well. + Fix a bug that caused tinc to ignore all but the last listening socket. + Fix check for raw socket support. + Pass index into listen_socket[] to handle_incoming_vpn_data(). + Add LocalDiscovery option which tries to detect peers on the local network. + Don't send ICMP Time Exceeded messages for other Time Exceeded messages. + Stricter checks against routing loops. + Only use broadcast at the start of the PMTU discovery phase. + Only log errors sending UDP packets when debug level >= 5. + Accept Subnets passed with the -o option when StrictSubnets = yes. + Add missing ICMP6 message type definitions. + Make sure disabling old RSA keys works on Windows. + Update copyright notices. + Releasing 1.0.17. + +Nick Hibma (1): + Add missing ICMP message type definitions. + +Version 1.0.16 July 23 2011 +------------------------------------------------------------------------ + +Guus Sliepen (4): + Make code to detect two nodes with the same Name less triggerhappy. + Flush output buffer in send_tcppacket(). + Use usleep() instead of sleep(), MinGW complained. + Releasing 1.0.16. + +Version 1.0.15 June 24 2011 +------------------------------------------------------------------------ + +Guus Sliepen (9): + Reorder checks for libraries to allow ./configure LDFLAGS=-static. + Make return value of SetPriorityClass() behave the same as setpriority(). + Fix sparse warnings and add an extra sprinkling of const. + Remove newlines from log messages. + Remove a few unnecessary #includes. + Attribution for Loïc Grenié. + Improved --logfile option. + Remove redundant @CFLAGS@ from AM_CFLAGS. + Releasing 1.0.15. + +Loïc Grenié (1): + Nearly tickless tinc. + +Version 1.0.14 May 08 2011 +------------------------------------------------------------------------ + +Guus Sliepen (48): + Fix reading configuration files that do not end with a newline. Again. + Define WINVER before including any other header file on Windows. + Use intptr_t instead of long to store a pointer. + OpenSSL 1.0.0 compiled for 64 bit Windows requires linking with -lcrypt32. + Fix all warnings when compiling with mingw64. + Use strrchr() insteaad of rindex(). + Detect and prevent two nodes with the same Name being on the VPN simultaneously. + Use 64 bit counters to keep track of bytes sent/received from the virtual network interface. + Do not append an address to ANS_KEY messages if we don't know any address. + Merge local host configuration with server configuration. + Remove duplicate command-line option parsing. + Attribution for Julien Muchembled. + Attribution for Timothy Redaelli. + Ensure there is a newline character before a PEM key is written. + Abort disabling old PEM keys on I/O errors. + Remove unused variables. + Quit when there are too many consecutive errors on the tun/tap device. + Read error counter must be static. + Add short options -R and -U to the tincd(8) manpage. + Don't use strlen() on a NULL pointer. + Provide usleep() for Windows. + Use variable length arrays instead of alloca(). + Fix warning message when setting SO_RCVBUF or SO_SNDBUF fails. + Free replay window when freeing a node_t. + Fix variable length array declaration. + Attribution for Brandon Black. + Use setpriority() instead of nice() on UNIX-like systems. + Always send MTU probes at least once every PingInterval. + Close all filedescriptors in Solaris close_device(). + Limit field width when scanning PID file. + Replace bogus #else with #endif. + Remove unused variables. + Document the behavior of "-n." + Update the manual. + Update the NEWS. + Proper check and dropin replacement for usleep(). + Fix typo spotted by Andrew Scheller. + Add support for VDE through libvdeplug. + Fix spurious misidentification of incoming UDP packets. + Prevent anything from updating our own UDP address. + Do not set indirect flag on edges from nodes with multiple addresses. + Increase threshold for detecting two nodes with the same Name. + Always use the default signal handler for ABRT signals. + Check for EVP_EncryptInit_ex instead of SHA1_Version in OpenSSL. + Update THANKS and copyright information. + Ensure proper linking with OpenSSL with recent versions of MinGW. + Include when using intptr_t. + Releasing 1.0.14. + +Brandon L Black (4): + Experimental IFF_ONE_QUEUE support for Linux + Configurable SO_RCVBUF/SO_SNDBUF for the UDP socket + Configurable ReplayWindow size, zero disables + Improved handling of queue-jumping packets on receive + +Julien Muchembled (2): + New '-o' option to configure server or hosts from command line + Fix command-line '-o' option for host configuration + +Timothy Redaelli (2): + Fix warnings showed using -D_FORTIFY_SOURCE=2 + Fix warnings under BSD + +Michael Tokarev (1): + Treat netname="." in a special way. + +Rumko (1): + DragonFlyBSD support + +Version 1.0.13 April 11 2010 +------------------------------------------------------------------------ + +Guus Sliepen (20): + Clamp MSS to miminum MTU in both directions. + Simplify reading lines from configuration files. + Check for dirent.h. + Preload all Subnets in TunnelServer mode. + Add the StrictSubnets option. + Add the Forwarding option. + Add the DirectOnly option. + Fixes for the Forwarding option. + ConnectTo does not mean tinc does not listen for incoming connections anymore. + Log unauthorized Subnets when StrictSubnets is set. + Fix typo. + Convert Port to numeric form before sending it to other nodes. + Ensure ICMP_NET_ANO is defined. + Reload Subnets when getting a HUP signal and StrictSubnets is used. + Fix reloading Subnets when StrictSubnets is set. + Ensure subnet-up/down scripts are called after HUP when necessary. + Fixes for definitions under Windows. + Don't redefine MAX if it already exists. + Mark Forwarding and DirectOnly options as being experimental. + Releasing 1.0.13. + +Timothy Redaelli (2): + Add --disable-lzo configure option + Add --disable-zlib configure option + +Sven-Haegar Koch (1): + Never delete Subnets when StrictSubnets is set + +Version 1.0.12 February 03 2010 +------------------------------------------------------------------------ + +Guus Sliepen (21): + When learning MAC addresses, only check our own Subnets for previous entries. + Remove unused variable in lookup_subnet_*() functions. + Forget addresses of unreachable nodes. + Do not fragment packets smaller than RFC defined minimum MTUs. + Allow port to be specified in Address statements. + Use xstrdup() instead of xasprintf() to copy static strings. + Allow Port and PMTUDiscovery options in tinc.conf, always enable PMTUDiscovery by default. + Clamp MSS of IPv4 SYN packets. + Ping nodes immediately when receiving SIGALRM. + Optimise handling of select() returning <= 0. + Also clamp MSS of TCP over IPv6 packets. + Make MSS clamping configurable, but enabled by default. + Fix subnet-up/down scripts being called with an empty SUBNET. + Run subnet-up/down scripts for local MAC addresses as well. + Be liberal in accepting KEY_CHANGED/REQ_KEY/ANS_KEY requests. + Determine peer's reflexive address and port when exchanging keys. + Immediately exchange keys when establishing a meta connection. + Try to set DF bit on BSDs as well. + Update copyright notices. + Ensure peers with a meta connection always have our key. + Releasing 1.0.12. + +Version 1.0.11 November 01 2009 +------------------------------------------------------------------------ + +Guus Sliepen (16): + Fix a possible crash when sending the HUP signal. + Starting to work towards 1.0.11. + Handle weighted Subnets in switch and hub modes. + Clarify and increase level of log message about MTU probes to unreachable nodes. + Add dummy device. + Use uint32_t instead of long int for connection options. + Allow UDP packets with an address different from the corresponding TCP connection. + Always reply to MTU probes via UDP. + Make maxmtu equal to minmtu when fixing the path MTU to a node. + Forward packets to not directly reachable hosts via UDP if possible. + Use IP_DONTFRAGMENT instead of IP_MTU_DISCOVER on Windows. + Use WSAGetLastError() to determine cause of network errors on Windows. + Move socket error interpretation to utils.h. + Fast handoff of roaming MAC addresses. + Start a tinc service if it already exists. + Releasing 1.0.11. + +Michael Tokarev (1): + Remove localedir leftovers. + +Version 1.0.10 October 18 2009 +------------------------------------------------------------------------ + +Guus Sliepen (78): + Update documentation for git. + Consistently allocate device and iface variables on the heap. + Only send packets via UDP if UDP communication is possible. + Move free()s at the end om main() to the proper destructor functions. + Change flush_events() to expire_events(). + Add missing cleanup functions in close_network_connections(). + Use a global list to track outgoing connections. + Remove unused definitions from net.h. + Allow reading config files with CRLF endings on Unix systems. + Validate Name before using it in a filename when generating a keypair. + Disable old RSA keys when generating new ones. + Handle neighbor solicitation requests without link layer addresses. + Allow weight to be assigned to Subnets. + Update THANKS and copyright information. + Disable PMTUDiscovery in switch and hub modes. + Use a simple Random Early Drop algorithm in send_tcppacket(). + Handle UDP packets from different and ports than advertised. + If PMTUDiscovery is not set, do not forward packets via TCP unnecessarily. + Fix link to Mattias Nissler's tun/tap driver for MacOS/X. + Fix initialisation of packet decryption context broken by commit 3308d13e7e3bf20cfeaf6f2ab17228a9820cea66. + Use xrealloc instead of if(ptr) ptr = xmalloc(). + Add declaration for sockaddrcmp_noport(). + Use packet size before decompression to calculate path MTU. + Do not forward broadcast packets when TunnelServer is enabled. + Add ProcessPriority option. + Add some const where appropriate. + Properly set HMAC length for incoming packets. + Don't try to send MTU probes to unreachable nodes. + Remove pending MTU probe events when a node's reachability status changes. + Do not log errors when recvfrom() returns EAGAIN or EINTR. + Change level of some debug messages, zero pointer after freeing hostname. + Always remove a node from the UDP tree before freeing it. + Add xasprintf() and xvasprintf(). + Check the return value of fscanf() when reading a PID file. + Replace asprintf() by xasprintf(). + UNIX signal numbers start at 1. + Ensure tinc compiles with gcc -std=c99. + Convert bitfields to integers in a safe way. + Add the GPL license to the repository. + Another safe bitfield conversion. + Add support for iPhones and recent iPods. + Don't stat() on iPhone/iPod. + Put Subnet weight in a separate environment variable. + Allow PMTUDiscovery in switch and hub modes again. + Handle unicast packets larger than PMTU in switch mode. + Remove superfluous call to avl_delete(). + Apparently it's impolite to ask GCC to subtract two pointers. + Use only rand(), not random(). + Also do not use drand48(), it is not available on Windows. + Allow compiling for Windows XP and higher. + Remove dropin random() function, as it is not used anymore. + Use access() instead of stat() for checking whether scripts exist. + Raise default crypto algorithms to AES256 and SHA256. + Remove extra {. + Use a mutex to allow the TAP reader to process packets faster on Windows. + Raise default RSA key length to 2048 bits. + Send large packets we cannot handle properly via TCP. + Update copyright information. + Remove all occurences of $Id$. + Remove Ivo's old email addresses. + Update the address of the Free Software Foundation in all copyright headers. + K&R style braces. + Remove checkpoint tracing. + Drop support for localisation. + Add more authors to the copyright headers. + Update the NEWS. + Remove autogenerated files from EXTRA_DIST. + Don't disconnect clients in TunnelServer mode who send unauthorised ADD_SUBNETs. + Remove code duplication when checking ADD_EDGE/DEL_EDGE messages. + Revert "Raise default crypto algorithms to AES256 and SHA256." + Ensure that the texinfo manual can be converted to HTML. + Small updates to the documentation. + Use MTU probes to regularly ping other nodes over UDP. + Allow the cloning /dev/tap interface to be used on FreeBSD and NetBSD. + Remove debugging message when reading packets from a BSD device. + Include missing header. + Fix description of the WEIGHT environment variable. + Releasing 1.0.10. + +Michael Tokarev (17): + Allow tunnelserver to work with clients that have other peers. + Enable PMTUDiscovery only if BOTH sides wants it. + Rename setup_network_connections() and split out try_outgoing_connections() + Implement privilege dropping + bugfix: initialize pid (as read from pidfile) to zero + bugfix: move mlock to after detach() so it works for child, not parent + bugfix: chdir(/) after chroot + change error messages in droppriv code to match the rest + format 'not supported on this platform' error message + TunnelServer: Don't disconnect client on DEL_SUBNET too + ignore indirect edge registrations in tunnelserver mode + don't log every strange packet coming to the UDP port + Fix ans_key exchange in recent changes + tunnelserver: log which ADD_SUBNET was refused + cleanup setpriority thing to make it readable + try outgoing connections before chroot/drop_privs + Remove extra semicolon in my definition of setpriority() + +Florian Forster (2): + src/linux/device.c: Fix segfault when running without `--net'. + src/net_socket.c: Bind outgoing TCP sockets to `BindToAddress'. + +Borg (1): + Removed last gettext function. + +Version 1.0.9 December 26 2008 +------------------------------------------------------------------------ + +Guus Sliepen (18): + Handle SERVICE_CONTROL_INTERROGATE requests. Thanks to Carsten Ralle for noticing this. + Make sure the prefixlength of subnets is sane. + Fix reading configuration files that do not end with a newline. + Do not try to send REQ_KEY or ANS_KEY requests to unreachable nodes. + Prevent freeing a NULL pointer when a hostname is unresolvable. + Correct debug message. + Treat virtual network device as tap if Mode = switch or hub. + Use TUNIFHEAD by default on FreeBSD to make sure IPv6 works. + Make sure IPv6 sockets are IPv6 only. + Update Dutch translation. + Update copyright information. + Enable PMTU discovery by default. + Update documentation. + Update the manpage as well, and some whitespace to make its source more legible. + Handle broadcast and multicast packets in router mode. + Apply patch from Max Rijevski fixing a memory leak when closing connections. + Add missing parentheses in check for IPv4 multicast addresses. + Releasing 1.0.9. + +Version 1.0.8 May 16 2007 +------------------------------------------------------------------------ + +Guus Sliepen (8): + Apply patch from Scott Lamb preventing an infinite loop when sending SIGALRM. + Apply patch from Scott Lamb fixing some memory and resource leaks. + Close the proper filedescriptor (if it exists). + Apply patch from "dnk" making sockets non-blocking under Windows. + Make sure connection->name is never NULL. + Update dutch translation. + Don't free struct addrinfo too early. Spotted by Christian Cier-Zniewski. + Releasing 1.0.8. + +Version 1.0.7 January 05 2007 +------------------------------------------------------------------------ + +Guus Sliepen (7): + Use a ringbuffer in shared memory to transfer packets from the tapreader thread to the main thread. + Tapreader socket should be bound to localhost only. + Fix generic BSD tun device to write only the actual packet length. + rename() cannot replace existing files on Windows. + No things to do for the 1.0 branch except bugfixing. + Update copyright notices. + Releasing 1.0.7. + +Version 1.0.6 December 18 2006 +------------------------------------------------------------------------ + +Guus Sliepen (13): + Make sure resolved addressed for outgoing connections are freed, if there are any. + Search for lzo/lzo1x.h, lzo2/lzo1x.h and lzo1x.h. + When building the minimum spanning tree, make sure we start from a reachable node. + Use the correct next pointer. + Remove unnecessary stuff from configure.in. + Remove old Spanish translation. + Fix rule that creates html version of manpages. + Use standard autoconf macros instead of our own. + We do properly check for malloc and realloc. + Remove the test for linux/if_tun.h. + Do a simple test for linux/if_tun.h instead of no test at all. + Prevent compiler warnings about redefinition of EAI_FAMILY on FreeBSD 6.1. + Releasing 1.0.6. + +Version 1.0.5 November 14 2006 +------------------------------------------------------------------------ + +Guus Sliepen (32): + Prevent possible buffer overflows when using very large (>= 8192 bit) RSA keys. + Add alloca.h to the list of necessary header files. + Enable OpenSSL ENGINE, so crypto hardware gets used. Thanks to Andreas van Cranenburgh. + EVP_Cleanup() when quitting. + Apply patch from Scott Lamb unifying configuration of TCP socket options. + Apply patch from Scott Lamb adding an output buffer for the TCP sockets. + Make sure $NAME is set correctly when executing tinc-down script. + Missing #include. + Export flush_meta(). + Fix signedness compiler warnings. + Fix a bug in handling prefixlengths that are not a multiple of 4. + Update copyright notices, remove Ivo's email address. + Restore length of the original packet in send_udppacket(). + Use memcpy() to copy sockaddrs returned by getaddrinfo(). + Add generic host-up and host-down scripts. + Do not break strict aliasing of status_t structs. + Fix format string warnings. + Remove unused variables. + Remove unused parameter from maskcmp(). + Remove unused variable. + memcpy() addresses from packet headers before calling the lookup functions. + The "active" bit in node.status is not used. + Added graph dumping ability based on Markus Goetz's patch. + popen() requires pclose(). + Support and autodetect LZO version 2.0 and later. + Support and autodetect LZO version 2.0 and later. + Document GraphDumpFile option. + Update Dutch translation. + Nodes use events, so event system should be initialised first and destroyed last. + When deleting an entire tree, start at head, not at root. + EWOULDBLOCK does not exist on platforms without O_NONBLOCK + Releasing 1.0.5. + +Version 1.0.4 May 04 2005 +------------------------------------------------------------------------ + +Guus Sliepen (17): + Make sure broadcast packet reach the local network interface. + Fix splay tree code. + subnet-up/down hooks + subnet-up/down hooks, use list_t for the todo list. + Small fix. + Free memory used by connection_t after it is deleted from the connection tree. + Use the proper free function. + Correct size argument for strncat(). + Nodes should only be in the node_udp_tree if they are reachable. + Don't try to add a non-existing node back to the node_udp_tree. + Remove unused (and potentially segfaulting) net2str() call. + Be on the safe side with initialisation of c->name. + Searching through splay trees may change the tree variable. + Several splay tree fixes. + Describe subnet-up/down scripts in documentation. + Update copyright notices. + Releasing 1.0.4. + +Version 1.0.3 November 11 2004 +------------------------------------------------------------------------ + +Guus Sliepen (77): + Removed items in TODO list that are already implemented. Only two items + Applied patch from Jamie Briggs for bash2 conformance. + Added another semicolon for bash2 compliance (thanks to Jamie Briggs) + Adding even more stuff from the CABAL branch. + Synchronise HEAD with CABAL branch. + This will become 2.0. + Some device.c files weren't synchronised. + Makevars file was accidentily removed. + Forgot to synchronise po/ directory... + Add description of new authentication scheme. + Add Opaque option which prevent information from being forwarded to certain nodes. + Replace Opaque and Strict options with a TunnelServer option. + Complain if pid file cannot be created. + Read MaxTimeout from tinc.conf like the manpage says. + Missing space between words. + Don't retry if configuration is wrong from the beginning. + Fix proxy-neighborsolicitation. + Code beautification, start of multicast support. + Forget multicast. Always inline some function. + Let tinc figure out the exact MTU of the link. + More sensible name, and try to set PMTU discovery on IPv6 sockets as well. + Describe the TunnelServer and PMTUDiscovery options. + Better name, show probed MTU in dump. + Improvements for PMTU discovery and IPv4 packet fragmentation. + Missing definitions. + Small fixes for PMTU discovery. + Don't forget to update destination MAC address. + Small updates. + Remove autogen.sh, the autoreconf program does exactly that. + Replace cvs-clean with a much better svn-clean. + Remove CVS related cruft. + Eat trailing whitespace in config files. + Only read our public key if it wasn't already in the private key file. + Updating dutch translation. + Even better svn-clean command. + Applied Martin Kihlgren's IdentityGenerosity patch, + Fix declaration of update_node_address(). + Use Subversion to create ChangeLog, better svn-clean rule. + Revert Martin Kihlgren's patch, it doesn't work the way it should. + Move CABAL branch to its rightful place: the trunk. + Update copyrights, links, email addresses and let Subversion update $Id$ keywords. + Increase MTU by 4 bytes to allow VLAN tagged Ethernet frames in hub and switch mode. + Clean up environment after executing scripts. + Handle timeouts during connecting the same way as other errors. + Added UML network socket handling. + Don't set $INTERFACE automatically, don't quit on EINTR/EAGAIN. + Marking potential late packets was in the wrong place. + Remove duplicate #include "system.h" + Move all #ifdef HAVE_HEADER_H #include to have.h, + Fix several #includes. + strndupa() is too arcane for some environments. + Allow tinc to work with the latest TAP-Win32 driver. + Correct return value. + Don't let tinc service depend on NDIS component. + Support alternative tun/tap driver from http://www-user.rhrk.uni-kl.de/~nissler/tuntap/ + Generic device driver for *BSD and MacOS/X + static + Check for sys/uio.h, net/if_tun.h and net/if_tap.h + Don't include .svn directory in sample configuration. + Splay trees. + Hoopjumping to get the default directories in the manuals properly. + Update to make it compile again. + Fixed another bug in late packet handling. + Hopefully this really fixes late packet handling. + Missing check for NULL-pointer. + Use the generic BSD tun/tap code. + Fix order of arguments for tar. + Let compiler decide when to inline. + Support tunneling IPv6 on Solaris. + Add BlockingTCP option, useful when using TCPOnly on slow or congested links. + Update documentation. + Set BSD tuns to broadcast mode. On OpenBSD, this enables IPv6 on the tun device! + Remove duplication. + Updated dutch translation. + Short readme about how to compile tinc from a Subversion checkout. + Add more people who have contributed to tinc. + Releasing 1.0.3. + +Ivo Timmermans (52): + Check for __gmpz_powm for libgmp3. + Changed version number to 1.0pre3. + Autogenerated by gettextize. + Bring head revision up to date with cabal (try #3) + Add check for the syslog function + Generalized error handling functions + Add all the new files to the sources list for the utility library + New function: xalloc_and_zero() + Generalized list and hash handling functions + First try to create a graphical frontend for tinc configuration + Updating HEAD branch #1; removing obsolete files. + Updating HEAD branch #2; removing debian/ dir. + Updating HEAD branch #3; more obsolete files removed. + Updating HEAD branch #4; Merging CABAL -> HEAD. + Updating HEAD branch #5; Last files from CABAL. + Ok, I forgot these ;) + More updates + More... + Last bits (hopefully) + Main pokey interface files. + Pokey interface definition + Write src/pokey/Makefile + Also compile in pokey/ + Remove debug level declaration + Update copyright info + Remove debug_lvl + New logging system to replace syslog() calls with a generic function. + Rename log_message to log + Add syslog() wrapper + Add syslog wrapper + Some magic + Added priority definitions from syslog.h + log_default_hook was renamed to log_default + Added prototype for log_syslog + Use logging.h instead of syslog.h + Compile in logging.c + Things to ignore... + Use new logging system + Include logging.h + Renamed libvpn to libtinc + Rename libvpn to libtinc + ... + Print newline when writing to stderr + *** empty log message *** + Moving files, first attempt at gcrypt compatibility, more interface + Commit diff test + Another file moved; random interface stuff. + Callbacks + Moved event.c/h + test + test 2 + Hm. + +Wessel Dankers (5): + Initial revision. Lots of loose ends, not usable yet. + added bit on config file, split up sections, added Id: tag + Added extra bit about keys. + More about keys + This file is now only in the CABAL revision. + +cvs2svn (1): + This commit was generated by cvs2svn to compensate for changes in r1352, + +Version 1.0.2 November 08 2003 +------------------------------------------------------------------------ + +Guus Sliepen (47): + Simplify fake getname/addrinfo() functions, possibly fixing freeing a NULL pointer. + stat() batch files under Windows. + Don't getsockopt() SO_ERROR. We get the error from send()/recv() anyway. + Fix fake getnameinfo() and check more arguments. + Fix --logfile under Windows. + Use the event log under Windows. + Compilation fix. + Do what the SDK documentation tells. + If we're not in main_loop() and the service is stopped, exit immediately. + Allow tinc to handle unknown type addresses from other tinc daemons. + Don't overwrite the first " when installing a service. + Add checkpoints. + When purging nodes, only delete them if nobody references them anymore. + Remove debug message. + Add license exception from Markus Oberhumer. + Remove old edges from unreachable nodes to us. This prevents the hosts/NAME-up + We don't have to tell GCC how to cast. + Prevent multiple inclusions. + Remove pidfile when exitting. + Update translations. + Check for short packets from the tun/tap device and from other tinc daemons. + Generate keys with 0x10001 as public exponent, which has less prime factors + Better length checks. + Copy structs from packets to the stack before using them, to prevent + const + Ethernet protocol types. + Unused variable in struct. + Don't confuse users with "Address family not supported" warnings. + Use CPPFLAGS, LDFLAGS and LIBS as appropiate. + PIDs are of type pid_t, and use %ld when reading/writing them to the pidfile. + Make sure type of AF_UNKNOWN is sa_family_t. + Forgot to #include "xalloc.h" + Update missing definitions, structs describing headers get __packed__ attribute. + Missing declaration. + Set media status for newer TAP-Win32 driver. + Some platforms don't know sa_family_t or define it other than uint16_t. + Update documentation. + Fix ASCII art. + Check return value of EVP_* functions, and check if length before en/decryption + Check all EVP_ function calls. + Parentheses in the wrong spots. + Fix bug that could lead to an assertion failure in libcrypto when multiple + Small fixes in documentation. + Fix another bug in meta.c. + Update dutch translation. + Add missing definitions. + Release notes for 1.0.2 + +Version 1.0.1 August 14 2003 +------------------------------------------------------------------------ + +Guus Sliepen (24): + Windows uses backslashes... + Tell windows to be patient. + Remove unused stuff from doc/. + Correct error message when remote host closed connection. + Simplify execute_script(). It will probably work under Windows as well. + Allow empty lines in config files. + Make rule for sample-config.tar.gz. + Readd quotes. + Typo. + Better error messages under Windows. + Log error first, try to close later. + Quote when needed and don't try stuff that doesn't work under Windows. + Under Windows, the installation directory can be found in the registry. + Better error checking and reporting. + Small things. + Simpler checking of permissions on private RSA key and other fixes. + Check for fchmod(). + Only system() needs script name quoted. + Update documentation. + Add a description for the Service control panel. + Updated dutch translation. + Small fixes. + Fix permissions check for rsa_key.priv. + Update. + +Version 1.0 August 08 2003 +------------------------------------------------------------------------ + +Guus Sliepen (111): + Thank some more people. + Run graph() after edge_del() when updating an edge. + Add documentation for BindToAddress. + Fix PriorityInheritance. + PrivateKeyFile instead of PrivateKey. + Run graph algorithm when replacing a second connection from the same host + Add $NAME for tinc-up/down scripts. + - Fix indentation in some places. + Various fixes for autoconf and OpenSSL 0.9.7 and a missing header. + Make sure send_meta() writes everything. + Typo. + - Avoid memory leak caused by OpenSSL 0.9.7a. + - Speed up checksumming + Don't copy more than necessary. + Checksums must also work for uneven number of bytes. + HUP signal now closes connections to hosts if their host config file is + Better handling of late packets. + Make sure outgoing_t is completely freed. + - Per-node EVP_CIPHER_CTX to avoid initialisation overhead. + Small fixes to make LZO compression work. + Small fixes. + Fix links. + Fix warning and add missing checks for LZO library. + Call make_names() before doing anything else. + If we have a Linux tun/tap device and we are in router mode, open the device + AddressFamily is "any" by default. + Remove mymac stuff from device.c. + Fixes from Wessel Danker's libavl. + More braces to make gcc happy. + Update documentation. + Update dutch translation. + Typo and conversion to UTF-8. + There are two lzo compression levels. + Really make tinc default to any addressfamily. + This subtle pointer arithmetic thingy is (I'm very sure of it) the cause + - simplify configure.in + Check for IPv6 header files. + Define logger(), cleans up source code and allows us to write log entries + Sprinkling the source with static and attributes. + Provide all missing IPv6 definitions in lib/ipv6.h. + Actually add ipv6.h. + More missing definitions. + More missing IPv6 definitions and autoconf checks to make sure it compiles + Simplify logging, update copyrights and some minor cleanups. + Update copyrights. + Removing distribution specific files from CVS. + Format string checking for logger(). + Export mymac. + Make use of the CIPE driver. Woohoo, tinc for Windows! + Windows headers declare a struct interface somewhere. + Big header file cleanup: everything that has to do with standard system + Even more missing definitions. + Remove all #ifndefs from route.c + Update all device.c files. + Check for ethernet/ipv4/ipv6 related structures. + Use iface instead of interface because it might already be declared in + Oops. + No UNIX style permissions under Windows. + Be consistent. + Oops. + Check for sys/mman.h. + Use functions from logger.c + Copy cygwin driver to mingw directory. It doesn't work (yet). + Add section about configuring Cygwin and CIPE on Windows. + Option to specify pidfile location. + Use bools and enums where appropriate. + Run setup_device() after parsing configuration but before claiming we're ready. + Don't initialise a CIPHER_CTX if cipher == NULL. + Sprinkle around a lot of const and some C99 initialisers. + More generic handling of tap device under Windows. + More checks for missing functions. + Fix compile errors and warnings. + Update dutch translation and make sure all device drivers are included in + Update configure scripts. + Make sure it works. + Make sure (at least) the MinGW device driver works. + Native Windows support. + Cleanups. + Update documentation and remove stuff that's too outdated. + Remove doc/es/ and src/device.c from the distribution. + No C99 initialisers, gcc 2.95.3 doesn't like it. + Replacement for stdbool.h + Prevent definitions from messing up attributes. + Check if the compiler knows about the __malloc__ attribute. + Wrong argument. + Remove forgotten braces. + No easy way to properly detect header files... + Woops! + Wrong function... + Prevent system headers from including our own headers. + Allow whitespace in values. + Oops. + Windows has no symbolic links as we know it. + When compiling with MinGW, link with ws2_32. + Install tinc as a service under Windows (MinGW). Remove cleanup_and_exit(), + Error messages. + Cleanups and error messages. + Missing include. + Oops. + Updated dutch translation. + Explain how tinc detaches and how it is "killed" under Windows. + Typo and another thing to think about. + Clean up last part of main(). + Old gcc compilers don't like declarations in the middle of a function. + Cygwin needs windows.h. + Keep Windows happy. + Remove newlines from log messages. + Update dutch translation + Simplify translation + Use our own port when connecting to ourself. + Sync CABAL branch with release-1_0 branch. + +Ivo Timmermans (2): + Fix saving of debug level for startup level 0 + Call RSA_blinding_on(), as advised in the paper on + +Wessel Dankers (1): + its: Engels voor "van het" - 3e persoon enkelvoud, genitief, onzijdig + +Version 1.0pre8 September 16 2002 +------------------------------------------------------------------------ + +Guus Sliepen (73): + Support for MaxOS/X. + Add BindToAddress variable, similar to the late BindToIP. + Added Nick Patavalis for his RedHat package. + Informative log message if execl() failed. + Fix very stupid bug in node_del(), which might have caused corruption of + Only purge once when there are no more connections. + Support RSA_PUBKEYs (as opposed to RSAPublicKeys) so tinc accepts + Make it work correctly with NetBSD tun device. + Use correct includes on NetBSD. + Cleanup: + Use inttypes.h instead of stdint.h. + - netinet/* include files depend on netinet/in_systm.h. + Added Darwin (MacOS/X) tun device handling. + Use darwin/device.c when compiling on MacOS/X. + Include darwin/device.c in distribution. + Autoconf cleanup. Works for both 2.13 and 2.53, although running autoconf + Add configuration details for NetBSD and Darwin (MacOS/X). + Reset listen_sockets after SIGHUP. + Update comments about IPv6 autoconfiguration. + s/sliepen.warande.net/sliepen.eu.org/g + Fix for prefixlengths of 32 (IPv4) and 128 (IPv6) bits. + Allow list of environment variables to be passed to execute_script(). + Allow identical subnets from different owners. + Clear subnets before using them. + Started port to Cygwin. + Added stub device.c for Cygwin. + Include complete fake-getname/addrinfo from OpenSSH. + Allow tincd to be locked into main memory. + Don't bother to chown, and correctly document ConnectTo. + Added support for raw sockets. This can be used instead of tun/tap devices. + Gettext 1.11.5 compatibility. + Check for ranlib. + Replacement for the current routing algorithm. + Make sure setlocale() is available. + Drop graph and edge stuff. Use new node stuff instead. + A reachable node is always more preferable to an unreachable one... + Woops. + Reduce KEY_CHANGED traffic. + Prevent looping DEL_NODE/ADD_NODE messages after a node disconnects. + Don't forget to set prevhop to myself for new connections. + Just ignore wrong ADD_NODEs instead of replying with a DEL_NODE, in the + Revert to edge and graph stuff. This time, use a directed graph. + Small fixes. + Generalized request broadcasting/forwarding. + Updated dutch translation. + Small updates. + Run autopoint and libtoolize before creating initial makefiles. + Add missing headers. + Typo. + Only reset seqno's when a key is sent or received. + Remove global edge_tree. + edge_weight_compare() shouldn't rely on edge_compare(). + Reset the *correct* seqnos. + Fix MST algorithm. + Why don't these connection_t's get cleaned up? + Cleanups: + Switch to K&R style indentation. + Switch to K&R style indentation. + Remove redundant spaces. + Let GCC check format string and arguments of send_request(). + Fix compiler warnings. + Clean up after indent. + Link with libintl if necessary. + Fix placement of #include "config.h" + Make sure malloc() is declared. + What was I thinking? + MacOS/X needs #define _P1003_1B_VISIBLE in order to use mlockall(). + port_t isn't used anymore and conflicts with MacOS/X headers. + Small fixes so tinc compiles out of the box on SunOS 5.8 + Updated dutch translation. + Use /dev/net/tun as default for tun/tap device under Linux. + Update documentation. + Remarks about 1.0pre8 release. + +Ivo Timmermans (9): + Put #ifndef checks for HAVE_RAND_PSEUDO_BYTES in the correct places. + Typo + OSX support + getnameinfo fixes + Add /sw/{include,lib} to search paths if they exist + Include a few more header files + Include netbsd's device.c in make dist + Added Alessandro Gatti + Added AM_MAINTAINER_MODE + +Wessel Dankers (1): + This should work much better. + +Version 1.0pre7 April 09 2002 +------------------------------------------------------------------------ + +Guus Sliepen (9): + Make configure --help output look nicer. + Don't check_network_activity() if select() is interrupted by a signal. + check_rsa() is broken, I don't know why, just remove it for now. + Fix maskcheck() and maskcmp(). + Automake forgets about depcomp, remind it. + masklength is better known as prefixlength. + masklength is better known as prefixlength + Updated dutch translation. + Remarks about 1.0pre7 release. + +Version 1.0pre6 March 27 2002 +------------------------------------------------------------------------ + +Guus Sliepen (91): + Forgot to merge new files from pre5. + Last bits of the merger. + Sensible defaults for $INTERFACE. + - If no PrivateKeyFile is specified, /etc/tinc/netname/rsa_key.priv is assumed. + Small fix. + Added support for packet compression, thanks to Mark Glines. + Don't use sa_sigaction (which NetBSD doesn't like) at all if we don't use siginfo. + Get rid of sys/signal.h. + Added device.c for NetBSD, actually a copy of the OpenBSD one. + Add check for NetBSD. + - Non-blocking connect()s. + Fix segfault when receiving HUP signal. + Use AF_UNSPEC for listening sockets if AddressFamily = any. + Forward packets in router mode. + Fix maskcmp() and maskcpy(). + Cache results of lookup_subnet_...(). + Protocol now also exchanges cipher/digest/maclength/compression for the + Preserve inpkt->len, needed for broadcasts. + - Use gai_strerror() where appropriate + - Change SA_LEN to SALEN, former one is already defined on some platforms. + Tweaking IPv6 support. + Allow multiple listening sockets. + Fix send_request() bug. + Make BindToInterface work. + Fix listening sockets. + If "PriorityInheritance = yes" is specified in tinc.conf, the value of the + Create/bind TCP and UDP listening sockets in pairs. + Updated documentation. + Updated dutch translation. + - Global time_t now, so that we don't have to call time() too often. + Document and clean up MAC address expiry. + Woops. + Check if BindToDevice and PriorityInheritance are supported. + Fix forwarding of IPv6 packets. + po/POTFILES and po/Makefile should not be generated by configure. + Autodetect $MAKE/gmake/make. + Small fixes to improve portability. + Don't retry to make outgoing connections when exitting. + Cleanups, spelling fixes, allow symbol names for signals (-k option), + prune_connections() before build_fdset(). + Try to reply to neighbor solicitation requests. + New strategy: forward icmp6 neighbor solicitations to intended target. + Simplified implementation of Kruskal's minimum spanning tree algorithm. + Packet sequence number/authentication warnings only if debug_lvl >= 5. + Remove silly cache thingy. + Put #ifdef NEIGHBORSOL around corresponding code. + Revert changes to Kruskal's algo. + Neighbor solicitation requests now work (I think). + Oops, don't forget to actually put the checksum in the response packet. + Different way of detecting neighbor solicitation requests. + Typo. + Unmap v4mapped sockaddrs. + Only unmap IPv6 addresses. + #define s6_addr32, needed for FreeBSD. + Fix #define s6_addr32. + Remember sockaddrs of listening sockets, use appropriate one when sending + Cleanup. + Don't use s6_addr[16|32] anymore. + Updated dutch translation. + Updated SSSP algorithm to automatically detect indirect links (if a node uses + Put a break on requests that run around in circles. + - Added support for jumbograms. + Fix add_edge_h(). + Fix compiler warnings, strictly use long int and %lx for options. + send_ack() was broken. + free() request strings when deleting past requests from the tree. + Don't run graph algorithms if no edge is deleted in terminate_connection(). + Reset retry timeout when receiving the first PONG, not right after receiving the ACK. + Don't try to execute scripts unless they exist. + Execute hosts/name-up when a node becomes reachable, and hosts/name-down + Set $INTERFACE correctly when using ethertap while compiled with tun/tap support. + Updated dutch translation. + Respect type field. + OpenBSD tun device uses address family number instead of Ethernet type. + Configuration variables were still handled case sensitively. + Set myself->status.reachable. + Updated documentation. + Tell a little bit more about security. + Send REQ_KEY only once until ANS_KEY has arrived. + Fix execute_script(). + Small correction. + Merge do_prune() with build_fdset(). Probably fixes the invalid filedescriptor error. + Extend list_t with the number of elements in the list. + Limit the amount of packets in a queue to 8. + Small updates. + Remove cruft. + Recent automake uses $(AMTAR) instead of $(TAR) + Remove symlink to device.c when doing a make dist. + Fix format strings. + Update dutch translation. + Update with information about the pre6 release. + +Version 1.0pre5 February 10 2002 +------------------------------------------------------------------------ + +Guus Sliepen (109): + Small fixes to allow correct compilation under FreeBSD (tested with 4.3) + Make sure Solaris is happy too. + Fix subnet_lookup() for overlapping subnets. Needs rethinking. + Added proxy-arp support. No more ifconfig -arp needed. Works like a charm + - tinc can now act as a switch or a hub too (as opposed to a router only) + Changed some stuff to allow correct generation of po/Makefile after a + Updated dutch translation. + - This oneliner removes the need for ifconfig tap? hw ether fe:fd:0:0:0:0 + Fix bug where lookup_subnet_ipv4() could go into an infinite loop. + You can now put an option "Mode" in tinc.conf, and choose from: + Add missing? counting of total_socket_in. + Log and warn about duplicate subnet_add()'s for the same subnet. + Fixes to make switching work between hosts that have no meta-connection. + Save configure cache more often. + Changed drastically because it didn't work correctly: + Only reset seconds_till_retry when we activate the outgoing connection. + Woops - big bug in send_key_changed fixed. + - Solaris compile fixes + Check for and add -ldl. + Remove #warnings I used for debugging stuff. + Reinstated search for if_tun.h in kernel source tree, because apparently + Spanish translation removed. Nobody maintains it, and it is severely + ABOUT-NLS is created by autogen.sh. + Don't build Spanish translation. + Execute tinc-down BEFORE tap device is closed. This is a. more symmetric + es.po revived. + Also remove po/Makefile.in.in, which is generated by autogen.sh. + Log error if two hosts connect with same IP/port tuple. + Fix gcc 3.0 warnings. + Check for dlopen in standard libraries first (needed for DEC OSF). + It appears that autogen.sh doesn't like es.po if it isn't mentioned in + Update of RedHat build scripts. + Dutch translation updated. + More items marked as done. + Fix printf format bug. + Fix compiler warning. + Check for all potential duplicate entries in the id tree. + - Always use instead of just + Don't load table of verbose OpenSSL errormessages. + Correct inclusion of standard if_tun.h header file. + Split connection list into two lists: + Correctly use the active_tree. + Remove all unnecessary status.meta and status.active checks. + Added purge_tree for connection_t's which are no longer in the connection, + Updated terminate_connection() so you can choose if DEL_HOSTs should be + Always close all sockets in terminate_connection(). + Woohoo! tinc now compiles, runs and actually *works* on Solaris! + Started writing a document about how daemons connect to each other. + Described problem in more detail. + Small update. + Correctie. + Written down a possible solution. + Discuss how sending ADD_EDGEs would be better than sending ADD_HOSTs. + More on edges. + Don't use %m in fprintf(). + Write public key to rsa_key.pub instead of rsa_key.priv (if not host + The val variable in a config_t is never used as a long. + Explicitly log which type of tunnel device is used. + Don't send DEL_HOSTs when !status.meta + Fix signed comparison bug in lookup_subnet_ipv4(). + Remove IndirectData support for now, new implementation will be added + Revised reconnection mechanism, always try out all ConnectTo lines. + Optional signal number for -k option. + config_t* is a const parameter in get_config_val(). + - Try old TUN/TAP ioctl() request if the one from if_tun.h fails. + Not only keep track of nexthop, but also of lastbutonehop. If destination cl + Show next- and lastbutonehop when dumping connectionlist to syslog. + Try next connectto instead of the same over and over. + Fill in next- and lastbutonehop for myself. + - Renamed lastbutonehop to prevhop. + Fix bug where tinc would crash because of a portscan or a connection from a + - Use ping timeout mechanism to close connections that don't authenticate + Fix bug when dropping an old connection in favour of a new one from the + Updated dutch translation. + Started implementing doc/CONNECTIVITY. + Small corrections. + Further implementation of doc/CONNECTIVITY. connection.[ch] is now split into a + Removed everything from connection.c that has already been moved to node.c and + Revamp configuration handling: + More updates to new node/vertex/connection combo. + - Split tap device stuff out of net.[ch] + Added FreeBSD tap device handling. + Solaris tun device handling cleaned up a bit and added. + Forgot to remove some old #ifdef stuff. + Added OpenBSD tun device handling. Untested though. + Forgot the tun specific stuff. + Support new files (node/vertex/device.[ch]) and OpenBSD. + Big bad commit: + Make sure everything links. + Various small fixes to make tinc runnable again. + What was I thinking? s/vertex/edge/g. + - More s/vertex/edge/g + - More changes needed for Kruskal's algorithm + Working version of Kruskal's algorithm. The running time is very bad though. + Various fixes, tinc is now somewhat capable of actually working again. + More updates to protocol handlers and reimplemented terminate_connection(). + - Small fixes to graph algorithms + Don't forget to read public RSA key when making an outgoing connection. + Show cfg->variable instead of cfg->value when complaining about wrong type. + Avoid connecting to another node twice, and check name of outgoing connections. + Some very small fixes + Use PEM functions as suggested by OpenSSL docs. + Several bugfixes. + *** empty log message *** + Be liberal in what you accept: allow unknown edges to be deleted. + Correctly check if subnet owner exists. + Various fixes needed for Solaris. + More fixes for Solaris. + Merging of the entire pre5 branch. + +Ivo Timmermans (32): + New make target: `make release' + Changed version number to 1.0-cvs + Don't distribute autogen.sh in a release + Don't include the debian/ dir in a release + Small fix to make it compile again + Killing tincd with SIGINT causes it to toggle between the current + Check for getaddrinfo + Check for getnameinfo, gai_strerror, freeaddrinfo + Credit OpenSSH + Check for struct addrinfo + Deprecated get_config_ip and get_config_port + Use struct addrinfo in connection_t to hold all host data such as IP + Changed prototype for lookup_connection to use struct addrinfo + Changed lookup_connection to use struct addrinfo + Removed definitions of ipv4_t, ipv6_t, port_t + Obsoleted all IP types in favor of struct addrinfo + Changed to use struct addrinfo where needed. + get_config_{ip,port} removed. + Don't compile/link netutl.c. + Obsoleted. + Don't include netutl.h. + (re)added port to struct node_t + Added HAVE_STRUCT_ADDRINFO + Added dropin replacements for get*info and helper functions. + First part of rewriting things to use struct addrinfo. + lookup_node_udp changed. + Don't include netutl.h. + route_ipv4 and route_ipv6 replaced by route_ip. + get_config_subnet needs to be fixed. + Fixed silly typo: "np" instead of "no" + Don't include netutl.h. + Conversion to struct addrinfo is almost complete for this file. + +Wessel Dankers (1): + make is not always GNU make. + +Version 1.0pre4 May 25 2001 +------------------------------------------------------------------------ + +Guus Sliepen (97): + Porting to FreeBSD: + - Added balanced tree management stuff as well. (It is not finished yet.) + - Simplified do_detach + - Removed stray @INCLUDE@ (how did that get there?) + - Fixed searching + - Implemented deletions + - Fix tree head/tail upon insertion + - Fixed a lot of small things. Tested everything except deletions. + - Deletion also works now. + - Small fixes + - Integrate rbl trees into tinc. + - Proper initialization of rbltree structures. + - Various small fixes. + - More fixes. + - Check for NULL tree->delete callback + - Cleaned up and checked for some more NULL pointers in rbl.c + - Write pidfile AFTER detaching... + - No more %as. + - Work with the correct key buffer in ans_key_h + - More porting to FreeBSD and Solaris. + - Fixed all (except 2) compiler warnings gcc -Wall gave. + - #include instead of + - Don't link with -ldl anymore + Another big & bad commit: + - Added Armijn to the list + - Added daemon() replacement. + - Use only one socket for all UDP traffic (for compatibility) + - Don't even think about using sscanf with %as anymore + - AVL tree routines: faster than RBL, and also more stable. + - Doubled size of trace buffer for easier debugging. + - Let user choose whether keys are in the config files or separate + - Updated dutch translation. + - Check and follow symlinks in is_safe_path + - Changed license of AVL tree library to GPL. + - Updated manual pages. + - Updated texinfo manual. + - Typo. + - Changed list routines to give it the same look'n'feel as the rbl and + - Reinstated a queue for outgoing packets. + - Added header file for route.c. The routing routines in it are not used + - Description of protocol and authentication updated. + - It's 2001, all copyright notices are updated. + - Fixed IPv6 subnet lookup routine. + - Added indirectdata and tcponly functionality. + - Squashed another nasty bug. + - Sign was wrong in search_closest_smaller/greater + - Cleaned up subnet_t + - Only send out DEL_HOSTs for hosts with a meta connection + Added sample configuration directory. + - Copy entire sample-config directory to /etc/tinc/example upon installing. + - Allow ASN1 style keys to be in the config files. + FreeBSD compile fixes (thanks to XeF4) + Fix memory leak in avl_insert() if item was already inserted. + Updated dutch translation. + Removed another local definition of the variable "errno" + Added .cvsignore files to get rid of warnings and prevent autogenerated + Ignore file for src/ + - Updated CVS_CREATED to remove intl/ directory and some other + Added description of the proposed new authentication scheme. + Corrected check for errors after read() calls. + Add missing \n. + Free node->data and node, not node->data twice. + Copy packets before putting them in the queue. + Encrypt network packets in CBC mode instead of CFB mode. + Implemented new authentication scheme from doc/SECURITY2. + Added process.c to the translated files. + - Make sure METAKEY is smaller than the modulus of the RSA key + Don't forget to reconnect if outgoing connection fails during + - Fixed Interface option (untested) + Removed lots of compiler warnings. + Removed compiler warning. + Various small fixes. + Added explaination of our key exchange using RSA encryption. + - route.c is now used to determine destination + Updated translation. + Added a description of what is going on in net.c and route.c, and how + Fixed a race condition triggered by receive_meta() and the new + Fixed bug in setup_signals() that would make tinc die when unexpected + Ignore alarm signals if we do not need to respond to them. + Check indirectdata option before forwarding certain requests. + Depend on new ssl package and install alias for universal TUN/TAP module. + Correctly cycle through ConnectTo variables. + - s/ip_t/ipv4_t/g + - Make sure correct information is supplied for both old kernels (with + More revisions to the documentation: + Changed URL from kernelnotes.org to linuxdoc.org. + Add randomness to PING/PONG packets to prevent crypto attacks on quiet + Since this is incompatible with some earlier versions, PROT_CURRENT is + All features for 1.0 are implemented now, we just have to check the + Only send key_changed if it was previously requested. + Small fixes: + Small corrections to the manuals. + With recent kernels the tun device file is located in /dev/net. + TCPonly now works (in a relatively clean way too). + Merged PROTOCOL, NETWORK and SECURITY2 with the texinfo manual. + Documents are merged. Now we only need to check the ports and the TCPonly + Fix sample configuration to show keys in PEM format and correct tapdevice. + +Ivo Timmermans (88): + Add a check for openssl that accepts explicit file locations. + Identify version as 1.0pre4-cvs + Better checks for OpenSSL. I think it can now detect almost all conceivable installations. + Oops, small error. + Get rid of the annoying empty line + Also check for rand.h and err.h. If any of these files does not + Also check for sha.h. + Use the HAVE_OPENSSL_xxx_H defined from m4/openssl.m4 during + Let the output from an executed script in execute_script() go to + List management and manipulation routines. + Keep a list of running children, and in each loop in main_loop(), + Move all process-related functions into process.c. + New function: xmalloc_and_zero, which initialises the allocated memory + Delete struct ifr + Move more functions from tincd.c into process.c. + Use proper prototypes. + Added this release + More function and header checks + Also include process.h + Get rid of all libtool references at once. libtool was only used by + Honor the --localstatedir option to configure, instead of hardcoded /var. + Add more checks to ensure that filedescriptors are right in + Declare fd. + Do not use the C library's daemon() call. + Do not check for the daemon() system call + Do not attempt to retreive ChangeLog information only from the CABAL + Set localstatedir to /var + Use cvs2cl instead of rcs2log to generate the ChangeLog. + Set CFLAGS to -O2 -Wall when running configure + Alter CFLAGS, somehow INCLUDES doesn't propagate properly. Still + Set errno to 0 before trying to kill the other process. + Explain how to tell configure where OpenSSL lives. + Call autogen.sh instead of configure alone; and make cvs-clean instead + Add default tinc-up and tinc-down scripts for a Debian system. These + Updated Spanish translation, provided by Enrique Zanardi. + Give an error message if daemon() failed. + Check for the function strsignal, and define it to "" if it is not + Sort items to either 1.0 or future release goals. + Use sigaction to set signal handlers, the previous commit (1.1.2.16) + Save RSA public and private keys to a separate file, instead of + dropin.c/h contain a set of drop-in replacements for non-standard C + Check for get_current_dir_name. There is a replacement function in + Added a check for a scanf that knows about %as. + Implemented a readline() function that will read an entire line into a + xstrdup now takes a const pointer as an argument. + Use readline() in read_config_file() instead of fgets. + Also free the pointer returned by readline(). + Updated Dutch translation + Implemented is_safe_path, and extended ask_and_safe_open. + Read the PEM file pointed to by the configuration directive + The file is safe if it doesn't exist. + In readline(): initialise the line to zero length; + Better error checking when reading the RSA private key. + Avoid printing duplicate messages from read_rsa_keys + New function read_rsa_public_key(); + All full stops have two spaces after them. (Silly commit, I know.) + Tagged `Storing private key in separate file' as done. + readline() accepts two extra parameters, buf and buflen, to avoid + Use buffer instead of line in read_config_file(), line may be assigned + Stated that distributing executables linked with OpenSSL is permitted + Include COPYING.README in the distribution. + Added documentation merger + Sort configuration directives + Option -d accepts an argument to set the debug level immediately. + Massive long awaited documentation update. It's not finished yet, + Oops. I did some VERY wrong things with readline(). Fixed now. + Tiny bits of code beautifying + Install a file in /etc/modutils/tinc, containing all necessary aliases + Ported it back to /bin/sh. + Give a warning about having to re-create the keys + Re-introduced MyVirtualIP and VpnMask, as dummy options. + Various small changes. + Include autogen.sh (needed for the Debian package). + Forget router.c + Added lint target, requires lclint. + Fix error reporting of read_config + Set Architecture to `any' + Change version to 1.0pre4 + Second draft of the release notes + Merged documentation with various updates I had lying around + Get the Debian changelog up to date + Get the PO files up to date with the current source + Fixed some errors + Distribute the sample config as a .tar.gz + Unpack sample-config.tar.gz when installing + More files to ignore in CVS + tinc_TUNTAP now substitutes the values outside the AC_CACHE_CHECK + Authentication done + +Wessel Dankers (1): + Important bugfix in avl_insert_before() and avl_insert_after() + +Version 1.0pre3 November 09 2000 +------------------------------------------------------------------------ + +Guus Sliepen (119): + Debian init.d script automatically sets tap device's MTU to 1448 now. + First step for implementation of the "indirectdata" directive. This should + If we have "indirectdata" flag set, we only send data to our uplink. + Large cleanup: + Added CVS Id tags to header files. + - Log possible spoofing attacks. + Hostnames are back! + Hostlookup() is actually being called now. + - More verbose connection list + Fixes some hostlookups. Fixes indirectdata for real now (hopefully). + - Indirectdata finally REALLY REALLY works now! + - Moved all connection messages to debug level 1, without -d's only the + - Fixed KEY_CHANGED notification. A lot of notify_others() calls were + - Fixed indirectdata=no problem + - Improved handling of errors on connection attempts. + - Purge old connections that are ADD_HOSTed. + - Fixes a silly little insignificant buglet. + - Extra check op EINTR bij inlezen requests + - Fixed some spelling errors. + - Fixed missing " in nl.po + - Fixed a message in nl.po + - Added log message when SIGCHLD is received ("thanks" to Ivo van Dong) + - Updated Dutch translation. + - Removed all IP_ADDR_S macros, because gettext doesn't like them. Each + - New semantics for BASIC_INFO, ADD_HOST and DEL_HOST requests. This will + - Fixed memory leak. + - Removed segfault bug in conf.c (must have been there for ages!) + - Instead of logging an error when remote end closes the connection, + - Made tinc even more silent if no -d flag is given at all. + - Added documentation for the protocols (most important the meta protocol) + - Removed a single unused bit from status_bits_t. + - Updated PROTOCOL (a bit) + - Forgot to mention ourselves in the tincd manual page! :) + - Added Spanish translation from Enrique Zanardi. + - Updated THANKS file + - Delayed address resolving for ConnectTo lines in configuration file to + - Fixed typo. + - Added experimental hackish tunneling-over-TCP support. + - Lots o' buglets fixed (-Wall helps) + Fixed PACKET read loop. + Removed calling add_queue for tcponly packets. + - Added date/time of build and protocol number to --version output. + - Moved TCP packet reception to meta handler: less kludgy and less buggy! + - Reinstated O_NONBLOCK for meta socket + - Added two extra configuration options, Interface and InterfaceIP, to + Fixed all sprintf() spl01ts. + Ran update-po and updated dutch translation. + Commented on some size calculations. + Updated the manual: + Updated tinc.conf manual. + Fix rules (thanks to Laurence) + - Use strerror() instead of sys_errlist[] for increased portability + - New protocol. Will break everything else for now. + - Added more function skeletons for the new protocol. + - Lots of functions added for the new protocol. + - Some key exchange stuff. (Last commit before going to bed.) + - Fixed modulo in keylength check + - Lots of small changes. + Added document about the used cryptographic algorithms and the reasons + - Included authentication scheme from protocol.c + - Updated authentication scheme. + - Severe code reduction and simplification of challenge requests + - Removed options "string" stuff. It was a bad idea... + - Very detailed example of the authentication phase. + - Added meta.c which contains functions to send, receive and broadcast + - Added subnet handling code + Removing cipher directory (all will be covered by OpenSSL). + Big and bad commit of my current tree... + - Changed genauth to produce rsa keypairs instead of random passphrases. + - Generalized config file parsing to support multiple configuration trees. + - Fixing-things pass: every source file compiles into an object file now, + - Second fixing-things pass: it even links now. + - The daemon actually runs now (somewhat) + Corrected #ifdefs for tun/tap support. + - Fixing little things + - More fixing. Tinc daemons can now even create activated connections. + - Seed the PRNG using /dev/random before generating the keys. + - tinc now really does public/private key encryption! It even works, whee! + - Made Makefile.am stub for doc/es/ + - Removed last reference to genauth from Makefile.am + - Fixed all debug levels. + - route.c will contain the routing logic. + - Lots of little stuff modified + - Updated subnet list handling. Subnets are added to two lists now, the + - Lots of small fixes + - Fixed offsets when reading/writing from/to tap device + - Override destination ethernet address on incoming packets with + - Very big cleanup. + - Fixed ans_key_h + - Hit people who can't figure out subnet address/mask pairs with a + - Enforce correct order of authentication requests + - Moved connlist stuff to the proper header file. + - Updated dutch translation. + - Removed old encr stuff + - Small fixes + - Use CFB mode for encrypting packets: it works and we don't need padding. + - Finishing touch: encrypt the meta connections + - Small cleanups + - Fixed some spelling mistakes and terminology here and there. + - Update. + Removed config file parsing and interface setup. This will be handled by + - Removed unused MAC strip/add functions. + - Removed even more warnings. + - Resolve scriptname after fork() + - Removed manpage for no longer existing genauth. + - connlist.c added to translation + - Don't forget to set packet cipher for added hosts. + - Forward keys in hex notation, not as binary data. + - Check for packets that are looping back. + - Simplified ping mechanism. + - Prepended config_ to all configuration option names, because it confused + Changed execution of tinc-up: + - Open UDP connection for all known hosts. Comments please. + Porting to SunOS 5.8: + Porting to SunOS 5.8: + - Fixed --config + - Applied Jamie Brigg's patch (close sockets after error) + - Add Jamie :) + - Make checkpoint tracing a compile time option (off by default) + +Ivo Timmermans (77): + Alphabetized the list, added Lubom�r Bulej, removed Sander Smeenk and Tijs van Bakel, put merits after all names. + Don't touch VPNMASK if it's defined, otherwise use $MSK. + These files are created by gettextize (run by autogen.sh) (should have known that). + Include ../intl in the include path, and add @INTLLIBS@ to the list of libraries. + Merge changes from 1.6-1.8. + Configuration directive `IndirectData'. + Changed version number to 1.0pre3. + Version 1.0pre3. + Removed Free Software Foundation copyright, because Guus Sliepen contributed significantly. + Oops, and mention Guus too. + Include the Spanish translation in the distribution/build process. + (Quoting Laurence Lane:) + Also chomp $VPNMASK + Added a rule to create an rpm + Changed CVSROOT path in `make ChangeLog' + Link with OpenSSL crypto libraries instead of own blowfish library + Updated text, removed protocol flowchart + Include openssl/blowfish.h + Support for -lsocket and -lnsl on SunOS + Correct filenames for passphrases given in the example + Add Guus' name and shift out old protocol requests + Better checks for SunOS libraries + Added some structures and types that are needed for the overhaul. + New directive: Name. + First round of needed fixes after the overhaul + Second round of fixes + Added Spanish translation of the docs by Matias Carrasco + Many updates, parts rewritten, added, shuffled around. + Link with OpenSSL, forget libGMP + Updated new requirements, pointers to the manual + Don't look for GMP header files + Update Depends lines to reflect the dependencies on OpenSSL + Fix `Requirements'-section for GMP and OpenSSL libraries. + Add CVS id lines + Add checks for the presence of the universal tun/tap device driver. + Wrap the tun/tap code in #ifdef HAVE_TUNTAP + Linearized checks for if_tun.h + Really #include the if_tun.h files now + Output doc/es/Makefile + Process subdir es/ + Don't declare cp_file and cp_line in xmalloc() + Get the head revision up to date with cabal + Changed changelog + Include linux/sockios.h and net/if.h anyway, regardless of the value of HAVE_TUNTAP. + read_server_config: Check for result of read_config_file. + Oops, echelon change committed to cabal... :) + Skip the check for Linux kernel sources + This file is no longer needed. + - Synchronized changelog with the package's changelog. + Do not include $(top_srcdir)/cipher, it does no longer exist. + Added a perl example to turn an IP address into a MAC address. + Only check for linux/if_tun.h once + Changed `I' to `We' - small change, lots of difference :) + More exhaustive list of changes - perhaps it can be worded differently? + Change wsl to Wessel's name and email address in the ChangeLog creation + Mention fileutils, add a pointer to THANKS for more details + Changed a few messages wrt. system calls; updated and changed the Dutch translation a bit. + Don't include shlibs, as it no longer exists. + Oops, and include doc-base.tinc (new file). + - If necessary, patch po/Makefile.in from po-Makefile.in.in.diff to + Minor cosmetic change. + Save the environment on startup. + Run the scripts tinc-up and tinc-down from a separate function, which + Warnings removal pass: always include config.h first; add a few + Small change to the way the environment is copied. + Use putenv() instead of clumsy do-it-yourself in execute_script. + Do not include the passphrases directory + In execute_script: + Add route.c to the list of source files. + Updated Dutch translation + Build-depends on libtool + Build-Depends on gettext + Final release notes added, also edited release notes for 1.0pre2 to what the announcement on the mailing list looked like. + Wrapped text to 70 (72?) columns for easy reading + Bop version number to 1.0pre3-1 + Updates, updates + Add prototype for destroy_queue + +Wessel Dankers (3): + File added to CABAL (hopefully) + Grrr, recommit + Added architecture section, made a start with the kernel section. + +Version 1.0pre2 May 31 2000 +------------------------------------------------------------------------ + +Ivo Timmermans (56): + Deleted the protocol description. + Perl version of the system startup script. + Only print an error with send_termreq if debug_lvl is 2 or more. + Add check for mpz_powm in libgmp3. + Version 1.0pre1-0.1. + Changed version to 1.0pre2. + Give IP address instead of hex number when connecting tcp socket failed. + Add shlibs control file for the blowfish library. + Inserted useful content. + Add initscript, tincd->tinc. + Add description, better dependancies. + Mention both upstream authors. + tincd->tinc + .deb version number 1.0pre2-0.4. + Updated to newer version. + Exit with zero status if is empty. + Unlimited length in the config file, thanks to Cris van Pelt. + Depend on perl5. + *** empty log message *** + Look if the tap devices exist before bluntly remaking them. + Use the new VpnMask directive to add a route to the rest of the VPN. + This file is generated with dpkg-buildpackage. + Read /etc/tinc/nets.boot to find the networks that have to be started. + Create a default /etc/tinc/nets.boot after installation, containing all directories under /etc/tinc by default. + Version 1.0pre2-0.3 + Don't distribute the file files. + Find networks in instead of . + Include postinst in the distribution. + Errors will not terminate the script or result in a nonzero exit code. + Updated copyright notice. + Fixed typo. + Mask the vpn net with the vpn netmask, route would give an error if the netmask didn't match the net. + When VpnMask is not present in the config file, silently use $MSK as vpnmask. + Add an example of using VpnMask. + Use /etc/tinc/example as a base directory for an example. /etc/tinc/example/README points to /usr/share/doc/tinc/README.Debian. + Create an empty /etc/tinc/nets.boot. + Updated by Lubomir Bulej and Mads Kiilerich: it uses /etc/tinc/nets.boot and the VpnMask directive in the config files. + Internationalization of tinc. + Include intl/ directory in the list of subdirs. + Include system.h and ABOUT-NLS. + Update acconfig.h to include values for gettext inclusion. + Include GNU gettext checks. + Define LOCALEDIR in CFLAGS. + Dutch translation of tinc. + Bounds check for request id (between 0 and 255). + Updated changes list for version 1.0pre2. + Added new configuration directive `Hostnames', which controls the resolving of IP addresses to hostnames. + When a connection is terminated, all hosts that are still connected get notified of the lost connections. + In terminate_connection, only send a notification to hosts that are directly connected to us. (DEL_HOST gets forwarded automatically.) + Only accept an ADD_HOST request for a host that already exists in our conn_list if the nexthop field matches the sender. This is a workaround for older clients. + Include news for 1.0pre2. + Tell about /etc/tinc/nets.boot. + Updated Dutch translation. + Version 1.0pre2-1. + Handle locale settings. + Miscellaneous copyright updates. + +Guus Sliepen (16): + Proxymode removed. + Cleanups. + Changed ping behaviour (backwards compatible). If we don't have any data + Fixed typos. + Test for existence of configured tinc networks. This will also make + Stub for VpnMask config directive. + TODO file reinstated: + VpnMask truely works now. + Typo. + Fixed last typo. Init.d now uses ifconfig command to set both the tap's IP + Documentation updates. Removed all references to configuration variable + Fix for a DoS attack: + Fixed typos. When terminating a connection, it's status is not only set to + Made tinc persistent. If no outgoing connection can be established right + Terminate a connection on any error. Furthermore, disallow del_host, + Only activate a connection upon receiving it's public key if it's an + +Version 1.0pre1 May 08 2000 +------------------------------------------------------------------------ + +Ivo Timmermans (84): + Get rid of the message `zxnrbl\'. + Upon regeneration, free the old encryption key `securely\' by overwriting it. + Kill the parent after any error conditions in detach(). + Ignore SIGCHLD. + New option -D, don't detach. + Moved to version number 1.0. + Only one round of reading bits out of urandom; + Pass the requested size from xmalloc() and xrealloc() on to xalloc_fail_func() + Check for an illegal length of passphrase in read_passphrase(). + Check if stdout is a terminal, if so, print a verbose message. + Default passphrase length of 1024, added -h/--help options. + Submitted by Mads Kiilerich. + New manpage for genauth. + Updated manpages. + Address for bugreports changed to tinc@nl.linux.org. + Include the directory redhat in the build process. + Include genauth.8 in the distribution. + Submitted changes by Mads Kiilerich. + A short notice from Mads Kiilerich. + Keep make dist(dir) happy. + Added cvs-clean. + These files are not needed in release 1.0. + Don't compile in `idea'. + Don't include idea/idea.h. + Don't try to create cipher/idea/Makefile. + The shell script autogen.sh can create all these removed files, but be + s/Gnome/tinc/g + This file is obsolete, most of the ideas are already in echelon. + Remove check for bigendianness. + Don't define HAVE_NAMESPACES and HAVE_STL. + Use `make ChangeLog' to create this file from the CVS logs. + Remove test for GNOME. + Changes largely from Mads Kiilerich. + Added Mads Kiilerich, removed Guus Sliepen. + *** empty log message *** + Generate this Makefile.am from Makefile.am.in. + Contributed by Mads Kiilerich. + Spelling fixes. + Delete all the files that are created by autogen.sh on a `make cvs-clean'. + Propagate CFLAGS from configure to gcc. + Don't include TODO in the dist. + Remove ChangeLog with a `make cvs-clean'. + Initial CVS. + *** empty log message *** + Create a ChangeLog file, automake requires it. + *** empty log message *** + Debug level tweaking. + From Mads Kiilerich. + The make command is in /usr/bin. + Add an entry to dir. + Omit TODO. + Version to 1.0pre1; + Filled in the details, license from libblowfish copied. + Updated version number to 1.0. + Default config file name is tinc.conf, and pidfile is tinc.pid. + More updates wrt. the change from tincd->tinc. + Added `deb' target. + Filled up the protocol structs with unused bytes. + Got rid of the nasty hacks... and replaced it by another one. + Initially, the vpn_mask of a connection is 255.255.255.255 to avoid confusion with lookup_conn. + Replaced check for status.active by status.dataopen in check_network_activity. + New way of handling the meta protocol. + Read public keys the right way (tm). + Removed debug messages. + Read one less byte from an ANS_KEY request. + Send one less byte from an ANS_KEY request. + Protocol fix (ANS_KEY). This breaks 0.3.3 protocol compatibility. + Key forwarding, write one byte extra. + Committed by Lubom�r Bulej. + Updates by Mads Kiilerich. + Committed by Mads Kiilerich. + Fixed meta protocol. + More tincd->tinc updates. + Mentioned new metaprotocol. + Fix a typo, better handling of the info document. (from Mads Kiilerich) + Don't use error.h or error(), put #error in front of cpp errors. + getopt_long() support for platforms that don't have it. + Include stdio.h for fprintf. + More for getopt support. + Check for the existance of libdl. + Don't link in libdl. + Include sys/types.h. + Copied most of the code from the redhat script. + Added semicolons required by bash2 (Mads Kiilerich). + +Guus Sliepen (18): + Added extra checks for desynchronized connection lists. Hopefully this will + Bug found! Wrong pointer was used for handling multiple ADD_HOST requests + Added checkpoints to beginning and ending of every function. + Packet queues fixed. They caused the trouble when resending keys. + Fixed typo and removed some unnecessary variables. + When trying to talk to a host that is in the netmask of a tinc server but + Converted every &variable[0] to variable. + Cleanups: + Removed write_n() function. + Oops! Reference to write_n() removed and changed into neat write() call. + Meta protocol overhaul. Tinc is now incompatible with previous versions, + Fixed small mistake that would prevent forwarding requests. + Previous fix fixed. Meta protocol should be really flawless from now on! + Replaced sprintf() by safer snprintf(), removed possible buffer overflow + Outgoing packets now use network byte order in header. + Fixes typo and UDP network byte order. + Squashed gcc warning. + Added new config variable "ProxyMode". If enabled, all outgoing packets - Releasing 1.1pre17. - -commit 32ff5ab8a22ab80cd6c141625538dcc027458c0e -Author: Guus Sliepen -Date: Sun Oct 7 18:05:50 2018 +0200 - - Update THANKS. - -commit 5f3e9858952277ef3d6ac9d119826cbdda0746d7 -Author: Rafael Sadowski -Date: Mon Oct 1 15:14:24 2018 +0200 - - OpenBSD has a proper tap device. - -commit 5e1f7fb11138bc552facfb4b64eca9131f3f25b1 -Author: Guus Sliepen -Date: Sun Oct 7 13:41:23 2018 +0200 - - Update README and links to required libraries. - -commit a03991b7911a5f0afbf1269ac47143d09be76c52 -Author: Guus Sliepen -Date: Sun Oct 7 13:32:25 2018 +0200 - - Don't check for NULL-pointers before calling free(). - -commit b0ffeb7eeb21920842382c302ca15ec0d758e9b6 -Author: Guus Sliepen -Date: Sun Oct 7 13:05:49 2018 +0200 - - Fix spelling errors. - - Found by codespell. - -commit 1c475ecb575367a6b3f9328b0f643ad636155341 -Author: Guus Sliepen -Date: Sat Oct 6 23:31:05 2018 +0200 - - Fix all warnings when compiling with -Wall -W -pedantic. - -commit 953f5b4231bbbb8269bb0c55b96a1c8c4bb34a59 -Author: Guus Sliepen -Date: Sat Oct 6 18:18:45 2018 +0200 - - Fix warnings from the Clang static analyzer. - -commit a6448291834ca7419553a807ee367c719c2956d0 -Author: Guus Sliepen -Date: Sat Oct 6 17:51:41 2018 +0200 - - Fix compiler warnings. - -commit 69e550f5950e31fb97eb4558c3d6e564211ab03a -Author: Guus Sliepen -Date: Sun Sep 9 22:13:43 2018 +0200 - - Add a test for backwards compatibility with the legacy protocol. - -commit 46f3eba7755089ff68fdc137b0754cae2fa523eb -Author: Guus Sliepen -Date: Sun Sep 9 18:19:15 2018 +0200 - - Prevent oracle attacks in the legacy protocol (CVE-2018-16737, CVE-2018-16738) - - The legacy authentication protocol allows an oracle attack that could - potentially be exploited. This commit contains several mitigations: - - - Connections are no longer closed immediately on error, but put in - a "tarpit". - - The authentication protocol now requires a valid CHAL_REPLY from the - initiator of a connection before sending a CHAL_REPLY of its own. - - Reduce the amount of connections per second accepted. - - Null ciphers or digests are no longer allowed in METAKEYs. - - Connections that claim to have the same name as the local node are - rejected. - - Just to be on the safe side: - - - The new protocol now requires a valid SIG from the initiator of a - connection before sending a SIG of its own. - -commit 01cb1961eac33de9e9d9cecd0910850a2cb549c3 -Author: Guus Sliepen -Date: Sun Jun 24 16:19:10 2018 +0200 - - Enable AutoConnect by default. - -commit 291b8f864ea57dd68b894a3b1482ee822aad66ed -Author: Guus Sliepen -Date: Sat Jun 23 22:32:19 2018 +0200 - - Remove address cache debug messages printed to stderr. - -commit e5b9bd324cc24355956e9e59e5ec2df72cf9d469 -Author: Guus Sliepen -Date: Sat Jun 23 22:26:12 2018 +0200 - - Avoid treating compressed MTU probes as having a negative length. - - This was not harmful, but caused negative values being logged. - -commit 950bbc8f2f9c580ac85bef7bab9a3ae36ea99c4b -Author: Guus Sliepen -Date: Wed Jun 13 22:41:02 2018 +0200 - - Print UDP RTT on its own line. - -commit 22ae0c3549628739ca7c40e48ce1a276469ded92 -Merge: 15341e76 70e1e467 -Author: Guus Sliepen -Date: Wed Jun 13 22:23:27 2018 +0200 - - Merge remote-tracking branch 'volth/release-1.1pre16-rtt' into 1.1 - - Also, reformat the code and fix a compiler warning. - -commit 15341e7697fe88a9f3b4646a2cb784dc515609bd -Author: Guus Sliepen -Date: Tue Jun 12 20:50:58 2018 +0200 - - Add missing item and attribution to NEWS. - -commit e60405831565062c914fe5498cf3b17b0bd13e8b -Author: Guus Sliepen -Date: Tue Jun 12 20:50:37 2018 +0200 - - Remove the ping test. - - This was kind of a hack. The ns-ping test is a much better test, although - it only works on Linux. - -commit 70e1e467f93f885da3e49289e96757d5cd2ae5ba -Author: volth -Date: Wed Jun 13 18:10:47 2018 +0000 - - minor - -commit 72136f8418bc7e8a0a5bf3c11215aa49dc679659 -Author: volth -Date: Wed Jun 13 14:12:02 2018 +0000 - - expose traffic stats to 'tinc info ___' and 'tinc dump nodes' - -commit 0f0585d71b28428792e53258bc570dddc17b0b27 -Author: volth -Date: Tue Jun 12 21:17:30 2018 +0000 - - keep track of round trip times of UDP pings - -commit 6c0584c55b99dd9814fed5c13536d831b3e5317e -Author: Guus Sliepen -Date: Tue Jun 12 20:01:43 2018 +0200 - - Releasing 1.1pre16. - -commit 75271559a9dc2536b9da1c655a012eb837c58761 -Author: Guus Sliepen -Date: Tue Jun 12 19:47:02 2018 +0200 - - Remove the wxPython GUI. - - This GUI is missing a lot of functionality, and won't be part of an 1.1.0 - release. Therefore, it's being removed, and might be brought back after - 1.1.0. - -commit 809ee79b458b0c45d4d60761b1d71171648bdbd5 -Author: Oliver Freyermuth -Date: Wed Apr 4 22:01:52 2018 +0200 - - Fix compiling when support for UML sockets is enabled. - -commit f52e4d07706e6314bb11cf9b553f58210f5dd181 -Author: Guus Sliepen -Date: Mon Apr 2 16:49:06 2018 +0200 - - Reformat all code using astyle. - -commit 7ee885a1f6776be85e5397eda04f75d98ff0b631 -Author: Guus Sliepen -Date: Mon Apr 2 16:33:14 2018 +0200 - - Add the ability to set a firewall mark on sockets. - - The FWMark option is added, when set it will use setsockopt(SOL_SOCKET, SO_MARK) - to set the given value as the mark on all sockets created by tinc. - - Thanks to Olivier Tirat for submitting a similar patch in the past. - -commit d32226bc14428864df08beccb3cf4f8a472f2eef -Author: Guus Sliepen -Date: Mon Apr 2 12:29:46 2018 +0200 - - Fix invitation tests if port 655 is available. - - Running the "del Port" command when no Port is set returns an error. But - it is not necessary anyway since the later "set Port" command will - overwrite it. - -commit 63fbaf7b4a33d5657cd3338b7ea91a173b9973fb -Author: Guus Sliepen -Date: Fri Mar 30 11:50:40 2018 +0200 - - Prevent an infinite loop in get_recent_address(). - - When a node is offline, but we still have edges to it that have the same - address as we already have in our address cache, an infinite loop would - happen in get_recent_address(), because we forgot to advance the pointer - in the list of known addresses, and kept looking at the same one over - and over. - - Thanks to Sven-Haegar Koch for spotting the bug and providing - diagnostics. - -commit 04e498f8b79c1ebfd7080338ffa0399d01862424 -Author: Guus Sliepen -Date: Fri Mar 30 11:38:22 2018 +0200 - - Properly implement tinc.texi's dependency on tincinclude.texi. - - With this, make distcheck succeeds even without the info-in-builddir - option to AM_INIT_AUTOMAKE. - -commit 63a3369cbc41ba68e221da174c28f5f909c2ed8d -Author: Guus Sliepen -Date: Tue Mar 27 22:54:15 2018 +0200 - - Warn if we cannot reload the tincd when creating an invitation. - -commit 2d268fc06bc01419e7f7f32d4da1b560e72e4ad3 -Author: Mike Sullivan -Date: Mon Mar 26 14:19:04 2018 -0500 - - Fix handling partial SPTPS messages in sptps_test. - -commit 69a18395931d657b77641b68ca12473ad6b996da -Author: Guus Sliepen -Date: Tue Mar 6 19:31:17 2018 +0100 - - Ensure we call CloseServiceHandle() in case of errors. - -commit a3f04cf74463e783eeddd45e998c1d15db0f868a -Author: Guus Sliepen -Date: Tue Mar 6 19:24:14 2018 +0100 - - Reformat all code using astyle. - -commit fa305d9570bc7350d04c7de66cfec28b9a2f53d1 -Author: Gjergji -Date: Tue Mar 6 11:10:41 2018 +0100 - - fix service removal. - Windows service was not removed until tincctl exits - -commit 7761a6992025ef06bf8dbf88d39a3bf9e459346a -Author: Guus Sliepen -Date: Wed Feb 28 21:34:48 2018 +0100 - - Fix compatibility with LibreSSL and OpenSSL < 1.1. - - Closes #184 on GitHub. - -commit a742ea4d040ecfaabbc875c63f2625654ce68923 -Author: Guus Sliepen -Date: Wed Feb 28 21:28:16 2018 +0100 - - Try to process all pending events after select(). - - If we break out of the loop every time at the first filedescriptor that - is read/writeable, we risk starving the other filedescriptors. - -commit d6c8a1a3d3e945142b251b2897517e10ce0dfce4 -Author: Todd C. Miller -Date: Tue Feb 27 14:20:46 2018 -0700 - - Call WSAWaitForMultipleEvents() in a loop until we have checked all events. - WSAWaitForMultipleEvents() only returns the index of the first event that is read. We need to call WSAWaitForMultipleEvents() repeatedly to check if other events are also ready. Otherwise, a single busy event (such as the TAP device) can starve the other events. - -commit 7c73cb3ace6659df58ec2382b8d47bb521dad886 -Author: Guus Sliepen -Date: Tue Feb 27 21:08:57 2018 +0100 - - Work around a GCC bug that causes inet_checksum() to give wrong results. - - Valgrind reports the following bug: - - ==24877== Conditional jump or move depends on uninitialised value(s) - ==24877== at 0x12283E: inet_checksum (route.c:80) - ==24877== by 0x12283E: route_ipv6_unreachable (route.c:315) - ==24877== by 0x1236AC: route_ipv6 (route.c:751) - ==24877== by 0x1236AC: route (route.c:1160) - ==24877== by 0x113DE0: receive_tcppacket (net_packet.c:493) - ==24877== by 0x1119D4: receive_meta (meta.c:315) - ==24877== by 0x113288: handle_meta_connection_data (net.c:287) - ==24877== by 0x11A091: handle_meta_io (net_socket.c:491) - ==24877== by 0x10FB0C: event_loop (event.c:370) - ==24877== by 0x11362E: main_loop (net.c:489) - ==24877== by 0x10CACA: main (tincd.c:551) - - Clearing the variable pseudo in route_ipv6_unreachable removes this error, - but the resulting checksum is still bad. If one instead adds a dummy - write that depends on checksum, the error goes away and the checksum is - correct. - -commit d661c7c7353da90911e9f2d0195ac861d6837f5c -Author: Guus Sliepen -Date: Tue Feb 27 19:11:38 2018 +0100 - - Revert "Unconditionally remove timeouts from the queue before calling the callback." - - This reverts commit e8a60109fc91a42420ec626b63956771675f89b0. - -commit e8a60109fc91a42420ec626b63956771675f89b0 -Author: Guus Sliepen -Date: Mon Feb 26 22:19:43 2018 +0100 - - Unconditionally remove timeouts from the queue before calling the callback. - - We are going to unlink the timeout from the splay tree anyway, so do it - unconditionally before the callback, instead of waiting until after the - callback to check whether or not to remove it based on its expiration - time. - -commit 03a94cb3148544230bdd306e905d2ce88c551c12 -Author: Todd C. Miller -Date: Thu Feb 22 14:27:37 2018 -0700 - - In device_handle_read() we need to reset the read event on error or - it will keep firing. This is easy to reproduce by suspending the - machine while tinc is running. - -commit f10e98f5e5a3537b43fbc53f07ab691265de999a -Author: Guus Sliepen -Date: Wed Feb 21 20:34:42 2018 +0100 - - Update the documentation of the control protocol. - -commit 89102b02047d0220766f55ec041c8fc46234cf69 -Author: Todd C. Miller -Date: Tue Feb 20 20:18:38 2018 -0700 - - Fix heap corruption on Windows exposed by the use-after free fix. - reset_address_cache() could call free_known_addresses() on a struct - addrinfo * that was returned by getaddrinfo(). It seems safest to just - make a copy of the addresses returned by getaddrinfo() so we can always - use free_known_addresses() instead of trying to determine whether or - not we need to use freeaddrinfo(). - -commit 8f73169567fed6703acbad4f0f5fd5cff700d619 -Author: Guus Sliepen -Date: Mon Feb 19 20:41:21 2018 +0100 - - Document the control protocol. - -commit ecfef0eeb9b52f6d75b4aa936a1e11e6d8e678e3 -Author: Guus Sliepen -Date: Sun Feb 18 16:51:06 2018 +0100 - - Reduce memory allocations due to HMAC() and EVP_MD_*(). - - HMAC() allocates a temporary buffer on the heap each time it is called. - Similarly, we called EVP_MD_CTX_create() every time we wanted to - calculate a hash. Use HMAC_CTX and EVP_MD_CTX variables to store the - state so no (re)allocations are necessary. HMAC() was called for every - legacy packet sent and received. - - This issue was found thanks to heaptrack. - -commit 6be453fc63da9f87455b5e579cb686f95fa92102 -Author: Guus Sliepen -Date: Sun Feb 18 15:38:12 2018 +0100 - - Reduce memory allocations due to zlib's uncompress(). - - Everytime uncompress() is called, zlib allocates some buffer on the heap - and frees it again. When compression is enabled, this is the biggest source - of memory allocations in tinc. Instead of using this function, use - inflate(), which can store its state in a z_stream variable, which avoids - (re)allocating memory for every packet received. - - This issue was found thanks to heaptrack. - -commit 8f2ef1a174d18a9efdf9b0bd2417132fe7d84e9f -Author: Guus Sliepen -Date: Sun Feb 18 15:33:36 2018 +0100 - - Add code coverage testing support. - - Allows configure to be run with the --enable-code-coverage flag, allowing - one to run make check-code-coverage, which runs the test suite and produces - a code coverage report. - -commit d2b03f006f98d504e3e30f2d4b91ce02abd19c51 -Author: Guus Sliepen -Date: Sat Feb 17 14:39:29 2018 +0100 - - Reformat all code using astyle. - -commit 536fe3ffcdc4c894ed986dfb5fdc0d6f78d6fe25 -Author: Todd C. Miller -Date: Fri Feb 16 14:17:39 2018 -0700 - - Fix a use-after-free bug in get_recent_address() and two related issues. - 1) The sockaddr_t * returned may be part of memory freed by the call to - freeaddrinfo(). - 2) The sockaddr_t * returned from a recently seen address not in the - cache was cast from struct addrinfo *ai, not the struct sockaddr * - inside of it. - 3) In do_outgoing_connection(), when filling in the address in the - connection_t, there is a buffer overflow (read, not write) if - the sa returned by get_recent_address() didn't come from the - cache of recently seen addresses. That is, it was really a - struct sockaddr * and not a sockaddr_t *. This last was - found by building tinc with address sanitizer. - -commit 8145a3392bdcff4d7856ba72e66a90d73d887c00 -Author: Todd C. Miller -Date: Wed Jan 31 14:55:20 2018 -0700 - - In device_issue_read() there is no need to reset Offset and OffsetHigh - to 0; they are only used for seekable files (not sockets). - - Reset the write event before the call to WriteFile(). This is - consistent with how the read event is reset before ReadFile(). - - Clear device_write_packet.len() if WriteFile() fails with an error - other than ERROR_IO_PENDING; otherwise write_packet() will call - GetOverlappedResult() the next time it is run even though there is - no write in progress. - -commit 5ec513ec0ffc735e30c559a03378659ba4cc4515 -Author: Todd C. Miller -Date: Tue Jan 23 15:57:58 2018 -0700 - - WSAEVENT is a pointer, so we cannot simply return the different of two - events in io_compare(), which returns an int. This can return the wrong - result for 64-bit executables. - -commit 92d66492e0824674f68d26e787dd1ba4444a4601 -Author: Todd C. Miller -Date: Mon Jan 22 10:27:16 2018 -0700 - - Add some missing freeaddrinfo() calls to avoid leaking memory. - -commit e0f6d90e7fac4c567900e98c354af979c97f8d59 -Author: Guus Sliepen -Date: Mon Jan 22 18:05:09 2018 +0100 - - Fix calling freeaddrinfo() on the wrong pointer. - - Thanks to Todd C. Miller for finding this issue. - -commit 7bf4d225a994d8ce9fb45d42afd53793c4232e8e -Author: Etienne Dechamps -Date: Wed Jan 17 19:37:53 2018 +0000 - - Move ResetEvent() call before ReadFile(). - - Commit 313a752 changed the Windows device code such that ResetEvent() is - called on the read OVERLAPPED structure before GetOverlappedResult(), as - opposed to before ReadFile(). In [1] Guus pointed out that this doesn't - make a ton of sense, and I agree with him; it must have been an - oversight on my part when I wrote this code. - - Surprisingly, none of this makes any difference in my testing, at least - with the standard TAP 9.0.0.9 driver. Nevertheless, this code is - probably wrong and fixing it will make me sleep better at night. - - [1]: https://www.tinc-vpn.org/pipermail/tinc/2018-January/005091.html - -commit 43cf631bc10097448db041639ad07f84f647017e -Author: Etienne Dechamps -Date: Sun Jan 7 14:48:08 2018 +0000 - - Fix "use of GNU empty initializer extension" warning. - -commit 1b777010e7255cb354e31ca28c6442ee86383bac -Author: Etienne Dechamps -Date: Sun Jan 7 14:44:12 2018 +0000 - - Fix "void function should not return void expression" warning. - -commit ddf798a0ef7df21d682d2f6763d5417400c987ba -Author: Etienne Dechamps -Date: Sun Jan 7 14:26:00 2018 +0000 - - Fix AC_CHECK_DECLS usage in openssl.m4. - - See: - - https://www.gnu.org/software/autoconf/manual/autoconf-2.62/html_node/Generic-Declarations.html - - "For each of the symbols (comma-separated list)" - - When building with aggressive warning settings the current code results - in the following configure test code being generated: - - #ifndef OpenSSL_add_all_algorithms EVP_aes_256_cfb - #ifdef __cplusplus - (void) OpenSSL_add_all_algorithms EVP_aes_256_cfb; - #else - (void) OpenSSL_add_all_algorithms EVP_aes_256_cfb; - #endif - #endif - - Which is obviously wrong and makes the configure check fail. - -commit 04543a57e73e29c3e2a1968fd330f03c94dd6059 -Author: Guus Sliepen -Date: Fri Jan 5 22:49:30 2018 +0100 - - Add a cache of recently seen addresses. - - This maintains a cache file for each host we have communicated with, either - via TCP or UDP. The cache is used when trying to make outgoing connections, - and is updated whenever a successful TCP or UDP connection is established. - Up to 8 addresses are stored in the cache. - - Currently, the cache is stored in /etc/tinc/NETNAME/cache. The directory - has to be manually created to opt in to this feature for now. - -commit ca989c0c8b19901cbd7664a9d2b42aa85c9c176e -Author: Guus Sliepen -Date: Sat Jan 6 20:46:22 2018 +0100 - - Fix all spelling errors found by codespell. - -commit 6989a070c35b9672683ebb0764ab9051e0650469 -Author: Guus Sliepen -Date: Sat Jan 6 20:34:37 2018 +0100 - - Document how to enable tinc at boot time using systemd. - -commit fe9089337093c917d172aa26eedc9285c8bafb6a -Author: Guus Sliepen -Date: Sat Jan 6 16:59:21 2018 +0100 - - Don't include generated files into the tarball. - -commit e56589082f6198380d7f2246a776e41d388496f6 -Author: Guus Sliepen -Date: Sat Jan 6 16:21:19 2018 +0100 - - Update .gitignore. - -commit ee5e3404e49ef08437cd6b6e4c5b83d190efa053 -Author: Guus Sliepen -Date: Sat Jan 6 16:20:25 2018 +0100 - - Ensure the sptps-basic test doesn't fail during make distcheck. - -commit c2d8264dbe8478d27ba694062cebecee0a0342c4 -Author: Guus Sliepen -Date: Sat Jan 6 16:20:03 2018 +0100 - - Set default systemd unit path to ${libdir}/systemd/system. - - This installs systemd unit files into /usr/local, just like the binaries. - The systemd documentation claims to read this directory as well. - -commit c550c85d75ae38b9621147fdca4bf4380d54edda -Author: Guus Sliepen -Date: Sat Jan 6 16:17:35 2018 +0100 - - Remove hardcoded paths from systemd unit files. - - Closes #160 on GitHub. - -commit bdeba3f9c26f9225c17c097ca490dc651cd40b90 -Merge: 696dc2ad 9ca5a3c4 -Author: Guus Sliepen -Date: Fri Jan 5 19:58:28 2018 +0100 - - Merge remote-tracking branch 'dechamps/ipip' into 1.1 - -commit 9ca5a3c43854fba782d87be080d7a97a88ef3427 -Author: Etienne Dechamps -Date: Tue Jan 2 09:55:26 2018 +0000 - - Support MSS clamping for IP in IP (RFC 2003) packets. - - This change allows tinc MSS clamping to operate on TCP streams that are - inside an IP in IP tunnel. - -commit 696dc2ad9743c62e56a6d21addb8c4e8efbffec1 -Author: Guus Sliepen -Date: Fri Jan 5 17:13:57 2018 +0100 - - Add missing newlines to some error messages. - -commit 313b05b67c59c316c0eff631598e0700e0fd3c8d -Author: Guus Sliepen -Date: Fri Jan 5 17:13:25 2018 +0100 - - Document that invitation files MUST always start with Name = ... - -commit 356118324f7cde276f393162fca54040f8c67f04 -Author: Guus Sliepen -Date: Fri Jan 5 17:12:06 2018 +0100 - - Don't warn about empty lines in invitation files. - -commit 50afa82a8f14ead7d4d3eafd2a1347b3bb9a2879 -Author: Guus Sliepen -Date: Mon Dec 18 10:47:40 2017 +0100 - - Document the --batch option. - -commit 0b2361a9399944cd57def87226f2be7f92646aa5 -Author: Guus Sliepen -Date: Sat Dec 16 22:54:31 2017 +0100 - - Assume all IPPROTO_* macros exist. - -commit b8acb89add4e553d141a45392bc0126c331deee6 -Author: Guus Sliepen -Date: Mon Nov 6 22:52:17 2017 +0100 - - Fix building documentation when using OpenBSD's make. - -commit 4986917cb11be70a9103917d58e7aa47ab88f09d -Author: Guus Sliepen -Date: Mon Nov 6 22:49:41 2017 +0100 - - Update THANKS. - -commit 38489e37f50e807e51bfd28ebb8b20396eed1447 -Author: Guus Sliepen -Date: Mon Nov 6 22:44:12 2017 +0100 - - Const correctness. - -commit 61b441dc995c1e6dd21fd85e2014dd981e9c9350 -Author: Guus Sliepen -Date: Mon Nov 6 22:35:28 2017 +0100 - - Support autoconf's --runstatedir option. - - Put the PID file in @runstatedir@ instead of @localstatedir@/run. This - requires autoconf 2.70, which is not released yet, so add a fallback to - use @localstatedir@/run if @runstatedir@ is not set. - -commit 42d2dff33306beae8ddbd9cc991ad80f135950a6 -Author: Guus Sliepen -Date: Mon Nov 6 22:28:32 2017 +0100 - - Ensure all parameters have names in header files. - -commit b34eb5555d40b7e87c1e06988250e4977a793c09 -Author: Guus Sliepen -Date: Mon Nov 6 22:27:57 2017 +0100 - - Remove unused functions. - -commit 6123ed30992d671b94fc016660086be6a62a3871 -Author: Guus Sliepen -Date: Mon Nov 6 21:46:17 2017 +0100 - - Don't log errors when autoconnecting fails and debuglevel is 0. - -commit c84fce52d2191df06e24737449e8983174984ddc -Author: Guus Sliepen -Date: Thu Oct 26 21:33:46 2017 +0200 - - If we are using libncurses, also try to link with libtinfo. - - On some distributions, tinc might not be linked correctly if -ltinfo is - not explicitly specified. - -commit e88b3fb52fb375cd8ab233a671f38ed2240ed828 -Author: Guus Sliepen -Date: Wed Oct 25 21:08:29 2017 +0200 - - Only forward SPTPS packets if Forwarding = internal. - - This tries to match what is done for packets using the legacy protocol. - However, since SPTPS is end-to-end encrypted, Forwarding = kernel cannot - be implemented. In that case, we also drop the packets. - -commit 87f96aec8c48327d879c20ff2b789c88a675173d -Author: Todd C. Miller -Date: Wed Oct 25 10:05:06 2017 -0600 - - Replace remaining sizeof foo with sizeof(foo). - -commit 9e7c6d4dce8b87d40cea537fd0b035a2612580e3 -Author: Guus Sliepen -Date: Mon Oct 23 21:10:20 2017 +0200 - - Disable PMTU discovery when TCPOnly is used. - -commit 7c359313aca273319f94fe18121831ab4b62a4b4 -Author: Guus Sliepen -Date: Wed Oct 11 19:30:17 2017 +0200 - - Add some information about the requirements of a chroot environment. - -commit a0baeddb8aa745007d0302ed06247cabb8facb32 -Author: Guus Sliepen -Date: Sun Oct 8 21:32:12 2017 +0200 - - Ensure "make distcheck" really runs without errors. - -commit f6e87ab476a0faf8b124ecaaa27f967d825e6457 -Author: Guus Sliepen -Date: Sat Oct 7 17:50:22 2017 +0200 - - Reformat all code using astyle. - -commit 3a316823b971396a428f020f401b9fe41252d98d -Author: Guus Sliepen -Date: Sat Oct 7 17:47:19 2017 +0200 - - Convert sizeof foo to sizeof(foo). - - While technically sizeof is an operator and doesn't need the parentheses - around expressions it operates on, except if they are type names, code - formatters don't seem to handle this very well. - -commit 5822f817aa802c2c5a83e9d99a8ae78cb822799b -Author: Guus Sliepen -Date: Sat Oct 7 17:40:34 2017 +0200 - - Update all header guards. - - Don't start with underscores, as those are reserved for system - libraries. Make sure all start with TINC_, and that they appear at - the top of the file. - -commit 3465746b9bf75124b21eab21cdf390696b608405 -Author: Guus Sliepen -Date: Sat Oct 7 16:51:32 2017 +0200 - - Remove unused/obsolete checks from configure.ac. - -commit ced6c3151d6012df560f088d39d306370bb115b7 -Author: Daniel Lublin -Date: Thu Oct 5 09:23:20 2017 +0200 - - doc: there is, not their is - -commit d3cb2a7342218c1aadfacd92d640c426d725112f -Author: Guus Sliepen -Date: Tue Oct 3 21:23:28 2017 +0200 - - Prepare for automatic code formatting using Artistic Style. - -commit e3d914a4d5f5be1c263ec77b9b5c62afb5fc1b78 -Author: Guus Sliepen -Date: Sun Oct 1 22:04:40 2017 +0200 - - Update THANKS. - -commit 453e6070ddfab2157f52536bdd7a79fc16f851f4 -Author: Todd C. Miller -Date: Thu Sep 28 16:39:59 2017 -0600 - - Fix parsing of -b flag - - Only the short -b option is missing, --batch works as expected. - -commit af81c436d6e11a53803747af7cc8ecfd449ccd4c -Author: Guus Sliepen -Date: Sat Sep 2 21:56:17 2017 +0200 - - Releasing 1.1pre15. - -commit 4e5c2193a1fa1ed054956fc0b1df387b19c546a5 -Author: Guus Sliepen -Date: Sat Sep 2 21:55:47 2017 +0200 - - Drop h and hh length modifiers from printf format strings. - -commit 91d50f8b375503be6b6081985f5948773d64b9d3 -Author: Guus Sliepen -Date: Sat Sep 2 21:54:34 2017 +0200 - - Ensure packet priority is cleared when sending PMTU probe replies. - - Found by the Clang static analyzer. - -commit 00d81ee6236e76f80b84372ac5c635636ad48136 -Author: Guus Sliepen -Date: Sat Sep 2 21:52:44 2017 +0200 - - Fix a file descriptor leak when using an invitation. - - Found by cppcheck. - -commit a073b2cb0bca646685a83479db6b66d518240bc5 -Author: Guus Sliepen -Date: Sat Sep 2 21:06:25 2017 +0200 - - Fix a compiler warning. - -commit 843990d8df0c060db9b64e170996e9d49c8c921d -Author: Guus Sliepen -Date: Sat Sep 2 17:24:05 2017 +0200 - - Force IPv4 for sptps-basic.test. - - Allow forcing either IPv4 or IPv6 for sptps_test, and use IPv4 for the - sptps-basic test. Since sptps_test is only opening a single listening - socket, and you cannot control which address family it uses, this gets - around a problem where the listening side is using a different address - family than the one connecting to it. - -commit 5f89950f47a9cf73169e797d4e2d6ef8b7f74a5a -Author: Guus Sliepen -Date: Sat Sep 2 17:04:25 2017 +0200 - - Add missing break statements. - -commit 92fdabc439bdb5e16f64a4bf2ed1deda54f7c544 -Author: Guus Sliepen -Date: Tue Aug 22 20:51:44 2017 +0200 - - Make autoconnect try to heal network splits. - - When we have less than three connections, we greedily try to connect to any - viable node. However, once we have three connections, try to connect to - nodes that we know of but that aren't reachable. - - We also make sure that if there are 100 reachable nodes, and 1 unreachable - one, that not all 100 reachable nodes try to connect to the unreachable - at the same time. - -commit 7c223917cb3d478fc3f5b23ee5602925f083e4d4 -Author: pacien -Date: Tue Aug 15 19:56:06 2017 +0200 - - Add LogLevel config option - -commit e4544dbc6989e4a146c19519924e52c116bfc343 -Author: Guus Sliepen -Date: Thu Jul 27 10:06:13 2017 +0200 - - Forward-port tinc 1.0's handling of device errors. - -commit d73cdee5df3e6c7395270c69e944b3c853f013ae -Author: volth -Date: Thu Jul 27 06:32:28 2017 +0000 - - Avoid infinite loop on EBADFD - - On Linux network restart, Tinc can get into a loop writing millions of error messages "Error while reading from Linux tun/tap device (tun mode) /dev/net/tun: File descriptor in bad state" to the log. https://github.com/NixOS/nixpkgs/pull/27675 - - It should be somehow aborted. - Here is my quick hack. - -commit acefa66dbd97617d86dee270b2b95ecdb763434b -Author: Guus Sliepen -Date: Sun Jul 9 16:12:55 2017 +0200 - - Store the invitation data after a succesful join. - - This can be used by the invitee to examine the file after a join, and - process it in different ways than the tinc CLI does. - -commit cd854fa86a9dc177dcaa56fa774afb127b29651a -Author: Guus Sliepen -Date: Sun Jul 9 15:57:51 2017 +0200 - - Add configurable experation time for invitations. - -commit 93584bc1cad7c7cc9c95859a8cde548bc18b6fa8 -Author: Guus Sliepen -Date: Sun May 28 12:48:32 2017 +0200 - - Set KillMode=mixed in the systemd service file. - - This ensures only the main process is sent the SIGTERM, and not anything - else that might have started in the same control group, including the - tinc-down script. - - Closes #145 on GitHub. - -commit 970799aa3406c22a575f665d3964c15d7c9ab555 -Author: Guus Sliepen -Date: Sun May 28 12:26:44 2017 +0200 - - Move logging of "would block" messages to debug level 4. - -commit 3d8a8363544bfcf75a9124251eff0caae3a8f1a2 -Author: Guus Sliepen -Date: Sun May 7 15:29:22 2017 +0200 - - Remove unused add_scalar function. - -commit 958a751e20270da821fee651ff9ecda8a2afc5d0 -Author: thorkill -Date: Thu May 4 23:44:56 2017 +0200 - - Fix NULL pointer dereference in send_udp_info - -commit 9527f4f22cd71feeee8a49866e29cce98408f1e7 -Author: thorkill -Date: Mon May 1 12:40:22 2017 +0200 - - Sanitize input in id_h - prevent integer overflows - -commit 18646deca120f0ccc3bfad643dba83547ecc2f20 -Author: Guus Sliepen -Date: Tue Apr 18 20:09:38 2017 +0200 - - Fix some minor issues found by cppcheck. - -commit 060ab1cd7cdf750a0477f2a8b6193d28849877e8 -Author: Guus Sliepen -Date: Tue Apr 18 20:09:08 2017 +0200 - - Add field widths to sscanf() calls. - - Found by cppcheck. - -commit be8e5cbd1cfcd198f975542e52085abdd543ec80 -Author: Guus Sliepen -Date: Tue Apr 18 20:07:33 2017 +0200 - - Remove dead stores. - - Found by the Clang static analyzer. - -commit 70fed5f7ffdeb0416ee6b77881098faab9a7cd47 -Author: Guus Sliepen -Date: Mon Apr 17 16:05:30 2017 +0200 - - Add missing tinc stop command to the scripts test. - -commit a14414731925cd59e64b3a90309b5a9ec60ac690 -Author: Guus Sliepen -Date: Mon Apr 17 13:54:02 2017 +0200 - - Fix tests on *BSD. - -commit db80dbbac93ce3c714247e0af2147f5e1474a135 -Author: Guus Sliepen -Date: Mon Apr 17 13:53:48 2017 +0200 - - Fix segfault when adding environment variables. - -commit 1be0c284c7c8d34c2dd6c2160ce49aeae468e867 -Author: Guus Sliepen -Date: Mon Apr 17 13:07:15 2017 +0200 - - Fix compiler warnings on *BSD. - -commit 2b4c0c63628ff9b432ec5d4b4c7b7ab2d4b02fb2 -Author: Guus Sliepen -Date: Mon Apr 17 13:02:39 2017 +0200 - - Make sure realname is always initialized. - -commit c87a77b5fd2a0378f2b992a5d579a80ee4033cec -Author: Guus Sliepen -Date: Mon Apr 17 12:50:30 2017 +0200 - - Ensure tests compile on *BSD. - -commit 95f09569beb2e304e6a2112d20cee6fab88f3729 -Author: Guus Sliepen -Date: Sat Apr 8 13:34:40 2017 +0200 - - Use getmsg()/putmsg() instead of read()/write() on Solaris. - - This fixes a problem where read() returns packets from the IP layer before - fragmentation is done. - - # Conflicts: - # src/solaris/device.c - -commit 6011197be5cdb18aa79713990d6a1887b9261d12 -Author: Guus Sliepen -Date: Sat Apr 8 13:31:04 2017 +0200 - - Use /dev/udp instead of /dev/ip on Solaris. - - # Conflicts: - # src/solaris/device.c - -commit 9a113db0a61242a0273a7ac95dd536f3a4bdb581 -Author: Guus Sliepen -Date: Wed Mar 29 08:08:56 2017 +0200 - - Ensure sptps_keypair and sptps_test get build for make check. - -commit d9a7f2d1054a7155b5f23855ba28dd98e0df73be -Author: Guus Sliepen -Date: Wed Mar 29 08:08:19 2017 +0200 - - Use 127.0.0.1 instead of localhost to ensure tests are reproducible. - -commit 3ab1893a4b6c2895075ac889cf06c511e2001a9e -Author: Guus Sliepen -Date: Sun Mar 26 17:54:37 2017 +0200 - - Ensure proper logging in the invite-offline test. - -commit 0af3dcf7a838dede699194c02444f1607644bb28 -Author: Guus Sliepen -Date: Sun Mar 26 17:43:33 2017 +0200 - - Add the scripts test. - - This test whether all the scripts are run with the right information in - the right order. - -commit ebade1e8f80ebaa476f701089da7ae654837397c -Author: Guus Sliepen -Date: Sun Mar 26 16:48:02 2017 +0200 - - Update .gitignore. - -commit fd3ec60757a84b7551e03b3a48dd30f35015c448 -Author: Guus Sliepen -Date: Sun Mar 26 16:47:54 2017 +0200 - - Add the invite-offline test. - - This tests generating an invitation on the server while no tinc daemon is - running. - -commit 5fcf6e16acccdaac573eebae21a5a47294e346e4 -Author: Guus Sliepen -Date: Sun Mar 26 16:46:31 2017 +0200 - - Remove superfluous sleep command in invite-join test. - -commit ccb4fb6f7ac2efbb99d044aa072e75c035f504aa -Author: Guus Sliepen -Date: Sun Mar 26 16:46:03 2017 +0200 - - Use unique ports for all tests. - -commit add75303e918af5e94ff545d969872799fac5cef -Author: Guus Sliepen -Date: Tue Mar 21 21:25:27 2017 +0100 - - Add DEBUG environment variable for scripts. - - This contains the current debug level used by tinc. Scripts can use it - to decide whether to log debugging information of their own. - - Closes #138 on GitHub. - -commit 5cbef906209eb5005f821af8f55a6f5d7e7d060c -Author: Guus Sliepen -Date: Tue Mar 21 21:21:23 2017 +0100 - - Put script environment creation/deletion in functions. - - This makes environment handling safer, and also has a single place where - we can add new environment variables that should be present for all - scripts. - -commit 3e643d5d7e5c7db35eacb3703d497c584e93cf18 -Author: Vittorio Gambaletta (VittGam) -Date: Wed Oct 12 13:52:17 2016 +0200 - - route: Support ToS/DiffServ priority inheritance when routing IPv6 packets. - - Signed-off-by: Vittorio Gambaletta - -commit aebaaa8db80ec3931346af710f2182d129c74c41 -Merge: 2c333f0f d21d97ea -Author: Guus Sliepen -Date: Mon Mar 20 22:33:18 2017 +0100 - - Merge remote-tracking branch 'dechamps/sleep' into 1.1 - -commit 2c333f0f45f445d0811a364817d03df0c8cf2d2f -Author: Guus Sliepen -Date: Mon Mar 20 22:19:36 2017 +0100 - - Don't try to use kill() on Windows. - -commit 26dc50599d6e38be1e7304602ffea0ba282c1091 -Author: Guus Sliepen -Date: Mon Mar 20 22:15:20 2017 +0100 - - Add missing #defines used by fd_device.c. - -commit 3fc678a8df4d6c057ef9f2c602b86ed106651e68 -Author: Guus Sliepen -Date: Tue Mar 7 19:19:19 2017 +0100 - - Use free_known_addresses() to free memory allocated by get_known_addresses(). - - We know what struct addrinfo looks like, but the standard says nothing - about how it is allocated. So we cannot trust freeaddrinfo() to work - correctly on the struct addrinfo list we allocated ourselves in - get_known_addresses(). To make a distinction by allocations from the - latter and from str2addrinfo(), we keep two pointers (*ai and *kai) in - struct outgoing, and use the freeing function that is appropriate for - each. - -commit ef661316f163f2ecf6c75a3dd28e2cad51772c56 -Author: Roman Savelyev -Date: Tue Mar 7 19:07:19 2017 +0100 - - Fix lost pointer trails in get_known_addresses(). - -commit 7a54fe5e884e98ade91af527c67f9c5df1452a50 -Author: Pacien TRAN-GIRARD -Date: Mon Feb 27 20:56:55 2017 +0100 - - Add fd_device - -commit 4a45a65fe2555efc5b6763a293d30251755e78a8 -Author: Guus Sliepen -Date: Tue Feb 14 20:51:43 2017 +0100 - - Remove the description of the LocalDiscoveryAddress option from the manual. - - This option is no longer implemented. - -commit d3cc96b027a919e22bbf06d634edb0a2a069ac92 -Author: Guus Sliepen -Date: Tue Jan 31 12:05:03 2017 +0100 - - Don't build sptps_* binaries by default. - -commit 88d158e15b9e16b4227b374d8bb4640010670cef -Author: Guus Sliepen -Date: Tue Jan 31 12:03:27 2017 +0100 - - Fix potential segfault in the replacement vasprintf() function. - -commit 06b820133285f83f7e1a839cccbed13358b84081 -Author: Etienne Dechamps -Date: Sun Dec 18 14:53:33 2016 +0000 - - Fix address memory leaks in add_edge_h(). - - Note that this is not as bad as it looks, because in practice - sockaddrfree() is a no-op for typical address types. - -commit 02093b12b0133b51dd04613c94c762ad2761cd3c -Author: Etienne Dechamps -Date: Sun Dec 18 14:32:25 2016 +0000 - - Clarify the flow of add_edge_h(). - - This is an attempt at making the control flow through this function - easier to understand by rearranging branches and cutting back on - indentation levels. - - This is a pure refactoring; there is no change in behavior. - -commit 3bf3d7d3e7d51034bda873861c52578f3abe6b5d -Author: Etienne Dechamps -Date: Sun Dec 18 14:25:20 2016 +0000 - - Fix edge updates containing local address changes. - - This commit fixes a logic bug in the edge update code where local - address changes are not taken into account if they are bundled in with - other changes. This bug breaks local discovery in some scenarios. - - The regression was introduced by commit - e4670fc4a0576eb76f1807ce29fa9455dd247632. - -commit 0792a10a5a66bcbf56185e479feed78252122667 -Author: Etienne Dechamps -Date: Sun Dec 18 16:56:27 2016 +0000 - - Fix edge local addresses not being set when connections are established. - - This bug prevented nodes from advertising their local addresses, thus - breaking local discovery. - - The regression was introduced in - ab13c14a1480561bb9f59ccfbbd6045e0484ce9c. - -commit d21d97eaf5db9e848d8eee28784c4f54af85f43d -Author: Etienne Dechamps -Date: Sat Dec 3 23:13:46 2016 +0000 - - On Windows, don't cancel I/O when disabling the device. - - I have observed cases where disable_device() can get stuck on the - GetOverlappedResult() call, especially when the computer is waking up - from sleep. This is problematic when combined with DeviceStandby=yes: - - other_side (1.2.3.4 port 655) didn't respond to PING in 5 seconds - Closing connection with other_side (1.2.3.4 port 655) - Disabling Windows tap device - - - gdb reveals the following stack trace: - - #0 0x77c7dd3c in ?? () - #1 0x7482aad0 in KERNELBASE!GetOverlappedResult () from C:\WINDOWS\SysWoW64\KernelBase.dll - #2 0x0043c343 in disable_device () at mingw/device.c:244 - #3 0x0040fcee in device_disable () at net_setup.c:759 - #4 0x00405bb5 in check_reachability () at graph.c:292 - #5 0x00405be2 in graph () at graph.c:301 - #6 0x004088db in terminate_connection (c=0x4dea5c0, report=true) at net.c:108 - #7 0x00408aed in timeout_handler (data=0x5af0c0 ) at net.c:168 - #8 0x00403af8 in get_time_remaining (diff=0x2a8fd64) at event.c:239 - #9 0x00403b6c in event_loop () at event.c:303 - #10 0x00409904 in main_loop () at net.c:461 - #11 0x00424a95 in main2 (argc=6, argv=0x2b42a60) at tincd.c:489 - #12 0x00424788 in main (argc=6, argv=0x2b42a60) at tincd.c:416 - - This is with TAP-Win32 9.0.0.9. I suspect driver bugs related to sleep. - In any case, this commit fixes the issue by cancelling I/O only when the - entire tinc process is being gracefully shut down, as opposed to every - time the device is disabled. Thankfully, the driver seems to be - perfectly fine with this code issuing TAP_IOCTL_SET_MEDIA_STATUS ioctls - while there are I/O operations inflight. - -commit 1672dbd66b619f84cb86950298ad89df93e1dcba -Author: Etienne Dechamps -Date: Sat Dec 3 22:52:30 2016 +0000 - - Fix crash on Windows when a socket is available for both write and read. - - Currently, if both write and read events fire at the same time on a - socket, the Windows-specific event loop will call both the write and - read callbacks, in that order. Problem is, the write callback could have - deleted the io handle, which makes the next call to the write callback a - use-after-free typically resulting in a hard crash. - - In practice, this issue is triggered quite easily by putting the - computer to sleep, which basically freezes the tinc process. When the - computer wakes up and the process resumes, all TCP connections are - suddenly gone; as a result, the following sequence of events might - appear in the logs: - - Metadata socket read error for node1 (1.2.3.4 port 655): (10054) An existing connection was forcibly closed by the remote host. - Closing connection with node1 (1.2.3.4 port 655) - Sending DEL_EDGE to everyone (BROADCAST): 13 4bf6 mynode node1 - Sending 43 bytes of metadata to node2 (5.6.7.8 port 655) - Could not send 10891 bytes of data to node2 (5.6.7.8 port 655): (10054) An existing connection was forcibly closed by the remote host.a - Closing connection with node2 (5.6.7.8 port 655) - - - In this example the crash occurs because the socket to node2 was - signaled for reading *in addition* to writing, but since the connection - was terminated, the attempt to call the read callback crashed the - process. - - This commit fixes the problem by not even attempting to fire the write - callback when the write event on the socket is signaled - instead, we - just rely on the part of the event loop that simulates level-triggered - write events. Arguably that's even cleaner and faster, because the code - being removed was technically redundant - we have to go through that - write check loop anyway. - -commit 979acc48aded5bb04f1574128d174d56550be302 -Author: Guus Sliepen -Date: Sun Oct 30 15:19:12 2016 +0100 - - Enforce maximum amount of bytes sent/received on meta-connections. - - This is 2^{block_length_in_bits / 2 - 1}. - -commit edc1efed3c0cf5aebb1c765066c0413757229a31 -Author: Guus Sliepen -Date: Sun Oct 30 15:17:52 2016 +0100 - - Use AES256 and SHA256 by default for the legacy protocol. - - At the start of the decade, there were still distributions that shipped - with versions of OpenSSL that did not support these algorithms. By now - everyone should support them. The old defaults were Blowfish and SHA1, - both of which are not considered secure anymore. - - The meta-protocol now always uses AES in CFB mode, but the key length - will adapt to the one specified by the Cipher option. The digest for the - meta-protocol is hardcoded to SHA256. - -commit fcaf158494af7cb015d8658a3241c324518e8d7f -Author: Dennis Lan -Date: Wed Oct 12 13:35:39 2016 +0200 - - Fix typo in src/upnp.c. - -commit 9cbd3c2b5b03c29c116a14f196db8a32c7135391 -Author: Vittorio G (VittGam) -Date: Tue Oct 11 20:30:41 2016 +0200 - - tincctl: Avoid falling back to 1024 bits RSA key generation when an invalid key size is specified. - - Also warn the user if a key smaller than 2048 bits is being generated. - - Signed-off-by: Vittorio Gambaletta - -commit c7c5c74d4af7442b92d863fc9eb04395c456b0be -Author: Vittorio G (VittGam) -Date: Tue Oct 11 13:30:05 2016 +0200 - - fsck: Fix ed25519 public key reading, and fclose usage. - - Signed-off-by: Vittorio Gambaletta - -commit e6497a23f7689663aa2c19311a278e20661bddc1 -Author: Guus Sliepen -Date: Tue Jul 26 16:47:45 2016 +0200 - - Log warnings about dropped packets only with debug level 5 or higher. - -commit 2784a171ec39e2a34aabf8194a651de570e19e0e -Author: Etienne Dechamps -Date: Thu Jul 14 19:15:35 2016 +0100 - - Fix error handling when setting up the UDP socket. - - Due to this typo, if tinc managed to set up the TCP socket but not the - UDP socket, it would continue anyway. - - The regression was introduced in - 6bc5d626a8726fc23365ee705761a3c666a08ad4. - -commit b1c29464b68d756035acc4b4d1681f05d8831eaf -Author: Guus Sliepen -Date: Fri Jun 24 11:22:24 2016 +0200 - - Fix compiling with OpenSSL < 1.1.0. - -commit 9a9f6fac009caf31c3786e13231eb05b3bad0681 -Author: Guus Sliepen -Date: Fri Jun 24 11:22:11 2016 +0200 - - Add missing m4 files. - - ax_cflags_warn_all.m4 depends on them. - -commit b9b0defaf422bcc1272f87d791d9ac53c9539734 -Author: Guus Sliepen -Date: Thu Jun 23 15:59:43 2016 +0200 - - Fix potential memory leaks found by the Clang static analyzer. - -commit 49edf9c53a31714b740d0ee67c29aca503973d81 -Author: Guus Sliepen -Date: Thu Jun 23 15:59:16 2016 +0200 - - Fix warnings from the Clang static analyzer. - - These are all false positives or harmless dead stores. - -commit e16ab7b89948c24a2c47652e8eb1a817a4b1424c -Author: Guus Sliepen -Date: Thu Jun 23 15:26:58 2016 +0200 - - Force nul-termination of strings after vsnprintf(). - - Apparently, on Windows this function might not always be properly - terminated. - -commit 2de5d866b5e4d4e6b827dcfb985c24edbda71f4f -Author: Guus Sliepen -Date: Wed Jun 22 23:08:30 2016 +0200 - - Use EVP_MD_CTX_destroy() instead of _free(). - - Thanks to azrdev for pointing out the build failure on Fedora 23. - -commit 9b148fd844587fbf956e28f57e4bd39a11edc07f -Author: Guus Sliepen -Date: Wed Jun 22 17:42:25 2016 +0200 - - Check return value of RSA_generate_key_ex(). - -commit 172763f4af4340ac2c2549e8fbb7490f5f995d47 -Author: Guus Sliepen -Date: Wed Jun 22 17:35:12 2016 +0200 - - Add -Wall to CFLAGS. - -commit 323c17e232539f3f06e7cebc664ab48f60127e0e -Author: Guus Sliepen -Date: Wed Jun 22 16:32:05 2016 +0200 - - Ensure compatibility with OpenSSL 1.1.0. - -commit 74eb4cc974f6d24370f439a1761dc4412d7fa58d -Author: Guus Sliepen -Date: Sun Jun 5 15:20:57 2016 +0200 - - Fix the previous commit. - -commit ab13c14a1480561bb9f59ccfbbd6045e0484ce9c -Author: Guus Sliepen -Date: Sun Jun 5 14:47:21 2016 +0200 - - 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. - -commit e47fe48aed76bfd7d2cb957e402a8cdcb0c84759 -Author: Sean McVeigh -Date: Sat May 21 17:38:14 2016 -0400 - - fix check in cmd_pid() for failure to connect to tincd - -commit 4314df644e22778a554ca1760941a2bfae08bce2 -Author: Sean McVeigh -Date: Sat May 21 17:25:18 2016 -0400 - - check for daemon pid existence before trying to connect to the control socket, and clean up stale files otherwise. - -commit 9d0e86683cdb7d53263569ad2e49dd87bd217939 -Author: lemoer -Date: Thu May 19 17:24:31 2016 +0200 - - Added comments and unfold deep "if"-construct in timeout_handler - -commit 5baecfd11be67bb80aab6c482e0b0ac98b267cca -Author: thorkill -Date: Thu May 19 15:48:15 2016 +0200 - - 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 - -commit 0cf943753ab16704c818bebe74b4e7ea96399b05 -Author: thorkill -Date: Wed May 11 19:27:05 2016 +0200 - - Send PKT_PROBE only when handshake has been done already. - -commit 0edef996a6d944e9143f87dd3c72390979c33630 -Author: Guus Sliepen -Date: Sun May 1 20:35:26 2016 +0200 - - Releasing 1.1pre14. - -commit 3f6c663a06aac728912c4e47cbc2dc4343a3798c -Author: Guus Sliepen -Date: Sun May 1 12:07:44 2016 +0200 - - Revert "Remove tinc.service, it is not necessary." - - This reverts commit 0b6f84f96eeed20a0d771fedb72c0e19941adb7e. Although - systemd does automatically provide a "tinc.slice" when there is only a - tinc@.service template, it doesn't quite work the same way as - tinc.service. - -commit 0a6d89acc6417399dcf95efd68553d21e1f744e3 -Author: Guus Sliepen -Date: Sat Apr 30 20:55:12 2016 +0200 - - Releasing 1.1pre13. - -commit 2055c3e21d5b3f4217883d52d5e5b0fbad504785 -Author: Guus Sliepen -Date: Sat Apr 30 20:05:22 2016 +0200 - - AutoConnect now only chooses from nodes for which we know an address. - - Based partially on work from Rafał Leśniak. - -commit 0b6f84f96eeed20a0d771fedb72c0e19941adb7e -Author: Guus Sliepen -Date: Sat Apr 30 18:08:31 2016 +0200 - - Remove tinc.service, it is not necessary. - - Thanks to Alexander Ried for pointing out that if you have - tinc@.service template, systemd will provide a default slice containing - all instances of that template. So "systemctl start tinc" will still do - what we want it to do. - -commit 8377d0b8569b8d5240ad88683ad527c67237617a -Author: Guus Sliepen -Date: Wed Apr 27 20:30:36 2016 +0200 - - Fix BSD tun device support. - - This was broken by a botched merge from the master branch in commit d7f6737. - -commit 390d25f0b80dd7418e147de3561c70461628574d -Author: Guus Sliepen -Date: Sun Apr 24 13:23:06 2016 +0200 - - Releasing 1.1pre12. - -commit 5a7c6546a46bdcc97cf73a9aef206d2a83bb1eb4 -Author: Guus Sliepen -Date: Sat Apr 23 21:39:53 2016 +0200 - - Don't check file permissions on Windows during fsck. - -commit 83fa44ce42c67837dad30ba1538bf1fa8c49a47d -Author: Guus Sliepen -Date: Sat Apr 23 21:32:42 2016 +0200 - - 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. - -commit 9a66d7499ae2c838c25f9c6bfcc277c3fa231dea -Author: Guus Sliepen -Date: Sat Apr 23 21:32:29 2016 +0200 - - Fix a compiler warning on Windows. - -commit ab5f4cbdc65cbc55062b36a6c11482c217884fe8 -Author: Guus Sliepen -Date: Sat Apr 23 17:28:30 2016 +0200 - - Fix possible read of freed memory when verifying the signature of a file. - -commit 76955a6c8b7a76d00ed401853c9d283e32d9ce1c -Author: Guus Sliepen -Date: Sat Apr 23 17:20:08 2016 +0200 - - Have "tinc fsck" recognize Ed25519PublicKey statements. - -commit 6805b157312c1f9adeee0035f540f4cbd63a79fd -Author: Guus Sliepen -Date: Sat Apr 23 16:05:41 2016 +0200 - - Move documentation of invitations to the manual. - -commit 51a0dc51451897cc0290d5040e42616dda9bdc8a -Author: Guus Sliepen -Date: Sun Apr 17 18:11:04 2016 +0200 - - Fix the "network" command in tinc shell. - -commit b6b302cee9de92d157f73d7739cc259d269c0ca0 -Author: Guus Sliepen -Date: Sun Apr 17 17:06:11 2016 +0200 - - Speed up AutoConnect at startup. - - Call periodic_handler() immediately at startup. Also, don't try to - connect to ourself. - -commit f934417aa658367587dadc81bd5c466baef407ef -Author: Guus Sliepen -Date: Sun Apr 17 16:23:31 2016 +0200 - - Don't call terminate_connection(myself->connection). - - It doesn't do anything except give a confusing error message that we are - closing the connection to ourself. Replace it with connection_del(). - This also fixes a double free. - -commit 2213ecaea550ce81c595464ad4347414bcb5d786 -Author: Guus Sliepen -Date: Sun Apr 17 16:01:49 2016 +0200 - - Handle special characters in sptps_test only if the --special option is given. - - sptps_test treats lines starting with #, ^ and $ specially, in order to - test the SPTPS protocol. However, this should only be done if explicitly - requested, otherwise it can unexpectedly fail. - -commit c2dc3784f127ef6db6e9960a4abecc1aab6f4e31 -Author: Guus Sliepen -Date: Sun Apr 17 14:38:37 2016 +0200 - - Add stricter checks for netnames. - - When passing a NetName via an invitation, we don't allow any characters - that are unsafe (either because they could cause shells to expand things, - or because they are not allowed on some filesystems). - - Also, warn when tinc is started with unsafe netnames. - -commit 097c69fc6a223213302fe9ffbe00a4c05357e660 -Author: Guus Sliepen -Date: Sun Apr 17 14:36:29 2016 +0200 - - Use ifconfig_header(). - -commit af9ee7ff003fb448b783ccf39347907adc239cb2 -Author: Guus Sliepen -Date: Sun Apr 17 14:04:57 2016 +0200 - - Chdir() to the configuration directory instead of /. - -commit 9bd978cc8ebf2fd9075f2be646fafd90128d403f -Author: Guus Sliepen -Date: Sun Apr 17 13:56:37 2016 +0200 - - Add a test for tinc-up creation from invitations. - -commit 0b96b6967256803c739a6b0a89d54ab8d6f63335 -Author: Guus Sliepen -Date: Sun Apr 17 13:55:36 2016 +0200 - - Fix compiler warnings. - -commit a08860ff8c2ad859836ed51c5629d6a85343e802 -Author: Guus Sliepen -Date: Sun Apr 17 13:55:18 2016 +0200 - - Fix gateway parsing in invitation files. - -commit 6d0452896673c36226c24144d4bde824a49c3950 -Author: Guus Sliepen -Date: Sun Apr 17 13:23:01 2016 +0200 - - Allow gateways to be specified for routes. - - Also improve the variable names, and ensure the % symbols in - %INTERFACE% are properly quoted. - -commit 03878f12150cbdb1aeb43e207404a0929a35ff13 -Author: Guus Sliepen -Date: Sun Apr 17 01:13:56 2016 +0200 - - Move some stray #includes. - -commit 3273e3254107a4b89cd9963012d5fac8927c417c -Author: Guus Sliepen -Date: Sun Apr 17 01:13:27 2016 +0200 - - Generate a tinc-up script from an invitation. - - This adds the ability for an invitation to provision an invitee with a - tinc-up script. This is quite strictly controlled; only address configuration - and routes are supported by adding "Ifconfig" and "Route" statements to - the invitation file. The "tinc join" command will generate a tinc-up script - from those statements, and will ask before enabling the tinc-up script. - -commit b2200f216658e07ab4e45592fa7de012a2ed96df -Author: Guus Sliepen -Date: Sat Apr 16 22:06:47 2016 +0200 - - Document how invitation files work. - - This should eventually be merged in to tinc.texi. - -commit a31e1f03c4eff16403178695d971a0838996ba2e -Author: Guus Sliepen -Date: Fri Apr 15 16:56:56 2016 +0200 - - Stop using SOL_TCP, SOL_IP and SOL_IPV6. - - Instead, use IPPROTO_TCP, _IP and _IPv6. This fixes an issue on OS X where - it didn't create an UDP socket that listened on IPv4. - -commit a0a8f8f81fc8da068e93088c7c13f689a96fac66 -Author: Guus Sliepen -Date: Fri Apr 15 16:30:45 2016 +0200 - - Fix crash at startup when Device is not specified on OS X. - -commit 8afb52a39a72805cd24b6979248135e0d8b17c32 -Author: Guus Sliepen -Date: Fri Apr 15 14:27:52 2016 +0200 - - Fix conditional checking of tun/tap headers on DragonFly BSD. - -commit 039d6d48afe00a0fa9e11bcdbfea8e996cce4ad0 -Author: Guus Sliepen -Date: Fri Apr 15 12:42:30 2016 +0200 - - Fix some compiler warnings from MinGW. - -commit 1f5c26102e228420fd954af1d73d3a89fc700d9d -Author: Guus Sliepen -Date: Fri Apr 15 12:30:01 2016 +0200 - - Fix generation of version_git.h for some versions of BSD make. - - In order to support VPATH builds, we have to use ${srcdir}/version.c as - the target for the rule that depends on the generation of version_git.h. - When not doing a VPATH build, ${srcdir} expands to ".", so the target - will be "./version.c". However, on some BSDs, make does not understand - that "./version.c" is the same as "version.c", and therefore it doesn't - trigger generating version_git.h when trying to build version.o. (It - works fine if you do a VPATH build, and OpenBSD's make does the right - thing in all cases.) - - The trick is to have version.c depend on ${srcdir}/version.c. Of course, - Linux's make knows this is nonsense and will complain about a circular - dependency, so add this rule only on BSD platforms. - -commit 0037ec7cb38994dda6ab5e4fa85ce595b9a59f6b -Author: Guus Sliepen -Date: Fri Apr 15 12:29:31 2016 +0200 - - Fix a non-working cast to get rid of a compiler warning. - -commit 25bcdad878eb7349d19ea877fdcc058d4c6b2242 -Author: Guus Sliepen -Date: Fri Apr 15 11:38:56 2016 +0200 - - Don't use HAVE_SYSTEM, the autoconf check was removed. - -commit cd5f222cc4e769395a7c6c8646abefe1d657f844 -Author: Guus Sliepen -Date: Fri Apr 15 11:25:18 2016 +0200 - - Remove use of strcpy() and sprintf(). - - Even though they were safe, compilers like to warn about them nowadays. - -commit d4410d0cce40929db9a0ce7042ef962f1867234d -Author: Guus Sliepen -Date: Fri Apr 15 11:10:50 2016 +0200 - - Don't assume sa.sa_family is a short int. - - Because FreeBSD's compiler complained about it. - -commit d704a89ecc0811eb0cdac4e4be8ff3bdb0838976 -Author: Guus Sliepen -Date: Fri Apr 15 11:00:14 2016 +0200 - - Add version_git.h and sample-config.tar.gz to CLEANFILES. - -commit 3cceae93f61a44d4f9f38d729555b2f31e209beb -Author: Guus Sliepen -Date: Thu Apr 14 23:51:18 2016 +0200 - - Make some platform-specific header checks conditional. - - Don't check for linux/if_tun.h on BSD platforms for example. - -commit d10834e92015f1e0e5bf74e03b161b3a5dc363fb -Author: Guus Sliepen -Date: Thu Apr 14 23:24:22 2016 +0200 - - Remove support for Windows 2000 and anything that doesn't support getaddrinfo(). - -commit 615ecb7a8a6e0ffc8d37f08fe46d5c50cef8b3e0 -Author: Guus Sliepen -Date: Thu Apr 14 23:10:59 2016 +0200 - - Remove checks for non-C99 compliant compilers. - -commit ed09fa4e03c907736b2be0a831d10863ce4cae84 -Author: Guus Sliepen -Date: Thu Apr 14 23:01:18 2016 +0200 - - Fix version_get.h generation on BSD. - - It doesn't like .PHONY rules that are actually doing stuff. So make a really - phony rule that does nothing and depend in it in the version_git.h rule. - -commit 2802b3a49797a0f58d6a8f4d9945d54acc64d996 -Author: Guus Sliepen -Date: Thu Apr 14 22:59:42 2016 +0200 - - Fix typo in Makefile.am. - -commit 46ebfbb6eb9966239f7826e002d99554420bbbc8 -Author: Guus Sliepen -Date: Thu Apr 14 17:29:25 2016 +0200 - - Use getcwd() instead of get_current_dir_name(). - -commit b5b04910b928c63a31a0859f04bf067ca9bd1cc2 -Author: Guus Sliepen -Date: Thu Apr 14 17:20:36 2016 +0200 - - Replace usleep() with nanosleep(). - -commit 491839a81aba00d4af50b66563cedaac4fa7028c -Author: Guus Sliepen -Date: Thu Apr 14 17:05:10 2016 +0200 - - Fix compiling under MinGW. - -commit 34ea20af73a35cd918ce9dc25796bebf9493b49c -Author: Guus Sliepen -Date: Thu Apr 14 17:03:01 2016 +0200 - - Remove checks for headers and functions that are in C99. - -commit fd3800324f4e4c67b087eaf5e0a61a184a270812 -Author: Guus Sliepen -Date: Wed Apr 13 15:34:16 2016 +0200 - - Make text files Markdown-compatible. - -commit 7f749c7e75c08549d7ce43838622624a8093de85 -Author: Guus Sliepen -Date: Mon Apr 11 15:28:26 2016 +0200 - - Update .gitignore. - -commit 9ba3e95a9a559240d16de71ca1513c7bfa98a70c -Author: Guus Sliepen -Date: Mon Apr 11 15:27:08 2016 +0200 - - Remove elliptic curve stubs from gcrypt/, add PRF implementation. - -commit 20dd1c21dc6d238200e62a1111a7d0d145168548 -Author: Guus Sliepen -Date: Fri Apr 8 17:49:49 2016 +0200 - - Really don't compile getopt*.c if the system provides getopt_long(). - -commit 9527622abc75ef41498de70ed6ded6bf5b38cfac -Author: Guus Sliepen -Date: Sat Apr 9 22:17:47 2016 +0200 - - Enable silent builds by default. - - Cleaner build messages make it easier to spot compiler warnings and errors. - Use make V=1 to get the verbose output back. - - # Conflicts: - # configure.ac - # doc/Makefile.am - -commit 413faffca356b25cf69ddf0a718730d46f9941bc -Author: Guus Sliepen -Date: Sun Apr 10 15:04:59 2016 +0200 - - Update links in the documentation. - - # Conflicts: - # doc/tinc.conf.5.in - # doc/tinc.texi - # src/avl_tree.c - # src/avl_tree.h - -commit 5cbc12b3d482231fc7e71fbe176c91971993760e -Author: Guus Sliepen -Date: Sun Apr 10 14:47:21 2016 +0200 - - Explicitly mention that LibreSSL can be used as well. - - # Conflicts: - # doc/tinc.texi - # m4/openssl.m4 - -commit d7f6737cfcae75e8c2f522c68aaedee0519a6131 -Author: Guus Sliepen -Date: Mon Apr 11 14:49:51 2016 +0200 - - Update support for BSD tun/tap devices, add support for OS X utun interfaces. - -commit 2a7871990bc401921b8bb9accbc6a8206d564f72 -Author: Guus Sliepen -Date: Sun Nov 1 21:07:56 2015 +0100 - - Update "now" after connect() when making outgoing connections. - - It could be that address resolution takes a long time, don't let that - count against a connection. This is especially important when using a - nameserver from the VPN. - - # Conflicts: - # src/net_socket.c - -commit cadbf587a09bd4adde664cd635b962315228b3f5 -Author: Guus Sliepen -Date: Sun May 3 20:06:12 2015 +0200 - - Never call putenv() with data on the stack. - - Even though we are using putenv() here to remove items from the - environment, there is no guarantee that putenv() doesn't add the - argument to the environment anyway. In that case, we have to make sure - that it doesn't go away. We also don't want a memory leak, so keep a - list of things we unputenv()ed around, so we can reuse things. - - Thanks to Poul-Henning Kamp for pointing out this problem. - - # Conflicts: - # src/process.c - -commit 0e8e53b4cee8f1ea27bad501cbc18292ced54fa1 -Author: Guus Sliepen -Date: Tue Apr 14 11:20:24 2015 +0200 - - Fix --logfile without a filename on Windows. - - On Windows, the log filename now defaults to "tinc.log" in the same - directory as tinc.conf. - - # Conflicts: - # src/tincd.c - -commit c544e5e8fe22250b230a46f0340483db5403a6c1 -Author: Guus Sliepen -Date: Sun Apr 10 17:22:41 2016 +0200 - - Support ToS/DiffServ for IPv6 meta and UDP connections. - - Also remember ToS/DiffServ priority for each socket individually. This - is a port of commits c72e237 and 042a6c1. - -commit e355088535ee9ebb12a4db0043bf6a9743085b28 -Author: Guus Sliepen -Date: Fri Apr 8 18:09:30 2016 +0200 - - Use iface instead of interface. - - This was accidentally added in commit 2f03a5d. - -commit 6f97c0011572a1e12fa6267068b7f3fd46ceffd8 -Author: Guus Sliepen -Date: Sun Apr 10 17:01:04 2016 +0200 - - Update THANKS. - -commit 8be447ac0227a8ecb89facb2831c121a7ca81748 -Author: Guus Sliepen -Date: Sun Apr 10 16:51:03 2016 +0200 - - Update .gitignore. - -commit 9f0fb224a6c2eab93b6917ef6c034423c49126cd -Author: Guus Sliepen -Date: Fri Apr 8 17:49:49 2016 +0200 - - Don't compile getopt*.c if the system provides getopt_long(). - - # Conflicts: - # configure.ac - # src/Makefile.am - # src/tincd.c - -commit c2726dae62d632883f822741f9619265640e57b3 -Author: Guus Sliepen -Date: Sun Apr 10 16:38:45 2016 +0200 - - Fix typo. - - Found by LunarShaddow. - -commit e44c337eae674120745f7c7c56a1a70919ff40ca -Author: LunarShaddow -Date: Mon Mar 7 15:43:04 2016 +0800 - - re-arrange include sequence to avoid a mingw introduced bug. - refers: https://www.cygwin.com/ml/cygwin/2012-12/msg00194.html - - # Conflicts: - # src/cygwin/device.c - -commit af83d0b9e87fe795a3d01d0ee3fb35e0d8579b88 -Author: LunarShaddow -Date: Mon Mar 7 15:42:34 2016 +0800 - - fix typo - -commit bf50b3502a022b406424d0d03aaf7670133452b2 -Author: Guus Sliepen -Date: Sun Feb 28 16:38:49 2016 +0100 - - Fix for botched cherry-pick commit 60fb230. - -commit 1ceea259c3ba5efb9b8b12161e75256270ba4804 -Author: Guus Sliepen -Date: Sat Feb 27 14:46:01 2016 +0100 - - Add warnings for bad combinations of Device and Interface. - - On Linux, the name of the tun/tap interface can be set freely. However, - on most other operating systems, tinc cannot change the name of the - interface. In those situations, it is possible to specify a Device and - an Interface that conflict with each other. On BSD, this can cause - $INTERFACE to be set incorrectly, on Windows, this results in a - potentially unreliable way in which a TAP-Win32 interface is selected. - - # Conflicts: - # src/bsd/device.c - -commit e3f80e9167ecef8db8add9359b6660ecdcaeb7af -Author: Guus Sliepen -Date: Sat Feb 27 14:22:36 2016 +0100 - - Small fixes for the documentation. - - # Conflicts: - # doc/tinc.texi - -commit 72cfd4f047210cc7cab9014cbf48e007bfd704e6 -Author: Guus Sliepen -Date: Sat Feb 27 14:21:53 2016 +0100 - - Clarify that scripts are called synchronously. - - # Conflicts: - # doc/tinc.conf.5.in - # doc/tinc.texi - -commit 4d7469e0da6652bddc8acde499068db4b41b646d -Author: Guus Sliepen -Date: Sun Feb 28 16:28:28 2016 +0100 - - Fix forwarding of edge updates. - - Commit e4670fc accidentily prevented ADD_EDGE messages from propagating - in some cases. - -commit 60fb2308e5bf1fd9ce642f6c4bcde81997593504 -Author: Guus Sliepen -Date: Sat Feb 27 14:18:20 2016 +0100 - - Improve performance of edge updates. - -commit 994adadf2752fd7515ee30ed5fdb91178a615fe9 -Author: Vittorio Gambaletta (VittGam) -Date: Fri Sep 25 16:51:51 2015 +0200 - - Remove forward declaration for do_decrement_ttl. - - Signed-off-by: Vittorio Gambaletta - - # Conflicts: - # src/route.c - -commit 0f3ae1a9f29c845a69e44a4f691f43d6a6651583 -Author: Vittorio Gambaletta (VittGam) -Date: Fri Sep 25 15:35:28 2015 +0200 - - s/broadcast_packet_helper/route_broadcast/ - - Signed-off-by: Vittorio Gambaletta - - # Conflicts: - # src/route.c - -commit 496f775568873bb769e48ceb644b15ab9f150d62 -Author: Vittorio Gambaletta (VittGam) -Date: Fri Sep 25 04:52:25 2015 +0200 - - Fix DecrementTTL option for packets destined to the local node. - - Signed-off-by: Vittorio Gambaletta - - # Conflicts: - # src/route.c - -commit 17e54ea0bec4d3a3b9a760854dde6039c7a1c421 -Author: Vittorio Gambaletta (VittGam) -Date: Fri Sep 4 17:04:03 2015 +0200 - - Try to reply with node address only when decrementing the TTL. - - Signed-off-by: Vittorio Gambaletta - -commit 92203bdbcb1af4a52c7ca9d0e1a271168435c905 -Author: Vittorio Gambaletta (VittGam) -Date: Fri Sep 4 04:00:57 2015 +0200 - - Fix source IP address for ICMP unreachable packets generated by tinc. - - Try to send ICMP unreachable replies from an address assigned to the - local machine, instead of the destination address of the original - packet. - - The address is found by looking up the route towards the sender of - the packet that generated the error; in usual configurations, this - is the tinc interface. - - This also fixes the traceroute display in mtr when using the - DecrementTTL option. - - Signed-off-by: Vittorio Gambaletta - - # Conflicts: - # src/route.c - -commit a8a3a2c8ceb19bcb6c2c3ef0647c94d7d0624b7a -Author: Vittorio Gambaletta (VittGam) -Date: Thu Sep 3 16:02:50 2015 +0200 - - Fix DecrementTTL option. - - The option was not actually working, as it could be seen on traceroute or mtr. - - The problem is that it was checking if the TTL was < 1 (so equal to 0) before decrementing it. - - This meant that a packet with a TTL of 1 was being sent with a TTL of 0 on the VPN, instead of being discarded with the ICMP error message. - - Signed-off-by: Vittorio Gambaletta - - # Conflicts: - # src/route.c - -commit ac9e32ff91ee2318c49808522f0c7d458c79eb44 -Author: Guus Sliepen -Date: Sun Feb 28 15:48:19 2016 +0100 - - Use nostdinc instead of overriding DEFAULT_INCLUDES. - -commit 96dd6e5f6c6f3f7717102fb3b38759b6cc0c0555 -Author: Guus Sliepen -Date: Sun Jul 5 16:03:03 2015 +0200 - - Only check for -fno-strict-overflow if -fwrapv does not work. - -commit 92f0c4db77a5e2733442491227625d0233f94a97 -Author: Guus Sliepen -Date: Sun Feb 28 15:39:41 2016 +0100 - - Update .gitignore. - -commit d8ca00fe40ff4b6d87e7e64c273f536fab462356 -Author: Guus Sliepen -Date: Wed Jan 27 00:09:29 2016 +0100 - - Add the ability to sign and verify files. - -commit 7418e9077f84db10ef6bb082a375870a7130bd7d -Merge: 420989e4 b6ed5c13 -Author: Guus Sliepen -Date: Sun Jan 17 23:29:23 2016 +0100 - - Merge remote-tracking branch 'mweinelt/tinc-gui' into 1.1 - -commit 420989e4c3ff109c7d077b2f8c06506540f1c0bd -Author: Guus Sliepen -Date: Thu Jan 14 15:07:22 2016 +0100 - - Only add a reflexive address when we're sure it's working. - -commit cda5a477c8138226d184a176256d559971b4f7ed -Author: Guus Sliepen -Date: Thu Dec 10 16:45:05 2015 +0100 - - Use static buffers for recvmmsg(), initialize them only as needed. - - As suggested by Michael Tokarev. - -commit e4fd81ed2d66b8fe3c2857244fe3da85c803cf60 -Author: Guus Sliepen -Date: Thu Dec 10 16:30:32 2015 +0100 - - Add support for recvmmsg(). - - Based on a patch from Samuel Thibault and input from Michael Tokarev. - -commit cef40b8b978694fc0e7c02e292fcbb60806bf028 -Author: Guus Sliepen -Date: Thu Nov 26 11:29:54 2015 +0100 - - list_delete() already free()s the deleted element. - -commit 9fdf4278f8c8c1563d45205c9e9f1bc351bd814f -Author: Guus Sliepen -Date: Tue Nov 24 16:48:44 2015 +0100 - - Don't leave dead outgoing_t's in the outgoing_list. - - If an outgoing connection cannot be made because no address is known for - it, it should be removed from the outgoing_list, otherwise it will - prevent it from being re-added later when we do know addresses for it. - -commit c58eba587da3ac884c6c18b64c262aed8fd1c452 -Author: Etienne Dechamps -Date: Sun Nov 22 18:57:59 2015 +0000 - - Add upnp.h to tincd SOURCES. - - This was missing from 513bffe1fee07bcbcb50691e221874adc1507857. - -commit 613d586afd22159cee57c9524218c7200f4f1096 -Author: Etienne Dechamps -Date: Sun Nov 22 17:14:14 2015 +0000 - - Don't unset validkey when receiving SPTPS handshakes over ANS_KEY. - - This fixes a hairy race condition that was introduced in - 1e89a63f1638e43dee79afbb18d5f733b27d830b, which changed - the underlying transport of handshake packets from REQ_KEY to ANS_KEY. - Unfortunately, what I missed in that commit is, on the receiving side, - there is a slight difference between req_key_h() and ans_key_h(): - indeed, the latter resets validkey to false. - - The reason why this is not a problem during typical operation is - because the normal SPTPS key regeneration procedure looks like this: - - KEX -> - <- KEX - SIG -> - <- SIG - - All these messages are sent over ANS_KEY, therefore the receiving side - will unset validkey. However, that's typically not a problem in practice - because upon reception of the last message (SIG), SPTPS will call - sptps_receive_record(), which will set validkey to true again, and - everything works out fine in the end. - - However, that was the *typical* scenario. Now let's assume that the - SPTPS channel is in active use at the same time key regeneration - happens. Specifically, let's assume a normal VPN data packet sneaks in - during the key regeneration procedure: - - KEX -> - <- KEX - <- (SPTPS packet, over TCP or UDP) - <- KEX (wtf?) - SIG -> (refused with Invalid packet seqno: XXX != 0) - - At this point, both nodes are extremely confused and the SPTPS channel - becomes unusable with various errors being thrown on both sides. The - channel will stay down until automatic SPTPS channel restart kicks in - after 10 seconds. - - (Note: the above is just an example - the race can occur on either side - whenever a packet is sent during the period of time between KEX and SIG - messages are received by the node sending the packet.) - - I've seen this race occur in the wild - it is very likely to occur if - key regeneration occurs on a heavily loaded channel. It can be - reproduced fairly easily by setting KeyExpire to a short value (a few - seconds) and then running something like ping -f foobar -i 0.01. - - The reason why this occurs is because tinc's TX code path triggers the - following: - - - send_packet() - - try_tx() - - try_tx_sptps() - - validkey is false because we just received an ANS_KEY message - - waitingforkey is false because it's not used for key regeneration - - send_req_key() - - SPTPS channel restart (sptps_stop(), sptps_start()). - - Obviously, it all goes downhill from there and the two nodes get very - confused quickly (for example the seqno gets reset, hence the error - messages). - - This commit fixes the issue by keeping validkey set when SPTPS data is - received over ANS_KEY messages. - -commit 95935cecb6290fd13b1266a96be1b8f9c1c54d0f -Author: Guus Sliepen -Date: Sat Nov 21 19:41:14 2015 +0100 - - Update THANKS file. - -commit 0f6d34dc1b43edc6f5bea45c17ce2d6a417265f1 -Author: Etienne Dechamps -Date: Sun Nov 15 17:42:14 2015 +0000 - - Try to ensure we build correctly against various libminiupnpc versions. - - Unfortunately, libminiupnpc has a somewhat... "peculiar" approach to - backwards compatibility for their API, where they reserve the right to - make breaking changes when they feel like it, forcing users to resort - to #ifdefs to ensure they use the correct API. Sigh. - - Previously, tinc would only build against API versions <= 13, because I - was doing my initial development using miniupnpc-1.9.20140610 which is - the version that ships with Debian. The changes in this commit are - required for tinc to build against more recent versions, from - 1.9.20150730 to the latest one at the time of this commit, 1.9.20151026. - -commit 675e3b497bdc87f5a4dfdef7508cd2070850e69e -Author: Etienne Dechamps -Date: Sun Nov 15 15:30:01 2015 +0000 - - Allow tinc to be built with miniupnpc on Windows. - - Contrary to what I expected, it so happens that modern versions of MinGW - include an implementation of pthread natively by default, so there is no - need to introduce Win32-specific threading code. This means the only - changes required to make UPnP work on Windows are just build parameter - tuning. - - This commit forces MinGW to be built statically. This makes linking - against miniupnpc simpler (otherwise we would have to handle the mess - of dllimport & co.) and it also prevents libwinpthread from being linked - dynamically (which it is by default), as this would require additional - DLLs to be distributed. Since static linking is how tinc is - traditionally built on Windows, I don't expect this to be a big deal. - -commit 513bffe1fee07bcbcb50691e221874adc1507857 -Author: Etienne Dechamps -Date: Sun Nov 15 13:40:07 2015 +0000 - - Add UPnP support to tincd. - - This commit makes tincd capable of discovering UPnP-IGD devices on the - local network, and add mappings (port redirects) for its TCP and/or UDP - port. - - The goal is to improve reliability and performance of tinc with nodes - sitting behind home routers that support UPnP, by making it less reliant - on UDP Hole Punching, which is prone to failure when "hostile" NATs are - involved. - - The way this is implemented is by leveraging the libminiupnpc library, - which we have just added a new dependency on. We use pthread to run the - UPnP client code in a dedicated thread; we can't use the tinc event loop - because libminiupnpc doesn't have a non-blocking API. - -commit 2bb567c6a31e333ebdd16d6d076ba9976e6ed4fb -Author: Etienne Dechamps -Date: Sat Nov 14 14:47:42 2015 +0000 - - Add a new optional dependency on the miniupnpc library. - - The miniupnpc library is a lightweight UPnP-IGD client. - - http://miniupnp.free.fr/ - - Contrary to other libraries, this dependency is disabled by default. - This is because the library is somewhat obscure and is only tangentially - useful, so enabling it by default would probably annoy most users. - -commit bdd84660c756437cf3bc8f64adf612055acc84ea -Author: Etienne Dechamps -Date: Sat Nov 7 11:04:13 2015 +0000 - - Make sure the packet source MAC address is always set. - - When tinc is used in router mode with a TAP device, Ethernet (MAC) - headers are not present in packets flowing over the VPN; it is the - node's responsibility to fill out this header before handing the - packet over to the TAP interface (which expects such headers). - - Currently, tinc fills out the destination MAC address of the packet - (otherwise the host would not recognize the packets, and nothing would - work), but it does not fill out the source MAC address. In practice this - doesn't seem to cause any real issues (the host doesn't care about the - source address), but it does look weird when looking at the packets with - a sniffer, and it also result in the following valgrind warning: - - ==13651== Syscall param write(buf) points to uninitialised byte(s) - ==13651== at 0x5C4B620: __write_nocancel (syscall-template.S:81) - ==13651== by 0x1445AA: write_packet (device.c:183) - ==13651== by 0x118C7C: send_packet (net_packet.c:1259) - ==13651== by 0x12B70A: route_ipv4 (route.c:443) - ==13651== by 0x12D5F8: route (route.c:971) - ==13651== by 0x1152BC: receive_packet (net_packet.c:250) - ==13651== by 0x117E1B: receive_sptps_record (net_packet.c:904) - ==13651== by 0x1309A8: sptps_receive_data_datagram (sptps.c:488) - ==13651== by 0x130A90: sptps_receive_data (sptps.c:508) - ==13651== by 0x115569: receive_udppacket (net_packet.c:286) - ==13651== by 0x119856: handle_incoming_vpn_data (net_packet.c:1499) - ==13651== by 0x10F3DA: event_loop (event.c:287) - ==13651== Address 0xffeffea3a is on thread 1's stack - ==13651== in frame #6, created by receive_sptps_record (net_packet.c:821) - ==13651== - - This commit fixes the issue by filling out the source MAC address. It is - generated by negating the last byte of the device MAC address, which is - consistent with what route_arp() does. - - In addition, this commit stops route_arp() from filling out the Ethernet - header of the packet - this is the responsibility of send_packet(), not - route(). - -commit 684bd659ae0c6ca623422851c245188037658698 -Author: Etienne Dechamps -Date: Wed Nov 4 19:18:12 2015 +0000 - - Revert "Cache node IDs in a hash table for faster lookups." - - This reverts commit c2319e90b16962fe899bc60abc8af0e2542bb176. - - As a general principle, I do not believe it is worthwhile to cache - nodes. Sure, it brings lookup time down from O(log n) to O(1), but - considering that the scalability target of tinc is around 1000 nodes - and log2(1000) is 10, that looks like premature optimization; tree - lookups should already be very fast. Therefore, I believe it makes sense - to remove the cache as a code cleanup initiative. - -commit eeebff55c07c09c5bc5e62a7b2a21f68ecd1c802 -Author: Etienne Dechamps -Date: Wed Nov 4 19:07:14 2015 +0000 - - Use a splay tree for node UDP addresses in order to avoid collisions. - - This commit replaces the node UDP address hash table "cache" with a - full-blown splay tree, aligning it with node_tree (name-indexed) and - node_id_tree (ID-indexed). - - I'm doing this for two reasons. The first reason is to make sure we - don't suddenly degrade to O(n) performance when two "hot" nodes end up - in the same hash table bucket (collision). - - The second, and most important, reason, has to do with the fact that - the hash table that was being used overrides elements that collide. - Indeed, it turns out that there is one scenario in which the contents of - node_udp_cache has *correctness* implications, not just performance - implications. This has to do with the way handle_incoming_vpn_data() is - implemented. - - Assume the following topology: - - A <-> B <-> C - - Now let's consider the perspective of tincd running on B, and let's - assume the following is true: - - - All nodes are using the 1.1 protocol with node IDs and relaying - support. - - Nodes A and C have UDP addresses that hash to the same value. - - Node C "wins" in the node_udp_cache (i.e. it overwrites A in the - cache). - - Node A has a "dynamic" UDP address (i.e. an UDP address that has been - detected dynamically and cannot be deduced from edge addresses). - - Then, before this commit, A would be unable to relay packets through B. - - This is because handle_incoming_vpn_data() will fall back to - try_harder(), which won't be able to match any edge addresses, doesn't - check the dynamic UDP addresses, and won't be able to match any keys - because this is a relayed packet which is encrypted with C's key, not - B's. As a result, tinc will fail to match the source of the packet and - will drop the packet with a "Received UDP packet from unknown source" - message. - - I have seen this happen in the wild; it is actually quite likely to - occur when there are more than a handful of nodes because node_udp_cache - only has 256 buckets, making collisions quite likely. This problem is - quite severe because it can completely prevent all packet communication - between nodes - indeed, if node A tries to initiate some communication - with C, it will use relaying at first, until C responds and helps A - establish direct communication with it (e.g. hole punching). If relaying - is broken, C will not help establish direct communication, and as a - result no packets can make it through at all. - - The bug can be reproduced fairly easily by reproducing the topology - above while changing the (hardcoded) node_udp_cache size to 1 to force a - collision. One will quickly observe various issues when trying to make A - talk to C. Setting IndirectData on B will make the issue even more - severe and prevent all communication. - - Arguably, another way to fix this problem is to make try_harder() - compare the packet's source address to each node's dynamic UDP - addresses. However, I do not like this solution because if two "hot" - nodes are contending on the same hash bucket, try_harder() will be - called very often and packet routing performance will degrade closer to - O(N) (where N is the total number of nodes in the graph). Using a more - appropriate data structure fixes the bug without introducing this - performance problem. - -commit 7a8515112a4bf94da3cec157ada6e0794a03b946 -Author: Guus Sliepen -Date: Mon Oct 26 13:46:30 2015 +0100 - - Avoid undefined behavior. - - Left shifts of negative values is undefined in C. This happens a lot in - the Ed25519 code. Cast to unsigned first, then cast the result back to - signed where necessary. - -commit b6ed5c134fc43d438c622d24f949c240632f5e67 -Author: Martin Weinelt -Date: Mon Sep 28 06:34:15 2015 +0200 - - tinc-gui: Properly initialize class attributes for VPN in __init__ - -commit 927efeff6242e262b176976a1eb298891578f77d -Author: Martin Weinelt -Date: Mon Sep 28 05:54:17 2015 +0200 - - tinc-gui: Use ArgumentParser, default to python2 - -commit e92bb7d1dd7adc02503e3ee795e53b15634df570 -Author: Martin Weinelt -Date: Mon Sep 28 05:34:22 2015 +0200 - - tinc-gui: Fix GetListCtrl method name in SuperListCtrl - - wxPython wrongly expects camelcase method names, this however - is against PEP8 - -commit 53333d6d0d870de6801352bda106286255f14319 -Author: Martin Weinelt -Date: Mon Sep 28 05:31:59 2015 +0200 - - tinc-gui: Update Node object to correctly parse responses - - The application was expecting a different respoonse from tinc - and wouldn't properly it, and thus not start at all. - -commit 0c7e0210d900185d4c1a9ffd969dc2a26d9523a9 -Author: Martin Weinelt -Date: Mon Sep 28 05:20:03 2015 +0200 - - tinc-gui: Reformat codebase according to PEP8 - -commit 73068238436d8a22abb86e67b08f573b09fd04e1 -Author: Guus Sliepen -Date: Fri Sep 25 10:06:18 2015 +0200 - - Fix a few memory leaks in the CLI found by AddressSanitizer. - -commit 543c0abbd91a7b076670b8763548b8d5849860a0 -Author: Guus Sliepen -Date: Fri Sep 25 10:05:24 2015 +0200 - - Fix struct node_status_t. - - Although not a problem for tinc internally, the size of the struct was 12 - bytes instead of 4, causing some problems when interpreting the value - received from tincd by the CLI. - -commit 706d855e507980de3845556989d7de7a3b9c76e8 -Author: Guus Sliepen -Date: Thu Sep 24 22:20:00 2015 +0200 - - Replace bare if statements with AS_IF in configure.ac. - -commit f54a87b800d551bec4532a5d3bf124d02e167856 -Author: Guus Sliepen -Date: Thu Sep 24 21:53:49 2015 +0200 - - Optionally install systemd service files. - - If --with-systemd is given when running the configure script, two - systemd service files will be installed. There is a template - tinc@.service, which can be used to control individual instances of - tinc. For example: - - systemctl enable tinc@foo - - Will create an instance for tinc with netname foo. There is also a - tinc.service, which can be used to start and stop all instances at once. - -commit 5ad43673acf03f86643f1463f1ebfa6e9ca189cc -Author: Guus Sliepen -Date: Thu Sep 24 17:10:25 2015 +0200 - - Add -I m4 back to ACLOCAL_AMFLAGS. - - In commit b7b5d51, AC_CONFIG_MACRO_DIRS([m4]) was added to configure.ac, - which is the current proper way of including the m4 directory. However, - old versions of autoconf ignore it and need the -I m4 statement in - Makefile.am. Both the old and new way of indicating that the m4/ - directory should be included can coexist. - -commit ae89a25695411149a7499189c9771762ad1f1726 -Author: Nathan Stratton Treadway -Date: Sat Sep 12 16:33:52 2015 +0200 - - Fix invalid checksum generation. - - Use equation 3 given in RFC 1624 and the UpdateTTL() example function given - RFC 1141. - - # Conflicts: - # src/route.c - -commit 56a8b90d863171d62e0a337b5635fbfc53a67fb0 -Author: Guus Sliepen -Date: Wed Jul 22 14:33:56 2015 +0200 - - In sssp_bfs(), never try to update myself. - -commit f75e6f61f280b138082b87ce69bdbdee3e4ba56e -Author: thorkill -Date: Sun Jul 19 18:53:29 2015 +0200 - - Do not access e->to->prevedge if not defined - - In some cases - mostly when e->to == myself the prevedge is set to NULL, - causing invalid memory access. In rare cases this may lead to malformed mst - or segfaults. - -commit f92c3446f2052a59d1e6a28f1bc7cec278cb1e48 -Author: Guus Sliepen -Date: Wed Jul 15 15:12:53 2015 +0200 - - Use AC_CONFIG_MACRO_DIR() instead of _DIRS(). - - The former is guaranteed to work with autoconf 2.58 and later, and we - don't have multiple m4 directories anyway. - -commit 9ca1750245b28ed8306f150b6371139c656be111 -Author: Guus Sliepen -Date: Sun Jul 12 16:31:32 2015 +0200 - - Fix the PRF function when compiling without OpenSSL. - -commit 3c54765bcdf8bd6114da0cb31f45404950089e3a -Author: thorkill -Date: Tue Jul 7 23:14:08 2015 +0200 - - Prevent tinc from forgeting e->local_address - - If ADD_EDGE came from tinc version 1.0.x local_address.sa.sa_family is set to 0. - If it came from tinc version 1.1.x forwarded for older verion it will be 255 - AF_UNKNOWN. - -commit 1e7ef381980a5c4c84d699522265290dde5ac728 -Author: thorkill -Date: Tue Jul 7 21:19:26 2015 +0200 - - Make sure we do not allocate new edge when talking to old nodes and the same edge already exists - - When tinc gets ADD_EDGE from older versions it will allocate - new edge in protocol_edge.c:189 due to missed case in lines 149-171 where - local_address is not defined. - -commit 7b831804aafa370a6c8d9e86caee31cda1a3dd72 -Author: Guus Sliepen -Date: Sun Jul 12 13:08:34 2015 +0200 - - Make subnet caches static. - -commit 322ffadac43c7e357cc12340d7b8112a0aaad5af -Author: thorkill -Date: Tue Jun 30 19:11:45 2015 +0200 - - Included missing names.h - -commit b7b5d516137713c594990cd982a29f7e5718b45b -Author: Guus Sliepen -Date: Sun Jul 12 13:05:51 2015 +0200 - - Use AC_CONFIG_MACRO_DIRS([m4]). - -commit 97457716d7efc541d18d08263bbd338e94195bd9 -Author: Guus Sliepen -Date: Sun Jul 12 12:55:13 2015 +0200 - - Remove unused code that caused warnings about an uninitialized variable. - -commit b22b9d438970a0442559949da35be9cc0ffaec00 -Author: thorkill -Date: Mon Jun 29 00:23:13 2015 +0200 - - Removed double break; - -commit b396585383fe12c890ef7953efaa13a83963b5d7 -Author: Guus Sliepen -Date: Sun Jul 12 12:33:07 2015 +0200 - - Fix undefined behaviour when left-shifting signed integers. - - Found by -fsanitize=undefined. - -commit de7d9ee437bc0e5d72f8c6744e1df7ea7b64d2e9 -Author: Guus Sliepen -Date: Sat Jul 4 17:53:11 2015 +0200 - - Call sockaddrfree(&e->local_address) in free_edge() instead of exit_edges(). - - The proper place to clean up resources of objects is in their - destructor. This makes sure proper cleanup when edge_del() is called as - well. At exit, free_edge() is called on all edges by free_edge_tree(), - which is called by exit_nodes(). - -commit 36cec9af88909cb2cf012d609e5c4d8c444ddab9 -Author: Guus Sliepen -Date: Sat Jul 4 17:51:05 2015 +0200 - - Coalesce two if statements that check for the same thing. - -commit 14ccf509540e338502ad806f60bdc3f71ddce66f -Author: Jo-Philipp Wich -Date: Thu Jun 18 23:58:31 2015 +0200 - - fix musl compatibility - - Let configure include sys/if_tun.h when testing for netinet/if_ether.h - to detect the Kernel/libc header conflict on musl. - - After this patch, configure will correctly detect netinet/if_ether.h as - unusable and the subsequent compilation will not attempt to use it. - - Conflicts: - src/have.h - -commit 37588b8d5cface1bc72424a198b1cc1a6044adb0 -Author: Guus Sliepen -Date: Sat Jul 4 17:18:40 2015 +0200 - - Don't #include OpenSSL headers when compiling without OpenSSL. - -commit abb24e9d71b3edb9cacf4c04361cc0dfd4e6a061 -Author: thorkill -Date: Sat Jul 4 03:21:01 2015 +0200 - - Cleanup local_address in protocol_edge.c - - In line 131 local_address has been defined, - but the memory was never freed on return. - -commit 92df36a610421ed5fcae90e832f64e3acfb7d431 -Author: thorkill -Date: Sat Jul 4 02:39:12 2015 +0200 - - Cleanup edges stored in edge_weight_tree on exit - - protocol_edge.c: 131 defines local_address using str2sockaddr - - str2sockaddr() allocates memory which has to be freed on exit. - -commit 1140ca6d3004b228947bad8736f0b49d6b169267 -Author: thorkill -Date: Sat Jul 4 00:29:36 2015 +0200 - - Fixed 2 leaks in setup_myself() - -commit 0267aef826ba627aba3a525b36c0e7bfc0f9a221 -Author: Florian Klink -Date: Thu Jul 2 12:35:42 2015 +0200 - - setup_outgoing_connection: log to LOG_DEBUG on if no known address - - With AutoConnect = yes, tinc tries to establish connections to known hosts. - However, you could have set no Address for this host, which is perfectly fine - (as long as there is at least one bootstrap node with an address or a local - discovered node already part of the network) - - So log this to LOG_DEBUG - -commit 91355b9ac5a80d6d7da6951a72ea0c22651bdfa8 -Author: Florian Klink -Date: Thu Jul 2 12:35:41 2015 +0200 - - (read|append)_config_file: log open errors as LOG_DEBUG - - In a "decentrally managed vpn" it is very likely that host config - files for some reachable nodes do not exist. Currently, tinc - fills the logs with "Cannot open config file" messages. - - This commit changes the log level to LOG_DEBUG so - syslog doesn't get filled by default. - -commit ebffa40aa7832459f63801e3a91cc741e6b339a8 -Author: Etienne Dechamps -Date: Sat Jun 20 11:41:20 2015 +0100 - - Protect against callbacks removing items from the io tree. - - The definition of the splay_each() macro is somewhat complicated for - syntactic reasons. Here's what it does in a more readable way: - - for (splay_node_t* node = tree->head; node;) { - type* item = node->data; - splay_node_t* next = node->next; - - // RUN USER BLOCK with (item) - - node = next; - } - - list_each() works in the same way. Since node->next is saved before the - user block runs, this construct supports removing the current item from - within the user block. However, what it does *not* support is removing - *other items* from within the user block, especially the next item. - Indeed, that will invalide the next pointer in the above loop and - therefore result in an invalid pointer dereference. - - Unfortunately, there is at least one code path where that unsupported - operation happens. It is located in ack_h(), where the authentication - protocol code detects a double connection (i.e. being connected to - another node twice). Running in the context of a socket read event, this - code will happily terminate the *other* metaconnection, resulting in its - socket being removed from the io tree. If, by misfortune, this other - metaconnection happened to have the next socket FD number (which is - quite possible due to FD reuse - albeit unlikely), and was part of the - io tree (which is quite likely because if that connection is stuck, it - will most likely have pending writes) then this will result in the next - pending io item being destroyed. Invalid pointer dereference ensues. - - I did a quick audit of other uses of splay_each() and list_each() and - I believe this is the only scenario in which this "next pointer - invalidation" problem can occur in practice. While this bug has been - there since at least 6bc5d626a8726fc23365ee705761a3c666a08ad4 (November - 2012), if not sooner, it happens quite rarely due to the very specific - set of conditions required to trigger it. Nevertheless, it does manage - to crash my central production nodes every other week or so. - -commit 7f020cf456b327313f0cfa8d103fb14f06f71994 -Author: Dato Simó -Date: Tue Jun 16 20:44:45 2015 -0300 - - Fix typo in tinc.texi. - -commit 45a46f068cf8fbe6cc8c59673de2d8580d18f87f -Author: Guus Sliepen -Date: Wed Jun 10 23:42:17 2015 +0200 - - Fix crash is sptps_logger(). - - Unfortunately, sptps_logger() cannot know if s->handle is pointing to a - connection_t or a node_t. But it needs to print name and hostname in - both cases. So make sure both types have name and hostname fields at the - start with the same offset. - -commit bfe231b977284ba78a582db96a05b5854ddf0d91 -Author: Guus Sliepen -Date: Sun Jun 7 23:20:14 2015 +0200 - - Fix alignment of output of sptps_speed. - -commit a797b4a19235be740c51bcb3bb6ec5de01915f46 -Author: Guus Sliepen -Date: Sun Jun 7 23:14:48 2015 +0200 - - Fix receiving SPTPS data in sptps_speed and sptps_test. - - The sptps_receive_data() was changed in commit d237efd to only process - one SPTPS record from a stream input. So now we have to put a loop - around it to ensure we process everything. - -commit d8d1ab4ee1e92ec84fe9ea86eec2396275483a92 -Author: Guus Sliepen -Date: Sun Jun 7 22:50:05 2015 +0200 - - Fix warnings about missing return value checks. - - In some harmless places, checks for the return value of ECDSA and RSA - key generation and verification was omitted. Add them to keep the - compiler happy and to warn end users in case something is wrong. - -commit ab0576a2034b03f92943ac477e4e97731a899554 -Author: Guus Sliepen -Date: Sun Jun 7 22:25:22 2015 +0200 - - Fix autoconf check for function attributes. - - GCC warns when a function attribute has no effect. The autoconf check - turns warnings about attributes into errors, therefore thinking that - they did not work. The reason was that the test function returned void, - which is not suitable for checking both __malloc__ and - __warn_unused_result__. - -commit 84ecc972e5c11f683ac618c5a734a17c295d9b46 -Author: Guus Sliepen -Date: Sun May 31 23:51:39 2015 +0200 - - Fix missing return value caused by the previous commit. - -commit eca357ed916c9782a64a68a2f30b144d84027795 -Author: Etienne Dechamps -Date: Sun May 31 20:19:48 2015 +0100 - - Don't try to relay packets to unreachable nodes. - - It is not unusual for tinc to receive SPTPS packets to be relayed to - nodes that just became unreachable, due to state propagation delays in - the metagraph. - - Unfortunately, the current code doesn't handle that situation correctly, - and still tries to relay the packet to the unreachable node. This - typically ends up segfaulting. - - This commit fixes the issue by checking for reachability before relaying - the packet. - -commit 9e3adef5cb31cb73fbbbd25d3fce115aac107714 -Author: Etienne Dechamps -Date: Sun May 24 09:49:16 2015 +0100 - - Fix invalid pointer use in get_my_hostname(). - - clang-3.7 warnings surfaced an actual bug: - - invitation.c:185:5: error: address of array 'filename' will always evaluate to 'true' - [-Werror,-Wpointer-bool-conversion] - if(filename) { - ~~ ^~~~~~~~ - - The regression was introduced in 3ccdf50beb6b2d3f2730bdc66006b43190537cde. - -commit 7fcfbe2bd2d14d13e06e3e2addfe0ea12b67873f -Author: Etienne Dechamps -Date: Sun May 24 09:45:09 2015 +0100 - - Fix wrong format string type in send_sptps_tcppacket(). - - This issue was found through a clang-3.7 warning: - - protocol_misc.c:167:46: error: format specifies type 'short' but the argument has type 'int' - [-Werror,-Wformat] - if(!send_request(c, "%d %hd", SPTPS_PACKET, len)) - ~~~ ^~~ - %d - -commit 3e61c7233b087b8400c29ca7a8d079aad8b706d8 -Author: Etienne Dechamps -Date: Sat May 23 17:24:05 2015 +0100 - - Don't set up an ongoing connection to myself. - - It is entirely possible that the configuration file could contain a - ConnectTo statement refering to its own name; that's a reasonable - scenario when one deploys semi-automatically generated tinc.conf files. - - Amusingly, tinc does not like that at all, and actually sets up an - outgoing_t structure to myself (which obviously makes no sense). This is - mostly benign, though it does result in non-sensical "Already connected - to myself" messages every retry interval. - - However, that also makes things blow up in close_network_connections(), - because there we delete the entire outgoing list and *then* the myself - node, which still has a reference to the freshly deleted outgoing - structure. Boom. - -commit 8587e8c0d9ac997fcd2040470c1ccf5930bc18c3 -Author: Etienne Dechamps -Date: Sat May 23 10:24:00 2015 +0100 - - Fix crashes when trying unreachable nodes. - - timeout_handler() calls try_tx(c->node) when c->edge exists. - Unfortunately, the existence of c->edge is not enough to conclude that - the node is reachable. - - In fact, during connection establishment, there is a short period of - time where we create an edge for the node at the other end of the - metaconnection, but we don't have one from the other side yet. - Unfortunately, if timeout_handler() runs during that short time - window, it will call try_tx() on an unreachable node, which makes - things explode because that function is not prepared to handle that - case. - - A typical symptom of this race condition is a hard SEGFAULT while trying - to send packets using metaconnections that don't exist, due to - n->nexthop containing garbage. - - This patch fixes the issue by making try_tx() check for reachability, - and then making all code paths use try_tx() instead of the more - specialized methods so that they go through the check. - - This regression was introduced in - eb7a0db18ea71a44999d6a37b4b179dac0ed9bc7. - -commit 537a9366718b39278fd4eb33b2ac568011e374cc -Author: Guus Sliepen -Date: Thu May 21 11:09:01 2015 +0200 - - Update copyright notices. - -commit 0a786ffbb9d293d7704b8e264f3943a616ed25cc -Author: Guus Sliepen -Date: Thu May 21 11:06:38 2015 +0200 - - Set the CLOEXEC flag on the umbilical socket. - -commit 87e09527735632aae3f595f5a28667880ca4c8c1 -Author: Guus Sliepen -Date: Wed May 20 21:28:54 2015 +0200 - - Use socketpair() instead of pipe() for the umbilical. - - This prepares for a possible conversion of the umbilical socket to a - control socket. - -commit 19e0d449ebd06450c9d7f16f032c0806242c7515 -Author: Guus Sliepen -Date: Wed May 20 21:25:06 2015 +0200 - - Don't write log messages to the umbilical pipe if we don't detach. - - If we run in the foreground and are started by the CLI, this would - otherwise cause the first few log messages to appear twice. - -commit 11868b890d1a7f4cfbfb37099393b32019010f66 -Author: Guus Sliepen -Date: Wed May 20 16:59:43 2015 +0200 - - Ensure "tinc start" knows if the daemon really started succesfully. - - We do this by creating an umbilical between the CLI and the daemon. The - daemon pipes log messages to the CLI until it starts the main loop. The - daemon then cuts the umbilical. The CLI copies all the received log - messages to stderr, and the last byte indicates whether the daemon - started succesfully or not, so the CLI can exit with a useful exit code. - -commit 7f96ef081dc0dc41e3955e35c1a36a62fd47f72b -Author: Guus Sliepen -Date: Wed May 20 11:11:12 2015 +0200 - - Fix check for LOCALSTATEDIR accessibility for the CLI. - - The CLI does not need write access to the directory where the PID file - is stored, it just needs to be able to read the PID file. - -commit 3ccdf50beb6b2d3f2730bdc66006b43190537cde -Author: Guus Sliepen -Date: Wed May 20 00:55:00 2015 +0200 - - Allocate temporary filenames on the stack. - - This gets rid of xasprintf() in a number of places, and removes the need - to free() the temporary strings. A few potential memory leaks have been - fixed. - -commit 58e8f598f38dbb2f210d8a62c8fb4b46513dc39f -Author: Guus Sliepen -Date: Wed May 20 00:12:01 2015 +0200 - - Allow dumping a list of outstanding invitations. - - This dumps the name of the invitation file, as well as the name of the - node that is being invited. This can make it easier to find the - invitation file belonging to a given node. - -commit 7c8f54cdb2925ba787209f5358b62d3cee414d43 -Author: Guus Sliepen -Date: Wed May 20 00:02:53 2015 +0200 - - Add "list" as an alias for "dump" in the CLI. - -commit 69ba5f621e4931417f9f41061a7689e36c70e3d9 -Author: Guus Sliepen -Date: Tue May 19 22:26:32 2015 +0200 - - Quit with an error message if ioctl(TUNSETIFF) fails. - - It is possible that opening /dev/net/tun works but that interface - creation itself fails, for example if a non-root user tries to create a - new interface, or if the desired interface is already opened by another - process. In this case, the ioctl() fails, but we actually silently - ignored this condition. - -commit 60fbdb3f2cf0216afb2cfcc2c4128fb5765471ac -Author: Guus Sliepen -Date: Tue May 19 22:17:18 2015 +0200 - - If LOCALSTATEDIR is inaccessible, store the pid and socket files in the configuration directory. - - The compile time local state directory is usually /var or - /usr/local/var. If this is not accessible for some reason, for example - because someone ./configured tinc without --localstatedir and - /usr/local/var does not exist, or if tinc is started by a non-root user, - then tinc will fall back to the directory where tinc.conf is stored. - A warning is logged when this happens. - -commit dece2db78e2c4ccd6e617e69195754639b086170 -Author: Guus Sliepen -Date: Tue May 19 21:32:30 2015 +0200 - - Don't log seqno failures in sptps_verify_datagram(). - - This function is not used for normal traffic, only when a packet from an - unknown source is received and we need to check against candidates. No - failures should be logger in this case; if the packet is really not - valid this will be logged by handle_incoming_vpn_data(). - -commit a7522118018928e17fc53840b420df570cf1bec5 -Author: Guus Sliepen -Date: Tue May 19 21:23:35 2015 +0200 - - Add source of SPTPS errors to log messages. - -commit d89f37eb17196e38105a92d746ed7cb6b6f6ba45 -Author: Guus Sliepen -Date: Tue May 19 14:25:20 2015 +0200 - - Add newline at end of precomp_data.h and sc.h. - -commit d8a3a182de30d649ed6764dd5d64b57ad77a446e -Author: Guus Sliepen -Date: Tue May 19 14:09:53 2015 +0200 - - Fix src/Makefile.am for *BSD. - - Apparently the BSDs don't like $(srcdir) but want to see ${srcdir} in - their rules. - -commit 96a323e16a1f3e99d0b498aa90423b060c3d458f -Author: Guus Sliepen -Date: Tue May 19 13:31:26 2015 +0200 - - Remove info-in-builddir option from AM_INIT_AUTOMAKE(). - - This option is not supported by older, but still widely used versions of - automake. The drawback is that when doing multiple VPATH builds in a - row, the info manual may mention incorrect paths, but it doesn't affect - the executables at all. - -commit 51b5aab9b042dffc6ef0791358f097895a3234eb -Author: Sven-Haegar Koch -Date: Wed May 13 21:24:29 2015 +0200 - - Fix check for public key in invite-join.test. - - Small fix to test/invite-join.test, comparing no-longer-existing - ECDSAPublicKey does not make sense. - -commit a196e9b0fde1e8a67108eacd51ac663eac5a63ae -Author: Etienne Dechamps -Date: Mon May 18 21:06:16 2015 +0100 - - Fix direct UDP communciation with pre-relaying 1.1 nodes. - - try_tx_sptps() gives up on UDP communication if the recipient doesn't - support relaying. This is too restrictive - we only need the other node - to support relaying if we actually want to relay through them. If the - packet is sent directly, it's fine to send it to an old pre-node-IDs - tinc-1.1 node. - -commit fef29d0193afc7e0a9dc766ef75b79cd4dc6fa37 -Author: Etienne Dechamps -Date: Mon May 18 20:48:45 2015 +0100 - - Don't parse node IDs if the sending node doesn't support them. - - Currently, tinc tries to parse node IDs for all SPTPS packets, including - ones sent from older, pre-node-IDs tinc-1.1 nodes, and therefore doesn't - recognize packets from these nodes. This commit fixes that. - - It also makes code slightly clearer by reducing the amount of fiddling - around packet offset/length. - -commit 643149b44991121c618a2412c64072ad22955991 -Author: Etienne Dechamps -Date: Mon May 18 20:35:44 2015 +0100 - - Fix SPTPS condition in try_harder(). - - A condition in try_harder() is always evaluating to false when talking - to a SPTPS node because n->status.validkey_in is always false in that - case. Fix the condition so that the SPTPS status is correctly checked. - - This prevented recent tinc-1.1 nodes from talking to older, pre-node-ID - tinc-1.1 nodes. - - The regression was introduced in - 6056f1c13bb37bf711dff9c25a6eaea99f14d31f. - -commit 01d251986260faf306927aa91daff705ee0523d6 -Author: Etienne Dechamps -Date: Sun May 17 22:36:15 2015 +0100 - - Don't pollute the system header directory namespace. - - Since commit 13f9bc1ff199bea46d3dde391a848f119e2cc0f0, tinc passes the - -I. option to the preprocessor so that version_git.h can be found during - out-of-tree ("VPATH") builds. - - The problem is, this option also affects the directory search for files - included *from* system headers. For example, on MinGW, unistd.h contains - the following line: - - #include - - Which, due to -I. putting the tinc directory at the head of the search - order, results in tinc's process.h being included instead of the file - from MinGW. Hilarity ensues. - - This commit fixes the issue by using -iquote, which doesn't affect - system headers. - -commit c1154bf696b0b3ad22126a76750d610e32e2ffc1 -Author: Etienne Dechamps -Date: Sun May 17 22:21:11 2015 +0100 - - Make sure the MIN() macro is defined. - - On MinGW this is not automatically the case, thereby breaking the build. - -commit 5c32bd1578d59e005f634621d17ca96af32bb630 -Merge: aa52300b 1a7a9078 2cb216d8 -Author: Guus Sliepen -Date: Sun May 17 21:07:45 2015 +0200 - - Merge remote-tracking branches 'dechamps/sptpsrestart' and 'dechamps/keychanged' into 1.1 - -commit 2cb216d83d825fcca2fa2b66c756b253f8f0828b -Author: Etienne Dechamps -Date: Sun May 17 19:23:12 2015 +0100 - - Don't send KEY_CHANGED messages if we don't support the legacy protocol. - - KEY_CHANGED messages are only useful to invalidate keys for non-SPTPS nodes; - SPTPS nodes use a different internal mechanism (forced KEX) for that purpose. - Therefore, if we know we can't talk to legacy nodes, there's no point in - sending them these messages. - -commit 1a7a9078c093f77950192c32be009bbe463fe372 -Author: Etienne Dechamps -Date: Sun May 17 18:50:11 2015 +0100 - - Proactively restart the SPTPS tunnel if we get receive errors. - - There are a number of ways a SPTPS tunnel can get into a corrupt state. - For example, during key regeneration, the KEX and SIG messages from - other nodes might arrive out of order, which confuses the hell out of - the SPTPS code. Another possible scenario is not noticing another node - crashed and restarted because there was no point in time where the node - was seen completely disconnected from *all* nodes; this could result in - using the wrong (old) key. There are probably other scenarios which have - not even been considered yet. Distributed systems are hard. - - When SPTPS got confused by a packet, it used to crash the entire - process; fortunately that was fixed by commit - 2e7f68ad2b51648b89c4b5c61aeb4cec67c2fbbb. However, the error handling - (or lack thereof) leaves a lot to be desired. Currently, when SPTPS - encounters an error when receiving a packet, it just shrugs it off and - continues as if nothing happened. The problem is, sometimes getting - receive errors mean the tunnel is completely stuck and will not recover - on its own. In that case, the node will become unreachable - possibly - indefinitely. - - The goal of this commit is to improve SPTPS error handling by taking - proactive action when an incoming packet triggers a failure, which is - often an indicator that the tunnel is stuck in some way. When that - happens, we simply restart SPTPS entirely, which should make the tunnel - recover quickly. - - To prevent "storms" where two buggy nodes flood each other with invalid - packets and therefore spend all their time negotiating new tunnels, we - limit the frequency at which tunnel restarts happen to ten seconds. - - It is likely this commit will solve the "Invalid KEX record length - during key regeneration" issue that has been seen in the wild. It is - difficult to be sure though because we do not have a full understanding - of all the possible conditions that can trigger this problem. - -commit aa52300b2b6e9d923d6d5b8c95fa500f549620d0 -Author: Etienne Dechamps -Date: Sun May 17 17:51:05 2015 +0100 - - Trivial: make sptps_receive_data_datagram() a little more readable. - - The new code updates variables as stuff is being consumed, so that the - reader doesn't have to do that in his head. - -commit 30e839b0a1810b9cb0a2de2595cef2f8ebb06357 -Author: Guus Sliepen -Date: Sun May 17 18:44:09 2015 +0200 - - Don't send local_address in ADD_EDGE messages if it's AF_UNSPEC. - -commit 23fda4db6d1bb400a97f6d2a07d9b700f9546129 -Author: Sven-Haegar Koch -Date: Sun May 17 05:29:21 2015 +0200 - - Let sockaddr2hostname() handle AF_UNSPEC addresses. - -commit 1e89a63f1638e43dee79afbb18d5f733b27d830b -Author: Etienne Dechamps -Date: Sun May 17 17:09:56 2015 +0100 - - Prevent SPTPS key regeneration packets from entering an UDP relay path. - - Commit 10c1f60c643607d9dafd79271c3475cddf81e903 introduced a mechanism - by which a packet received by REQ_KEY could continue its journey over - UDP. This was based on the assumption that REQ_KEY messages would never - be used for handshake packets (which should never be sent over UDP, - because SPTPS currently doesn't handle lost handshake packets very - well). - - Unfortunately, there is one case where handshake packets are sent using - REQ_KEY: when regenerating the SPTPS key for a pre-established channel. - With the current code, such packets risk getting relayed over UDP. - - When processing a REQ_KEY message, it is impossible for the receiving - end to distinguish between a data SPTPS packet and a handshake packet, - because this information is stored in the type field which is encrypted - with the end-to-end key. - - This commit fixes the issue by making tinc use ANS_KEY for all SPTPS - handshake messages. This works because ANS_KEY messages are never - forwarded using the SPTPS relay mechanisms, therefore they are - guaranteed to stick to TCP. - -commit eecfeadeb4fc70ee002b81c20ba12ba3e3acb843 -Author: Guus Sliepen -Date: Sat May 16 02:01:54 2015 +0200 - - Let sockaddr2str() handle AF_UNSPEC addresses. - -commit 613c121cdceec0199dc4d056857be021ed1d21de -Author: Guus Sliepen -Date: Fri May 15 23:35:46 2015 +0200 - - Try all addresses for the hostname in an invitation URL. - -commit 54a8bd78e3fbe2de4d9daea748643f9c9b5b240e -Author: Guus Sliepen -Date: Fri May 15 23:08:53 2015 +0200 - - Be more liberal accepting ADD_EDGE messages with conflicting local address information. - - If the ADD_EDGE is for one of the edges we own, and if it is not the - same as we actually have, send a correcting ADD_EDGE back. Otherwise, if - the ADD_EDGE contains new information, update our idea of the local - address for that edge. - - If the ADD_EDGE does not contain local address information, then we - never make a correction nor log a warning. - -commit 8028e01100eb40f64da5e50ef33fbf9e3f8099de -Author: Guus Sliepen -Date: Fri May 15 23:01:06 2015 +0200 - - Use AF_UNSPEC instead of AF_UNKNOWN for unspecified local address in add_edge_h(). - - AF_UNKNOWN is reserved for valid addresses that the local node cannot - parse, but remote nodes possibly can. - -commit fd1cff6df23c3f16a46edaff8a52a7212914b2f0 -Author: Guus Sliepen -Date: Fri May 15 00:21:48 2015 +0200 - - Fix receiving UDP packets from tinc 1.0.x nodes. - - In try_mac(), the wrong offsets were used into the packet buffer, - causing the digest verification to always fail. - -commit 44e9f1e1d8d6dbd4625e5458cfffcf6b5168374a -Author: Guus Sliepen -Date: Wed May 13 14:28:28 2015 +0200 - - Fix invitations. - - These were broken due to a change in behaviour of sptps_receive_data() - introduced in commit d237efd325cd7bdd73f5eb111c769470238dce6e. - -commit 7e6b2dd1ea51057b7135139c200d97a9e8f9c9cb -Author: Etienne Dechamps -Date: Sun May 10 19:00:03 2015 +0100 - - Introduce raw TCP SPTPS packet transport. - - Currently, SPTPS packets are transported over TCP metaconnections using - extended REQ_KEY requests, in order for the packets to pass through - tinc-1.0 nodes unaltered. Unfortunately, this method presents two - significant downsides: - - - An already encrypted SPTPS packet is decrypted and then encrypted - again every time it passes through a node, since it is transported - over the SPTPS channels of the metaconnections. This - double-encryption is unnecessary and wastes CPU cycles. - - - More importantly, the only way to transport binary data over - standard metaconnection messages such as REQ_KEY is to encode it - in base64, which has a 33% encoding overhead. This wastes 25% of the - network bandwidth. - - This commit introduces a new protocol message, SPTPS_PACKET, which can - be used to transport SPTPS packets over a TCP metaconnection in an - efficient way. The new message is appropriately protected through a - minor protocol version increment, and extended REQ_KEY messages are - still used with nodes that do not support the new message, as well as - for the intial handshake packets, for which efficiency is not a concern. - - The way SPTPS_PACKET works is very similar to how the traditional PACKET - message works: after the SPTPS_PACKET message, the raw binary packet is - sent directly over the metaconnection. There is one important - difference, however: in the case of SPTPS_PACKET, the packet is sent - directly over the TCP stream completely bypassing the SPTPS channel of - the metaconnection itself for maximum efficiency. This is secure because - the SPTPS packet that is being sent is already encrypted with an - end-to-end key. - -commit d237efd325cd7bdd73f5eb111c769470238dce6e -Author: Etienne Dechamps -Date: Sun May 10 19:28:11 2015 +0100 - - Only read one record at a time in sptps_receive_data(). - - sptps_receive_data() always consumes the entire buffer passed to it, - which is somewhat inflexible. This commit improves the interface so that - sptps_receive_data() consumes at most one record. The goal is to allow - non-SPTPS stuff to be interleaved with SPTPS records in a single TCP - stream. - -commit de14308840a96060d700c93117789e83ec948c01 -Author: Etienne Dechamps -Date: Sun May 10 18:05:19 2015 +0100 - - Rename REQ_SPTPS to SPTPS_PACKET. - - REQ_SPTPS implies the message has an ANS_ counterpart (like REQ_KEY, - ANS_KEY), but it doesn't. Therefore dropping the REQ_ seems more - appropriate, and we add a _PACKET suffix to reduce the likelihood of - naming conflicts. - -commit 10c1f60c643607d9dafd79271c3475cddf81e903 -Author: Etienne Dechamps -Date: Sat May 9 18:09:23 2015 +0100 - - Try to use UDP to relay SPTPS packets received over TCP. - - Currently, when tinc receives a SPTPS packet over TCP via the REQ_KEY - encapsulation mechanism, it forwards it like any other TCP request. This - is inefficient, because even though we received the packet over TCP, - we might have an UDP link with the next hop, which means the packet - could be sent over UDP. - - This commit removes that limitation by making sure SPTPS data packets - received through REQ_KEY requests are not forwarded as-is but passed - to send_sptps_data() instead, thereby using the same code path as if - the packet was received over UDP. - -commit 1296f715b57c88c17299cacadaccdc0be898e0b1 -Author: Etienne Dechamps -Date: Sat May 9 17:54:34 2015 +0100 - - Expose the raw SPTPS send interface from net_packet. - - net_packet doesn't actually use send_sptps_data(); it only uses - send_sptps_data_priv(). In addition, the only user of send_sptps_data() - is protocol_key. Therefore it makes sense to expose - send_sptps_data_priv() directly, and move send_sptps_data() (which is - basically just boilerplate) as a local function in protocol_key. - -commit 8e43a2fc744559956640d3eb9a7a26a945d94fde -Author: Etienne Dechamps -Date: Sun May 10 18:46:47 2015 +0100 - - Use the correct originator node when relaying SPTPS UDP packets. - - Currently, when relaying SPTPS UDP packets, the code uses the direct - sender as the originator, instead of preserving the original source ID. - - This wouldn't cause any issues in most cases because the originator and - the sender are the same in simple one-hop relay chains, but this will - break as soon as there is more than one relay. - -commit 9d223cb7e7f337c6b9707f07e3e9796108a3b597 -Author: Etienne Dechamps -Date: Sun May 10 18:37:30 2015 +0100 - - When relaying, send probes to the destination, not the source. - - This seems to be a typo from c23e50385d9de538af676706596f6508b2ceb01a. - Achievement unlocked: got a one-line commit wrong. - -commit 13f9bc1ff199bea46d3dde391a848f119e2cc0f0 -Author: Etienne Dechamps -Date: Sat Jul 12 16:01:41 2014 +0100 - - Add support for out-of-tree ("VPATH") builds. - - This fixes some issues with the build system when building out of tree. - - With this commit, it is now possible to do the following: - - $ cd /tmp/build - $ /path/to/tinc/configure - $ make - -commit 462e9892ae2765d0c7036005fafe036fd2a9f4f2 -Author: Etienne Dechamps -Date: Sat Jul 12 16:21:32 2014 +0100 - - Remove explicit distribution rules for m4 scripts. - - It turns out Automake is smart enough to include these files in the - distribution by itself. - -commit 362b79176439a2eb643612633aa0ff210a6a4d81 -Author: Guus Sliepen -Date: Sat May 9 15:41:37 2015 +0200 - - Really remove "release-" from the git-derived version string. - -commit b109e8b16488f9bbfdc4aefe0e9b00c4f202e905 -Author: Etienne Dechamps -Date: Sun Jun 29 18:26:55 2014 +0100 - - Use git describe to populate autoconf's VERSION. - - This uses the output of "git describe" directly in configure.ac to - determine the version number to use, instead of hardcoding it. - - With this change, current version information is completely removed - from the codebase itself, and is always fetched on-the-fly from git as - the single source of truth. - - In order to ensure make dist always uses the current version number in - the contents of the packaged configure script as well as the package - name, a dependency is added to the dist target such that autoconf is - always run before dist to regenerate the version number. If this wasn't - the case, make dist would use the version number from when autoconf was - originally run, not the version number that make dist is running from. - That said, errors from that rule are ignored so that people can still - run make dist without a working autoconf. - - In addition, the NEWS check is dropped, as it would then become annoying - because it would force make dist users to always have a line for the - current commit in the NEWS file. - -commit 1c77069064e0cf0e0ddd81bab1b1354a8952fb33 -Author: Pierre Emeriaud -Date: Sat May 9 00:03:51 2015 +0200 - - Fix typo in tincctl help. - -commit 54554cc2765befc2e95fd7fe2fedfd75a94b5926 -Author: Guus Sliepen -Date: Tue May 5 23:05:22 2015 +0200 - - Don't include build-time generated version_git.h in the tarball. - -commit c46bdbde18629f0a0613c776c13a79fea0ec6093 -Author: Guus Sliepen -Date: Tue May 5 23:03:41 2015 +0200 - - Remove "release-" from displayed git version. - - Also make sure that version_git.h is only written to if the "git - describe" command succeeds. - -commit 120e0567cba17eeb57c12a34686fddbbb491b62f -Author: Etienne Dechamps -Date: Sun Jun 29 15:22:10 2014 +0100 - - Use git description as the tinc version. - - Instead of using the hardcoded version number in configure.ac, this - makes tinc use the live version reported by "git describe", - queried on-the-fly during the build process and regenerated for every - build. - - This makes tinc version output more useful, as tinc will now display the - number of commits since the last tag as well as the commit the binary is - built from, following the format described in git-describe(1). - - Here's an example of tincd --version output: - - tinc version release-1.1pre10-48-gc149315 (built Jun 29 2014 15:21:10, protocol 17.3) - - When building directly from a release tag, this will look like the following: - - tinc version release-1.1pre10 (built Jun 29 2014 15:21:10, protocol 17.3) - - (Note that the format is slightly different - because of the way the - tags are named, it says "release-1.1pre10" instead of just "1.1pre10") - - If git describe fails (for example when building from a release - tarball), the build automatically falls back to the autoconf-provided - VERSION macro (i.e. the old behavior). - -commit 95594f47384b60a6f994f0fca6fd9f79b2b283aa -Author: Guus Sliepen -Date: Fri Apr 24 23:51:29 2015 +0200 - - Fix typo 0fda572c88d02b0b200ef81d72cc4da594fa0e38 that prevented some errors from being logged. - -commit 0fda572c88d02b0b200ef81d72cc4da594fa0e38 -Author: Guus Sliepen -Date: Fri Apr 24 23:43:58 2015 +0200 - - Don't log an error message when receiving a TERMREQ. - -commit ea1e815223e99f3747f94cf0d10eb06e52f70b21 -Author: Guus Sliepen -Date: Fri Apr 24 23:43:19 2015 +0200 - - Fix a possible segmentation fault during key upgrades. - - read_rsa_public_key() was bailing out early if the given node already has an Ed25519 key, and - returned true even though c->rsa was NULL. The early bailout code isn't necessary anymore, so just - remove it. - -commit 2059814238320b761fb93608b7f8a114de861302 -Author: Guus Sliepen -Date: Fri Apr 24 23:40:20 2015 +0200 - - Allow one-sided upgrades to Ed25519. - - This deals with the case where one node knows the Ed25519 key of another node, but not the other - way around. This was blocked by an overly paranoid check in id_h(). The upgrade_h() function already - handled this case, and the node that already knows the other's Ed25519 key checks that it has not - been changed, otherwise the connection will be aborted. - -commit 3def9d2ad88a9015af4c42aac329e0e2a80679f7 -Merge: 95921696 0c010ff9 -Author: Guus Sliepen -Date: Sun Apr 12 15:43:05 2015 +0200 - - Merge remote-tracking branch 'dechamps/wintapver' into 1.1 - -commit 95921696a49d1eff058880c90a80efd208de959d -Merge: f500a3d4 7027bba5 -Author: Guus Sliepen -Date: Sun Apr 12 15:42:48 2015 +0200 - - Always call res_init() before getaddrinfo(). - - Unfortunately, glibc assumes that /etc/resolv.conf is a static file that - never changes. Even on servers, /etc/resolv.conf might be a dynamically - generated file, and we never know when it changes. So just call - res_init() every time, so glibc uses up-to-date nameserver information. - - Conflicts: - src/have.h - src/net.c - src/net_setup.c - -commit f500a3d4e6e51ea1d88235e89e494ecb8f71ba5b -Merge: 41798146 89715454 -Author: Guus Sliepen -Date: Sun Apr 12 15:36:50 2015 +0200 - - Merge remote-tracking branch 'dechamps/windevice' into 1.1 - -commit 417981462a2dde7800768eb58cf8f4e5238d4ad7 -Merge: 11effab8 176ee015 -Author: Guus Sliepen -Date: Sun Apr 12 15:35:50 2015 +0200 - - Merge remote-tracking branch 'dechamps/winmtu' into 1.1 - -commit 11effab85b6b278ccf0ac3ba52a12bbca3e3dcc5 -Merge: 9e71b74e 43b41e90 -Author: Guus Sliepen -Date: Sun Apr 12 15:35:37 2015 +0200 - - Merge remote-tracking branch 'dechamps/fsckwin' into 1.1 - -commit 9e71b74ed83c51e0b35114a4f153b62b54fd3702 -Merge: 76a9be5b fa432426 -Author: Guus Sliepen -Date: Sun Apr 12 15:34:50 2015 +0200 - - Merge remote-tracking branch 'dechamps/staticfix' into 1.1 - -commit 0c010ff9fe50b4046b5c7977bafac3e74037f075 -Author: Etienne Dechamps -Date: Sun Mar 15 18:30:39 2015 +0000 - - Warn about performance if using TAP-Windows >=9.21. - - Testing has revealed that the newer series of Windows TAP drivers (i.e. - 9.0.0.21 and later, also known as NDIS6, tap-windows6) suffer from - serious performance issues in the write path. Write operations seems to - take a very long time to complete, resulting in massive packet loss even - for throughputs as low as 10 Mbit/s. - - I've made some attempts to alleviate the problem using parellelism. By - using custom code that allows up to 256 write operations at the same - time the results are much better, but it's still about 2 times worse - than the traditional 9.0.0.9 driver. - - We need to investigate more and file a bug against tap-windows6, but in - the mean time, let's inform the user that he might not want to use the - latest drivers. - -commit 0f328d9d2853ca723ff3205f39bb22207d21a932 -Author: Etienne Dechamps -Date: Sun Mar 15 18:18:04 2015 +0000 - - Log TAP-Windows driver version on startup. - - This is generally useful. We've seen issues that are specific to some - version of these drivers (especially the newer 9.0.0.21 version), so - it's relevant to log it, especially since that means it will be - copy-pasted by people posting their logs asking for help. - -commit 7027bba541eca3e34f689bebd6f6e408ba4e7710 -Author: Etienne Dechamps -Date: Sun Mar 15 18:01:03 2015 +0000 - - Increase the ReplayWindow default from 16 to 32. - - As a rule, it seems reasonable to make sure that tinc operates correctly - on at least 1G links, since these are pretty common. However, I have - observed replay window issues when operating at speeds of 600 Mbit/s and - above, especially when the receiving end is a Windows system (not sure - why). This commit increases the default so that this won't occur on - fresh setups. - -commit 94f49a163aa570ea272bf3bbd7734187098d88b7 -Author: Etienne Dechamps -Date: Sun Mar 15 17:50:53 2015 +0000 - - Set the default for UDPRcvBuf and UDPSndBuf to 1M. - - It may not be obvious, but due to the way tinc operates (single-threaded - control loop with no intermediate packet buffer), UDP send and receive - buffers can have a massive impact on performance. It is therefore of - paramount importance that the buffers be large enough to prevent packet - drops that could occur while tinc is processing a packet. - - Leaving that value to the OS default could be reasonable if we weren't - relying on it so much. Instead, this makes performance somewhat - unpredictable. - - In practice, the worst case scenario occurs on Windows, where Microsoft - had the brillant idea of making the buffers 8K in size by default, no - matter what the link speed is. Considering that 8K flies past in a - matter of microseconds on >1G links, this is extremely inappropriate. On - these systems, changing the buffer size to 1M results in *obscene* - raw throughput improvements; I have observed a 10X jump from 40 Mbit/s - to 400 Mbit/s on my system. - - In this commit, we stop trusting the OS to get this right and we use a - fixed 1M value instead, which should be enough for <=1G links. - -commit 89715454c083aaeb4dc73340f2d0ab9a3d9503e0 -Author: Etienne Dechamps -Date: Sat Mar 14 18:19:22 2015 +0000 - - Fix Windows device asynchronous write behavior. - - Write operations to the Windows device do not necessarily complete - immediately; in fact, with the latest TAP-Win32 drivers, this never - seems to be the case. - - write_packet() does not handle that case correctly, because the - OVERLAPPED structure and the packet data go out of scope before the - write operation completes, resulting in race conditions. - - This commit fixes the issue by making sure these data structures are - kept in global scope, and by dropping any packets that may arrive while - the previous write operation is still pending. - -commit 675142c7d88c9d325c0ca0bc5761072a5d810c75 -Author: Etienne Dechamps -Date: Sat Mar 14 17:27:14 2015 +0000 - - When disabling the Windows device, wait for pending reads to complete. - - On Windows, when disabling the device, tinc uses the CancelIo() to - cancel the pending read operation, and then proceeds to delete the event - handle immediately. - - This assumes that CancelIo() blocks until the pending read request is - completely torn down and no references to it remain. While MSDN is not - completely clear on that subject, it does suggest that this is not the - case: - - http://msdn.microsoft.com/en-us/library/windows/desktop/aa363791.aspx - If the function succeeds [...] the cancel operation for all pending - I/O operations issued by the calling thread for the specified file - handle was successfully requested. - - This implies that cancellation was merely "requested", and that there - are no guarantees as to the state of the operation when CancelIo() - returns. Therefore, care must be taken not to close event handles - prematurely. - - While I'm no aware of this potential race condition causing any problems - in practice, I don't want to take any chances. - -commit 176ee015267d87ff4fd4d2615e9f5ac978116171 -Author: Etienne Dechamps -Date: Sun Mar 15 10:00:56 2015 +0000 - - Make sure packet header structures are correctly packed on Windows. - - Modern versions of GCC handle structure packing differently when - compiling for Windows, as reported in the following GCC bug report: - - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991 - - In practice, this affects tinc because it uses packed structs as a - convenient way to populate packet headers. "struct ip" is especially - affected - on Linux, sizeof(struct ip) returns 20 as expected, while on - Windows, it returns 24 because of the broken alignment. - - This in turn completely breaks code that has to populate an IP header. - Specifically, this breaks route_ipv4_unreachable() which is responsible, - among other things, for the generation of ICMP Fragmentation Needed - messages. On Windows, these messages are corrupted beyond hope because - of this alignment issue. For TCP connections that are established - before tinc obtains a fix on the MTU (and thus are not MSS clamped), - this can result in massive disruption. - - This commit fixes the issue by forcing GCC to use standard alignment - for all packed structures in the tinc codebase instead of the MSVC - alignment. - -commit 43b41e9095e6261c53da1ae46117d018296c3b68 -Author: Etienne Dechamps -Date: Sat Mar 14 16:17:32 2015 +0000 - - Fix HAVE_DECL_RES_INIT conditionals. - - HAVE_DECL_RES_INIT is generated using AC_CHECK_DECLS. tinc checks this - symbol using #ifdef, which is wrong because (according to autoconf docs) - the symbol is always defined, it's just set to zero if the check failed. - - This broke the Windows build starting from - 0b310bf406dbe58afe37fa31156b9ea47599d7be, because it introduced this - conditional in code that's not excluded from the Windows build. - -commit 4989362300f800a6f407508f1e0127867cf80cba -Author: Etienne Dechamps -Date: Sat Mar 14 16:07:54 2015 +0000 - - Fix invalid getuid() call on Windows. - - This is breaking the Windows build. Regression was introduced in - 268e3ffca7b45cfc736e1bc9bec7a113c6c45701. - -commit fa432426df7e2e364e310ab4bac28e60f732a3c9 -Author: Etienne Dechamps -Date: Sat Mar 14 14:04:50 2015 +0000 - - Don't send UDP probes past static relays. - - Ironically, commit 0f8e2cc78cafe47a087d3fc9b480551b841aeb30 introduced - a regression on its own, since it accidently removed a return statement - that prevented try_tx_sptps() from sending UDP/MTU probes to nodes that - are past static relays. - -commit 76a9be5bce43a1a7363c670882f5315c824c903c -Author: Etienne Dechamps -Date: Sun Mar 8 20:17:27 2015 +0000 - - Throttle the rate of MTU_INFO messages. - - This makes sure MTU_INFO messages are only sent at the maximum rate of - 5 per second (by default). As usual with these "probe" mechanisms, the - rate of these messages cannot be higher than the rate of data packets - themselves, since they are sent from the RX path. - -commit 467397f25d3a99ec1a97d4419502c37b64276f49 -Author: Etienne Dechamps -Date: Sun Mar 8 19:54:44 2015 +0000 - - Throttle the rate of UDP_INFO messages. - - This makes sure UDP_INFO messages are only sent at the maximum rate of - 5 per second (by default). As usual with these "probe" mechanisms, the - rate of these messages cannot be higher than the rate of data packets - themselves, since they are sent from the RX path. - -commit b1421b919090351e885ed3d06df67fb2eb69e765 -Author: Etienne Dechamps -Date: Sun Mar 8 18:54:50 2015 +0000 - - Add MTU_INFO protocol message. - - In this commit, nodes use MTU_INFO messages to provide MTU information. - - The issue this code is meant to address is the non-trivial problem of - finding the proper MTU when UDP SPTPS relays are involved. Currently, - tinc has no idea what the MTU looks like beyond the first relay, and - will arbitrarily use the first relay's MTU as the limit. This will fail - miserably if the MTU decreases after the first relay, forcing relays to - fall back to TCP. More generally, one should keep in mind that relay - paths can be arbitrarily complex, resulting in packets taking "epic - journeys" through the graph, switching back and forth between UDP (with - variable MTUs) and TCP multiple times along the path. - - A solution that was considered consists in sending standard MTU probes - through the relays. This is inefficient (if there are 3 nodes on one - side of relay and 3 nodes on the other side, we end up with 3*3=9 MTU - discoveries taking place at the same time, while technically only - 3+3=6 are needed) and would involve eyebrow-raising behaviors such as - probes being sent over TCP. - - This commit implements an alternative solution, which consists in - the packet receiver sending MTU_INFO messages to the packet sender. - The message contains an MTU value which is set to maximum when the - message is originally sent. The message gets altered as it travels - through the metagraph, such that when the message arrives to the - destination, the MTU value contained in the message can be used to - send packets while making sure no relays will be forced to fall back to - TCP to deliver them. - - The operating principles behind such a protocol message are similar to - how the UDP_INFO message works, but there is a key difference that - prevents us from simply reusing the same message: the UDP_INFO message - only cares about relay-to-relay links (i.e. it is sent between static - relays and the information it contains only makes sense between two - adjacent static relays), while the MTU_INFO cares about the end-to-end - MTU, including the entire relay path. Therefore, UDP_INFO messages stop - when they encounter static relays, while MTU_INFO messages don't stop - until they get to the original packet sender. - - Note that, technically, the MTU that is obtained through this mechanism - can be slightly pessimistic, because it can be lowered by an - intermediate node that is not being used as a relay. Since nodes have no - way of knowing whether they'll be used as dynamic relays or not (and - have no say in the matter), this is not a trivial problem. That said, - this is highly unlikely to result in noticeable issues in realistic - scenarios. - -commit 9bb230f30f665779eb89dcce077a15360ec50be1 -Author: Etienne Dechamps -Date: Sat Jan 3 17:46:33 2015 +0000 - - Add UDP_INFO protocol message. - - In this commit, nodes use UDP_INFO messages to provide UDP address - information. The basic principle is that the node that receives packets - sends UDP_INFO messages to the node that's sending the packets. The - message originally contains no address information, and is (hopefully) - updated with relevant address information as it gets relayed through the - metagraph - specifically, each intermediate node will update the message - with its best guess as to what the address is while forwarding it. - - When a node receives an UDP_INFO message, and it doesn't have a - confirmed UDP tunnel with the originator node, it will update its - records with the new address for that node, so that it always has the - best possible guess as to how to reach that node. This applies to the - destination node of course, but also to any intermediate nodes, because - there's no reason they should pass on the free intel, and because it - results in nice behavior in the presence of relay chains (multiple nodes - in a path all trying to reach the same destination). - - If, on the other hand, the node does have a confirmed UDP tunnel, it - will ignore the address information contained in the message. - - In all cases, if the node that receives the message is not the - destination node specified in the message, it will forward the message - but not before overriding the address information with the one from its - own records. If the node has a confirmed UDP tunnel, that means the - message is updated with the address of the confirmed tunnel; if not, - the message simply reflects the records of the intermediate node, which - just happen to be the contents of the UDP_INFO message it just got, so - it's simply forwarded with no modification. - - This is similar to the way ANS_KEY messages are currently - overloaded to provide UDP address information, with two differences: - - - UDP_INFO messages are sent way more often than ANS_KEY messages, - thereby keeping the address information fresh. Previously, if the UDP - situation were to change after the ANS_KEY message was sent, the - sender would virtually never get the updated information. - - - Once a node puts address information in an ANS_KEY message, it is - never changed again as the message travels through the metagraph; in - contrast, UDP_INFO messages behave the opposite way, as they get - rewritten every time they travel through a node with a confirmed UDP - tunnel. The latter behavior seems more appropriate because UDP tunnel - information becomes more relevant as it moves closer to the - destination node. The ANS_KEY behavior is not satisfactory in some - cases such as multi-layered graphs where the first hop is located - before a NAT. - - Ultimately, the rationale behind this whole process is to improve UDP - hole punching capabilities when port translation is in effect, and more - generally, to make tinc more reliable in (very) hostile network - conditions (such as multi-layered NAT). - -commit 6568cffd52d4803effaf52a9bb9c98d69cf7922a -Author: Guus Sliepen -Date: Sat Mar 14 12:02:29 2015 +0000 - - --syslog and --logfile are mutually exclusive. - -commit 15ad628f06895175d7e629ce0188805dc00159fd -Author: Guus Sliepen -Date: Sat Mar 14 12:02:06 2015 +0000 - - Fix the case where we detach and use --logfile. - -commit 04fc19112da5e7fcefefcf6e490987cdcfb6f620 -Merge: f9ecaa10 19d16e40 -Author: Guus Sliepen -Date: Sat Mar 14 11:45:55 2015 +0000 - - Merge remote-tracking branch 'seehuhn/1.1' into 1.1 - -commit f9ecaa10768926302f24a70975f36e360b51c8ce -Merge: c23e5038 2e7f68ad -Author: Guus Sliepen -Date: Sat Mar 14 11:44:38 2015 +0000 - - Merge remote-tracking branch 'dechamps/sptpsabort' into 1.1 - -commit 19d16e40ccfb39461eda5336f4e754e10a640aba -Author: Jochen Voss -Date: Fri Mar 13 11:05:22 2015 +0000 - - Add a new --syslog option for tincd. - - This commit adds a new command line option for tincd which allows to - use tincd in non-detached mode with log messages still going to - syslog. The motivation for this change is to ease use of tincd - in Docker containers. - -commit 2e7f68ad2b51648b89c4b5c61aeb4cec67c2fbbb -Author: Etienne Dechamps -Date: Sun Mar 8 17:32:39 2015 +0000 - - Don't abort() willy-nilly in SPTPS code. - - If receive_handshake() or the receive_record() user callback returns an - error, sptps_receive_data_datagram() crashes the entire process. This is - heavy-handed, makes tinc very brittle to certain failures (i.e. - unexpected packets), and is inconsistent with the rest of SPTPS code. - -commit c23e50385d9de538af676706596f6508b2ceb01a -Author: Etienne Dechamps -Date: Sun Mar 8 14:32:01 2015 +0000 - - Fix UDP/MTU discovery in intermediate SPTPS UDP relays. - - Refactoring commit 81578484dc74fd92f1b01f71f882016f120ab1de seems to - have introduced a regression as it moved discovery code away from - send_sptps_data_priv() and within send_packet(). The issue is, - send_packet() is not called when the node is simply relaying an UDP - SPTPS packet: indeed, send_sptps_data_priv() is called directly from - handle_incoming_vpn_data() in that case. - - As a result, try_tx_sptps() is not called in the relaying case, which in - practice means that a relay doesn't initiate UDP/MTU discovery with the - next relay (unless some other activity compels it to do so). This can - result in packets getting sent over TCP instead of UDP from the relay. - -commit 0f8e2cc78cafe47a087d3fc9b480551b841aeb30 -Author: Etienne Dechamps -Date: Sun Mar 8 14:20:15 2015 +0000 - - Fix dynamic UDP SPTPS relaying. - - Refactoring commit 0e653260478005eb7c824a9a1a3df04f39938cd6 broke UDP - SPTPS relaying by accidently removing try_tx_sptps() logic related to - establishing connectivity to so-called "dynamic" relays (i.e. relays - that are not specified by IndirectData configuration statements, but - are used on-the-fly to circumvent loss of direct UDP connectivity). - - Specifically, the TX path was not trying to establish a tunnel to - dynamic relays (nexthop) anymore. This meant that MTU was not being - discovered with dynamic relays, which basically meant that all packets - being sent to dynamic relays went over TCP, thereby defeating the whole - purpose of SPTPS UDP relaying. - - Note that this bug could easily go unnoticed if a tunnel was established - with the dynamic tunnel for some other reason (i.e. exchanging actual - data packets with the relay node). - -commit 537c3528863c4736e877c4d1b6c6579940e6df5d -Author: xentec -Date: Tue Feb 17 04:02:35 2015 +0100 - - Fix compile errors introduced in cfe9285adf391ab66faeb5def811fe08e47a221a - - Compiling with `--disable-legacy-protocol` resulted in failure caused by the missing exclusion of some symbols in net_packet.c. - -commit cffcaf966b65a61943a00120f1ec5c868c917c1f -Author: Guus Sliepen -Date: Mon Feb 16 08:42:30 2015 +0100 - - Suppress warnings about parsing Ed25519 keys when they are not present. - -commit 833a8a048b22612cd12d703d55a71448b7179b4a -Author: Guus Sliepen -Date: Mon Feb 16 08:26:49 2015 +0100 - - Document that --force should precede commands. - -commit 85000a30ca68d3c8e9a98eb9537f4d1505bd849e -Author: Sven-Haegar Koch -Date: Tue Feb 10 01:17:12 2015 +0100 - - Fixed variables.test testsuite after 'Make "tinc add" idempotent.' change. - -commit 4b2ddded2c8ae1a1a5930637552eeb48f30d6530 -Author: Guus Sliepen -Date: Mon Feb 9 15:23:59 2015 +0100 - - Make "tinc add" idempotent. - - When calling "tinc add" multiple times with the same variable and value, - make sure only one unique line is added to the configuration file. - -commit 0b310bf406dbe58afe37fa31156b9ea47599d7be -Author: Guus Sliepen -Date: Mon Feb 9 15:16:36 2015 +0100 - - Always call res_init() before getaddrinfo(). - - Unfortunately, glibc assumes that /etc/resolv.conf is a static file that - never changes. Even on servers, /etc/resolv.conf might be a dynamically - generated file, and we never know when it changes. So just call - res_init() every time, so glibc uses up-to-date nameserver information. - -commit 268e3ffca7b45cfc736e1bc9bec7a113c6c45701 -Author: Guus Sliepen -Date: Thu Jan 15 22:57:56 2015 +0100 - - Add the "fsck" command to the CLI. - - This will report possible problems in the configuration files, and in - some cases offers to fix them. - - The code is far from perfect yet. It expects keys to be in their default - locations, it doesn't check for Public/PrivateKey[File] statemetns yet. - It also does not correctly handle Ed25519 public keys yet. - -commit a95e182d9ca54960383bfe3950b2b798e1f24f9e -Author: Guus Sliepen -Date: Mon Jan 12 14:43:32 2015 +0100 - - Improve packet source detection. - - When no UDP communication has been done yet, tinc establishes a guess - for the UDP address+port of each node. However, when there are multiple nodes - behind a NAT, tinc will guess the exact same address+port combination - for them, because it doesn't know about the NAT mappings yet. So when - receiving a packet, don't trust that guess unless we have confirmed UDP - communication. - - This ensures try_harder() is called in such cases. However, this - function was actually very inefficient, trying to verify packets - multiple times for nodes with multiple edges. Only call try_mac() at - most once per node. - -commit ae5b56c03d1e1af7561d7f1d1d8a333c3a9691ff -Author: Guus Sliepen -Date: Sun Jan 11 17:44:50 2015 +0100 - - Send gratuitous type 2 probe replies. - - If we receive any traffic from another node, we periodically send back a - gratuitous type 2 probe reply with the maximum received packet length. - On the other node, this causes the udp and perhaps mtu probe timers to - be reset, so it does not need to send a probe request. Gratuitous probe - replies from another node also count as received traffic for this - purpose, so for nodes that also have a meta-connection, UDP keepalive - packets in principle can now solely be type 2 replies. This reduces the - amount of probe traffic even more. - - To work, gratuitous replies should be sent slightly more often than - udp_discovery_keepalive_interval, so probe requests won't be triggered. - This also means that the timer resolution must be smaller than the - difference between the two, and at the moment it's kind of a hack. - -commit 7b76b7ac35b49b8a94ad91c432886a0a54e144d1 -Author: Guus Sliepen -Date: Sun Jan 11 16:14:05 2015 +0100 - - Send the size of the largest recently received packets in type 2 probe replies. - -commit 79b6adb489dde4ae92207ae7b9146f4e141c946c -Author: Guus Sliepen -Date: Sun Jan 11 16:12:57 2015 +0100 - - Move UDP probe reply code into its own function. - - This reduces the level of indentation, and prepares for sending gratuitous type 2 probe replies. - -commit f0afde0467443969eb408090d6b8ee542768ee33 -Author: Guus Sliepen -Date: Sun Jan 11 16:10:58 2015 +0100 - - Keep track of the largest UDP packet size received from a node. - -commit d63941593736fbf268f2770d42e7f3f6a2132fae -Author: Guus Sliepen -Date: Sun Jan 11 15:38:56 2015 +0100 - - Move detection of PMTU decrease to try_mtu(). - - When we have fixed the PMTU, n->mtuprobes == -1. When we send MTU probes - when mtuprobes == -1, decrease mtuprobes, and reset it back to -1 in - mtu_probe_h(). If mtuprobes < -1, send MTU probes every second, until - mtuprobes <= -4, in which case we will restart MTU discovery. - -commit e97e9b22cb6061070611212a06756fb493846955 -Author: Guus Sliepen -Date: Sun Jan 11 14:44:27 2015 +0100 - - Send MTU probes only once every PingInterval. - -commit 088b5fd9ee6d5f566e8726eae861cbc7cd832b17 -Author: Guus Sliepen -Date: Sun Jan 11 14:44:15 2015 +0100 - - Remove RTT and packet loss estimation code. - - This is not working at all anymore. Just remove it, and we'll do another - attempt at RTT, bandwidth and packet loss estimation after the new - probing code stabilizes. - -commit ce7079f4af3157eaef514d6d160933a016b2ab62 -Author: Guus Sliepen -Date: Sun Jan 11 13:53:16 2015 +0100 - - Only send small packets during UDP probes. - - We are trying to decouple UDP probing from MTU probing, so only send - very small packets during UDP probing. This significantly reduces the - amount of traffic sent (54 to 67 bytes per probe instead of 1500 bytes). - - This means the MTU probing code takes over sending PMTU sized probes, - but this commit does not take care of detecting PMTU decreases. - -commit e4077c00c6fead63467d296c89d5afc2860e2935 -Author: Guus Sliepen -Date: Sun Jan 11 13:51:55 2015 +0100 - - Immediately send our key when a meta-connection is established. - - This is what 1.0 does, and speeds up the UDP probing. - -commit eb7a0db18ea71a44999d6a37b4b179dac0ed9bc7 -Author: Guus Sliepen -Date: Sun Jan 11 13:31:01 2015 +0100 - - Always keep UDP mappings alive for nodes that also have a meta-connection. - - This is necessary for assisting with UDP hole punching. But we don't - need to know the PMTU for this, so only send UDP probes. - -commit 545ecb339654573b3ee91bffb45c8282154885c6 -Author: Guus Sliepen -Date: Sun Jan 11 01:52:37 2015 +0100 - - Fix segfault when sptps_test cannot open the key files. - -commit 69d4ccc43781152dc90521b3f517b0d9588ae207 -Author: Etienne Dechamps -Date: Tue Dec 30 09:56:30 2014 +0000 - - Fix typo in logging statement. - - This was introduced in cfe9285adf391ab66faeb5def811fe08e47a221a. - -commit 6fcfe763aa54e0522e726dc088b23d24899794d8 -Author: Guus Sliepen -Date: Sat Jan 10 23:58:35 2015 +0100 - - Don't send probe replies if we don't have the other's key. - - This can happen with the legacy protocol. Don't try to send anything - back in this case, otherwise it will be sent via TCP, which is silly. - -commit f3801cb54311da2c30cbe27cd66559a2ea5daa91 -Author: Guus Sliepen -Date: Sat Jan 10 23:52:23 2015 +0100 - - Proactively send our own key when we request another node's key. - -commit c26bb47af130d48d003afd29af4d7ea6ad0538c5 -Author: Guus Sliepen -Date: Sat Jan 10 23:33:55 2015 +0100 - - Fix size of type 2 probe replies. - - Type 2 replies should be as small as possible. The minimum payload size - for probe packets is 14 bytes, otherwise they won't be recognized as - such. - -commit 0209f12d27d29f3aedc09b228bd289305851c75d -Author: Guus Sliepen -Date: Sat Jan 10 23:00:51 2015 +0100 - - Correctly estimate the initial MTU for legacy packets. - -commit 0e653260478005eb7c824a9a1a3df04f39938cd6 -Author: Guus Sliepen -Date: Sat Jan 10 22:28:47 2015 +0100 - - Try to clarify the new code in net_packet.c a bit. - - Mainly by trying to reduce complex if statements, by splitting try_tx() into try_tx_legacy() and - try_tx_sptps(), since they don't share a lot of code. - -commit 6056f1c13bb37bf711dff9c25a6eaea99f14d31f -Author: Guus Sliepen -Date: Sat Jan 10 22:26:33 2015 +0100 - - Remember whether we sent our key to another node. - - In tinc 1.0.x, this was tracked in node->inkey, however in tinc 1.1 we have an abstraction layer for - the legacy cipher and digest, and we don't keep an explicit copy of the key around. We cannot use - cipher_active() or digest_active(), since it is possible to set both to the null algorithm. So add a bit to - node_status_t. - -commit f1f2df07387bc48a3b165c85a0493ff2774de737 -Author: Guus Sliepen -Date: Sun Jan 4 16:00:02 2015 +0100 - - Use global "now" in try_udp() and try_mtu(). - -commit b737103a9187e0191dbc1995da3399ab3dbcdc66 -Author: Guus Sliepen -Date: Sun Jan 4 14:19:23 2015 +0100 - - Use void pointers for opaque data blobs in the SHA512 code. - -commit 4b42518813de7459a1fb264fe9ddfaf066ecc22b -Author: Guus Sliepen -Date: Sun Jan 4 14:15:35 2015 +0100 - - Fix indentation and some whitespace issues. - -commit 07108117ceddaff0654f9def703e717c002f3e2d -Author: Etienne Dechamps -Date: Sat Jan 3 10:05:57 2015 +0000 - - Use a different UDP discovery interval if the tunnel is established. - - This introduces a new configuration option, - UDPDiscoveryKeepaliveInterval, which is used as the UDP discovery - interval once the UDP tunnel is established. The pre-existing option, - UDPDiscoveryInterval, is therefore only used before UDP connectivity - is established. - - The defaults are set so that tinc sends UDP pings more aggressively - if the tunnel is not established yet. This is appropriate since the - size of probes in that scenario is very small (16 bytes). - -commit 06345f89b9a1e9acaf74cbbf896559b4286c102e -Author: Etienne Dechamps -Date: Thu Jan 1 16:59:45 2015 +0000 - - Recalculate and resend MTU probes if they are too large for the system. - - Currently, if a MTU probe is sent and gets rejected by the system - because it is too large (i.e. send() returns EMSGSIZE), the MTU - discovery algorithm is not aware of it and still behaves as if the probe - was actually sent. - - This patch makes the MTU discovery algorithm recalculate and send a new - probe when this happens, so that the probe "slot" does not go to waste. - -commit f89319f9815da5ece8e96f1a2a777fb6d2e31c33 -Author: Etienne Dechamps -Date: Wed Dec 31 16:21:08 2014 +0000 - - Fine-tune the MTU discovery multiplier for the maxmtu < MTU case. - - The original multiplier constant for the MTU discovery algorithm, 0.97, - assumes a somewhat pessmistic scenario where we don't get any help from - the OS - i.e. maxmtu never changes. This can happen if IP_MTU is not - usable and the OS doesn't reject overly large packets. - - However, in most systems the OS will, in fact, contribute to the MTU - discovery process. In these situations, an actual MTU equal to maxmtu - is quite likely (as opposed to the maxmtu = 1518 case where that is - highly unlikely, unless the physical network supports jumbo frames). - It therefore makes sense to use a multiplier of 1 - that will make the - first probe length equal to maxmtu. - - The best results are obtained if the OS supports the getsockopt(IP_MTU) - call, and its result is accurate. In that case, tinc will typically fix - the MTU after one single probe(!), like so: - - Using system-provided maximum tinc MTU for foobar (1.2.3.4 port 655): 1442 - Sending UDP probe length 1442 to foobar (1.2.3.4 port 655) - Got type 2 UDP probe reply 1442 from foobar (1.2.3.4 port 655) - Fixing MTU of foobar (1.2.3.4 port 655) to 1442 after 1 probes - -commit bce17c83e871cb8a8c9158045eaf13f1be4b3d13 -Author: Etienne Dechamps -Date: Wed Dec 31 16:12:11 2014 +0000 - - Add IP_MTU-based maxmtu estimation. - - Linux provides a getsockopt() option, IP_MTU, to get the kernel's best - guess at a connection MTU. In practice, it seems to return the MTU of - the physical interface the socket is using. - - This patch uses this option to initialize maxmtu to a better value when - MTU discovery starts. - - Unfortunately, this is not supported on Windows. Winsock has options - such as SO_MAX_MSG_SIZE, SO_MAXDG and SO_MAXPATHDG but they seem useless - as they always return absurdly large values (typically, 65507), as - confirmed by http://support.microsoft.com/kb/822061/ - -commit c1532035e2850dc4ec0eb22a6d51208e3128eb94 -Author: Etienne Dechamps -Date: Wed Dec 31 09:26:14 2014 +0000 - - Don't send MTU probes smaller than 512 bytes. - - If MTU discovery comes up with an MTU smaller than 512 bytes (e.g. due - to massive packet loss), it's pretty much guaranteed to be wrong. Even - if it's not, most Internet applications assume the MTU will be at least - 512, so fixing the MTU to a small value is likely to cause trouble - anyway. - - This also makes the discovery algorithm converge even faster, since the - interval it has to consider is smaller. - -commit 172cbe6771fd3b98233f71e42ac9c9407d534568 -Author: Etienne Dechamps -Date: Tue Dec 30 17:02:38 2014 +0000 - - Adjust MTU probe counts. - - The recently introduced new MTU discovery algorithm converges much - faster than the previous one, which allows us to reduce the number - of probes required before we can confidently fix the MTU. This commit - reduces the number of initial discovery probes from 90 to 20. With the - new algorithm this is more than enough to get to the precise (byte-level - accuracy) MTU value; in cases of packet loss or weird MTU values for - which the algorithm is not optimized, we should get close to the actual - value, and then we rely on MTU increase detection (steady state probes) - to fine-tune it later if the need arises. - - This patch also triggers MTU increase detection even if the MTU we have - is off by only one byte. Previously we only did that if it was off by at - least 8 bytes. Considering that (1) this should happen less often, - (2) restarting MTU discovery is cheaper than before and (3) having MTUs - that are subtly off from their intended values by just a few bytes - sounds like trouble, this sounds like a good idea. - -commit 24d28adf64934c8d726959e25dce8c10dbd10d1f -Author: Etienne Dechamps -Date: Tue Dec 30 16:34:48 2014 +0000 - - Use a smarter algorithm for choosing MTU discovery probe sizes. - - Currently, tinc uses a naive algorithm for choosing MTU discovery probe - sizes, picking a size at random between minmtu and maxmtu. - - This is of course suboptimal - since the behavior of probes is - deterministic (assuming no packet loss), it seems likely that using a - non-deterministic discovery algorithm will not yield the best results. - Furthermore, the randomness introduces a lot of variation in convergence - times. - - The random solution also suffers from pathological cases - since it's - using a uniform distribution, it doesn't take into account the fact that - it's often more interesting to send small probes rather than large ones, - because getting replies is the only way we can make progress (assuming - the worst case scenario in which the OS doesn't know anything, therefore - keeping maxmtu constant). This can lead to absurd situations where the - discovery algorithm is close to the real MTU, but can't get to it - because the random number generator keeps generating numbers that are - past it. - - The algorithm implemented in this patch aims to improve on the naive - random algorithm. It is organized around "cycles" of 8 probes; the sizes - of the probes decrease as we go through the cycle, thus making sure the - algorithm can cover lots of ground quickly (in case we're far from - actual MTU), but also examining the local area (in case we're close to - actual MTU). Using cycles ensures that the algorithm will "go back" to - large probes to better cover the new interval and to protect against - packet loss. - - For the probe size itself, various mathematical models were simulated in - an attempt to find the one that converges the fastest; it has been - determined that using an exponential based on the size of the remaining - interval was the most effective option. The exponential is adjusted with - a magic multiplier fine-tuned to make tinc jump to the "most - interesting" (i.e. 1400+) section as soon as discovery starts. - - Simulations indicate that assuming no packet loss and no help from the - OS (i.e. maxmtu stays constant), this algorithm will typically converge - to the *exact* MTU value in less than 10 probes, and will get within 8 - bytes in less than 5 probes, for actual MTUs between 1417 and ~1450 - (which is the range the algorithm is fine-tuned for). In contrast, the - previous algorithm gives results all over the place, sometimes taking - 30+ probes to get in the ballpark. Because of the issues with the - distribution, the previous algorithm sometimes never gets to the precise - MTU value within any reasonable amount of time - in contrast, the new - algorithm will always get to the precise value in less than 30 probes, - even if the actual MTU is completely outside the optimized range. - -commit c22560ae3283a8f5f12eee8ee4dcaa5e65ee8cf9 -Author: Etienne Dechamps -Date: Tue Dec 30 10:47:56 2014 +0000 - - Remove bandwidth estimation code. - - tinc bandwidth estimation has always been quite unreliable (at least in - my experience), but there's no chance of it working anymore since the - last changes to MTU discovery code, because packets are not sent in - batches of three anymore. - - This commit removes the dead code - fortunately, nothing depends on this - estimation (it's not even shown in node info). We probably need be - smarter about this if we do want this estimation back. - -commit 1b972f22733dc979568bc0ad8ebe0c711887e447 -Author: Etienne Dechamps -Date: Tue Dec 30 10:16:32 2014 +0000 - - Send one MTU probe at a time. - - Currently, tinc sends MTU probes in batches of three every second. This - commit changes that to send one packet every 333 milliseconds instead. - - This change brings two benefits: - - - It makes MTU probing faster, because MTU probe lengths are calculated - based on minmtu, and minmtu is adjusted based on the replies. When - sending batches of three packets, all three packets are based on the - same minmtu estimation; in contrast, by sending one packet more - frequently, each subsequent packet can benefit from the replies that - have been received since the last packet was sent. As a result, MTU - discovery converges much faster (2-3 times as fast, typically). - - - It reduces network spikiness - it's more network-friendly to send - one packet from time to time as opposed to sending bursts. - -commit 5bdc1f2b82869d379812879334dbf2b549ff48db -Author: Etienne Dechamps -Date: Thu Jan 1 16:04:08 2015 +0000 - - Use -1 to identify the post-initial MTU discovery state. - - This is a minor cosmetic nit to emphasise the distinction between the - initial MTU discovery phase, and the post-initial phase (i.e. maxmtu - checking). - - Furthermore, this is an improvement with regard to the DRY (Don't - Repeat Yourself) principle, as the maximum mtuprobes value is only - written once. - -commit df6f67895723dd0c4226fa0f94257245a81a273f -Author: Etienne Dechamps -Date: Thu Jan 1 10:32:14 2015 +0000 - - Fix MTU as soon as possible. - - If a probe reply is received that makes minmtu equal to maxmtu, we - have to wait until try_mtu() runs to realize that. Since try_mtu() - runs after a packet is sent, this means there is at least one packet - (possibly more, depending on timing) that won't benefit from the - fixed MTU. This also happens when maxmtu is updated from the send() - path. - - This commit fixes that by making sure we check whether the MTU can be - fixed every time minmtu or maxmtu is touched. - -commit 97cf4783188b8027d2309ce594fea5fc6daf31d1 -Author: Etienne Dechamps -Date: Mon Dec 29 17:05:19 2014 +0000 - - Move try_mtu() closer to try_tx(). - - This moves related functions together, and is a pure cut-and-paste - change. The reason it was not done in the previous commit is because it - would have made the diff harder to review. - -commit 98716a227ee39fdcdfafa7309adb73499311a2ce -Author: Etienne Dechamps -Date: Mon Dec 29 16:47:49 2014 +0000 - - Move PMTU discovery code into the TX path. - - Currently, the PMTU discovery code is run by a timeout callback, - independently of tunnel activity. This commit moves it into the TX - path, meaning that send_mtu_probe_handler() is only called if a - packet is about to be sent. Consequently, it has been renamed to - try_mtu() for consistency with try_tx(), try_udp() and try_sptps(). - - Running PMTU discovery code only as part of the TX path prevents - PMTU discovery from generating unreasonable amounts of traffic when - the "real" traffic is negligible. One extreme example is sending one - real packet and then going silent: in the current code this one little - packet will result in the entire PMTU discovery algorithm being run - from start to finish, resulting in absurd write traffic amplification. - With this patch, PMTU discovery stops as soon as "real" packets stop - flowing, and will be no more aggressive than the underlying traffic. - - Furthermore, try_mtu() only runs if there is confirmed UDP - connectivity as per the UDP discovery mechanism. This prevents - unnecessary network chatter - previously, the PMTU discovery code - would send bursts of (potentially large) probe packets every second - even if there was nothing on the other side. With this patch, the - PMTU code only does that if something replied to the lightweight UDP - discovery pings. - - These inefficiencies were made even worse when the node is not a - direct neighbour, as tinc will use PMTU discovery both on the - destination node *and* the relay. UDP discovery is more lightweight for - this purpose. - - As a bonus, this code simplifies overall code somewhat - state is - easier to manage when code is run in predictable contexts as opposed - to "surprise callbacks". In addition, there is no need to call PMTU - discovery code outside of net_packet.c anymore, thereby simplifying - module boundaries. - -commit eef792c01ed1704c03d55163de3f302a3c1d42fa -Author: Etienne Dechamps -Date: Mon Dec 29 16:11:04 2014 +0000 - - Remove PMTU discovery code redundant with UDP discovery. - - This is a rewrite of the send_mtu_probe_handler() function to make it - focus on the actual discovery of PMTU. In particular, the PMTU - discovery code doesn't care about tunnel state anymore - it only cares - about doing the initial PMTU discovery, and once that's done, making - sure PMTU did not increase by checking it from time to time. All other - duties have already been rewritten in the UDP discovery code. - - As a result, the send_mtu_probe_handler(), which previously implemented - a nightmarish state machine which was very difficult to follow and - understand, has been massively simplified. We moved from four persistent - states to only two - initial discovery and steady state. - - Furthermore, a side effect is that network chatter is reduced: instead - of sending bursts of three minmtu-sized packets in the steady state, - there is only one such packet that's sent from the UDP discovery code. - However, that introduces a slight regression in the bandwidth estimation - code, which relies on three-packet bursts in order to function. - Considering that this estimation is extremely unreliable (in my - experience) and isn't relied on by anything, this seems like an - acceptable regression. - -commit 88026f27715774a7647c109ba5594068f0ba56af -Author: Etienne Dechamps -Date: Mon Dec 29 15:40:55 2014 +0000 - - Move responsibility for local discovery to UDP discovery. - - Since UDP discovery is the place where UDP feasibility is checked, it - makes sense to test for local connectivity as well. This was previously - done as part of PMTU discovery. - -commit 7939ee12836bf2ef772f2a6a1e805ee0d64a8e70 -Author: Etienne Dechamps -Date: Mon Dec 29 10:34:39 2014 +0000 - - Add UDP discovery mechanism. - - This adds a new mechanism by which tinc can determine if a node is - reachable via UDP. The new mechanism is currently redundant with the - PMTU discovery mechanism - that will be fixed in a future commit. - - Conceptually, the UDP discovery mechanism works similarly to PMTU - discovery: it sends UDP probes (of minmtu size, to make sure the tunnel - is fully usable), and assumes UDP is usable if it gets replies. It - assumes UDP is broken if too much time has passed since the last reply. - - The big difference with the current PMTU discovery mechanism, however, - is that UDP discovery probes are only triggered as part of the - packet TX path (through try_tx()). This is quite interesting, because - it means tinc will never send UDP pings more often than normal packets, - and most importantly, it will automatically stop sending pings as soon - as packets stop flowing, thereby nicely reducing network chatter. - - Of course, there are small drawbacks in some edge cases: for example, - if a node only sends one packet every minute to another node, these - packets will only be sent over TCP, because the interval between packets - is too long for tinc to maintain the UDP tunnel. I consider this a - feature, not a bug: I believe it is appropriate to use TCP in scenarios - where traffic is negligible, so that we don't pollute the network with - pings just to maintain a UDP tunnel that's seeing negligible usage. - -commit 5d6478b9fbb7379fe6017b2b74c0f1ccb3d2501f -Author: Etienne Dechamps -Date: Sun Dec 28 17:29:03 2014 +0000 - - Move try_sptps() closer to try_tx(). - - This moves related functions together. try_tx() is at the right place - since its only caller is send_packet(). - - This is a pure cut-and-paste change. The reason it was not done in the - previous commit is because it would have made the diff harder to review. - -commit 81578484dc74fd92f1b01f71f882016f120ab1de -Author: Etienne Dechamps -Date: Sun Dec 28 17:16:27 2014 +0000 - - Add the try_tx() function. - - Currently, the TX path (starting from send_packet()) in tinc has three - responsabilities: - - - Making sure packets can be sent (e.g. fetching SPTPS keys); - - Making sure they can be sent optimally (e.g. fetching non-SPTPS keys - so that UDP can be used); - - Sending the actual packet, if feasible. - - The first two are closely related; the third one, however, can be - cleanly separated from the other two - meaning, we can loosen code - coupling between sending packets and "optimizing" the way packets are - sent. This will become increasingly important as future commits will - move more tunnel establishment and maintenance code into the TX path, - so we will benefit from a cleaner separation of concerns. - - This is especially relevant because of the dual nature of the TX path - (SPTPS versus non-SPTPS), which can make things really complicated when - trying to share low-level code between both. - - In this commit, code related to establishing or improving tunnels is - moved away from the core TX path by introducing the "try_*()" family of - function, of which try_sptps() already existed before this commit. - - This is a pure refactoring; this commit shouldn't introduce any change - in behavior. - -commit 950edc0744dfa04790ae274e8b7f55b1a990a43c -Author: Etienne Dechamps -Date: Sun Oct 12 19:44:33 2014 +0100 - - Clarify the send_mtu_probe() function. - - This cleans up the PMTU probing function a little bit. It moves the - low-level sending of packets to a separate function, so that the code - reads naturally instead of using a weird for loop with "special - indexes". In addition, comments are moved inside the body of the - function for additional context. - - This shouldn't introduce any change of behavior, except for local - discovery which has some minor logic fixes and which now always uses - small packets (16 bytes) because there's no need for a full-length - probe just to try the local network. - -commit d28f33228635e78dac8f9e9bcaec92690f2ca10a -Author: Guus Sliepen -Date: Thu Jan 1 00:52:39 2015 +0100 - - Fixes for bugs in src/Makefile.am and tincctl.c introduced by cfe9285adf391ab66faeb5def811fe08e47a221a. - -commit 4d50f9f3485503099f5cb6e8486e9b98b72cb9be -Author: Guus Sliepen -Date: Tue Dec 30 11:16:08 2014 +0100 - - Add missing nolegacy/crypto.c and prf.c. - -commit cfe9285adf391ab66faeb5def811fe08e47a221a -Author: Guus Sliepen -Date: Mon Dec 29 22:57:18 2014 +0100 - - Allow tinc to be compiled without OpenSSL. - - The option "--disable-legacy-protocol" was added to the configure - script. The new protocol does not depend on any external crypto - libraries, so when the option is used tinc is no longer linked to - OpenSSL's libcrypto. - -commit 8d32b283b016e205b051b0bacb49a1e86fd5e1bc -Author: Guus Sliepen -Date: Sat Dec 27 09:22:31 2014 +0100 - - Releasing 1.1pre11. - -commit db465434e2736f6e052e5c52d3613ad81b4bde10 -Author: Guus Sliepen -Date: Sat Dec 27 09:20:46 2014 +0100 - - Add BroadcastSubnet and DeviceStandby options to the manual and completion. - -commit 26d3ee0dd9b770a857615752b5c5588be0354a16 -Author: Guus Sliepen -Date: Sat Dec 27 09:08:34 2014 +0100 - - Better default paths for log and PID files on Windows. - -commit b78436ff1e9afd767c3da473d34b7553d8411b6a -Author: Guus Sliepen -Date: Fri Dec 26 18:22:13 2014 +0100 - - Remove AES-GCM support. - -commit 128a37397432e5e63099633e275c65a652c16673 -Author: Guus Sliepen -Date: Fri Dec 26 18:12:28 2014 +0100 - - Linux doesn't like .PHONY .o files. - - In order to please every OS, make version.c .PHONY again, and add an - empty rule to make version.c. - -commit 69689f908b0c9a14b7108b7ab8edd92facc53ddf -Author: Guus Sliepen -Date: Fri Dec 26 17:53:40 2014 +0100 - - We don't depend on ECDH functions from OpenSSL anymore. - -commit aa2d4f8dd9bab794dd197b92ba54e6428400555f -Author: Guus Sliepen -Date: Fri Dec 26 15:58:28 2014 +0100 - - BSD make doesn't like .PHONY .c files. - - It then thinks there should be a rule to make the .c file, which does - not exist of course. Luckily, we can tell it that version.o is .PHONY, - and this will still cause the .o file to be regenerated and linked into - the binaries everytime make is called. - -commit 8ee4004edfbc79b1a17bf03c262f063f2f4c128d -Author: Guus Sliepen -Date: Fri Dec 26 15:40:09 2014 +0100 - - Check whether res_init() really lives in libresolv. - - On some platforms (Mac OS X for example), the res_init() function requires - linking with libresolv. On others (Linux, OpenBSD for example), res_init() - lives in libc. - -commit 9f20922d62d258d7f5f1ef30dcd538c661062439 -Author: Guus Sliepen -Date: Fri Dec 26 14:59:15 2014 +0100 - - Update THANKS file. - -commit 880d74ad2d8a6d73c2e94ec54df542b88dc0c6f4 -Author: Guus Sliepen -Date: Fri Dec 26 14:38:01 2014 +0100 - - Allow running tinc without RSA keys. - - This allows one to run tinc with only Ed25519 keys, forcing tinc to - always use the SPTPS protocol. - -commit 266afc6c63d3d02584feb24b69063f97057daac8 -Merge: 7730d5f3 c269a17c -Author: Guus Sliepen -Date: Thu Dec 25 18:13:24 2014 +0100 - - Merge remote-tracking branch 'groxxda/gui-fixes' into 1.1 - -commit 7730d5f3ed9bd7c011dced5808130ffcbd74ea6b -Author: Etienne Dechamps -Date: Sun Oct 12 12:14:46 2014 +0100 - - Use plain old PACKET for TCP packets sent directly to a neighbor. - - Currently, when sending packets over TCP where the final recipient is - a node we have a direct metaconnection to, tinc first establishes a - SPTPS handshake between the two neighbors. - - It turns out this SPTPS tunnel is not actually useful, because the - packet is only being sent over one metaconnection with no intermediate - nodes, and the metaconnection itself is already secured using a separate - SPTPS handshake. - - Therefore it seems simpler and more efficient to simply send these - packets directly over the metaconnection itself without any additional - layer. This commits implements this solution without any changes to the - metaprotocol, since the appropriate message already exists: it's the - good old "plaintext" PACKET message. - - This change brings two significant benefits: - - - Packets to neighbors can be sent immediately - there is no initial - delay and packet loss previously caused by the SPTPS handshake; - - - Performance of sending packets to neighbors over TCP is greatly - improved since the data only goes through one round of encryption - instead of two. - - Conflicts: - src/net_packet.c - -commit 0356efecb6385b59a69bea220057396d6daa30bc -Author: Etienne Dechamps -Date: Sun Oct 12 11:41:08 2014 +0100 - - Don't spontaneously start SPTPS with neighbors. - - Currently, when tinc establishes a metaconnection, it automatically - starts a VPN SPTPS tunnel with the other side of the metaconnection. - - It is not clear what this is trying to accomplish. Having a - metaconnection with a node does not necessarily mean we're going to send - packets to that node. This patch removes this behavior, thereby - simplifying code paths and removing unnecessary network chatter. - - Naturally, this introduces a slight delay (as well as at least one - initial packet loss) between the moment a metaconnection is established - and the moment VPN packets can be exchanged between the two nodes. - However this is no different to the non-neighbor case, so it makes - things more consistent and therefore easier to reason about. - -commit 6b92ac505d2cd5c7e390d49bf1f0b399ef9f8327 -Author: Guus Sliepen -Date: Wed Dec 24 22:23:24 2014 +0100 - - Add a variable offset to vpn_packet_t, drop sptps_packet_t. - - The offset value indicates where the actual payload starts, so we can - process both legacy and SPTPS UDP packets without having to do casting - tricks and/or moving memory around. - -commit 107d9c7da5b206425a8e1643a6849ea990f725f8 -Author: Guus Sliepen -Date: Wed Dec 24 22:15:40 2014 +0100 - - Use void pointers for opaque data blobs in the SPTPS code. - -commit 3df86ef17bce9f24c3dad79ccc2b17aa6e93ea34 -Author: Guus Sliepen -Date: Wed Dec 24 17:31:33 2014 +0100 - - Fix memory leaks found by Valgrind. - -commit d00d8dbb9b122a17ef93090de10396ebdd2c4a84 -Author: Guus Sliepen -Date: Wed Dec 24 17:06:05 2014 +0100 - - Don't use myself->name in device_disable(), it's already freed. - -commit 313de46e70b249de2938b04e7fc9c3872d99474a -Author: Guus Sliepen -Date: Wed Dec 24 16:59:08 2014 +0100 - - Don't pass uninitialized bytes to ioctl(). - -commit a99ded7d987c3242f972162e02767c498257f2b8 -Author: Guus Sliepen -Date: Wed Dec 24 16:54:12 2014 +0100 - - Avoid using OpenSSL's random number functions. - -commit 199573f1e834290290a1c278072a153b90443b05 -Author: Guus Sliepen -Date: Sun Dec 14 13:05:30 2014 +0100 - - Fix reception of SPTPS UDP packets. - - Some bugs were introduced in 46fa12e666badb79e480c4b2399787551f8266d0. - -commit 558b19c2432d938afc4a659668bd461ace6ed744 -Author: Guus Sliepen -Date: Sun Dec 14 12:42:03 2014 +0100 - - Fix segfault when receiving UDP packets with an unknown source address. - -commit 5104001bae7d09040703ddbe18cf8781c7aaa94f -Author: Guus Sliepen -Date: Mon Dec 8 08:43:15 2014 +0100 - - Changes that should have been in commit 46fa12e666badb79e480c4b2399787551f8266d0. - -commit 46fa12e666badb79e480c4b2399787551f8266d0 -Author: Guus Sliepen -Date: Mon Dec 8 00:58:09 2014 +0100 - - Make UDP packet handling more efficient. - - Limit the amount of address/ID lookups to the minimum in all cases: - - 1) Legacy packets, need an address lookup. - 2) Indirect SPTPS packets, need an address lookup + two ID lookups. - 3) Direct SPTPS packets, need an ID or an address lookup. - - So we start with an address lookup. If the source is an 1.1 node, we know it's an SPTPS packet, - and then the check for direct packets is a simple check if dstid is zero. If not, do the srcid and dstid - lookup. If the source is an 1.0 node, we don't have to do anything else. - - If the address is unknown, we first check whether it's from a 1.1 node by assuming it has a valid srcid - and verifying the packet. If not, use the old try_harder(). - -commit 263d9903826ffb65aec89bdf5d46f72bd183d467 -Author: Guus Sliepen -Date: Mon Dec 8 00:44:38 2014 +0100 - - Avoid memmove() for legacy UDP packets. - -commit c2319e90b16962fe899bc60abc8af0e2542bb176 -Author: Guus Sliepen -Date: Sun Dec 7 22:11:37 2014 +0100 - - Cache node IDs in a hash table for faster lookups. - -commit 9d48d5b7d48ad23e23eae02feae69bdc5ae80c8e -Author: Guus Sliepen -Date: Sun Dec 7 22:10:16 2014 +0100 - - Add an explicit hash_delete() function. - -commit 6062df4a0fa6214d21ac83d885087e9dbdac3f39 -Author: Guus Sliepen -Date: Sun Dec 7 21:42:20 2014 +0100 - - Better log messages when we already know the peer's key during an upgrade. - - If the peer presents a different one from the one we already know, log - an error. Otherwise, log an informational message, and terminate in the - same way as we would if we didn't already have that key. - -commit 148a4c9161735a76b0a4ce73ffaaec21d76ca702 -Author: Sven-Haegar Koch -Date: Fri Dec 5 03:06:44 2014 +0100 - - Try handling the case when the first side knows the ecdsa key of - the second, but the second not the key of the first. - (And both have the experimental protocol enabled) - -commit b90c42a33b78f22b7046da5a5445c712020f30eb -Author: Guus Sliepen -Date: Sun Dec 7 17:25:30 2014 +0100 - - Log an error message with the node's name when receiving bad SPTPS packets. - - The SPTPS code doesn't know about nodes, so when it logs an error about - a bad packet, it doesn't log which node it came from. So add a log - message with the node's name and hostname in receive_udppacket(). - -commit 660a2c7d1bf7f5fba905b525bc7c3b9a5ac2ec99 -Author: Guus Sliepen -Date: Sun Dec 7 17:20:18 2014 +0100 - - Check validity of Ed25519 key during an upgrade. - -commit 5716c8877fd705d5af36d82e27632b123fa5dde0 -Author: Sven-Haegar Koch -Date: Fri Dec 5 02:41:55 2014 +0100 - - Do not disconnect when no ecdsa key is known yet. - - This is the normal case when we support the experimental protocol, - but the other side is a tinc 1.0 which does not. - -commit dd6b0e65b96280235893705a947eac4a1c71276e -Author: Guus Sliepen -Date: Wed Dec 3 14:51:45 2014 +0100 - - Fix compiler warnings. - -commit 790b107f668a886c3b335e68b9440ef5152a2844 -Author: Etienne Dechamps -Date: Sat Oct 4 16:33:33 2014 +0100 - - Query the Linux device for its MAC address. - - On Linux, tinc doesn't know the MAC address of the TAP device until the - first read. This means that if no packets are sent through the - interface, tinc won't be able to figure out which MAC address to tag - incoming packets with. As a result, it is impossible to receive any - packet until at least one packet has been sent. - - When IPv6 is disabled Linux does not spontanously send any packets - when the interface comes up. At first users wonder why the node is not - responding to ICMP pings, and then as soon as at least one packet is - sent through the interface, pings mysteriously start working, resulting - in user confusion. - - This change fixes that problem by making sure tinc is aware of the - device's MAC address even before the first packet is sent. - -commit c269a17ca4d4e4946a3f8ab05da8cdd338d97ffb -Author: groxxda -Date: Tue Oct 14 22:18:56 2014 +0200 - - tinc-gui: Don't assign broadcast subnets to any node, fix parsing of Edges, fix diplay of Subnet.weight. - -commit 9a366544c297d5c558800f9ffc301e2cb5a6a672 -Author: Etienne Dechamps -Date: Sat Oct 4 15:01:11 2014 +0100 - - Make sure to discover MTU with relays. - - Currently, when tinc sends UDP SPTPS datagrams through a relay, it - doesn't automatically start discovering PMTU with the relay. This means - that unless something else triggers PMTU discovery, tinc will keep using - TCP when sending packets through the relay. - - This patches fixes the issue by explicitly establishing UDP tunnels with - relays. - -commit 63daebcd1ec2975c0c2ad8e0ee0fced33b1fbbf0 -Author: Etienne Dechamps -Date: Sat Oct 4 14:25:16 2014 +0100 - - Don't send MTU probes to nodes we can't reach directly. - - Currently, we send MTU probes to each node we receive a key for, even if - we know we will never send UDP packets to that node because of - indirection. This commit disables MTU probing between nodes that have - direct communication disabled, otherwise MTU probes end up getting sent - through relays. - - With the legacy protocol this was never a problem because we would never - request the key of a node with indirection enabled; with SPTPS this was - not a problem until we introduced relaying because send_sptps_data() - would simply ignore indirections, but this is not the case anymore. - - Note that the fix is implemented in a quick and dirty way, by disabling - the call to send_mtu_probe() in ans_key_h(); this is not a clean fix - because there's no code to resume sending MTU probes in case the - indirection disappears because of a graph change. - -commit 111040d7d1993c67246c52cbfd073183818655f9 -Author: Etienne Dechamps -Date: Sun Sep 28 12:38:06 2014 +0100 - - Add UDP datagram relay support to SPTPS. - - This commit changes the layout of UDP datagrams to include a 6-byte - destination node ID at the very beginning of the datagram (i.e. before - the source node ID and the seqno). Note that this only applies to SPTPS. - - Thanks to this new field, it is now possible to send SPTPS datagrams to - nodes that are not the final recipient of the packets, thereby using - these nodes as relay nodes. Previously SPTPS was unable to relay packets - using UDP, and required a fallback to TCP if the final recipient could - not be contacted directly using UDP. In that sense it fixes a regression - that SPTPS introduced with regard to the legacy protocol. - - This change also updates tinc's low-level routing logic (i.e. - send_sptps_data()) to automatically use this relaying facility if at all - possible. Specifically, it will relay packets if we don't have a - confirmed UDP link to the final recipient (but we have one with the next - hop node), or if IndirectData is specified. This is similar to how the - legacy protocol forwards packets. - - When sending packets directly without any relaying, the sender node uses - a special value for the destination node ID: instead of setting the - field to the ID of the recipient node, it writes a zero ID instead. This - allows the recipient node to distinguish between a relayed packet and a - direct packet, which is important when determining the UDP address of - the sending node. - - On the relay side, relay nodes will happily relay packets that have a - destination ID which is non-zero *and* is different from their own, - provided that the source IP address of the packet is known. This is to - prevent abuse by random strangers, since a node can't authenticate the - packets that are being relayed through it. - - This change keeps the protocol number from the previous datagram format - change (source IDs), 17.4. Compatibility is still preserved with 1.0 and - with pre-1.1 releases. Note, however, that nodes running this code won't - understand datagrams sent from nodes that only use source IDs and - vice-versa (not that we really care). - - There is one caveat: in the current state, there is no way for the - original sender to know what the PMTU is beyond the first hop, and - contrary to the legacy protocol, relay nodes can't apply MSS clamping - because they can't decrypt the relayed packets. This leads to - inefficient scenarios where a reduced PMTU over some link that's part of - the relay path will result in relays falling back to TCP to send packets - to their final destinations. - - Another caveat is that once a packet gets sent over TCP, it will use - TCP over the entire path, even if it is technically possible to use UDP - beyond the TCP-only link(s). - - Arguably, these two caveats can be fixed by improving the - metaconnection protocol, but that's out of scope for this change. TODOs - are added instead. In any case, this is no worse than before. - - In addition, this change increases SPTPS datagram overhead by another - 6 bytes for the destination ID, on top of the existing 6-byte overhead - from the source ID. - -commit 8dd1c8a020e3babf5054179b0d30e2aa850d2e2b -Author: Etienne Dechamps -Date: Sat Sep 27 18:13:33 2014 +0100 - - Prepend source node ID information to UDP datagrams. - - This commit changes the layout of UDP datagrams to include the 6-byte ID - (i.e. node name hash) of the node that crafted the packet at the very - beginning of the datagram (i.e. before the seqno). Note that this only - applies to SPTPS. - - This is implemented at the lowest layer, i.e. in - handle_incoming_vpn_data() and send_sptps_data() functions. Source ID is - added and removed there, in such a way that the upper layers are unaware - of its presence. - - This is the first stepping stone towards supporting UDP relaying in - SPTPS, by providing information about the original sender in the packet - itself. Nevertheless, even without relaying this commit already provides - a few benefits such as being able to reliably determine the source node - of a packet in the presence of an unknown source IP address, without - having to painfully go through all node keys. This makes tinc's behavior - much more scalable in this regard. - - This change does not break anything with regard to the protocol: It - preserves compatibility with 1.0 and even with older pre-1.1 releases - thanks to a minor protocol version change (17.4). Source ID information - won't be included in packets sent to nodes with minor version < 4. - - One drawback, however, is that this change increases SPTPS datagram - overhead by 6 bytes (the size of the source ID itself). - -commit 092d620dbb3fdc8226ea0a4e1cfd5cd53d608420 -Author: Etienne Dechamps -Date: Sat Sep 27 13:34:56 2014 +0100 - - Change vpn_packet_t::seqno from uint32_t to uint8_t[4]. - - This is to make sure on-wire vpn_packet_t fields are always 1-byte - aligned, otherwise padding could get in the way. - -commit 55a78da4e0b496fc599704473f41d5ea52669737 -Author: Etienne Dechamps -Date: Sun Sep 21 18:17:02 2014 +0100 - - Introduce node IDs. - - This introduces a new type of identifier for nodes, which complements - node names: node IDs. Node IDs are defined as the first 6 bytes of the - SHA-256 hash of the node name. They will be used in future code in lieu - of node names as unique node identifiers in contexts where space is at - a premium (such as VPN packets). - - The semantics of node IDs is that they are supposed to be unique in a - tinc graph; i.e. two different nodes that are part of the same graph - should not have the same ID, otherwise things could break. This - solution provides this guarantee based on realistic probabilities: - indeed, according to the birthday problem, with a 48-bit hash, the - probability of at least one collision is 1e-13 with 10 nodes, 1e-11 - with 100 nodes, 1e-9 with 1000 nodes and 1e-7 with 10000 nodes. Things - only start getting hairy with more than 1 million nodes, as the - probability gets over 0.2%. - -commit ac77e3c1eb9d7503e30dd69e96e411e7baaa1dfd -Author: Etienne Dechamps -Date: Sun Sep 21 15:44:59 2014 +0100 - - Invalidate UDP information on address changes. - - Currently, when tinc receives an UDP packet from an unexpected address - (i.e. an address different from the node's current address), it just - updates its internal UDP address record and carries on like nothing - happened. - - This poses two problems: - - - It assumes that the PMTU for the new address is the same as the - old address, which is risky. Packets might get dropped if the PMTU - turns out to be smaller (or if UDP communication on the new address - turns out to be impossible). - - - Because the source address in the UDP packet itself is not - authenticated (i.e. it can be forged by an attacker), this - introduces a potential vulnerability by which an attacker with - control over one link can trick a tinc node into dumping its network - traffic to an arbitrary IP address. - - This commit fixes the issue by invalidating UDP/PMTU state for a node - when its UDP address changes. This will trigger a temporary fallback - to indirect communication until we get confirmation via PMTU discovery - that the node is indeed sitting at the other end of the new UDP address. - -commit f57d53c3ad9af89489e15a8cfd94b56937bf3179 -Author: Etienne Dechamps -Date: Sat Sep 27 17:51:33 2014 +0100 - - Fix protocol version check for type 2 MTU probe replies. - - Currently tinc only uses type 2 MTU probe replies if the recipient uses - protocol version 17.3. It should of course support any higher minor - protocol version as well. - -commit f6b008d7317cb1c3766419bdf6bd97d7b4d561f1 -Author: Franz Pletz -Date: Mon Sep 22 22:43:15 2014 +0200 - - tinc-gui: Use /usr/bin/env to resolve path to python - -commit daf65919d1ccc40f6c11f3f723f325de9021c422 -Author: Etienne Dechamps -Date: Sun Sep 21 11:38:41 2014 +0200 - - Preemptively mirror REQ_PUBKEY messages from nodes with unknown keys. - - In this commit, if a node receives a REQ_PUBKEY message from a node it - doesn't have the key for, it will send a REQ_PUBKEY message in return - *before* sending its own key. - - The rationale is to prevent delays when establishing communication - between two nodes that see each other for the first time. These delays - are caused by the first SPTPS packet being dropped on the floor, as - shown in the following typical exchange: - - node1: No Ed25519 key known for node2 - REQ_PUBKEY -> - <- ANS_PUBKEY - node1: Learned Ed25519 public key from node2 - REQ_SPTPS_START -> - node2: No Ed25519 key known for zyklos - <- REQ_PUBKEY - ANS_PUBKEY -> - node2: Learned Ed25519 public key from node1 - -- 10-second delay -- - node1: No key from node2 after 10 seconds, restarting SPTPS - REQ_SPTPS_START -> - <- SPTPS -> - node1: SPTPS key exchange with node2 succesful - node2: SPTPS key exchange with node1 succesful - - With this patch, the following happens instead: - - node1: No Ed25519 key known for node2 - REQ_PUBKEY -> - node2: Preemptively requesting Ed25519 key for node1 - <- REQ_PUBKEY - <- ANS_PUBKEY - ANS_PUBKEY -> - node2: Learned Ed25519 public key from node1 - node1: Learned Ed25519 public key from node2 - REQ_SPTPS_START -> - <- SPTPS -> - node1: SPTPS key exchange with node2 succesful - node2: SPTPS key exchange with node1 succesful - -commit c897f8c99e0b0827cff60f098bd3f9852a062233 -Author: Etienne Dechamps -Date: Sun Sep 21 12:58:23 2014 +0200 - - Fix default device path selection on BSD. - - Currently, if DeviceType = tap but Mode = router, the default - device path is /dev/tun0, which is wrong. This commit fixes that. - -commit a649aa51bf8e5b5fcc76061c9f660122a08245a8 -Author: Etienne Dechamps -Date: Sun Sep 21 11:25:49 2014 +0100 - - Ignore the Interface option if device rename is impossible. - - There are platforms on which it is impossible to rename the TUN/TAP - device. An example is Mac OS X (tuntapx). On these platforms, - specifying the Interface option will not rename the interface, but - the specified name will still be passed to tinc-up scripts and the - like, resulting in potential confusion for the user. - -commit 053925efebf466b5866de12434010c1e8127c172 -Author: Etienne Dechamps -Date: Sun Sep 21 11:14:19 2014 +0100 - - Fix default TAP device on Darwin. - - On Darwin (tuntapx), the first TAP device is /dev/tap0, not /dev/tun0. - -commit 1ac9a3fbd18f961d604c2c080374b8fc32f155d6 -Author: Etienne Dechamps -Date: Sat Sep 6 18:16:46 2014 +0100 - - Fix wrong identifier in SO_NOSIGPIPE call. - - f134bd0c9c2213fbbb3967f3d784759cb65e2c76 broke the Mac OS X build by - introducing a reference to an identifier, c, that doesn't exist. - -commit 7ac52637659b7f17ab5139010f0436aefcf9625c -Author: Etienne Dechamps -Date: Sat Sep 6 10:43:15 2014 +0100 - - Don't enable the device if the reachable count is zero. - - A logic bug was introduced in bd451cfe1512fa69eac35a60dbe6df17bfc39154 - in which running graph() several times with zero reachable nodes had - the effect of calling device_enable() (instead of keeping the device - disabled). - - This results in weird behavior when DeviceStandby is enabled, especially - on Windows where calling device_enable() several times in a row corrupts - I/O structures for the device, rendering it unusable. - -commit 9ad656b512582ed95a574b3fd74b948f876953ce -Author: Etienne Dechamps -Date: Sun Aug 31 13:59:30 2014 +0100 - - Fix undefined HOST_NAME_MAX on Windows. - - The Windows build was broken by commit - 826ad11e419db90b66b3f76a90b54df021bb39fc which introduced a dependency - on the HOST_NAME_MAX macro, which is not defined on Windows. According - to MSDN for gethostname(), the maximum length of the returned string - is 256 bytes (including the terminating null byte), so let's use that - as a fallback. - -commit 0f09260b1377f2d6f14bcdf5de7cbad415743c1e -Author: Etienne Dechamps -Date: Sat Aug 30 10:57:57 2014 +0100 - - Remove Google from the list of copyright owners. - - Google released copyright to me for my own contributions. - -commit 38d7e730e619a8b86dfbf68d77773564595f12a1 -Author: William A. Kennington III -Date: Sun Aug 24 22:35:25 2014 -0700 - - tincctl: Use replace_name to properly replace and validate input hostnames - -commit 511b51ffe60c20a9091829c03863197b76027716 -Author: William A. Kennington III -Date: Sun Aug 24 21:55:42 2014 -0700 - - utils: Refactor check_id out of protocol for global access - -commit 826ad11e419db90b66b3f76a90b54df021bb39fc -Author: William A. Kennington III -Date: Sun Aug 24 19:49:27 2014 -0700 - - utils: Refactor get_name's functionality into util for global access - -commit 78bf82cf332327889f0f61388b73053850d8e59b -Author: Etienne Dechamps -Date: Sun Aug 17 20:22:44 2014 +0100 - - Clarify copyright ownership for code authored by Etienne Dechamps. - -commit 73d8393bd6c54e0ec28d5f6c114a6eb3821a8ec1 -Author: Sven-Haegar Koch -Date: Thu Aug 7 22:14:20 2014 +0200 - - commandline.test: Adding test that fetching non-existing config setting really fails. - -commit 9fe5ab7ccb60537810b60b76a415507ef2cadfdd -Author: Sven-Haegar Koch -Date: Thu Aug 7 23:01:05 2014 +0200 - - Fix exit code of "tinc get". - - Successfully getting an existing variable ("tinc get name") should - not result in an error exitcode (1) from the tinc command. - - This changes the result of test/commandline.test from FAIL to PASS. - -commit 5ae1ec8d80393182b6ff235062b6816b64edfa9b -Author: Etienne Dechamps -Date: Sat Jul 19 18:11:42 2014 +0100 - - Handle TAP-Win32 immediate reads correctly. - - The handling of TAP-Win32 virtual network device reads that complete - immediately (ReadFile() returns TRUE) is incorrect - instead of - starting a new read, tinc will continue listening for the overlapped - read completion event which will never fire. As a result, tinc stops - receiving packets on the interface. - -commit 1d10afd3d33f5623494d9eeb2fa8237712f8aa2e -Author: Etienne Dechamps -Date: Sat Jul 19 16:05:23 2014 +0100 - - Only read from TAP-Win32 if the device is enabled. - - With newer TAP-Win32 versions (such as the experimental - tap-windows6 9.21.0), tinc is unable to read from the virtual network - device: - - Error while reading from (null) {23810A13-BCA9-44CE-94C6-9AEDFBF85736}: No such file or directory - - This is because these new drivers apparently don't accept reads when - the device is not in the connected state (media status). - - This commit fixes the issue by making sure we start reading no sooner - than when the device is enabled, and that we stop reading when the - device is disabled. This also makes the behavior somewhat cleaner, - because it doesn't make much sense to read from a disabled device - anyway. - -commit cc9203ee75c49360dd29710ac12bb67fe503f97b -Author: Etienne Dechamps -Date: Sun Jul 13 15:54:34 2014 +0100 - - Add a non-interactive mode to tinc commands. - - Some tinc commands, such as "tinc generate-keys", use the terminal to - ask the user for information. This can be bypassed by making sure - there is no terminal, which is trivial on *nix but might require - jumping through some hoops on Windows depending on how the command is - invoked. - - This commit adds a --batch option that ensures tinc will never ask the - user for input, even if it is attached to a terminal. - -commit afb175873e6aa10d2d4dca3572edf054968c538d -Author: Guus Sliepen -Date: Sat Jul 12 22:51:37 2014 +0200 - - Revert "Use git description as the tinc version." - - This reverts commit e024b7a2c50e23311834e6d180e5acc72783b339. Automatic version - number generation needs a little bit more work to get it working correctly in - all cases. - -commit 19e42b76f546dc3baee4a5d6a4f161155d279c74 -Merge: f7043048 b12f122f -Author: Guus Sliepen -Date: Sat Jul 12 22:25:55 2014 +0200 - - Merge branch 'keysegfault' of https://github.com/dechamps/tinc into 1.1 - -commit f704304823df0ac868786ac89355eda38592dc3f -Merge: 54fd228e ea12a0fb -Author: Guus Sliepen -Date: Sat Jul 12 22:22:31 2014 +0200 - - Merge branch 'tincstart' of https://github.com/dechamps/tinc into 1.1 - -commit 54fd228e696acc9d78a17845402640cc04e2c54c -Merge: 53036a58 14be1d30 -Author: Guus Sliepen -Date: Sat Jul 12 22:21:01 2014 +0200 - - Merge branch 'ctrl' of https://github.com/dechamps/tinc into 1.1 - -commit 53036a58790168e18f524bd923f9a7d34691ba2d -Merge: ddd0cd47 b2a6381a -Author: Guus Sliepen -Date: Sat Jul 12 22:19:45 2014 +0200 - - Merge branch 'winwarnings' of https://github.com/dechamps/tinc into 1.1 - -commit ddd0cd47bc0bb3478b7d250192248a1e3aa2a243 -Author: Etienne Dechamps -Date: Mon Jun 30 14:03:17 2014 +0100 - - Verify seqno early in sptps_verify_datagram(). - - This is a slight optimization for sptps_verify_datagram(), which might - come in handy since this function is called in a loop via try_harder(). - - It turns out that since sptps_verify_datagram() doesn't update any - state, it doesn't matter in which order verifications are done. However, - it does affect performance since it's much cheaper to check the seqno - than to try to decrypt the packet. - - Since this function is called with the wrong node most of the time, it - makes verification vastly faster for the majority of calls because the - seqno will be wrong in most cases. - -commit 7bf61575fe1009ecb93b3f6b8f5145525874e470 -Author: Etienne Dechamps -Date: Sun Jul 6 11:34:57 2014 +0100 - - Add documentation about using system-assigned ports. - - There are two caveats to be aware of which are documented in this - commit: - - - Because the system will likely assign different ports when binding - several times to different address families, it is recommended to - only use a single address family, otherwise other nodes will only - get one port among the several that were assigned, possibly breaking - communication. - - - AutoConnect won't work in this scenario, because it relies on the UDP - port being the same as the TCP port, which is not the case when using - system-assigned ports. - -commit ea12a0fb066793c316ccc9ef21444f092f74b4ba -Author: Etienne Dechamps -Date: Sat Jul 12 18:53:25 2014 +0100 - - Improve subprocess behavior in tinc start command. - - When invoking tincd, tinc start currently uses the execvp() function, - which doesn't behave well in a console as the console displays a new - prompt before the subprocess finishes (which makes me suspect the exit - value is not handled at all). This new code uses spawnvp() instead, - which seems like a better fit. - -commit b22499668a7aa63c619cb8fa8535282a38841ce9 -Author: Etienne Dechamps -Date: Sat Jul 12 18:37:56 2014 +0100 - - Fix "tinc start" on Windows when the path contains spaces. - - When invoking "tinc start" with spaces in the path, the following - happens: - - > "c:\Program Files (x86)\tinc\tinc.exe" start - c:\Program: unrecognized argument 'Files' - Try `c:\Program --help' for more information. - - This is caused by inconsistent handling of command line strings between - execvp() and the spawned process' CRT, as documented on MSDN: - http://msdn.microsoft.com/library/431x4c1w.aspx - -commit 14be1d30ec3727906907dad49d3bcb868c19d777 -Author: Etienne Dechamps -Date: Sat Jul 12 17:47:01 2014 +0100 - - Shutdown cleanly when receiving a Windows console shutdown request. - - This commit makes tinc exit cleanly on Windows when hitting CTRL+C at - the console or when the user logs off. This change has no effect when - running tinc as a service. - -commit b12f122f1be89b49d8a3e39fb1b10c6e4d3ada94 -Author: Etienne Dechamps -Date: Sat Jul 12 13:56:01 2014 +0100 - - Check if devops is valid before closing the device. - - This fixes a segfault that occurs on exit if tinc fails before the - device is initialized (for example, if it fails to read the private - key). - -commit 5ffdff685a0e7d25f7c016f3a6cd89bb82fed71c -Author: Guus Sliepen -Date: Sat Jul 12 14:35:29 2014 +0200 - - Fix unsafe use of strncpy() and sprintf(). - - The strncpy() problem was found by cppcheck. - -commit 31361075d36fd3f4a393eeb90b75ae2567992ef2 -Author: Guus Sliepen -Date: Sat Jul 12 14:34:39 2014 +0200 - - Fix a potential file descriptor leak. - - Found by cppcheck. - -commit b2a6381ab28dbae4bf976627afccbf6c2fcb0625 -Author: Etienne Dechamps -Date: Sat Jul 12 13:32:23 2014 +0100 - - Resolve KEY_EVENT conflict between Windows and ncurses. - - This fixes the following compiler warning when building for Windows: - - In file included from top.c:24:0: - /usr/local/mingw/ncurses/include/curses.h:1478:0: error: "KEY_EVENT" redefined [-Werror] - #define KEY_EVENT 0633 /* We were interrupted by an event */ - ^ - In file included from /usr/share/mingw-w64/include/windows.h:74:0, - from /usr/share/mingw-w64/include/winsock2.h:23, - from have.h:46, - from system.h:26, - from top.c:20: - /usr/share/mingw-w64/include/wincon.h:101:0: note: this is the location of the previous definition - #define KEY_EVENT 0x1 - ^ - -commit 5217c16db4babd64580c2fd7aa36180bb9bd838c -Author: Etienne Dechamps -Date: Sat Jul 12 13:27:05 2014 +0100 - - Remove unused device stats variables. - - This removes a bunch of variables that are never actually used anywhere. - - This fixes the following compiler warning when building for Windows: - - mingw/device.c:46:17: error: ‘device_total_in’ defined but not used [-Werror=unused-variable] - static uint64_t device_total_in = 0; - ^ - -commit 6e221a828f87a511aecee9d9263a1db0836701c4 -Author: Etienne Dechamps -Date: Sat Jul 12 12:57:11 2014 +0100 - - Remove unused variable in TAP-Win32 setup_device(). - - This fixes the following compiler warning when building for Windows: - - mingw/device.c: In function ‘setup_device’: - mingw/device.c:92:9: error: unused variable ‘thread’ [-Werror=unused-variable] - HANDLE thread; - ^ - -commit 2d2e94406c5f595eff67a01ee6bb1190f77c37ff -Author: Etienne Dechamps -Date: Sat Jul 12 12:54:45 2014 +0100 - - Fix callback signature for TAP-Win32 device_handle_read(). - - This fixes the following compiler warning when building for Windows: - - mingw/device.c: In function ‘setup_device’: - mingw/device.c:186:2: error: passing argument 2 of ‘io_add_event’ from incompatible pointer type [-Werror] - io_add_event(&device_read_io, device_handle_read, NULL, CreateEvent(NULL, TRUE, FALSE, NULL)); - ^ - In file included from mingw/../net.h:27:0, - from mingw/../subnet.h:24, - from mingw/../conf.h:34, - from mingw/device.c:26: - mingw/../event.h:61:13: note: expected ‘io_cb_t’ but argument is of type ‘void (*)(void *)’ - extern void io_add_event(io_t *io, io_cb_t cb, void* data, WSAEVENT event); - -commit f693cb7295298ecd6993a4feac1faf9129aa204d -Author: Etienne Dechamps -Date: Sat Jul 12 12:52:25 2014 +0100 - - Remove an unnecessary pointer dereference in execute_script(). - - This fixes the following compiler warning when building for Windows: - - script.c: In function ‘execute_script’: - script.c:52:5: error: value computed is not used [-Werror=unused-value] - *q++; - ^ - -commit d7f89a79448dd1633342ea5ee344d403c8e6890b -Author: Etienne Dechamps -Date: Sat Jul 12 12:49:59 2014 +0100 - - Only declare the origpriority variable if we support priority. - - This fixes the following compiler warning when building for Windows: - - net_packet.c: In function ‘send_udppacket’: - net_packet.c:633:6: error: unused variable ‘origpriority’ [-Werror=unused-variable] - int origpriority = origpkt->priority; - ^ - -commit 5aed916ef4fd75e6843f8fe739444dae91ea106a -Author: Guus Sliepen -Date: Sat Jul 12 14:24:16 2014 +0200 - - Reserve legacy active bit in connection_status_t. - - This is so the positions of the other bits don't change, making it easier to - debug problems with different versions of tinc. - - Also fix the padding so connection_status_t is exactly 32 bits. - -commit b23bf132838156d2fe5a18d50a2b5e068ae18ec3 -Author: Etienne Dechamps -Date: Sat Jul 12 11:57:03 2014 +0100 - - Remove redundant connection_t::status.active field. - - The only places where connection_t::status.active is modified is in - ack_h() and terminate_connection(). In both cases, connection_t::edge - is added and removed at the same time, and that's the only places - connection_t::edge is set. Therefore, the following is true at all - times: - - !c->status.active == !c->edge - - This commit removes the redundant state information by getting rid of - connection_t::status.active, and using connection_t::edge instead. - -commit 127f2f99f3d43e0565782750f26f1d3980c72711 -Author: Etienne Dechamps -Date: Sat Jul 12 11:13:04 2014 +0100 - - Don't initialize outpkt to an unused value. - - in receive_udppacket(), we initialize outpkt to a default value but the - value is never read anywhere, as every read is preceded by a write. - - This issue was found by the clang static analyzer tool: - http://clang-analyzer.llvm.org/ - -commit 77e96c07912c2a8b280d3e812c71fa1f12efb0ff -Author: Etienne Dechamps -Date: Sat Jul 12 11:06:36 2014 +0100 - - Handle the "no local address" case in send_sptps_data(). - - If choose_local_address() is unable to find a local address (e.g. - because of old nodes that don't send their local address information), - then send_sptps_data() ends up using uninitialized variables for the - socket and address. - - This regression was introduced in - 415910897122da0073a862784d148802ca390020. The commit took care of - handling that case in send_udppacket() but was missing the same fix - for send_sptps_data(). - - This bug was found by the clang static analyzer tool: - http://clang-analyzer.llvm.org/ - -commit 45a30f71572fab8e73c456737b7506b2cf12be25 -Author: Guus Sliepen -Date: Thu Jul 10 22:41:01 2014 +0200 - - Fix incorrect format qualifiers. - - Based on a patch from Etienne Dechamps. We avoid the use of %hhx, since even - though it is C99, not all compilers support it yet. We use %x instead, since - it's guaranteed that the minimum size of function arguments on the stack or in - registers is that of an int. - -commit d8ed5cf36d0c6d5a863497674248c8e8b63b9d98 -Author: Etienne Dechamps -Date: Thu Jul 10 20:29:12 2014 +0100 - - Fix a typo (FORTIFY_SOURCE). - -commit 2f4075f7da2c6ddf777c5bab93992a6c6ac5ec40 -Author: Baptiste Jonglez -Date: Sun Jul 6 20:55:26 2014 +0900 - - Fix typos in the manual page - -commit d8ea4c11dec5946c135ad2d2d05954473a0bfda9 -Author: Guus Sliepen -Date: Tue Jul 8 14:20:11 2014 +0200 - - Fix segmentation fault when dumping subnets. - -commit 23a22ea1ceb9d0a6b6c288142130f0e30c0fdec9 -Author: Guus Sliepen -Date: Tue Jul 8 14:20:01 2014 +0200 - - Fix compiler warnings. - -commit 163773d7107b7726bed24cb1c31b1cecc0d0c239 -Author: Etienne Dechamps -Date: Sun Jul 6 12:35:32 2014 +0100 - - Fix event loop io tree inconsistency on Windows. - - On Windows, the event loop io tree uses the Windows Event handle to - differentiate between io_t objects. Unfortunately, there is a bug in - the io_add_event() function (introduced in - 2f9a1d4ab5ff51b05a5e8cc41a1528fdeb36c723) as it sets the event after - inserting the object into the tree, resulting in objects appearing in - io_tree out of order. - - This can lead to crashes on Windows as the event loop is unable to - determine which events fired. - -commit fcf5b53e785fd191dd951b77ad831fe6ac78dce4 -Author: Etienne Dechamps -Date: Sun Jul 6 10:55:23 2014 +0100 - - Make sure myport is set correctly when running with Port = 0. - - Setting the Port configuration variable to zero can be used to make tinc - listen on a system-assigned port. Unfortunately, in this scenario myport - will be zero, which means that tinc won't transmit its actual UDP - listening port to other nodes. This breaks UDP hole punching and local - discovery. - -commit c786ed116805c0bc911f592c03dc0d5562287283 -Author: Etienne Dechamps -Date: Sat Jul 5 00:23:05 2014 +0100 - - Fix tinc event loop reentrancy from timeout handlers. - - Commit 611217c96ec684799882cf330f40a0936131b6b5 introduced a regression - because it accidentally reordered the timeout handler calls and the - fdset setup code. This means that any io_add(), io_del() or io_set() - calls in timeout handlers would be ignored in the current event loop - iteration, resulting in erratic behavior. - - The most visible symptom is when a metaconnection timeout occurs and the - connection is closed; the timeout handler closes the socket but it still - ends up in the select() call, typically resulting in the following - crash: - - Error while waiting for input: Bad file descriptor - -commit d0d01a44485ee04f60a8fccf9bdf8311e23ffa43 -Author: Etienne Dechamps -Date: Sat Jul 5 19:51:19 2014 +0100 - - Canonicalize IPv6 addresses as per RFC 5952 before printing them. - - Currently we don't do any shortening on IPv6 addresses (aside from - removing trailing zeroes) before printing them. This commit makes - textual addresses smaller by shortening them according to the rules - described in RFC 5952. This is also the canonical textual representation - for IPv6 addresses, thus making them easier to compare. - -commit dec0400714cc6b125f615c224ac37903f44addb9 -Author: Etienne Dechamps -Date: Sat Jul 5 19:02:02 2014 +0100 - - Don't print subnet prefix lengths and weights for one-host subnets. - - This commit suppresses subnet prefix length output (/xx) for subnets - that only contain one address (/32 for IPv4, /128 for IPv6). It also - suppresses weight information if the subnet is using the default - weight. This improves readability of net2str() output in the majority - of cases. - -commit dc55691ca7399bab28963f92e4c3dea9d6bf8eb1 -Author: Etienne Dechamps -Date: Sat Jul 5 18:52:03 2014 +0100 - - When printing MAC addresses, always use trailing zeroes. - - tinc currently prints MAC addresses without trailing zeroes, for example: - - 1:2:3:4:5:6 - - This looks weird and is inconsistent with how MAC addresses are - displayed everywhere else. This commit adds trailing zeroes, so the - above address will be printed as the following: - - 01:02:03:04:05:06 - -commit 3d730a40a42d9b238da8725438a612296dea3860 -Author: Etienne Dechamps -Date: Sat Jul 5 18:05:55 2014 +0100 - - Rewrite, fix and improve str2net(). - - This is a complete rewrite of the str2net() function. Besides - refactoring duplicate code, this new code brings the following fixes - and improvements: - - - Fixes handling of leading/trailing double colon in IPv6 addresses. - For example, with the previous code the address - 2001:0db8:85a3:0000:0000:8a2e:0370:: is interpreted as a MAC address, - and ::0db8:85a3:0000:0000:8a2e:0370:7334 is rejected. - - - Catches more invalid cases, such as garbage at the end of the string. - - - Adds support for dotted quad notation in IPv6 (e.g. ::1.2.3.4). - - See RFC 4291, section 2.2 for details on the textual format of IPv6 - addresses. - -commit e024b7a2c50e23311834e6d180e5acc72783b339 -Author: Etienne Dechamps -Date: Sun Jun 29 15:22:10 2014 +0100 - - Use git description as the tinc version. - - Instead of using a hardcoded version number in configure.ac, this makes - tinc use the live version reported by "git describe", queried on-the-fly - during the build process and regenerated for every build. - - This provides several advantages: - - Less redundancy: git is now the source of truth for version - information, no need to store it in the repository itself. - - Simpler release process: just creating a git tag automatically - updates the version. No need to change files. - - More useful version information: tinc will now display the number of - commits since the last tag as well as the commit the binary is built - from, following the format described in git-describe(1). - - Here's an example of tincd --version output: - - tinc version release-1.1pre10-48-gc149315 (built Jun 29 2014 15:21:10, protocol 17.3) - - When building directly from a release tag, this would like the following: - - tinc version release-1.1pre10 (built Jun 29 2014 15:21:10, protocol 17.3) - - (Note that the format is slightly different - because of the way the - tags are named, it says "release-1.1pre10" instead of just "1.1pre10") - -commit aec82bb1c94af6d3142cdef0c51f42f38e9be3e0 -Author: Etienne Dechamps -Date: Sun Jun 29 14:57:42 2014 +0100 - - Regenerate build date and time every time tinc is built. - - This prevents the date and time shown in version information from - getting stale because of partial builds. With these changes, date and - time information is written to a dedicated object file that gets rebuilt - every time make is run, even if there are no changes. - -commit 116f2ed27a74982e4d1a19b7a8fd08b0aaee1f8d -Author: Etienne Dechamps -Date: Sun Jun 29 14:15:58 2014 +0100 - - Make IPv4 multicast space 224.0.0.0/4 broadcast by default. - - We already do this for IPv6 multicast space (ff00::/8), so why not - extend it to IPv4. - -commit 46a5aa0d674914f4220d8583b1b2f87c7f05a804 -Author: Etienne Dechamps -Date: Sun Jun 29 13:18:25 2014 +0100 - - Make broadcast addresses configurable. - - This adds a new option, BroadcastSubnet, that allows the user to - declare broadcast subnets, i.e. subnets which are considered broadcast - addresses by the tinc routing layer. Previously only the global IPv4 - and IPv6 broadcast addresses were supported by virtue of being - hardcoded. - - This is useful when using tinc in router mode with Ethernet virtual - devices, as it can be used to provide broadcast support for a local - broadcast address (e.g. 10.42.255.255) instead of just the global - address (255.255.255.255). - - This is implemented by removing hardcoded broadcast addresses and - introducing "broadcast subnets", which are subnets with a NULL owner. - By default, behavior is unchanged; this is accomplished by adding - the global broadcast addresses for Ethernet, IPv4 and IPv6 at start - time. - -commit b54fde67474e7201e94fa4be34dae65d295b2936 -Author: Etienne Dechamps -Date: Sun Jun 29 09:57:11 2014 +0100 - - Implement sptps_verify_datagram(). - - Implementation of sptps_verify_datagram() was left as a TODO. This - causes problems when using SPTPS in tinc, because this function is - used in try_mac(), which itself is used in try_harder() to locate - nodes sending UDP packets from unexpected addresses. In the current - state this function always returns true, resulting in UDP addresses - of random nodes getting changed which makes UDP communication - fragile and unreliable. In addition, this makes UDP communication - impossible through port translation and local discovery. - - This commit adds the missing implementation, thus fixing the issue. - -commit 498f1b1d5835ab1ac21886cdf0d1471ac90f75b2 -Author: Etienne Dechamps -Date: Sun Jun 29 11:06:44 2014 +0100 - - Enable LocalDiscovery by default. - - Recent improvements to the local discovery mechanism makes it cheaper, - more network-friendly, and now it cannot make things worse (as opposed - to the old mechanism). Thus there is no reason not to enable it by - default. - -commit 415910897122da0073a862784d148802ca390020 -Author: Etienne Dechamps -Date: Sun Jun 29 11:01:24 2014 +0100 - - Remove broadcast-based local discovery mechanism. - - The new local address based local discovery mechanism is technically - superior to the old broadcast-based one. In fact, the old algorithm - can technically make things worse by e.g. sending broadcasts over the - VPN itself and then selecting the VPN address as the node's UDP - address. This cannot happen with the new mechanism. - - Note that this means old nodes that don't send their local addresses in - ADD_EDGE messages can't be discovered, because there is no address to - send discovery packets to. Old nodes can still discover new nodes by - sending them broadcasts, though. - -commit e16ade874d08f82481dca7302b98305bcfbe27cf -Author: Etienne Dechamps -Date: Sun Jun 22 17:27:55 2014 +0100 - - Use edge local addresses for local discovery. - - This introduces a new way of doing local discovery: when tinc has - local address information for the recipient node, it will send local - discovery packets directly to the local address of that node, instead - of using broadcast packets. - - This new way of doing local discovery provides numerous advantages compared to - using broadcasts: - - - No broadcast packets "polluting" the local network; - - - Reliable even if the sending host has multiple network interfaces (in - contrast, broadcasts will only be sent through one unpredictable - interface) - - - Works even if the two hosts are not on the same broadcast domain. One - example is a large LAN where the two hosts might be on different local - subnets. In fact, thanks to UDP hole punching this might even work if - there is a NAT sitting in the middle of the LAN between the two nodes! - - - Sometimes a node is reachable through its "normal" address, and via a - local subnet as well. One might think the local subnet is the best route - to the node in this case, but more often than not it's actually worse - - one example is where the local segment is a third party VPN running in - parallel, or ironically it can be the local segment formed by the tinc - VPN itself! Because this new algorithm only checks the addresses for - which an edge is already established, it is less likely to fall into - these traps. - -commit bfce56d473e1e01a8af0260262ca84f09154e71f -Author: Etienne Dechamps -Date: Sun Jun 22 16:29:30 2014 +0100 - - Add local address information to edges. - - In addition to the remote address, each edge now stores the local address from - the point of view of the "from" node. This information is then made available - to other nodes through a backwards-compatible extension to ADD_EDGE messages. - - This information can be used in future code to improve packet routing. - -commit 762db91ef7d3b2eab00c23250ca61c7f814899c7 -Author: Guus Sliepen -Date: Sat Jun 28 21:54:34 2014 +0200 - - Give getsockopt() a reference to a socklen_t. - -commit e57daac63b6f703af8e7c8209ef61a4d3b2180c3 -Merge: cc284e7c 313a752c -Author: Guus Sliepen -Date: Sat Jun 28 21:49:55 2014 +0200 - - Merge branch 'winevents-clean' of https://github.com/dechamps/tinc into 1.1 - -commit 313a752cb5fbf27450d34c15b0085d2d8a4147af -Author: Etienne Dechamps -Date: Sat Jun 28 18:39:00 2014 +0100 - - Remove the TAP-Win32 reader thread. - - tinc is using a separate thread to read from the TAP device on Windows. - The rationale was that the notification mechanism for packets arriving - on the virtual network device is based on Win32 events, and the event - loop did not support listening to these events. - - Thanks to recent improvements, this event loop limitation has been - lifted. Therefore we can get rid of the separate thread and simply add - the Win32 "incoming packet" event to the event loop, just like a socket. - The result is cleaner code that's easier to reason about. - -commit ffbc99558cae4dff876645fe205349d8c4cd7acb -Author: Etienne Dechamps -Date: Sat Jun 28 15:19:11 2014 +0100 - - Use a Windows event to stop tinc when running as a service. - - Currently, when the tinc service handler callback (which runs in a - separate thread) receives a service shutdown request, it calls - event_exit() to request the event loop to exit. - - This approach has a few issues: - - - The event loop will only notice the exit request when the next event - fires. This slows down tinc service shutdown. In some extreme cases - (DeviceStandby enabled, long PingTimeout and no connections), - shutdown can take ages. - - - Strictly speaking, because of the absence of memory barriers, there - is no guarantee that the event loop will even notice an exit request - coming from another thread. I suppose marking the "running" variable - as "volatile" is supposed to alleviate that, but it's unclear whether - that provides any guarantees with modern systems and compilers. - - This commit fixes the issue by leveraging the new event loop Windows - interface, using a custom Windows event that is manually set when - shutdown is requested. - -commit 2f9a1d4ab5ff51b05a5e8cc41a1528fdeb36c723 -Author: Etienne Dechamps -Date: Sat Jun 28 15:15:41 2014 +0100 - - Make the event loop expose a Windows event interface. - - This allows event loop users to specify Win32 events to wait on, - thus making the event loop more flexible. - -commit 611217c96ec684799882cf330f40a0936131b6b5 -Author: Etienne Dechamps -Date: Fri Jun 27 21:58:35 2014 +0100 - - Use native Windows events for the event loop. - - This commit changes the event loop to use WSAEventSelect() and - WSAWaitForMultipleEvents() on Windows. This paves the way for making the - event loop more flexible on Windows by introducing the required - infrastructure to make the event loop wait on any Win32 event. - - This commit only affects the internal implementation of the event - module. Externally visible behavior remains strictly unchanged (for - now). - -commit cc284e7c5d298ca887c07f918da35e376bf98720 -Author: Etienne Dechamps -Date: Sat Jun 28 11:13:29 2014 +0100 - - Fix connection event error handling. - - Commit 86a99c6b999671ed444711139db1937617e802a0 changed the way we - handle connection events to protect against spurious event loop - callbacks. Unfortunately, it turns out that calling connect() twice on - the same socket results in different behaviors depending on the platform - (even though it seems well defined in POSIX). On Windows this resulted - in the connection handling code being unable to react to connection - errors (such as connection refused), always hitting the timeout; on - Linux this resulted in spurious error messages about connect() returning - success. - - In POSIX and on Linux, using connect() on a socket where the previous - attempt failed will attempt to connect again, resulting in unnecessary - network activity. Using getsockopt(SO_ERROR) before connect() solves - that, but introduces a race condition if a connection failure happens - between the two calls. - - For this reason, this commit switches from connect() to a zero-sized - send() call, which is more consistent (though not completely, see the - truth table in the comments) and simpler to use for that purpose. Note - that Windows explictly support empty send() calls; POSIX says nothing - on the subject, but testing shows it works at least on Linux. - - (Surprisingly enough, Windows seems more POSIX-compliant than Linux on - this one!) - -commit 86a99c6b999671ed444711139db1937617e802a0 -Author: Etienne Dechamps -Date: Fri Jun 27 19:33:31 2014 +0100 - - Protect against spurious connection events. - - The event loop does not guarantee that spurious write I/O events do not - happen; in fact, they are guaranteed to happen on Windows when - event_flush_output() is called. Because handle_meta_io() does not check - for spurious events, a metaconnection socket might appear connected even - though it's not, and will fail immediately when sending the ID request. - - This commit fixes this issue by making handle_meta_io() check the - connection status before assuming the socket is connected. It seems that - the only reliable way to do that is to try to call connect() again and - look at the error code, which will be EISCONN if the socket is - connected, or EALREADY if it's not. - -commit 0c026f3c6dec784c3267ad7e2c4709d5393dc292 -Author: Etienne Dechamps -Date: Thu Jun 26 20:42:40 2014 +0100 - - Fix errno references when handling socket errors. - - When using socket functions, "sockerrno" is supposed to be used to - retrieve the error code as opposed to "errno", so that it is translated - to the correct call on Windows (WSAGetLastError() - Windows does not - update errno on socket errors). Unfortunately, the use of sockerrno is - inconsistent throughout the tinc codebase, as errno is often used - incorrectly on socket-related calls. - - This commit fixes these oversights, which improves socket error - handling on Windows. - -commit 058473dc8d4cf60f79aee18d473342b8a3c25fbe -Author: Etienne Dechamps -Date: Sun Jun 22 18:45:49 2014 +0100 - - Fix Windows includes. - - These Windows include lines are capitalized, which causes the build to fail - when cross-compiling from Linux to Windows using MinGW as the MinGW headers - are entirely lower case. - -commit b24faf3cbe07dd931911ec4d70f1a9e0d6a87519 -Author: Guus Sliepen -Date: Sun May 11 17:11:02 2014 +0200 - - Remove the warnings when IP_DONTFRAGMENT/IPV6-DONTFRAG is not supported. - - There is nothing we can do about it, and tinc will run fine anyway. - -commit b99e1a306c7fb8f43dd61e432f3c896f5142e4ac -Author: Alexis Hildebrandt -Date: Sun Jun 22 16:43:15 2014 +0200 - - Add support to link against libresolv Mac OS X - -commit e76df30cb2af7a22e9c1dc91bb47a76c2fcbc43d -Author: Armin Fisslthaler -Date: Fri Apr 25 14:44:06 2014 +0200 - - reload /etc/resolv.conf in SIGALRM handler - -commit 132bdb77a0792d85d03ad89f846cbd4024037393 -Author: Etienne Dechamps -Date: Sun Jun 22 10:48:34 2014 +0100 - - Make DeviceStandby control network interface link status on Windows. - - Besides controlling when tinc-up and tinc-down get called, this commit makes - DeviceStandby control when the virtual network interface "cable" is "plugged" - on Windows. This is more user-friendly as the status of the tinc network can - be seen just by looking at the state of the network interface, and it makes - Windows behave better when isolated. - -commit bd451cfe1512fa69eac35a60dbe6df17bfc39154 -Author: Etienne Dechamps -Date: Sun Jun 22 10:48:34 2014 +0100 - - Add DeviceStandby option to only enable the device when nodes are reachable. - - This adds a new DeviceStandby option; when it is disabled (the default), - behavior is unchanged. If it is enabled, tinc-up will not be called during - tinc initialization, but will instead be deferred until the first node is - reachable, and it will be closed as soon as no nodes are reachable. - - This is useful because it means the device won't be set up until we are fairly - sure there is something listening on the other side. This is more user-friendly, - as one can check on the status of the tinc network connection just by checking - the status of the network interface. Besides, it prevents the OS from thinking - it is connected to some network when it is in fact completely isolated. - -commit f0885b8d2fe69610e7e294735795d98db11157a5 -Author: Etienne Dechamps -Date: Sun Jun 22 14:06:44 2014 +0100 - - Cleanly remove the device FD from the event loop before closing it. - -commit ed1d0878afe53032a4b63e87afd4a435015cf5de -Author: Etienne Dechamps -Date: Sun Jun 22 09:53:26 2014 +0100 - - Make device close cleaner. - -commit 638260865399693c3ced9337ef2664c5ba968a2a -Author: Etienne Dechamps -Date: Sun Jun 22 09:54:45 2014 +0100 - - Move Solaris if_fd to local scope. - - This variable is never used outside of setup_device(), therefore there is no - reason to declare it in global scope. - -commit 9bfc228ef5fcd4166897e32fbe82f4cc4e252922 -Author: Baptiste Jonglez -Date: Fri Jun 20 15:56:13 2014 +0900 - - Clarify man page regarding the IndirectData option - -commit 31c68993989fbca3c88df1449ea2077baafce481 -Author: Guus Sliepen -Date: Sun Jun 15 12:19:10 2014 +0200 - - Unconditionally return non-zero exit code when "tinc del" does not find the requested variable. - -commit 1ce0f7613964c7441ef683f9d875dd09cbfd667c -Author: Guus Sliepen -Date: Sun Jun 15 12:14:01 2014 +0200 - - Return non-zero exit code when "tinc get" does not find the requested variable. - -commit ef5e8b6920d1dd3097f36bd0c50170100acf2f28 -Author: Guus Sliepen -Date: Tue Jun 3 11:02:58 2014 +0200 - - Fix base64 decoding of Ed25519 keys. - -commit b0d80c7f28528c2c8857c5662b4aca779b3184bb -Author: Guus Sliepen -Date: Sun May 18 21:51:42 2014 +0200 - - Allow Cipher and Digest "none". - - This is for backwards compatibility with tinc 1.0, it has no effect on - the SPTPS protocol. - -commit 666718998eaa044f6f25fe99810a78dca8471393 -Author: Guus Sliepen -Date: Sun May 18 20:49:35 2014 +0200 - - Implement a PEM-like format for Ed25519 keys. - - We don't require compatibility with any other software, but we do want Ed25519 keys to work - the same as RSA keys for now. - -commit f0e7e6b03e34e69cac5b01a2d943ad3b9b59d36c -Author: Guus Sliepen -Date: Sun May 18 20:47:04 2014 +0200 - - Rename ECDSA to Ed25519. - -commit 35437a50e2a46861742b6fb8e49d065aa52a04dc -Author: Guus Sliepen -Date: Tue May 13 20:29:09 2014 +0200 - - Add sanity checks when generating new RSA keys. - - The key size should be a multiple of 8 bits, and it should be between 1024 and - 8192 bits. - -commit 66f325f4674e70d83744626f3b8dda6760f8d613 -Author: Guus Sliepen -Date: Mon May 12 15:57:40 2014 +0200 - - Fix PMTU discovery via datagram SPTPS. - - In send_sptps_data(), the len variable contains the length of the whole - datagram that needs to be sent to the peer, including the overhead from SPTPS - itself. - -commit c35bfa18ec49439d4a028990fcf0ae6d8c4508a5 -Author: Guus Sliepen -Date: Mon May 12 15:56:29 2014 +0200 - - Fix a crash when we have a malformed public ECDSA key of another node. - -commit c32fcdfc1dde289c52bc359b7b6c5f8c30186e58 -Author: Guus Sliepen -Date: Mon May 12 14:35:56 2014 +0200 - - Add missing closedir(). - -commit 75e5b2e906bd8563bf0f53a76065618c88122e1c -Author: Guus Sliepen -Date: Mon May 12 14:35:12 2014 +0200 - - Use void pointers to opaque buffers. - -commit 332b55d4720fadea76c0a5d9b9d484af6a724006 -Author: Guus Sliepen -Date: Tue May 6 14:11:55 2014 +0200 - - Change AutoConnect from int to bool. - - The proper value is 3, not 2 or 4, and 5 is right out. So just hardcode this value, - and only have the option to turn AutoConnect on or off. - -commit 27acb5d04792f2da70e937543de9110e16aae21c -Author: Guus Sliepen -Date: Tue May 6 13:01:48 2014 +0200 - - Fix compiler warnings. - -commit bc33a073d82cd4b5e75d00e379ddfeeaa6ade962 -Author: Guus Sliepen -Date: Tue May 6 12:58:25 2014 +0200 - - Nexthop calculation should always use the shortest path. - - When tinc runs the graph algorithms and updates the nexthop and via pointers, - it uses a breadth-first search, but it can sometimes revisit nodes that have - already been visited if the previous path is marked as being indirect, and - there is a longer path that is "direct". The via pointer should be updated in - this case, because this points to the closest hop to the destination that can - be reached directly. However, the nexthop pointer should not be updated. - - This fixes a bug where there could potentially be a routing loop if a node in - the graph has an edge with the indirect flag set, and some other edge without - that flag, the indirect edge is part of the minimum spanning tree, and a - broadcast packet is being sent. - -commit b6e2b416bf9a5788c8847267b849efcd9e5bbf95 -Author: Saverio Proto -Date: Mon May 5 15:23:25 2014 +0200 - - Fix typo in comment - -commit 18698c4e123d1ed22f3a2fc5529fac62fbabaf19 -Author: Guus Sliepen -Date: Fri Apr 25 17:00:55 2014 +0200 - - Put brackets around IPv6 addresses in invitation URL, even if there is no port number. - -commit 475088ed77df925ce0680c9993305cd746742708 -Author: Guus Sliepen -Date: Tue Apr 15 17:26:08 2014 +0200 - - sptps_test: allow using a tun device instead of stdio. - -commit 2980173ee7f8142598fe5e1ab117e463751da310 -Author: Guus Sliepen -Date: Mon Apr 14 21:43:45 2014 +0200 - - Use the ChaCha-Poly1305 cipher for the SPTPS protocol. - - The main reason to switch from AES-256-GCM to ChaCha-Poly1305 is to remove a - dependency on OpenSSL, whose behaviour of the AES-256-GCM decryption function - changes between versions. The source code for ChaCha-Pol1305 is small and in - the public domain, and can therefore be easily included in tinc itself. - Moreover, it is very fast even without using any optimized assembler, easily - outperforming AES-256-GCM on platforms that don't have special AES instructions - in hardware. - -commit 49e3baec20ddad9cc297c3eeb1d13f0e421f69c8 -Merge: 37b729d7 2f01744f -Author: Guus Sliepen -Date: Mon Apr 14 20:49:43 2014 +0200 - - Merge branch '1.1-ed25519' into 1.1 - -commit 37b729d7fdd49da5466696f7995a96ebb54fbcbb -Author: Guus Sliepen -Date: Sun Apr 13 12:09:48 2014 +0200 - - Properly initialize buffers. - - Valgrind complained about use of uninitialized data. - -commit 2f01744f82be542894fe2ceecbfb9ead93c9ffa5 -Author: Guus Sliepen -Date: Sun Apr 6 22:47:26 2014 +0200 - - Use Ed25519 keys. - - This uses the portable Ed25519 library made by Orson Peters, which in turn uses - the reference implementation made by Daniel J. Bernstein. - - This implementation also allows Ed25519 keys to be used for key exchange, so - there is no need to add a separate implementation of Curve25519. - -commit d6734a2da483675f5bcc9cf7b15723a409b1019f -Author: Guus Sliepen -Date: Sun Apr 6 22:46:06 2014 +0200 - - Fix return value of b64encode(). - -commit f134bd0c9c2213fbbb3967f3d784759cb65e2c76 -Author: Guus Sliepen -Date: Sun Mar 9 15:32:10 2014 +0100 - - Handle a disconnecting tincd better. - - - Try to prevent SIGPIPE from being sent for errors sending to the control - socket. We don't outright block the SIGPIPE signal because we still want the - tinc CLI to exit when its output is actually sent to a real (broken) pipe. - - - Don't call exit() from top(), and properly detect when the control socket is - closed by the tincd. - -commit 09e000ba54fd4a4ffe3e5c15ee7aeadac35d6996 -Author: Guus Sliepen -Date: Wed Feb 26 17:27:57 2014 +0100 - - Rewind the file before trying to use PEM_read_RSA_PUBKEY(). - -commit 44c7f554c7a6eb411428cfd30ca2cb21a613830e -Author: Guus Sliepen -Date: Wed Feb 26 11:00:30 2014 +0100 - - Add "network" command to list or switch networks. - -commit 48ecff6ddb7e6f9d6b6df7f8952c4cfb318572fa -Author: Guus Sliepen -Date: Fri Feb 7 23:06:26 2014 +0100 - - Add missing attribution for 1.1pre10 to the NEWS file. - -commit 9f7e2dffb27297385c56698638386b264c9aff1a -Author: Guus Sliepen -Date: Fri Feb 7 23:05:33 2014 +0100 - - Really fix compiling under Windows. - -commit 173072ff078a8917b60c24dbe58aa7c258450de2 -Author: Guus Sliepen -Date: Fri Feb 7 21:40:42 2014 +0100 - - Releasing 1.1pre10. - -commit cb5c1b5986861361207fa244662bb2c7f3d6a3a4 -Author: Guus Sliepen -Date: Fri Feb 7 21:40:29 2014 +0100 - - Check whether OpenSSL has support for GCM. - -commit cdda0388a82eb44ff260e25c0902794c8db9643a -Author: Guus Sliepen -Date: Fri Feb 7 21:14:41 2014 +0100 - - Fix compiling for Windows. - -commit 06a4a8c153407b690a3ce3f0e7fdaa8568ccb1a3 -Author: Guus Sliepen -Date: Fri Feb 7 20:38:48 2014 +0100 - - Update copyright notices. - -commit bc9347042bf6586d23bf17efd9fdf64a2c4a4d27 -Author: Guus Sliepen -Date: Fri Feb 7 19:57:06 2014 +0100 - - Attribution for Dennis Joachimsthaler. - -commit ac7f82cb235008d1711781a87ffdce5d45465134 -Author: Guus Sliepen -Date: Fri Feb 7 16:34:08 2014 +0100 - - Handle errors from TAP-Win32/64 adapter in a better way. - - Before, the tapreader thread would just exit immediately after encountering the - first error, without notifying the main thread. Now, the tapreader thead never - exits itself, but tells the main thread to stop when more than ten errors are - encountered in a row. - -commit 2f41780023bffc81fa42b0e72f67be86a52b370c -Author: Guus Sliepen -Date: Fri Feb 7 19:48:11 2014 +0100 - - Attribution for various contributors. - - Conflicts: - THANKS - -commit e717e424c22233aa728b75c4c8bb047e13b0107a -Author: Guus Sliepen -Date: Thu Jan 30 17:10:30 2014 +0100 - - Use addresses learned from other nodes when making outgoing connections. - - Before, when making a meta-connection to a node (either because of a ConnectTo - or because AutoConnect is set), tinc required one or more Address statements - in the corresponding host config file. However, tinc learns addresses from - other nodes that it uses for UDP connections. We can use those just as well for - TCP connections. - -commit 995444c4f96bafecf7fb5d59510b3034459cf85c -Author: Guus Sliepen -Date: Wed Jan 29 17:32:18 2014 +0100 - - Document Weight and also allow it to be set from tinc.conf. - -commit 2e318f379992a730f592b4c5261d26d8e1a38cfd -Author: Guus Sliepen -Date: Wed Jan 29 17:17:59 2014 +0100 - - Don't ask questions if we are not running interactively. - - When creating invitations or using them to join a VPN, and the tinc command is - not run interactively (ie, when stdin and stdout are not connected or - redirected to/from a file), don't ask questions. If normally tinc would ask for - a confirmation, just assume the default answer instead. If tinc really needs - some input, just print an error message instead. - - In case an invitation is used for a VPN which uses a netname that is already in - use on the local host, tinc will store the configuration in a temporary - directory. Normally it asks for an alternative netname and then renames the - temporary directory, but when not run interactively, it now just prints the - location of the unchanged temporary directory. - -commit 00398a60ec317740bcec83c5a524c5a95ce7f1c2 -Author: Guus Sliepen -Date: Mon Jan 27 23:21:25 2014 +0100 - - Add missing newlines when copying variables from tinc.conf to an invitation file. - -commit fa1e9b046128db81c207c9ed920d068a144cd687 -Author: Guus Sliepen -Date: Fri Jan 24 16:09:32 2014 +0100 - - Test two tinc daemons using network namespaces. - - Testing multiple daemons connecting to each other on the same computer is - usually difficult, because connections to local IP addresses will bypass most - of the network stack. However, recent versions of Linux support network - namespaces, which can isolate network interfaces. We use this to isolate the - virtual interface of the daemons from each other, so we get the behaviour as if - the daemons were each running on their own machine. This can also be used for - more complicated tests (including those with firewall rules) without disturbing - the real network setup of the host computer. - -commit 38adc8bf548c2c465d5f4147866c3d3f9112d3a8 -Author: Guus Sliepen -Date: Mon Jan 20 21:19:13 2014 +0100 - - Add the ListenAddress option. - - ListenAddress works the same as BindToAddress, except that from now on, - explicitly binding outgoing packets to the address of a socket is only done for - sockets specified with BindToAddress. - -commit e187758a7e163cb2d2e57db8b093823f68f1491f -Author: Guus Sliepen -Date: Mon Jan 20 20:21:15 2014 +0100 - - Document that 1.1 uses AES-256 in GCM mode. - -commit 1a115d1d1c58db179df6568e9b33fab3e8f80486 -Author: Guus Sliepen -Date: Mon Jan 20 20:16:58 2014 +0100 - - Document clearly that tinc depends on curses and readline libraries. - -commit a3decd09513370fbb3aa22dae11435103d179c30 -Author: Guus Sliepen -Date: Sun Jan 19 21:15:23 2014 +0100 - - Let tinc-gui use correct address family when connecting to tincd via TCP. - -commit c10f3105b354c523d4d4d36b09dd46f890e94a30 -Author: Dennis Joachimsthaler -Date: Fri Jan 17 18:15:40 2014 +0100 - - Ensure tinc-gui running in 64 bits mode can find tinc's 32 bit registry key. - -commit ab583f7e8c550822c63a1a6b73a7a329f622d9e0 -Author: Dennis Joachimsthaler -Date: Fri Jan 17 16:10:10 2014 +0100 - - Fix tinc-gui on Windows. - -commit 11d562e9b2b3ce483b04bb8c8cadb22a0beb1ab6 -Author: Guus Sliepen -Date: Thu Jan 16 14:52:44 2014 +0100 - - Add index entries for the CLI commands. - -commit d8ea66ff1fc68ca9ea672727b0274663df6f4866 -Author: Guus Sliepen -Date: Thu Jan 16 14:46:44 2014 +0100 - - Update the documentation of the tinc command. - -commit 8af6d64fd9dfdd684a56534249e12d201628055c -Author: Guus Sliepen -Date: Thu Jan 16 14:02:56 2014 +0100 - - Clarify StrictSubnets. - -commit c8543bbe6b9ae2de318b0ed4f54cdebcbc3fe5a4 -Author: Florent Clairambault -Date: Sun Dec 29 23:11:54 2013 +0100 - - Adding "conf.d" configuration dir support. - - Any file matching the pattern /etc/tinc/$NETNAME/conf.d/*.conf will be - parsed after the tinc.conf file. - -commit e6b32936c569d9f2ceaea76af2f8f0551d163dd9 -Author: Guus Sliepen -Date: Tue Dec 10 17:13:15 2013 +0100 - - Fix handling of --with-libgcrypt. - -commit b7d59f035bfa2e546428cac2b72318d4f5c517fb -Author: Guus Sliepen -Date: Tue Dec 10 17:02:52 2013 +0100 - - Don't enable -fstack-protector-all. - - It is not supported on all architectures and is problematic on some - platforms. - -commit 53b00f8c1abda0d477c75e4d70a7341301fa1733 -Author: Guus Sliepen -Date: Tue Dec 10 11:18:04 2013 +0100 - - Add our own autoconf check for libgcrypt. - - This one doesn't require one to have libgcrypt installed while running - autoreconf, making life easier for people who compile tinc from git. - -commit 283c5d1cf07f77d29fc1fc2f09532508f5124679 -Author: Guus Sliepen -Date: Tue Dec 10 10:48:00 2013 +0100 - - Enable compiler hardening flags by default. - - Check whether the compiler supports hardening flags and enable them unless - --disable-hardening is specified. - - Conflicts: - configure.ac - -commit ef8efdfff1de2b18092f9d4f383e3f2898bf86cd -Author: Guus Sliepen -Date: Sun Dec 8 21:37:56 2013 +0100 - - Remove erroneous warning about SPTPS being disabled. - -commit be1446f5d0e8831b60ea473a5b7b9ba40f18986e -Author: Guus Sliepen -Date: Sun Dec 8 21:32:21 2013 +0100 - - Don't print an error when no ECDSA key is known for a node using the legacy protocol. - -commit c151cfa2e978e92c1e5394bfcc8b41c6155f8436 -Author: Guus Sliepen -Date: Sun Dec 8 21:31:50 2013 +0100 - - Give full path to unconfigured tinc-up script. - -commit 1b580b2a6beee9d32488a1d95c45de336dee9c2e -Author: Guus Sliepen -Date: Sun Dec 8 21:06:03 2013 +0100 - - Allow running without ECDSA keys If ExperimentalProtocol is not explicitly set. - - To make upgrading less painful, allow running tinc 1.1 without ECDSA keys - unless ExperimentalProtocol is explicitly set to yes. - -commit 41583d5dcfc1277b1a203478de4cce2cd0cda1b1 -Author: Guus Sliepen -Date: Sun Dec 8 20:23:44 2013 +0100 - - Don't print device statistics when exiting tinc. - - Much more detailed statistics are now kept per node, which can be queried at - any time, which makes the device statistics obsolete. - -commit 19b97e79aa63bcb6f81c2dbfd7ca91d89a230387 -Author: Guus Sliepen -Date: Sat Dec 7 22:59:37 2013 +0100 - - Prefer ncurses over curses. - -commit b115de21990ecb1a2f377a73d07ff26e35980aba -Author: Guus Sliepen -Date: Sat Dec 7 22:54:02 2013 +0100 - - Use hardcoded value for TUNNEWPPA if net/if_tun.h is missing on Solaris. - -commit cf9bea4e938f4eec531782e2e947d711cac16014 -Author: Guus Sliepen -Date: Sat Dec 7 22:39:24 2013 +0100 - - Avoid using a variable named "sun". Solaris doesn't like it. - -commit 221f559bcf13febc9a4135c5eb54c236c543ee19 -Author: Guus Sliepen -Date: Sat Dec 7 22:20:10 2013 +0100 - - Stricter check for raw socket support. - -commit c1f7357e7dca18f43f02541cff2684f737512686 -Author: Guus Sliepen -Date: Sat Dec 7 22:19:39 2013 +0100 - - Include for PATH_MAX. - -commit c9bdac68e1b56d34b8fd8bff03bddda1d2cca516 -Author: Guus Sliepen -Date: Sat Dec 7 21:52:41 2013 +0100 - - Update support for Solaris. - - Adds support for the latest TAP driver from - http://www.whiteboard.ne.jp/~admin2/tuntap/, so tinc now also works in switch - mode on Solaris 11. - -commit 06943e828c45d8f4f1da6dc51907499f92957a39 -Author: Guus Sliepen -Date: Thu Dec 5 15:01:30 2013 +0100 - - If no Port is specified, set myport to actual port of first listening socket. - - If the Port statement is not used, there are two other ways to let tinc listen - on a non-default port: either by specifying one or more BindToAddress - statements including port numbers, or by starting it from systemd with socket - activation. Tinc announces its own port to other nodes, but before it only - announced what was set using the Port statement. - -commit 3e924045ccaab1441b77ff43a2d7eb759b313f7b -Author: Guus Sliepen -Date: Thu Dec 5 14:30:00 2013 +0100 - - Mention in the manual that multiple Address staments are allowed. - -commit 51bddfd4dd95161afae2cac4aa5d31970fef5714 -Author: Guus Sliepen -Date: Thu Nov 28 14:19:55 2013 +0100 - - Allow "none" for Cipher and Digest again. - -commit 3d41e7d71247998b7c4a3dd4eacb93bd3529428d -Author: Guus Sliepen -Date: Thu Nov 21 22:13:14 2013 +0100 - - Make LocalDiscovery work for SPTPS packets. - -commit c1703ea9172be05f501d636510834e31d5d4f98c -Author: Guus Sliepen -Date: Wed Nov 20 23:02:20 2013 +0100 - - Remove an unused variable. - -commit 6168a9b6d51b19378af9ba9977227042cf6eafc6 -Author: Guus Sliepen -Date: Fri Nov 15 15:32:53 2013 +0100 - - Fix two warnings from Clang's static analyzer. - -commit 29b42aa17ede17bc67963292e86b186cc09039b1 -Author: Guus Sliepen -Date: Tue Oct 22 21:28:44 2013 +0200 - - Fix sending bulk data starting with a newline. - -commit a5bcb29fdffe9bb2a9dd59c2e315f13fda6d5b34 -Author: Guus Sliepen -Date: Tue Oct 22 21:19:41 2013 +0200 - - Make sptps_test less verbose by default. - -commit 7da999f4aee4e9c8b192769fddbe1c61cd31d7d0 -Author: Guus Sliepen -Date: Fri Oct 18 16:58:47 2013 +0200 - - Clean up child processes from proxy type exec. - -commit 9b2eaebdf6eb46321403bfc6af1145d051d3bbdc -Author: Guus Sliepen -Date: Tue Oct 15 14:09:42 2013 +0200 - - Fix sending empty SPTPS records. - -commit 0da07280882253b792ddf9c6bd8b6690ba585b7a -Author: Guus Sliepen -Date: Sun Oct 13 01:02:52 2013 +0200 - - Use AES-256-GCM for the SPTPS protocol. - - It is faster than AES-256-CTR + HMAC-SHA256, especially on Intel chips with AES - and PCLMULQDQ instructions. - -commit e42bd6009785263b545c1651840943c01461ffda -Author: Guus Sliepen -Date: Fri Sep 27 10:43:56 2013 +0200 - - Fix typos in the documentation. - - Thanks to Thomas Sattler for finding and reporting them. - -commit 68e3efe34980cc82ffc143fc33d3c11b69ec8e2b -Author: Guus Sliepen -Date: Fri Sep 27 11:36:46 2013 +0200 - - Fix segfault when Name = $HOST but $HOST is not set. - - Conflicts: - src/net_setup.c - -commit 22d804d4467cfe9f3926ab6d37b69c3760395b6c -Author: Guus Sliepen -Date: Sun Sep 15 22:03:00 2013 +0200 - - Link sptps_speed with -lrt. - - This is necessary for clock_gettime() on older versions of libc. - -commit c621dd62c74284bfc307a351bec875eb6918bf0f -Author: Guus Sliepen -Date: Sun Sep 15 22:02:33 2013 +0200 - - Don't leak memory during the key generation speed test. - -commit b7b68c3e979994a70f3adb9b40784f65cadf6a75 -Author: Guus Sliepen -Date: Sun Sep 15 17:35:55 2013 +0200 - - Add a benchmark for the SPTPS protocol. - -commit 87b017c71062bbc75ab5a98795abaf87f96ceba6 -Author: Guus Sliepen -Date: Sun Sep 15 16:21:25 2013 +0200 - - Avoid using BIOs. - -commit aaa7caad3d2a03d799264b0d62cddac6b4ee4092 -Author: Guus Sliepen -Date: Sun Sep 15 13:36:53 2013 +0200 - - Wrong date for the 1.1pre9 release in the NEWS. - -commit 85d33e563a0e4ce5910c9ba3b34eba8fbb1cbd30 -Author: Guus Sliepen -Date: Sun Sep 8 17:29:12 2013 +0200 - - Releasing 1.1pre9. - -commit e11daa264615f6eb5782f1f349b23f47518577dd -Author: Guus Sliepen -Date: Sun Sep 8 15:03:06 2013 +0200 - - Don't try to mkdir(CONFDIR) if --config is used. - -commit c25c684a847e11be80916e6de0608f11958d701d -Author: Guus Sliepen -Date: Sun Sep 8 14:47:59 2013 +0200 - - Make sure test scripts end up in the tarball. - -commit 6072759bcb6118923685ace08048c2917425680a -Author: Guus Sliepen -Date: Sun Sep 8 14:42:32 2013 +0200 - - Automake doesn't like info files being mentioned in CLEANFILES. - -commit b80cbaba040775ba20159b20d02c8c903c84e0e1 -Author: Guus Sliepen -Date: Thu Sep 5 17:42:31 2013 +0200 - - Test running ping through two tinc daemons. - - This is a more complicated test with one tinc daemon using a tap interface - (therefore requiring root), and a second one using a multicast interface. A - separate program "pong" is listening on the same multicast address, and waits - for ARP and ICMP packets, responding to ICMP echo packets with replies. - This test doesn't require any configuration of the tap interface. - -commit fe1d0043c81b26f337bdce63dd290d882b01cf21 -Author: Guus Sliepen -Date: Thu Sep 5 17:41:05 2013 +0200 - - Don't return zero-length packets when receiving multicast loopback packets. - -commit 2faf3e91af90716180bde27f54370fe4cbfc64c2 -Author: Guus Sliepen -Date: Thu Sep 5 14:59:56 2013 +0200 - - Add two more test scripts. - -commit 6242b68242646fa94bdacc94be93f0e894ae757e -Author: Guus Sliepen -Date: Thu Sep 5 14:51:13 2013 +0200 - - Fix multicast device. - -commit 09b5a3c02057fe9448c4e9494a99c93a61f98280 -Author: Guus Sliepen -Date: Thu Sep 5 14:50:10 2013 +0200 - - Exit value 1 instead of a random non-zero value. - -commit bdbb710060bef4b3ec63f5592e4def57a4817bd9 -Author: Guus Sliepen -Date: Mon Sep 2 00:15:50 2013 +0200 - - Add a test for invite and join commands. - -commit 566ef6bcbae2bb17c30d500c96331d0c7bdca070 -Author: Guus Sliepen -Date: Mon Sep 2 00:15:18 2013 +0200 - - Also test whether tinc daemons can connect to each other after import/export. - -commit 796c14b75c9e8066b4f68f6ce7cdaddd97c46a87 -Author: Guus Sliepen -Date: Mon Sep 2 00:11:04 2013 +0200 - - Slightly relax the connection rate limit for a single address. - - The restriction of accepting only 1 connection per second from a single address - is a bit too much, especially if one wants to join a VPN using an invitation, - which requires two connections. - -commit 933f7f7526d89a4ad41e2c2936c26cb41997ed78 -Author: Guus Sliepen -Date: Sun Sep 1 22:59:51 2013 +0200 - - Send a RELOAD to a running tincd when a new invitation key has been generated. - -commit 4e7e4818b771af47a10ce0b8f4046ab455ef14a9 -Author: Guus Sliepen -Date: Sun Sep 1 22:58:45 2013 +0200 - - Clean up leftover tincd and sptps_test processes. - -commit b00a6d0666f13b5206b6fcb21479281270169584 -Author: Guus Sliepen -Date: Sun Sep 1 21:55:16 2013 +0200 - - Fix tincd logfile location when running tests. - -commit c179dd0fc8ba0d20e8b29b0a5d2485a637e999e6 -Author: Etienne Dechamps -Date: Sun Sep 1 20:07:32 2013 +0100 - - Fix broken build with --with-openssl, --with-libgcrypt. - - When --with-openssl is used, $openssl is set to the specified path. - Unfortunately, that confuses the OPENSSL conditional which expects it to - be set to "true". The result is that the contents of the openssl/ - directory are not built when --with-openssl is used, resulting in - undefined references and a broken build. - - In addition, there is a typo in the GCRYPT conditional definition - ("grypt" instead of "gcrypt") which means GCRYPT never gets set, - (presumably) breaking builds using libgcrypt. - - These regressions were introduced in - 9b9230a0a79c670b86f54fadd2807b864ff9d91f. - -commit a4e49f45664cfc9414d6eaaa7bd45f1eb3012e37 -Author: Guus Sliepen -Date: Sun Sep 1 21:07:02 2013 +0200 - - Add test for import, export and exchange commands. - -commit 2cd8e2b8e8d60fdeb633afe54eaf38e18afb04dc -Author: Guus Sliepen -Date: Sun Sep 1 21:06:25 2013 +0200 - - Small fixes for tests. - -commit 09cd7ac62a40851a73f0bf7e8721848c10a7b1ff -Author: Guus Sliepen -Date: Sun Sep 1 16:02:49 2013 +0200 - - Make sptps_test more easy to work with. - - It now defers reading from stdin until after the authentication phase is - completed. Furthermore, it supports the -q, -r, -w options similar to those of - Jürgen Nickelsen's socket. - -commit 1cdb0c21d42d600d0e89857f4e9f33843f9372c8 -Author: Guus Sliepen -Date: Sun Sep 1 15:40:59 2013 +0200 - - Some shells set $_ to an absolute path. - -commit 05a7f0b2fb07f8ee7752604a2a87b85f2430aaa3 -Author: Guus Sliepen -Date: Sun Sep 1 00:39:14 2013 +0200 - - Start of a test suite. - -commit d01ab07f78f84d7d30c5788416c8d4ca0e1f74bf -Author: Guus Sliepen -Date: Fri Aug 30 14:23:02 2013 +0200 - - Allow testing the replay window with sptps_test. - -commit ccbf70b66f8e5ac18e672309a7bad899cfc0f400 -Author: Guus Sliepen -Date: Fri Aug 30 14:22:05 2013 +0200 - - Fix the replay window in SPTPS. - -commit c7752ca73e582d63412e7f40984cff2fca02c22f -Author: Guus Sliepen -Date: Fri Aug 30 13:43:23 2013 +0200 - - Fix CTR mode. - -commit d0aa0817d2387e89555ed090d900f61c56b19caa -Author: Guus Sliepen -Date: Fri Aug 30 13:04:14 2013 +0200 - - Add an option to test datagram SPTPS with packet loss. - -commit 5da0ebd421572230fbd213ca0749df6771f4cb10 -Author: Guus Sliepen -Date: Wed Aug 28 14:24:07 2013 +0200 - - When generating invitations, handle any order of Port and Adress statements. - -commit f0e11cd2c55a83662049646d2f6ffba3ac697989 -Author: Guus Sliepen -Date: Tue Aug 27 21:19:50 2013 +0200 - - Call WSAStartup() in main(). - - The tinc utility defered calling WSAStartup() until it tried to connect to a - running tinc daemon. However, socket functions are now also used for other - things (like joining another VPN using an invitation). Now we just - unconditionally call WSAStartup() early in main(). - -commit 82575bd44dc02bd1febd265c1db0f05b298329af -Author: Guus Sliepen -Date: Sat Aug 24 00:48:24 2013 +0200 - - Tell invited node about Mode and Broadcast settings. - - Since these settings really should be the same for all nodes in a VPN. - -commit 57991e264202ad83e2c1b663777b358bf5573652 -Author: Guus Sliepen -Date: Fri Aug 23 19:24:36 2013 +0200 - - Use PATHEXT when checking for the presence of scripts on Windows. - - It seems like a lot of overhead to call access() for every possible extension - defined in PATHEXT, but apparently this is what Windows does itself too. At - least this avoids calling system() when the script one is looking for does not - exist at all. - - Since the tinc utility also needs to call scripts, execute_script() is now - split off into its own source file. - -commit 21184674b38ea1da87588de97dab076c9b9e4a81 -Author: Guus Sliepen -Date: Wed Aug 21 00:24:55 2013 +0200 - - Execute scripts when invitations are created or accepted. - -commit 9699f08afc6420d2bdac1063ea6789b585aaf42e -Author: Guus Sliepen -Date: Tue Aug 20 23:09:36 2013 +0200 - - Ensure the invitation filenames do not reveal the secret cookie. - - Since filenames could potentially leak to unprivileged users (for example, - because of locatedb), it should not contain the cookie used for invitations. - Instead, tinc now uses the hash of the cookie and the invitation key as the - filename to store pending invitations in. - -commit 5dec1c25713a19c49fcbb885200184a9682ef175 -Author: Guus Sliepen -Date: Tue Aug 20 22:36:31 2013 +0200 - - Let a server explicitly send a notification when the invitation protocol succeeded. - -commit c798f7309337fc4c6dec7fd99d45cd76f809ab02 -Author: Guus Sliepen -Date: Tue Aug 20 16:49:03 2013 +0200 - - Use our own infrastructure for finding out the local node's externally visible host name. - -commit 160b7cb5e3e9b7869f6ca38e6a7ab2db39aba979 -Author: Guus Sliepen -Date: Tue Aug 20 16:47:07 2013 +0200 - - Resolve the local host name before generating the invitation file. - -commit 65f5e8fba45c6c51cfdfa2a41ab6db14663cdf73 -Author: Guus Sliepen -Date: Sun Aug 18 23:55:40 2013 +0200 - - Bind outgoing sockets again. - - Commit cff5a84 removed the feature of binding outgoing TCP sockets to a local - address. We now call bind() again, but only if there is exactly one listening - socket with the same address family as the destination address of the outgoing - socket. - -commit 0c54f365534fcb345e87961e71d452e269e170fe -Author: Guus Sliepen -Date: Sun Aug 18 22:43:55 2013 +0200 - - Remove broadcast of KEY_CHANGED message during tinc's initialization. - -commit 09b0b49b98cc16f6b281e4e635c2c70234e38865 -Author: Guus Sliepen -Date: Sun Aug 18 22:35:27 2013 +0200 - - Fix order of tincd's initialization. - - The order in which tinc initialized things was not completely correct. Now, it - is done as follows: - - - Load and parse configuration files. - - Create all TCP and UDP listening sockets. - - Create PID file and UNIX socket. - - Run the tinc-up script. - - Drop privileges. - - Start outgoing connections. - - Run the main loop. - - The PID file can only be created correctly if the listening sockets have been - set up ,as it includes the address and port of the first listening socket. The - tinc-up script has to be run after the PID file and UNIX socket have been - created so it can change their permissions if necessary. Outgoing connections - should only be started right before the main loop, because this is not really - part of the initialization. - -commit 8f8424445810aa7d5e9d4d537494e64811a8e29f -Author: Guus Sliepen -Date: Sun Aug 18 18:20:41 2013 +0200 - - Don't force a .bat extension for scripts under Windows. - -commit b180c1af99c559809d0e7b23fce3022817ec56a9 -Author: Guus Sliepen -Date: Sun Aug 18 17:02:49 2013 +0200 - - Create UNIX socket at the same time as the PID file is created. - - The PID file was created before tinc-up was called, but the UNIX socket was - created afterwards, which meant one could not change the UNIX socket's owner or - permissions from the tinc-up script. - -commit 707914e0e4b45183b1f687b44d97731127df3078 -Author: Guus Sliepen -Date: Wed Aug 14 16:20:32 2013 +0200 - - Remove texi2html rule in docs/Makefile. - - According to Debian, texi2html is deprecated and makeinfo --html should be used - instead. Automake already provides a html target that invokes makeinfo. - -commit 5e50a56dd9ebef71683b60856f904d352a3b89dc -Author: Guus Sliepen -Date: Wed Aug 14 16:17:12 2013 +0200 - - Stop using EXTRA_DIST in src/Makefile.am. - - Automake finds the files in the subdirectories of src/ now that they are - properly declared in the _SOURCES variables. Using EXTRA_DIST would now cause - .o files to be included in the tarball. - -commit 60e774942826cb28c53ac6fd23887162323696e9 -Author: Guus Sliepen -Date: Tue Aug 13 22:05:43 2013 +0200 - - Releasing 1.1pre8. - -commit 6aa864baa626b366f5bba1f1b349a870b68d7c01 -Author: Guus Sliepen -Date: Tue Aug 13 20:40:40 2013 +0200 - - Don't typedef the same struct in two header files. - - Some (older?) versions of GCC don't like this. - -commit 5e00a24e1f13fa70a6945831c409d873b7809d11 -Author: Guus Sliepen -Date: Tue Aug 13 20:38:57 2013 +0200 - - Update copyright notices. - -commit a61d3d1c0b6d0dc1b53040ae2e1a055fb34eb832 -Author: Guus Sliepen -Date: Tue Aug 13 20:37:55 2013 +0200 - - Build .tar.gz instead of .tar.xz. - - Only FreeBSD's tar supports xz compression, the other BSDs do not. NetBSD doesn't even - like bzip2. - -commit 2df534808d75c5898a819a7a4063c7a6f2445bd4 -Author: Guus Sliepen -Date: Tue Aug 13 20:35:48 2013 +0200 - - Move .h files from noinst_HEADERS to tincd_SOURCES. - - This is the recommended way according to the Automake manual. - -commit de8e6bf452227094a8aadd32dd5ea0d94d4b5db9 -Author: Guus Sliepen -Date: Thu Aug 8 17:40:15 2013 +0200 - - Don't echo broadcast packets back when Broadcast = direct. - -commit 81c71203201f6642a496f466660236efdd522ceb -Author: Guus Sliepen -Date: Fri Aug 2 23:51:55 2013 +0200 - - Fix a typo. - -commit 76c90e1639ee900fca4fc858260f0078ba32b9b1 -Author: Guus Sliepen -Date: Fri Aug 2 23:46:19 2013 +0200 - - Non-zero exit code when reloading config file fails after SIGHUP. - - When reloading the configuration file via the tinc command, the user will get - an error message if reloading has failed. However, no such warning exists when - sending a HUP signal. Previously, tincd would exit in both cases, but with a - zero exit code. Now it will exit with code 1 when reloading fails after a - SIGHUP, but tincd will keep running if it is signaled via the tinc command. - Instead, the tinc command will exit with a non-zero exit code. - -commit f3a2bed063d98961d0619ca318185740f8cf6f99 -Author: Guus Sliepen -Date: Fri Aug 2 20:53:54 2013 +0200 - - Really retry outgoing connections immediately if requested. - - The retry() function would only abort connections that were in progress of - being made, it wouldn't reschedule the outgoing connections that had been - sleeping. - -commit 1e7d1cd3c72cc478482fb75b15f9f50745b68504 -Author: Guus Sliepen -Date: Fri Aug 2 20:50:19 2013 +0200 - - Clean up the SIGINT handler. - -commit a38e0d621397d6d69c939ccc287d5a803b668195 -Author: Guus Sliepen -Date: Fri Aug 2 19:27:06 2013 +0200 - - Use umask() to set file and UNIX socket permissions without race conditions. - - As mentioned by Erik Tews, calling fchmod() after fopen() leaves a small window - for exploits. As long as tinc is single-threaded, we can use umask() instead to - reduce file permissions. This also works when creating the AF_UNIX control socket. - - The umask of the user running tinc(d) is used for most files, except for the - private keys, invitation files, PID file and control socket. - -commit a1f4f14c6c5e269c901e6e019418fb8f789cf96b -Author: Guus Sliepen -Date: Fri Jul 26 15:48:52 2013 +0200 - - Defer handling netname conflicts when accepting an invitation. - - In case no explicit netname of configuration directory is specified when - accepting an invitation, the netname specified in the invitation data is - used. However, this new netname is only known after making the connection - to the server. If the new netname conflicts with an existing one at the - client, we ask the user for a netname that doesn't conflict. However, we - should first finish accepting the invitation, so we don't run into the - problem that the server times out and cancels the invitation. So, we create - a random netname and store the files there, and only after we finish - accepting the invitation we ask the user for a better netname, and then - just rename the temporary directory to the final name. - -commit d47c79533f831a2714aff277aff31c46da1ec684 -Author: Guus Sliepen -Date: Fri Jul 26 15:44:05 2013 +0200 - - Make absolutely sure we can write config files before accepting an invitation. - -commit 37cca72e6c973b77b5d11dcf721ae050edc23586 -Author: Guus Sliepen -Date: Fri Jul 26 14:53:36 2013 +0200 - - Choose a different Port when 655 isn't available when doing "tinc join". - -commit 8f2db4afddf109e59c7ec0cdb7ad79db75d698e5 -Author: Guus Sliepen -Date: Fri Jul 26 14:17:15 2013 +0200 - - Choose a different Port when 655 isn't available when doing "tinc init". - - If port 655 cannot be bound to when using the init command, tinc will try to - find a random port number that can be bound to, and will add the appropriate - Port variable to its host config file. A warning will be printed as well. - -commit d6a67266c812a85f11c734503ae5560ab8983edb -Author: Guus Sliepen -Date: Thu Jul 25 17:17:33 2013 +0200 - - Don't forget the Port variable when creating an invitation URL. - -commit d1e01bc880a6970050e55f19bafe8eaf1f0b9be2 -Author: Guus Sliepen -Date: Thu Jul 25 17:14:07 2013 +0200 - - Allow control-C to stop tincd without stopping the tinc shell. - -commit d219fe2c09652fcdc6b457bb5fd72ad18a3a33c5 -Author: Guus Sliepen -Date: Thu Jul 25 16:21:11 2013 +0200 - - Warn when incorrect use of add or set causes variables to be removed. - -commit e6249695684dcddc5d7ae0269adc7764ecec925a -Author: Guus Sliepen -Date: Wed Jul 24 20:48:31 2013 +0200 - - Fix compression when using the SPTPS protocol. - -commit 5fca595b80f5d2a6629d74e89ca2ef46ba9ae292 -Author: Guus Sliepen -Date: Mon Jul 22 22:58:13 2013 +0200 - - Honour umask, let temporary key files inherit original's permissions. - - During the init command, tinc changed the umask to 077 when writing the public - and private key files, to prevent the temporary copies from being world - readable. However, subsequently created files would therefore also be - unreadable for others. Now we don't change the umask anymore, therefore - allowing the user to choose whether the files are world readable or not by - setting the umask as desired. The private key files are still made unreadable - for others of course. Temporary files now inherit the permissions of the - original, and the tinc-up script's permissions now also honour the umask. - -commit ae85a020303d523f24ddf45a816e6a2ceb4fc935 -Author: Etienne Dechamps -Date: Mon Jul 22 21:22:26 2013 +0100 - - Further improve bandwidth estimation for type 2 MTU probe replies. - - This patch adds timestamp information to type 2 MTU probe replies. This - timestamp can then be used by the recipient to estimate bandwidth more - accurately, as jitter in the RX direction won't affect the results. - -commit e3c763eae89df9a69bb2d611238ef18f78de311f -Author: Etienne Dechamps -Date: Sun Jul 21 13:05:42 2013 +0100 - - Introduce lightweight PMTU probe replies. - - When replying to a PMTU probe, tinc sends a packet with the same length - as the PMTU probe itself, which is usually large (~1450 bytes). This is - not necessary: the other node wants to know the size of the PMTU probes - that have been received, but encoding this information as the actual - reply length is probably the most inefficient way to do it. It doubles - the bandwidth usage of the PMTU discovery process, and makes it less - reliable since large packets are more likely to be dropped. - - This patch introduces a new PMTU probe reply type, encoded as type "2" - in the first byte of the packet, that indicates that the length of the - PMTU probe that is being replied to is encoded in the next two bytes of - the packet. Thus reply packets are only 3 bytes long. - - (This also protects against very broken networks that drop very small - packets - yes, I've seen it happen on a subnet of a national ISP - in - such a case the PMTU probe replies will be dropped, and tinc won't - enable UDP communication, which is a good thing.) - - Because legacy nodes won't understand type 2 probe replies, the minor - protocol number is bumped to 3. - - Note that this also improves bandwidth estimation, as it is able to - measure bandwidth in both directions independently (the node receiving - the replies is measuring in the TX direction) and the use of smaller - reply packets might decrease the influence of jitter. - -commit e3a4672afb8eb341b380e74b2bf6d098f61c08a3 -Author: Etienne Dechamps -Date: Sat Jul 20 22:59:57 2013 +0100 - - Disable PMTU discovery when TCPOnly is set. - - Obviously, PMTU discovery doesn't make much sense when we know we'll be - using TCP anyway. - -commit b03bbaa38561e790873de3adabc3d4405be17fb8 -Author: Guus Sliepen -Date: Sun Jul 21 00:20:54 2013 +0200 - - Allow extra options to be passed to "tinc restart" again. - -commit e82bec667059b370b0cfd5df2a34647b8f32829c -Author: Guus Sliepen -Date: Sun Jul 21 00:13:38 2013 +0200 - - Forbid protocol version rollback. - - When we know a node's ECDSA key, we only allow communication via the SPTPS - protocol. - -commit fab2965d381f2f71ea8d249d30294918e954d2db -Author: Guus Sliepen -Date: Sat Jul 20 23:41:01 2013 +0200 - - Attribution for Etienne Dechamps. - -commit 51c1639884b409a98a4581a7b661ef65b94e9d86 -Author: Etienne Dechamps -Date: Sat Jul 20 14:50:28 2013 +0100 - - Fix hash_function(). - - The hashing function that tinc uses is currently broken as it only looks - at the first 4 bytes of data. - - This leads to interesting bugs, like the node UDP address cache being - subtly broken because two addresses with the same protocol and port (but - not the same IP address) will override each other. This is because - the first four bytes of sockaddr_in contains the IP protocol and port, - while the IP address itself is contained in the four remaining bytes - that are never used when the hash is computed. - -commit 182890814881be90e28ac5183039e25709766992 -Author: Guus Sliepen -Date: Wed Jul 17 18:06:56 2013 +0200 - - Don't use vasprintf() anymore on Windows. - - Windows doesn't actually support it, but MinGW provides it. However, with some versions of - MinGW it doesn't work correctly. Instead, we vsnprintf() to a local buffer and xstrdup() the - results. - -commit 54127996ca4156668b6c7df3bb5d8f952dc598ad -Author: Guus Sliepen -Date: Wed Jul 17 18:02:07 2013 +0200 - - Don't search in local directories for include files. - - Tinc's source code doesn't rely on this anymore, and this gets rid of potential conflicts with - system headers. - -commit fb1e69072e9c1dda35033cc2785c27e324a2abda -Author: Guus Sliepen -Date: Wed Jul 17 18:00:40 2013 +0200 - - Add missing definitions on Windows. - -commit 918067f117d5b9983a8f2273fd81983362a2ff88 -Author: Guus Sliepen -Date: Mon Jul 15 14:48:43 2013 +0200 - - Fix warning "Both netname and configuration directory given" on Windows. - -commit 633b7cbb452ea19e515cadee9bc63e631f8183c2 -Author: Etienne Dechamps -Date: Sat Jul 13 23:34:42 2013 +0100 - - Fix combination of Mode = router and DeviceType = tap on Linux. - - I believe I have found a bug in tinc on Linux when it is used with - Mode = router and DeviceType = tap. This combination is useful because - it allows global broadcast packets to be used in router mode. However, - when tinc receives a packet in this situation, it needs to make sure its - destination MAC address matches the address of the TAP adapter, which is - typically not the case since the sending node doesn't know the MAC - address of the recipient. Unfortunately, this is not the case on Linux, - which breaks connectivity. - -commit 24e3ec863ec463186501f76961c6d4b1dfe122af -Author: Guus Sliepen -Date: Thu Jul 11 23:38:38 2013 +0200 - - Add connection rate limiting. - - Tinc now strictly limits incoming connections from the same host to 1 per - second. For incoming connections from multiple hosts short bursts of incoming - connections are allowed (by default 100), but on average also only 1 connection - per second is allowed. - - When an incoming connection exceeds the limit, tinc will keep the connection in - a tarpit; the connection will be kept open but it is ignored completely. Only - one connection is in a tarpit at a time to limit the number of useless open - connections. - -commit 2eba7933053d7d21bf82e647978ee90abe98dc3a -Author: Guus Sliepen -Date: Fri Jul 5 21:36:51 2013 +0200 - - Set $NAME when calling host-up/down and subnet-up/down scripts. - -commit b811e980e3a2a301c019459b91df2252468fd572 -Author: Guus Sliepen -Date: Fri May 31 18:50:34 2013 +0200 - - Add the LocalDiscoveryAddress option. - - When LocalDiscovery is enabled, tinc normally sends broadcast packets during - PMTU discovery to the broadcast address (255.255.255.255 or ff02::1). This - option lets tinc use a different address. - - At the moment only one LocalDiscoveryAddress can be specified. - -commit e92b2004e20e1c8e6bc56f97bf4a45c6da4a630c -Author: Guus Sliepen -Date: Fri May 31 17:23:00 2013 +0200 - - Use strerror() instead of gai_strerror() when err == EAI_SYSTEM. - -commit ce5e0f6557edba19f8077661c034f48cdfd64b9a -Author: Guus Sliepen -Date: Thu May 30 17:38:48 2013 +0200 - - Allow the log output to be stopped with control-C in tinc's shell. - -commit 6bf3595a915111770b7a167c54ccbca86cfbec78 -Author: Guus Sliepen -Date: Thu May 30 16:53:16 2013 +0200 - - Better optional argument handling. - - Some options can take an optional argument. However, in this case GNU getopt - requires that the optional argument is right next to the option without - whitespace inbetween. If there is whitespace, getopt will treat it as a - non-option argument, but tincd ignored those without a warning. Now tincd will - allow optional arguments with whitespace inbetween, and will give an error when - it encounters any other non-option arguments. - - The tinc binary now requires that all options for itself are given before the - command. - -commit ced4c1a327b321a6d73028a3a15b41b0be64d910 -Author: Guus Sliepen -Date: Wed May 29 18:31:10 2013 +0200 - - Add an invitation protocol. - - Using the tinc command, an administrator of an existing VPN can generate - invitations for new nodes. The invitation is a small URL that can easily - be copy&pasted into email or live chat. Another person can have tinc - automatically setup the necessary configuration files and exchange keys - with the server, by only using the invitation URL. - - The invitation protocol uses temporary ECDSA keys. The invitation URL - consists of the hostname and port of the server, a hash of the server's - temporary ECDSA key and a cookie. When the client wants to accept an - invitation, it also creates a temporary ECDSA key, connects to the server - and says it wants to accept an invitation. Both sides exchange their - temporary keys. The client verifies that the server's key matches the hash - in the invitation URL. After setting up an SPTPS connection using the - temporary keys, the client gives the cookie to the server. If the cookie - is valid, the server sends the client an invitation file containing the - client's new name and a copy of the server's host config file. If everything - is ok, the client will generate a long-term ECDSA key and send it to the - server, which will add it to a new host config file for the client. - - The invitation protocol currently allows multiple host config files to be - send from the server to the client. However, the client filters out - most configuration variables for its own host configuration file. In - particular, it only accepts Name, Mode, Broadcast, ConnectTo, Subnet and - AutoConnect. Also, at the moment no tinc-up script is generated. - - When an invitation has succesfully been accepted, the client needs to start - the tinc daemon manually. - -commit 12e68b95e6a84582a016492a467d0a16337a3c4b -Author: Guus Sliepen -Date: Tue May 28 13:41:53 2013 +0200 - - Fix port number in pidfile. - -commit cbe03b09324dcf930e9bec71a809c66e2d3d77d5 -Author: Guus Sliepen -Date: Tue May 28 13:40:32 2013 +0200 - - Add a newline when logging to stderr in the tinc binary. - -commit c3d357af6c73d538f7cbcaca293ebbca666d3a82 -Author: Guus Sliepen -Date: Tue May 28 13:39:15 2013 +0200 - - Improve base64 encoding/decoding, add URL-safe variant. - - b64decode() now returns length 0 when an invalid character was encountered. - -commit ad93dc3a4b89799e8d5c1154e1dacc5b9a31c83b -Author: Guus Sliepen -Date: Tue May 28 13:36:26 2013 +0200 - - Annotate the xalloc functions. - - Most important is the annotation of xasprintf() with the format attribute, - which allows the compiler to give warnings about the format string and - arguments. - -commit bc87b450034382858822b918f43bdf31ad8e6995 -Author: Guus Sliepen -Date: Sat May 18 16:11:30 2013 +0200 - - Send a new key when we receive packets from a node we don't have a valid key for. - -commit a9b80226e10b0a957604ad55edd945f49bc5f334 -Author: Guus Sliepen -Date: Wed May 15 13:55:06 2013 +0200 - - Enable and fix warnings from automake. - -commit a518f82af79036527cb8d1a592a6778ec1657e9c -Author: Sven-Haegar Koch -Date: Tue May 14 02:57:35 2013 +0200 - - Modified some error messages in src/sptps.c. - -commit fa20cfceecee1756ecb7882b6fe9167f4db92777 -Author: Guus Sliepen -Date: Sun May 12 13:39:22 2013 +0200 - - Don't try to handle incoming data if sptps_start() has not been called yet. - -commit 52f64cdf954a525bf7de1c5f9d3be60dfbe220b5 -Author: Guus Sliepen -Date: Sat May 11 16:54:50 2013 +0200 - - Fix potential NULL pointer dereferences. - -commit d03dc91e27b31851f87351c03cfc9a43c1b06458 -Author: Guus Sliepen -Date: Sat May 11 14:13:23 2013 +0200 - - Don't free ephemeral ECDH keys twice. - - ecdh_compute_shared() was changed to immediately delete the ephemeral key after - the shared secret was computed. Therefore, the pointer to the ecdh_t struct - should be zeroed so it won't be freed again when a struct sptps_t is freed. - -commit fc119fb0096a9221f2cff279b07c886bcd794d28 -Author: Guus Sliepen -Date: Sat May 11 14:05:28 2013 +0200 - - Use read_host_config() where appropriate. - -commit 3c163a3796c984deb874fb1cca1ed9a85fc1d087 -Author: Guus Sliepen -Date: Sat May 11 14:04:39 2013 +0200 - - Fix check for presence of ECDSA public key for outgoing connections. - - At this point, c->config_tree may or may not be NULL, but this does not tell us whether it is an - outgoing connection or not. For incoming connections, we do not know the peer's name yet, - so we always have to claim ECDSA support. For outgoing connections, we always need to check - whether we have the peer's ECDSA public key, so that if we don't, we correctly tell the peer that - we want to upgrade. - -commit c83c2d080f21b12db42ef664d7c3272b8b700656 -Author: Guus Sliepen -Date: Fri May 10 21:11:45 2013 +0200 - - Enable the SPTPS protocol by default. - -commit ee34ac3d6125b7d1f41afa82c7e30f0a7205546c -Author: Guus Sliepen -Date: Fri May 10 20:55:52 2013 +0200 - - Add a few more checks and warnings in the crypto functions. - -commit 214060ef20499332b0369030b664a8e239518661 -Author: Guus Sliepen -Date: Fri May 10 20:30:47 2013 +0200 - - Fix warnings for functions marked __attribute((warn_unused_result)). - -commit 7b949262c4c01fdeff30a612d43f4b64f1ad426f -Author: Guus Sliepen -Date: Fri May 10 20:23:01 2013 +0200 - - Add __attribute__((warn_unused_result)) to crypto functions. - -commit 45063953fd3f2c25c7f8cc65860b32a35b3ba80e -Author: Guus Sliepen -Date: Fri May 10 20:15:27 2013 +0200 - - Add more __attribute__((malloc)) where appropriate. - -commit 0acdce222ff21c84cafc82c137e3d1e107a66fd9 -Author: Guus Sliepen -Date: Wed May 1 17:45:38 2013 +0200 - - Add generic crypto headers. - - They should have been included in commit 9b9230a. - -commit 5b07039b0712bee0f19749d63116a10fb08a2d8b -Author: Guus Sliepen -Date: Wed May 1 17:31:33 2013 +0200 - - Rename xmalloc_and_zero() to xzalloc(). - - The former name is more or less only used by tinc, the latter is used by other - projects as well, and shorter as well. - -commit 9b9230a0a79c670b86f54fadd2807b864ff9d91f -Author: Guus Sliepen -Date: Wed May 1 17:17:22 2013 +0200 - - Use conditional compilation for cryptographic functions. - - This gets rid of the rest of the symbolic links. However, as a consequence, the - crypto header files have now moved to src/, and can no longer contain - library-specific declarations. Therefore, cipher_t, digest_t, ecdh_t, ecdsa_t - and rsa_t are now all opaque types, and only pointers to those types can be - used. - -commit e70b5b5bd77bb66e8dd324c17d86d9bff151aa82 -Author: Guus Sliepen -Date: Wed May 1 12:20:06 2013 +0200 - - Use conditional compilation for device.c. - - This requires the automake option "subdir-objects" to be enabled, and it - becomes more critical to specify the exact path to local header files. - -commit 9f8020a09ce08210a10a0c65cefd83d2646395ab -Author: Guus Sliepen -Date: Wed May 1 11:46:40 2013 +0200 - - Modernize the configure script a bit. - -commit 43c72093ade72f14cb2fc78bef55dade8cd38df7 -Author: Guus Sliepen -Date: Sun Apr 28 19:33:04 2013 +0200 - - Don't try to create tinc.conf when using set or add commands. - - It is almost certainly an error. If one really wants to create a new tinc.conf - file, one should use the init command. - -commit 8e732fcbbb5ac627ea302bf5c0ea17ec9b3cea7c -Author: Guus Sliepen -Date: Mon Apr 22 15:54:05 2013 +0200 - - Releasing 1.1pre7. - -commit 258bf7ea0fe69bae395a084843ba59b9770199f1 -Author: Guus Sliepen -Date: Fri Apr 12 17:15:05 2013 +0200 - - Drop packets forwarded via TCP if they are too big (CVE-2013-1428). - - Normally all requests sent via the meta connections are checked so that they - cannot be larger than the input buffer. However, when packets are forwarded via - meta connections, they are copied into a packet buffer without checking whether - it fits into it. Since the packet buffer is allocated on the stack, this in - effect allows an authenticated remote node to cause a stack overflow. - - This issue was found by Martin Schobert. - -commit 9e2ae03d1dc3b0d9a32a748320b9ed1565fa1374 -Author: Guus Sliepen -Date: Tue Mar 12 11:28:40 2013 +0100 - - Fix completion of add/del/get/set commands. - -commit f8f250ca1289990cb1fe69dfa252f0796aa38255 -Author: Guus Sliepen -Date: Tue Mar 12 10:49:45 2013 +0100 - - Describe the SPTPS protocol in the manual. - - Also mention that Cipher, Digest and MACLength have no influence on the SPTPS protocol, - since that uses a fixed ciphersuite. - -commit 40666a5f5b85aa0151c3ba60950267f3c2a3a6bc -Author: Guus Sliepen -Date: Fri Mar 8 16:26:21 2013 +0100 - - Remove references to the config keyword. - -commit 23a634becf09ac84c71250474fcb96e23b0ebdf1 -Author: Guus Sliepen -Date: Fri Mar 8 16:22:56 2013 +0100 - - Rename tincctl to tinc. - -commit 3793cf10da488b9f4f7a1ac71f60bc270bdf31c6 -Author: Guus Sliepen -Date: Fri Mar 8 14:12:48 2013 +0100 - - Include README.android in the tarballs. - -commit 4c30004cb6dc23616d7295b0ce631f066e7f1f82 -Author: Guus Sliepen -Date: Fri Mar 8 14:11:15 2013 +0100 - - Avoid calling time(NULL). - - In most cases we can use the cached time. - -commit af77e5d475d4d4ab7ad036e926a05f4f3b5c6589 -Author: Guus Sliepen -Date: Fri Mar 8 11:40:40 2013 +0100 - - Allow changing configuration with tincctl without the "config" keyword. - - This saves typing some characters, and forces one to be more explicit about the - desired command (get, set). - -commit 1d226977a43cc6c3e4ff32e1a41a06dde08356e0 -Author: Guus Sliepen -Date: Fri Mar 8 11:24:37 2013 +0100 - - Better default output file for generated public keys. - -commit f9ab8e266b93aa3be772374ef4a8fdb06e376568 -Author: Guus Sliepen -Date: Fri Mar 1 17:15:26 2013 +0100 - - Flush output buffers in the tap reader thread on Windows. - - This is basically a port of commit 50fcfea1 to 1.1. - -commit 4d05e695ab68a16cc5ed853b50482c443c6e12a9 -Author: Guus Sliepen -Date: Fri Feb 22 15:37:48 2013 +0100 - - Use UDP when using sptps_test in datagram mode. - -commit a93c0139c5734f89180483b5fe160b334f7ece4b -Author: Guus Sliepen -Date: Wed Feb 20 15:35:19 2013 +0100 - - Releasing 1.1pre6. - -commit d298ebe91c9209d139f38b6de2e42bf7c5bb5899 -Author: Guus Sliepen -Date: Wed Feb 20 15:35:08 2013 +0100 - - Fix compiler warnings on some BSD variants. - -commit 3847b78ba5900fe4311e9ef62474e32e1a6750e5 -Author: Guus Sliepen -Date: Wed Feb 20 14:39:24 2013 +0100 - - Fix compiler warnings on Windows. - -commit 1bb969c9306812d0d5c954fe8db32ed1a248bf20 -Author: Guus Sliepen -Date: Wed Feb 20 13:59:50 2013 +0100 - - Fix a tiny memory leak. - - Found by cppcheck. - -commit d21f63d5b39280b653ca72a272f3a70c7c3f03be -Author: Guus Sliepen -Date: Fri Feb 8 16:44:50 2013 +0100 - - Don't expect a response from tincd after sending REQ_STOP. - -commit 26eca516508829c3f9d8f2549335f613b569e8f5 -Author: Guus Sliepen -Date: Thu Feb 7 15:27:16 2013 +0100 - - Let the GUI use UNIX sockets if available. - -commit a8b52becbbd86a52dc50a6a1b725a80737f2c760 -Author: Guus Sliepen -Date: Thu Feb 7 15:26:56 2013 +0100 - - Derive UNIX socket filename from PID filename. - -commit 079dcd01794187d2857e1233f6c9930310812593 -Author: Guus Sliepen -Date: Thu Feb 7 14:22:28 2013 +0100 - - Don't send proxy requests for incoming connections. - -commit ee63f2a32be398c31301e9ce9154511b24089d8d -Author: Guus Sliepen -Date: Wed Feb 6 15:24:02 2013 +0100 - - Fix segmentation fault when trying to connect via a SOCKS5 proxy. - -commit 053af97c9e729ab485609e4202f5195fdc8aeeb5 -Author: Guus Sliepen -Date: Wed Feb 6 15:12:53 2013 +0100 - - Check for writability when waiting for a socket to finish connecting. - - We were checking only for readability, which is not a problem for normal - connections, since the server side of a connection will always send an ID - request. But when using a proxy, the proxy server doesn't send anything before - the client, so tinc would not see that its connection to the proxy had already - been established. - -commit 1135669b3c6820f5473ea451a58865f552ba768f -Author: Guus Sliepen -Date: Wed Feb 6 11:30:35 2013 +0100 - - Fix tincd terminating immediately on Windows. - -commit 9c878bf56f81049397a35d3a41aa69749c697fce -Author: Guus Sliepen -Date: Thu Jan 31 16:12:56 2013 +0100 - - Remove direct inclusion of OpenSSL headers in net_packet.c and tincd.c. - -commit 42b222ecb66b1957d7b439e5d8be8b287aef0054 -Author: Guus Sliepen -Date: Thu Jan 31 15:58:33 2013 +0100 - - Detect increases in PMTU. - - Tinc never restarts PMTU discovery unless a node becomes unreachable. However, - it can be that the PMTU was very low during the initial discovery, but has - increased later. To detect this, tinc now tries to send an extra packet every - PingInterval, with a size slightly higher than the currently known PMTU. If - this packet is succesfully received back, we partially restart PMTU discovery - to find out the new maximum. - - Conflicts: - src/net_packet.c - -commit 87416bcd8bd3e8816750150e2dbe90a970400a00 -Author: Guus Sliepen -Date: Mon Jan 21 16:12:18 2013 +0100 - - Get microsecond time resolution on Windows. - -commit 8aadbd4b37cddaf021949e93bceab98146f4c499 -Author: Guus Sliepen -Date: Mon Jan 21 13:59:52 2013 +0100 - - Fix a typo. - -commit 3a039ece25198c87e67950f0c4687587bf268075 -Author: Guus Sliepen -Date: Mon Jan 21 13:47:46 2013 +0100 - - Fix datagram SPTPS. - - Commit dd07c9fc1f37bed8d1f67ffe7b203f61e7914edf broke the reception of datagram - SPTPS packets, by undoing the conversion of the sequence number to host byte - order before comparison. This caused error messages like "Packet is 16777215 - seqs in the future, dropped (1)". - -commit cc3c69c892b0dad9a6ece0a0f4ccd429a22fcbff -Author: Guus Sliepen -Date: Sun Jan 20 21:03:22 2013 +0100 - - Releasing 1.1pre5. - -commit 76dbcf89895e87144e1bcb3b5cb98ffce03c383b -Author: Guus Sliepen -Date: Sun Jan 20 21:02:58 2013 +0100 - - Fix tincctl init when /etc/tinc does not yet exist. - -commit aa465969918ce3f3332f5829dbc482fc3b732012 -Author: Guus Sliepen -Date: Sun Jan 20 20:19:08 2013 +0100 - - Remove possible definition of timersub(), which is also in dropin.h. - -commit 1be7dc759a64d436fd7586aad43b545f2dc665b5 -Author: Guus Sliepen -Date: Sun Jan 20 15:16:13 2013 +0100 - - Make sure PriorityInheritance also works in switch mode. - - Conflicts: - src/route.c - -commit 94587264bda45cce0295aaa37b59905d4b9843a8 -Author: Guus Sliepen -Date: Thu Jan 17 18:12:55 2013 +0100 - - Allow connections via UNIX sockets. - - This is mainly useful for control connections. The client must still present - the control cookie from the PID file. - -commit 2c1412306242d26f7803829873e582b50adde922 -Author: Guus Sliepen -Date: Thu Jan 17 16:39:41 2013 +0100 - - Fix compilation of UML and VDE device support. - -commit f5bb64b36ae0807cdd3f241f81a8e933065437f6 -Author: Guus Sliepen -Date: Thu Jan 17 16:39:02 2013 +0100 - - Move make_names() and related variables to its own source file. - -commit a9eba276a4ccec1c67611e8496ac0a30137b7493 -Author: Guus Sliepen -Date: Thu Jan 17 14:14:17 2013 +0100 - - Handle SIGINT gracefully. - -commit 1ddd6111a40733929089316838020f89176cbda2 -Author: Guus Sliepen -Date: Thu Jan 17 11:21:18 2013 +0100 - - Fix the minimum spanning tree algorithm. - - Tinc uses Kruskal's algorithm to calculate a MST. However, this was broken in - commit 6e80da3370249caa1082c23c3ef55f338d1e9e74. Revert back to the working - algorithm from tinc 1.0. - - Thanks to Cheng LI for spotting the problem. - -commit 61275547cdf950e1c4499f19044ff171a9a74af7 -Author: Guus Sliepen -Date: Wed Jan 16 16:31:56 2013 +0100 - - Estimate RTT, bandwidth and packet loss between nodes. - - Without adding any extra traffic, we can measure round trip times, estimate the - bandwidth and packet loss between nodes. The RTT and bandwidth can be measured - by timing the MTU probe packets. The RTT is the difference between the time a - burst of MTU probes was sent and when the first reply is received. The - bandwidth can be estimated by multiplying the size of the probe packets by the - time between succesive received probe replies of the same burst. The packet - loss can be estimated for incoming traffic by comparing how many packets have - actually been received to the increase in the sequence numbers. - - The estimates are not perfect. Especially bandwidth is difficult to measure, - the only accurate way is to continuously send as much data as possible, but - that is obviously not desirable. The packet loss rate is also almost always - a few percent when sending a lot of data over the VPN via TCP, since TCP - *needs* packet loss to work properly. - -commit eef25266cb862b5e2c24450d158d99e3cb43e511 -Author: Guus Sliepen -Date: Tue Jan 15 13:33:16 2013 +0100 - - Count the number of correctly received UDP packets. - - Keep track of the number of correct, non-replayed UDP packets that have been - received, regardless of their content. This can be compared to the sequence - number to determine the real packet loss. - -commit b50a92d0c3d26edfeb7c8d6c1b8c3adc28edd6fe -Author: Guus Sliepen -Date: Tue Jan 15 13:31:51 2013 +0100 - - Add the tincctl exchange and exchange-all commands. - - These are identical to an export/export-all followed by an import, and make - it simpler to exchange host config files with other nodes. - -commit dd07c9fc1f37bed8d1f67ffe7b203f61e7914edf -Author: Guus Sliepen -Date: Mon Jan 14 13:08:35 2013 +0100 - - Check HMAC before sequence number. - -commit 83a94ab08fb36b88a473a56b164a9795637fe798 -Author: Guus Sliepen -Date: Mon Jan 14 13:02:39 2013 +0100 - - Always complain if too many arguments are given for tincctl commands. - -commit 50e1790101efa1d695ce27498e7d7dede7ed3f9b -Author: Guus Sliepen -Date: Mon Jan 14 13:01:47 2013 +0100 - - Better error messages when using -L, -R or -U on platforms that do not support it. - -commit cad86108f3a47e9bba885ccd8decf20057f909f7 -Author: Guus Sliepen -Date: Mon Jan 14 12:59:17 2013 +0100 - - Don't complain about garbage if we skipped importing a host file. - -commit c90c431bc93c1478836149a8724fdc68d1ec455c -Author: Guus Sliepen -Date: Mon Jan 14 12:58:24 2013 +0100 - - Mention that the -L, -R and -U options are not supported on all platforms. - -commit 5b88f5ba74fa9aa2cad82576308847e08cea88b1 -Author: Guus Sliepen -Date: Mon Jan 14 12:57:33 2013 +0100 - - Note that tincctl import is only meant to work with data from tincctl export. - -commit bb228e2f058c1274dca29ba255714e6fa2be494f -Author: Guus Sliepen -Date: Mon Jan 14 12:56:54 2013 +0100 - - Note that node Names are case sensitive. - -commit 2c7ecdcd0c50d4d3da6ff0b8fc2ea39573338d7f -Author: Guus Sliepen -Date: Mon Jan 14 12:56:14 2013 +0100 - - Fix a typo. - -commit 17a0b3a8907d7e618eb94ee2792d10c7cb8d3f30 -Author: Guus Sliepen -Date: Sun Dec 16 15:36:06 2012 +0100 - - Fix support for tunemu on iOS devices. - - The actual code was fine but the #ifdefs tested for the wrong preprocessor - variable. - - Conflicts: - src/bsd/device.c - src/process.c - -commit c26581e29f1f8f23217da266b57082e81dfc8320 -Author: Guus Sliepen -Date: Fri Dec 7 15:49:21 2012 +0100 - - Fix infinite loop in timeout handling on Windows. - -commit 58026f72a17b316f1b9756400f0ee9e9f519f877 -Author: Guus Sliepen -Date: Thu Dec 6 16:57:57 2012 +0100 - - Fix display of cumulative packet counters. - -commit b300f99dfbda5fc57a5366cdcb2a347e38723417 -Author: Guus Sliepen -Date: Thu Dec 6 16:55:28 2012 +0100 - - Clarify the description of IndirectData and Mode = router. - -commit 5b7f42bca4dbfee7a5fa2bc119f4739baaeb2f55 -Author: Guus Sliepen -Date: Wed Dec 5 22:32:10 2012 +0100 - - Releasing 1.1pre4. - -commit 4c16094e949e1f17461ac744118076a3cec437e8 -Author: Guus Sliepen -Date: Wed Dec 5 21:42:43 2012 +0100 - - Fix whitespace. - -commit 4f8abf1b29b117c5d593bfa7703966fd88e9eace -Author: Guus Sliepen -Date: Wed Dec 5 21:40:49 2012 +0100 - - Scale packet counters similar to byte counters. - -commit d5f0ff5df86d06825110527ddc252b1268e31479 -Author: Guus Sliepen -Date: Wed Dec 5 21:33:01 2012 +0100 - - Don't use nested functions. - - This allows tinc to be compiled with Clang. - -commit eb80105ea855f2c7ee0ea467574acf86cf455a77 -Author: Guus Sliepen -Date: Wed Dec 5 14:42:21 2012 +0100 - - Fix compiler warnings on OpenBSD. - -commit 5e3607b616538eac7bb70d78d4f20d847a1c3064 -Author: Guus Sliepen -Date: Mon Dec 3 13:09:40 2012 +0100 - - Remove GraphDumpFile from the manual and manpages. - - This option is not supported in tinc 1.1, "tincctl dump graph" can be used - instead. - -commit a717b9bcfbe811787fd6718fb3f8fb3f272bcfb9 -Author: Guus Sliepen -Date: Mon Dec 3 13:08:03 2012 +0100 - - Add option to dump only a list of reachable nodes. - -commit 75c619e372f02f8225d158fd514f01bd04857d3b -Author: Guus Sliepen -Date: Mon Dec 3 10:41:28 2012 +0100 - - More fixes for Windows. - - In particular, Windows does support many of the timer* macros, except timeradd - and timersub. - -commit d53384c2de6d2824b9adcec111301d86e6b25f8e -Author: Guus Sliepen -Date: Mon Dec 3 09:08:21 2012 +0100 - - Fix compiler error on Windows. - -commit 76816e119b7d38a14823d430aafeff362dfbfd41 -Author: Guus Sliepen -Date: Mon Dec 3 09:07:23 2012 +0100 - - Fix crash in timeout handling. - -commit d19b00606576d19ef206e363ac709daf3bd00f25 -Author: Guus Sliepen -Date: Mon Dec 3 09:02:08 2012 +0100 - - Set a node's pointers to zero before trying to insert it into a tree. - -commit d2b19be1a0dd3c4987aa926117f5bf281892c78b -Author: Guus Sliepen -Date: Thu Nov 29 14:35:08 2012 +0100 - - Fix use of unitialised values in hash tables. - - Not only was Valgrind unhappy about it, it could also result in cache misses. - -commit d9c70767aa6da8b62b4a1034d5f07892603beddd -Author: Guus Sliepen -Date: Thu Nov 29 14:32:12 2012 +0100 - - Fix check for expired events. - - This would trigger a infinite loop if a timeout expired and the next timeout - was not expired yet, but less than 1 second from being expired. - -commit 8825cddd0d8ed6dad00924ef382139da51ca3fc4 -Author: Guus Sliepen -Date: Thu Nov 29 12:37:04 2012 +0100 - - Allow multiple timeouts to expire at the exact same time. - -commit 6bc5d626a8726fc23365ee705761a3c666a08ad4 -Author: Guus Sliepen -Date: Thu Nov 29 12:28:23 2012 +0100 - - Drop libevent and use our own event handling again. - - There are several reasons for this: - - - MacOS/X doesn't support polling the tap device using kqueue, requiring a - workaround to fall back to select(). - - On Windows only sockets are properly handled, therefore tinc uses a second - thread that does a blocking ReadFile() on the TAP-Win32/64 device. However, - this does not mix well with libevent. - - Libevent, event just the core, is quite large, and although it is easy to get - and install on many platforms, it can be a burden. - - Libev is more lightweight and seems technically superior, but it doesn't - abstract away all the platform differences (for example, async events are not - supported on Windows). - -commit d30b9e1272fef18070d37d10b2b3e4bb2fc07f59 -Author: Guus Sliepen -Date: Mon Nov 19 14:20:50 2012 +0100 - - Ensure MTU probe replies are sent back the same way they came in. - - Also sprinkle some comments over mtu_probe_h(). - -commit 3c1b7047332f4b5e9d5ae7109e696b33712a5fb2 -Author: Guus Sliepen -Date: Mon Nov 19 13:50:17 2012 +0100 - - Improve UDP address selection. - - We don't need to search the whole edge tree, we can use the node's own edge - tree since each edge has a pointer to its reverse. Also, we do need to make - sure we try the reflexive address often. - -commit f57129ce3439f3826c12f15feb5df05e5ad8cab9 -Author: Guus Sliepen -Date: Sat Nov 17 22:48:06 2012 +0100 - - Try all known addresses of node during PMTU discovery, now also for SPTPS. - -commit 30404650b28bf72d0b05b55393f2dd492434f9f3 -Author: Guus Sliepen -Date: Sat Nov 17 22:14:52 2012 +0100 - - Choose a suitable socket when updating a node's UDP address. - -commit 8f9ee895224b39347783f3119343efc3bdaa3511 -Author: Guus Sliepen -Date: Thu Nov 15 11:24:18 2012 +0100 - - Also don't use poll() on MacOS/X. - -commit 8a77df9e28114cbfd83351070fdb266cf31fc310 -Author: Guus Sliepen -Date: Thu Nov 15 11:13:40 2012 +0100 - - Disable support for kqueue on MacOS/X. - - Apparently MacOS/X doesn't support kqueue events on character devices. - -commit 818c92e6583006bf2e38f1027044925df6cf0ca0 -Author: Guus Sliepen -Date: Wed Nov 14 10:44:35 2012 +0100 - - Remove text saying you must have one of PrivateKey or PrivateKeyFile in tinc.conf. - -commit e8bf81794f412b27261be0f2aa4eb287352041af -Author: Guus Sliepen -Date: Tue Nov 13 15:05:41 2012 +0100 - - Send broadcast packets using a random socket, and properly support IPv6. - - Before it would always use the first socket, and always send an IPv4 broadcast packet. That - works fine in a lot of situations, but it is better to try all sockets, and to send IPv6 packets - on IPv6 sockets. This is especially important for users that are on IPv6-only networks or that - have multiple physical network interfaces, although in the latter case it probably requires - them to use the ListenAddress variable to create a separate socket for each interface. - -commit 0870c7c32cf8a24f234fc066df867747ddb1ddc7 -Author: Guus Sliepen -Date: Tue Nov 13 15:01:43 2012 +0100 - - Don't take the address of a variable whose scope is about to disappear. - -commit bb3d7f3b31d4a429d1c31c6621d82f34dd552482 -Author: Guus Sliepen -Date: Sun Nov 11 19:01:28 2012 +0100 - - Fix configure script help text for --enable options. - -commit 5bfbb8f6c58307a8109f556caa30be122cc4d39f -Author: Guus Sliepen -Date: Sun Nov 11 19:01:02 2012 +0100 - - Fix index entry for section about readline library. - -commit 5766518589a5e6cc43ba77a4049059ead05fb300 -Author: Guus Sliepen -Date: Sun Nov 11 18:53:23 2012 +0100 - - Mention in the manual that support for LZO and zlib can be disabled. - -commit 6ec4596557d658f6c15c2cb9a96152c8c476118a -Author: Guus Sliepen -Date: Sun Nov 11 18:45:40 2012 +0100 - - Mention libcurses and libreadline in the manual. - -commit 0ee139e91431527015b7132e4c36f8d4ec09f66b -Author: Guus Sliepen -Date: Sat Nov 10 23:45:22 2012 +0100 - - Make sure PMTU discovery works in switch mode with VLAN tags. - - Before, when tinc saw a packet larger than the PMTU with a VLAN tag, it would - not know what to do with it, and would just forward it via TCP. Now, tinc - handles 802.1q packets correctly, as long as there is only one tag. - -commit ade4fccad6857f3d6d548e52bc94ab23751e4fef -Author: Guus Sliepen -Date: Sat Nov 10 23:13:05 2012 +0100 - - Using alloca() for a constant sized buffer is very silly. - - Cppcheck said using alloca() in the 21st century is silly anyway. - -commit b355476e917f377abb6434657933fcf4ffe6870a -Author: Guus Sliepen -Date: Sat Nov 10 23:09:31 2012 +0100 - - Fix potential buffer overflow reading the PID file. - - Found by cppcheck. - -commit edc08b73a9e353bde6db4c73866a6a730a1a7cb4 -Author: Guus Sliepen -Date: Sun Oct 21 17:45:16 2012 +0200 - - Slightly randomize all timeouts. - -commit 717ea66d7ba0c23f27d86b3d5c6992b751135455 -Author: Guus Sliepen -Date: Sun Oct 21 17:35:13 2012 +0200 - - Add the AutoConnect option. - - When set to a non-zero value, tinc will try to maintain exactly that number of - meta connections to other nodes. If there are not enough connections, it will - periodically try to set up an outgoing connection to a random node. If there - are too many connections, it will periodically try to remove an outgoing - connection. - -commit 1f8b70efa0dedbd3642e0ee82a640d125664af34 -Author: Guus Sliepen -Date: Sun Oct 21 17:34:53 2012 +0200 - - Keep track of the number of nodes in a tree. - -commit 0006c754f2e61e108aa2dd5a6ddd2e9b50d51bd6 -Author: Guus Sliepen -Date: Wed Oct 17 13:51:02 2012 +0200 - - Fix warnings from groff. - -commit 0db9e471ea53b48687ea247c855cd95ec453530c -Author: Guus Sliepen -Date: Sun Oct 14 19:22:30 2012 +0200 - - Releasing 1.1pre3. - -commit 3254e75afe0ff28fed68d8682f61c184f442161d -Author: Guus Sliepen -Date: Sun Oct 14 19:21:13 2012 +0200 - - Fix a few compiler errors/warnings. - -commit 70a1a5594af5d4e6a364186b42ba4e34c676009b -Author: Guus Sliepen -Date: Sun Oct 14 17:42:49 2012 +0200 - - Update copyright notices. - -commit 4200a378c4fedf64e89b9f8481d7cd09dac14965 -Author: Guus Sliepen -Date: Sun Oct 14 16:39:16 2012 +0200 - - Fix compile error on Windows. - -commit 368727c3dac4a1f8343e2e0eccf5bc62d9b197e2 -Author: Guus Sliepen -Date: Sun Oct 14 16:07:35 2012 +0200 - - tincctl: add node colors and edge weight to graph dump. - -commit 40ed0c07dd3d4667054b0f5952b89ee39686493b -Author: Guus Sliepen -Date: Sun Oct 14 15:37:24 2012 +0200 - - Log more messages using logger(). - -commit b234304b6628aeddce63d7f751da97c3344bbb78 -Author: Guus Sliepen -Date: Sun Oct 14 14:48:35 2012 +0200 - - Make sure the ReplayWindow option works for SPTPS as well. - -commit ee1d655f2f1ede6da66b6268974d6f9585c616b3 -Author: Guus Sliepen -Date: Sun Oct 14 14:45:27 2012 +0200 - - Only log success of initial datagram SPTPS handshake. - -commit 44a24f63acc70d19904e5540986b8301b3c9b882 -Author: Guus Sliepen -Date: Sun Oct 14 14:33:54 2012 +0200 - - Fix handling of initial datagram SPTPS packet. - - Only the very first packet of an SPTPS session should be send with REQ_KEY, - this signals the peer to abort any previous session and start a new one as - well. - -commit ec1f7e525d046bcaeb8e7040b8cec9a34a568371 -Author: Sven-Haegar Koch -Date: Fri Oct 12 17:08:01 2012 +0200 - - sptps.c: Add missing newline to log message. - -commit 94ec8d34db0ddef14b5446975663e5ff37e27b45 -Author: Guus Sliepen -Date: Thu Oct 11 22:47:13 2012 +0200 - - Strip newline from incoming SPTPS requests. - - Most of the code doesn't care whether requests are terminated with a newline or - not, except that when requests are forwarded, it is assumed they do not have - one and a newline is added. When a node using SPTPS receives a request from - another SPTPS-using node, and forwards it to a non-SPTPS-using node, this will - result in two consecutive newlines, which the latter node will see as an empty, - and thus invalid, request. - -commit 45944e4514a7765f858fa33cc1d9719a603099e0 -Author: Guus Sliepen -Date: Thu Oct 11 22:21:30 2012 +0200 - - Clear status and options fields of unreachable nodes. - -commit d917c8cb6b69475d568ccbe82389b9f2b3eb5e80 -Author: Guus Sliepen -Date: Wed Oct 10 17:17:49 2012 +0200 - - Fix whitespace. - -commit 58f4b845b9a7d83739af77337f2ce263d8df7838 -Author: Guus Sliepen -Date: Wed Oct 10 14:46:22 2012 +0200 - - Try all known addresses of node during the PMTU discovery phase. - - This helps in situations where some nodes have IPv6 and others have not. - -commit 0ed0cc6f9c30537bd74222fd99a41726d488dd37 -Author: Guus Sliepen -Date: Tue Oct 9 17:49:09 2012 +0200 - - Fix hash functions for keys whose size is not divisible by 4. - -commit d1ec010660905ae0b99d783737350ccc08b37b16 -Author: Guus Sliepen -Date: Tue Oct 9 16:27:28 2012 +0200 - - Fix memory leaks found by valgrind. - -commit 72642b40b3ad476101622da202b6f977a32b472f -Author: Guus Sliepen -Date: Tue Oct 9 15:52:58 2012 +0200 - - Clear Ethernet header when reading packets from a tun device. - - This fixes a warning from valgrind about uninitialized bytes, which were being - sent to other nodes. - -commit b346338f9c2de6f71d87cb4ad8e61b0af0052688 -Author: Guus Sliepen -Date: Tue Oct 9 13:28:09 2012 +0200 - - Remove unused variables, fix some #includes. - -commit f62b4a91344bd0de09e7fb4e4c8c1993ffc027c3 -Author: Guus Sliepen -Date: Tue Oct 9 13:23:12 2012 +0200 - - Fix deleting connections from the connection list. - -commit 0b8b23e0dd7219344543f135ca0aeba8a4a42d48 -Author: Guus Sliepen -Date: Mon Oct 8 00:35:38 2012 +0200 - - C99 extravaganza. - -commit ff306f0cdaedb50de1472e7c1fb55de922a6ca60 -Author: Guus Sliepen -Date: Sun Oct 7 21:59:53 2012 +0200 - - Replace the connection_tree with a connection_list. - - The tree functions were never used on the connection_tree, a list is more appropriate. - Also be more paranoid about connections disappearing while traversing the list. - -commit ce059e36fdb3d3049c278e8b2f36b03c93778996 -Author: Guus Sliepen -Date: Sun Oct 7 21:02:40 2012 +0200 - - Refactor outgoing connection handling. - - Struct outgoing_ts and connection_ts were depending too much on each other, - causing lots of problems, especially the reuse of a connection_t. Now, whenever - a connection is closed it is immediately removed from the list of connections - and destroyed. - -commit d93a37928b75b17ac5e1eae5c2d62fd0760a6608 -Author: Guus Sliepen -Date: Sun Oct 7 17:53:23 2012 +0200 - - Fix warnings from cppcheck. - -commit 5d0812d49275ec8bda2b5b0ac813239045463777 -Author: Guus Sliepen -Date: Sun Oct 7 14:06:47 2012 +0200 - - Remove a debug message. - -commit c2a9ed9e98e3dc4218c74fff774ddfe654adfd72 -Author: Guus Sliepen -Date: Sun Oct 7 14:03:50 2012 +0200 - - Handle packets encrypted via SPTPS that need to be forwarded via TCP. - -commit bb6b97ce3493d49b79f1bd57fdac420c312ef8d6 -Author: Guus Sliepen -Date: Sun Oct 7 13:31:19 2012 +0200 - - Make datagram SPTPS key exchange more robust. - - Similar to old style key exchange requests, keep track of whether a key - exchange is already in progress and how long it took. If no key is known yet - or if key exchange takes too long, (re)start a new key exchange. - -commit b99af2f813b897e1fd49c87a7cf44241cad3a017 -Author: Guus Sliepen -Date: Sun Oct 7 11:45:54 2012 +0200 - - Useful error messages when writing to a meta connection fails. - -commit e05371346548dee977d4ee45e12e3058e749afb6 -Author: Guus Sliepen -Date: Sat Oct 6 21:16:17 2012 +0200 - - When terminating, keep control connections open until the end. - - This ensures all device files and listening sockets have been closed before - tincctl gets notified of tincd's termination. - -commit 86116bb022f0b885638ff9ba21b359fc9f55286a -Author: Guus Sliepen -Date: Sat Oct 6 21:15:19 2012 +0200 - - Clear connection options and status fields in free_connection_partially(). - - Most fields should be zero when reusing a connection. In particular, when an - outgoing connection to a node which is reachable on more than one address is - made, the second connection to that node will have status.encryptout set but - outctx will be NULL, causing a NULL pointer dereference when - EVP_EncryptUpdate() is called in send_meta() when it shouldn't. - -commit ef9358c0d616c5ff3391c8ec3da5d357286a4457 -Author: Guus Sliepen -Date: Sat Oct 6 17:45:03 2012 +0200 - - Improve starting/stopping tincd using tincctl. - - When starting tincd, tincctl now strips non-options from the command line, and - sets argv[0] to the name of the tincd command instead of copying its own - command name. - - When stopping a running tincd, tincctl now waits for it to terminate. - -commit 47f33e07ff90b557cfa96999e921d35ea537ca80 -Author: Guus Sliepen -Date: Sat Oct 6 16:53:43 2012 +0200 - - Fix off-by-one error. - - Apart from writing 1 byte beyond an array allocated on the stack, this slipped - an unitialized byte in the seed used for key generation. - -commit 20b441a6de743b2149df59cfb94a7663e1924fa3 -Author: Guus Sliepen -Date: Mon Oct 1 10:42:13 2012 +0200 - - Libreadline might depend on libcurses. - -commit 3887e6dcb54494ee11798e721e274e06b0a5621a -Author: Guus Sliepen -Date: Mon Oct 1 10:39:15 2012 +0200 - - Remove abort() call that accidentily sneaked into commit dd1b69e. - -commit 0b0949e5bb63f9545feb4714812e2aa2112fb092 -Author: Guus Sliepen -Date: Mon Oct 1 10:36:23 2012 +0200 - - Make sure sptps_test compiles without -flto. - -commit b381acd60dbadbb4bc679d35a7d86bf425f21f86 -Author: Guus Sliepen -Date: Sun Sep 30 23:12:43 2012 +0200 - - Remove unused function declaration. - -commit dd1b69e31f83e2cc200ecc10e6d927373823332b -Author: Guus Sliepen -Date: Sun Sep 30 22:43:48 2012 +0200 - - Fix not reading Port statement from host config file. - -commit 6dfdb323612184529b4b83c1be914dda8262de47 -Merge: 9e76c464 c4940a5c -Author: Guus Sliepen -Date: Sun Sep 30 15:00:47 2012 +0200 - - Merge branch 'master' into 1.1 - - Conflicts: - lib/utils.c - src/net_setup.c - src/process.c - src/protocol_auth.c - src/protocol_key.c - src/utils.h - -commit c4940a5c888d85b4c477b6face5e9a618e64718d -Author: Guus Sliepen -Date: Sun Sep 30 13:45:47 2012 +0200 - - Add strict checks to hex to binary conversions. - - The main goal is to catch misuse of the obsolete PrivateKey and PublicKey - statements. - -commit 3bd810ea79d6933839ddac4a2cf1445c51947d38 -Author: Guus Sliepen -Date: Sun Sep 30 13:45:39 2012 +0200 - - Attribution for Martin Schürrer. - -commit 5a161e86cf35351f5274d7a8e17fef4630b40686 -Author: Martin Schürrer -Date: Sun Sep 30 02:04:55 2012 +0200 - - Output details of encryption errors - -commit 9e76c464b26b066e1eb3aa5232e573792e28020d -Author: Guus Sliepen -Date: Fri Sep 28 17:51:48 2012 +0200 - - Remove some debugging messages. - -commit e971130b601064090815c31c90b876e3d0d1d5b1 -Author: Guus Sliepen -Date: Fri Sep 28 17:36:25 2012 +0200 - - Make tincctl robust against dropped control connections. - -commit c5325ffdd1c6749beaf842c272eb28ecd5a070b6 -Author: Guus Sliepen -Date: Fri Sep 28 17:05:01 2012 +0200 - - Correctly add/remove outgoing connections when reloading configuration. - -commit f417271ea1447589ea05901f54fbb0377e7afaf9 -Author: Guus Sliepen -Date: Fri Sep 28 17:03:14 2012 +0200 - - Fix column sorting, make all lists sortable. - -commit aee86011ff2d389832fc9a23081ea23ab8484607 -Author: Guus Sliepen -Date: Thu Sep 27 22:12:15 2012 +0200 - - Let the GUI handle the new dump format. - -commit fac5593f44e47f3bd4f4b425ada38ab49fbe3b42 -Author: Guus Sliepen -Date: Thu Sep 27 17:19:02 2012 +0200 - - Fix links in documenation. - -commit 2e09986a1fd6dc5b6313f10e5d86aaaf4a531235 -Author: Guus Sliepen -Date: Thu Sep 27 17:18:49 2012 +0200 - - Fix links in documentation. - -commit f70cbc9d3ee3a88cf956592007e57f7a1dde2c17 -Author: Guus Sliepen -Date: Thu Sep 27 15:45:02 2012 +0200 - - Comment out old public/private keys when generating new ones. - -commit 38dbc63f118dbfdb955b56740b8c20a9379fb3ba -Author: Guus Sliepen -Date: Wed Sep 26 23:56:21 2012 +0200 - - Update documentation of the "dump graph" command. - -commit 1f312137d5ab12a2d996d5f7972f169aeb852040 -Author: Guus Sliepen -Date: Wed Sep 26 23:52:36 2012 +0200 - - Allow dumping either directed or undirected graphs. - - Internally, tinc maintains a directed graph of the meta connections between - nodes. However, this causes graphviz to draw two lines between nodes, which is - not always desirable. The "dump graph" command now defaults to dumping an - undirected graph, the "dump digraph" command will dump a directed graph. - -commit d6388d782ede1bbe49a5c2643362e2e0f383fa89 -Author: Guus Sliepen -Date: Wed Sep 26 23:18:32 2012 +0200 - - Let tincctl parse and format dumps. - - At the moment it just reproduces the old format. - -commit 9ade39b7d5564fb6f5a41946c9a23cfa7851a19f -Author: Guus Sliepen -Date: Wed Sep 26 22:20:43 2012 +0200 - - Keep last known address and time since reachability changed. - - This allows tincctl info to show since when a node is online or offline. - -commit 1e5deec973cd366b9d9cec6c1314a97e7051ce0f -Author: Guus Sliepen -Date: Tue Sep 25 22:28:08 2012 +0200 - - Remove remnants of Ethertap and old TUNSETIFF ioctl(). - -commit 125dd0dbcf4f46033ead3486044eb00b413fe537 -Author: Guus Sliepen -Date: Tue Sep 25 22:12:36 2012 +0200 - - Fix typo in manpage. - -commit 72f08932cf6f1ac0cfb837d377b423207e8c671a -Author: Guus Sliepen -Date: Mon Sep 24 14:56:00 2012 +0200 - - Don't ignore Makefile.am. - -commit 66e702d90d83977dc089736d7e4146330bc5df28 -Author: Guus Sliepen -Date: Mon Sep 24 14:02:07 2012 +0200 - - Attribution for Vil Brekin and some code style cleanups. - -commit f421a640777bd9484c59fa6feacadcf3e05d4b44 -Author: Vilbrekin -Date: Sat Aug 25 20:32:38 2012 +0200 - - Android cross-compilation instructions. - -commit afe4bf62eccab76c75e5a661fb2c16f1391a8417 -Author: Vilbrekin -Date: Sat Aug 25 20:01:11 2012 +0200 - - Use __ANDROID__ define rather than dirty hard-code to allow android NDK cross-compilation. - -commit c6720f1a608d19c722d8601fab1048773dbad59b -Author: Vilbrekin -Date: Sat Aug 25 19:59:26 2012 +0200 - - Add basic .gitignore file, cleaning (most) files generated by autotools. - -commit f2570c1b7f5813e087c867cf002f36f0c09b5cfa -Author: Vilbrekin -Date: Sat Aug 25 19:14:00 2012 +0200 - - Replace hard-code with new ScriptsInterpreter configuration property. - - This new setting allows choosing a custom script interpreter used for the various tinc callbacks. - If none is specified, the script itself is called as executable (as before). - This is particularly useful when storing tinc configuration and script on a mount point with no-exec attribute. - -commit 8a6f278fd2606c0a8f133f05df83b2649eacf6c3 -Author: Vilbrekin -Date: Wed Aug 22 10:46:24 2012 +0200 - - Basic patch for android cross-compilation. - - Commented non-existing functions in android NDK. - Prefix scripts execution with shell binary to allow execution on no-exec mount points. - Everyything is currently hard coded, while it should use pre-compiler variables... - -commit 2dc8deb1047a076d1c040f47bedf36ad4b41b17c -Author: Guus Sliepen -Date: Thu Sep 13 21:35:29 2012 +0200 - - Ensure sptps_test compiles with -flto. - -commit 90f1cba1fd9e748ec4b8274511d5a36ec1a24d9d -Author: Guus Sliepen -Date: Wed Sep 5 13:05:48 2012 +0200 - - Replace node_udp_tree with a hash table. - -commit 4c05afd19acada4781e1b8865cf702b197882e5d -Author: Guus Sliepen -Date: Wed Sep 5 12:45:36 2012 +0200 - - Use hash tables to lookup owners of addresses. - -commit 6b6a025488f289f749498a7e6cc1994be19f53e8 -Author: Guus Sliepen -Date: Wed Sep 5 12:44:41 2012 +0200 - - Add a simple hash table implementation. - -commit e9de08be0dab58a48f9a8ce3d250516cf05d6b8e -Author: Guus Sliepen -Date: Tue Sep 4 14:21:50 2012 +0200 - - Remove newlines at end of log messages. - -commit 05dac63dbc03dc5a64a7f4b50e24eb3766135916 -Author: Guus Sliepen -Date: Tue Sep 4 14:16:05 2012 +0200 - - Remove some debug messages. - -commit 742f7bb04e72d93f2c4a858534144a599b3fc14d -Author: Guus Sliepen -Date: Thu Aug 30 14:21:23 2012 +0200 - - Properly handle SPTPS packets with stripped Ethernet headers. - -commit d74b81b61e87c66d364a8590a48d87773ad2652c -Author: Guus Sliepen -Date: Thu Aug 30 14:00:34 2012 +0200 - - Fix node name check for "connect" and "disconnect" commands. - -commit 5567c0d4107e6ff6f4639d8664651841bd59ddad -Author: Guus Sliepen -Date: Sun Aug 5 17:25:31 2012 +0200 - - Quit when "exit" or "quit" commands are used in tincctl's shell. - -commit d18519ae21345fea68dd7f0f5525adba3a7639a9 -Author: Guus Sliepen -Date: Sun Aug 5 17:03:57 2012 +0200 - - Fix segfault when using tincctl's shell without readline. - -commit b332bd964663b7109a5fc4be596d36fbf1dbaa47 -Author: Guus Sliepen -Date: Sun Aug 5 13:50:51 2012 +0200 - - Add bash completion script. - -commit e29e0fee8812851473bcf24324a15cbf3cc854a0 -Author: Guus Sliepen -Date: Fri Aug 3 14:17:02 2012 +0200 - - Make sure the top command can be used more than once in tincctl's shell. - -commit a57db1dfe0736fd902a45ed5f695630faf3f0e1e -Author: Guus Sliepen -Date: Fri Aug 3 14:15:50 2012 +0200 - - Fork when using the "start" command in tincctl. - - This allows the command to be given in its shell without immediatly exiting tincctl. - -commit 36c6afede36b6956bd86df824f5616c1afee35ed -Author: Guus Sliepen -Date: Fri Aug 3 13:23:07 2012 +0200 - - Add readline completion for tincctl config and tincctl info. - -commit 8af2f3f5a4061a8dbfd4f7d259e0038df06a373e -Author: Guus Sliepen -Date: Thu Aug 2 17:44:59 2012 +0200 - - Optionally compress and/or strip Ethernet header from SPTPS packets. - -commit 73348be58ecb9c40cf435122a00e72ac4d1a4c9b -Author: Guus Sliepen -Date: Thu Aug 2 17:24:42 2012 +0200 - - Have tincctl act as a shell when no command is given. - - By default it uses readline to read commands. If the input and output are not a - tty, no prompt is shown. - -commit 91937812bdfe74699e4f7cdf86265d07423acbba -Author: Guus Sliepen -Date: Thu Aug 2 17:23:51 2012 +0200 - - Clear struct sptps before reusing it. - -commit 6bcd03c2027636f82ab7228566717d112df7bc6d -Author: Guus Sliepen -Date: Wed Aug 1 22:22:52 2012 +0200 - - Update the documentation to encourage using "tincctl init" and "tincctl config". - -commit 6396f42d74f22ab5f8e736dc5cb04c57917f9319 -Author: Guus Sliepen -Date: Wed Aug 1 16:51:59 2012 +0200 - - Stricter checks for netname and node names. - - - Node names should not be empty. - - Net names should not contain slashes or start with a dot, because they are - used in pathnames. - -commit 61006ced88e1bf62e8883216cabc636f2d4cb12a -Author: Guus Sliepen -Date: Wed Aug 1 16:13:23 2012 +0200 - - Add missing configuration variables. - -commit b0f3a76e9bf8ceeab75c1e6f4dce6763aecddc5e -Author: Guus Sliepen -Date: Wed Aug 1 15:50:45 2012 +0200 - - Add the ability to query configuration variables to tincctl. - -commit a9caa2a6ea3aa553c9d2140ad4f5b34b7ab7297b -Author: Guus Sliepen -Date: Wed Aug 1 15:15:37 2012 +0200 - - tincctl restart should work even if no tincd is running. - -commit 07980b056c5371f8b6fdd50172f501be07155bdf -Author: Guus Sliepen -Date: Wed Aug 1 15:14:48 2012 +0200 - - Try sending SIGTERM if we cannot connect to a tincd but we know its PID. - -commit 7a71d48009e03ff1143a6e1084803f456a27c849 -Author: Guus Sliepen -Date: Tue Jul 31 21:43:49 2012 +0200 - - Use a status bit to track which nodes use SPTPS. - -commit 6bc8df3e010509f69af95d2cc14ec893def6f644 -Author: Guus Sliepen -Date: Tue Jul 31 20:39:15 2012 +0200 - - Add Brandon Black's replay window code to SPTPS. - -commit 5ede437307cc3bbb20431f4b82f4a2ef79c9b746 -Author: Guus Sliepen -Date: Tue Jul 31 20:36:35 2012 +0200 - - Handle SPTPS datagrams in try_mac(). - -commit aaff0ed08916f936b0a7b8a3d0607b8111b7a185 -Author: Guus Sliepen -Date: Tue Jul 31 20:29:13 2012 +0200 - - Remove unused #include. - -commit 153abaa4d940bf2bc9bd7275d5efe5c01c354190 -Author: Guus Sliepen -Date: Mon Jul 30 18:36:59 2012 +0200 - - Use datagram SPTPS for packet exchange between nodes. - - When two nodes which support SPTPS want to send packets to each other, they now - always use SPTPS. The node initiating the SPTPS session send the first SPTPS - packet via an extended REQ_KEY messages. All other handshake messages are sent - using ANS_KEY messages. This ensures that intermediate nodes using an older - version of tinc can still help with NAT traversal. After the authentication - phase is over, SPTPS packets are sent via UDP, or are encapsulated in extended - REQ_KEY messages instead of PACKET messages. - -commit 248d300f1be0d5f2aae39202041699ab2b46c56b -Merge: e1355e24 3391018e -Author: Guus Sliepen -Date: Fri Jul 27 22:48:24 2012 +0200 - - Merge branch 'master' into 1.1 - -commit 3391018efbd41858d42ccae6ae919749ba94c8db -Author: Guus Sliepen -Date: Fri Jul 27 22:43:01 2012 +0200 - - Also clarify hostnames=[yes|no] in tinc.conf(5). - -commit e895b358db8863d19dfa3d77c861ae19b76bc750 -Author: Mesar Hameed -Date: Tue Jul 24 07:18:50 2012 +0100 - - Minor clarification, tinc.conf hostnames=[yes|no] variable only resolves names for logging purposes. - -commit e1355e24eb7fe36bdb5dd7c818815fa266046a51 -Author: Guus Sliepen -Date: Sun Jul 22 13:05:56 2012 +0200 - - Remove unused po/ directory. - -commit 6c9b33c8b67374d38525b88f292840034c559a45 -Author: Guus Sliepen -Date: Sun Jul 22 12:55:04 2012 +0200 - - Have tinc-gui use same way of locating pidfile as tincd and tincctl. - -commit 2b97a7d7cf6ca7f4d84d3df754062a55bdf55305 -Author: Guus Sliepen -Date: Sun Jul 22 12:52:31 2012 +0200 - - tincctl init now also creates a template tinc-up script. - -commit eb430005c74b6b5f717e7e264afa3bd35284740d -Author: Guus Sliepen -Date: Sat Jul 21 17:10:10 2012 +0200 - - Fix exit code when installing tincd as a service on Windows. - -commit e5e96882c3825cee81ff163490b2f39fad3192b8 -Author: Guus Sliepen -Date: Sat Jul 21 16:33:09 2012 +0200 - - Windows doesn't like quotes around "edit" when calling it through system(). - - Even though that works fine on the command line. - -commit 18237e1f2d9dd5eef4a4e0d746d016bf94a42ad4 -Author: Guus Sliepen -Date: Sat Jul 21 16:26:55 2012 +0200 - - Use backslashes on Windows. - - Although Windows itself supports the forward slash, some programs may not. - -commit 09a8ff649cc7aa51d291c89e1556526a6265cc81 -Author: Guus Sliepen -Date: Sat Jul 21 15:58:16 2012 +0200 - - Don't try to mkdir(CONFDIR) on Windows when there is a registry key for tinc. - -commit ed8ce60845dc0568840c64c692838136f342fa54 -Author: Guus Sliepen -Date: Sat Jul 21 15:51:15 2012 +0200 - - Fix crash when no netname is specified. - -commit 7303b512b0e4f0d9cbc3236e846b2618f527b830 -Author: Guus Sliepen -Date: Sat Jul 21 15:50:50 2012 +0200 - - Fix some compiler warnings. - -commit 33521eabd4501b4add35468618453ac4f76311f3 -Author: Guus Sliepen -Date: Sat Jul 21 15:15:04 2012 +0200 - - Have tincd and tincctl use the same method of determining netname. - -commit 1d322d2eda8223f21b0c00381af34b94054f251a -Author: Guus Sliepen -Date: Sat Jul 21 15:02:44 2012 +0200 - - Add a newline to a configuration file if it is missing. - -commit dea722c4aca9a8cfa463807d279aa10cc6a0fc64 -Author: Guus Sliepen -Date: Sat Jul 21 15:02:17 2012 +0200 - - Add some checks when changing configuration. - -commit cc0c35267f8fac4f82622ff73474ed1e2d3a1e36 -Author: Guus Sliepen -Date: Sat Jul 21 14:19:23 2012 +0200 - - Call event_init() after detaching. - - Otherwise, the call to daemon() could close filedescriptors in use by libevent - itself; for example if it uses kqueue or epoll instead of a select() or poll() - backend. - -commit 4e0fc52197546bbf8a0be7af946f4b569e13048c -Author: Guus Sliepen -Date: Sat Jul 21 13:53:22 2012 +0200 - - Fix various compiler warnings. - -commit b161088b35fad1d284855f6434a895a20e34a250 -Author: Guus Sliepen -Date: Sat Jul 21 13:38:14 2012 +0200 - - BSD make doesn't like $<. - -commit 98a72d686983178f71cd2bf336c1f3d5c647f1e7 -Author: Guus Sliepen -Date: Sat Jul 21 13:02:35 2012 +0200 - - Make sure sptps.h and info.h are in the tarball. - -commit 5eeed38b8eb15f4c0464675b7d8c7722bc8be168 -Author: Guus Sliepen -Date: Sat Jul 21 12:51:53 2012 +0200 - - Make sure tinc compiles on Windows. - -commit 1d4590ca5cae09ea3b7a7e80355639e20861d349 -Author: Guus Sliepen -Date: Fri Jul 20 20:35:07 2012 +0200 - - Prefer routes with lower weight as long as they do not increase the number of hops. - - This should improve traffic to nodes that are not directly reachable somewhat. - -commit 4c8ead98743254be97c830e942f0cc53539d780c -Author: Guus Sliepen -Date: Fri Jul 20 20:01:29 2012 +0200 - - Allow more configuration variables to be changed when reloading configuration. - - In particular, Subnets may be added or removed from the local node on the fly. - -commit c678e7c4fb52d93350eafaed0f666018ed469e10 -Author: Guus Sliepen -Date: Fri Jul 20 19:59:47 2012 +0200 - - Split setup_myself() into two functions, one for reloading configuration. - -commit 4591e96c76914795aaae317c067f16abc22fb2e0 -Author: Guus Sliepen -Date: Fri Jul 20 17:29:16 2012 +0200 - - Never remove items from cmdline_conf. - - We should treat cmdline_conf as const, so we can call read_config_options() - more than once with prefix = NULL. - -commit 68a20876d0c4a6c370064d78786dd9f2aa6273cb -Author: Guus Sliepen -Date: Fri Jul 20 01:02:51 2012 +0200 - - Use minor protocol version to determine whether to use ECDH key exchange between nodes. - -commit 76a3ada4eb4032172c3d780915a07680f9954d42 -Author: Guus Sliepen -Date: Tue Jul 17 18:05:55 2012 +0200 - - Put minor protocol version in connection options so other nodes can see it. - - This allows two nodes that do not have a meta-connection with each other see - which version they are. - -commit 68de7b481e54d6a7c573d9a2d61f76d4d3a6b2f9 -Author: Guus Sliepen -Date: Mon Jul 16 18:49:39 2012 +0200 - - When exporting configuration files, don't copy Name variables. - - These interfere with tincctl import. Besides, host configuration files should - not contain Name at all. - -commit c52c46f8717aac6904f32766d774fa3fdf9611d8 -Author: Guus Sliepen -Date: Mon Jul 16 16:48:24 2012 +0200 - - Add an easy way to export and import host configuration files. - -commit 6319dc9dde3b328ba800f25a6bb4cf303d27f664 -Author: Guus Sliepen -Date: Mon Jul 16 01:14:08 2012 +0200 - - Strip default subnet weight from output. - -commit 74646a4afa6557a0363cc85e0a95d578d4ab0ac2 -Author: Guus Sliepen -Date: Mon Jul 16 01:09:47 2012 +0200 - - Give an error message when tincctl info cannot parse the given subnet or address. - -commit 53735a9d964579829d089f4b7572aef50c4e1468 -Author: Guus Sliepen -Date: Mon Jul 16 01:05:25 2012 +0200 - - "tincctl info" gives more human readable information about nodes or subnets. - -commit 3c7003893fe2f82023d0d4f54b488bb7a16d0007 -Author: Guus Sliepen -Date: Mon Jul 16 00:52:50 2012 +0200 - - Move all functions related to subnet parsing to subnet_parse.c. - -commit e72e6febfeddbd4354560388c8e0e125a8017909 -Author: Guus Sliepen -Date: Sun Jul 15 22:53:03 2012 +0200 - - Fix tincctl dump. - -commit 9be8980a2bb6245da017270f85bd6da186fb433b -Author: Guus Sliepen -Date: Sun Jul 15 21:17:10 2012 +0200 - - Let tincctl ignore tincd options, so they will be passed on. - -commit 36dee4c539521578005eed5e58b4803b73f0c889 -Author: Guus Sliepen -Date: Sun Jul 15 21:15:35 2012 +0200 - - Fix tincctl start. - -commit 439069bda62b25baaabeb765ac0557efa57b6cfb -Author: Guus Sliepen -Date: Sun Jul 15 20:59:17 2012 +0200 - - Have tincctl notify a running tincd of configuration file changes. - -commit eb01fd96258e5f99be0e4930eac04e5487a108a0 -Author: Guus Sliepen -Date: Sun Jul 15 20:37:38 2012 +0200 - - Add an easy way to edit a configuration file. - -commit cedfeccb247abb00063316068d7d2ade880f9d09 -Author: Guus Sliepen -Date: Sun Jul 15 20:22:21 2012 +0200 - - Stricter checks for node names. - -commit 03f72c6173f27198e2e68227cb41e00f8ec4ddc9 -Author: Guus Sliepen -Date: Sun Jul 15 18:16:35 2012 +0200 - - Allow configuration variables to be added/removed using tincctl. - -commit dd102efd24d847c41890adfcc7ce6d9d2592dcdb -Author: Guus Sliepen -Date: Sun Jul 15 15:46:16 2012 +0200 - - Put every command in its own function. - -commit a444ec396456a25546a4ab3d185c7fb5e4bb7ae3 -Author: Guus Sliepen -Date: Sun Jul 15 14:49:36 2012 +0200 - - "tincctl init" creates initial directory structure, tinc.conf and keypairs. - -commit 268c8545aaf83b7433f43402f5c77e39e20006ef -Merge: bce17776 f13fd8c3 -Author: Guus Sliepen -Date: Sat Jul 14 15:13:21 2012 +0200 - - Merge branch 'master' into 1.1 - -commit f13fd8c35068cd1f776e33362dcac40be9499035 -Author: Guus Sliepen -Date: Thu Jul 12 11:32:08 2012 +0200 - - Update THANKS file. - -commit 2eb0043e1352944b1113c1f7e40f37dffac0021d -Author: Guus Sliepen -Date: Thu Jul 12 11:30:56 2012 +0200 - - Document how to load the tap driver on FreeBSD. - -commit ae8c0b65d8f97942d7eff5f96344f781b8dec35d -Author: Guus Sliepen -Date: Thu Jul 12 11:25:11 2012 +0200 - - Use /dev/tap0 by default on FreeBSD and NetBSD when using Mode = switch. - -commit bce177767d521b47efd458c5cd570959a98d940d -Author: Guus Sliepen -Date: Tue Jun 26 14:22:57 2012 +0200 - - Fix crash when handling the ALRM signal. - - In retry() the function do_outgoing_connection() is called, which can delete - items from the connection_tree, so when walking the tree we must first save the - pointer to the next item. - -commit 19be9cf7150858311f7898fa3fb525d692d02f64 -Merge: 62b61a1b 00e71ece -Author: Guus Sliepen -Date: Tue Jun 26 13:24:20 2012 +0200 - - Merge branch 'master' of git://tinc-vpn.org/tinc into 1.1 - - Conflicts: - NEWS - README - configure.in - lib/utils.c - src/linux/device.c - src/meta.c - src/net.h - src/net_setup.c - src/net_socket.c - src/protocol.c - src/protocol_auth.c - src/tincd.c - -commit 00e71ece25070dc919f9bc0696e4ff3a387360d0 -Author: Guus Sliepen -Date: Mon Jun 25 19:45:51 2012 +0200 - - Releasing 1.0.19. - -commit 236b0ba4ebba01e22e382e79897100338a039bbb -Author: Guus Sliepen -Date: Mon Jun 25 19:03:54 2012 +0200 - - Fix crash when using Broadcast = direct. - -commit 0a84f9cb8f52f2d2b4f03a5ad5ef9dfcd3509033 -Author: Guus Sliepen -Date: Mon Jun 25 19:01:51 2012 +0200 - - Fix compiler warnings. - -commit 62ee9b776d45af41c8b040ad86e50ba8f6f8e6c4 -Author: Guus Sliepen -Date: Mon Jun 25 15:01:42 2012 +0200 - - #include on Windows. - - MinGW complained about it not being included. - -commit c0af4c37d2046ffb3e07dd62f266a4fb99ea5614 -Author: Guus Sliepen -Date: Mon Jun 25 15:00:24 2012 +0200 - - Small fixes in proxy code. - -commit 62b61a1b7c2382b1bade142b3a41a9b27c1fd40d -Author: Guus Sliepen -Date: Sun May 13 22:16:42 2012 +0200 - - Don't forget to send a newline when forwarding requests. - -commit 42a8158b1dca6ee4ec1707176199cc36c26da7af -Author: Michael Tokarev -Date: Fri May 4 16:41:47 2012 +0400 - - add (errnum) in front of windows error messages - - On localized, non-English versions of windows, it is - common to have two active charsets -- for console applications - and for GUI applications, together with localized error messages - returned by windows. But two charsets are rarely compatible, - so sending the same byte sequence to console and to windows - event log makes one or another to be unreadable. So at least - include the error number, this way it will be possible to - lookup the actual error test using external ways. - - Signed-off-by: Michael Tokarev - -commit 58007d7efa3940c863c5a398f8b257a686ce37ba -Author: Guus Sliepen -Date: Tue May 8 16:44:15 2012 +0200 - - Always pass request strings to other functions as const char *. - -commit 291a59b5b732de084e392daea1433b1fdb9fbfd5 -Author: Sven-Haegar Koch -Date: Sun Apr 22 03:44:28 2012 +0200 - - free_connection_partially(): also reset remote protocol version infos - - The used remote protocol can change between two reconnects, aka if - the remote side has enabled/disabled for example their ExperimentalProtocols - setting. - -commit 32e5c5bb7c2c9127274247cb74cffa7345b04fad -Author: Sven-Haegar Koch -Date: Sun Apr 22 03:05:29 2012 +0200 - - Silence SPTPS log messages, reduce them from DEBUG_ALWAYS to DEBUG_META. - -commit c78bb143030162f0c820f08c87808e157c014a07 -Author: Sven-Haegar Koch -Date: Sun Apr 22 02:55:06 2012 +0200 - - terminate_connection(): delete non-outgoing (aka incoming) connections. - -commit 8b9e5af0d93069a81ce2ebed9899eedf3b7b184b -Author: Sven-Haegar Koch -Date: Sat Apr 21 03:44:24 2012 +0200 - - Label control connections for log output as "", not "". - -commit d3f4cf59ca917386e7c6358a98adbe3b8e9ce87a -Author: Sven-Haegar Koch -Date: Sat Apr 21 01:59:01 2012 +0200 - - free_connection_partially(): Avoid possible use-after-free for c->hischallenge - -commit 7a6ca7a993e5907497d97fef09e375698dde182f -Author: Sven-Haegar Koch -Date: Sat Apr 21 01:51:36 2012 +0200 - - terminate_connection(): only kill c->node->connection if it is pointing - to the same connection - -commit a96c4f016c9fff2392d85f762e16f5430c0b6463 -Author: Sven-Haegar Koch -Date: Fri Apr 20 00:24:38 2012 +0200 - - terminate_connection(): Avoid use-after-free and double-free for - already freed edge structure. - -commit 5c0dd104f94519c3cb50e9ca44227656c5adc7ae -Author: Guus Sliepen -Date: Thu Apr 19 15:56:08 2012 +0200 - - Document new proxy types. - -commit 5ae19cb0bb8dd6be1e9bcd560bb051f496a373ec -Author: Guus Sliepen -Date: Thu Apr 19 15:18:31 2012 +0200 - - Add support for proxying through an external command. - - Proxy type "exec" can be used to have an external script or binary set - up an outgoing connection. Standard input and output will be used to - exchange data with the external command. The variables REMOTEADDRESS and - REMOTEPORT are set to the intended destination address and port. - -commit fb5588856fa4dd6f140c72f7360302fe85b20c75 -Author: Guus Sliepen -Date: Thu Apr 19 14:10:54 2012 +0200 - - Add support for SOCKS 5 proxies. - - This only covers outgoing TCP connections, and supports only - username/password authentication or no authentication. - -commit b58d95eb29662bce4388f95dbc5762b9e2999806 -Author: Guus Sliepen -Date: Wed Apr 18 23:19:40 2012 +0200 - - Add basic support for SOCKS 4 and HTTP CONNECT proxies. - - When the Proxy option is used, outgoing connections will be made via the - specified proxy. There is no support for authentication methods or for having - the proxy forward incoming connections, and there is no attempt to proxy UDP. - -commit 84531fb6e621959e06519fdbb7f2a8f7578f66bd -Author: Guus Sliepen -Date: Mon Apr 16 01:57:25 2012 +0200 - - Allow broadcast packets to be sent directly instead of via the MST. - - When the "Broadcast = direct" option is used, broadcast packets are not sent - and forwarded via the Minimum Spanning Tree to all nodes, but are sent directly - to all nodes that can be reached in one hop. - - One use for this is to allow running ad-hoc routing protocols, such as OLSR, on - top of tinc. - -commit 9ebb34f907e8a15cb71dd20b111270d80bad1e96 -Author: Guus Sliepen -Date: Mon Apr 16 01:16:59 2012 +0200 - - Update README to reflect that only OpenSSL is currently supported. - -commit a851d8a9f6e3b69ab75695d84471ff4d525341b7 -Author: Guus Sliepen -Date: Mon Apr 16 01:14:59 2012 +0200 - - Add autoconf checks for OpenSSL's elliptic curve functions. - -commit f8e15dfe8d155b5bdb1e39bf6b9af486606145e8 -Author: Sven-Haegar Koch -Date: Sat Apr 14 02:28:43 2012 +0200 - - ecdh & ecdsa: avoid some possible memory leaks in error conditions. - -commit 8792b9a9f343e751dc3cfd789db9528da609ba9f -Author: Sven-Haegar Koch -Date: Sat Apr 14 02:02:11 2012 +0200 - - Remove confusing error message for failed reading in ECDSA keys. - - Most likeley the error is that there just is no valid key inside the used - host file, and in this case errno just contains a random value from the - last previously failed call. - -commit a5bb6d40fb517aa175510ec179091e4f9ffaf6f6 -Author: Sven-Haegar Koch -Date: Sat Apr 14 02:29:32 2012 +0200 - - sptps_stop(): clear pointers after free to avoid double free. - - sptps_stop() may get called twice on some failed connection setups. - -commit 535a55100bb77f107c85361e9f72a194e92bc8bc -Author: Guus Sliepen -Date: Thu Mar 29 16:45:25 2012 +0100 - - Allow environment variables to be used for Name. - - When the Name starts with a $, the rest will be interpreted as the name of an - environment variable containing the real Name. When Name is $HOST, but this - environment variable does not exist, gethostname() will be used to set the - Name. In both cases, illegal characters will be converted to underscores. - -commit 1d9dacb1f26971e19463b5501c2410c57f780ecb -Merge: 86c29903 89f4574e -Author: Guus Sliepen -Date: Mon Mar 26 19:06:39 2012 +0100 - - Merge branch 'master' of git://tinc-vpn.org/tinc into 1.1 - - Conflicts: - src/logger.c - src/net_setup.c - -commit 89f4574e0b1553c8e5dcbfc275e829a759b697f6 -Author: Guus Sliepen -Date: Mon Mar 26 14:46:09 2012 +0100 - - Add support for systemd style socket activation. - - If the LISTEN_FDS environment variable is set and tinc is run in the - foreground, tinc will use filedescriptors 3 to 3 + LISTEN_FDS for its listening - TCP sockets. For now, tinc will create matching listening UDP sockets itself. - - There is no dependency on systemd or on libsystemd-daemon. - -commit cc6aee784659bfbd21eb8d414e00a8f1a801cac4 -Author: Guus Sliepen -Date: Mon Mar 26 14:45:20 2012 +0100 - - Remove newline from log message. - -commit 16e6769feef21a5bf58f6022d990452987bb5efb -Author: Anthony G. Basile -Date: Mon Mar 26 06:29:40 2012 -0400 - - configure.in: fix AC_ARG_ENABLE and AC_ARG_WITH - - The current configure.in file does not correctly make use of these - macros. The resulting configure file will therefore enable an item - even if --disable-FEATURE is given. This patch restores the intended - behavior. - -commit 86c2990327fdf7ec1197aa73cb2b9a926a734db4 -Merge: d7bf63c6 b23681dd -Author: Guus Sliepen -Date: Sun Mar 25 23:35:31 2012 +0100 - - Merge branch 'master' of git://tinc-vpn.org/tinc into 1.1 - - Conflicts: - NEWS - README - configure.in - src/Makefile.am - src/conf.c - src/conf.h - src/connection.c - src/net.c - src/tincd.c - -commit b23681dddb8987571f04d46fc14f0ba012a7929c -Author: Guus Sliepen -Date: Sun Mar 25 22:54:36 2012 +0100 - - Support :: in IPv6 Subnets. - -commit 482c6119a7ae80f320e5b519ef2e785e04a77b8e -Author: Guus Sliepen -Date: Sun Mar 25 15:32:26 2012 +0100 - - Releasing 1.0.18. - -commit 64c657b32d1eb34eb669c6d5b0ec26c1a643b194 -Author: Guus Sliepen -Date: Sun Mar 25 15:30:58 2012 +0100 - - Mark DecrementTTL option experimental. - -commit f71ce341800739c7cdee01d7cf025e7492da22ac -Author: Guus Sliepen -Date: Sun Mar 25 15:17:50 2012 +0100 - - Fix return type of vde_recv() as well. - - In this case it is not really necessary as the conversion to int will already - take care of ensuring the return value is treated as signed. - -commit 6225b1884a25af4debc2d0821a4c377ddbaec696 -Author: Guus Sliepen -Date: Sun Mar 25 14:55:56 2012 +0100 - - Document OpenBSD "ifconfig link0" and Linux "ip tuntap" commands. - -commit 399835385380d485416d6d59a8f27ce71f1db644 -Author: Guus Sliepen -Date: Sun Mar 25 14:46:50 2012 +0100 - - Fix some more compiler warnings. - -commit cfe6558d4ba4f572311aeafd62737f6f2692ad86 -Author: Guus Sliepen -Date: Sun Mar 25 14:00:21 2012 +0100 - - Fix return value type of vde_send(). - - The libvdeplug_dyn.h header file incorrectly declares the return type of - vde_send() to size_t, while in reality it is ssize_t. - -commit 95968c67f9df9102ddbce5b7c8d34107989ad51a -Author: Guus Sliepen -Date: Sun Mar 25 13:58:14 2012 +0100 - - Fix compiler warnings. - -commit e2d1b0b899ef66cd7ff227549e58b96c292f784e -Author: Guus Sliepen -Date: Sun Mar 25 13:42:10 2012 +0100 - - Allow scoped addresses to be used for IPv6 multicast socket. - -commit 251204063255d95910f9a079015e2f9b428fd983 -Author: Guus Sliepen -Date: Sun Mar 25 13:40:55 2012 +0100 - - Add #ifdefs in case not all platforms support IPv4 and IPv6 multicast. - -commit b5e3bf1a85462f0c41638c11305d28f87af24395 -Author: Guus Sliepen -Date: Fri Mar 23 13:18:36 2012 +0100 - - Set default value of DecrementTTL to "no". - - Decrementing the TTL causes IPv6 to fail when Mode = switch, and there may be - other unforeseen side-effects. - -commit c373de2e9812700c0568640727ad917b6fc7d758 -Author: Guus Sliepen -Date: Wed Mar 21 17:00:53 2012 +0100 - - Add support for multicast communication with UML/QEMU/KVM. - - DeviceType = multicast allows one to specify a multicast address and port with - a Device statement. Tinc will then read/send packets to that multicast group - instead of to a tun/tap device. This allows interaction with UML, QEMU and KVM - instances that are listening on the same group. - -commit a7dbb50c23f447a23b543c92ec096ff178bc2de3 -Author: Guus Sliepen -Date: Wed Mar 21 13:20:15 2012 +0100 - - Allow a port to be specified in BindToAddress statements. - - This can be used to let tinc listen on multiple ports for incoming connections. - -commit 80e15d8b96e5313b33c91003b1f75d7f6db9924e -Author: Guus Sliepen -Date: Tue Mar 20 23:49:16 2012 +0100 - - Always try next Address when an outgoing connection fails to authenticate. - - When making outgoing connections, tinc goes through the list of Addresses and - tries all of them until one succeeds. However, before it would consider - establishing a TCP connection a success, even when the authentication failed. - This would be a problem if the first Address would point to a hostname and port - combination that belongs to the wrong tinc node, or perhaps even to a non-tinc - service, causing tinc to endlessly try this Address instead of moving to the - next one. - - Problem found by Delf Eldkraft. - -commit d7bf63c63ab397cf3e5ca4a065922364925788e7 -Author: Guus Sliepen -Date: Sun Mar 18 21:24:46 2012 +0100 - - Make sure the signature also covers the session label. - -commit 42a0b61076d5d0f6391f0dd5c2c400b8fb89c5c5 -Author: Guus Sliepen -Date: Sun Mar 18 20:38:48 2012 +0100 - - Start documenting the SPTPS protocol. - -commit d756bb92ed52d5b1ecdd42af32f11f733db64d91 -Author: Guus Sliepen -Date: Sun Mar 18 17:46:30 2012 +0100 - - Don't send an ACK message after the first key exchange in the SPTPS protocol. - -commit c970ecdd75d4e7b3203a788f28b6e40cd532759b -Author: Guus Sliepen -Date: Sun Mar 18 17:42:43 2012 +0100 - - Test SPTPS messages sent while key renegotation is in progress. - -commit 3a4fe104a06b73fd19c550546e7c65a59ff2afe3 -Author: Guus Sliepen -Date: Sun Mar 18 16:42:02 2012 +0100 - - Add datagram mode to the SPTPS protocol. - - * Everything is identical except the headers of the records. - * Instead of sending explicit message length and having an implicit sequence - number, datagram mode has an implicit message length and an explicit sequence - number. - * The sequence number is used to set the most significant bytes of the counter. - -commit 03e06fd43aff73b4a5c9d367968a1279371ae252 -Author: Guus Sliepen -Date: Sun Mar 18 16:41:13 2012 +0100 - - Allow CTR mode counter to be set to a specific value. - -commit 28a1501b9a8b4c730f7f965d6b2e8fc50feba261 -Author: Guus Sliepen -Date: Sat Mar 10 13:31:36 2012 +0100 - - Releasing 1.0.17. - -commit 4712d8f92e63e86e835ffb624d6399343ee568ea -Author: Guus Sliepen -Date: Sat Mar 10 13:23:08 2012 +0100 - - Update copyright notices. - -commit 5b0f5ad958d6db4e73aebc5ee6c608cdae81b7b5 -Author: Guus Sliepen -Date: Thu Mar 8 23:23:39 2012 +0100 - - Make sure disabling old RSA keys works on Windows. - - Seeking in files and rewriting parts of them does not seem to work properly on - Windows. Instead, when old RSA keys are found when generating new ones, the - file containing the old keys is copied to a temporary file where the changes - are made, and that file is renamed back to the original filename. On Windows, - we cannot atomically replace files with a rename(), so we need to move the - original file out of the way first. If anything fails, the new code will warn - that the user has to solve the problem by hand. - -commit 2f1c337c541fcb7e2c62aeeab245ff7a43eb51a5 -Author: Guus Sliepen -Date: Thu Mar 8 22:19:20 2012 +0100 - - Add missing ICMP6 message type definitions. - -commit 40c28589328a2aa96c2ce1419c5d90616c758b3d -Merge: 8ac096b5 9dea33f5 -Author: Guus Sliepen -Date: Thu Mar 8 21:15:08 2012 +0100 - - Merge branch 'master' of git://tinc-vpn.org/tinc into 1.1 - - Conflicts: - src/net_packet.c - -commit 9dea33f5301119dd4423eb962956cf2d246af3f3 -Author: Guus Sliepen -Date: Wed Mar 7 10:40:06 2012 +0100 - - Accept Subnets passed with the -o option when StrictSubnets = yes. - -commit 63f8303a5dc1758876451a580a8317dbc3d295d6 -Author: Guus Sliepen -Date: Fri Mar 2 16:09:58 2012 +0100 - - Only log errors sending UDP packets when debug level >= 5. - - Since tinc will fall back to TCP or route via another node, it is not necessary - to log such errors unconditionally. - -commit 8ac096b5bf9da1b3961a3ac4a03d083629222a63 -Author: Guus Sliepen -Date: Sun Feb 26 18:37:36 2012 +0100 - - Allow log messages to be captured by tincctl. - - This allows tincctl to receive log messages from a running tincd, - independent of what is logged to syslog or to file. Tincctl can receive - debug messages with an arbitrary level. - -commit a1bd3a291379492c8ffecd53792065dc20a28c79 -Author: Guus Sliepen -Date: Sun Feb 26 16:56:53 2012 +0100 - - Don't close control connections when handling a reload command. - - Because this would terminate the connection while the control message - handler was still running, it would lead to a segmentation fault later - on. - -commit 483c5dcfb43719e5fd50902641252e28a04fd74e -Merge: 344d6b9a ae524961 -Author: Guus Sliepen -Date: Sun Feb 26 16:27:13 2012 +0100 - - Merge branch 'master' of git://tinc-vpn.org/tinc into 1.1 - -commit ae5249610954af17c68c547bb1b45ad286ad647e -Author: Guus Sliepen -Date: Sun Feb 26 16:23:02 2012 +0100 - - Only use broadcast at the start of the PMTU discovery phase. - - For local peer discovery, only a handful of packets are necessary for - peers to detect each other. - -commit 344d6b9ac3c795f2942e457c1ab38b1dac5f7242 -Author: Guus Sliepen -Date: Sun Feb 26 12:39:46 2012 +0100 - - Let tincctl use the NETNAME environment variable if no -n option is given. - - This allows administrators who frequently want to work with one tinc - network to omit the -n option. Since the NETNAME variable is set by - tincd when executing scripts, this makes it slightly easier to use - tincctl from within scripts. - -commit 84570275acd84628586a6ca591a283d074ca10f0 -Author: Guus Sliepen -Date: Sun Feb 26 12:33:16 2012 +0100 - - Ensure all SPTPS functions are prefixed with sptps_. - -commit 8b1ad6f76f821648079818f6ff018bbc33b9d9e9 -Author: Guus Sliepen -Date: Sat Feb 25 23:03:09 2012 +0100 - - Go back to breadth first search for path finding. - - If 1.1.x nodes using Dijkstra's algorithm are mixed with 1.0.x nodes using BFS, - then routing loops can occur. - -commit 36623e15a1c8685e5d8730345c1a7f9c93710fef -Merge: 65d6f023 5140656d -Author: Guus Sliepen -Date: Sat Feb 25 22:52:57 2012 +0100 - - Merge branch 'master' of git://tinc-vpn.org/tinc into 1.1 - -commit 5140656de6bcfda72951a7827b05414ce306e3ca -Author: Guus Sliepen -Date: Sat Feb 25 22:11:30 2012 +0100 - - Stricter checks against routing loops. - - If a packet that had to be sent via an intermediate hop, and that intermediate - hop was the one that sent the packet, we drop it. - -commit f1d5eae643cdf537ef357f10f2da8ff83bdf32b4 -Author: Guus Sliepen -Date: Sat Feb 25 21:46:18 2012 +0100 - - Don't send ICMP Time Exceeded messages for other Time Exceeded messages. - - That would be silly. - -commit 65d6f023c46ac3a087f59b60762f87c869783f21 -Author: Guus Sliepen -Date: Sat Feb 25 18:25:21 2012 +0100 - - Use SPTPS when ExperimentalProtocol is enabled. - -commit efd21e232dced3225f119aeb7a585ebf55b7cf77 -Author: Guus Sliepen -Date: Sat Feb 25 15:18:15 2012 +0100 - - Apply HMAC after encryption. - -commit f5dc136cfd7a3a195b75f7174722734e25f30fd9 -Merge: 3fba8017 5a28aa7b -Author: Guus Sliepen -Date: Thu Feb 23 13:26:01 2012 +0100 - - Merge branch 'master' of git://tinc-vpn.org/tinc into 1.1 - - Conflicts: - src/net.c - src/net_packet.c - src/net_socket.c - -commit 5a28aa7b8b0ab6237c2eab5f8b11253ea3ec5a05 -Author: Guus Sliepen -Date: Wed Feb 22 23:17:43 2012 +0100 - - Add LocalDiscovery option which tries to detect peers on the local network. - - Currently, this is implemented by sending IPv4 broadcast packets to the - LAN during path MTU discovery. - -commit 8e717ddb602f01f656369106ec0398efbe9ca4a4 -Author: Guus Sliepen -Date: Wed Feb 22 14:37:56 2012 +0100 - - Pass index into listen_socket[] to handle_incoming_vpn_data(). - -commit 3fba80174dbe29bcfe0d121a2a1d2e61be5ee57b -Merge: fba1c85f 65e8e06c -Author: Guus Sliepen -Date: Wed Feb 22 14:23:59 2012 +0100 - - Merge branch 'master' of git://tinc-vpn.org/tinc into 1.1 - - Conflicts: - NEWS - README - configure.in - doc/tincd.8.in - src/Makefile.am - src/bsd/device.c - src/connection.c - src/connection.h - src/cygwin/device.c - src/device.h - src/dropin.h - src/linux/device.c - src/mingw/device.c - src/net.c - src/net_packet.c - src/net_setup.c - src/net_socket.c - src/process.c - src/protocol.c - src/protocol_key.c - src/raw_socket_device.c - src/route.c - src/solaris/device.c - src/tincd.c - src/uml_device.c - -commit fba1c85f44edfc56c19d35332b1eb825179a8bb6 -Author: Guus Sliepen -Date: Tue Feb 21 23:19:51 2012 +0100 - - Remove useless warning about signature length being shorter than expected. - -commit cb6cbf452f6183a00746afc5bff8f63f3f55235f -Author: Guus Sliepen -Date: Tue Feb 21 23:17:12 2012 +0100 - - Use only one hash algorithm (SHA512) in the PRF. - - On some platforms, OpenSSL by default does not support the Whirlpool algorithm. - -commit 65e8e06c6dc7349b11c3c1e8f4071b51e2994c65 -Author: Nick Hibma -Date: Tue Feb 21 15:26:58 2012 +0100 - - Add missing ICMP message type definitions. - -commit ac48c4ee8c09c8144f830cb66386b9dbe7298440 -Author: Guus Sliepen -Date: Tue Feb 21 14:06:55 2012 +0100 - - Fix check for raw socket support. - - Also, move some variables so there are no compiler warnings about unused - variables when there is no support for raw sockets. - -commit d9ad3d313d96d30ef45cd53367dff9a855a396d4 -Author: Guus Sliepen -Date: Tue Feb 21 13:31:21 2012 +0100 - - Fix a bug that caused tinc to ignore all but the last listening socket. - -commit 46506b7aaf6c6a8a85561c38fdb9c95eae21aa75 -Author: Guus Sliepen -Date: Tue Feb 21 13:13:40 2012 +0100 - - Document the command line flag -o and provide --option as well. - -commit 7d76e287598c8c18cadfb5818046d9dd1b0ad881 -Author: Guus Sliepen -Date: Tue Feb 21 11:39:21 2012 +0100 - - Move initialization of char *priority up to prevent freeing an uninitialized pointer. - -commit 8420a0c8bde1781db04dd2436eb9d5dca5a1732a -Author: Guus Sliepen -Date: Mon Feb 20 17:19:00 2012 +0100 - - Allow disabling of broadcast packets. - - The Broadcast option can be used to cause tinc to drop all broadcast and - multicast packets. This option might be expanded in the future to selectively - allow only some broadcast packet types. - -commit ea415ccc1690d6e5864a7500977b181e5c8faafe -Author: Guus Sliepen -Date: Mon Feb 20 17:12:48 2012 +0100 - - Rename connection_t *broadcast to everyone. - -commit cff5a844a3e6b494f4a4f6eb5b48a84780f2d0e5 -Author: Guus Sliepen -Date: Mon Feb 20 16:52:53 2012 +0100 - - Don't bind outgoing TCP sockets anymore. - - The code introduced in commit 41a05f59ba2c3eb5caab555f096ed1b9fbe69ee3 is not - needed anymore, since tinc has been able to handle UDP packets from a different - source address than those of the TCP packets since 1.0.10. When using multiple - BindToAddress statements, this code does not make sense anymore, we do want the - kernel to choose the source address on its own. - -commit 0233b1d710222cb09be0cbd08c1297e3ece38a9f -Author: Guus Sliepen -Date: Mon Feb 20 16:34:02 2012 +0100 - - Decrement TTL of incoming packets. - - Tinc will now, by default, decrement the TTL field of incoming IPv4 and IPv6 - packets, before forwarding them to the virtual network device or to another - node. Packets with a TTL value of zero will be dropped, and an ICMP Time - Exceeded message will be sent back. - - This behaviour can be disabled using the DecrementTTL option. - -commit 6289859ab365dc1c0d420323174418b316b14502 -Author: Guus Sliepen -Date: Mon Feb 20 15:44:52 2012 +0100 - - Only compile raw socket code when it is supported on that platform. - -commit d1dcdf8eb6f800704be426b1ce6f6c1a8e65ba0d -Merge: 1b2846d9 3b1fad04 -Author: Guus Sliepen -Date: Sat Feb 18 14:31:08 2012 +0100 - - Merge branch 'master' of black:tinc - -commit 3b1fad04de6bed2f284fdf3d5b27d4162aeebc8c -Author: Guus Sliepen -Date: Sat Feb 18 14:37:52 2012 +0100 - - Allow setting DeviceType to tun or tap on Linux. - -commit 6455654d26d204cea4bbc102e5bd6550b7fff7a7 -Author: Guus Sliepen -Date: Sat Feb 18 11:48:21 2012 +0100 - - Send packets back using the same socket as they were received on. - -commit 1b2846d907adfc8472fc9da0c951c3243c7ee143 -Merge: 9f6a96af 6455654d -Author: Guus Sliepen -Date: Sat Feb 18 11:43:00 2012 +0100 - - Merge branch 'master' of black:tinc - -commit 9f6a96af3939bd2de410ce346a8c8fbcf93e7c9b -Author: Guus Sliepen -Date: Fri Feb 17 16:25:00 2012 +0100 - - Allow multiple BindToAddress statements. - -commit 708314df2f61675d0f54e541c9fff62ac1f433b5 -Author: Guus Sliepen -Date: Fri Feb 17 16:13:38 2012 +0100 - - Set FD_CLOEXEC flag on all sockets. - - Scripts called by tinc would inherit its open filedescriptors. This could - be a problem if other long-running daemons are started from those scripts, - if those daemons would not close all filedescriptors before going into the - background. - - Problem found and solution suggested by Nick Hibma. - -commit 1f00111e94b2f9a4beb9608b1e03a5e73c9c5d21 -Author: Guus Sliepen -Date: Mon Dec 26 23:11:27 2011 +0100 - - Fix a few small memory leaks. - -commit b50d6a7f2ad98239018bc5ce7a5739e3bf4f50f7 -Author: Guus Sliepen -Date: Mon Dec 26 23:04:40 2011 +0100 - - Fix compiler warnings. - -commit 178e52f76ef4ba40748c13ea7e518837394d6dbc -Author: Guus Sliepen -Date: Sun Dec 4 01:20:59 2011 +0100 - - Allow linking with multiple device drivers. - - Apart from the platform specific tun/tap driver, link with the dummy and - raw_socket devices, and optionally with support for UML and VDE devices. - At runtime, the DeviceType option can be used to select which driver to - use. - -commit 5672863e59e6a114ac6b66de98254b14266c0e61 -Author: Guus Sliepen -Date: Sat Dec 3 21:59:47 2011 +0100 - - Fix a few small memory leaks. - -commit 52ded09d1713b83222b56db7d29ff061aefb95e3 -Author: Guus Sliepen -Date: Sun Nov 27 12:13:16 2011 +0100 - - Add vde/device.c to the tarball. - -commit 2c7c87ec75c94d0b3cca9f7a5aeba34384f77cc1 -Author: Guus Sliepen -Date: Sun Nov 27 12:12:34 2011 +0100 - - Fix compilation of VDE and UML interfaces. - -commit 2a9060bba62d78f73da9b09ca791fe80993520fc -Author: Guus Sliepen -Date: Thu Oct 6 15:32:12 2011 +0200 - - Exchange ACK records to indicate switch to new keys. - - This allow application records to be sent while key renegotiation is still - happening. - -commit 3b5898078af1ab86797b3e24f2381131e6e702f7 -Author: Guus Sliepen -Date: Thu Oct 6 09:34:34 2011 +0200 - - Use counter mode encryption. - -commit a0f795ff5bd671ca10a7203e4234b37a12d8d1cd -Author: Guus Sliepen -Date: Thu Oct 6 09:33:09 2011 +0200 - - Add counter mode encryption. - -commit 67ff81ec16b8ab5f15d16efbedfecfaf0be17c13 -Author: Guus Sliepen -Date: Wed Oct 5 22:05:13 2011 +0200 - - Test corner cases in the SPTPS protocol. - - * Test zero-byte messages. - * Test maximum size (65535 byte) messages. - * Test different message types. - * Test key renegotiation. - -commit 30013511504e925729ebc67772205a74c4b8aeea -Author: Guus Sliepen -Date: Wed Oct 5 22:00:51 2011 +0200 - - Update SPTPS protocol. - - * Exchange nonce and ECDH public key first, calculate the ECDSA signature - over the complete key exchange. - * Make an explicit distinction between client and server in the signatures. - * Add more comments and replace some magic numbers by #defines. - - Thanks to Erik Tews for very helpful hints and comments! - -commit 810847248ae90140ee6f3e568add80aef88c3def -Author: Guus Sliepen -Date: Wed Oct 5 21:59:33 2011 +0200 - - Fix compiler warning. - -commit ddea7a23a66b8fee4942f2ce237dcabe02e17270 -Author: Guus Sliepen -Date: Tue Aug 30 20:49:48 2011 +0200 - - Return false instead of void when there is an error. - -commit e838289683c0039fac0ae6172d40b4177c17911b -Author: Guus Sliepen -Date: Tue Aug 30 19:56:56 2011 +0200 - - Prevent read_rsa_public_key() from returning an uninitialized RSA structure. - - In case the config file could not be opened a new but unitialized RSA structure - would be returned, causing a segmentation fault later on. This would only - happen in the case that the config file could be opened before, but not when - read_rsa_public_key() was called. This situation could occur when the --user - option was used, and the config files were not readable by the specified user. - -commit 5d4336e5429b88dcc53e80c00412e76a5269b384 -Author: Guus Sliepen -Date: Wed Aug 10 17:04:17 2011 +0200 - - Handle UDP packets with unknown source addresses properly. - - Probably due to a merge, the try_harder() function had duplicated the - rate-limiting code for detecting the sender node based on the HMAC of the - packet. This prevented this detection from running at all. The function is now - identical again to that in the 1.0 branch. - -commit bbc0ba9e87f76111529d6dc9cb00c0b9435b5858 -Author: Michael Tokarev -Date: Sun Aug 7 12:18:20 2011 +0400 - - use execvp() not execve() in tincctl start - - sometimes argv[0] will have directory-less name (when the - command is started by shell searching in $PATH for example). - For tincctl start we want the same rules to run tincd as for - tincctl itself (having full path is better but if shell does - not provide one we've no other choice). Previous code tried - to run ./tincd in this case, which is obviously wrong. - - This is a fix for the previous commit. - - Signed-off-by: Michael Tokarev - -commit a7556a9d2c943a6317d2dab66d9f742997f0d47a -Author: Michael Tokarev -Date: Sun Aug 7 12:05:07 2011 +0400 - - run tincd from the same directory as tincctl and pass all options to it - - For tincctl start, run tincd from dirname($0) not SBINDIR - - this allows painless alternative directory installation and - running from build directory too. - - Also while at it, pass the rest of command line to tincd, not - only options before "start" argument. This way it's possible - to pass options to tincd like this: - tincctl -n net start -- -d 1 -R -U tincuser ... - - And also add missing newline at the end of error message there. - - Signed-Off-By: Michael Tokarev - -commit 2696ad2cca73aee13e38f740d5530dc33e4a92e6 -Author: Michael Tokarev -Date: Sun Aug 7 11:25:03 2011 +0400 - - don't mention reload twice in tincctl help - - Signed-Off-By: Michael Tokarev - -commit 3d75dbc0880484ff6d2f689a9b981def3cd75b5e -Author: Guus Sliepen -Date: Sun Jul 24 15:44:51 2011 +0200 - - Start of "Simple Peer-To-Peer Security" protocol. - - Encryption and authentication of the meta connection is spread out over - meta.c and protocol_auth.c. The new protocol was added there as well, - leading to spaghetti code. To improve things, the new protocol will now - be implemented in sptps.[ch]. - - The goal is to have a very simplified version of TLS. There is a record - layer, and there are only two record types: application data and - handshake messages. The handshake message contains a random nonce, an - ephemeral ECDH public key, and an ECDSA signature over the former. After - the ECDH public keys are exchanged, a shared secret is calculated, and a - TLS style PRF is used to generate the key material for the cipher and - HMAC algorithm, and further communication is encrypted and authenticated. - - A lot of the simplicity comes from the fact that both sides must have - each other's public keys in advance, and there are no options to choose. - There will be one fixed cipher suite, and both peers always authenticate - each other. (Inspiration taken from Ian Grigg's hypotheses[0].) - There might be some compromise in the future, to enable or disable - encryption, authentication and compression, but there will be no choice - of algorithms. This will allow SPTPS to be built with a few embedded - crypto algorithms instead of linking with huge crypto libraries. - - The API is also kept simple. There is a start and a stop function. All - data necessary to make the connection work is passed in the start - function. Instead having both send- and receive-record functions, there - is a send-record function and a receive-data function. The latter will - pass protocol data received from the peer to the SPTPS implementation, - which will in turn call a receive-record callback function when - necessary. This hides all the handshaking from the application, and is - completely independent from any event loop or socket characteristics. - - [0] http://iang.org/ssl/hn_hypotheses_in_secure_protocol_design.html - -commit 0f2aa4bd8b698608876bec141c5aef1aa619730b -Author: Guus Sliepen -Date: Sat Jul 23 14:12:23 2011 +0200 - - Releasing 1.0.16. - -commit e16ead8dd9d4600664058069f0695832dfe068b2 -Author: Guus Sliepen -Date: Sat Jul 23 14:11:44 2011 +0200 - - Use usleep() instead of sleep(), MinGW complained. - -commit ff751903aa82bd6dd66a099f9c05dcdae9fc57f2 -Author: Guus Sliepen -Date: Wed Jul 20 08:19:18 2011 +0200 - - Don't abort() on low-level crypto errors, just return false. - - The abort() calls were accidentily left in for debugging. - -commit 2f4ccfe2473948372f7c9f14d9ffce1d77f5fd8c -Author: Guus Sliepen -Date: Tue Jul 19 21:11:11 2011 +0200 - - Fix tinc 1.0.x daemons connecting when ExperimentalProtocol = yes. - -commit f8d94f34fc5d7fe9ed4a076a2fd77eacbd83adca -Author: Guus Sliepen -Date: Sun Jul 17 20:09:08 2011 +0200 - - Releasing 1.1pre2. - -commit c259d552fa89c3e4a962d9adf2b237f24bc077da -Author: Guus Sliepen -Date: Sun Jul 17 20:06:06 2011 +0200 - - Add missing newline. - -commit f6020a5224c9c4c17c11c5f9d2c8441638ac04fc -Author: Guus Sliepen -Date: Sun Jul 17 20:01:24 2011 +0200 - - Write loopback address instead of "any" address in pidfile. - -commit 50fcfea127c9d2fdf8894498a9fdcc6fb3bbb2ce -Author: Guus Sliepen -Date: Sun Jul 17 19:34:01 2011 +0200 - - Flush output buffer in send_tcppacket(). - - This is mainly important for Windows, where the select() call in the - main thread is not being woken up when the tapreader thread calls - route(), causing a delay of up to 1 second before the output buffer is - flushed. This would cause bad performance when UDP communication is not - possible. - -commit 25091454da21941dd92375ddbee7dd6151343058 -Author: Guus Sliepen -Date: Sun Jul 17 19:23:52 2011 +0200 - - "tincctl stop" now removes the tinc service on Windows. - -commit c6c989cfa175154f4cd3830c5a77fbd2071f52af -Author: Guus Sliepen -Date: Sun Jul 17 18:02:56 2011 +0200 - - Fix declaration of usleep(). - -commit 18e9839dc861c368141bbbc9a963f719a83eba3e -Author: Guus Sliepen -Date: Sun Jul 17 10:59:54 2011 +0200 - - Ensure symlinked files do not end up in the tarball. - -commit fa4a01e4a27dd4b3a57077acbd0e69f95d55944a -Author: Guus Sliepen -Date: Sat Jul 16 22:38:50 2011 +0200 - - Use const pointer to source in base64 and hex routines. - -commit 574b380dfc75ef13ee4accba1f2416165c58a5a2 -Author: Guus Sliepen -Date: Sat Jul 16 22:38:22 2011 +0200 - - Use usleep() instead of sleep(), MinGW complained. - -commit 8efc8dc961865ceddb74cb36f0b4a2ebde39cc55 -Author: Guus Sliepen -Date: Sat Jul 16 21:44:17 2011 +0200 - - Update info manual. - -commit cff27a258f3b3a97b5d2e309c264eceea41dff3a -Author: Guus Sliepen -Date: Sat Jul 16 20:21:44 2011 +0200 - - Use ECDSA to sign ECDH key exchange for UDP session keys. - - The ECDSA public keys will also be included in the ANS_KEY requests, - but are only used when no ECDSA public key is known yet. - -commit 03ac48ea19914e4162f17a2fb0f742b99ae32499 -Author: Guus Sliepen -Date: Sat Jul 16 15:21:37 2011 +0200 - - Use the same logic as tinc 1.0.x for detecting two nodes with the same Name. - -commit 2ba61742d4c2ab82525efb806dc654a6d95d335e -Author: Guus Sliepen -Date: Sat Jul 16 15:15:29 2011 +0200 - - Use the correct direction flag when setting cipher keys. - - The flag was set incorrectly, but for most ciphers this does not have - any effect. AES in any of the block modes is picky about it though. - -commit be2fc8b0458b1e2ced3b5de410356d8d8639acff -Author: Guus Sliepen -Date: Sat Jul 16 10:47:35 2011 +0200 - - Make code to detect two nodes with the same Name less triggerhappy. - - First of all, if there really are two nodes with the same name, much - more than 10 contradicting ADD_EDGE and DEL_EDGE messages will be sent. - Also, we forgot to reset the counters when nothing happened. - - In case there is a ADD_EDGE/DEL_EDGE storm, we do not shut down, but - sleep an increasing amount of time, allowing tinc to recover gracefully - from temporary failures. - -commit 303dd1e70219a7542921f6e63d9391ab326d434f -Author: Guus Sliepen -Date: Wed Jul 13 22:52:52 2011 +0200 - - Fix compiler warnings. - -commit 791c1898ea8f92b07f1d79e90540c257ac38298d -Author: Guus Sliepen -Date: Wed Jul 13 22:29:30 2011 +0200 - - Remove unnecessary variables and functions. - -commit fec279a9c54ec8a13bd1ba4c7bec0d2a15454992 -Author: Guus Sliepen -Date: Tue Jul 12 23:43:12 2011 +0200 - - Make use of the improved hex and base64 functions. - - Also, use base64 for all EC related data, it is shorter and easy to - distinguish from the legacy protocol. - -commit 06b8271ed5d56c9bd3de459d95907d0ef4f0ea3c -Author: Guus Sliepen -Date: Tue Jul 12 22:54:49 2011 +0200 - - Make hexadecimal and base64 routines behave the same. - - The length parameter for the encoding functions is the length of the - binary input, and for the decoding functions it is the maximum size of - the binary output. - - The return value is always the length of the resulting output, excluding - the terminating NULL character for the encoding routines. - - All functions can encode and decode in-place. The encoding functions - will always write a terminating NULL character, and the decoding - functions will stop at a NULL character. - -commit c108c79a22118ef7246a3d7b3bc20e205e11d179 -Author: Guus Sliepen -Date: Mon Jul 11 22:14:06 2011 +0200 - - Don't use wildcards in filenames in configure.in. - -commit bbeab00f46a6c856573fe0d2b9b85bce35728403 -Author: Guus Sliepen -Date: Mon Jul 11 21:54:01 2011 +0200 - - Require ExperimentalProtocol = yes for new features, update documentation. - -commit d1cd3c81455ecb32149cbaa424b7870075b2b2fc -Author: Guus Sliepen -Date: Sun Jul 10 22:46:43 2011 +0200 - - Close meta connection socket after cleaning up event structures. - - Epoll doesn't like it when an already closed filedescriptor is being - removed, so we defer closing the socket until after all else is cleaned - up. - -commit 30ef2a981e1d62692b3a2363e0b3a0e8711d9604 -Author: Guus Sliepen -Date: Sun Jul 10 22:34:17 2011 +0200 - - Automatically exchange ECDSA keys and upgrade to new authentication protocol. - - If we don't have ECDSA keys for the node we connect to, set protocol_minor - to 1, to indicate this to the other end. This will first complete the - old way of authentication with RSA keys, and will then exchange ECDSA keys. - The connection will be terminated right afterwards, and the next attempt - will use ECDSA keys. - -commit 027228debee2ea6f31cd176e456c13d626380066 -Author: Guus Sliepen -Date: Sun Jul 10 21:02:34 2011 +0200 - - Free ECDSA and RSA structures when freeing a connection_t. - -commit 73863fab8ae1ecd8307aaeef486919cc76b85d63 -Author: Guus Sliepen -Date: Fri Jul 8 18:17:34 2011 +0200 - - Hash input before signing it with ECDSA. - -commit 8132be8fbd6c45be309c63a117f418ad12ced094 -Author: Guus Sliepen -Date: Thu Jul 7 22:30:55 2011 +0200 - - Very primitive ECDSA signed ECDH key exchange for the meta protocol. - - Nonces and hash of the ID requests should be included in the seed for the PRF. - -commit 210b5ceeeebdf742a74dcf95a0a13d69623ee001 -Author: Guus Sliepen -Date: Thu Jul 7 22:28:25 2011 +0200 - - Read ECDSA keys. - -commit 03582eb669494cb778ebea7b0fe3b1b841335750 -Author: Guus Sliepen -Date: Thu Jul 7 22:27:17 2011 +0200 - - Implement ECDSA sign and verify operations. - - Very basic at the moment, doesn't hash the input first, - and uses OpenSSL's DER encoded signature as output. - -commit 86d83bd9bd69e2129f4e4e8397f1c7e223685e2f -Author: Guus Sliepen -Date: Tue Jul 5 21:29:31 2011 +0200 - - Bump minor protocol to indicate ECDH capability for UDP session keys. - -commit 9708bbfa8e3094de8932a30b1d24c661558d8a03 -Author: Guus Sliepen -Date: Tue Jul 5 21:19:48 2011 +0200 - - Add a minor number to the protocol version. - -commit b99656d84a88dad7935d5981fcdb43a5b2bfa417 -Author: Guus Sliepen -Date: Mon Jul 4 07:51:47 2011 +0200 - - Round up the size of the secret parts after splitting it in two. - -commit 95e1cc36d320b47408ac3ec6f89df54e55a010d4 -Author: Guus Sliepen -Date: Sun Jul 3 23:44:43 2011 +0200 - - Add ECDSA key import. - -commit 1e2d9b08991861c8770aa2c5a73d86dc02e3067d -Author: Guus Sliepen -Date: Sun Jul 3 23:33:56 2011 +0200 - - Finish base64 decoding routine. - -commit 80b81c00b129b006981b76bdb734df3296317d6f -Author: Guus Sliepen -Date: Sun Jul 3 22:25:29 2011 +0200 - - Have tincctl generate ECDSA keys. - - The generate-keys command now generates both an RSA and an ECDSA keypair, - but one can generate-rsa-keys or generate-ecdsa-keys to just generate one type. - -commit 8ace7f3e5771957fbdda8b817fa26951d9d62c28 -Author: Guus Sliepen -Date: Sun Jul 3 22:15:00 2011 +0200 - - Add ECDSA key generation. - -commit 1d92dd62a786ecabbc05dfba5195f3f08e0f9585 -Author: Guus Sliepen -Date: Sun Jul 3 22:13:58 2011 +0200 - - Base64 encoding and decoding functions. - -commit c385d115331845e8a844322e66571d74d833e822 -Author: Guus Sliepen -Date: Sun Jul 3 22:13:34 2011 +0200 - - Cleanups in ECDH code. - -commit 895f868714f9422a757a95650345e0c662d12b49 -Author: Guus Sliepen -Date: Sun Jul 3 21:21:37 2011 +0200 - - No need to keep around pointers to EC_GROUP. - -commit ac163120d7f0300c8d555f76ace3368ce2ffa655 -Author: Guus Sliepen -Date: Sun Jul 3 16:30:49 2011 +0200 - - Proper use of PRF. - -commit 82f00ea07bffc10985ccb1a15723e6daa0ab4969 -Author: Guus Sliepen -Date: Sun Jul 3 15:59:49 2011 +0200 - - Use PRF. - -commit feb3f22fffa2620b9b11a509ce51ff9fa3be9418 -Author: Guus Sliepen -Date: Sun Jul 3 15:26:58 2011 +0200 - - Add PRF to derive key material from the ECDH shared secret. - - It is modelled after the pseudorandom function from RFC4346 (TLS 1.1), the only - significant change is the use of SHA512 and Whirlpool instead of MD5 and SHA1. - -commit 8dfa072733feab737cabf69f000c70657719826a -Author: Guus Sliepen -Date: Sun Jul 3 13:17:28 2011 +0200 - - Support ECDH key exchange. - - REQ_KEY requests have an extra field indicating key exchange version. - If it is present and > 0, the sender supports ECDH. If the receiver also - does, then it will generate a new keypair and sends the public key in a - ANS_KEY request with "ECDH:" prefixed. The ans_key_h() function will - compute the shared secret, which, at the moment,is used as is to set the - cipher and HMAC keys. However, this must be changed to use a proper KDF. - In the future, the ECDH key exchange must also be signed. - -commit ee8a214318fd6dbe6bc5d6b510896f30d92d46c6 -Author: Guus Sliepen -Date: Mon Jun 27 21:52:23 2011 +0200 - - Preliminary implementation of Elliptic Curve Diffie-Hellman Ephemeral key exchange. - -commit 6c21b5716b8e9e5ff5def8070f92b76a0f353cb0 -Author: Guus Sliepen -Date: Sun Jun 26 13:15:44 2011 +0200 - - Add manpage for tinc-gui. - -commit 4c934d0903a32e71ae83ffdf344957bd06b7164d -Author: Guus Sliepen -Date: Sun Jun 26 13:14:48 2011 +0200 - - Remove debug messages that were printed to stdout. - -commit e73052b05444679d922dbdf3d0c507873110957e -Author: Guus Sliepen -Date: Sun Jun 26 12:59:11 2011 +0200 - - Update documentation to mention pidfiles instead of controlcookies. - -commit 8c953b1bfef3c6ebee7c537c2c2f144807d0311a -Author: Guus Sliepen -Date: Sun Jun 26 12:58:50 2011 +0200 - - Don't react to escape character in tincctl top. - - Not only the ESC key generates an escape character, but many other keys - do as well, such as arrow keys. - -commit 27e6a89b155b171b0b026d5e24ee0cc68f43d010 -Author: Guus Sliepen -Date: Sun Jun 26 12:51:25 2011 +0200 - - Use pidfile in tinc-gui as well. - -commit 660f530a6ff733f96f81eefa69b38e2ea685f890 -Author: Guus Sliepen -Date: Sat Jun 25 22:20:39 2011 +0200 - - Really stable sorting of tincctl top output. - -commit 810766e1394f18b8709e9f0c75a41a2c348e3fad -Author: Guus Sliepen -Date: Sat Jun 25 21:38:59 2011 +0200 - - Add +git to the version string. - -commit ab4d289fafd1d391583935ab4c306f1f508ea1d0 -Author: Guus Sliepen -Date: Sat Jun 25 21:35:27 2011 +0200 - - Make pid files backwards compatible and add address of listening socket. - - The pid is now written first, so that a version 1.0.x tincd can be used to stop - a running version 1.1 tincd. Getsockname() is used to determine the address of - the first listening socket, so that tincctl can connect to the local tincd even - if AddressFamily = ipv6, or if BindToAddress or BindToInterface is used. - -commit a05fa7f88264599a43f9e411287e018259dc22b1 -Author: Guus Sliepen -Date: Sat Jun 25 21:21:36 2011 +0200 - - Rename controlcookie file to pidfile. - -commit c64f64b875879591873d68faf2d3cd8e9d644101 -Author: Guus Sliepen -Date: Sat Jun 25 21:16:13 2011 +0200 - - Don't call exit_control() if we didn't do init_control(). - -commit 3b237afbda86bc95703ed25386cc9a26695d4602 -Author: Guus Sliepen -Date: Sat Jun 25 20:20:07 2011 +0200 - - Re-add support for SIGALRM. - -commit 386c1aff08a3ce6e295931e2fcf4bfc607053ff0 -Author: Guus Sliepen -Date: Sat Jun 25 17:39:02 2011 +0200 - - Merge Tinc.py into tinc-gui to simplify make install. - - Autoconf/automake's Python support is strange. - -commit c4c32f40599eb8e75b1160083020d924c5807ac8 -Author: Guus Sliepen -Date: Sat Jun 25 17:11:05 2011 +0200 - - Thank Scott Lamb, Sven-Haegar Koch and Loïc Grenié in the NEWS file. - -commit 8733110dec28967d67a3c00d00cdfa608dbeb9c4 -Author: Guus Sliepen -Date: Sat Jun 25 17:08:40 2011 +0200 - - Ensure the right files end up in the tarball after make dist. - -commit e4f65db89726ac06ba7e787d420db4422d9a6e98 -Author: Guus Sliepen -Date: Sat Jun 25 15:28:54 2011 +0200 - - Releasing 1.1pre1. - -commit 2c5ded652035bfaa204a7e1cc6766efb87135569 -Author: Guus Sliepen -Date: Sat Jun 25 15:28:13 2011 +0200 - - Ensure that the texinfo manual can be converted to HTML. - - Somehow commit 2c30af6c90926340a89748c63cc453b1c0b5a589 was not properly - merged. - -commit e8deda0b23463599a7533e82cf038a01062956a7 -Author: Guus Sliepen -Date: Sat Jun 25 14:52:47 2011 +0200 - - Update manpages and info manual. - -commit 47393b5de42120dfb7d01f8b77aff16ac68177ec -Author: Guus Sliepen -Date: Sat Jun 25 00:32:45 2011 +0200 - - Add Makefile.am in gui/. - - This ensures the gui source will be included in the tarball with make dist, - and will be installed with make install. - -commit 7944cce19e4de4207a4ef20569155118acebd406 -Author: Guus Sliepen -Date: Sat Jun 25 00:06:06 2011 +0200 - - Don't use AM_CONDITIONAL for CURSES. - - For some reason, this doesn't work when cross-compiling for Windows. - -commit 365f60f3f8a8ff85a616d5014d555b470740d395 -Author: Guus Sliepen -Date: Fri Jun 24 22:49:18 2011 +0200 - - Don't call event_del() from the mtuevent handler, always send_mtu_probe() in ans_key_h(). - -commit 1fe8ba2f06c39d7c8b81f0e451bdbac94ae9375f -Author: Guus Sliepen -Date: Fri Jun 24 22:10:03 2011 +0200 - - Delete mtuevent if it is not used. - - Keeping it around prevents ans_key_h() from restarting PMTU discovery. - -commit 79e9a4f743b7b59fed968575f6b36171cf4a0063 -Merge: fb5b2601 05260f94 -Author: Guus Sliepen -Date: Fri Jun 24 21:40:55 2011 +0200 - - Merge branch 'master' of git://tinc-vpn.org/tinc into 1.1 - - Conflicts: - NEWS - README - configure.in - src/Makefile.am - -commit 05260f941c2a24eb3f09070a2550cf15e431266a -Author: Guus Sliepen -Date: Fri Jun 24 14:50:20 2011 +0200 - - Releasing 1.0.15. - -commit 3c0511984f0041f79e64bcc55d58680f86e8e408 -Author: Guus Sliepen -Date: Fri Jun 24 12:27:04 2011 +0200 - - Remove redundant @CFLAGS@ from AM_CFLAGS. - -commit fb5b260190b1c6d07ec822154094aee7416f292e -Author: Guus Sliepen -Date: Tue Jun 21 23:08:05 2011 +0200 - - No need to check for pselect() in tinc 1.1. - -commit 532557beeaa60d96ac423248ff62d2cc03205c22 -Author: Guus Sliepen -Date: Tue Jun 21 23:06:53 2011 +0200 - - Only log UDP address changes at the appropriate debug levels. - -commit 60ed7fe598ccf3ac11fab616c9c85492c576b722 -Author: Guus Sliepen -Date: Mon Jun 6 21:19:30 2011 +0200 - - Reopen log file after SIGHUP. - - This was missed by the previous merge. - -commit 33f241d97852d7a171f1aaf1bda7f66356ff889e -Merge: 601f3b2d 4b3fd94b -Author: Guus Sliepen -Date: Mon Jun 6 20:42:15 2011 +0200 - - Merge branch 'master' of git://tinc-vpn.org/tinc into 1.1 - - Conflicts: - NEWS - configure.in - doc/tincd.8.in - lib/pidfile.c - lib/pidfile.h - lib/xalloc.h - lib/xmalloc.c - src/conf.c - src/conf.h - src/connection.c - src/connection.h - src/event.c - src/graph.c - src/graph.h - src/net.c - src/net.h - src/node.h - src/openssl/crypto.c - src/process.c - src/protocol.c - src/protocol_key.c - src/route.c - -commit 601f3b2dd746ff5726eca256861f2ecf662b3a55 -Author: Guus Sliepen -Date: Mon Jun 6 20:12:33 2011 +0200 - - Clean up digests when freeing a connection_t. - -commit 4b3fd94b1cc79c24c4092b6b10ed4627a2648d26 -Author: Guus Sliepen -Date: Mon Jun 6 16:26:11 2011 +0200 - - Improved --logfile option. - - Instead of UNIX time, the log messages now start with the time in RFC3339 - format, which human-readable and still easy for the computer to parse and sort. - The HUP signal will also cause the log file to be closed and reopened, which is - useful when log rotation is used. If there is an error while opening the log - file, this is logged to stderr. - -commit b3bbeab6e669795f6f5a6b98590da359178bfdce -Author: Guus Sliepen -Date: Sat Jun 4 11:27:54 2011 +0200 - - Attribution for Loïc Grenié. - -commit 50af33d01f425983dd2b1d7b61092a6325be3f41 -Author: Loïc Grenié -Date: Sat Jun 4 09:05:23 2011 +0200 - - Nearly tickless tinc. - - Use pselect instead of select in main_loop (if available). This lets - tincd sleeps as long as there is nothing to do. - -commit 8b3cc695b56d4ab5e51c7e194153894f920b307f -Author: Guus Sliepen -Date: Fri Jun 3 15:50:20 2011 +0200 - - Don't ignore SIGCHLD, system() needs it. - - But we do ignore SIGPIPE, and tinc 1.0.x signals that are no longer used - (SIGUSR1 and SIGUSR2), since the default handler of these signals is to - terminate tincd immediately. - -commit 5989a29d7b53b25e8ed2f60bc3a0e089e423c02c -Author: Guus Sliepen -Date: Fri Jun 3 00:46:56 2011 +0200 - - Fix format strings for Windows. - - Windows doesn't like %zd, so cast (s)size_t to int. Also, some shorts were - incorrectly printed with %d instead of %hd. - -commit 3ade33bfac11715190ed3e6cc3589d1a738ce257 -Author: Guus Sliepen -Date: Fri Jun 3 00:34:30 2011 +0200 - - Use send() when writing to sockets, and the return type is ssize_t. - -commit 5f4d57e846b566e80557c57a72e2bad562f66e7b -Author: Guus Sliepen -Date: Thu Jun 2 23:40:27 2011 +0200 - - Small fixes for Windows. - -commit 2adc789401153ffde847f76155e07665fbf909ac -Author: Guus Sliepen -Date: Thu Jun 2 22:14:53 2011 +0200 - - Even simpler signal handling. - -commit 2f42896789a1798e71374fa2ddf555fe2fa46c44 -Author: Guus Sliepen -Date: Thu Jun 2 21:29:11 2011 +0200 - - Remove debugging message that was accidentily left in. - -commit c6b0e102ad7caabae6876849c97f8acaecf5bc1a -Author: Guus Sliepen -Date: Thu Jun 2 21:16:57 2011 +0200 - - Don't treat packets coming in via TCP as having zero length. - -commit 80ca91769d48e546d3e4cde03c2eb2820c03acc4 -Author: Guus Sliepen -Date: Thu Jun 2 21:14:50 2011 +0200 - - Fix nodes joining the VPN after tincctl top started. - -commit 311f60f4f0bdf974d4890d7eb4a752299d1c9458 -Author: Guus Sliepen -Date: Thu Jun 2 20:48:18 2011 +0200 - - Make traffic statistics more readable with configurable scaling. - -commit a8f0d21330b40993d52421327b1aa33a6ea7acb7 -Author: Guus Sliepen -Date: Thu Jun 2 20:27:16 2011 +0200 - - More stable sorting in tincctl top. - - Although we use qsort(), which is not guaranteed to be stable, resorting the - previously sorted array is more stable than recreating and resorting the array - each time. - -commit 2bda2aa8855ff3ae42aba7aa86e1d7ff2b7a3b34 -Author: Guus Sliepen -Date: Thu Jun 2 18:22:26 2011 +0200 - - Fix some compiler and cppcheck warnings. - -commit 809dfd2f5b08ecbfe55d1a06d267abeef0044b0b -Author: Guus Sliepen -Date: Thu Jun 2 18:07:50 2011 +0200 - - Remove support for the Ethertap device. - -commit af2e0c9a32642065aedd2e67ca1f5791ca7a407d -Author: Guus Sliepen -Date: Thu Jun 2 17:57:53 2011 +0200 - - Remove unused functions and variables. - -commit 9eca49329db0c3b0a80114045cf214eaeaf3d5c2 -Author: Guus Sliepen -Date: Thu Jun 2 17:55:29 2011 +0200 - - Don't #include anymore. - -commit b7754e5aaa3cc453582d6c8c2e66483fdcd1ac0d -Author: Guus Sliepen -Date: Thu Jun 2 17:53:35 2011 +0200 - - Drop the GNU memcmp.c implementation. - -commit 25b467638a23ad03524719329027225ae1da75bc -Author: Guus Sliepen -Date: Thu Jun 2 17:45:06 2011 +0200 - - Drop the GNU malloc.c, realloc.c, and xmalloc.c. - - We live in the 21st century, and we require C99 semantics, so we do not need to - work around buggy libcs. The xmalloc() and related functions are now static - inline functions. - -commit e452a933f9c53fd58db9d932afd15319129dd988 -Author: Guus Sliepen -Date: Thu Jun 2 17:14:30 2011 +0200 - - Simplify signal handling. - - We don't override any signal handlers anymore except those for SIGPIPE and - SIGCHLD. Fatal signals (SIGSEGV, SIGBUS etc.) will terminate tincd and - optionally dump core. The previous behaviour was to terminate gracefully and - try to restart, but that usually failed and made any core dump useless. - -commit 4d440336c3ce68719e23b2fc51fac368e23352ad -Author: Guus Sliepen -Date: Sun May 29 22:34:19 2011 +0200 - - Remove outgoing event in free_connection(). - -commit d29bfc9a450b4758e44757a71675bac631dd3c55 -Author: Guus Sliepen -Date: Sun May 29 22:14:35 2011 +0200 - - Initialise priority field to zero for packets read from the VPN interface. - -commit 4c403840ffdeb2a2ff04c9b7780a407920b2b794 -Author: Guus Sliepen -Date: Sun May 29 22:12:37 2011 +0200 - - Cosmetic fix when pressing 's' in tincctl top. - -commit b3aeaf0f917a895332ff937c7ab64638eacc0eae -Author: Guus Sliepen -Date: Sun May 29 22:10:54 2011 +0200 - - Show hostname and port in error message when connecting to a running tincd. - -commit 04de15984f1479d0142bdfa5bd968274aea2209e -Author: Sven-Haegar Koch -Date: Sun May 29 21:53:21 2011 +0200 - - do_outgoing_connection() may delete a failed connection, and the structure - must not be accessed afterwards. - -commit 82109868b5acd55e452569c565ab6dc090ea1de0 -Author: Sven-Haegar Koch -Date: Sun May 29 21:35:31 2011 +0200 - - src/net_socket.c bind_to_address(): Use after free in error path. - -commit 5bc957074a35e58f49cbcf8d1fb5d6237d37363d -Author: Guus Sliepen -Date: Sun May 29 14:41:05 2011 +0200 - - Allow tincctl to connect to something besides localhost. - - This would allow tincctl to connect to a remote tincd, or to a local tincd that - isn't listening on localhost, for example if it is using the BindToInterface or - BindToAddress options. - -commit 64771f73ebbff04262defcde59263e98f89f0fa1 -Author: Guus Sliepen -Date: Sat May 28 23:46:56 2011 +0200 - - Remove a few unnecessary #includes. - - Some spotted by Michael Tokarev. - -commit 5cff8c47c1781a88123c128a4cec6cdd39925aa5 -Author: Guus Sliepen -Date: Sat May 28 23:42:18 2011 +0200 - - Remove newlines from log messages. - -commit 6d08eb1614b59d5f86a43edda9db06fca72b76cd -Author: Guus Sliepen -Date: Sat May 28 23:36:52 2011 +0200 - - Fix sparse warnings and add an extra sprinkling of const. - - This is more or less the equivalent of Sven-Haegar Koch's fixes in the 1.1 - branch. - -commit e6b21e1a510691a86dcc1ecdf71a80a7c62ff17f -Author: Sven-Haegar Koch -Date: Sat May 28 03:48:07 2011 +0200 - - fgets() returns NULL on error, not < 0 - -commit 434e57ae5ee79b3d990c4d75358047bad641998b -Author: Sven-Haegar Koch -Date: Sat May 28 03:46:39 2011 +0200 - - sparse fixup: warning: Using plain integer as NULL pointer - -commit f4010694b3b16453e5e6298c208910264e326978 -Author: Sven-Haegar Koch -Date: Sat May 28 03:57:20 2011 +0200 - - sparse fixup: warning: non-ANSI function declaration of function '...' - -commit d772289f6d6adfb8932658b533349d43f08ec326 -Author: Sven-Haegar Koch -Date: Sat May 28 03:56:06 2011 +0200 - - sparse fixup: warning: symbol '...' was not declared. Should it be static? - -commit 02e32cf61ee25d3d0e2fc1fef5cd98cbfa1c9a2f -Author: Sven-Haegar Koch -Date: Sat May 28 03:12:03 2011 +0200 - - sparse fixup: error: too many arguments for function send_key_changed - -commit b995243ac3d9605003996ba879808ddcbc77ae15 -Author: Sven-Haegar Koch -Date: Sat May 28 03:08:31 2011 +0200 - - sparse fixup: error: dubious one-bit signed bitfield - -commit bbd0025ae323e7141ba04a5371ec2f3f75f9b059 -Author: Sven-Haegar Koch -Date: Sat May 28 02:57:40 2011 +0200 - - Use same definition for xalloc_fail_func as is really used. - -commit 3fca2cad485ef70360bca085c5c4d052b6deb15b -Author: Sven-Haegar Koch -Date: Sat May 28 01:36:10 2011 +0200 - - Removed two newlines from the end of log messages which created empty lines. - -commit 9cce44dfe3401867f753778b73fd1e7ac1ee3122 -Author: Sven-Haegar Koch -Date: Sat May 28 01:33:45 2011 +0200 - - Fixed error logging on "Input buffer full" condition. - -commit 07ffb1a19859791d419b83a876ba552dadedbf46 -Author: Guus Sliepen -Date: Sun May 22 15:56:04 2011 +0200 - - Make return value of SetPriorityClass() behave the same as setpriority(). - -commit 453c44e7b27d4259461795ab4ec6ef264085dd28 -Author: Guus Sliepen -Date: Sun May 22 14:17:30 2011 +0200 - - Add the ability to dump all traffic going through route() over a control connection. - - One can get the packet stream in pcap format, which can be decoded using - tcpdump, for example: - - tincctl -n pcap | tcpdump -r - - -commit 54c900e961de6065f607f5661edeb7c84be29ea5 -Author: Guus Sliepen -Date: Sun May 22 14:02:27 2011 +0200 - - Reset tcplen after use. - -commit 8ddcad5fa1908727f68abb461b615c666616064f -Author: Guus Sliepen -Date: Sun May 22 13:15:27 2011 +0200 - - Check if an event is initialized before calling event_del(). - - Libevent prints a warning to stderr if we do that. - -commit 931e30f91a9241ab8aa705c911c92ba8943f80fd -Author: Guus Sliepen -Date: Sun May 22 13:15:05 2011 +0200 - - Always compact the buffer if it has reached MAXBUFSIZE. - -commit 90c7fafe594cf6d03c15a072a3d749f3e4d78482 -Author: Guus Sliepen -Date: Sun May 22 12:56:51 2011 +0200 - - Compact input buffer before trying to read instead of after. - - Also log an error when the input buffer contains more than MAXBUFSIZE bytes - already, instead of silently claiming the other side closed the connection. - -commit 8de8f1d9e2c2c02d4a14a5506e7d0d914dc328da -Author: Guus Sliepen -Date: Tue May 17 10:58:22 2011 +0200 - - Fix some compiler warnings. - -commit a80c18dd20e5303b26d5283e6cb5062a1812ddc3 -Author: Guus Sliepen -Date: Tue May 17 10:57:30 2011 +0200 - - Use GetItemCount() on ListCtrls instead of directly accessing ItemCount. - -commit f536504a7de90927b09d16f3bf0d3c6adead9955 -Author: Guus Sliepen -Date: Mon May 16 09:48:19 2011 +0200 - - Add top.h. - -commit e272fab858d5d3eeb43ff9f36268d25d3c6d32f1 -Author: Guus Sliepen -Date: Mon May 16 09:46:54 2011 +0200 - - Add tincctl.h. - -commit 6d97cb1e229c22d1d34aa9889aeaf17644ff06dc -Author: Guus Sliepen -Date: Sun May 15 16:30:13 2011 +0200 - - Nicer top command. - - - Configurable refresh interval. - - Switch between cumulative count or current rate. - - Configurable sorting. - -commit 4574b04f79d79d53492b7e0eb592d64ff9b2362b -Author: Guus Sliepen -Date: Sun May 15 16:29:54 2011 +0200 - - Allow inserting items in the middle of a list. - -commit 97355690b9cf8d8b56a316e01f73f8ff1fee68c8 -Author: Guus Sliepen -Date: Sun May 15 13:16:48 2011 +0200 - - Add a very primitive "top" command to tincctl. - -commit ec495b2f15fc5ae22136c226c7966caf51f643f8 -Author: Guus Sliepen -Date: Sun May 15 12:06:21 2011 +0200 - - Add an autoconf check for the curses library. - -commit 362d8a6358019cb97456c8133832f18798cea41f -Author: Guus Sliepen -Date: Sun May 15 11:59:13 2011 +0200 - - Dump traffic statistics over control sockets. - -commit f5843e7d649f4a7f72cb3fd356bc935457aa492f -Author: Guus Sliepen -Date: Sun May 15 00:42:29 2011 +0200 - - Add per-node traffic counters. - -commit ffa3a443b9f01d3ea0fcb3c4fc6928a5c695cf4a -Author: Guus Sliepen -Date: Sat May 14 22:30:23 2011 +0200 - - Several fixes for the buffer code. - -commit cdb793f687262b9f56823ca9046523a609a758af -Author: Guus Sliepen -Date: Sat May 14 19:20:56 2011 +0200 - - Remove use of bufferevent and eventbuffers, use our own buffering instead. - -commit f431fcb35f400be388a905ae0f7f50c1f5c4cd5d -Author: Guus Sliepen -Date: Sat May 14 19:15:04 2011 +0200 - - Add simple buffer management code. - - Libevent 2.0's buffer code is not completely backward compatible with 1.4's. - In order to not (mis)use it anymore, we implement it ourselves. The buffers - are automatically expanding when necessary. When consuming data from the - buffer, no memmove()s are performed. Only when adding to the buffer would - write past the end do we shift everything back to the start. - -commit 3794e551c7db9aa81405f65f7b04a9951c4120b2 -Author: Guus Sliepen -Date: Sat May 14 11:52:35 2011 +0200 - - Fix check for event initialization due to the merge. - -commit 03b7118139f57033659730afb740bf5cef7c961c -Author: Guus Sliepen -Date: Fri May 13 12:37:26 2011 +0200 - - Reorder checks for libraries to allow ./configure LDFLAGS=-static. - - OpenSSL depends on libdl and libz. When linking dynamically, libcrypto will - automatically link with the other two libraries. However, when linking - statically, these libraries need to be specified explicitly while linking. By - moving the autoconf checks for libdl and libz before those for libcrypto, we - ensure the latter test will be done with the proper libraries. - -commit ce8775000ab38229a78ecf3dc26bab008ca0f332 -Merge: 3f59a26d 5686ad80 -Author: Guus Sliepen -Date: Mon May 9 21:35:14 2011 +0200 - - Merge branch 'master' of git://tinc-vpn.org/tinc into 1.1 - - Conflicts: - NEWS - README - configure.in - doc/tincd.8.in - lib/pidfile.c - src/bsd/device.c - src/dropin.h - src/net.c - src/net_packet.c - src/node.c - src/process.c - src/tincd.c - -commit 5686ad80b545afa3de9ed2f4176a5346e289aaa8 -Author: Guus Sliepen -Date: Sun May 8 23:17:46 2011 +0200 - - Releasing 1.0.14. - -commit 0d906489f2ce9faf81dc230f7db6ab5378573554 -Author: Guus Sliepen -Date: Sun May 8 23:12:44 2011 +0200 - - Include when using intptr_t. - -commit dc887f5011834d5a9a6ec5deb8781c6bfd88c474 -Author: Guus Sliepen -Date: Sun May 8 23:12:06 2011 +0200 - - Ensure proper linking with OpenSSL with recent versions of MinGW. - -commit 67766d65f06854ee894d784f638c5c9cd2b50bca -Author: Guus Sliepen -Date: Sun May 8 21:22:20 2011 +0200 - - Update THANKS and copyright information. - -commit 6e6b037ef4fd9877aeb1d947da7364409fa8cbb7 -Author: Guus Sliepen -Date: Sun May 8 21:06:06 2011 +0200 - - Check for EVP_EncryptInit_ex instead of SHA1_Version in OpenSSL. - - The latter function disappeared, and wasn't actually used in tinc, so now we - check on a function that we do use. - -commit 257cb6ac60bb0924720de9e252cdf7f4759bf741 -Author: Guus Sliepen -Date: Sun May 8 12:40:44 2011 +0200 - - Always use the default signal handler for ABRT signals. - - This will allow coredumps to be generated when tinc is daemonized. - Also add the -kABRT option. - -commit eacb5a28fb4c1515633f2b8a206e7067bc7b8f0c -Author: Guus Sliepen -Date: Sun May 8 12:16:26 2011 +0200 - - Increase threshold for detecting two nodes with the same Name. - - In commit 4a21aabada23d1d2c8a10f54dd7248171c4ec82f, code was added to detect - contradicting ADD_EDGE and DEL_EDGE messages being sent, which is an indication - of two nodes with the same Name connected to the same VPN. However, these - contradictory messages can also happen when there is a network partitioning. In - the former case a loop happens which causes many contradictory message, while - in the latter case only a few of those messages will be sent. So, now we - increase the threshold to at least 10 of both ADD_EDGE and DEL_EDGE messages. - -commit f11c6101f30df645223920bef3eb7592de9bcb79 -Author: Julien Muchembled -Date: Thu Apr 28 13:21:55 2011 +0200 - - Fix command-line '-o' option for host configuration - - This fixes a regression introduced by commit 667b1ba while refactoring option - parsing code. - -commit 0aa86d4b8b3010522e6de8842f5bd29004ba3df6 -Author: Guus Sliepen -Date: Wed Mar 9 09:34:56 2011 +0100 - - Do not set indirect flag on edges from nodes with multiple addresses. - - Since tinc now handles UDP packets with a different source address and port - than used for TCP connections, the heuristic to treat edges as indirect when - tinc could detect that multiple addresses were used does not make sense - anymore, and can actually reduce performance. - -commit 7cf68b5e35c002511cc7468967de6a75934cc998 -Author: Guus Sliepen -Date: Fri Feb 18 23:11:43 2011 +0100 - - Prevent anything from updating our own UDP address. - - Because we don't want to keep track of that, and this will cause the node - structure from being relinked into the node tree, which results in myself - pointing to an invalid address. - -commit cdbbbfabea173894bd2fb5f28135a04ddc5e3fd7 -Author: Guus Sliepen -Date: Fri Feb 18 23:02:11 2011 +0100 - - Fix spurious misidentification of incoming UDP packets. - - When a UDP packet was received with an unknown source address/port, and if it - failed a HMAC check against known keys, it could still incorrectly assign that - UDP address to another node. This would temporarily cause outgoing UDP packets - to go to the wrong destination address, until packets from the correct address - were received again. - -commit 046d83bf91e01bc7a32e66a02758caf228bc4601 -Author: Rumko -Date: Sat Feb 12 18:22:14 2011 +0100 - - DragonFlyBSD support - - * added DragonFly BSD support - * added a check for sys/resource.h (needed on DragonFly) - -commit f017c7f98f8f68d6ca50ebe247f4115aadd93635 -Author: Guus Sliepen -Date: Mon Feb 7 18:34:55 2011 +0100 - - Add support for VDE through libvdeplug. - - When compiled with vde/device.c, tinc will connect to a vde_switch instance - instead of using a tun/tap device. - -commit 8d18cc6c4e625625a2437d26c587f9f382a0c589 -Author: Guus Sliepen -Date: Sat Jan 29 10:49:44 2011 +0100 - - Fix typo spotted by Andrew Scheller. - -commit b3731c04097e66a6b8908bb893c5da831d89c04d -Author: Guus Sliepen -Date: Wed Jan 12 20:57:14 2011 +0100 - - Proper check and dropin replacement for usleep(). - -commit 4b8a5993036fccc2108fcc2550649d9b78fb1ab7 -Author: Guus Sliepen -Date: Sun Jan 2 17:25:24 2011 +0100 - - Update the NEWS. - -commit c228da54d47657811dfb679e7f138cbba58a9f67 -Author: Guus Sliepen -Date: Sun Jan 2 17:25:03 2011 +0100 - - Update the manual. - -commit 4575c6c7dffe228ce302776022a2075b7ef37ab0 -Author: Guus Sliepen -Date: Sun Jan 2 17:24:23 2011 +0100 - - Document the behavior of "-n." - -commit 6c05bf082b1ce9acfc0ebb5c6f32c2ece41c7f80 -Author: Guus Sliepen -Date: Sun Jan 2 16:59:42 2011 +0100 - - Remove unused variables. - -commit 6a51d89cf706bcefce1861a1a66d40ef7d7db43b -Author: Guus Sliepen -Date: Sun Jan 2 16:55:42 2011 +0100 - - Replace bogus #else with #endif. - - Found by cppcheck, which complained about lenin not being initialized, but the - real problem is that reading packets would fail when using code compiled with - --tunemu on a normal tun device. - -commit d7636352ce359e807b392a6e5ac0a6aeff4a63d2 -Author: Guus Sliepen -Date: Sun Jan 2 16:52:36 2011 +0100 - - Limit field width when scanning PID file. - - Cppcheck warns that scanf() might otherwise crash when presented with a huge, - bogus PID file. - -commit 3ce5e292da8bab3a1316faf1ca18625f05074467 -Author: Guus Sliepen -Date: Sun Jan 2 16:50:24 2011 +0100 - - Close all filedescriptors in Solaris close_device(). - -commit f99661a4ca5bacff47239ce7978b9c9948917c54 -Author: Guus Sliepen -Date: Sun Jan 2 15:02:23 2011 +0100 - - Always send MTU probes at least once every PingInterval. - - Before, if MTU probes failed, tinc would stop sending probes until the next - time keys were regenerated (by default, once every hour). Now it continues to - send them every PingInterval, so it recovers faster from temporary failures. - -commit cac0a5c651535e8317839b0deff1ee98086a8184 -Author: Guus Sliepen -Date: Sat Nov 20 14:31:11 2010 +0000 - - Use setpriority() instead of nice() on UNIX-like systems. - - The return value of nice() can not reliably indicate errors. The return value - of the setpriority() call is well-defined. - -commit 3f59a26d8098b8b0902b8746715508360b347f47 -Author: Guus Sliepen -Date: Fri Nov 19 12:26:20 2010 +0000 - - Do not try to dereference myself->connection->config_tree. - - This was a bug introduced due to an incomplete merge (commit - ff71f289022ccb91abc2726f16522d55b5ccf0f6). - -commit 886a6f61a1f4cc48a77b42d10f34f9126377d904 -Merge: 23dddc25 d91903ef -Author: Guus Sliepen -Date: Fri Nov 19 12:22:48 2010 +0000 - - Merge branch 'master' into 1.1 - - Conflicts: - src/net_packet.c - src/openssl/rsagen.h - src/protocol_auth.c - src/protocol_key.c - -commit d91903ef3c2a1f4481ae8757bb2b14282f2b7e68 -Author: Guus Sliepen -Date: Tue Nov 16 17:28:41 2010 +0100 - - Attribution for Brandon Black. - -commit e764ff7be9949c91865aff72844357e76ae6dd78 -Author: Guus Sliepen -Date: Tue Nov 16 16:45:36 2010 +0100 - - Fix variable length array declaration. - -commit 5eb0440110f99f0a49838cc00a0686c7a7595663 -Author: Guus Sliepen -Date: Sat Nov 13 21:36:51 2010 +0100 - - Free replay window when freeing a node_t. - -commit a9445e38f25bd24eca289768fc46e44e36b842ac -Author: Guus Sliepen -Date: Sat Nov 13 21:34:59 2010 +0100 - - Fix warning message when setting SO_RCVBUF or SO_SNDBUF fails. - -commit 0d61d4ae1358553fc8dde350747542f137f5cb8b -Author: Brandon L Black -Date: Sat Nov 13 12:05:51 2010 -0600 - - Improved handling of queue-jumping packets on receive - -commit 23acc19bc090051156ad895caed61848f5afb144 -Author: Brandon L Black -Date: Sat Nov 13 12:05:50 2010 -0600 - - Configurable ReplayWindow size, zero disables - -commit 8dfe1b374e165ecba5d3ae324ee834d337476be8 -Author: Brandon L Black -Date: Sat Nov 13 12:05:49 2010 -0600 - - Configurable SO_RCVBUF/SO_SNDBUF for the UDP socket - -commit 3f410e2f8f7c365630f226adf4904935698f9e0d -Author: Brandon L Black -Date: Sat Nov 13 12:05:48 2010 -0600 - - Experimental IFF_ONE_QUEUE support for Linux - -commit 9e3ca397735077f85bbde48c36e1b3e0fa950988 -Author: Guus Sliepen -Date: Sat Nov 13 15:55:38 2010 +0100 - - Use variable length arrays instead of alloca(). - -commit e2e6ec8050274b0a8678d6fc263e7dc4ef66feae -Author: Guus Sliepen -Date: Sat Nov 13 15:50:39 2010 +0100 - - Provide usleep() for Windows. - -commit 23dddc25930bc9033e5a2ac659376032aff44d82 -Author: Guus Sliepen -Date: Sat Nov 13 15:46:19 2010 +0100 - - Link tincctl with dropin.o. - -commit a22041922f160667573e9a5ae3f4195e1668906a -Merge: 8b70c5be 930bf74f -Author: Guus Sliepen -Date: Fri Nov 12 16:15:29 2010 +0100 - - Merge branch 'master' into 1.1 - - Conflicts: - doc/tincd.8.in - lib/pidfile.c - src/graph.c - src/net.c - src/net.h - src/net_packet.c - src/net_setup.c - src/net_socket.c - src/netutl.c - src/node.c - src/node.h - src/protocol_auth.c - src/protocol_key.c - src/tincd.c - -commit 930bf74fbe5ce8363b6cc2ae3a3e960e910e0996 -Author: Guus Sliepen -Date: Fri Nov 12 11:38:05 2010 +0100 - - Don't use strlen() on a NULL pointer. - - A bug introduced in commit 667b1bac77b134cf32c98d5dc25619e8c3303f52 caused tinc - to crash on startup. - -commit a07aa92176571eb7f063708640d0d486280808ef -Author: Guus Sliepen -Date: Fri Nov 12 11:33:01 2010 +0100 - - Add short options -R and -U to the tincd(8) manpage. - -commit 66b7aea294896a99df289231143a506b422b994c -Author: Guus Sliepen -Date: Tue Nov 2 14:23:43 2010 +0100 - - Read error counter must be static. - -commit a91bf2dfcd0f5857905e59da7d944654e0875503 -Author: Guus Sliepen -Date: Tue Nov 2 14:18:35 2010 +0100 - - Quit when there are too many consecutive errors on the tun/tap device. - - Although transient errors sometimes happen on the tun/tap device (for example, - if the kernel is temporarily out of buffer space), there are situations where - the tun/tap device becomes permanently broken. Instead of endlessly spamming - the syslog, we now sleep an increasing amount of time between consecutive read - errors, and if reads still fail after 10 attempts (approximately 3 seconds), - tinc will quit. - -commit aca70cd3c3fe787e62c618849e43f67b3870ac20 -Author: Michael Tokarev -Date: Sun Oct 24 15:23:10 2010 +0400 - - Treat netname="." in a special way. - - Treat netname "." in a special way as if there was no netname - specified. Before, f.e. tincd -n. -k didn't work as it tried - to open /var/run/tinc-.pid. Now -n. works as if there was no - -n option is specified. - - Signed-Off-By: Michael Tokarev - -commit 5f729f76f5a63114df582fc29f4189140c1e5ead -Author: Guus Sliepen -Date: Fri Oct 22 22:46:44 2010 +0200 - - Remove unused variables. - - These were caused by commit 667b1bac77b134cf32c98d5dc25619e8c3303f52. - -commit 20ae7dd8c12390f7360eb28cc17e1b8a8a706b06 -Author: Guus Sliepen -Date: Fri Oct 22 22:43:50 2010 +0200 - - Abort disabling old PEM keys on I/O errors. - -commit a08462bf845973016e061b8ca1233142d80416f6 -Author: Guus Sliepen -Date: Fri Oct 22 22:42:21 2010 +0200 - - Ensure there is a newline character before a PEM key is written. - -commit c6ccbadfcf93a7bd4a88dee8ff146b4db7f85e71 -Author: Guus Sliepen -Date: Fri Oct 22 13:40:04 2010 +0200 - - Attribution for Timothy Redaelli. - -commit 1c2cd7ed273ee1538ff8a13d036c68aa9992c4aa -Author: Guus Sliepen -Date: Fri Oct 22 13:17:42 2010 +0200 - - Attribution for Julien Muchembled. - -commit 667b1bac77b134cf32c98d5dc25619e8c3303f52 -Author: Guus Sliepen -Date: Fri Oct 22 13:06:06 2010 +0200 - - Remove duplicate command-line option parsing. - - Also fix parsing of command-line host configuration options for the local node. - -commit ff71f289022ccb91abc2726f16522d55b5ccf0f6 -Author: Guus Sliepen -Date: Fri Oct 22 12:47:12 2010 +0200 - - Merge local host configuration with server configuration. - - With some exceptions, tinc only accepted host configuration options for the - local node from the corresponding host configuration file. Although this is - documented, many people expect that they can also put those options in - tinc.conf. Tinc now internally merges the contents of both tinc.conf and the - local host configuration file. - -commit 8c3105283ac53f8cc9cc4dde25957ec1cf6b53a0 -Author: Julien Muchembled -Date: Fri Sep 3 13:34:22 2010 +0200 - - New '-o' option to configure server or hosts from command line - - Options given on the command line have precedence over configuration from files. - - This can be useful, for example, for a roaming node, for which 'ConnectTo' and - .Address depends on its location. - -commit 4b6a9f1c1f645ce5989692655337d9e23ca28648 -Author: Guus Sliepen -Date: Fri Jun 4 16:03:19 2010 +0200 - - Do not append an address to ANS_KEY messages if we don't know any address. - - This would let tinc raise an exception when an ANS_KEY request crossed a - DEL_EDGE request for the node sending the key. - -commit 798fa2f04c52b0639713f74b1195847bec40c16a -Author: Guus Sliepen -Date: Fri Jun 4 15:04:08 2010 +0200 - - Use 64 bit counters to keep track of bytes sent/received from the virtual network interface. - -commit 4a21aabada23d1d2c8a10f54dd7248171c4ec82f -Author: Guus Sliepen -Date: Fri Jun 4 14:53:52 2010 +0200 - - Detect and prevent two nodes with the same Name being on the VPN simultaneously. - - In this situation, the two nodes will start fighting over the edges they announced. - When we have to contradict both ADD_EDGE and DEL_EDGE messages, we log a warning, - and with 25% chance per PingTimeout we quit. - -commit dbf3d168b720045328d476f3b9e5f5e45b4ab6de -Author: Guus Sliepen -Date: Fri May 7 12:24:49 2010 +0200 - - Use strrchr() insteaad of rindex(). - - The latter function is deprecated, some build environments do not support. - -commit eda71798749e8b0abf5e8b3cbc11da82aa607f00 -Author: Timothy Redaelli -Date: Tue May 4 15:43:48 2010 +0200 - - Fix warnings under BSD - -commit df985256a766ee90f2fa4269b95fa0565c969dda -Author: Timothy Redaelli -Date: Tue May 4 00:27:44 2010 +0200 - - Fix warnings showed using -D_FORTIFY_SOURCE=2 - -commit f5122ccecee095b9185b2324dea7bcd9655462ee -Author: Guus Sliepen -Date: Sat May 1 15:39:59 2010 +0200 - - Fix all warnings when compiling with mingw64. - -commit ef92a5725c47c6e8e801e07190dd7dd3f9cb3a17 -Author: Guus Sliepen -Date: Sat May 1 15:39:03 2010 +0200 - - OpenSSL 1.0.0 compiled for 64 bit Windows requires linking with -lcrypt32. - -commit 0fdd7da52077d77a11a3646eb3e7d5b6ffa178e8 -Author: Guus Sliepen -Date: Sat May 1 15:38:04 2010 +0200 - - Use intptr_t instead of long to store a pointer. - -commit c94ede3b8708cdf105a3fecfc119a558e1583f27 -Author: Guus Sliepen -Date: Sat May 1 15:37:11 2010 +0200 - - Define WINVER before including any other header file on Windows. - -commit 8b70c5be9bc762d81354f9cd77c3748a44a4956d -Author: Guus Sliepen -Date: Fri Apr 30 23:18:22 2010 +0200 - - Remove obsolete lib/ directory. - -commit ee427cac0d04c60d09cc235c04664eab8b0c6527 -Author: Guus Sliepen -Date: Fri Apr 30 23:13:02 2010 +0200 - - Do not try to free NULL pointers. - -commit 113458c2864ec8c046ab7d63ff1b417252c8e4df -Author: Guus Sliepen -Date: Fri Apr 30 23:11:48 2010 +0200 - - Use correct digest length when checking a received key. - -commit 76b41ba20dc9783ff0d21dd738739a81d62142e7 -Author: Guus Sliepen -Date: Sat Apr 17 12:33:36 2010 +0200 - - Add missing return statement. - -commit 2911af6e23d0dba6d771fcd590551a84bd9dc932 -Author: Guus Sliepen -Date: Sat Apr 17 12:33:15 2010 +0200 - - Fix merge of commit 4a0b9981513059755b9fd15b38fc198f46a0d6f2. - -commit 79e46d08a46f2fef2ee4e8eac7ba487007160564 -Merge: 4ce4af4c 4766359e -Author: Guus Sliepen -Date: Sat Apr 17 12:21:53 2010 +0200 - - Merge branch 'master' into 1.1 - - Conflicts: - NEWS - README - configure.in - src/net.c - src/net.h - -commit 4ce4af4c712c80d08630767ec34787253da1021b -Author: Guus Sliepen -Date: Sat Apr 17 12:03:08 2010 +0200 - - Fix experimental GUI when reading hexadecimal values. - -commit 4766359e1426bdf1383c898d6103d8760e5e296d -Author: Guus Sliepen -Date: Sat Apr 17 12:01:38 2010 +0200 - - Fix reading configuration files that do not end with a newline. Again. - -commit 26b8cf8680ae68443dccac2adbc2361caafc3712 -Author: Guus Sliepen -Date: Sun Apr 11 20:40:20 2010 +0200 - - Releasing 1.0.13. - -commit 74653beb5bc510e60579058ee15c0f66350f5137 -Author: Guus Sliepen -Date: Sun Apr 11 19:47:44 2010 +0200 - - Mark Forwarding and DirectOnly options as being experimental. - -commit 0ddce6370d39eff162bd212a6e47fe3a8e96a09e -Author: Guus Sliepen -Date: Sun Apr 11 19:39:31 2010 +0200 - - Don't redefine MAX if it already exists. - -commit a9bbb3357a89e27185312fbce0ee134eda4eda90 -Author: Guus Sliepen -Date: Sun Apr 11 19:20:02 2010 +0200 - - Fixes for definitions under Windows. - -commit 4708f2c89edea4be2562256544cf35309cf1ea89 -Author: Guus Sliepen -Date: Sun Apr 11 18:34:50 2010 +0200 - - Ensure subnet-up/down scripts are called after HUP when necessary. - -commit 32f5524c4b52a2d3a96bc48ee2437f8b9b4dbe10 -Author: Guus Sliepen -Date: Sun Apr 11 04:35:16 2010 +0200 - - Fix reloading Subnets when StrictSubnets is set. - -commit 9f53ab209d8a6a7622a49ed03cef735b6e3f3eeb -Author: Guus Sliepen -Date: Sun Apr 11 00:50:42 2010 +0200 - - Reload Subnets when getting a HUP signal and StrictSubnets is used. - -commit d1cc637470edaed663e694fdeb290eb45cc9ecca -Author: Guus Sliepen -Date: Sat Apr 10 23:55:15 2010 +0200 - - Ensure ICMP_NET_ANO is defined. - -commit f75e71bc693847af71f61fb72cd788e3e47f9bd3 -Author: Guus Sliepen -Date: Sat Apr 3 09:46:45 2010 +0100 - - Convert Port to numeric form before sending it to other nodes. - - If one uses a symbolic name for the Port option, tinc will send that name - literally to other nodes. However, it is not guaranteed that all nodes have - the same contents in /etc/services, or have such a file at all. - -commit e49891e188f618a0e98f1d30bcbf240286e8ad5c -Author: Sven-Haegar Koch -Date: Wed Mar 31 03:56:53 2010 +0200 - - Fixed metadata protokoll corruption on forwarded requests - - When forwarding a metadata request through forward_request() we were - adding the required newline char to our buffer, but then sending the - data without it - this results in the forwarded request and the next one - to be garbled together. - - Additionally while at it add a warning comment that request string is - not zero terminated anymore after a call to the forward_request() - function - for now this is ok as it is not used by any caller after this. - -commit 0310deb225cad21c458fb32fd589027e3f844735 -Author: Sven-Haegar Koch -Date: Fri Mar 26 17:25:18 2010 +0100 - - Demote all LOG_EMERG to LOG_ERR, spamming all xterms is bad. - -commit d5654f568dcaf81341395b52b2711f68c0417ec6 -Author: Sven-Haegar Koch -Date: Fri Mar 26 16:54:13 2010 +0100 - - README.git: tinc 1.1 needs libevent - -commit 685509ffe10d1bf9c409e5ba90f46cd747f2d9cd -Author: Sven-Haegar Koch -Date: Sun Mar 28 17:51:26 2010 +0200 - - Function flush_meta() does not exist anymore. - -commit c6d2b9d734859ccbd9582b28351983a12b04abb0 -Author: Sven-Haegar Koch -Date: Fri Mar 26 17:07:30 2010 +0100 - - Add missing AC_CHECK_HEADERS([dirent.h]) to configure.in - -commit ffa1dc73dcd62a856325641972a13d398aa8121c -Author: Sven-Haegar Koch -Date: Fri Mar 26 17:18:04 2010 +0100 - - Fixed 1.0 miss-merges - -commit 103543aa2c15d9f1e2aa313a2e593a7524cce484 -Merge: 35b1c250 29235491 -Author: Sven-Haegar Koch -Date: Fri Mar 26 16:51:03 2010 +0100 - - Merge branch 'master' into 1.1 - - Conflicts: - NEWS - README - configure.in - have.h - src/conf.c - src/conf.h - src/net.c - src/net_packet.c - src/protocol_key.c - src/protocol_subnet.c - src/route.c - src/tincd.c - -commit 292354912f346fe467f557f0dc026b519997289c -Author: Sven-Haegar Koch -Date: Wed Mar 10 02:50:51 2010 +0100 - - Never delete Subnets when StrictSubnets is set - - If a node is unreachable, and not connected to an edge anymore, it gets - deleted. When this happens its subnets are also removed, which should - not happen with StrictSubnets=yes. - - Solution: - - do not remove subnets in src/net.c::purge(), we know that all subnets - in the list came from our hosts files. - I think here you got the check wrong by looking at the tunnelserver - code below it - with strictsubnets we still inform others but do not - remove the subnet from our data. - - do not remove nodes in net.c::purge() that still have subnets - attached. - -commit 146760bd35b351d58e817ce0e67f5c6f74750cd4 -Author: Guus Sliepen -Date: Wed Mar 10 16:07:01 2010 +0100 - - Fix typo. - -commit f2346771cf5b22092dd3f5af3674008aa1e878d1 -Author: Guus Sliepen -Date: Mon Mar 8 21:44:32 2010 +0100 - - Log unauthorized Subnets when StrictSubnets is set. - -commit ee64b8ef33b709fabfc1ed56762d5f52fc026e52 -Author: Guus Sliepen -Date: Mon Mar 8 17:54:57 2010 +0100 - - ConnectTo does not mean tinc does not listen for incoming connections anymore. - -commit 8ae54dc7c782bcc4b771ec0766fcf9eee115756e -Author: Guus Sliepen -Date: Tue Mar 2 23:27:50 2010 +0100 - - Fixes for the Forwarding option. - -commit 3e4829e78a3c7f7e19017d05611e5b69d5268119 -Author: Guus Sliepen -Date: Tue Mar 2 22:55:24 2010 +0100 - - Add the DirectOnly option. - - When this option is enabled, packets that cannot be sent directly to the destination node, - but which would have to be forwarded by an intermediate node, are dropped instead. - When combined with the IndirectData option, - packets for nodes for which we do not have a meta connection with are also dropped. - -commit 95a6974de173e0cb78611c6704ed09631d510dae -Author: Guus Sliepen -Date: Tue Mar 2 22:34:26 2010 +0100 - - Add the Forwarding option. - - This determines if and how incoming packets that are not meant for the local - node are forwarded. It can either be off, internal (tinc forwards them itself, - as in previous versions), or kernel (packets are always sent to the TUN/TAP - device, letting the kernel sort them out). - -commit 5038964032ef55913b2d4741c67bf191b2208abb -Author: Guus Sliepen -Date: Tue Mar 2 00:18:44 2010 +0100 - - Add the StrictSubnets option. - - When this option is enabled, tinc will not accept dynamic updates of Subnets - from other nodes, but will only use Subnets read from local host config files - to build its routing table. - -commit 9fed0ec34b9208611a7e96a595f23fa04e60a5c0 -Author: Guus Sliepen -Date: Mon Mar 1 23:44:56 2010 +0100 - - Preload all Subnets in TunnelServer mode. - - This simplifies the logic in protocol_subnet.c. - -commit d47ab576a25d91600acf7eecf376ed026bdc9c83 -Author: Guus Sliepen -Date: Mon Mar 1 23:44:46 2010 +0100 - - Check for dirent.h. - -commit 21f33b638291c2ffe7156e6c1e0df339f855d831 -Author: Guus Sliepen -Date: Mon Mar 1 23:35:02 2010 +0100 - - Simplify reading lines from configuration files. - - Instead of allocating storage for each line read, we now read into fixed-size - buffers on the stack. This fixes a case where a malformed configuration file - could crash tinc. - -commit 3cb91d75f874e3398c35cd4280c1e0a1ceeedabc -Author: Guus Sliepen -Date: Sun Feb 28 18:20:13 2010 +0100 - - Clamp MSS to miminum MTU in both directions. - - Clamp MSS of both incoming and outgoing packets, and use the minimum of the - PMTU of both directions when clamping. - -commit ddb8cb0779ed36d17ce186dd0bf67e9f0c860d28 -Author: Timothy Redaelli -Date: Wed Feb 10 14:52:15 2010 +0100 - - Add --disable-zlib configure option - -commit eeb505af36ba9496ad29b32cd0917afb8c6cd355 -Author: Timothy Redaelli -Date: Wed Feb 10 13:24:33 2010 +0100 - - Add --disable-lzo configure option - -commit f7b2a2ea43fca323f543e152e6a43a29a4eb6671 -Author: Guus Sliepen -Date: Wed Feb 3 22:49:48 2010 +0100 - - Releasing 1.0.12. - -commit cd0c2e86a403fc9aabecdc8d51413f94491b5494 -Author: Guus Sliepen -Date: Wed Feb 3 11:18:46 2010 +0100 - - Ensure peers with a meta connection always have our key. - - This keeps UDP probes going, which in turn keeps NAT mappings alive. - -commit 40d91ff619a6ea24a2a35c9d934bcc6bace27e24 -Author: Guus Sliepen -Date: Tue Feb 2 22:49:21 2010 +0100 - - Update copyright notices. - -commit 44f8f61396a92c899172a1863bbc9c705cbfa649 -Author: Guus Sliepen -Date: Tue Feb 2 22:22:27 2010 +0100 - - Try to set DF bit on BSDs as well. - - Every operating system seems to have its own, slightly different way to disable - packet fragmentation. Emit a compiler warning when no suitable way is found. - On OpenBSD, it seems impossible to do it for IPv4. - -commit ed14ef93b47622ba13099dfc6be5335222e987a6 -Author: Guus Sliepen -Date: Tue Feb 2 01:02:40 2010 +0100 - - Immediately exchange keys when establishing a meta connection. - - This in turn will trigger PMTU discovery, and ensures nodes know each others - reflexive UDP address and port. - -commit 4a0b9981513059755b9fd15b38fc198f46a0d6f2 -Author: Guus Sliepen -Date: Tue Feb 2 00:51:44 2010 +0100 - - Determine peer's reflexive address and port when exchanging keys. - - To help peers that are behind NAT connect to each other directly via UDP, they - need to know the exact external address and port that they use. Keys exchanged - between NATted peers necessarily go via a third node, which knows this address - and port, and can append this information to the keys, which is in turned used - by the peers. - - Since PMTU discovery will immediately trigger UDP communication from both sides - to each other, this should allow direct communication between peers behind - full, address-restricted and port-restricted cone NAT. - -commit d15099e0029578bfd24d6b464b941f4693280001 -Author: Guus Sliepen -Date: Sat Jan 23 18:48:01 2010 +0100 - - Be liberal in accepting KEY_CHANGED/REQ_KEY/ANS_KEY requests. - - When we got a key request for or from a node we don't know, we disconnected the - node that forwarded us that request. However, especially in TunnelServer mode, - disconnecting does not help. We now ignore such requests, but since there is no - way of telling the original sender that the request was dropped, we now retry - sending REQ_KEY requests when we don't get an ANS_KEY back. - -commit 469fa318bc817908af9a51e3a980ffc998fae6f2 -Author: Guus Sliepen -Date: Fri Jan 22 21:59:40 2010 +0100 - - Run subnet-up/down scripts for local MAC addresses as well. - -commit 5d194b9f8767390d9fb1170554a8b6928214957a -Author: Guus Sliepen -Date: Fri Jan 22 21:47:26 2010 +0100 - - Fix subnet-up/down scripts being called with an empty SUBNET. - - Commit 052ff8b2c598358d1c5febaa9f9f5fc5d384cfd3 contained a bug that causes - scripts to be called with an empty, or possibly corrupted SUBNET variable when - a Subnet is added or removed while the owner is still online. In router mode, - this normally does not happen, but in switch mode this is normal. - -commit b45511118421920771f5dcd5e4bafc04376e4450 -Author: Guus Sliepen -Date: Sat Jan 16 20:16:33 2010 +0100 - - Make MSS clamping configurable, but enabled by default. - - It can either be set globally in tinc.conf, or per-node in host config files. - -commit 95928f7c2910a7da01a89cdc63c86c4d87fac004 -Author: Guus Sliepen -Date: Sat Jan 16 19:32:33 2010 +0100 - - Also clamp MSS of TCP over IPv6 packets. - -commit b1945f70fe993ca447555a1e27f35638b0c1fd8b -Author: Guus Sliepen -Date: Fri Jan 15 23:41:14 2010 +0100 - - Optimise handling of select() returning <= 0. - - Before, we immediately retried select() if it returned -1 and errno is EAGAIN - or EINTR, and if it returned 0 it would check for network events even if we - know there are none. Now, if -1 or 0 is returned we skip checking network - events, but we do check for timer and signal events. - -commit 51099658c919794cde72ea1107b9d9b9c3cee926 -Author: Guus Sliepen -Date: Fri Jan 15 23:19:08 2010 +0100 - - Ping nodes immediately when receiving SIGALRM. - - One reason to send the ALRM signal is to let tinc immediately try to connect to - outgoing nodes, for example when PPP or DHCP configuration of the outgoing - interface finished. Conversely, when the outgoing interface goes down one can - now send this signal to let tinc quickly detect that links are down too. - -commit 2a538ed34332b3392f866d56accd9efecc9467ed -Author: Guus Sliepen -Date: Fri Jan 15 13:42:37 2010 +0100 - - Clamp MSS of IPv4 SYN packets. - - Some ISPs block the ICMP Fragmentation Needed packets that tinc sends. We - clamp the MSS of IPv4 SYN packets to prevent hosts behind those ISPs from - sending too large packets. - -commit 35b1c25093a478d20e01f0ff391c9cdc9c41c2b8 -Author: Guus Sliepen -Date: Thu Dec 31 13:19:13 2009 +0100 - - Move source from lib/ to src/. - - The utility functions in the lib/ directory do not really form a library. - Also, now that we build two binaries, tincctl does not need everything that was - in libvpn.a, so it is wasteful to link to it. - -commit 41497246eeccbcc417f93c2ae087e927751c6914 -Author: Guus Sliepen -Date: Thu Dec 31 13:09:14 2009 +0100 - - Remove unused AVL tree library. - -commit e4812ba9cc4262ec921944f02639ce55781d7497 -Author: Guus Sliepen -Date: Thu Dec 24 12:42:21 2009 +0100 - - Allow Port and PMTUDiscovery options in tinc.conf, always enable PMTUDiscovery by default. - -commit 7203d5fb07be2d3ae006c2b65d0be1e6533e1273 -Author: Guus Sliepen -Date: Wed Dec 23 19:51:55 2009 +0100 - - Use xstrdup() instead of xasprintf() to copy static strings. - -commit a9a803d5662832eb397837055a49fd94118eabf3 -Author: Guus Sliepen -Date: Wed Dec 23 19:49:38 2009 +0100 - - Allow port to be specified in Address statements. - - This allows one to connect to use more than one port number to connect to - another node. The syntax is now: - - Address = [] - -commit 43e34d8180c90682ed1601dec3de7f68ec96d65b -Author: Guus Sliepen -Date: Wed Dec 23 19:22:06 2009 +0100 - - Do not fragment packets smaller than RFC defined minimum MTUs. - - For IPv6, the minimum MTU is 1280 (RFC 2460), for IPv4 the minimum is actually - 68, but this is such a low limit that it will probably hurt performance, so we - do as if it is 576 (the minimum packet size hosts should be able to handle, RFC - 791). If we detect a path MTU smaller than those minima, and we have to handle - a packet that is bigger than the PMTU but smaller than those minima, we forward - them via TCP instead of fragmenting or returning ICMP packets. - -commit 36261650024ba8e18f9c77396f1d7a4e51f20602 -Author: Guus Sliepen -Date: Sat Dec 19 23:23:25 2009 +0100 - - Do not use hardcoded cipher block length when padding. - -commit f542ef8f9e645bf30e11e196dd768fac4f957eac -Author: Guus Sliepen -Date: Sat Dec 19 22:17:39 2009 +0100 - - Fix alignment of results of RSA operations when using libgcrypt. - - If the result of an RSA encryption or decryption operation can be represented - in less bytes than given, gcry_mpi_print() will not add leading zero bytes. Fix - this by adding those ourself. - -commit 4c68a8cb60eb0a4c05d9ce98963b930a976b55ee -Author: Guus Sliepen -Date: Sat Dec 19 20:53:48 2009 +0100 - - Do not consider unreachable nodes when trying to determine packet origin. - -commit 74e50d52e0e23c9dd1e21fb447f1e1a59d02d0b2 -Author: Guus Sliepen -Date: Sat Dec 19 20:52:19 2009 +0100 - - recv() and recvfrom() return int, do not prematurely cast the return value. - -commit 0bfd69a2736cb98470b47c1f6cba617b58bb86ef -Author: Guus Sliepen -Date: Sat Dec 19 20:26:30 2009 +0100 - - Fix reading raw RSA keys with libgcrypt. - -commit 0ff44fc2417217d542bf0e9a7ecfd20020893bc7 -Author: Guus Sliepen -Date: Sat Dec 19 20:10:38 2009 +0100 - - Reinitialise block cipher IV each time we encrypt a packet when using libgcrypt. - -commit 3c90be7678566203d38624c4a6fe3affaffbe5e3 -Author: Guus Sliepen -Date: Sat Dec 19 18:57:54 2009 +0100 - - Fix block cipher padding when using libgcrypt. - -commit c845bc109c85e6fb350096c63e13ef8e617ee29b -Author: Guus Sliepen -Date: Fri Dec 18 01:15:25 2009 +0100 - - Fix packet authentication. - - This wasn't working at all, since we didn't do HMAC but just a plain hash. - Also, verification of packets failed because it was checking the whole packet, - not the packet minus the HMAC. - -commit 10d609b1f0dd9eeb024cd40359683d48542aecbf -Author: Guus Sliepen -Date: Wed Dec 16 21:18:21 2009 +0100 - - Start of a GUI for tinc. - -commit 55ef2f806f9840103bceb472564a711b22e73d58 -Author: Guus Sliepen -Date: Wed Dec 16 21:16:56 2009 +0100 - - Allow connections to be closed. - - This only closes existing meta connections, it may not affect node - reachability. - -commit f12c36afd5293ddbecccf13f36edb8d36e56f040 -Author: Guus Sliepen -Date: Mon Dec 14 21:25:06 2009 +0100 - - Include missing header files and source directories. - -commit 2a410cd26d25cc01b96d255644df3ad138eae776 -Author: Guus Sliepen -Date: Mon Dec 14 21:20:56 2009 +0100 - - Do not include OpenSSL headers directly. - -commit 5d78e497f1c352c8d490eed1d44d128523a34572 -Author: Guus Sliepen -Date: Fri Dec 11 22:38:06 2009 +0100 - - Fix compiler warnings. - -commit d6c50eb73ad49bd2eac67214995dff76b7a20661 -Merge: fec14791 369fe1ab -Author: Guus Sliepen -Date: Fri Dec 11 22:31:27 2009 +0100 - - Merge branch 'master' into 1.1 - - Conflicts: - src/subnet.c - -commit fec14791e869180bb7994ca38ca7006cc2e957fb -Author: Guus Sliepen -Date: Fri Dec 11 22:24:07 2009 +0100 - - Only call ioctlsocket() on Windows. - -commit 369fe1ab1cbfc3f8305de1faab2e30157378b044 -Author: Guus Sliepen -Date: Tue Dec 8 22:18:37 2009 +0000 - - Forget addresses of unreachable nodes. - - We clear the cached address used for UDP connections when a node becomes - unreachable. This also prevents host-up scripts from passing the old, cached - address from when the host becomes reachable again from a different address. - -commit 62f235e05c54e458724f437e519ed1b3e17835b1 -Author: Guus Sliepen -Date: Sat Nov 28 11:56:13 2009 +0000 - - Remove unused variable in lookup_subnet_*() functions. - -commit 92aefd25bf9e8e63f199cc252218f5c427f836b7 -Author: Guus Sliepen -Date: Sat Nov 28 11:52:23 2009 +0000 - - When learning MAC addresses, only check our own Subnets for previous entries. - - Before it would check all addresses, and not learn an address if another node - already claimed that address. This caused fast roaming to fail, the code from - commit 6f6f426b353596edca77829c0477268fc2fc1925 was never triggered. - -commit edebf579f2ea29e6e84360cb13731f5858a1555b -Author: Guus Sliepen -Date: Sat Nov 7 23:43:25 2009 +0100 - - Use the TCP socket infrastructure for control sockets. - - The control socket code was completely different from how meta connections are - handled, resulting in lots of extra code to handle requests. Also, not every - operating system has UNIX sockets, so we have to resort to another type of - sockets or pipes for those anyway. To reduce code duplication and make control - sockets work the same on all platforms, we now just connect to the TCP port - where tincd is already listening on. - - To authenticate, the program that wants to control a running tinc daemon must - send the contents of a cookie file. The cookie is a random 256 bits number that - is regenerated every time tincd starts. The cookie file should only be readable - by the same user that can start a tincd. - - Instead of the binary-ish protocol previously used, we now use an ASCII - protocol similar to that of the meta connections, but this can still change. - -commit c388527e341658dc915dd67c90bbc9b52b8539c0 -Author: Guus Sliepen -Date: Sat Nov 7 16:09:56 2009 +0100 - - Small fixes to get really working control sockets on Windows. - -commit 5c5548fc7185cc1462602dadcd39a53cef481d29 -Author: Guus Sliepen -Date: Sat Nov 7 14:35:48 2009 +0100 - - Better integration of libevent in build system. - - Since event.h is not part of tinc, we include it in have.h were all other - system header files are included. We also ensure -levent comes before -lgdi32 - when compiling with MinGW, apparently it doesn't work when the order is - reversed. - -commit 075264a9e18f9fd58cad044c064a91557e9ed429 -Author: Guus Sliepen -Date: Thu Nov 5 23:29:28 2009 +0100 - - Make sure the 1.1 branch compiles in a MinGW environment. - - UNIX domain sockets, of course, don't exist on Windows. For now, when compiling - tinc in a MinGW environment, try to use a TCP socket bound to localhost as an - alternative. - -commit 08615e420b2dd5054dd978bf53c88b8dde6e4788 -Author: Guus Sliepen -Date: Thu Nov 5 00:02:42 2009 +0100 - - Handle PKCS#5 padding in the gcrypt backend. - -commit d9b2ac6767f85927a26e2b95bba69c052ac503ac -Author: Guus Sliepen -Date: Thu Nov 5 00:01:25 2009 +0100 - - Handle truncated message authentication codes with gcrypt. - - Commit 4124b9682f8f890acb25d0c92f2583eef670274a did not update the gcrypt - backend. - -commit c4afc481541bff4db7f57c81796b7a5f61cdb1b5 -Author: Guus Sliepen -Date: Wed Nov 4 16:19:08 2009 +0100 - - Use %x instead of %lx where appropriate. - - Some conversions were not properly merged from the master branch. - -commit 37ccb325af5c7865eb16716780121a8a6dce8abd -Author: Guus Sliepen -Date: Wed Nov 4 16:18:08 2009 +0100 - - Don't enable device events when there is no valid filedescriptor. - -commit 108b238915c5f58b3d94ab433dc5d04e064c2b11 -Merge: 761517c2 44834d03 -Author: Guus Sliepen -Date: Mon Nov 2 14:24:27 2009 +0100 - - Merge branch 'master' into 1.1 - - Conflicts: - NEWS - README - configure.in - doc/tinc.texi - doc/tincd.8.in - src/Makefile.am - src/connection.c - src/edge.c - src/meta.c - src/net.c - src/net.h - src/net_packet.c - src/net_setup.c - src/net_socket.c - src/node.c - src/openssl/rsagen.h - src/protocol_auth.c - src/protocol_edge.c - src/subnet.c - -commit 44834d030464bbe1f7733caba8d96c678f1d6cf2 -Author: Guus Sliepen -Date: Sun Nov 1 16:24:39 2009 +0100 - - Releasing 1.0.11. - -commit d331f04e4598824afc7de33ac1228cf441ae9872 -Author: Guus Sliepen -Date: Sun Nov 1 15:57:28 2009 +0100 - - Start a tinc service if it already exists. - -commit 6f6f426b353596edca77829c0477268fc2fc1925 -Author: Guus Sliepen -Date: Tue Oct 27 23:53:49 2009 +0100 - - Fast handoff of roaming MAC addresses. - - In switch mode, if a known MAC address is claimed by a second node before it - expired at the first node, it is likely that this is because a computer has - roamed from the LAN of the first node to that of the second node. To ensure - packets for that computer are routed to the second node, the first node should - delete its corresponding Subnet as soon as possible, without waiting for the - normal expiry timeout. - -commit e00b44cb98e4d50a0d426048ba01dbd80bcb5941 -Author: Guus Sliepen -Date: Sun Oct 25 01:40:07 2009 +0200 - - Move socket error interpretation to utils.h. - -commit c11dc8079b60d9f8c5b1c7e8fecd90d0fac5a20c -Author: Guus Sliepen -Date: Sun Oct 25 00:50:09 2009 +0200 - - Use WSAGetLastError() to determine cause of network errors on Windows. - - This reduces log spam and lets path MTU discovery work faster. - -commit 1bca167b7e24a9cb00ad6130c24f0bb60e208f1f -Author: Michael Tokarev -Date: Sun Oct 18 21:27:24 2009 +0400 - - Remove localedir leftovers. - -commit c3acae034c4da2d1c70f31b852b14ca098c0eeb9 -Author: Guus Sliepen -Date: Sat Oct 24 22:32:35 2009 +0200 - - Use IP_DONTFRAGMENT instead of IP_MTU_DISCOVER on Windows. - - This ensures the DF bit on outgoing UDP packets gets set on Windows when path - MTU discovery is enabled, reducing fragmentation. - -commit 242c4e2ca67d0b5c78dfe6e68a5ddcd27be1de99 -Author: Guus Sliepen -Date: Sat Oct 24 21:53:01 2009 +0200 - - Forward packets to not directly reachable hosts via UDP if possible. - - If MTU probing discovered a node was not reachable via UDP, packets for it were - forwarded to the next hop, but always via TCP, even if the next hop was - reachable via UDP. This is now fixed by retrying to send the packet using - send_packet() if the destination is not the same as the nexthop. - -commit d922db253cd098bc038449e5c591cc94c1019952 -Author: Guus Sliepen -Date: Sat Oct 24 21:35:40 2009 +0200 - - Make maxmtu equal to minmtu when fixing the path MTU to a node. - - This ensures MTU probes used to ping nodes are not too large, and prevents - restarting MTU probing unnecessarily. - -commit a8f7fccbc2b5f1c4c39fc2804abaa358b31a5080 -Author: Guus Sliepen -Date: Sat Oct 24 21:32:06 2009 +0200 - - Always reply to MTU probes via UDP. - - It could sometime happen that a node would return MTU probes via TCP, which - does not make a lot of sense. - -commit cddcdc9af34afb388a8e4bdfff6882f568b98313 -Author: Guus Sliepen -Date: Sat Oct 24 20:54:44 2009 +0200 - - Allow UDP packets with an address different from the corresponding TCP connection. - -commit 5cbddc68bade0d1f8ded1b784bb27bb44c5dc5dc -Author: Guus Sliepen -Date: Sat Oct 24 16:15:24 2009 +0200 - - Use uint32_t instead of long int for connection options. - - Options should have a fixed width anyway, but this also fixes a possible MinGW - compiler bug where %lx tries to print a 64 bit value, even though a long int is - only 32 bits. - -commit 468f393c4fabf9223a1bd15adfb3906cde90d547 -Author: Guus Sliepen -Date: Sat Oct 24 16:05:12 2009 +0200 - - Add dummy device. - -commit b6543af7626403516b5fc54c24b11d3a242a2992 -Author: Guus Sliepen -Date: Tue Oct 20 22:39:07 2009 +0200 - - Clarify and increase level of log message about MTU probes to unreachable nodes. - -commit 43a6e786648fb666a9b7be8f05c8a173031c9110 -Author: Guus Sliepen -Date: Tue Oct 20 22:33:16 2009 +0200 - - Handle weighted Subnets in switch and hub modes. - - We now handle MAC Subnets in exactly the same way as IPv4 and IPv6 Subnets. - This also fixes a problem that causes unncessary broadcasting of unicast - packets in VPNs where some daemons run 1.0.10 and some run other versions. - -commit 3a925479c2883a6a9711f7b6931863d7f2a2c09b -Author: Guus Sliepen -Date: Tue Oct 20 22:22:59 2009 +0200 - - Starting to work towards 1.0.11. - -commit 35af4051c3749cd2c2137a7eb57171a1fbb12af7 -Author: Guus Sliepen -Date: Tue Oct 20 22:14:47 2009 +0200 - - Fix a possible crash when sending the HUP signal. - - When the HUP signal is sent while some outgoing connections have not been made - yet, or are being retried, a NULL pointer could be dereferenced resulting in - tinc crashing. We fix this by more careful handling of outgoing_ts, and by - deleting all connections that have not been fully activated yet at the HUP - signal is received. - -commit 8c267d3d558ac97a4ce7381a37abb6cc4b46b133 -Author: Guus Sliepen -Date: Sun Oct 18 16:45:13 2009 +0200 - - Releasing 1.0.10. - -commit 3849de9a331ad132ed9d01c9f0cac47196624b3e -Author: Guus Sliepen -Date: Sun Oct 18 16:44:32 2009 +0200 - - Fix description of the WEIGHT environment variable. - -commit 87364c16564c897b1a2d306615804d68ea5a9ba1 -Author: Guus Sliepen -Date: Sun Oct 18 14:22:20 2009 +0200 - - Include missing header. - -commit c7fdc7d5b8d728c744b13a823e7eef9d2432c61e -Author: Guus Sliepen -Date: Mon Oct 12 23:51:57 2009 +0200 - - Remove debugging message when reading packets from a BSD device. - - This was inadvertently introduced by commit - 4a5d42178cc0954efba8b24058da9c70cc77c35a. - -commit ec4c8bcb18c1f463cf4544126e027fc8ec9b3a39 -Author: Guus Sliepen -Date: Mon Oct 12 22:14:47 2009 +0200 - - Allow the cloning /dev/tap interface to be used on FreeBSD and NetBSD. - - This device works like /dev/tun on Linux, automatically creating a new tap - interface when a program opens it. We now pass the actual name of the newly - created interface in $INTERFACE. - -commit 92b8abc921dd15b710f67335562210eb713fbb39 -Author: Guus Sliepen -Date: Sun Oct 11 18:57:58 2009 +0200 - - Use MTU probes to regularly ping other nodes over UDP. - - This keeps NAT mappings for UDP alive, and will also detect when a node is not - reachable via UDP anymore or if the path MTU is decreasing. Tinc will fall back - to TCP if the node has become unreachable. - - If UDP communication is impossible, we stop sending probes, but we retry if it - changes its keys. - - We also decouple the UDP and TCP ping mechanisms completely, to ensure tinc - properly detects failure of either method. - -commit 927064e5fd0ebf29a7ea768a7f9c4226da626a72 -Author: Guus Sliepen -Date: Sun Oct 11 15:46:52 2009 +0200 - - Small updates to the documentation. - - Mention that TCPOnly is not necessary anymore since tinc will autodetect - whether it can send via UDP or not. Also mention the WEIGHT environment - variable and the new default value (2048 bits) of RSA keys. - -commit 2c30af6c90926340a89748c63cc453b1c0b5a589 -Author: Guus Sliepen -Date: Sun Oct 11 14:20:14 2009 +0200 - - Ensure that the texinfo manual can be converted to HTML. - - The top node was made conditional with the @iftex command, since it should not - appear in PostScript and PDF output. However, it is still necessary for - texi2html, so we have to use @ifnottex instead. - - Texi2html also complains about the use of @cindex in the copyright statement, - so we remove that. - -commit a4f132770dc136d456c67b01d209e73f5f4d7a65 -Author: Guus Sliepen -Date: Sun Oct 11 13:56:04 2009 +0200 - - Revert "Raise default crypto algorithms to AES256 and SHA256." - - Although it would be better to have the new defaults, only the most recent - releases of most of the platforms supported by tinc come with a version of - OpenSSL that supports SHA256. To ensure people can compile tinc and that nodes - can interact with each other, we revert the default back to Blowfish and SHA1. - - This reverts commit 4bb3793e38b7c7f24dd308801e7f6dbb02cf02d2. - -commit 2762509be179dcb21d855f3d6f90d3ee686e3910 -Author: Guus Sliepen -Date: Sun Oct 11 13:54:05 2009 +0200 - - Remove code duplication when checking ADD_EDGE/DEL_EDGE messages. - -commit 5cddf5e52aeb20e50c887356ad23aec354e04151 -Author: Guus Sliepen -Date: Sun Oct 11 13:51:10 2009 +0200 - - Don't disconnect clients in TunnelServer mode who send unauthorised ADD_SUBNETs. - - So that we are liberal in what we accept. - -commit 430c90412c521c534113b3c4e5fc883e9b7ecff0 -Author: Borg -Date: Sat Oct 3 13:06:00 2009 +0200 - - Removed last gettext function. - -commit 3282375f4d64d9402141ac4bf142629ec2e1cd53 -Author: Guus Sliepen -Date: Tue Sep 29 16:25:20 2009 +0200 - - Remove autogenerated files from EXTRA_DIST. - - Apparently they were once necessary, but autoconf now includes them - automatically. Some of them are not used anymore, and this caused make dist to - fail. - -commit 761517c21c37a808a19b487aa116c3c19439feca -Author: Guus Sliepen -Date: Tue Sep 29 15:33:58 2009 +0200 - - Update FSF address in files not covered by the merge. - -commit 07a560eab66b575f382428a956550817697e25e2 -Author: Guus Sliepen -Date: Tue Sep 29 15:19:55 2009 +0200 - - Drop localisation and checkpoint tracing in files not covered by the merge. - -commit 7ea85043ac1fb2096baea44f6b0af27ac0d0b2cf -Merge: f1fec466 9a2b0f88 -Author: Guus Sliepen -Date: Tue Sep 29 14:55:29 2009 +0200 - - Merge branch 'master' into 1.1 - - Conflicts: - NEWS - configure.in - lib/Makefile.am - lib/pidfile.c - lib/pidfile.h - lib/utils.c - po/POTFILES.in - po/nl.po - src/Makefile.am - src/bsd/device.c - src/conf.c - src/connection.c - src/cygwin/device.c - src/edge.c - src/event.c - src/graph.c - src/linux/device.c - src/meta.c - src/mingw/device.c - src/net.c - src/net_packet.c - src/net_setup.c - src/net_socket.c - src/netutl.c - src/node.c - src/process.c - src/protocol.c - src/protocol_auth.c - src/protocol_edge.c - src/protocol_key.c - src/protocol_misc.c - src/protocol_subnet.c - src/raw_socket/device.c - src/route.c - src/solaris/device.c - src/subnet.c - src/tincd.c - src/uml_socket/device.c - -commit 9a2b0f88a9cae753ebc81c939d01403178b18a35 -Author: Guus Sliepen -Date: Sat Sep 26 12:51:52 2009 +0200 - - Update the NEWS. - -commit 46e481dc945c5572eb6091a3660f6bf258ee0cfa -Author: Guus Sliepen -Date: Fri Sep 25 21:14:56 2009 +0200 - - Add more authors to the copyright headers. - - Git's log and blame tools were used to find out which files had significant - contributions from authors who sent in patches that were applied before we used - git. - -commit 4c85542894f7fca823b119b05e07179deb24229a -Author: Guus Sliepen -Date: Fri Sep 25 00:54:07 2009 +0200 - - Drop support for localisation. - - Localised messages don't make much sense for a daemon, and there is only the - Dutch translation which costs time to maintain. - -commit a227843b739d279b63adcf3736ebb03d856080c4 -Author: Guus Sliepen -Date: Fri Sep 25 00:33:04 2009 +0200 - - Remove checkpoint tracing. - - This feature is not necessary anymore since we have tools like valgrind today - that can catch stack overflow errors before they make a backtrace in gdb - impossible. - -commit 5dde6461a321ee47b06e33f8203f2acf00a31a51 -Author: Guus Sliepen -Date: Fri Sep 25 00:14:03 2009 +0200 - - K&R style braces. - - This is essentially commit f02d3ed3e135b5326003e7f69f8331ff6a3cc219 from the - 1.1 branch, making it easier to merge between master and 1.1. - -commit ab7c61b06f6c6e991225f2fcc32d02b8e1084aee -Author: Guus Sliepen -Date: Fri Sep 25 00:01:00 2009 +0200 - - Update the address of the Free Software Foundation in all copyright headers. - -commit 0e6856b1379e278aa5ed116d0911851339a6064c -Author: Guus Sliepen -Date: Thu Sep 24 23:42:30 2009 +0200 - - Remove Ivo's old email addresses. - -commit c217d214f4f071c235bc7c463a1da6124e2570a6 -Author: Guus Sliepen -Date: Thu Sep 24 23:39:16 2009 +0200 - - Remove all occurences of $Id$. - -commit c23fcf555ee4b69f03b76a0ffb731c3a475a77e7 -Author: Guus Sliepen -Date: Thu Sep 24 23:29:46 2009 +0200 - - Update copyright information. - - - Update year numbers in copyright headers. - - Add copyright information for Michael Tokarev and Florian Forster to the - copyright headers of files to which they have contributed significantly. - - Mention Michael and Florian in AUTHORS. - - Mention that tinc is GPLv3 or later if compiled with the --enable-tunemu - flag. - -commit f1fec466e232c00c668422014029dce9114d3add -Author: Guus Sliepen -Date: Wed Sep 16 23:43:19 2009 +0200 - - Add a better autoconf check for libevent. - -commit 4bdf0e80ee4cd0d40eb6522dab05df9346a5b3d0 -Author: Guus Sliepen -Date: Wed Sep 16 20:28:30 2009 +0200 - - Replace asprintf()s not covered by the merge to xasprintf(). - -commit 1cbddbd573d786f6b2bf9812dda89d1ea5b7e021 -Author: Guus Sliepen -Date: Wed Sep 16 20:17:11 2009 +0200 - - Use correct format specifiers. - -commit 2f97bdb46b1ed0a669619e0b9acf76f43dfa648b -Author: Guus Sliepen -Date: Wed Sep 16 20:16:54 2009 +0200 - - Add missing #include. - -commit 075e6828a7533e7daa790225f17aa6bb39703278 -Merge: 9b129c07 b5ccce29 -Author: Guus Sliepen -Date: Wed Sep 16 19:55:47 2009 +0200 - - Merge branch 'master' into 1.1 - - Conflicts: - have.h - lib/dropin.c - lib/fake-getaddrinfo.c - lib/pidfile.c - src/Makefile.am - src/bsd/device.c - src/conf.c - src/connection.c - src/connection.h - src/graph.c - src/mingw/device.c - src/net.c - src/net_setup.c - src/node.c - src/protocol_key.c - src/protocol_misc.c - src/tincd.c - -commit b5ccce296848aab72d574ca3de14af5fdf3efa4d -Author: Guus Sliepen -Date: Tue Sep 15 23:22:13 2009 +0200 - - Send large packets we cannot handle properly via TCP. - - During the path MTU discovery phase, we might not know the maximum MTU yet, but - we do know a safe minimum. If we encounter a packet that is larger than that - the minimum, we now send it via TCP instead to ensure it arrives. We also - allow large packets that we cannot fragment or create ICMP replies for to be - sent via TCP. - -commit d273efb177738d429e3cef7d8db8ee5cc8dcada7 -Author: Guus Sliepen -Date: Tue Sep 15 23:04:52 2009 +0200 - - Raise default RSA key length to 2048 bits. - -commit b47c17bcdeb70b63ad9346dc97ba575597cbd803 -Author: Guus Sliepen -Date: Tue Sep 15 22:59:01 2009 +0200 - - Use a mutex to allow the TAP reader to process packets faster on Windows. - - The TAP-Win32 device is not a socket, and select() under Windows only works - with sockets. Tinc used a separate thread to read from the TAP-Win32 device, - and passed this via a local socket to the main thread which could then select() - from it. We now use a global mutex, which is only unlocked when the main thread - is waiting for select(), to allow the TAP reader thread to process packets - directly. - -commit 802a50ffcd5f39bfc6424ac841de4e41154092fc -Author: Guus Sliepen -Date: Tue Sep 15 22:58:16 2009 +0200 - - Remove extra {. - -commit 4bb3793e38b7c7f24dd308801e7f6dbb02cf02d2 -Author: Guus Sliepen -Date: Tue Sep 15 12:08:05 2009 +0200 - - Raise default crypto algorithms to AES256 and SHA256. - - In light of the recent improvements of attacks on SHA1, the default hash - algorithm in tinc is now SHA256. At the same time, the default symmetric - encryption algorithm has been changed to AES256. - -commit 633c0cf1b067d118d5453bc8522fab65ffc82d2c -Author: Guus Sliepen -Date: Tue Sep 15 00:36:07 2009 +0200 - - Use access() instead of stat() for checking whether scripts exist. - -commit 6f1e0ece4e61f30612ed84ca4640635a02892cc8 -Author: Guus Sliepen -Date: Tue Sep 15 00:28:20 2009 +0200 - - Remove dropin random() function, as it is not used anymore. - -commit fa9bedd47cf8c143e801889c78f0a0979ac4d2fc -Author: Guus Sliepen -Date: Tue Sep 15 00:24:31 2009 +0200 - - Allow compiling for Windows XP and higher. - - This allows us to use getaddrinfo(), getnameinfo() and related functions, which - allow tinc to make connections over existing IPv6 networks. These functions are - not available on Windows 2000 however. By default, support is enabled, but when - compiling for Windows 2000 the configure switch --with-windows2000 should be - used. - - Since getaddrinfo() et al. are not functions but macros on Windows, we have to - use AC_CHECK_DECLS() instead of AC_CHECK_FUNCS() in configure.in. - -commit f80bf14f28925df6eaa56f3ed77adaf418ab9890 -Author: Guus Sliepen -Date: Mon Sep 14 23:28:28 2009 +0200 - - Also do not use drand48(), it is not available on Windows. - -commit 35e87b903e08fc51975a8cc97f06251d5153a424 -Author: Guus Sliepen -Date: Mon Sep 14 23:06:00 2009 +0200 - - Use only rand(), not random(). - - We used both rand() and random() in our code. Since it returns an int, we have - to use %x in our format strings instead of %lx. This fixes a crash under - Windows when cross-compiling tinc with a recent version of MinGW. - -commit 75773efe2689d347a2f219c5f27e4a82eef1236b -Author: Guus Sliepen -Date: Sun Sep 13 14:08:59 2009 +0200 - - Apparently it's impolite to ask GCC to subtract two pointers. - - If two pointers do not belong to the same array, pointer subtraction gives - nonsensical results, depending on the level of optimisation and the - architecture one is compiling for. It is apparently not just subtracting the - pointer values and dividing by the size of the object, but uses some kind of - higher magic not intended for mere mortals. GCC will not warn about this at - all. Casting to void * is also a no-no, because then GCC does warn that strict - aliasing rules are being broken. The only safe way to query the ordering of two - pointers is to use the (in)equality operators. - - The unsafe implementation of connection_compare() has probably caused the "old - connection_t for ... still lingering" messages. Our implementation of AVL trees - is augmented with a doubly linked list, which is normally what is traversed. - Only when deleting an old connection the tree itself is traversed. - -commit 23e151aeed6b3ffe0fab10f51ffdb134deb7a852 -Author: Guus Sliepen -Date: Sun Sep 13 14:07:40 2009 +0200 - - Remove superfluous call to avl_delete(). - -commit 9915f2abbedb7f1aa2b9e2f81d52ddcfca60e82d -Author: Guus Sliepen -Date: Sat Sep 12 14:19:36 2009 +0200 - - Handle unicast packets larger than PMTU in switch mode. - - If PMTUDiscovery is enabled, and we see a unicast packet that is larger than - the path MTU in switch mode, treat it just like we would do in router mode. - -commit 7242868b64f9d6f62b6c5bbf1526eb632ed9a4d6 -Author: Guus Sliepen -Date: Sat Sep 12 13:40:32 2009 +0200 - - Allow PMTUDiscovery in switch and hub modes again. - - PMTUDiscovery was disabled in commit d5b56bbba56480b5565ffb38496175a7c1df60ac - because tinc did not handle packets larger than the path MTU in switch and hub - modes. We now allow it again in preparation of proper support, but default to - off. - -commit 052ff8b2c598358d1c5febaa9f9f5fc5d384cfd3 -Author: Guus Sliepen -Date: Sat Sep 12 13:34:11 2009 +0200 - - Put Subnet weight in a separate environment variable. - - Commit 5674bba5c54c1aee3a4ac5b3aba6b3ebded91bbc introduced weighted Subnets, - but the weight was included in the SUBNET variable passed to subnet-up/down - scripts. This makes it harder to use in those scripts. The weight is now - stripped from the SUBNET variable and put in the WEIGHT variabel. - -commit a60a0a1f1357508063ee565d672c39898a787e33 -Author: Guus Sliepen -Date: Thu Sep 10 19:51:08 2009 +0200 - - Don't stat() on iPhone/iPod. - - Grzegorz Dymarek noted that tinc segfaults at the stat() call in - execute_script() on the iPhone. We can omit the stat() call for the moment, - the subsequent call to system() will fail with just a warning. - -commit 4a5d42178cc0954efba8b24058da9c70cc77c35a -Author: Guus Sliepen -Date: Thu Sep 10 19:32:54 2009 +0200 - - Add support for iPhones and recent iPods. - - This is a slightly modified patch from Grzegorz Dymarek that allows tinc to use - the tunemu device, which allows tinc to be compiled for iPhones and recent - iPods. To enable support for tunemu, the --enable-tunemu option has to be used - when running the configure script. - -commit ff946d0423fe547ea42bb11acfb3035c3b8aee4e -Author: Guus Sliepen -Date: Wed Sep 9 14:51:36 2009 +0200 - - Another safe bitfield conversion. - -commit dd6226062c2356d2a3679e2c7972be71233cb9de -Author: Guus Sliepen -Date: Wed Sep 9 13:23:16 2009 +0200 - - Add the GPL license to the repository. - - Tinc is licensed under the GPL version 2 or later. To ensure autoconf does not - install the wrong license if COPYING is missing, we have to put the right one - in place. - -commit 81afa26e4ad53bea00da18a7666f63d33cf3f588 -Author: Guus Sliepen -Date: Wed Sep 9 12:04:08 2009 +0200 - - Convert bitfields to integers in a safe way. - - This is commit eb391c52eed46f3f03b404553df417851fc0cb90 redone, but without the - non-standard anonymous union. - -commit 9b394bc887695da6db74f4b9796b4823e553f8cc -Author: Guus Sliepen -Date: Tue Sep 8 21:45:24 2009 +0200 - - Ensure tinc compiles with gcc -std=c99. - - We use a lot of C99 features already, but also some extensions which are not in - the standard. - -commit f52ea0a7eb0383cc2a5f41db1bf24c39424fdb04 -Author: Guus Sliepen -Date: Tue Sep 8 18:21:52 2009 +0200 - - UNIX signal numbers start at 1. - -commit 73d77dd416b87b7c4e9b6aa450f64846235cd2b4 -Author: Guus Sliepen -Date: Tue Sep 8 18:18:36 2009 +0200 - - Replace asprintf() by xasprintf(). - -commit 3e55dc77f4ba19fd9e79f3d5ce9d28bb6b05019e -Author: Guus Sliepen -Date: Tue Sep 8 18:18:16 2009 +0200 - - Check the return value of fscanf() when reading a PID file. - -commit 5e0efd53e797a2b5468b91b41b6122f3b942efb2 -Author: Guus Sliepen -Date: Tue Sep 8 18:16:58 2009 +0200 - - Add xasprintf() and xvasprintf(). - - These functions wrap asprintf() and vasprintf(), and check the return value. If - the function failed, tinc will exit with an error message, similar to xmalloc() - and friends. - -commit 63fe89e9eb8ef9077bfe3cd416c86820715eb33b -Author: Michael Tokarev -Date: Sat Sep 5 17:24:41 2009 +0400 - - Remove extra semicolon in my definition of setpriority() - -commit 5a7fc58012da10b96073804994777255463d1b8d -Author: Guus Sliepen -Date: Tue Sep 8 16:35:28 2009 +0200 - - Always remove a node from the UDP tree before freeing it. - - Valgrind caught tinc reading free'd memory during a purge(). This was caused by - first removing it from the main node tree, which will already call free_node(), - and then removing it from the UDP tree. This might cause spurious segmentation - faults. - -commit de029ce46056e02908b5390da9b71a6a59133f26 -Author: Guus Sliepen -Date: Thu Jun 11 19:39:25 2009 +0200 - - Change level of some debug messages, zero pointer after freeing hostname. - -commit 66be914d35cb7e7ea4dd4aed68ae9e41addd9f70 -Author: Guus Sliepen -Date: Thu Jun 11 19:26:34 2009 +0200 - - Do not log errors when recvfrom() returns EAGAIN or EINTR. - - Although we select() before we call recvfrom(), it sometimes happens that - select() tells us we can read but a subsequent read fails anyway. This is - harmless. - -commit df4add94a4a6461758b218a9ad257efc735062fe -Author: Guus Sliepen -Date: Thu Jun 11 19:07:54 2009 +0200 - - Remove pending MTU probe events when a node's reachability status changes. - -commit 36f8e4da8b1708474505f5a1fa8cf1ba848921de -Author: Guus Sliepen -Date: Thu Jun 11 18:36:08 2009 +0200 - - Don't try to send MTU probes to unreachable nodes. - - If there is an outstanding MTU probe event for a node which is not reachable - anymore, a UDP packet would be sent to that node, which caused a key request to - be sent to that node, which triggered a NULL pointer dereference. Probes and - other UDP packets to unreachable nodes are now dropped. - -commit 9b129c07e273ae113f3c67a9feeee82e8146f3a1 -Author: Guus Sliepen -Date: Sat Jun 6 20:14:51 2009 +0200 - - Fix pointer arithmetic when creating and verifying message authentication codes. - -commit 4124b9682f8f890acb25d0c92f2583eef670274a -Author: Guus Sliepen -Date: Sat Jun 6 19:04:04 2009 +0200 - - Handle truncated message authentication codes. - -commit 5a132550deb58473285e5f91705d286aef47be71 -Merge: 08aabbf9 591c38eb -Author: Guus Sliepen -Date: Fri Jun 5 23:03:28 2009 +0200 - - Merge branch 'master' into 1.1 - - Conflicts: - doc/tincd.8.in - lib/pidfile.c - src/graph.c - src/net.c - src/net.h - src/net_packet.c - src/net_setup.c - src/net_socket.c - src/netutl.c - src/node.c - src/node.h - src/protocol_auth.c - src/protocol_key.c - src/tincd.c - -commit 261d1eac1c5bbe6c87aa707566f290e611169432 -Author: Guus Sliepen -Date: Fri Jun 5 16:14:31 2009 +0200 - - Properly set HMAC length for incoming packets. - -commit 591c38eb38dbf0851bdebdd50b08d1bcbf6d7b0f -Author: Michael Tokarev -Date: Fri Jun 5 13:33:58 2009 +0400 - - try outgoing connections before chroot/drop_privs - - When chrooted, we either need to force-initialize resolver - and/or nsswitch somehow (no clean way) or resolve all the - names we want before entering chroot jail. The latter - looks cleaner, easier and it is actually safe because - we still don't talk with the remote nodes there, only - initiating outgoing connections. - -commit a42a8dde45fe95aa3fd3f7f15a74c5166efe3633 -Author: Michael Tokarev -Date: Fri Jun 5 11:58:17 2009 +0400 - - cleanup setpriority thing to make it readable - -commit a5fb0d8c6c384b9ea1074fb469c0a3dd5b874e98 -Author: Guus Sliepen -Date: Thu May 28 23:18:22 2009 +0200 - - Add some const where appropriate. - -commit 41c10c5a966000531099c79d6006429253ff8fd6 -Author: Guus Sliepen -Date: Thu May 28 22:51:30 2009 +0200 - - Add ProcessPriority option. - - This option can be set to low, normal or high. On UNIX flavours, this changes - the nice value of the process by +10, 0 and -10 respectively. On Windows, it - sets the priority to BELOW_NORMAL_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS and - HIGH_PRIORITY_CLASS respectively. - - A high priority might help to reduce latency and packet loss on the VPN. - -commit 41a05f59ba2c3eb5caab555f096ed1b9fbe69ee3 -Author: Florian Forster -Date: Wed May 27 14:20:24 2009 +0200 - - src/net_socket.c: Bind outgoing TCP sockets to `BindToAddress'. - - If a host has multiple addresses on an interface, the source address of the TCP - connection(s) was picked by the operating system while the UDP packets used a - bound socket, i. e. the source address was the address specified by the user. - This caused problems because the receiving code requires the TCP connection and - the UDP connection to originate from the same IP address. - - This patch adds support for the `BindToInterface' and `BindToAddress' options - to the setup of outgoing TCP connections. - - Tested with Debian Etch on x86 and Debian Lenny on x86_64. - - Signed-off-by: Florian Forster - -commit 6b415a1a7f5bad2fff7b133ef2a2febccb96d6e5 -Author: Florian Forster -Date: Wed May 27 09:27:44 2009 +0200 - - src/linux/device.c: Fix segfault when running without `--net'. - - If running without `--net', the (global) variable `netname' is NULL. This - creates a segmentation fault because this NULL-pointer is passed to strdup: - - Program terminated with signal 11, Segmentation fault. - #0 0xb7d30463 in strlen () from /lib/tls/i686/cmov/libc.so.6 - (gdb) bt - #0 0xb7d30463 in strlen () from /lib/tls/i686/cmov/libc.so.6 - #1 0xb7d30175 in strdup () from /lib/tls/i686/cmov/libc.so.6 - #2 0x0805bf47 in xstrdup (s=0x0) at xmalloc.c:118 <--- - #3 0x0805be33 in setup_device () at device.c:66 - #4 0x0805072e in setup_myself () at net_setup.c:432 - #5 0x08050db2 in setup_network () at net_setup.c:536 - #6 0x0805b27f in main (argc=Cannot access memory at address 0x0) at tincd.c:580 - - This patch fixes this by checking `netname' in `setup_device'. An alternative - would be to check for NULL-pointers in `xstrdup' and return NULL in this case. - - Signed-off-by: Florian Forster - -commit a8a65cee083a27afe42cab360596e1453e7141b9 -Author: Michael Tokarev -Date: Sun May 24 17:23:24 2009 +0400 - - tunnelserver: log which ADD_SUBNET was refused - - Add some logging about refused ADD_SUBNET - (it causes subsequent client disconnect so it's - important to know which subnet was at fault). - - Maybe we should just ignore it completely. - -commit 4e9e3ca89dba68cbacaaa15ddfb298b181a969da -Author: Guus Sliepen -Date: Mon May 25 15:04:33 2009 +0200 - - Do not forward broadcast packets when TunnelServer is enabled. - - First of all, the idea behind the TunnelServer option is to hide all other - nodes from each other, so we shouldn't forward broadcast packets from them - anyway. The other reason is that since edges from other nodes are ignored, the - calculated minimum spanning tree might not be correct, which can result in - routing loops. - -commit 7fc69bc73b15349dafc193a50464caeb2f978369 -Author: Guus Sliepen -Date: Mon May 25 12:19:37 2009 +0200 - - Use packet size before decompression to calculate path MTU. - - Since compression can either grow or shrink a packet, the size of an MTU probe - after decompression might not reflect the real path MTU. Now we use the size - before decompression, which is independent of the compression algorithm, and - substract a safety margin such that the calculated path MTU will be safe even - for packets which grow as much as possible after compression. - -commit 1b3add6c29f8eb424a62837e89fe7d384fc94a48 -Author: Guus Sliepen -Date: Mon May 25 12:19:08 2009 +0200 - - Add declaration for sockaddrcmp_noport(). - -commit ca5b67111e4d797d15623c2163f67fe489dc3bf2 -Author: Michael Tokarev -Date: Sun May 24 22:32:24 2009 +0400 - - Fix ans_key exchange in recent changes - - send_ans_key() was using the wrong in vs. outkeylength to - terminate the key being sent, so it was always empty. - -commit 7034338bc36d9ea96d152091b9d58c2afc3f0c20 -Author: Guus Sliepen -Date: Sun May 24 19:35:51 2009 +0200 - - Use xrealloc instead of if(ptr) ptr = xmalloc(). - -commit e012e752f4f1a2b06dfab4640bbbea8f084999ff -Author: Guus Sliepen -Date: Sun May 24 19:31:31 2009 +0200 - - Fix initialisation of packet decryption context broken by commit 3308d13e7e3bf20cfeaf6f2ab17228a9820cea66. - - Instead of a single, global decryption context, each node has its own context. - However, in send_ans_key(), the global context was initialised. This commit - fixes that and removes the global context completely. - - Also only set status.validkey after all checks have been evaluated. - -commit 0246939ce18e1af9660b782b6814be182a7af9da -Author: Michael Tokarev -Date: Fri May 22 01:10:16 2009 +0400 - - don't log every strange packet coming to the UDP port - - it's a sure way to fill up syslog. Only log those if - debug level is up to PROTOCOL - -commit 576899ef0dec3aaede9b8ac101d189798587a646 -Author: Guus Sliepen -Date: Sun May 24 17:13:00 2009 +0200 - - Fix link to Mattias Nissler's tun/tap driver for MacOS/X. - - Thanks to Martin Christof Kindsmüller for spotting. - -commit 2c67eafc6e6c5e210636c0d2bad15827bf2d7cf0 -Author: Guus Sliepen -Date: Sun May 24 15:58:47 2009 +0200 - - If PMTUDiscovery is not set, do not forward packets via TCP unnecessarily. - -commit 7e4d57adf54ce369e4111bde0ccd3ea4b9e853ee -Author: Michael Tokarev -Date: Fri May 22 01:01:35 2009 +0400 - - ignore indirect edge registrations in tunnelserver mode - - In tunnelserver mode we're not interested to hear about - our client edges, just like in case of subnets. Just - ignore all requests which are not about our node or the - client node. - - The fix is very similar to what was done for subnets. - - Note that we don't need to add the "unknown" nodes to - the list in tunnelserver mode too, so move allocation - of new nodes down the line. - -commit 3759aa5f7745709c43f81faa36510ff650b4bf99 -Author: Michael Tokarev -Date: Wed May 20 18:40:04 2009 +0400 - - TunnelServer: Don't disconnect client on DEL_SUBNET too - - Similar changes as was in 2327d3f6eb5982bcc922ff1ab1ec436ba6aeffdc - but for del_subnet_h(). - - Before, we vere returning false (and causing disconnect of the - client) in case of tunnelserver and the client sending DEL_SUBNET - for non-his subnet or for subnet which owner isn't in our connection - list. - - After the mentioned change to add_subnet_h() that routine does not - add such indirect owners to the connection list anymore, so that - was ok (owner == NULL and we return true). - - But if we too has a connection with the node about which the client - is sending DEL_SUBNET notification, say, because that client lost - connection with that other node, we'll disconnect this client from - us too, returning false for indirect DEL_SUBNET. - - Fix that by allowing and ignoring indirect DEL_SUBNET in tunnelserver - mode. - - Also rearranged the function a bit, to match add_subnet_h() (in - particular, syntax-check everything first, see if we've seen this - request before). - - And also fix some comments. - -commit 218adee785df7c79ac18395d056a2eb6d63c407f -Author: Michael Tokarev -Date: Mon May 18 17:34:30 2009 +0400 - - format 'not supported on this platform' error message - - Format it in a similar way in all places, to make translation happier. - No functional changes. - -commit 54cb6b1aecb06a1ca44a7a60c74dd0d65b0043dd -Author: Michael Tokarev -Date: Mon May 18 17:00:00 2009 +0400 - - change error messages in droppriv code to match the rest - - Change formatting of error messages about failed syscalls - to be the same as in other places in tincd. - - Also suggest a change in "$foo not supported on this platform" - message as it's now used more than once. - -commit d4f9863635d06665cfbd3c46dc482344de240e97 -Author: Michael Tokarev -Date: Mon May 18 16:53:08 2009 +0400 - - bugfix: chdir(/) after chroot - - Fix the famous chdir(".") vs chdir("/") after chroot(something). - -commit 6be5d4f5b67764115b37528d2fe01bd245b3cd3e -Author: Michael Tokarev -Date: Mon May 18 16:49:39 2009 +0400 - - bugfix: move mlock to after detach() so it works for child, not parent - - mlock()/mlockall() are not persistent across fork(), and it's - done in parent process before daemon() which does fork(). So - basically, current --mlock does nothing useful. - - Move mlock() to after detach() so it works for child process - instead of parent. - - Also, check if the platform supports mlock right when processing - options (since else we'll have to die after startup, not at - startup, the error message will be in log only). - -commit cdf7f13c31310da0c40819fd812e19519bf4318c -Author: Michael Tokarev -Date: Mon May 18 16:28:55 2009 +0400 - - bugfix: initialize pid (as read from pidfile) to zero - - If we didn't read any number from a pid file, we'll return - an unitialized variable to the caller, and it will treat - that garbage as a pid of a process (possible to kill). - - Fix that. - -commit ec316aa32e8567395a88c4583007f01ffae008ce -Author: Michael Tokarev -Date: Mon May 18 16:25:41 2009 +0400 - - Implement privilege dropping - - Add two options, -R/--chroot and -U/--user=user, to chroot to the - config directory (where tinc.conf is located) and to perform - setuid to the user specified, after all the initialization is done. - - What's left is handling of pid file since we can't remove it anymore. - -commit 6698f7c390a5ae2f262e30560d9df59f9d5c418d -Author: Michael Tokarev -Date: Mon May 18 16:25:10 2009 +0400 - - Rename setup_network_connections() and split out try_outgoing_connections() - - In preparation of chroot/setuid operations, split out call to - try_outgoing_connections() from setup_network_connections() - (which was the last call in setup_network_connections()). - This is because dropping privileges should be done in-between - setup_network_connections() and try_outgoing_connections(). - - This patch renames setup_network_connections() to setup_network() - and moves call to try_outgoing_connections() into main routine. - - No functional changes. - -commit 3308d13e7e3bf20cfeaf6f2ab17228a9820cea66 -Author: Guus Sliepen -Date: Fri Apr 3 01:05:23 2009 +0200 - - Handle UDP packets from different and ports than advertised. - - Previously, tinc used a fixed address and port for each node for UDP packet - exchange. The port was the one advertised by that node as its listening port. - However, due to NAT the port might be different. Now, tinc sends a different - session key to each node. This way, the sending node can be determined from - incoming packets by checking the MAC against all session keys. If a match is - found, the address and port for that node are updated. - -commit 08aabbf9317806bc50a9a6693ca866c8936ce26b -Merge: 551cd194 43fa7283 -Author: Guus Sliepen -Date: Mon Mar 9 19:02:24 2009 +0100 - - Merge branch 'master' into 1.1 - - Conflicts: - NEWS - README - doc/tinc.conf.5.in - doc/tinc.texi - po/nl.po - src/conf.c - src/connection.c - src/event.c - src/graph.c - src/net.c - src/net_packet.c - src/net_socket.c - src/node.c - src/node.h - src/openssl/rsagen.h - src/protocol_auth.c - src/protocol_key.c - src/protocol_misc.c - src/subnet.c - src/subnet.h - src/tincd.c - -commit 43fa7283ac01f2ecc95381b519ef6b3342546f35 -Author: Guus Sliepen -Date: Mon Mar 9 14:04:31 2009 +0100 - - Use a simple Random Early Drop algorithm in send_tcppacket(). - -commit d5b56bbba56480b5565ffb38496175a7c1df60ac -Author: Guus Sliepen -Date: Mon Mar 9 13:48:54 2009 +0100 - - Disable PMTUDiscovery in switch and hub modes. - - In switch and hub modes, tinc does not generate ICMP packets in response to - packets that are larger than the path MTU. However, if PMTUDiscovery is - enabled, the IP_MTU_DISCOVER and IPV6_MTU_DISCOVER option is set on the UDP - sockets, which causes all UDP packets to be sent with the DF bit set, causing - large packets to be dropped, even if they would otherwise be routed fine. - -commit 78fc59e994c764d072bf0045177f690a378d1308 -Author: Guus Sliepen -Date: Thu Mar 5 14:12:36 2009 +0100 - - Update THANKS and copyright information. - -commit 5674bba5c54c1aee3a4ac5b3aba6b3ebded91bbc -Author: Guus Sliepen -Date: Thu Mar 5 13:34:13 2009 +0100 - - Allow weight to be assigned to Subnets. - - Tinc allows multiple nodes to own the same Subnet, but did not have a sensible - way to decide which one to send packets to. Tinc also did not check the - reachability of nodes when deciding where to route packets to, so it would not - automatically fail over to a reachable node. - - Tinc now assigns a weight to each Subnet. The default weight is 10, with lower - weights having higher priority. The Subnets are now internally sorted in the - same way as the kernel's routing table, and the Subnets are search linearly, - skipping those of unreachable nodes. A small cache of recently used addresses - is used to speed up the lookup functions. - -commit 76a1bcaffcf1f1abf81fdda379b703a004640cb4 -Author: Michael Tokarev -Date: Sat Feb 28 16:37:51 2009 +0300 - - Enable PMTUDiscovery only if BOTH sides wants it. - - Don't enable PMTUDiscovery if at least one side does not support it. - Before it was enabled if at least one side supported it, now both are required. - -commit 1c1a67fd93530b9d16538ab2897c3911d3b16574 -Author: Guus Sliepen -Date: Tue Feb 17 14:43:05 2009 +0100 - - Handle neighbor solicitation requests without link layer addresses. - - Apparently FreeBSD likes to send out neighbor solicitation requests, even on a - tun interface where this is completely pointless. These requests do not have an - option header containing a link layer address, so the proxy-neighborsol code - was treating these requests as invalid. We now handle such requests, and send - back equally pointless replies, also without a link layer address. This seems - to satisfy FreeBSD. - -commit 2327d3f6eb5982bcc922ff1ab1ec436ba6aeffdc -Author: Michael Tokarev -Date: Mon Feb 9 23:51:10 2009 +0100 - - Allow tunnelserver to work with clients that have other peers. - - In TunnelServer mode, tinc server disconnects any client if it announces - indirect subnets -- subnets that are not theirs (e.g. subnets for nodes - the CLIENT has connections now, even if those nodes are known to the server - too). Fix that by ignoring such (indirect) announces instead. - - While we're at it, move check for such indirect subnet registration to - before allocating new node structure, as in TunnelServer mode we don't - really need to know that other node. - -commit 23730375f27c32e0fe1a59c7a761dd85296a7a4a -Author: Guus Sliepen -Date: Tue Feb 3 14:54:45 2009 +0100 - - Disable old RSA keys when generating new ones. - - When generating an RSA keypair, the new public and private keys are appended to - files. However, when OpenSSL reads keys it only reads the first in a file, not - the last. Instead of printing an easily ignored warning, tinc now disables old - keys when appending new ones. - -commit 0d0dfd0852e9b2c9a7660880966a3c84790d5ea2 -Author: Guus Sliepen -Date: Tue Jan 20 14:21:50 2009 +0100 - - Validate Name before using it in a filename when generating a keypair. - -commit 0966cca8ab6dcde2747c717f21d73fd332e04242 -Author: Guus Sliepen -Date: Tue Jan 20 14:20:44 2009 +0100 - - Allow reading config files with CRLF endings on Unix systems. - -commit d1910ac198232573c1b18d8238a27bc29bc73f8a -Author: Guus Sliepen -Date: Tue Jan 20 13:19:31 2009 +0100 - - Remove unused definitions from net.h. - -commit 503c32eb0ef9d6329e931559082f4ddf6d487dc6 -Author: Guus Sliepen -Date: Tue Jan 20 13:12:41 2009 +0100 - - Use a global list to track outgoing connections. - - Previously an outgoing_t was maintained for each outgoing connection, - but the pointer to it was either stored in a connection_t or in an event_t. - This made it very hard to keep track of and to clean up. - - Now a list is created when tinc starts and reads all the ConnectTo variables, - and which is recreated when tinc receives a HUP signal. - -commit a7e793c94ec414eb71ec2aa3debc9e2e5ed5cfef -Author: Guus Sliepen -Date: Mon Jan 19 23:17:28 2009 +0100 - - Add missing cleanup functions in close_network_connections(). - -commit 116065afe352221ac6c2c8e34c109252004d6a59 -Author: Guus Sliepen -Date: Mon Jan 19 22:50:05 2009 +0100 - - Change flush_events() to expire_events(). - - The former function made a totally bogus shallow copy of the event_tree, called - the handler of each event and then deleted the whole tree. This should've - caused tinc to crash when an ALARM signal was sent more than once, but for some - reason it didn't. It also behaved incorrectly when a handler added a new event. - - The new function just moves the expiration time of all events to the past. - -commit a39a9506cd041a7092a98498b362eaacfd2f33c3 -Author: Guus Sliepen -Date: Fri Jan 9 12:36:06 2009 +0100 - - Move free()s at the end om main() to the proper destructor functions. - -commit 67df7fb7e1c9eefe4bbc920fdc68b595ef28abd9 -Author: Guus Sliepen -Date: Sat Jan 3 22:33:55 2009 +0100 - - Only send packets via UDP if UDP communication is possible. - - When no session key is known for a node, or when it is doing PMTU discovery but - no MTU probes have returned yet, packets are sent via TCP. Some logic is added - to make sure intermediate nodes continue forwarding via TCP. The per-node - packet queue is now no longer necessary and has been removed. - -commit b069da90d67b49dce041f513a3855b8da3d82f80 -Author: Guus Sliepen -Date: Sat Jan 3 22:06:10 2009 +0100 - - Consistently allocate device and iface variables on the heap. - - This fixes a segfault when no Device has been specified and tinc exits, and it - would try to free() a static string. Thanks to Borg for spottin. - -commit f81cea3bdc8683b27188cd8f24a2de906a29eb81 -Author: Guus Sliepen -Date: Sat Dec 27 11:09:43 2008 +0100 - - Update documentation for git. - -commit c81f90b91a054eeafcc3c8c45abc52045e4a8146 -Author: Guus Sliepen -Date: Fri Dec 26 13:47:34 2008 +0000 - - Releasing 1.0.9. - -commit a4d99ebf5042dedb609359cbbfc3fa4630b5fc70 -Author: Guus Sliepen -Date: Fri Dec 26 12:46:45 2008 +0000 - - Add missing parentheses in check for IPv4 multicast addresses. - -commit 099bc56f53e7d3cb7b799d26ff9535673ff03e1c -Author: Guus Sliepen -Date: Tue Dec 23 23:14:37 2008 +0000 - - Apply patch from Max Rijevski fixing a memory leak when closing connections. - It also cleans up more when stopping tinc, helping tools like valgrind. - -commit de032054dee67bcc406b4a15fb9e957a766d016a -Author: Guus Sliepen -Date: Tue Dec 23 22:31:38 2008 +0000 - - Handle broadcast and multicast packets in router mode. - Multicast packets are treated as broadcast packets. - Based on a patch from Max Rijevski. - -commit a5f899a9794f215e8174455ead04862a2c14a5b1 -Author: Guus Sliepen -Date: Mon Dec 22 21:49:23 2008 +0000 - - Update the manpage as well, and some whitespace to make its source more legible. - -commit e8f08ced76bf1b9a94dd0dc874ad22761ad8900b -Author: Guus Sliepen -Date: Mon Dec 22 21:29:21 2008 +0000 - - Update documentation. - - TCPOnly is not experimental. - - Do not mention old Linux kernels and Ethertap anymore. - - Document the DeviceType, PMTU and PMTUDiscovery options. - -commit 0e4d419aae8a82f2ae4552f755894a9bc70c83d2 -Author: Guus Sliepen -Date: Mon Dec 22 20:35:45 2008 +0000 - - Enable PMTU discovery by default. - -commit e9576632dc4b780b867044269d06cc50f76d8c05 -Author: Guus Sliepen -Date: Mon Dec 22 20:27:52 2008 +0000 - - Update copyright information. - -commit f50dc972cde2644588eabf35a2422fe0e372a024 -Author: Guus Sliepen -Date: Mon Dec 22 19:43:49 2008 +0000 - - Update Dutch translation. - -commit 26b490e86bc305b150200c0b08cd8e9c3bd605fb -Author: Guus Sliepen -Date: Mon Dec 22 19:40:40 2008 +0000 - - Make sure IPv6 sockets are IPv6 only. - This will get rid of the "Can't bind to 0.0.0.0 port 655/tcp: Address already - in use" message on Linux. - -commit c6830ba821e6387be961ca68b32992382a74a0e9 -Author: Guus Sliepen -Date: Mon Dec 22 19:33:37 2008 +0000 - - Use TUNIFHEAD by default on FreeBSD to make sure IPv6 works. - -commit a269ec4193900feee01ac83f0e18a6e2b98e751f -Author: Guus Sliepen -Date: Sun Dec 21 16:19:31 2008 +0000 - - Treat virtual network device as tap if Mode = switch or hub. - On OpenBSD, the link0 flag should still be set in tinc-up or by other means. - -commit 551cd19406a560d0d206bff5b4e9da064ec222b6 -Author: Guus Sliepen -Date: Sun Dec 14 12:47:26 2008 +0000 - - Move RSA key generation into the wrappers. - -commit 911c05f873ad967c40d04aa7347b1067fe62c055 -Author: Guus Sliepen -Date: Thu Dec 11 20:49:14 2008 +0000 - - Make sure IPv6 sockets are IPv6 only. - -commit 6e80da3370249caa1082c23c3ef55f338d1e9e74 -Author: Guus Sliepen -Date: Thu Dec 11 18:07:26 2008 +0000 - - Use Dijkstra's algorithm. Based on patches from Max Rijevskiy. - -commit 26a228e3025c3970fd461af777013e3807b0fc58 -Author: Guus Sliepen -Date: Thu Dec 11 18:05:59 2008 +0000 - - Remove wrong checks. - -commit 636200d1a2024982fe5b3062153daa72a8253015 -Author: Guus Sliepen -Date: Thu Dec 11 15:56:18 2008 +0000 - - Remove unnecessary parentheses from sizeof, apply sizeof to variables instead of types whereever possible. - -commit a9bdfb424e7a469d15156aa44bbe2fd0b8e28531 -Author: Guus Sliepen -Date: Thu Dec 11 15:42:46 2008 +0000 - - Fix compiler warnings. - -commit 76165488f8201a59e649b4eec02ee31398b3fb92 -Author: Guus Sliepen -Date: Thu Dec 11 15:21:40 2008 +0000 - - Backport fixes from trunk since revision 1555. - -commit 046158a216e78a0412186ec8463157f6bce45d5d -Author: Guus Sliepen -Date: Thu Dec 11 14:44:44 2008 +0000 - - Use the crypto wrappers again instead of calling OpenSSL directly. - This theoretically allows other cryptographic libraries to be used, - and it improves the readability of the code. - -commit 8c69f42d7d9b4d9d5f6b6656cfc1bf1e1abee854 -Author: Guus Sliepen -Date: Thu Dec 11 14:43:13 2008 +0000 - - Move AC_GNU_SOURCE up to make autoconf happy. - Also bump libgcrypt dependency to 1.4.0, because that version supports the OFB cipher mode. - -commit 8e8fe805c81d3edc974c12c468f793ea0c1e5ee7 -Author: Guus Sliepen -Date: Thu Dec 11 14:03:52 2008 +0000 - - Only show meta connection related debug messages when debug level >= 4 - -commit 40bebbb19fd69fa094e2f6c3c1474adc0105b048 -Author: Guus Sliepen -Date: Thu Dec 11 13:59:46 2008 +0000 - - Look in the configured sbin directory for the tincd binary. - -commit 38c2d6c1dae3f09c68baa37fd24caa2e0ec6d8ad -Author: Guus Sliepen -Date: Fri Dec 5 14:17:39 2008 +0000 - - Correct debug message. - -commit a36259435c17f76cf12476234a56f40fcd8faf41 -Author: Guus Sliepen -Date: Tue Nov 18 15:11:27 2008 +0000 - - Prevent freeing a NULL pointer when a hostname is unresolvable. - -commit 4a1740ede7c1992f7f3da5e197db9975c0344ac3 -Author: Guus Sliepen -Date: Sat Oct 25 19:54:00 2008 +0000 - - Do not try to send REQ_KEY or ANS_KEY requests to unreachable nodes. - -commit cb52aa06833a69e57b5e26337e51a4d375b6d8fb -Author: Guus Sliepen -Date: Sat Oct 25 18:10:08 2008 +0000 - - Fix reading configuration files that do not end with a newline. - -commit b2cee41b187d79c095914d1097b8ff34a0609ec3 -Author: Guus Sliepen -Date: Fri Dec 14 21:17:08 2007 +0000 - - Make sure the prefixlength of subnets is sane. - Thanks to Sven-Haegar Koch for spotting the bug and providing a fix. - -commit fe2f1fceb546ca4326435cac26bcf3f513e82b43 -Author: Scott Lamb -Date: Thu Nov 8 19:18:44 2007 +0000 - - Use a control socket directory to restrict access - - This provides reasonable security even on Solaris. The sysadmin is - responsible for securing the control socket's ancestors from the - grandparent on. - - We could add a cryptographic handshake later if desired. - -commit b1f8c65a2cfa307d9b8ed8cc3c8d4819f605e4f6 -Author: Scott Lamb -Date: Wed Nov 7 06:45:28 2007 +0000 - - Coding style corrections - -commit d82fcc88f355e3c8144478a860dfae0b299004a9 -Author: Scott Lamb -Date: Wed Nov 7 02:51:24 2007 +0000 - - Reload configuration through control socket - - I also kept the SIGHUP handler, which many people will expect to see. - The control socket is better, though - it will tell you if there is a - problem. - -commit f0a57eab4cfd64d4f8261b1885a2072177f9e76b -Author: Scott Lamb -Date: Wed Nov 7 02:50:58 2007 +0000 - - Retry connections through control socket - -commit a62a6825a8a69e279ee0688a4cd9e51fbc52054b -Author: Scott Lamb -Date: Wed Nov 7 02:50:27 2007 +0000 - - Alter debugging levels through control socket - -commit 1065879c8c6e8cdf8d3755024241f31eaabd4138 -Author: Scott Lamb -Date: Wed Nov 7 02:49:57 2007 +0000 - - Purge through the control socket - -commit 6eaefb4dbce240334e35f67d9f3db5d4f44e49c9 -Author: Scott Lamb -Date: Wed Nov 7 02:49:25 2007 +0000 - - Dump through control socket - - Note this removes SIGUSR1, SIGUSR2, and the graph dumping config option. - It seems cleaner to do everything through the control socket. - -commit 50ad3f2a895c38f8d546f87490ca96ab7d9e011e -Author: Scott Lamb -Date: Wed Nov 7 02:48:33 2007 +0000 - - Fancier protocol for control socket - - * pass error status back - * pass message boundaries - -commit b0b52991849073de059a188800d1b2f03663a188 -Author: Scott Lamb -Date: Wed Nov 7 02:48:15 2007 +0000 - - Fix reload crash - - sighup_handler was expecting the connection_tree to stay the same across - terminate_connection(), which hasn't been true since r1539. - -commit da81da064a093f94e460fc1c359b5cfab26d6b5b -Author: Scott Lamb -Date: Wed Nov 7 02:48:00 2007 +0000 - - Update documentation to match tincctl changes - - (Most of this was done in r1559, but it looks like tincctl.8.in got missed.) - -commit 40731d030fef793c6b6405efd9b3e64c26c00045 -Author: Scott Lamb -Date: Wed Nov 7 02:47:05 2007 +0000 - - Temporarily revert to old crypto code - - (The new code is still segfaulting for me, and I'd like to proceed with other - work.) - - This largely rolls back to the revision 1545 state of the existing code - (new crypto layer is still there with no callers), though I reintroduced - the segfault fix of revision 1562. - -commit 269892f70bf357de6ad66ca89daa34b225ee9e37 -Author: Guus Sliepen -Date: Sat Oct 20 11:21:44 2007 +0000 - - Prevent double free() of a used challenge nonce. - -commit b0709d2649ebd7ad01d6e24851dcdfc2707d09c5 -Author: Guus Sliepen -Date: Fri Oct 19 19:07:30 2007 +0000 - - Fix meta data segfault when receiving a partial command. - -commit 67d9a72ea2f10f1a2d2eb7c04a41183359d5e1cc -Author: Guus Sliepen -Date: Fri Oct 19 18:54:43 2007 +0000 - - Use a dummy function as the read callback for connection bufferevents. Should not be triggered. - -commit 54892b2e3efcbbbd65b26a32f487829bbb8d787c -Author: Guus Sliepen -Date: Fri Oct 19 18:53:48 2007 +0000 - - Fix connection weight estimation. - -commit 6c453769fd16125ec18e8e6d102a3eaa09d370c7 -Author: Guus Sliepen -Date: Tue Sep 4 15:06:35 2007 +0000 - - Apply patch from Scott Lamb: Update documentation to match tincctl changes - -commit 86358fabfedca395b60310799a648b4875596efb -Author: Guus Sliepen -Date: Tue Sep 4 14:58:52 2007 +0000 - - Small fixes to make gcrypt routines compile. - -commit f8733d1935ed83399c4851a31f4be710eb8c825f -Author: Guus Sliepen -Date: Tue Sep 4 14:58:11 2007 +0000 - - Fix formatting of --help output. - -commit 65375289dff849f00b3429dfe4be7e66efe48444 -Author: Guus Sliepen -Date: Tue Sep 4 14:57:37 2007 +0000 - - Only check for libgcrypt if --with-gcrypt is used. - -commit d7ca0300a3f004e9dc7d97ffb6fa6bdeda890fda -Author: Guus Sliepen -Date: Fri Aug 17 22:09:00 2007 +0000 - - Handle SERVICE_CONTROL_INTERROGATE requests. Thanks to Carsten Ralle for noticing this. - -commit 1fd1d5bd9330e02ab5dc32ad027f654ff2620099 -Author: Scott Lamb -Date: Fri Jul 20 20:10:46 2007 +0000 - - const correctness - - cipher_encrypt and cipher_decrypt should take "const void *" data - -commit 35d865a6348cd62d2992bb3d353e37471d902889 -Author: Scott Lamb -Date: Wed Jul 18 16:44:05 2007 +0000 - - Updated svn:ignores list for new symlinked sources and tincctl. - -commit dd299c06dccceeb9b4db09eee17268cf5631fa41 -Author: Scott Lamb -Date: Wed Jul 18 16:40:41 2007 +0000 - - Refresh po/POTFILES.in. - - In particular, remove lib/pidfile.c which was causing failures. Also sort - for diffability with "find . -type f -name '*.c' | cut -c3- | sort" output. - -commit 46018a1a16579ce00b02eb6a991a70615ab9bc3e -Author: Scott Lamb -Date: Wed Jul 18 16:40:29 2007 +0000 - - Revert to only requiring autoconf 2.59. - - The new autoconf macros introduced at the same time (AC_GNU_SOURCE, - AC_FUNC_MALLOC, AC_FUNC_REALLOC) exist in the autoconf 2.59 documentation, - and autoconf 2.59 appears to still work. This is more convenient, as RHEL 5 - ships with autoconf 2.59. - -commit 1b8f8918360b40a2749d40355266ed7dedbe41b5 -Author: Guus Sliepen -Date: Wed May 23 13:45:49 2007 +0000 - - Finish crypto wrapping. Also provide wrappers for OpenSSL. - Disable libgcrypt by default. Since it doesn't support the OFB cipher mode, - we can't use it in a backwards compatible way. - -commit f42e57f663a2663c830c4fb4c01927c2d3c89c09 -Author: Guus Sliepen -Date: Tue May 22 23:41:22 2007 +0000 - - Some more crypto wrapper functions are needed. - -commit 19413a8048fd851866c551ab8035f008f0c7e806 -Author: Guus Sliepen -Date: Tue May 22 21:44:17 2007 +0000 - - Make sure the crypto wrapper functions can actually be compiled. - -commit e8689a4753ca2b1665e131cc40217da6c033ebd3 -Author: Guus Sliepen -Date: Tue May 22 21:32:48 2007 +0000 - - Create wrappers for the cryptographic operations used in tinc. - Implement them using libgcrypt. - -commit 465837dd7f7b727d489b354e4b75489dd49fd6e3 -Author: Guus Sliepen -Date: Sun May 20 22:28:49 2007 +0000 - - Parse PEM RSA keys ourself, and use libgcrypt to do RSA encryption and decryption. - -commit fbf305c09d91bf34b1504b58d50392df2e6bcfba -Author: Guus Sliepen -Date: Sat May 19 22:23:02 2007 +0000 - - Use libevent for meta socket input/output buffering. - -commit 59108e4e4f7aa4632c510d16961edd8c551a6542 -Author: Guus Sliepen -Date: Sat May 19 16:21:52 2007 +0000 - - Use bufferevents to handle control socket buffering. - -commit 8c6131deda546452386f3703af968ee664cadfbd -Author: Guus Sliepen -Date: Sat May 19 15:21:26 2007 +0000 - - Implement "stop" command, and allow tincctl to retrieve a running tincd's PID. - -commit e9043e17c76f92b787c9ecdaf1a2ae7916f690a6 -Author: Guus Sliepen -Date: Sat May 19 14:55:35 2007 +0000 - - Move key generation to tincctl. - -commit bf8e3ce13dba6109757c14dc0013a315a75d2ba3 -Author: Guus Sliepen -Date: Sat May 19 14:13:21 2007 +0000 - - Remove pidfile in favour of control socket. - -commit bc0a24ec810cb911610ae7aafa245e47d1268cd2 -Author: Guus Sliepen -Date: Sat May 19 13:34:32 2007 +0000 - - Fix retrying outgoing connections. - -commit ce976717ea9756aa985699547fdbf132b694748d -Author: Guus Sliepen -Date: Sat May 19 12:07:30 2007 +0000 - - We can safely delete a connection_t in terminate_connection() now. - -commit 01f47c46af514a9d7f39c143e4558a8426a0d3eb -Author: Guus Sliepen -Date: Fri May 18 16:52:34 2007 +0000 - - Start of control socket implementation. - -commit 6ded8a3f089a22c98d2a06b960d65b44e60188d6 -Author: Guus Sliepen -Date: Fri May 18 11:54:16 2007 +0000 - - Update documentation. - -commit 86586594334e951a99845d92baed1966e394aafa -Author: Guus Sliepen -Date: Fri May 18 11:35:21 2007 +0000 - - Show branch version number. - -commit e37ef57a956507cc29e80930201731562b4266e5 -Author: Guus Sliepen -Date: Fri May 18 11:19:31 2007 +0000 - - More consistent variable naming. - -commit 29fbce4497357580fc0aa00f087e8f1a538a2a50 -Author: Guus Sliepen -Date: Fri May 18 10:29:10 2007 +0000 - - Detect duplicate outgoing connections. - -commit fb0cfccf7dc2240b576011edcf74fd5b058916cb -Author: Guus Sliepen -Date: Fri May 18 10:05:26 2007 +0000 - - Use splay trees instead of AVL trees. - -commit f02d3ed3e135b5326003e7f69f8331ff6a3cc219 -Author: Guus Sliepen -Date: Fri May 18 10:00:00 2007 +0000 - - K&R style braces - -commit 760dd966efe7dbff316a8c638e40dee162848256 -Author: Guus Sliepen -Date: Fri May 18 09:51:54 2007 +0000 - - Remove last references to the global variable "running". - -commit 3909b8e51b27b11c6d54541220cb7767bf25569c -Author: Guus Sliepen -Date: Fri May 18 09:43:52 2007 +0000 - - Remove the last bits of the legacy main_loop(). - -commit ddc6a81a854023e38b563f213aa9a449ee91add8 -Author: Guus Sliepen -Date: Fri May 18 09:34:06 2007 +0000 - - Remove global variable "now". - -commit 7e1117197ca4fc62af93fda50e28e0ff06cb736c -Author: Guus Sliepen -Date: Thu May 17 23:57:48 2007 +0000 - - Move key regeneration handling to net_setup.c. - -commit 563577a1479549fa0c20dcda45831a0fff8c7513 -Author: Guus Sliepen -Date: Thu May 17 23:33:07 2007 +0000 - - Use libevent to handle key expiration. - -commit 8852d4407d87cf5dcf2c212d352279015aa050c0 -Author: Guus Sliepen -Date: Thu May 17 23:24:40 2007 +0000 - - Use libevent to age learned MAC addresses. - -commit a530f94e7c4acd94d1cd568b384931eec6f60563 -Author: Guus Sliepen -Date: Thu May 17 23:14:42 2007 +0000 - - Use libevent to age past requests. - -commit aaf1851315023c2f960c58a0d977085a485298e7 -Author: Guus Sliepen -Date: Thu May 17 23:04:02 2007 +0000 - - Redo SIGALRM handling. - -commit 6d19ebd612e6387ba34419cce5cd4d5d861b9a9e -Author: Guus Sliepen -Date: Thu May 17 22:41:34 2007 +0000 - - Use libevent to handle all non-fatal signals. - -commit 531d5a904a3a91bca8b7d373fb6ab2869b31e7fa -Author: Guus Sliepen -Date: Thu May 17 22:17:24 2007 +0000 - - Properly use the timeout_initialized() macro. - -commit bf6490825eabdf4eda6e64f2e5fcd690db7b72ce -Author: Guus Sliepen -Date: Thu May 17 22:13:12 2007 +0000 - - Remove legacy event system. - -commit a67ab277c9fdbcfc8c0550e9046df2a00b5fed81 -Author: Guus Sliepen -Date: Thu May 17 22:09:55 2007 +0000 - - Use libevent for retrying outgoing connections. - -commit 3321591d93d00326eee01fa7c78fb0d56b3d0fba -Author: Guus Sliepen -Date: Thu May 17 22:01:07 2007 +0000 - - Use libevent to send MTU probes. - -commit ee7844905f63872e12cd12f5a3d1a62220594831 -Author: Guus Sliepen -Date: Thu May 17 21:47:27 2007 +0000 - - Configure events after obtaining a socket. - -commit 294ce72441e44c0561556c2984f0e26a74230347 -Author: Guus Sliepen -Date: Thu May 17 21:34:58 2007 +0000 - - Use libevent to handle HUP signal. - -commit 4d0621b1f39537699b0ec4655b0c6e6b84581c9a -Author: Guus Sliepen -Date: Thu May 17 21:14:30 2007 +0000 - - Use libevent to dump graphs when necessary. - event_add() can be called repeatedly, the second and later calls are ignored if - the event hasn't been removed yet. - -commit 0f6f54ff8aa96d981f68b5b71c7126b8fdbead6c -Author: Guus Sliepen -Date: Thu May 17 20:20:10 2007 +0000 - - Use a separate event structure to handle meta data writes. - Make meta socket events persistent. - -commit 17c8033029d50ce4a30b6e3585c0ee28ef45bc97 -Author: Guus Sliepen -Date: Thu May 17 19:52:12 2007 +0000 - - 128 listener sockets is way too much. - -commit d8dea8091fa2260071f775db58ba277d4ce44ea7 -Author: Guus Sliepen -Date: Thu May 17 19:51:26 2007 +0000 - - Properly delete listener socket events on shutdown. - -commit 6ea1dfc995f386b3a9406c7935642524dc755c51 -Author: Guus Sliepen -Date: Thu May 17 19:15:48 2007 +0000 - - Port fixes from release 1.0.8. - -commit cf2be574948fdd02db0503d9639d3b6e268dd4ff -Author: Guus Sliepen -Date: Wed May 16 17:16:09 2007 +0000 - - Releasing 1.0.8. - -commit 6af8900f8e1c7f2fe6a50a991ae6cbd0fd7edd43 -Author: Guus Sliepen -Date: Wed May 16 14:46:25 2007 +0000 - - Don't free struct addrinfo too early. Spotted by Christian Cier-Zniewski. - -commit 31a190dc7db21aa9bb97792563dd83e7c41b831c -Author: Guus Sliepen -Date: Wed May 16 14:42:41 2007 +0000 - - Update dutch translation. - -commit 480dd127c8a539036ff82a3810a0ad83136944f8 -Author: Guus Sliepen -Date: Wed May 16 14:42:08 2007 +0000 - - Make sure connection->name is never NULL. - -commit f0cf4991e2bd0e618c7020511fb12cb0b5c59a40 -Author: Guus Sliepen -Date: Mon May 14 09:21:09 2007 +0000 - - Apply patch from "dnk" making sockets non-blocking under Windows. - -commit 3730156165fd1aa7c8810cd8e390aba6a8badcfa -Author: Guus Sliepen -Date: Mon Mar 12 17:55:43 2007 +0000 - - Only free members of connection_t that have been allocated. - -commit 39f6d59b4b81dc2d754329e6c9f885e8211c5e70 -Author: Scott Lamb -Date: Tue Feb 27 08:13:41 2007 +0000 - - Lots of svn:ignore entries - -commit 38c25d62c2bc76908bd95fb21c8f5e39ad269884 -Author: Scott Lamb -Date: Tue Feb 27 01:57:01 2007 +0000 - - Convert to libevent. - - This is a quick initial conversion that doesn't yet show much advantage: - - We roll our own timeouts. - - We roll our own signal handling. - - We build up the meta connection fd events on each loop rather than - on state changes. - -commit 834290b00f859412ee48bef454a07083cb727130 -Author: Scott Lamb -Date: Tue Feb 27 01:30:57 2007 +0000 - - A couple missed tevent things. - (Sorry; had a couple changes queued.) - -commit 6362b12df725044f3404faceff113e469d8ac860 -Author: Scott Lamb -Date: Tue Feb 27 01:26:11 2007 +0000 - - Rename "event_t" to "tevent_t", along with associated functions. - This relieves some confusion and problems during the libevent transition. - In particular, "event_add" was defined by both. - (The 't' stands for 'timeout', 'tinc', 'temporary', or some such.) - -commit 54431094d95f3989084755fdb91883b24cf5a9f4 -Author: Guus Sliepen -Date: Sat Feb 24 22:50:42 2007 +0000 - - Created the 1.1 branch where large code changes can take place, - at the same time keeping compatibility with 1.0. - -commit ab6f76f6a9fc8028fff96322a52b770710ffa1a9 -Author: Guus Sliepen -Date: Wed Feb 14 09:32:16 2007 +0000 - - Close the proper filedescriptor (if it exists). - -commit 45fca3c723302868de3225e7509d2292008948f7 -Author: Guus Sliepen -Date: Wed Feb 14 09:21:34 2007 +0000 - - Apply patch from Scott Lamb fixing some memory and resource leaks. - -commit 6c6535a4161d04accb3a22c51477e9f92ae34086 -Author: Guus Sliepen -Date: Wed Feb 14 09:20:20 2007 +0000 - - Apply patch from Scott Lamb preventing an infinite loop when sending SIGALRM. - -commit 16c8b0e5bb7c05a0559b2d799a32204bfa0a0e3f -Author: Guus Sliepen -Date: Fri Jan 5 15:03:07 2007 +0000 - - Releasing 1.0.7. - -commit a1e72f84d08b76784c11ff723666ceeaef2756eb -Author: Guus Sliepen -Date: Fri Jan 5 13:18:36 2007 +0000 - - Update copyright notices. - -commit a22ef25f9b81993226a74b193377c7d6baf910ca -Author: Guus Sliepen -Date: Fri Jan 5 13:17:33 2007 +0000 - - No things to do for the 1.0 branch except bugfixing. - -commit d80cc7a5cc918a1dbf8dd789d2125f55c4949d27 -Author: Guus Sliepen -Date: Fri Jan 5 05:44:01 2007 +0000 - - rename() cannot replace existing files on Windows. - -commit 5214ece03009a916159c710cf436af1e92909f41 -Author: Guus Sliepen -Date: Fri Jan 5 04:49:02 2007 +0000 - - Fix generic BSD tun device to write only the actual packet length. - Due to a copy&paste bug, it tried to write a packet with the maximum size. - This was not a problem until the maximum size was increased to support VLANs. - -commit 40f02ff8eee359dc0ccc898f8da319f56af161ad -Author: Guus Sliepen -Date: Thu Jan 4 15:28:36 2007 +0000 - - Tapreader socket should be bound to localhost only. - -commit 03f3fc01e8d9402c4a14904fded883ff8cc574f6 -Author: Guus Sliepen -Date: Wed Jan 3 18:18:54 2007 +0000 - - Use a ringbuffer in shared memory to transfer packets from the tapreader thread to the main thread. - It's a wonder it ever worked before. The socket that is created is not of a - datagram type, therefore packet boundaries were not preserved, which becomes - a problem as soon as the TAP-Win32 device receives packets in fast succession. - -commit 52787a73b0211bcb4cb3cdd308b1a4c53a60f8ce -Author: Guus Sliepen -Date: Mon Dec 18 17:38:05 2006 +0000 - - Releasing 1.0.6. - -commit b32c22cf54e47677726d15a5fca7eecc2fa42754 -Author: Guus Sliepen -Date: Mon Dec 18 11:41:53 2006 +0000 - - Prevent compiler warnings about redefinition of EAI_FAMILY on FreeBSD 6.1. - -commit 855806b2f75fc1c566cfaac01c788cdc625b4687 -Author: Guus Sliepen -Date: Sat Dec 16 16:53:58 2006 +0000 - - Do a simple test for linux/if_tun.h instead of no test at all. - -commit 0322c0883b76257c0893aa75a510e264056ac15b -Author: Guus Sliepen -Date: Sat Dec 16 16:40:09 2006 +0000 - - Remove the test for linux/if_tun.h. - It has been available for years on any decent Linux distribution. - Although linux/if_tun.h is now required to compile tinc, - you can still run it on systems which only support Ethertap. - -commit b55813dc0b4a6a1f70c0f8d5f0512c8cebb4a5ba -Author: Guus Sliepen -Date: Sat Dec 16 16:34:04 2006 +0000 - - We do properly check for malloc and realloc. - -commit 5219ee25a248fe26055e54215c5027cbf8483439 -Author: Guus Sliepen -Date: Sat Dec 16 16:26:57 2006 +0000 - - Use standard autoconf macros instead of our own. - -commit 9d469a19691f9749b5d729a1ae903d7aa224a6e8 -Author: Guus Sliepen -Date: Sat Dec 16 16:26:08 2006 +0000 - - Fix rule that creates html version of manpages. - -commit dd03a003962788eb21910c3faabbda0e84eff5eb -Author: Guus Sliepen -Date: Fri Dec 15 20:44:33 2006 +0000 - - Remove old Spanish translation. - -commit 031e09f865e2c634f30fb0ed4e0b6a1f6df57588 -Author: Guus Sliepen -Date: Fri Dec 15 20:43:39 2006 +0000 - - Remove unnecessary stuff from configure.in. - -commit b834d67d7cc7d7f5d8b729b340ec0c809c7d54b6 -Author: Guus Sliepen -Date: Tue Dec 12 14:54:39 2006 +0000 - - Use the correct next pointer. - -commit 8b55dfacb199d152391aa5f7adbbbe35bceea7d7 -Author: Guus Sliepen -Date: Tue Dec 12 14:49:09 2006 +0000 - - When building the minimum spanning tree, make sure we start from a reachable node. - -commit 47d916ec5eb61fa396c0ec6962afed7885141478 -Author: Guus Sliepen -Date: Wed Nov 29 17:18:39 2006 +0000 - - Search for lzo/lzo1x.h, lzo2/lzo1x.h and lzo1x.h. - -commit 1bb5a284fec8c538f8ba243d4f9b2e46f68cd7e8 -Author: Guus Sliepen -Date: Wed Nov 29 16:57:46 2006 +0000 - - Make sure resolved addressed for outgoing connections are freed, if there are any. - -commit 5c69c390a17fc2b37218881e7285b639b79cfc5a -Author: Guus Sliepen -Date: Tue Nov 14 15:43:28 2006 +0000 - - Releasing 1.0.5. - -commit e5b1b5cefb82531e8a700c2ee251da1bb0a06fbf -Author: Guus Sliepen -Date: Tue Nov 14 12:28:04 2006 +0000 - - EWOULDBLOCK does not exist on platforms without O_NONBLOCK - -commit 3353ab37c2d6fb3652fbf7a85d85997be1c0c1b5 -Author: Guus Sliepen -Date: Sat Nov 11 22:45:45 2006 +0000 - - When deleting an entire tree, start at head, not at root. - -commit 0714ac6c59099a398e67770ad9c72fcec615812b -Author: Guus Sliepen -Date: Sat Nov 11 22:44:15 2006 +0000 - - Nodes use events, so event system should be initialised first and destroyed last. - -commit 35e4096120236db8d64a767f1ccdd6bf03a091fc -Author: Guus Sliepen -Date: Sat Nov 11 21:37:22 2006 +0000 - - Update Dutch translation. - -commit 315ef3e42bf16e03cfbea763442a52389a16b832 -Author: Guus Sliepen -Date: Sat Nov 11 20:37:58 2006 +0000 - - Document GraphDumpFile option. - -commit 8d393b30a922110ec77d5b243347416b50cd2160 -Author: Guus Sliepen -Date: Sat Nov 11 20:10:46 2006 +0000 - - Support and autodetect LZO version 2.0 and later. - -commit bdb3c24cea06e9557738b42e3c37cd036613b58d -Author: Guus Sliepen -Date: Sat Nov 11 20:06:14 2006 +0000 - - Support and autodetect LZO version 2.0 and later. - -commit 0d1ac68c59db87141616f69bcd3d79c705b1ecd0 -Author: Guus Sliepen -Date: Sat Nov 11 14:37:03 2006 +0000 - - popen() requires pclose(). - -commit 0200d3cd5d773d9b101c33264532d2a301c2af32 -Author: Guus Sliepen -Date: Sat Nov 11 14:11:16 2006 +0000 - - Added graph dumping ability based on Markus Goetz's patch. - -commit 1728d5b2c43b33700a9997f97fe8503ad1cf3585 -Author: Guus Sliepen -Date: Sat Nov 11 13:43:00 2006 +0000 - - The "active" bit in node.status is not used. - -commit 134dc8995b296b0bd8b346617c705204b0f3125c -Author: Guus Sliepen -Date: Wed Aug 9 22:31:10 2006 +0000 - - memcpy() addresses from packet headers before calling the lookup functions. - This probably fixes a problem on the ARM architecture that causes tinc to fail to lookup IPv4 addresses. - -commit 64e0519cb5042b251e7345f07429e8b82e2ac09b -Author: Guus Sliepen -Date: Tue Aug 8 13:50:58 2006 +0000 - - Remove unused variable. - -commit ddcf079cad3351f0823fc07af15787d02e5f1901 -Author: Guus Sliepen -Date: Tue Aug 8 13:44:37 2006 +0000 - - Remove unused parameter from maskcmp(). - -commit c620df3c1511643aa533ca31afc17db75b7255b8 -Author: Guus Sliepen -Date: Tue Aug 8 13:44:19 2006 +0000 - - Remove unused variables. - -commit 9fa27097dd82e20299f5277ecb4efffb4a99669c -Author: Guus Sliepen -Date: Tue Aug 8 13:29:17 2006 +0000 - - Fix format string warnings. - -commit eb391c52eed46f3f03b404553df417851fc0cb90 -Author: Guus Sliepen -Date: Tue Aug 8 13:21:08 2006 +0000 - - Do not break strict aliasing of status_t structs. - -commit 2077451e07f93edc520cf5bc31815624a2b03fdd -Author: Guus Sliepen -Date: Mon Jun 12 21:45:39 2006 +0000 - - Add generic host-up and host-down scripts. - Thanks to Menno Smits for a patch. - -commit f88c9942e1e3d4d463ec71ba5a60d045381bda8f -Author: Guus Sliepen -Date: Sun Jun 11 18:53:27 2006 +0000 - - Use memcpy() to copy sockaddrs returned by getaddrinfo(). - Thanks to Miles Nordin for spotting this. - -commit 412f3fb5101514d9a7d4d9e5729ee9c665a07cb6 -Author: Guus Sliepen -Date: Wed Apr 26 16:29:47 2006 +0000 - - Restore length of the original packet in send_udppacket(). - -commit de78d79db84c486afcc353884ec1770866beb653 -Author: Guus Sliepen -Date: Wed Apr 26 13:52:58 2006 +0000 - - Update copyright notices, remove Ivo's email address. - -commit 8ebb017a10cd85406ddf5ab60d8ef1f56df526ff -Author: Guus Sliepen -Date: Wed Apr 12 08:38:35 2006 +0000 - - Fix a bug in handling prefixlengths that are not a multiple of 4. - Thanks to Sven-Haegar Koch for spotting the bug and providing the fix. - -commit af95368c0f30955f0e13b587d5d6d4989fd5a83e -Author: Guus Sliepen -Date: Sun Mar 19 13:06:21 2006 +0000 - - Fix signedness compiler warnings. - -commit fb1cda2ca4ca74a85e88c39c11b97340e6495a08 -Author: Guus Sliepen -Date: Sun Mar 19 12:43:45 2006 +0000 - - Export flush_meta(). - -commit 098090468a9e1e8c5cdb0aeefa277329ff5f3406 -Author: Guus Sliepen -Date: Sun Mar 19 12:43:28 2006 +0000 - - Missing #include. - -commit a90f1b652c0fb52950f3b0783a7e2b7f2e0cf2db -Author: Guus Sliepen -Date: Mon Feb 6 12:30:51 2006 +0000 - - Make sure $NAME is set correctly when executing tinc-down script. - -commit 228e7a5c8f0e517dcede50f886965a44fca39853 -Author: Guus Sliepen -Date: Thu Jan 19 17:13:18 2006 +0000 - - Apply patch from Scott Lamb adding an output buffer for the TCP sockets. - This helps coalescing multiple send_meta() commands into one TCP packet. - Also limit the size of the output buffer before dropping PACKETs. - -commit a5a4d2b865879b8694760c0a5b5909c9a3675027 -Author: Guus Sliepen -Date: Fri Jan 13 11:21:59 2006 +0000 - - Apply patch from Scott Lamb unifying configuration of TCP socket options. - -commit e02f13cdb3133c33ac84d9582e2f47ca5ebd35bf -Author: Guus Sliepen -Date: Fri Jan 13 11:09:19 2006 +0000 - - EVP_Cleanup() when quitting. - -commit 0912260755021b9b836830dd99ae128c5fd912d9 -Author: Guus Sliepen -Date: Wed Nov 16 10:45:11 2005 +0000 - - Enable OpenSSL ENGINE, so crypto hardware gets used. Thanks to Andreas van Cranenburgh. - -commit 64e4c12778697f71ad3fcf33ee6cf1066322caa5 -Author: Guus Sliepen -Date: Fri Jun 3 10:56:02 2005 +0000 - - Add alloca.h to the list of necessary header files. - -commit e810545dc2ae158745624c1575b76c55f883c892 -Author: Guus Sliepen -Date: Fri Jun 3 10:16:03 2005 +0000 - - Prevent possible buffer overflows when using very large (>= 8192 bit) RSA keys. - Thanks to Tonnerre Lombard for noticing! - -commit 02746165a21a4a495d0069526c9a2355110a5784 -Author: Guus Sliepen -Date: Wed May 4 19:38:28 2005 +0000 - - Releasing 1.0.4. - -commit df3220a1549f992cbf4a9b6e67c1e67b69896c7d -Author: Guus Sliepen -Date: Wed May 4 18:09:30 2005 +0000 - - Update copyright notices. - -commit 54a30e30ad41d7c0e73fcc4e6ff23c3e85af75c4 -Author: Guus Sliepen -Date: Wed May 4 16:53:11 2005 +0000 - - Describe subnet-up/down scripts in documentation. - -commit bded1b74cc23c60e7319ed9e7465413b94a7914e -Author: Guus Sliepen -Date: Wed May 4 15:56:25 2005 +0000 - - Several splay tree fixes. - -commit faaaa1ef38dcdf19d5d5d73ab66806b15467c043 -Author: Guus Sliepen -Date: Wed May 4 15:52:55 2005 +0000 - - Searching through splay trees may change the tree variable. - -commit dc09f6fe896f5e35fffe8cc2004781b2e1b6fd5a -Author: Guus Sliepen -Date: Wed May 4 15:51:45 2005 +0000 - - Be on the safe side with initialisation of c->name. - -commit 92c4a28d7d43b68a324cf2eca741298ed6b692d6 -Author: Guus Sliepen -Date: Wed Apr 6 20:43:37 2005 +0000 - - Remove unused (and potentially segfaulting) net2str() call. - -commit 6363ed4d9c675b8b9301b694c4e4dd9c892e04e2 -Author: Guus Sliepen -Date: Thu Jan 20 15:14:25 2005 +0000 - - Don't try to add a non-existing node back to the node_udp_tree. - -commit 39fe3b445c2f20b325ee492dd1845877777b25c8 -Author: Guus Sliepen -Date: Tue Jan 4 22:19:56 2005 +0000 - - Nodes should only be in the node_udp_tree if they are reachable. - -commit fe0bfa3e65049d6e7cd46cf6caea7eb91b478008 -Author: Guus Sliepen -Date: Tue Jan 4 22:18:58 2005 +0000 - - Correct size argument for strncat(). - -commit 56c36a14d87b58c14dbc48df4d3d977207e2c06e -Author: Guus Sliepen -Date: Fri Dec 3 13:27:33 2004 +0000 - - Use the proper free function. - -commit 18c617ecf29b9dfb95227e764c76fff0f9d7af96 -Author: Guus Sliepen -Date: Fri Dec 3 13:22:18 2004 +0000 - - Free memory used by connection_t after it is deleted from the connection tree. - -commit 672ad5634cbedfbd6345e887935eed3e806f1e2d -Author: Guus Sliepen -Date: Wed Dec 1 21:26:51 2004 +0000 - - Small fix. - -commit 40b1692940a8d588c08fb6b8f24ded7c33b041b1 -Author: Guus Sliepen -Date: Wed Dec 1 20:06:39 2004 +0000 - - subnet-up/down hooks, use list_t for the todo list. - -commit c46f56a8b8bb865dd8951441b5acf4701b5b5b09 -Author: Guus Sliepen -Date: Wed Dec 1 20:06:05 2004 +0000 - - subnet-up/down hooks - -commit f08baa3072e7cd6cee7a2a7cde35b46c85363baf -Author: Guus Sliepen -Date: Thu Nov 18 20:34:48 2004 +0000 - - Fix splay tree code. - -commit 0077cfaae112b63d6af6aa1e5d079cebdde84b74 -Author: Guus Sliepen -Date: Tue Nov 16 19:02:54 2004 +0000 - - Make sure broadcast packet reach the local network interface. - -commit 79c48cfafd75dfc86a382f6454a9f009d3c099b6 -Author: Guus Sliepen -Date: Thu Nov 11 19:42:25 2004 +0000 - - Releasing 1.0.3. - -commit 2771691bfc85b2544b30ccaee8a709bd26c7e1ab -Author: Guus Sliepen -Date: Thu Nov 11 19:39:28 2004 +0000 - - Add more people who have contributed to tinc. - Remove details and sort on name; - the details were not always equally accurate and are hard to maintain. - -commit 4f3f6f07b234b4abd32bf3bae1be0551bc7dd9dc -Author: Guus Sliepen -Date: Thu Nov 11 11:17:04 2004 +0000 - - Short readme about how to compile tinc from a Subversion checkout. - -commit 704c3707c2c400b7e35ef4ac2c1d21e0f2de0187 -Author: Guus Sliepen -Date: Wed Nov 10 23:28:32 2004 +0000 - - Updated dutch translation. - -commit a20eb05714f828be7dc0f78c1a07f218a3482dff -Author: Guus Sliepen -Date: Wed Nov 10 23:21:41 2004 +0000 - - Remove duplication. - -commit d8fe2ecdd8dc5caf6f8d6acf2923a0baed64735f -Author: Guus Sliepen -Date: Wed Nov 10 23:20:59 2004 +0000 - - Set BSD tuns to broadcast mode. On OpenBSD, this enables IPv6 on the tun device! - -commit 2369b0ab09a008c519cd4307b634fd294c66014e -Author: Guus Sliepen -Date: Wed Nov 10 21:57:04 2004 +0000 - - Update documentation. - -commit 4fe7aff4d1b8605d4997b842481cc78bd062fe2a -Author: Guus Sliepen -Date: Wed Nov 10 21:56:31 2004 +0000 - - Add BlockingTCP option, useful when using TCPOnly on slow or congested links. - -commit 5bba3124c8c23568def7a4804651a53f3a6b4fd2 -Author: Guus Sliepen -Date: Wed Nov 10 21:14:08 2004 +0000 - - Support tunneling IPv6 on Solaris. - -commit d02d81ff9dbb12253957065752c56785aedccee3 -Author: Guus Sliepen -Date: Wed Nov 10 19:36:02 2004 +0000 - - Let compiler decide when to inline. - -commit db68db4b0e0f8b776f2d3dc938fb81dac975fdd8 -Author: Guus Sliepen -Date: Wed Nov 10 19:34:38 2004 +0000 - - Fix order of arguments for tar. - -commit 923abcfa35c7282251d507af83d6163df76c943b -Author: Guus Sliepen -Date: Wed Nov 10 18:11:44 2004 +0000 - - Use the generic BSD tun/tap code. - -commit e8b11b1cca11f7f50542a7b34f4251f43447db0d -Author: Guus Sliepen -Date: Wed Nov 10 18:10:59 2004 +0000 - - Missing check for NULL-pointer. - -commit ca7948fc06fd0495dc8104d7f55948f702ac09e2 -Author: Guus Sliepen -Date: Tue Nov 9 09:51:35 2004 +0000 - - Hopefully this really fixes late packet handling. - -commit f7b9761000000063bd00460af4b57117db7361e4 -Author: Guus Sliepen -Date: Mon Nov 8 22:30:13 2004 +0000 - - Fixed another bug in late packet handling. - -commit 14eab178295768311d4518289533005991add8ba -Author: Guus Sliepen -Date: Mon Nov 8 22:11:33 2004 +0000 - - Update to make it compile again. - -commit 804b2892a5e26a2dc46d19397cc8b321b43b8add -Author: Guus Sliepen -Date: Mon Nov 8 22:03:28 2004 +0000 - - Hoopjumping to get the default directories in the manuals properly. - -commit 719cb95ea4fa7a2e6f4291aed607323f290c7a91 -Author: Guus Sliepen -Date: Tue Nov 2 20:50:53 2004 +0000 - - Splay trees. - -commit 2af1538976c9c85c40becfdd8601b421ad2ab057 -Author: Guus Sliepen -Date: Mon Nov 1 17:05:09 2004 +0000 - - Don't include .svn directory in sample configuration. - -commit dced64c5c3625f6d2f0674e9fed14455aabc635e -Author: Guus Sliepen -Date: Mon Nov 1 17:04:28 2004 +0000 - - Check for sys/uio.h, net/if_tun.h and net/if_tap.h - -commit 1f00810da336f3b7132df17b7fe4625748ff4b63 -Author: Guus Sliepen -Date: Mon Nov 1 17:02:19 2004 +0000 - - static - -commit 82b29e9a3b1dc6b2104ab92ed78bf431a4e55649 -Author: Guus Sliepen -Date: Mon Nov 1 17:01:56 2004 +0000 - - Generic device driver for *BSD and MacOS/X - -commit 922e5b7beaad5bb3fcbfa6b8dd13c05bda29e5fa -Author: Guus Sliepen -Date: Mon Nov 1 15:18:53 2004 +0000 - - Support alternative tun/tap driver from http://www-user.rhrk.uni-kl.de/~nissler/tuntap/ - -commit faff6498821555e6afb3dc5e4e3b61d448a4fef1 -Author: Guus Sliepen -Date: Mon Nov 1 15:18:22 2004 +0000 - - Don't let tinc service depend on NDIS component. - -commit 396ac4be802f8b75c5a2ab5925925427c61c1da3 -Author: Guus Sliepen -Date: Mon Nov 1 15:16:12 2004 +0000 - - Correct return value. - -commit 58153cca98fd43c37ae52d3cf69474c3d736c431 -Author: Guus Sliepen -Date: Fri Oct 1 18:26:15 2004 +0000 - - Allow tinc to work with the latest TAP-Win32 driver. - -commit 6411e0d8bda8abc2cef87ca852255502f9bb03d0 -Author: Guus Sliepen -Date: Fri Oct 1 18:24:41 2004 +0000 - - strndupa() is too arcane for some environments. - -commit b0a80007e8945a11d7ce25aab096c5ee58ce0ad5 -Author: Guus Sliepen -Date: Fri Oct 1 18:23:08 2004 +0000 - - Fix several #includes. - -commit 2c40495747945bc497dac65b734a4995ab3400a3 -Author: Guus Sliepen -Date: Fri Oct 1 18:22:06 2004 +0000 - - Move all #ifdef HAVE_HEADER_H #include to have.h, - this allows for simplification of configure.in. - -commit 7717cb0c54cc1b736b9f210b180c3cb3f4663ded -Author: Guus Sliepen -Date: Mon Sep 20 20:56:14 2004 +0000 - - Remove duplicate #include "system.h" - -commit 5373129344d349ff6aeb2b3d21f947f5ecbbcfaf -Author: Guus Sliepen -Date: Mon Sep 20 20:55:49 2004 +0000 - - Marking potential late packets was in the wrong place. - -commit c44f69a30243a94ab93bd15915dbfa71db698bde -Author: Guus Sliepen -Date: Sat Jul 17 12:04:30 2004 +0000 - - Don't set $INTERFACE automatically, don't quit on EINTR/EAGAIN. - -commit dcec713675b604f5ef82e64d0671727e3f5ea518 -Author: Guus Sliepen -Date: Sat Jul 17 00:09:14 2004 +0000 - - Added UML network socket handling. - Now you can use tinc instead of uml_switch. - -commit fe84fafcb684391739a1b3366705c58683210392 -Author: Guus Sliepen -Date: Mon Jun 21 14:37:52 2004 +0000 - - Handle timeouts during connecting the same way as other errors. - -commit e5e0dd7534be5fb96032fb733ca36a09cb067f17 -Author: Guus Sliepen -Date: Mon Jun 14 14:32:10 2004 +0000 - - Clean up environment after executing scripts. - -commit 9e44f116bf0f72d1dd4f099440a351dbe0a74573 -Author: Guus Sliepen -Date: Thu Apr 15 14:09:56 2004 +0000 - - Increase MTU by 4 bytes to allow VLAN tagged Ethernet frames in hub and switch mode. - -commit 7926a156e5b118d06295228e57de0cc9de0433b4 -Author: Guus Sliepen -Date: Sun Mar 21 14:21:22 2004 +0000 - - Update copyrights, links, email addresses and let Subversion update $Id$ keywords. - -commit 42e01abd54bd36ee84a45a2b646cfa27034de8d1 -Merge: 5ca64f89 af86a322 -Author: Guus Sliepen -Date: Sun Mar 21 13:22:24 2004 +0000 - - Move CABAL branch to its rightful place: the trunk. - -commit af86a3226ea42375644b3f99c182c778d327de1e -Author: Guus Sliepen -Date: Sat Mar 20 22:23:42 2004 +0000 - - Revert Martin Kihlgren's patch, it doesn't work the way it should. - -commit 27c304940a5dbe83fb0f655c5c43150bafed3b63 -Author: Guus Sliepen -Date: Sat Mar 20 15:40:26 2004 +0000 - - Use Subversion to create ChangeLog, better svn-clean rule. - -commit 8df22248293a8cd5e6056415b6e08740e40aa2bc -Author: Guus Sliepen -Date: Sat Mar 20 15:33:07 2004 +0000 - - Fix declaration of update_node_address(). - -commit 56aad1bb486675ff9aba31418708cc179eea0381 -Author: Guus Sliepen -Date: Sat Mar 20 15:28:55 2004 +0000 - - Applied Martin Kihlgren's IdentityGenerosity patch, - simplified and renamed to StrictSource. - -commit 8c189c2a9b77fb326ab5f27a05bf2601e16af017 -Author: Guus Sliepen -Date: Mon Mar 15 19:09:52 2004 +0000 - - Even better svn-clean command. - -commit b05df3fcbfb8dbef4c87691d118c5b68aeb79e4a -Author: Guus Sliepen -Date: Mon Mar 15 18:36:14 2004 +0000 - - Updating dutch translation. - -commit a92c471a2bc0773a7473ef0361d1a51fafee50d4 -Author: Guus Sliepen -Date: Mon Mar 15 18:15:02 2004 +0000 - - Only read our public key if it wasn't already in the private key file. - -commit a67a21ef3c17d32af95373e921138429a7fc507e -Author: Guus Sliepen -Date: Mon Mar 15 18:05:41 2004 +0000 - - Eat trailing whitespace in config files. - -commit 4350704d6578656af98195b26006c6b6d6a798e3 -Author: Guus Sliepen -Date: Mon Mar 15 17:54:19 2004 +0000 - - Remove CVS related cruft. - -commit 538595f7350ba6c7d11aba7d9f481ea1641e1857 -Author: Guus Sliepen -Date: Mon Mar 15 17:53:17 2004 +0000 - - Replace cvs-clean with a much better svn-clean. - -commit 5ca64f89be71131e77a29661827dc8866a5f278c -Author: cvs2svn -Date: Sat Jan 10 23:21:36 2004 +0000 - - This commit was generated by cvs2svn to compensate for changes in r1352, - which included commits to RCS files with non-trunk default branches. - -commit fcd836c609568fab323f4af6dd525de957a6f4cc -Author: Guus Sliepen -Date: Sat Jan 10 23:21:36 2004 +0000 - - Remove autogen.sh, the autoreconf program does exactly that. - Update everything for the latest autoconf and automake versions. - -commit f2aa7466e6db9777090583ef26d923fc0a4fcea8 -Author: Guus Sliepen -Date: Sat Jan 10 23:19:20 2004 +0000 - - Small updates. - -commit 519d63bedbdcc533dd7839aae02b4d7bc2debfb0 -Author: Guus Sliepen -Date: Sat Dec 27 16:32:52 2003 +0000 - - Don't forget to update destination MAC address. - -commit aebc97a77f37ec63fbd36721f9b284c975e54270 -Author: Guus Sliepen -Date: Wed Dec 24 10:48:15 2003 +0000 - - Small fixes for PMTU discovery. - -commit 2c7ce7de12d16cb407fd40224b6cb802528ee942 -Author: Guus Sliepen -Date: Mon Dec 22 11:05:23 2003 +0000 - - Missing definitions. - -commit 35399784b695c9ac692beba7be7930ee9f24412f -Author: Guus Sliepen -Date: Mon Dec 22 11:04:17 2003 +0000 - - Improvements for PMTU discovery and IPv4 packet fragmentation. - -commit 6d41b429a26dd1acaa7c56b2124f2daf55b5b97c -Author: Guus Sliepen -Date: Sat Dec 20 21:25:17 2003 +0000 - - Better name, show probed MTU in dump. - -commit af490a745d4ddc8994ceca546b5f9139f6a6ebe2 -Author: Guus Sliepen -Date: Sat Dec 20 21:20:10 2003 +0000 - - Describe the TunnelServer and PMTUDiscovery options. - -commit 9bab08e972ae0ca4b904a659d9aed46aaa9b5dd5 -Author: Guus Sliepen -Date: Sat Dec 20 21:09:33 2003 +0000 - - More sensible name, and try to set PMTU discovery on IPv6 sockets as well. - -commit 6b12bea62fe2e4bd8b5b6bd0e5ca7f53318705db -Author: Guus Sliepen -Date: Sat Dec 20 19:47:53 2003 +0000 - - Let tinc figure out the exact MTU of the link. - -commit e8fbef5de653e4df35eee49aae6e1ac92d6466e6 -Author: Guus Sliepen -Date: Sat Dec 13 21:50:26 2003 +0000 - - Forget multicast. Always inline some function. - -commit 5a1406adefd8b51981af0da5ac0ebec830eb43b4 -Author: Guus Sliepen -Date: Fri Dec 12 19:52:25 2003 +0000 - - Code beautification, start of multicast support. - -commit 354b7ab20e04736b368985a9e9dfd54ff5b7584e -Author: Guus Sliepen -Date: Mon Dec 8 12:00:40 2003 +0000 - - Fix proxy-neighborsolicitation. - -commit 331cef948db4b3cca245ab62cb0fafb5b1e5ebb3 -Author: Guus Sliepen -Date: Sun Dec 7 14:31:09 2003 +0000 - - Don't retry if configuration is wrong from the beginning. - -commit a3cd273751fdcef90a43108a5d2e669877b0bccb -Author: Guus Sliepen -Date: Sun Dec 7 14:29:02 2003 +0000 - - Missing space between words. - -commit 25447b384173cc3c99660c784fd784c787917e80 -Author: Guus Sliepen -Date: Sun Dec 7 14:28:39 2003 +0000 - - Read MaxTimeout from tinc.conf like the manpage says. - -commit 0b5e6cf04ec0c7e3c54c74a54a32b30e6e3c1f83 -Author: Guus Sliepen -Date: Thu Nov 27 23:24:59 2003 +0000 - - Complain if pid file cannot be created. - -commit e3220cacb5bc79fc56167e61b7a342f88a33a479 -Author: Guus Sliepen -Date: Mon Nov 17 15:30:18 2003 +0000 - - Replace Opaque and Strict options with a TunnelServer option. - -commit 0e59fb022c6c015a5be7ed70e0378cb011be98b5 -Author: Guus Sliepen -Date: Mon Nov 10 22:31:53 2003 +0000 - - Add Opaque option which prevent information from being forwarded to certain nodes. - -commit a8f415e67fd316d929f9b9e6661e0d3d66fc197b -Author: Guus Sliepen -Date: Sat Nov 8 15:29:40 2003 +0000 - - Release notes for 1.0.2 - -commit 507a83c74635955f803bb26c450f3e83dd4809f9 -Author: Guus Sliepen -Date: Sat Nov 8 15:09:03 2003 +0000 - - Add missing definitions. - -commit 0271de0e80459bdebcac50d38c053d4aaf657e9a -Author: Guus Sliepen -Date: Sat Nov 8 12:56:24 2003 +0000 - - Update dutch translation. - -commit d35a510fff65a7a3318036f27c11b956526b26f6 -Author: Guus Sliepen -Date: Sun Oct 12 11:40:00 2003 +0000 - - Fix another bug in meta.c. - -commit e88ea7277a97d46fa2c3ba1896cf0d0c62bdf128 -Author: Guus Sliepen -Date: Sat Oct 11 14:42:30 2003 +0000 - - Small fixes in documentation. - -commit ffb7327c20952cefcb5578e40f9802295172c5c2 -Author: Guus Sliepen -Date: Sat Oct 11 14:18:52 2003 +0000 - - Fix bug that could lead to an assertion failure in libcrypto when multiple - requests arrive and TCP packets are heavily fragmented. - -commit 258b7ce220607bb3f2a24bb7cab5fcd19e82314a -Author: Guus Sliepen -Date: Sat Oct 11 12:28:48 2003 +0000 - - Parentheses in the wrong spots. - -commit a1ab57e2755df6c1a8fab95a0886fea368200b96 -Author: Guus Sliepen -Date: Sat Oct 11 12:16:13 2003 +0000 - - Check all EVP_ function calls. - -commit b0dd705a264f0f72a7afba6de85200598cbe083b -Author: Guus Sliepen -Date: Fri Oct 10 16:24:24 2003 +0000 - - Check return value of EVP_* functions, and check if length before en/decryption - matches that after in meta.c. - -commit 9d2bf718f233672c11a9740ed2a1539eaab1509b -Author: Guus Sliepen -Date: Fri Oct 10 16:23:30 2003 +0000 - - Fix ASCII art. - -commit e33307fc9f5354933554d26de618db1b08fc04c0 -Author: Guus Sliepen -Date: Thu Oct 9 21:33:15 2003 +0000 - - Update documentation. - -commit 98edfb14fcc7167d24d440ed2772d0755daac3b7 -Author: Guus Sliepen -Date: Wed Oct 8 12:09:37 2003 +0000 - - Some platforms don't know sa_family_t or define it other than uint16_t. - -commit f2ebdf75806d8c04138db0eb30727f846541ed75 -Author: Guus Sliepen -Date: Wed Oct 8 11:37:53 2003 +0000 - - Set media status for newer TAP-Win32 driver. - -commit acf5f9c968d17ad3e31129d2184309de06d72eed -Author: Guus Sliepen -Date: Wed Oct 8 11:37:20 2003 +0000 - - Missing declaration. - -commit 1d7706a8506d8073def0965da809960c6ad8bf9a -Author: Guus Sliepen -Date: Wed Oct 8 11:34:55 2003 +0000 - - Update missing definitions, structs describing headers get __packed__ attribute. - -commit 5b556c0971e847580b85268e57f0b29dbde5499c -Author: Guus Sliepen -Date: Wed Oct 8 11:33:54 2003 +0000 - - Forgot to #include "xalloc.h" - -commit ad39db95fecf760297b4e320ef2f6d6d9fdad605 -Author: Guus Sliepen -Date: Mon Oct 6 16:49:42 2003 +0000 - - Make sure type of AF_UNKNOWN is sa_family_t. - -commit 5900c07fab39d2833ea66429ad652ca49a91a508 -Author: Guus Sliepen -Date: Mon Oct 6 16:13:08 2003 +0000 - - PIDs are of type pid_t, and use %ld when reading/writing them to the pidfile. - -commit e898b930dcd0694a49dc8cdcf373e0fc125c9fde -Author: Guus Sliepen -Date: Mon Oct 6 16:05:30 2003 +0000 - - Use CPPFLAGS, LDFLAGS and LIBS as appropiate. - -commit 6350334aa44f85e737c1eb0b55e0392766aa1e84 -Author: Guus Sliepen -Date: Mon Oct 6 14:41:45 2003 +0000 - - Don't confuse users with "Address family not supported" warnings. - -commit 0842998c0bd46855d198923acc2c13cff7430ffe -Author: Guus Sliepen -Date: Mon Oct 6 14:33:04 2003 +0000 - - Unused variable in struct. - -commit 77cb10dac0abbfa4389a7588f51797152d91ac22 -Author: Guus Sliepen -Date: Mon Oct 6 14:16:51 2003 +0000 - - Ethernet protocol types. - -commit c97b8827ed34284535706e8017c962ff8f3a4383 -Author: Guus Sliepen -Date: Mon Oct 6 13:57:12 2003 +0000 - - const - -commit 60943122f7b3a5896ce64c9000e119931484c12c -Author: Guus Sliepen -Date: Mon Oct 6 13:49:57 2003 +0000 - - Copy structs from packets to the stack before using them, to prevent - alignment issues. - -commit 5713fb07b3e831b78d8841d56a53c2a2698fe738 -Author: Guus Sliepen -Date: Wed Oct 1 09:43:01 2003 +0000 - - Add description of new authentication scheme. - -commit acbb9d6692614539260749c7b763eca5a6f81f07 -Author: Guus Sliepen -Date: Wed Oct 1 09:14:01 2003 +0000 - - Better length checks. - -commit eeb97e3ef4eb9089851f7b71d5393df24313c993 -Author: Guus Sliepen -Date: Thu Sep 25 10:34:16 2003 +0000 - - Generate keys with 0x10001 as public exponent, which has less prime factors - than 0xFFFF. - -commit 288d956728ab4d4aabe9bc59b87991420dbda151 -Author: Guus Sliepen -Date: Tue Sep 23 20:59:01 2003 +0000 - - Check for short packets from the tun/tap device and from other tinc daemons. - -commit 4e80612ac0f38daa0f2280c293427c7f25dac278 -Author: Guus Sliepen -Date: Tue Sep 9 15:47:59 2003 +0000 - - Update translations. - -commit cbf5a741aa2af937b3db606f0894990703f77bcb -Author: Guus Sliepen -Date: Mon Sep 8 21:52:47 2003 +0000 - - Remove pidfile when exitting. - -commit 0dba26267c76982a422984b61a3196ed2cd2b04a -Author: Guus Sliepen -Date: Wed Sep 3 16:20:33 2003 +0000 - - Prevent multiple inclusions. - -commit 6c5f3d8b74ffea1522a727ef189a5ba65a939e07 -Author: Guus Sliepen -Date: Thu Aug 28 21:05:11 2003 +0000 - - We don't have to tell GCC how to cast. - -commit 762cc2d2797d62ab593ea64d8ceeb4fe96be2a0d -Author: Guus Sliepen -Date: Thu Aug 28 15:27:12 2003 +0000 - - Remove old edges from unreachable nodes to us. This prevents the hosts/NAME-up - script from being called twice in some situations. - -commit a6dc69e7f30522bf885714f6b663960b6fbfff6a -Author: Guus Sliepen -Date: Wed Aug 27 13:58:29 2003 +0000 - - Forgot to synchronise po/ directory... - -commit 62349da6f2617c7250a77af6610344ec0dbfc4f2 -Author: Guus Sliepen -Date: Wed Aug 27 13:57:04 2003 +0000 - - Makevars file was accidentily removed. - -commit dc3b7d47f3297e22161787a1d6e06205140cf0fb -Author: Guus Sliepen -Date: Wed Aug 27 13:47:52 2003 +0000 - - Some device.c files weren't synchronised. - -commit 9e81a6ab5f50df4f5ca36d5303b91a8d5a0e753e -Author: Guus Sliepen -Date: Sun Aug 24 20:50:30 2003 +0000 - - This will become 2.0. - -commit 013a2e159e42c46808ea8d0b6abd57525db30a50 -Author: Guus Sliepen -Date: Sun Aug 24 20:38:31 2003 +0000 - - Synchronise HEAD with CABAL branch. - -commit ffb55e6904426a31c03b56c3bd87bb60db0624c6 -Author: Guus Sliepen -Date: Fri Aug 22 21:32:45 2003 +0000 - - Add license exception from Markus Oberhumer. - -commit 3e0b28b0c4d874934dde7b487a56cfacc956e3b4 -Author: Guus Sliepen -Date: Fri Aug 22 15:07:57 2003 +0000 - - Remove debug message. - -commit 89c9f3ed8fddb316d0f9ef7de30bdc76fba39e41 -Author: Guus Sliepen -Date: Fri Aug 22 15:04:26 2003 +0000 - - When purging nodes, only delete them if nobody references them anymore. - -commit 22dd23b650eb9b760bc68ab3a9227caf3b449140 -Author: Guus Sliepen -Date: Fri Aug 22 15:03:59 2003 +0000 - - Add checkpoints. - -commit 570e7e9c615388cfba263c7a7c66cbc3d092d6e7 -Author: Guus Sliepen -Date: Fri Aug 22 15:05:01 2003 +0000 - - Don't overwrite the first " when installing a service. - -commit 72bdc05cb7e246e56ed21a25256d441c45fccca8 -Author: Guus Sliepen -Date: Fri Aug 22 11:18:42 2003 +0000 - - Allow tinc to handle unknown type addresses from other tinc daemons. - -commit 5ac4179df66747a7013a10d576c23531d2b4fc58 -Author: Guus Sliepen -Date: Sun Aug 17 12:05:08 2003 +0000 - - If we're not in main_loop() and the service is stopped, exit immediately. - -commit 46cfe6199449a86eb58abaeac45b4021ffa7e178 -Author: Guus Sliepen -Date: Sun Aug 17 12:04:35 2003 +0000 - - Do what the SDK documentation tells. - -commit 107448698fc078bbd4cdbacdfbf51298ddc9ea65 -Author: Guus Sliepen -Date: Sun Aug 17 12:03:40 2003 +0000 - - Compilation fix. - -commit 3112e6a863b4421eb1a0b32632b86c55e47f989e -Author: Guus Sliepen -Date: Sun Aug 17 09:04:00 2003 +0000 - - Use the event log under Windows. - -commit 5e7c52610f8c8b9c38e437ef166a08372d5b8a61 -Author: Guus Sliepen -Date: Sun Aug 17 09:03:30 2003 +0000 - - Fix --logfile under Windows. - -commit 2236e05e518c9e317d82c027596bea5228725214 -Author: Guus Sliepen -Date: Sun Aug 17 08:32:39 2003 +0000 - - Fix fake getnameinfo() and check more arguments. - -commit f4e80cc5e0d1689bcdd828ac7f158bd634b7dd20 -Author: Guus Sliepen -Date: Sat Aug 16 12:40:01 2003 +0000 - - Don't getsockopt() SO_ERROR. We get the error from send()/recv() anyway. - -commit fd40130eb6bbba34176d34936a01bb6a6f9121d4 -Author: Guus Sliepen -Date: Sat Aug 16 12:11:11 2003 +0000 - - stat() batch files under Windows. - -commit 03995ca52ee31ed505902a3c8c3d1119988c8497 -Author: Guus Sliepen -Date: Sat Aug 16 12:10:28 2003 +0000 - - Simplify fake getname/addrinfo() functions, possibly fixing freeing a NULL pointer. - -commit dbfd6f284e0ff0aa04e6d6e62b902966912da516 -Author: Guus Sliepen -Date: Thu Aug 14 14:32:34 2003 +0000 - - Update. - -commit 7ed25590257b6ed33dfa879d187a09b0d790794f -Author: Guus Sliepen -Date: Thu Aug 14 14:21:35 2003 +0000 - - Fix permissions check for rsa_key.priv. - -commit 1f2670aab295dfd09c8c655611d2a5b820cb00fc -Author: Guus Sliepen -Date: Tue Aug 12 14:48:13 2003 +0000 - - Small fixes. - -commit b038e8db376969e70f1315840428b8a14ec8420f -Author: Guus Sliepen -Date: Tue Aug 12 12:35:53 2003 +0000 - - Updated dutch translation. - -commit ae070b917066f612e9aba8611c7a5da88e19a51a -Author: Guus Sliepen -Date: Sun Aug 10 13:35:05 2003 +0000 - - Add a description for the Service control panel. - -commit 9b579eb9ffdc1fd4a3d0cacb0728ec0796526bc5 -Author: Guus Sliepen -Date: Sat Aug 9 00:53:22 2003 +0000 - - Update documentation. - -commit 7eed829d288d0fdec2f31709a18ec420e489c2e4 -Author: Guus Sliepen -Date: Fri Aug 8 22:45:46 2003 +0000 - - Only system() needs script name quoted. - -commit 91f65c277483b47343b1b64d0f4edd497a8045a3 -Author: Guus Sliepen -Date: Fri Aug 8 22:13:50 2003 +0000 - - Check for fchmod(). - -commit 9bde92ce97d5503ff2d31dcc6f0648902580ec14 -Author: Guus Sliepen -Date: Fri Aug 8 22:11:54 2003 +0000 - - Simpler checking of permissions on private RSA key and other fixes. - -commit 96f5d98fc299a53fcdad304a56eb3a77a2c229e7 -Author: Guus Sliepen -Date: Fri Aug 8 19:56:11 2003 +0000 - - Small things. - -commit ef65a64443f740e3b22d9e903f764d9a58ce0ff0 -Author: Guus Sliepen -Date: Fri Aug 8 19:49:47 2003 +0000 - - Better error checking and reporting. - -commit bb2f18a3fc8acb7802f30e06153def30eb97a994 -Author: Guus Sliepen -Date: Fri Aug 8 19:45:21 2003 +0000 - - Under Windows, the installation directory can be found in the registry. - -commit 7f05445047c6479b81b7d393543ff73a95ee0dc8 -Author: Guus Sliepen -Date: Fri Aug 8 19:43:47 2003 +0000 - - Quote when needed and don't try stuff that doesn't work under Windows. - -commit b4c913aaa926d80a72aeb97459f84f992b65d1ed -Author: Guus Sliepen -Date: Fri Aug 8 19:42:35 2003 +0000 - - Log error first, try to close later. - -commit b0825f36b7b5dade1693fdbddfec7eef3f5ed86f -Author: Guus Sliepen -Date: Fri Aug 8 19:39:41 2003 +0000 - - Better error messages under Windows. - -commit 6f3099595530280028f6ec3d0b310df523e75f98 -Author: Guus Sliepen -Date: Fri Aug 8 17:20:12 2003 +0000 - - Typo. - -commit 691907caaeb348dee3dbe8a85f3590241f2cc992 -Author: Guus Sliepen -Date: Fri Aug 8 17:17:13 2003 +0000 - - Readd quotes. - -commit f956a28147ec8596c9a51b0c1535bb4b8c87692c -Author: Guus Sliepen -Date: Fri Aug 8 16:49:29 2003 +0000 - - Make rule for sample-config.tar.gz. - -commit 7e74e00d167da659ba6c3db3e8822008d27c081b -Author: Guus Sliepen -Date: Fri Aug 8 14:59:27 2003 +0000 - - Allow empty lines in config files. - -commit 863349638beb1eaab09e2a3d537c20a7913aef30 -Author: Guus Sliepen -Date: Fri Aug 8 14:48:33 2003 +0000 - - Simplify execute_script(). It will probably work under Windows as well. - -commit deba3ed900eb4453d27412606cecfaf89b5a5643 -Author: Guus Sliepen -Date: Fri Aug 8 14:24:09 2003 +0000 - - Correct error message when remote host closed connection. - -commit 0c2256670fc0822cc5a86bca754186c50f943a1c -Author: Guus Sliepen -Date: Fri Aug 8 14:07:12 2003 +0000 - - Remove unused stuff from doc/. - Let configure update pathnames in documentation. - -commit 070aee3be16b8d8078b049c5bb43dce7b18123df -Author: Guus Sliepen -Date: Fri Aug 8 12:55:05 2003 +0000 - - Tell windows to be patient. - -commit adb68b9c2aa7ad72dd5c38b95c083c47599cb65a -Author: Guus Sliepen -Date: Fri Aug 8 12:24:52 2003 +0000 - - Windows uses backslashes... - -commit ef091d1ddb1f7ab5244db96841274dc769e85167 -Author: Guus Sliepen -Date: Fri Aug 8 11:45:37 2003 +0000 - - Sync CABAL branch with release-1_0 branch. - -commit 5193a14ddea4c20ffc708dc629a2f91f1e4ccea3 -Author: Guus Sliepen -Date: Sun Aug 3 21:45:41 2003 +0000 - - Use our own port when connecting to ourself. - -commit 62a7fa9a7bfd1cd1592fd7c381ea28aac0ed7936 -Author: Guus Sliepen -Date: Sun Aug 3 21:45:13 2003 +0000 - - Simplify translation - -commit 98f97da9d7d80b528d9a2b2f03f710cdd2b293d0 -Author: Guus Sliepen -Date: Sun Aug 3 21:43:19 2003 +0000 - - Update dutch translation - -commit e220187f484f3549df3ad3a04939b9a38051d1a0 -Author: Guus Sliepen -Date: Sun Aug 3 12:38:43 2003 +0000 - - Remove newlines from log messages. - -commit 3671ed806d7371fb6b14a5909451b20e54a1b14a -Author: Guus Sliepen -Date: Sun Aug 3 12:38:18 2003 +0000 - - Keep Windows happy. - -commit 7bed2a7099fc7359f6ec24e5f2d7050c7d63b6ac -Author: Guus Sliepen -Date: Sun Aug 3 12:37:55 2003 +0000 - - Cygwin needs windows.h. - -commit fa9c00733e4b793691bf5a068ff7f2f391854fb4 -Author: Guus Sliepen -Date: Sun Aug 3 09:55:20 2003 +0000 - - Old gcc compilers don't like declarations in the middle of a function. - -commit a65011b3c54cd4ddc66f20909ca0e495de0d6eb0 -Author: Guus Sliepen -Date: Sun Aug 3 09:08:52 2003 +0000 - - Clean up last part of main(). - -commit e20ac7b52da8e3f7da292836c6e2551fc9f64617 -Author: Guus Sliepen -Date: Sat Aug 2 22:01:50 2003 +0000 - - Typo and another thing to think about. - -commit 92938c07b17fdd30f4e7f9ae1b884b05c7aa312c -Author: Guus Sliepen -Date: Sat Aug 2 21:55:12 2003 +0000 - - Explain how tinc detaches and how it is "killed" under Windows. - -commit 8a1969bc8319761e3821fc76a7c2f7037ffb8850 -Author: Guus Sliepen -Date: Sat Aug 2 21:39:11 2003 +0000 - - Updated dutch translation. - -commit f605ec47bed26362e24ffacf71c7ae5aeed3c230 -Author: Guus Sliepen -Date: Sat Aug 2 21:34:10 2003 +0000 - - Oops. - -commit e6e32814584f82ee61f658a71cb435bbb491bd39 -Author: Guus Sliepen -Date: Sat Aug 2 21:33:52 2003 +0000 - - Missing include. - -commit c044d12dfd54c033bc5ad9fbf9f889724762f76c -Author: Guus Sliepen -Date: Sat Aug 2 21:33:19 2003 +0000 - - Cleanups and error messages. - -commit 3fd96ebec7e44a0a7288c60da1cdec2d4fe03e8c -Author: Guus Sliepen -Date: Sat Aug 2 21:01:50 2003 +0000 - - Error messages. - -commit f08fc359a0b7f638e73a8f866119b016b7dff8de -Author: Guus Sliepen -Date: Sat Aug 2 20:50:38 2003 +0000 - - Install tinc as a service under Windows (MinGW). Remove cleanup_and_exit(), - either exit() directly on errors or let main_loop() shutdown gracefully. - -commit 7c34122af7ed4667748ceae4966bd5b519ac8ad7 -Author: Guus Sliepen -Date: Sat Aug 2 16:05:33 2003 +0000 - - When compiling with MinGW, link with ws2_32. - -commit 9a491a10eee55b243dd1030ee9016ec510908a10 -Author: Guus Sliepen -Date: Sat Aug 2 15:32:57 2003 +0000 - - Windows has no symbolic links as we know it. - -commit 9c2d5d9f9212dee5ee988f4824e5e4afedb7a2dd -Author: Guus Sliepen -Date: Sat Aug 2 15:29:06 2003 +0000 - - Oops. - -commit c7bf64c7946ece3e1a6a7cdd7bce00045bddb9cd -Author: Guus Sliepen -Date: Sat Aug 2 15:27:24 2003 +0000 - - Allow whitespace in values. - -commit b79e55b183898911e2c2b7b151b281aef8d474e1 -Author: Guus Sliepen -Date: Sat Aug 2 15:13:08 2003 +0000 - - Prevent system headers from including our own headers. - -commit 998ac634d456567e7caf99fe879d4ef1602f36bf -Author: Guus Sliepen -Date: Fri Aug 1 08:18:22 2003 +0000 - - Wrong function... - -commit 2531ff59b73af3a6de85fdc33d744758a6ab9449 -Author: Guus Sliepen -Date: Thu Jul 31 14:24:19 2003 +0000 - - Woops! - -commit 1fe56637874a1e93882a2ca6ffb8c50a773f80e4 -Author: Guus Sliepen -Date: Thu Jul 31 13:18:34 2003 +0000 - - No easy way to properly detect header files... - -commit 8eca27e863d9cb139a1e4039f63aaac3c9afc3c6 -Author: Guus Sliepen -Date: Thu Jul 31 11:31:51 2003 +0000 - - Remove forgotten braces. - -commit 5c29d066688691dd1664597ba1c76195634f06c0 -Author: Guus Sliepen -Date: Thu Jul 31 11:20:32 2003 +0000 - - Wrong argument. - -commit da3078c63a3b658573f6e2f986f69ed4d7993b3a -Author: Guus Sliepen -Date: Thu Jul 31 11:17:39 2003 +0000 - - Check if the compiler knows about the __malloc__ attribute. - -commit d798b8b3d832f8c69769e08cfd64a4d8355faf0e -Author: Guus Sliepen -Date: Wed Jul 30 21:52:41 2003 +0000 - - Prevent definitions from messing up attributes. - -commit 2edc764a333764e7e5c4d3420131c13e9c81ecf7 -Author: Guus Sliepen -Date: Wed Jul 30 16:00:59 2003 +0000 - - Replacement for stdbool.h - -commit fcbe29bc4cc67530581a36cf1a3a1445c741b8e5 -Author: Guus Sliepen -Date: Wed Jul 30 11:50:45 2003 +0000 - - No C99 initialisers, gcc 2.95.3 doesn't like it. - Also make sure getopt.h is included. - -commit de223b51b94c58d1674f1ef56e9d485ff48d366d -Author: Guus Sliepen -Date: Wed Jul 30 09:45:21 2003 +0000 - - Remove doc/es/ and src/device.c from the distribution. - -commit 63568bb6bca20b4d2b2068a6367084a273eabac8 -Author: Guus Sliepen -Date: Wed Jul 30 09:22:29 2003 +0000 - - Update documentation and remove stuff that's too outdated. - -commit 2ed154e73192d5e162544bc570abbb3a1df3ec83 -Author: Guus Sliepen -Date: Tue Jul 29 23:21:01 2003 +0000 - - Cleanups. - -commit 721e4caee0f7c6e003c297c95fb6d93bd4102219 -Author: Guus Sliepen -Date: Tue Jul 29 22:59:01 2003 +0000 - - Native Windows support. - -commit 586f15ed20682413d1bddbb4518dd2714c96b255 -Author: Guus Sliepen -Date: Tue Jul 29 12:38:49 2003 +0000 - - Make sure (at least) the MinGW device driver works. - -commit 6f7cce69479f9b2796d81f458bf836287b74462e -Author: Guus Sliepen -Date: Tue Jul 29 12:18:35 2003 +0000 - - Make sure it works. - -commit 4370b98bb1dfa9eb1e400549cb6fcb6711aa1b29 -Author: Guus Sliepen -Date: Tue Jul 29 11:50:39 2003 +0000 - - Update configure scripts. - -commit ae50b0077e27c4c4d81a98da46c66865ffa069be -Author: Guus Sliepen -Date: Tue Jul 29 11:06:23 2003 +0000 - - Update dutch translation and make sure all device drivers are included in - the translation and distribution. - -commit 714fb32d0377ed9f5643ed8f0bd914843d12266b -Author: Guus Sliepen -Date: Tue Jul 29 10:50:15 2003 +0000 - - Fix compile errors and warnings. - -commit 0e945413315c9d15a3eb013fa3731dd978a8c7b8 -Author: Guus Sliepen -Date: Mon Jul 28 22:06:09 2003 +0000 - - More checks for missing functions. - -commit c15e8a96bf7e45adf750b7a36b0e8446ea049468 -Author: Guus Sliepen -Date: Mon Jul 28 21:54:03 2003 +0000 - - More generic handling of tap device under Windows. - -commit 83263b74460656ba557fd9bb84dc27258549e9cd -Author: Guus Sliepen -Date: Thu Jul 24 12:08:16 2003 +0000 - - Sprinkle around a lot of const and some C99 initialisers. - -commit 5cb147135184e3748c6f5e6e6203d22ab9f904f8 -Author: Guus Sliepen -Date: Wed Jul 23 22:17:31 2003 +0000 - - Don't initialise a CIPHER_CTX if cipher == NULL. - -commit 4aadb9500d9198f9c271deb048a2d36000bfae34 -Author: Guus Sliepen -Date: Tue Jul 22 21:13:23 2003 +0000 - - Run setup_device() after parsing configuration but before claiming we're ready. - -commit eefa28059ab989c915a7d95fb4ae728abd7ce713 -Author: Guus Sliepen -Date: Tue Jul 22 20:55:21 2003 +0000 - - Use bools and enums where appropriate. - -commit 471308e1636e7a06e1d9ebc98e82b1c0c5150dde -Author: Guus Sliepen -Date: Tue Jul 22 12:58:34 2003 +0000 - - Option to specify pidfile location. - -commit c96900f378966ca1be96ddb1c43f855c74083b70 -Author: Guus Sliepen -Date: Mon Jul 21 19:58:58 2003 +0000 - - Add section about configuring Cygwin and CIPE on Windows. - -commit bad82522ecfc1f3c72c600cbca6e8fa7e950c3bf -Author: Guus Sliepen -Date: Mon Jul 21 15:51:00 2003 +0000 - - Copy cygwin driver to mingw directory. It doesn't work (yet). - -commit e169244e4b10dbcc1910c0f7fd811304d5b1a5a5 -Author: Guus Sliepen -Date: Mon Jul 21 14:47:43 2003 +0000 - - Use functions from logger.c - -commit 2f2defc4525befd5b5cb69d03b7887db35e9e46c -Author: Guus Sliepen -Date: Mon Jul 21 13:18:44 2003 +0000 - - Check for sys/mman.h. - -commit 64fd25aa6b794bb1d957b50d48705f30ed47c878 -Author: Guus Sliepen -Date: Mon Jul 21 13:15:36 2003 +0000 - - Oops. - -commit c1e8152f4fe5e4557784d8411e50006d461b8786 -Author: Guus Sliepen -Date: Mon Jul 21 13:14:02 2003 +0000 - - Be consistent. - -commit b657f0519456d05bcea5742017165793f79e56df -Author: Guus Sliepen -Date: Fri Jul 18 14:10:27 2003 +0000 - - No UNIX style permissions under Windows. - -commit 38aa0319ef79124e59b587e6d55f37a79a9d847c -Author: Guus Sliepen -Date: Fri Jul 18 14:09:47 2003 +0000 - - Oops. - -commit 123bb765d10453fdccbe363a02e3042c588729cc -Author: Guus Sliepen -Date: Fri Jul 18 13:45:06 2003 +0000 - - Use iface instead of interface because it might already be declared in - system header files. - -commit 96ee04b678143defa1040f2defdd3424efedea11 -Author: Guus Sliepen -Date: Fri Jul 18 13:42:35 2003 +0000 - - Check for ethernet/ipv4/ipv6 related structures. - -commit 00ddbf5723511d80fbd2522fc503bd409dc6189a -Author: Guus Sliepen -Date: Fri Jul 18 13:41:37 2003 +0000 - - Update all device.c files. - -commit 271d3537fed28b3e76cf0e76082b44c8771ac5da -Author: Guus Sliepen -Date: Fri Jul 18 12:21:03 2003 +0000 - - Remove all #ifndefs from route.c - -commit b0a4f7b5551cae6fb5af2eb4bcb0dfb3443f7d89 -Author: Guus Sliepen -Date: Fri Jul 18 12:16:24 2003 +0000 - - Even more missing definitions. - -commit e449d94caef963809d417f16497f6f978e10d731 -Author: Guus Sliepen -Date: Thu Jul 17 15:06:27 2003 +0000 - - Big header file cleanup: everything that has to do with standard system - libraries is moved to system.h. - -commit 47721be760c495ec13d68181bc03b151ffc1399c -Author: Guus Sliepen -Date: Tue Jul 15 16:38:18 2003 +0000 - - Windows headers declare a struct interface somewhere. - -commit 4c52febc57f2e34f5a187f0e57782903fe1eb95e -Author: Guus Sliepen -Date: Tue Jul 15 16:27:39 2003 +0000 - - Make use of the CIPE driver. Woohoo, tinc for Windows! - -commit d26a4af4561ce4236b8224919cf4f3636f57b4c1 -Author: Guus Sliepen -Date: Tue Jul 15 16:26:18 2003 +0000 - - Export mymac. - -commit 784db4e70d2573468c82ff5dfee723b77a20322f -Author: Guus Sliepen -Date: Sat Jul 12 20:24:04 2003 +0000 - - Format string checking for logger(). - -commit a438ac911e7e60e54d7d1fc4f84373fab7e055af -Author: Guus Sliepen -Date: Sat Jul 12 20:19:22 2003 +0000 - - Removing distribution specific files from CVS. - -commit 085d33e6265e139bb08cdfda3d7498993190d187 -Author: Guus Sliepen -Date: Sat Jul 12 17:48:38 2003 +0000 - - Update copyrights. - -commit 5db596c6844169f1eb5f804b72abe99d067aaa5a -Author: Guus Sliepen -Date: Sat Jul 12 17:41:48 2003 +0000 - - Simplify logging, update copyrights and some minor cleanups. - -commit 2a7f11c0e90f5f0465bbc3c75de715454066ff72 -Author: Guus Sliepen -Date: Fri Jul 11 16:13:00 2003 +0000 - - More missing IPv6 definitions and autoconf checks to make sure it compiles - under Solaris 2.6. - -commit 71f8124ea49f2a0e00e0cedbb1b76e49e9f1425d -Author: Guus Sliepen -Date: Mon Jul 7 11:50:52 2003 +0000 - - More missing definitions. - -commit a88f1edf297152580a7729c6f3d274ba2bff7360 -Author: Guus Sliepen -Date: Mon Jul 7 11:13:31 2003 +0000 - - Actually add ipv6.h. - -commit 30c0381d71d333a99f6c83ff9d03ef4a0857f423 -Author: Guus Sliepen -Date: Mon Jul 7 11:11:33 2003 +0000 - - Provide all missing IPv6 definitions in lib/ipv6.h. - -commit 1401faf608e1c8af0d0754e545b0ec79d2bd5d93 -Author: Guus Sliepen -Date: Sun Jul 6 23:16:29 2003 +0000 - - Sprinkling the source with static and attributes. - -commit 0b9175e998c2180e5d73ef3d644a49d620c68cad -Author: Guus Sliepen -Date: Sun Jul 6 22:11:37 2003 +0000 - - Define logger(), cleans up source code and allows us to write log entries - to a separate file. - -commit 868104703003605711582c984b57f8933bf361ee -Author: Guus Sliepen -Date: Sun Jul 6 17:49:49 2003 +0000 - - Check for IPv6 header files. - -commit 81f5713ab71944d51703653eab7f364fba0c482e -Author: Guus Sliepen -Date: Sun Jul 6 17:15:25 2003 +0000 - - - simplify configure.in - - drop support for OpenSSL < 0.9.7 - - add some missing definitions/includes - -commit 6c7172d694dcb80e538518282b6c4bd51818f1d2 -Author: Guus Sliepen -Date: Wed Jun 25 20:55:05 2003 +0000 - - This subtle pointer arithmetic thingy is (I'm very sure of it) the cause - of the lingering connections problem. Hopefully it is fixed now... - -commit 9528a63c35da77ba5b825068aeffbc5587816dd5 -Author: Guus Sliepen -Date: Wed Jun 25 20:52:59 2003 +0000 - - Really make tinc default to any addressfamily. - -commit 8bfa554af97ee0694919b9f5b78ada89c6af62f5 -Author: Guus Sliepen -Date: Thu Jun 12 11:08:40 2003 +0000 - - There are two lzo compression levels. - -commit c3593491d44e8e8f239bb297f5d5f6541d581b78 -Author: Guus Sliepen -Date: Wed Jun 11 20:36:36 2003 +0000 - - Typo and conversion to UTF-8. - -commit 636e650261712e3687048fe19987fd50ce84b093 -Author: Guus Sliepen -Date: Wed Jun 11 20:19:46 2003 +0000 - - Update dutch translation. - -commit 9279b3c69982b066e2aaea4e444892b51332881a -Author: Guus Sliepen -Date: Wed Jun 11 20:18:48 2003 +0000 - - Update documentation. - -commit 0a9aef2da749f7b7d1ca183daad88f6433579b9f -Author: Guus Sliepen -Date: Wed Jun 11 19:40:43 2003 +0000 - - More braces to make gcc happy. - -commit cf63cbef2bcb6a1f21ded439cbb09842581b9020 -Author: Guus Sliepen -Date: Wed Jun 11 19:39:02 2003 +0000 - - Fixes from Wessel Danker's libavl. - -commit 12de5a8eedd985f4732e88de6185f77a8244612c -Author: Guus Sliepen -Date: Wed Jun 11 19:28:38 2003 +0000 - - Remove mymac stuff from device.c. - -commit 31f17d43346a9175aec7c29ce41c71b1d08f725e -Author: Guus Sliepen -Date: Wed Jun 11 19:27:35 2003 +0000 - - AddressFamily is "any" by default. - -commit 451800eda87e886021fabd1888e486c51e97902a -Author: Guus Sliepen -Date: Wed Jun 11 19:09:52 2003 +0000 - - If we have a Linux tun/tap device and we are in router mode, open the device - in tun mode. - -commit 9e02a3d5631b687833e4cdcde18cda66e38138fc -Author: Guus Sliepen -Date: Wed Jun 11 19:07:56 2003 +0000 - - Call make_names() before doing anything else. - -commit 4b0e5a03fe89529ebe5d471a82c29c153a12116b -Author: Guus Sliepen -Date: Sat Jun 7 13:18:32 2003 +0000 - - Fix warning and add missing checks for LZO library. - -commit f238c209f4a0ced889b8fb443753ed2cdb3548b3 -Author: Guus Sliepen -Date: Sat May 17 22:12:52 2003 +0000 - - Fix links. - -commit 249933350bda2c3fa09c7ce8eb36bf84ee30a1cb -Author: Guus Sliepen -Date: Wed May 7 11:21:58 2003 +0000 - - Small fixes. - -commit 6ba4e2da55001e17aec6a7ee71002130555ff439 -Author: Guus Sliepen -Date: Tue May 6 23:14:45 2003 +0000 - - Small fixes to make LZO compression work. - -commit c70f52087bf6f7514684bbc859b83aec2ca17ae4 -Author: Guus Sliepen -Date: Tue May 6 21:13:18 2003 +0000 - - - Per-node EVP_CIPHER_CTX to avoid initialisation overhead. - - LZO compression, thanks to Teemu Kiviniemi. - - Updated dutch translation. - -commit 1ad2394b8468593030653bbfd0dee879fb711432 -Author: Guus Sliepen -Date: Sat Apr 19 11:12:45 2003 +0000 - - Make sure outgoing_t is completely freed. - -commit bc9e78250ef6fb5169d03565b7d8d9caf309eb98 -Author: Guus Sliepen -Date: Fri Apr 18 21:18:36 2003 +0000 - - Better handling of late packets. - -commit 51a1bcf00143319c74ffb58a66a19c41be422c21 -Author: Guus Sliepen -Date: Thu Apr 3 11:43:17 2003 +0000 - - HUP signal now closes connections to hosts if their host config file is - gone or changed. The tinc.conf file is reread for changes in the ConnectTo - lines. - -commit 8285827da127e38728b60b5c5484e5cdabff2f21 -Author: Guus Sliepen -Date: Sat Mar 29 22:11:22 2003 +0000 - - Checksums must also work for uneven number of bytes. - -commit c3ad3731a8dfa34535a156a7cfdb4e18afaa8bce -Author: Guus Sliepen -Date: Sat Mar 29 21:58:35 2003 +0000 - - Don't copy more than necessary. - -commit 7d21a8d1c7fd8909fe02385dbb4717c074db4648 -Author: Guus Sliepen -Date: Sat Mar 29 21:51:21 2003 +0000 - - - Speed up checksumming - - If a destination is not found in the subnet list or the destination node - is unreachable, respond with an appropiate ICMP message. - -commit 9792ba2cac35cb50cc99b72dd4cb9d3ef350dbd4 -Author: Guus Sliepen -Date: Fri Mar 28 13:41:49 2003 +0000 - - - Avoid memory leak caused by OpenSSL 0.9.7a. - - Disable RSA_blinding_on() because it segfaults. - -commit 69158563e9f790777eb27aeb8484a86d12385af4 -Author: Guus Sliepen -Date: Wed Mar 19 11:45:05 2003 +0000 - - Typo. - -commit 88ae2e9e0c1eb62d9b74c4b38d9c0e93557fed9f -Author: Guus Sliepen -Date: Wed Mar 19 11:43:42 2003 +0000 - - Make sure send_meta() writes everything. - -commit 2fff0a91a7e3e5f44e97255b6dd5807656b255a8 -Author: Ivo Timmermans -Date: Fri Mar 14 09:43:10 2003 +0000 - - Call RSA_blinding_on(), as advised in the paper on - http://crypto.stanford.edu/~dabo/abstracts/ssl-timing.html - to offer some resistance against timing attacks. - -commit 1783a3aaa9b692ab64260a9c2adf588ed6083a1c -Author: Guus Sliepen -Date: Fri Jan 17 00:43:58 2003 +0000 - - Various fixes for autoconf and OpenSSL 0.9.7 and a missing header. - -commit c08858baa91a00e38c0f5482dbb0817dbd0361f1 -Author: Guus Sliepen -Date: Fri Jan 17 00:37:20 2003 +0000 - - - Fix indentation in some places. - - Optimise select loop. - - Remove unused function setup_outgoing_socket(). - - Clear EVP_CIPHER_CTX structures before using them. - -commit 38f562fdfcacb50d34b9a48bfaea7faa132f493a -Author: Guus Sliepen -Date: Tue Jan 14 12:53:59 2003 +0000 - - Add $NAME for tinc-up/down scripts. - -commit 44b87ddb7ac90be13ef3e3d5118acaa158184853 -Author: Guus Sliepen -Date: Sun Jan 12 17:02:23 2003 +0000 - - Run graph algorithm when replacing a second connection from the same host - replaces an older one. - -commit 4c88ff86bcd32735d4768ef3464812cd77c500be -Author: Guus Sliepen -Date: Fri Dec 27 19:32:33 2002 +0000 - - PrivateKeyFile instead of PrivateKey. - -commit 5b2a62ebb6317cd88e491ee958c54670f381aee8 -Author: Guus Sliepen -Date: Thu Nov 14 22:09:03 2002 +0000 - - Fix PriorityInheritance. - -commit 07db46a44feb283c1c17bcce918ab49274a3b11f -Author: Guus Sliepen -Date: Mon Oct 7 07:32:31 2002 +0000 - - Add documentation for BindToAddress. - -commit e310cc82d3f9c9bdb3b827daa149861a41e2e00a -Author: Ivo Timmermans -Date: Mon Sep 30 19:04:37 2002 +0000 - - Fix saving of debug level for startup level 0 - -commit 006591efe5b3e6c64040d267f8c0477468abf2bf -Author: Guus Sliepen -Date: Tue Sep 24 11:43:34 2002 +0000 - - Run graph() after edge_del() when updating an edge. - -commit 6904e0469ef52aa6100f0185d579bc205bd07be8 -Author: Wessel Dankers -Date: Mon Sep 16 14:08:04 2002 +0000 - - its: Engels voor "van het" - 3e persoon enkelvoud, genitief, onzijdig - it's: Engels voor "het is". Dus niet "van het". - -commit 4f3395ee4dad3cdd23706af180ebddfa5e576012 -Author: Guus Sliepen -Date: Sun Sep 15 22:37:59 2002 +0000 - - Thank some more people. - -commit b216297a004f083336c633aaccecb4ab175360b3 -Author: Guus Sliepen -Date: Sun Sep 15 22:34:25 2002 +0000 - - Remarks about 1.0pre8 release. - -commit 1dcbdf48eb4a642e4d70a9e67aaca78deacf352d -Author: Guus Sliepen -Date: Sun Sep 15 22:19:38 2002 +0000 - - Update documentation. - -commit bf3a11898898c0618cd1b2e7a792b7d7fe56aecb -Author: Guus Sliepen -Date: Sun Sep 15 22:19:19 2002 +0000 - - Use /dev/net/tun as default for tun/tap device under Linux. - -commit 7d76ceaebd5180f4ef37086980c799199eb7de16 -Author: Guus Sliepen -Date: Sun Sep 15 17:40:00 2002 +0000 - - Updated dutch translation. - -commit 5eca9520d93bced1275d45e5e2a933d69354cd6d -Author: Guus Sliepen -Date: Sun Sep 15 14:55:54 2002 +0000 - - Small fixes so tinc compiles out of the box on SunOS 5.8 - -commit 8d472a415e9c5fdb878386005d29cdfd97b8a404 -Author: Guus Sliepen -Date: Sun Sep 15 12:26:24 2002 +0000 - - port_t isn't used anymore and conflicts with MacOS/X headers. - -commit 38c80bdd46fab68c686a293e2820041291972f3a -Author: Guus Sliepen -Date: Sun Sep 15 12:26:04 2002 +0000 - - MacOS/X needs #define _P1003_1B_VISIBLE in order to use mlockall(). - -commit 3e3b4a3190cf950c265a8c62d577812a22b11dcc -Author: Guus Sliepen -Date: Wed Sep 11 22:25:58 2002 +0000 - - What was I thinking? - -commit f6905582d0e70ac5b44369780aaa921d9c721197 -Author: Guus Sliepen -Date: Tue Sep 10 22:13:22 2002 +0000 - - Make sure malloc() is declared. - -commit eaf1208e9d5c5a15e4b23de936830520bf3b5685 -Author: Guus Sliepen -Date: Tue Sep 10 22:13:01 2002 +0000 - - Fix placement of #include "config.h" - -commit dd888ca685176128bf41034208f3dbb220f9d832 -Author: Guus Sliepen -Date: Tue Sep 10 21:46:05 2002 +0000 - - Link with libintl if necessary. - -commit c01f78ed3603eecaec8e3649a3bfb3de9742fd24 -Author: Guus Sliepen -Date: Tue Sep 10 21:29:42 2002 +0000 - - Clean up after indent. - -commit 161f917dd03c174742fb8c6722f430a93b506cb1 -Author: Guus Sliepen -Date: Tue Sep 10 09:40:25 2002 +0000 - - Fix compiler warnings. - -commit 3bc554347560a9c24e68bb2c7c7749be07bbec3d -Author: Guus Sliepen -Date: Mon Sep 9 22:41:56 2002 +0000 - - Let GCC check format string and arguments of send_request(). - -commit 6f9f6779e6bd1dd7bb795b42dad550863a386ca8 -Author: Guus Sliepen -Date: Mon Sep 9 22:33:31 2002 +0000 - - Remove redundant spaces. - -commit 9f38e394636a177c00a4545de2a99c661de36386 -Author: Guus Sliepen -Date: Mon Sep 9 21:49:16 2002 +0000 - - Switch to K&R style indentation. - -commit f75dcef72a81a337e847adf0bae54198894f65b9 -Author: Guus Sliepen -Date: Mon Sep 9 21:25:28 2002 +0000 - - Switch to K&R style indentation. - -commit 5fc1ed17f41f0c535cf57a4b7e00cd6d45759503 -Author: Guus Sliepen -Date: Mon Sep 9 19:40:12 2002 +0000 - - Cleanups: - - Convert cp to cp(); so that automatic indenters work. - - Convert constructions like if(x == NULL) to if(!x). - - Move all assignments out of conditions. - -commit 5638b9830f9cfe43f545c37cfd7ccf1d4b4bfcc6 -Author: Guus Sliepen -Date: Fri Sep 6 21:22:35 2002 +0000 - - Why don't these connection_t's get cleaned up? - -commit a8ddba42b99d7694359f1387235596b84d297b9e -Author: Guus Sliepen -Date: Fri Sep 6 21:02:36 2002 +0000 - - Fix MST algorithm. - -commit 66741978e16cc407e5c760621c34d1aabb753cd2 -Author: Guus Sliepen -Date: Fri Sep 6 14:31:12 2002 +0000 - - Reset the *correct* seqnos. - -commit d5b61fc0cd249fd2b2751a1ff77b321323a17beb -Author: Guus Sliepen -Date: Fri Sep 6 12:19:16 2002 +0000 - - edge_weight_compare() shouldn't rely on edge_compare(). - -commit fc7116a32b798589e7731db9f9db66345c8c3e01 -Author: Ivo Timmermans -Date: Fri Sep 6 11:08:21 2002 +0000 - - Added AM_MAINTAINER_MODE - -commit fbf8a47879671541939cfdc6beb93b02b9eee303 -Author: Guus Sliepen -Date: Fri Sep 6 10:23:52 2002 +0000 - - Remove global edge_tree. - -commit 641705df90b4c41e7f5083f6cd601cbbfb1c2c85 -Author: Guus Sliepen -Date: Fri Sep 6 09:48:39 2002 +0000 - - Only reset seqno's when a key is sent or received. - -commit e4d85a6557ee45870bee0c5a16807e48b7a3c243 -Author: Guus Sliepen -Date: Wed Sep 4 23:11:58 2002 +0000 - - Typo. - -commit b4f87952bf2d37524c705b32864f802144f94d68 -Author: Guus Sliepen -Date: Wed Sep 4 23:05:49 2002 +0000 - - Add missing headers. - -commit b18bd211bec84a804f58da5f2d2908e54de3fe40 -Author: Guus Sliepen -Date: Wed Sep 4 23:04:52 2002 +0000 - - Run autopoint and libtoolize before creating initial makefiles. - -commit 6fdaa8e1caff4edb44a105b03c79403b743e9bd2 -Author: Guus Sliepen -Date: Wed Sep 4 19:57:53 2002 +0000 - - Small updates. - -commit d4277e9ee8affa59ac9b3475245360bd14af1fa8 -Author: Guus Sliepen -Date: Wed Sep 4 16:36:03 2002 +0000 - - Updated dutch translation. - -commit 8b2b67e26c5b971761f5015764d5e188f6343bc4 -Author: Guus Sliepen -Date: Wed Sep 4 16:26:45 2002 +0000 - - Generalized request broadcasting/forwarding. - -commit 431fa10b37e78172a03c952e28a0364cc0e438f0 -Author: Guus Sliepen -Date: Wed Sep 4 14:17:28 2002 +0000 - - Small fixes. - -commit 82ebfc923ddb050c88bdf5d65ac943a15ca8748a -Author: Guus Sliepen -Date: Wed Sep 4 13:48:52 2002 +0000 - - Revert to edge and graph stuff. This time, use a directed graph. - -commit 973530db628fb91106d6fb7a17151e1d036e40a2 -Author: Guus Sliepen -Date: Wed Sep 4 08:48:03 2002 +0000 - - Just ignore wrong ADD_NODEs instead of replying with a DEL_NODE, in the - hope other DEL_NODEs will catch up eventually. - -commit 2af0bcc8fd39ca34a7ff856d539cdf38728a8c25 -Author: Guus Sliepen -Date: Wed Sep 4 08:36:34 2002 +0000 - - Don't forget to set prevhop to myself for new connections. - -commit 698d6ddac6ab32d5a4b802941b02232793442684 -Author: Guus Sliepen -Date: Wed Sep 4 08:33:08 2002 +0000 - - Prevent looping DEL_NODE/ADD_NODE messages after a node disconnects. - -commit 4a7c2026aec6966f934b60d75bc472d28f8587d8 -Author: Guus Sliepen -Date: Wed Sep 4 08:02:33 2002 +0000 - - Reduce KEY_CHANGED traffic. - -commit ddb96301a39dd3dac8d3df4e2e189b13b75e0b6e -Author: Guus Sliepen -Date: Tue Sep 3 22:49:55 2002 +0000 - - Woops. - -commit b5bb06200eda170c9836e1b4474d6f5b920c2151 -Author: Guus Sliepen -Date: Tue Sep 3 22:37:49 2002 +0000 - - A reachable node is always more preferable to an unreachable one... - -commit d134c4542d4e890e1c1007f32b866742319853c5 -Author: Guus Sliepen -Date: Tue Sep 3 20:43:26 2002 +0000 - - Drop graph and edge stuff. Use new node stuff instead. - -commit 856de4c5fe8acd779aa9277d4554e34ff3625e97 -Author: Guus Sliepen -Date: Tue Sep 3 20:42:05 2002 +0000 - - Make sure setlocale() is available. - -commit 2cb21f8810a6e0241a80623e991c8308b603ae95 -Author: Guus Sliepen -Date: Mon Sep 2 22:40:42 2002 +0000 - - Replacement for the current routing algorithm. - -commit f2c2443bbcfd5e09518bd87f3fd8d4a727d73ae2 -Author: Guus Sliepen -Date: Sat Aug 24 12:54:55 2002 +0000 - - Check for ranlib. - -commit 912e7e968f4888d62b3c620893a70e825599973b -Author: Guus Sliepen -Date: Sat Aug 24 12:11:40 2002 +0000 - - Gettext 1.11.5 compatibility. - -commit 18948c5784bfedf0dd5a371e41bc2cceee76d92e -Author: Guus Sliepen -Date: Thu Jul 18 14:30:45 2002 +0000 - - Added support for raw sockets. This can be used instead of tun/tap devices. - -commit 9f370893fafaeacdd78f5488cfa8b76fdee0d224 -Author: Guus Sliepen -Date: Tue Jul 16 13:18:27 2002 +0000 - - Don't bother to chown, and correctly document ConnectTo. - -commit 227ccd3a8a5602e4c31add8da1bfd8b35c6a801f -Author: Guus Sliepen -Date: Tue Jul 16 13:12:49 2002 +0000 - - Allow tincd to be locked into main memory. - -commit c4cd19935763b379e730a6fdf53dc1ca98d0b938 -Author: Guus Sliepen -Date: Fri Jul 12 11:45:21 2002 +0000 - - Include complete fake-getname/addrinfo from OpenSSH. - -commit afabbd6b9020dd6555a7ecd320a7b3e96119d538 -Author: Guus Sliepen -Date: Thu Jul 11 12:57:06 2002 +0000 - - Added stub device.c for Cygwin. - -commit 8949404db08f4ab594e60778bb76a9061426d7cc -Author: Guus Sliepen -Date: Thu Jul 11 12:55:58 2002 +0000 - - Started port to Cygwin. - -commit c98db1b861d62430e23f26b0da18e7b3ec875767 -Author: Guus Sliepen -Date: Thu Jul 11 12:42:43 2002 +0000 - - Clear subnets before using them. - -commit 8dd09568f1604f1ac8cc0d8d5120d986f5654900 -Author: Guus Sliepen -Date: Wed Jul 10 11:32:33 2002 +0000 - - Allow identical subnets from different owners. - -commit 36cbaa32f480b481bf2ee99fd4835586a02ebc60 -Author: Guus Sliepen -Date: Wed Jul 10 11:27:06 2002 +0000 - - Allow list of environment variables to be passed to execute_script(). - When executing host-up/down scripts, include the address and port of the - remote host. - -commit a1bd878e11ae7e66e7e9a4040c3b19f9b7bc50f4 -Author: Guus Sliepen -Date: Fri Jun 21 17:49:48 2002 +0000 - - Fix for prefixlengths of 32 (IPv4) and 128 (IPv6) bits. - -commit 627f7c22b447bd464b536cd016278545674df93d -Author: Guus Sliepen -Date: Fri Jun 21 10:11:37 2002 +0000 - - s/sliepen.warande.net/sliepen.eu.org/g - s/itimmermans@bigfoot.com/ivo@o2w.nl/g - -commit faabd163adf89bd0580cd40b8735ef8d9028a942 -Author: Guus Sliepen -Date: Fri Jun 14 11:51:29 2002 +0000 - - Update comments about IPv6 autoconfiguration. - -commit 940fcb6701d055f49530f12c93371f0280efce80 -Author: Guus Sliepen -Date: Thu Jun 13 16:12:40 2002 +0000 - - Reset listen_sockets after SIGHUP. - -commit 3a3adf5b690e9be1390a5df3caee6af64b25838f -Author: Guus Sliepen -Date: Wed Jun 12 13:45:23 2002 +0000 - - Add configuration details for NetBSD and Darwin (MacOS/X). - -commit 8988b127e18435054e48cbcca8ac712ddda3d6d2 -Author: Guus Sliepen -Date: Tue Jun 11 11:03:17 2002 +0000 - - Autoconf cleanup. Works for both 2.13 and 2.53, although running autoconf - 2.53 still gives some errors. - -commit de6835a9dd1891b6435c128cc6c2293950a4d7a7 -Author: Guus Sliepen -Date: Mon Jun 10 15:08:23 2002 +0000 - - Include darwin/device.c in distribution. - -commit 40ac473cb10f9c6a59739ce70032b746d8e0bf68 -Author: Guus Sliepen -Date: Mon Jun 10 14:35:18 2002 +0000 - - Use darwin/device.c when compiling on MacOS/X. - -commit 69b758879ee6d322e89143141b98d52167845c26 -Author: Guus Sliepen -Date: Mon Jun 10 14:33:40 2002 +0000 - - Added Darwin (MacOS/X) tun device handling. - -commit bd72e14138185f342885c0ed1c0f2c5dbf571132 -Author: Ivo Timmermans -Date: Sun Jun 9 16:23:12 2002 +0000 - - Added Alessandro Gatti - -commit 944df3eeee50972fcac84cfc8eefb36033bf04ad -Author: Ivo Timmermans -Date: Sun Jun 9 16:19:20 2002 +0000 - - Include netbsd's device.c in make dist - -commit 7608136a8dae24f2df30eac8644efd0d7cd57dc9 -Author: Ivo Timmermans -Date: Sun Jun 9 16:12:04 2002 +0000 - - Include a few more header files - -commit cd3601c5df57c7544ece00bf79e82b36499a26ff -Author: Ivo Timmermans -Date: Sun Jun 9 15:58:05 2002 +0000 - - Add /sw/{include,lib} to search paths if they exist - -commit 548551fd05f58863dfbbaaf147febfab0a22889b -Author: Ivo Timmermans -Date: Sun Jun 9 15:50:12 2002 +0000 - - getnameinfo fixes - -commit 9d769e0bf2ce266e8533e5e7c16bf07e44a9be34 -Author: Ivo Timmermans -Date: Sun Jun 9 15:26:10 2002 +0000 - - OSX support - -commit 78e88521845ae3bdd963ae5a414cb9c251963fa2 -Author: Guus Sliepen -Date: Sat Jun 8 14:08:57 2002 +0000 - - - netinet/* include files depend on netinet/in_systm.h. - - Squash bashism in configure.in. - -commit e47e51e9d17416e2b614287d14a5518881decd44 -Author: Guus Sliepen -Date: Sat Jun 8 13:46:43 2002 +0000 - - Use inttypes.h instead of stdint.h. - -commit 116ba3b3da73fb857cf75b5c92c6aacd70d94dd9 -Author: Guus Sliepen -Date: Sat Jun 8 12:57:10 2002 +0000 - - Cleanup: - - Remove checks for specific OS's, instead check for #defines/#includes. - - Use uint??_t where appropriate. - - Mask handling functions use void pointers to get rid of silly casts. - -commit d333fca4d611b85dd922ddf35bd9eddcb8095c85 -Author: Wessel Dankers -Date: Fri Jun 7 11:14:05 2002 +0000 - - This should work much better. - -commit 14e570f5eeff631c1312b11fcc5d22230ec27aff -Author: Guus Sliepen -Date: Wed Jun 5 00:25:55 2002 +0000 - - Use correct includes on NetBSD. - -commit 5886b6a10d0d2edf20ff53c4926ec4e41a36b8c0 -Author: Guus Sliepen -Date: Wed Jun 5 00:20:40 2002 +0000 - - Make it work correctly with NetBSD tun device. - -commit 4856d8e1f8398780a49545f35ba9b5746c9fc060 -Author: Guus Sliepen -Date: Sun Jun 2 16:06:33 2002 +0000 - - Support RSA_PUBKEYs (as opposed to RSAPublicKeys) so tinc accepts - public keys generated by the OpenSSL command line tools. - -commit efa5148bc76effb440d807d653dda02de050fde0 -Author: Ivo Timmermans -Date: Tue May 7 14:48:41 2002 +0000 - - Hm. - -commit 151ab8c9708534e012447688ed44d711d5b5fa2d -Author: Ivo Timmermans -Date: Thu May 2 13:23:58 2002 +0000 - - test 2 - -commit be04387a0c868b22ee4427822573df8b3b479bbe -Author: Ivo Timmermans -Date: Thu May 2 13:22:44 2002 +0000 - - test - -commit a9bb66367df82d062175f2b9b4bf236d77ae3ff1 -Author: Ivo Timmermans -Date: Thu May 2 13:11:55 2002 +0000 - - Moved event.c/h - -commit 474aab6325bf94724874cb74a9b56d9da739e1b8 -Author: Ivo Timmermans -Date: Thu May 2 11:52:28 2002 +0000 - - Callbacks - -commit 4c1a4e8a790584e4c7d5c0f2485706f4c01e1911 -Author: Ivo Timmermans -Date: Thu May 2 11:50:07 2002 +0000 - - Another file moved; random interface stuff. - -commit 2be8e69ca16e1558463c39c48af76d3d4a4674b7 -Author: Guus Sliepen -Date: Wed May 1 09:15:58 2002 +0000 - - Only purge once when there are no more connections. - -commit a77b35e748b7cf4cf7ac31750cefab7b2b0325f5 -Author: Ivo Timmermans -Date: Mon Apr 29 20:19:42 2002 +0000 - - Commit diff test - -commit 7caa253df4a34e594438e3fbe80c2bddab9a2b4a -Author: Guus Sliepen -Date: Mon Apr 29 20:05:07 2002 +0000 - - Fix very stupid bug in node_del(), which might have caused corruption of - subnets. - -commit 04d33be4bd102de67bb6dba5c449e12fea0db4d2 -Author: Ivo Timmermans -Date: Sun Apr 28 12:46:26 2002 +0000 - - Moving files, first attempt at gcrypt compatibility, more interface - abstraction - -commit b0a676988a8da3120e64ef0e1a4ea4c28b1511e1 -Author: Ivo Timmermans -Date: Sun Apr 28 12:43:40 2002 +0000 - - *** empty log message *** - -commit 67a6d7bcc4891c627663c639c0e02315bd4cf437 -Author: Guus Sliepen -Date: Sat Apr 27 11:40:45 2002 +0000 - - Informative log message if execl() failed. - -commit e6a67fc439fc3b46157647bed1af59b7519adb80 -Author: Ivo Timmermans -Date: Fri Apr 26 18:13:00 2002 +0000 - - Typo - -commit 01747d73a217f7ddf2107b086476702a9d04d683 -Author: Guus Sliepen -Date: Thu Apr 25 19:17:24 2002 +0000 - - Added Nick Patavalis for his RedHat package. - -commit b6ad4ce35a4434c209ee26015f15a18180987bac -Author: Guus Sliepen -Date: Tue Apr 23 07:49:38 2002 +0000 - - Add BindToAddress variable, similar to the late BindToIP. - -commit 40c2e36a96a3f5c34d4851b30f3561123f3906b5 -Author: Guus Sliepen -Date: Fri Apr 19 14:06:40 2002 +0000 - - Support for MaxOS/X. - -commit 97d492d9e23f43fe4c8a5ca8c95747088cf32f98 -Author: Ivo Timmermans -Date: Thu Apr 18 20:09:05 2002 +0000 - - Put #ifndef checks for HAVE_RAND_PSEUDO_BYTES in the correct places. - -commit fa8faff84bbbeb818adaea80d7bf9e12e0074978 -Author: Ivo Timmermans -Date: Sat Apr 13 18:01:58 2002 +0000 - - Print newline when writing to stderr - -commit fbebc5b65606119c01e9e1e3fcc7b2cc4cfd1daf -Author: Ivo Timmermans -Date: Sat Apr 13 11:24:25 2002 +0000 - - ... - -commit 7c75090025a4b06290663e0033a62414f3368f7c -Author: Ivo Timmermans -Date: Sat Apr 13 11:23:46 2002 +0000 - - Rename libvpn to libtinc - -commit 55385cacbfb0c743fc518e54854e24b7b05a623c -Author: Ivo Timmermans -Date: Sat Apr 13 11:23:19 2002 +0000 - - Renamed libvpn to libtinc - -commit 2389dcd573d909f21c8ec2d349b079075af6c7d3 -Author: Ivo Timmermans -Date: Sat Apr 13 11:21:58 2002 +0000 - - Include logging.h - -commit 246ce12c92ccc7badbb8c8c9a88fa03a7de9811f -Author: Ivo Timmermans -Date: Sat Apr 13 11:21:01 2002 +0000 - - Use new logging system - -commit a5b3ec41214ac8aea9b82734f92b5953e04a0c09 -Author: Ivo Timmermans -Date: Sat Apr 13 11:15:43 2002 +0000 - - Things to ignore... - -commit e239504524589a0f1549ca174f927afd07d563ba -Author: Ivo Timmermans -Date: Sat Apr 13 11:14:50 2002 +0000 - - Compile in logging.c - -commit e26dd564163fca001ab1694a51e7412f9ac970de -Author: Ivo Timmermans -Date: Sat Apr 13 11:08:31 2002 +0000 - - Use logging.h instead of syslog.h - -commit 72cd8938e2c759905666ea7d2c90dc1f0b2e2cd5 -Author: Ivo Timmermans -Date: Sat Apr 13 11:00:41 2002 +0000 - - Added prototype for log_syslog - -commit 48b80c93d30d5fae4273b0b496252bbc884abe53 -Author: Ivo Timmermans -Date: Sat Apr 13 10:55:42 2002 +0000 - - log_default_hook was renamed to log_default - -commit b63c3a1f0002675b6bedbd0b235e0ad0a708d4e3 -Author: Ivo Timmermans -Date: Sat Apr 13 10:50:48 2002 +0000 - - Added priority definitions from syslog.h - -commit 490b13edcfcae0422b6bd77fdb2a7f0181b14307 -Author: Ivo Timmermans -Date: Sat Apr 13 10:45:56 2002 +0000 - - Some magic - -commit 738389581b1ba29a181f639f3d20e3e24ff546f5 -Author: Ivo Timmermans -Date: Sat Apr 13 10:43:10 2002 +0000 - - Add syslog wrapper - -commit efa59f7cf4d416c8416866baeaa72cba7e936568 -Author: Ivo Timmermans -Date: Sat Apr 13 10:40:09 2002 +0000 - - Add syslog() wrapper - -commit 8822481d7b11db72d5400717d6b491b5f36bcb1f -Author: Ivo Timmermans -Date: Sat Apr 13 10:29:07 2002 +0000 - - Rename log_message to log - -commit cc603e2765f17555ecdc2b74c27ebf96e6691bf6 -Author: Ivo Timmermans -Date: Sat Apr 13 10:25:38 2002 +0000 - - New logging system to replace syslog() calls with a generic function. - -commit 131327a729216de8ae86da0c3c4d65d409741b7b -Author: Ivo Timmermans -Date: Sat Apr 13 10:04:46 2002 +0000 - - Remove debug_lvl - -commit e3c51b61caabc1a55772f7a52e75aab642c200ed -Author: Ivo Timmermans -Date: Sat Apr 13 10:02:48 2002 +0000 - - Update copyright info - -commit 9e8468f54aa5ecdb8b63c60449791427b59a474d -Author: Ivo Timmermans -Date: Sat Apr 13 10:02:16 2002 +0000 - - Remove debug level declaration - -commit 9f2c50e159caea1884c6a7aaa33f8098539ae0f5 -Author: Guus Sliepen -Date: Fri Apr 12 08:25:01 2002 +0000 - - Adding even more stuff from the CABAL branch. - -commit 191dcd5add0afba8b5d3aaa1e188c562c621712e -Author: Ivo Timmermans -Date: Thu Apr 11 20:18:02 2002 +0000 - - Also compile in pokey/ - -commit 39e93f473d34d6cdf6f4a7f0390a3b50cbd7b564 -Author: Ivo Timmermans -Date: Thu Apr 11 20:17:33 2002 +0000 - - Write src/pokey/Makefile - -commit c351b9e25b9f7b168a47fd8e6b60c66377e1824c -Author: Ivo Timmermans -Date: Thu Apr 11 14:27:35 2002 +0000 - - Pokey interface definition - -commit 17b308f0f0879c01f6864265af2e63595e965993 -Author: Ivo Timmermans -Date: Thu Apr 11 14:23:56 2002 +0000 - - Main pokey interface files. - -commit b5b38381c643632aa88c677236cace8c60e8344e -Author: Ivo Timmermans -Date: Tue Apr 9 16:11:48 2002 +0000 - - Last bits (hopefully) - -commit 77dd7b55801a3c7c2c6221664204ffdd7b83836a -Author: Ivo Timmermans -Date: Tue Apr 9 15:51:26 2002 +0000 - - More... - -commit 58c1df4028429ed6de4dad9455e3c92928450ffe -Author: Ivo Timmermans -Date: Tue Apr 9 15:48:54 2002 +0000 - - More updates - -commit 86dc60b9808d3aac70eccda80607a91ffd2e5292 -Author: Ivo Timmermans -Date: Tue Apr 9 15:32:14 2002 +0000 - - Ok, I forgot these ;) - -commit af23dfa5efb82b35eb00b94bda56390c9e2aac6f -Author: Ivo Timmermans -Date: Tue Apr 9 15:28:45 2002 +0000 - - Updating HEAD branch #5; Last files from CABAL. - -commit 462ab530e546f5732dfd51134751da6f6910d679 -Author: Ivo Timmermans -Date: Tue Apr 9 15:26:01 2002 +0000 - - Updating HEAD branch #4; Merging CABAL -> HEAD. - -commit e64ef59df44d39c76c00dee22841bbcce7c24e47 -Author: Ivo Timmermans -Date: Tue Apr 9 15:07:27 2002 +0000 - - Updating HEAD branch #3; more obsolete files removed. - -commit db59cbfa47aa152bcfa807754189aa18f28cb569 -Author: Ivo Timmermans -Date: Tue Apr 9 14:58:14 2002 +0000 - - Updating HEAD branch #2; removing debian/ dir. - -commit 50f2afec7e6dab3d809fc1b82820d1069205b69b -Author: Ivo Timmermans -Date: Tue Apr 9 14:54:37 2002 +0000 - - Updating HEAD branch #1; removing obsolete files. - -commit e69d2258032362c85c5936a5c137c70227e59332 -Author: Guus Sliepen -Date: Tue Apr 9 11:44:47 2002 +0000 - - Remarks about 1.0pre7 release. - -commit f2a3fcbdda250e5982c3ef36808568f996f8fff1 -Author: Guus Sliepen -Date: Tue Apr 9 11:43:45 2002 +0000 - - Updated dutch translation. - -commit b1322d244ff24e900f2298b8aa775d825c8ab00b -Author: Guus Sliepen -Date: Tue Apr 9 11:43:29 2002 +0000 - - masklength is better known as prefixlength - -commit 5df8a8cb3f4a0d2290f6677b44bbcaaf27a60bbc -Author: Guus Sliepen -Date: Tue Apr 9 11:42:48 2002 +0000 - - masklength is better known as prefixlength. - -commit 630dd023b990e076fdab890ff90783dc1ac7c13f -Author: Guus Sliepen -Date: Mon Apr 8 13:27:09 2002 +0000 - - Automake forgets about depcomp, remind it. - -commit ad6b1203490699ecc708290b2af1a45e134a5e20 -Author: Guus Sliepen -Date: Fri Apr 5 09:11:38 2002 +0000 - - Fix maskcheck() and maskcmp(). - -commit d8c249008a0b2abd44e652ed70e69b3dbc05b9d8 -Author: Guus Sliepen -Date: Mon Apr 1 21:28:39 2002 +0000 - - check_rsa() is broken, I don't know why, just remove it for now. - -commit 438419734ebee38dc3f7390e5c8ae8e6ca2cb6cf -Author: Guus Sliepen -Date: Mon Apr 1 21:28:05 2002 +0000 - - Don't check_network_activity() if select() is interrupted by a signal. - -commit 3d8a373bb3a788efffc555122b9d0569b96c5944 -Author: Guus Sliepen -Date: Wed Mar 27 19:43:50 2002 +0000 - - Make configure --help output look nicer. - -commit 9a03e7fa3d52ea062b4a3ff88b5d87ee95d24772 -Author: Guus Sliepen -Date: Wed Mar 27 16:26:26 2002 +0000 - - Update with information about the pre6 release. - -commit 33d3bad87d5f3e00e3ed81b75bca2ef21fd6e983 -Author: Guus Sliepen -Date: Wed Mar 27 16:00:49 2002 +0000 - - Update dutch translation. - -commit 0fe3dc38ed0527a5cfda9218114c8ee10422086b -Author: Guus Sliepen -Date: Wed Mar 27 16:00:38 2002 +0000 - - Fix format strings. - -commit 420f46acb0551a290b3263e39347b694286b2fa4 -Author: Guus Sliepen -Date: Wed Mar 27 15:47:06 2002 +0000 - - Remove symlink to device.c when doing a make dist. - -commit a5d8be8b1a9978d58c251d1020bb730bb1dc8ea1 -Author: Guus Sliepen -Date: Wed Mar 27 15:35:07 2002 +0000 - - Recent automake uses $(AMTAR) instead of $(TAR) - -commit c6d2f6c620beae387e8f9fc995ed7c8e8a5bc3dc -Author: Guus Sliepen -Date: Wed Mar 27 15:26:44 2002 +0000 - - Remove cruft. - -commit efd29fde85481e080a676f2ba780a528a90a9925 -Author: Guus Sliepen -Date: Wed Mar 27 15:26:29 2002 +0000 - - Small updates. - -commit 5eba1e1f6feadb3f7efb1261bd65e1e9e40b7f2b -Author: Guus Sliepen -Date: Wed Mar 27 15:01:37 2002 +0000 - - Limit the amount of packets in a queue to 8. - -commit 61cb593e670107ca3041f582c5486c243d5eda9e -Author: Guus Sliepen -Date: Wed Mar 27 15:01:16 2002 +0000 - - Extend list_t with the number of elements in the list. - -commit 0e7136027ce05bfeca977f2f64f3b228ea4fda87 -Author: Guus Sliepen -Date: Wed Mar 27 14:02:36 2002 +0000 - - Merge do_prune() with build_fdset(). Probably fixes the invalid filedescriptor error. - -commit e2238047d39eacc69da5732937021c38171ec7b9 -Author: Guus Sliepen -Date: Tue Mar 26 13:19:56 2002 +0000 - - Small correction. - -commit 7d07df71f9b82afdcf23494867bb8899198a6223 -Author: Guus Sliepen -Date: Tue Mar 26 12:00:38 2002 +0000 - - Fix execute_script(). - -commit 2de5e0eef911b9ff723d562ef9c62d833f3cdc45 -Author: Guus Sliepen -Date: Mon Mar 25 15:51:58 2002 +0000 - - Send REQ_KEY only once until ANS_KEY has arrived. - -commit a0c1696515fabd2183da7d8d83fd68410d2ec834 -Author: Guus Sliepen -Date: Mon Mar 25 15:12:09 2002 +0000 - - Tell a little bit more about security. - -commit 89a2f761a6d8ae4912c2dd2e9178589001487ef5 -Author: Guus Sliepen -Date: Mon Mar 25 15:01:32 2002 +0000 - - Updated documentation. - -commit 33d8747021d57c5827c6a755739756f95c7527c8 -Author: Guus Sliepen -Date: Mon Mar 25 13:54:49 2002 +0000 - - Set myself->status.reachable. - -commit 2749b997df33749f13d05e294db0e1e327e81d12 -Author: Guus Sliepen -Date: Sun Mar 24 17:14:01 2002 +0000 - - Configuration variables were still handled case sensitively. - -commit c73bdd6bc8e213b7e27848b97307228c01570a1d -Author: Guus Sliepen -Date: Sun Mar 24 17:08:38 2002 +0000 - - OpenBSD tun device uses address family number instead of Ethernet type. - -commit 8379c14b7f7a9b1400dd3776fc21dc9ccddd991d -Author: Guus Sliepen -Date: Sun Mar 24 16:50:58 2002 +0000 - - Respect type field. - -commit ad4f5cbc5fbce23893b7d42669ba907f18cc8ff4 -Author: Guus Sliepen -Date: Sun Mar 24 16:40:14 2002 +0000 - - Updated dutch translation. - -commit 4252ae83a43ea81382ce71ba614e2d1655f2e189 -Author: Guus Sliepen -Date: Sun Mar 24 16:36:56 2002 +0000 - - Set $INTERFACE correctly when using ethertap while compiled with tun/tap support. - -commit d699f3079c658e05f928c358d110d1d27849ea71 -Author: Guus Sliepen -Date: Sun Mar 24 16:28:27 2002 +0000 - - Execute hosts/name-up when a node becomes reachable, and hosts/name-down - when it becomes unreachable. - -commit 6ad5dd1a9adb1c1322ceb44d6f0fd160229e72ff -Author: Guus Sliepen -Date: Sun Mar 24 16:22:59 2002 +0000 - - Don't try to execute scripts unless they exist. - -commit 594d5b5d15551bd802c43926c7cb8863b7531654 -Author: Guus Sliepen -Date: Sat Mar 23 20:21:10 2002 +0000 - - Reset retry timeout when receiving the first PONG, not right after receiving the ACK. - -commit cbd8133ab4a2ea8a0c46224a5f1ae79e92819e5f -Author: Guus Sliepen -Date: Sat Mar 23 20:13:56 2002 +0000 - - Don't run graph algorithms if no edge is deleted in terminate_connection(). - -commit 6aee1ad021092d37538e15da22367789a4d4a763 -Author: Guus Sliepen -Date: Sat Mar 23 20:12:29 2002 +0000 - - free() request strings when deleting past requests from the tree. - -commit ccea26e0044ea59a9722385c9d69b1bc703e884f -Author: Guus Sliepen -Date: Sat Mar 23 20:01:05 2002 +0000 - - send_ack() was broken. - -commit 3c5655f59e85d312d11fa04489123e604920f95b -Author: Guus Sliepen -Date: Fri Mar 22 13:31:18 2002 +0000 - - Fix compiler warnings, strictly use long int and %lx for options. - -commit d6b70ed6f8b7ed65f64193fcfcdb6c8f4625e03c -Author: Guus Sliepen -Date: Fri Mar 22 12:41:54 2002 +0000 - - Fix add_edge_h(). - -commit 52e7699273a3009fe4d91e608522401076922785 -Author: Guus Sliepen -Date: Fri Mar 22 11:43:48 2002 +0000 - - - Added support for jumbograms. - - Remove tcpaddress from edges, it is not used at all. - - Last bits of code to prevent looping requests. - -commit 9da5390666ad532825d820b3554da3f39d3bc511 -Author: Guus Sliepen -Date: Thu Mar 21 23:11:53 2002 +0000 - - Put a break on requests that run around in circles. - -commit f48f8f4fedba365ceea30e1133bf1c560e9a522a -Author: Guus Sliepen -Date: Tue Mar 19 22:48:25 2002 +0000 - - Updated SSSP algorithm to automatically detect indirect links (if a node uses - different addresses for connections to other nodes). - -commit 5a88a27742d305be48498a297b90ee3fbdd935bf -Author: Guus Sliepen -Date: Tue Mar 19 00:08:34 2002 +0000 - - Updated dutch translation. - -commit 5c2d74de86d1acb3774a20357ad815d000f8a7f6 -Author: Guus Sliepen -Date: Tue Mar 19 00:08:23 2002 +0000 - - Don't use s6_addr[16|32] anymore. - -commit 9d99a789c38e8a1694537e427e8d4313c948b02b -Author: Guus Sliepen -Date: Tue Mar 19 00:07:09 2002 +0000 - - Cleanup. - -commit 305505f5ec4bb738f175cd897fa409f08d2971a3 -Author: Guus Sliepen -Date: Mon Mar 18 22:47:20 2002 +0000 - - Remember sockaddrs of listening sockets, use appropriate one when sending - UDP packets. - -commit 106fc2b769a635142bf5f9233a2f03e3a0f26b7f -Author: Guus Sliepen -Date: Mon Mar 18 14:39:37 2002 +0000 - - Fix #define s6_addr32. - -commit 813c369a8faca94fc38bc66afafad063fa00f928 -Author: Guus Sliepen -Date: Mon Mar 18 14:19:02 2002 +0000 - - #define s6_addr32, needed for FreeBSD. - -commit b2579385de427c3c03d28520d3a93bd5f9bc9488 -Author: Guus Sliepen -Date: Sun Mar 17 16:08:39 2002 +0000 - - Only unmap IPv6 addresses. - -commit 8b84c44175fedb81ca38107e0067ddea750add00 -Author: Guus Sliepen -Date: Sun Mar 17 15:59:29 2002 +0000 - - Unmap v4mapped sockaddrs. - -commit 07e37f8da03fa315be39623e62d8acba617aa226 -Author: Guus Sliepen -Date: Fri Mar 15 15:50:14 2002 +0000 - - Typo. - -commit e0dee537705cdbd005f6ab1fbef5ac71dc8411c0 -Author: Guus Sliepen -Date: Fri Mar 15 15:40:40 2002 +0000 - - Different way of detecting neighbor solicitation requests. - -commit 0e93f0aa02274481c16fc9f30b795d4f063bd1c3 -Author: Guus Sliepen -Date: Fri Mar 15 15:08:21 2002 +0000 - - Oops, don't forget to actually put the checksum in the response packet. - -commit e1de9ca990ea638c7e297c5335be415e44c250c1 -Author: Guus Sliepen -Date: Fri Mar 15 14:41:57 2002 +0000 - - Neighbor solicitation requests now work (I think). - -commit 4b3aef9e6992ca78f1b17b179a3051d3fec0473d -Author: Guus Sliepen -Date: Tue Mar 12 16:30:15 2002 +0000 - - Revert changes to Kruskal's algo. - -commit f219f156cf13fd30369d7cd4632c406ffd6ff628 -Author: Guus Sliepen -Date: Tue Mar 12 14:25:04 2002 +0000 - - Put #ifdef NEIGHBORSOL around corresponding code. - -commit ecad9e9289162faec7b678be54178d22876b5d90 -Author: Guus Sliepen -Date: Tue Mar 12 14:20:44 2002 +0000 - - Remove silly cache thingy. - -commit d6c2c4f2b7a94ef6a4db0de134d015bc8d21ffb1 -Author: Guus Sliepen -Date: Tue Mar 12 14:19:51 2002 +0000 - - Packet sequence number/authentication warnings only if debug_lvl >= 5. - -commit 2e7db2a6936a77baa0a81eb566674bd76d204951 -Author: Guus Sliepen -Date: Tue Mar 12 13:42:23 2002 +0000 - - Simplified implementation of Kruskal's minimum spanning tree algorithm. - -commit d2e0ed533c8aa3c6ab538d87e004108c631cb0be -Author: Guus Sliepen -Date: Mon Mar 11 13:56:00 2002 +0000 - - New strategy: forward icmp6 neighbor solicitations to intended target. - -commit 46fa10cec7b6bf26773f5e86e7b8118d9075e807 -Author: Guus Sliepen -Date: Mon Mar 11 13:14:53 2002 +0000 - - Try to reply to neighbor solicitation requests. - -commit c2713ba7a5ff12e270d66a5d3188a3640873830e -Author: Guus Sliepen -Date: Mon Mar 11 11:45:12 2002 +0000 - - prune_connections() before build_fdset(). - -commit 4fda4560bbdd41e217ce0e1a90ba98c79e4f3519 -Author: Guus Sliepen -Date: Mon Mar 11 11:23:04 2002 +0000 - - Cleanups, spelling fixes, allow symbol names for signals (-k option), - don't remove pidfile if other tincd is still running. - -commit 5ffeb13d65313d5a191a605690a4f8fdf1604b48 -Author: Guus Sliepen -Date: Sun Mar 10 16:09:15 2002 +0000 - - Don't retry to make outgoing connections when exitting. - -commit 3cbe67a8de1da7bd042474de4d16cb4f7e9822ab -Author: Guus Sliepen -Date: Sun Mar 10 15:40:27 2002 +0000 - - Small fixes to improve portability. - -commit 9de7470bfdabacec5f3769bf5cfa97ef4e481ba0 -Author: Guus Sliepen -Date: Sun Mar 10 14:07:08 2002 +0000 - - Autodetect $MAKE/gmake/make. - -commit 0c34478cc03167208c84f3d6d2ed6e53172b4711 -Author: Guus Sliepen -Date: Sun Mar 10 14:05:35 2002 +0000 - - po/POTFILES and po/Makefile should not be generated by configure. - -commit 024ab44d98883d78cefe2c622cec9831c7f19c13 -Author: Guus Sliepen -Date: Sun Mar 10 14:04:48 2002 +0000 - - Fix forwarding of IPv6 packets. - -commit 0c16add71c6432c882c6d8f538a4b2db0026ec24 -Author: Guus Sliepen -Date: Fri Mar 1 15:14:29 2002 +0000 - - Check if BindToDevice and PriorityInheritance are supported. - -commit 7d5741859e681e6b0d0e32b978da6f309c456729 -Author: Guus Sliepen -Date: Fri Mar 1 14:33:48 2002 +0000 - - Woops. - -commit ab90fa9bd1a653a330be7ef11293000721a0e7b4 -Author: Guus Sliepen -Date: Fri Mar 1 14:25:10 2002 +0000 - - Document and clean up MAC address expiry. - -commit 14979f835df4214a7c2510852f7ffedc9e08c2c0 -Author: Guus Sliepen -Date: Fri Mar 1 14:09:31 2002 +0000 - - - Global time_t now, so that we don't have to call time() too often. - - MAC addresses expire after a time configurable by MACExpire (default 600 - seconds) - -commit 7496ecc45ab6205bcce4e576c23b9afb52004e39 -Author: Guus Sliepen -Date: Fri Mar 1 13:38:15 2002 +0000 - - Updated dutch translation. - -commit 0c879b8eeed3477b0f1cdd2f232e67e38bd9bce6 -Author: Guus Sliepen -Date: Fri Mar 1 13:38:02 2002 +0000 - - Updated documentation. - -commit f93b1334e087dd7af1b87f475b2d398fdd4d56ab -Author: Guus Sliepen -Date: Fri Mar 1 13:18:54 2002 +0000 - - Create/bind TCP and UDP listening sockets in pairs. - -commit c2b738e7b51fbec2b11fbbf030b9a5a36df55fc4 -Author: Guus Sliepen -Date: Fri Mar 1 12:26:56 2002 +0000 - - If "PriorityInheritance = yes" is specified in tinc.conf, the value of the - TOS field of the tunneled packets will be passed on to the UDP packets tinc - sends out. - -commit 80ea653e8d8050878380fbc1446571cbaf578297 -Author: Guus Sliepen -Date: Fri Mar 1 12:25:58 2002 +0000 - - Fix listening sockets. - -commit 7f58ed7685f9fcd5271359a8c896670a835e1f95 -Author: Guus Sliepen -Date: Fri Mar 1 11:18:34 2002 +0000 - - Make BindToInterface work. - -commit 17bc5220c332fdd083fd47fc600010f85171adc7 -Author: Guus Sliepen -Date: Wed Feb 27 22:37:55 2002 +0000 - - Fix send_request() bug. - -commit 50403909b6bf6536924d4693bb1f32c248f17fda -Author: Guus Sliepen -Date: Tue Feb 26 23:26:41 2002 +0000 - - Allow multiple listening sockets. - -commit 2ac7be0d51a112108dc6c2b1c6f46da022f72f40 -Author: Guus Sliepen -Date: Tue Feb 26 22:47:51 2002 +0000 - - Tweaking IPv6 support. - -commit 23fda5688e8a109f8a50511538b14e4fbe4f738c -Author: Guus Sliepen -Date: Wed Feb 20 22:37:38 2002 +0000 - - - Change SA_LEN to SALEN, former one is already defined on some platforms. - - Use SALEN everywhere appropriate. - -commit dbc5b5bb5eb3096ad930aa6b590deaba2a103dfc -Author: Guus Sliepen -Date: Wed Feb 20 22:15:32 2002 +0000 - - - Use gai_strerror() where appropriate - - Clear hints before using them with getaddrinfo() - - Use sa_len on platforms that support them - -commit 28cc9a6488f78c72152251f6fa2ee84d417223e8 -Author: Guus Sliepen -Date: Wed Feb 20 19:31:15 2002 +0000 - - Preserve inpkt->len, needed for broadcasts. - -commit c6d01588312bec7691e72b42cf20c59ffe2749c2 -Author: Guus Sliepen -Date: Wed Feb 20 19:25:09 2002 +0000 - - Protocol now also exchanges cipher/digest/maclength/compression for the - meta connection. - -commit 626d5956d2bb0660ba315fba77da6cec9776fd3b -Author: Guus Sliepen -Date: Wed Feb 20 17:16:15 2002 +0000 - - Cache results of lookup_subnet_...(). - -commit e8e69460a7090aaf6ecda8970d3060695de81b00 -Author: Guus Sliepen -Date: Wed Feb 20 17:15:33 2002 +0000 - - Fix maskcmp() and maskcpy(). - -commit ed509312906625acee4007da6262de3898846888 -Author: Guus Sliepen -Date: Wed Feb 20 16:04:59 2002 +0000 - - Forward packets in router mode. - -commit 8c91fac31570594b6249d632cefe768f33c54b19 -Author: Guus Sliepen -Date: Wed Feb 20 16:04:39 2002 +0000 - - Use AF_UNSPEC for listening sockets if AddressFamily = any. - -commit 76f01453dfa157b0070751b1025e55a1e36ebdca -Author: Guus Sliepen -Date: Wed Feb 20 16:04:07 2002 +0000 - - Fix segfault when receiving HUP signal. - -commit c2b9c06062d36bde859b630b99a08c7b7428e721 -Author: Guus Sliepen -Date: Mon Feb 18 16:25:19 2002 +0000 - - - Non-blocking connect()s. - - Socket handling revamped to use sockaddr_t. - - tinc can now tunnel over IPv6. - - Handle all addresses and subnets in network byte order. - Only convert them when they need to be printed. - - IPv6 subnets bigger than /128 now work. - - Use %s and strerror(errno) instead of %m. - -commit fc674eaae14ed2e07abc0df1285b1bd70e0d27cc -Author: Guus Sliepen -Date: Tue Feb 12 14:42:37 2002 +0000 - - Add check for NetBSD. - -commit 2fb8a62edef7cb0988e44f92c3948cde6f34875e -Author: Guus Sliepen -Date: Tue Feb 12 14:40:12 2002 +0000 - - Added device.c for NetBSD, actually a copy of the OpenBSD one. - -commit f64b41a73b3b432aae17ba990414e0be2f61ce62 -Author: Guus Sliepen -Date: Tue Feb 12 14:36:45 2002 +0000 - - Get rid of sys/signal.h. - -commit dd611fb4f91b9b17c20c458694d2765b22814c5f -Author: Guus Sliepen -Date: Tue Feb 12 14:29:00 2002 +0000 - - Don't use sa_sigaction (which NetBSD doesn't like) at all if we don't use siginfo. - -commit d9a62c6354d1e2ad78ee8c610518ae9f9ab012d1 -Author: Guus Sliepen -Date: Mon Feb 11 15:59:18 2002 +0000 - - Added support for packet compression, thanks to Mark Glines. - Add "Compression = " to the host config files, where level can be - 0 (off), or any integer between 1 (fast) and 9 (best). - -commit 94b171b3051b999e619ae19e1c9c29d356606788 -Author: Guus Sliepen -Date: Mon Feb 11 14:20:46 2002 +0000 - - Small fix. - -commit 1708997bc8ab55122f9de9cc8b81397d3a003ea9 -Author: Guus Sliepen -Date: Mon Feb 11 14:20:21 2002 +0000 - - - If no PrivateKeyFile is specified, /etc/tinc/netname/rsa_key.priv is assumed. - - Check RSA key before using it. - -commit 1c34ba7fb8580949f3bd3a0d804747bbaea28e36 -Author: Guus Sliepen -Date: Mon Feb 11 12:33:01 2002 +0000 - - Sensible defaults for $INTERFACE. - -commit 24cc2a9065a4e962fb05addac47322930099a4b5 -Author: Guus Sliepen -Date: Mon Feb 11 10:16:18 2002 +0000 - - Last bits of the merger. - -commit 5bf4b88666ecafe190e8ed71d6c14c9de8d16e1f -Author: Guus Sliepen -Date: Mon Feb 11 10:05:58 2002 +0000 - - Forgot to merge new files from pre5. - -commit f0aa9641e82fb6e09c1e485366d14dddaa7f7c36 -Author: Guus Sliepen -Date: Sun Feb 10 21:57:54 2002 +0000 - - Merging of the entire pre5 branch. - -commit c2752b961c9262386b940c2c053b9909bee22859 -Author: Ivo Timmermans -Date: Fri Nov 16 22:41:38 2001 +0000 - - Conversion to struct addrinfo is almost complete for this file. - -commit 4f47da5b87ef7da608c7e44026122f3d95deb2eb -Author: Ivo Timmermans -Date: Fri Nov 16 22:40:26 2001 +0000 - - Don't include netutl.h. - -commit a59bbc72317c9cd97243a9cbf49db01ff249eb1e -Author: Ivo Timmermans -Date: Fri Nov 16 22:31:41 2001 +0000 - - Fixed silly typo: "np" instead of "no" - -commit bf664c054fdabc30679367a752a27bb769655e4d -Author: Ivo Timmermans -Date: Fri Nov 16 22:31:15 2001 +0000 - - get_config_subnet needs to be fixed. - -commit 9b2b3747340173590b8f6f5fbdd060b42985f026 -Author: Ivo Timmermans -Date: Fri Nov 16 17:40:50 2001 +0000 - - route_ipv4 and route_ipv6 replaced by route_ip. - -commit a4938b22e7502579ce44cac42410111db11256eb -Author: Ivo Timmermans -Date: Fri Nov 16 17:39:59 2001 +0000 - - Don't include netutl.h. - -commit ccda709f8243949a3c0ffcc6133d8d8fc5125f2e -Author: Ivo Timmermans -Date: Fri Nov 16 17:39:38 2001 +0000 - - lookup_node_udp changed. - -commit 836766d4c5bc47682ab69c57337157c879517670 -Author: Ivo Timmermans -Date: Fri Nov 16 17:38:39 2001 +0000 - - First part of rewriting things to use struct addrinfo. - -commit 2ec5b5f8621d9fb91181ab155084daa1bb2d1a54 -Author: Ivo Timmermans -Date: Fri Nov 16 17:37:08 2001 +0000 - - Added dropin replacements for get*info and helper functions. - -commit aabe59f6305cdd46220e95d8927a1636d4b4819d -Author: Ivo Timmermans -Date: Fri Nov 16 16:16:33 2001 +0000 - - Added HAVE_STRUCT_ADDRINFO - -commit 251f87c842b62cf770129d8a953fb06ef5d0e466 -Author: Ivo Timmermans -Date: Fri Nov 16 15:56:44 2001 +0000 - - (re)added port to struct node_t - -commit 6cf744e4b29cfe3b135b6553851816802ba3d8a8 -Author: Ivo Timmermans -Date: Fri Nov 16 12:22:02 2001 +0000 - - Don't include netutl.h. - -commit a79252af4383b8cd71cf0d13f1ae040d518517bf -Author: Ivo Timmermans -Date: Fri Nov 16 12:21:22 2001 +0000 - - Obsoleted. - -commit 331d9402e892b4baa9cadbbb364073ae10b58d99 -Author: Ivo Timmermans -Date: Fri Nov 16 12:16:28 2001 +0000 - - Don't compile/link netutl.c. - -commit f95e6ca8f6976d7a15f4623e25c85e1c7f82c04b -Author: Ivo Timmermans -Date: Fri Nov 16 12:14:20 2001 +0000 - - get_config_{ip,port} removed. - -commit 31db57bb4a00f5ca3743b89f8bb2fbd39919bf28 -Author: Ivo Timmermans -Date: Fri Nov 16 12:13:34 2001 +0000 - - Changed to use struct addrinfo where needed. - -commit f1b20b3ded5b360e426e094cf79df3bf97f350b4 -Author: Ivo Timmermans -Date: Fri Nov 16 12:10:54 2001 +0000 - - Obsoleted all IP types in favor of struct addrinfo - -commit fb6dc0b0890ebae2471e00e7a3e1d86c1fc3d646 -Author: Ivo Timmermans -Date: Fri Nov 16 12:08:38 2001 +0000 - - Removed definitions of ipv4_t, ipv6_t, port_t - -commit 3ef15f2554d1819d6c7d2573dac6039f2e76b638 -Author: Ivo Timmermans -Date: Fri Nov 16 12:02:17 2001 +0000 - - Changed lookup_connection to use struct addrinfo - -commit 74e1299fb58025f7506c7e2608c353a76f98d8df -Author: Ivo Timmermans -Date: Fri Nov 16 12:01:48 2001 +0000 - - Changed prototype for lookup_connection to use struct addrinfo - -commit 51b72b75f254c956b62be9dfca642145b199415f -Author: Ivo Timmermans -Date: Fri Nov 16 00:23:28 2001 +0000 - - Use struct addrinfo in connection_t to hold all host data such as IP - address and port - -commit 72395f989cb44132d7c756c91b3a6d8ba63517e5 -Author: Ivo Timmermans -Date: Fri Nov 16 00:13:08 2001 +0000 - - Deprecated get_config_ip and get_config_port - -commit 93cd0e33defba46f8e51d9a98a94599ceb0d521c -Author: Ivo Timmermans -Date: Thu Nov 15 23:49:46 2001 +0000 - - Check for struct addrinfo - -commit b16bf68a6dc27b364cb76156a7be0208594f1e94 -Author: Ivo Timmermans -Date: Thu Nov 15 23:28:58 2001 +0000 - - Credit OpenSSH - -commit 18269cfbe831902b97a6171ba0346fd323583e48 -Author: Ivo Timmermans -Date: Thu Nov 15 23:26:27 2001 +0000 - - Check for getnameinfo, gai_strerror, freeaddrinfo - -commit ae11e7c3d71893c5200b12682839538a52df37b8 -Author: Ivo Timmermans -Date: Thu Nov 15 23:05:34 2001 +0000 - - Check for getaddrinfo - -commit e06415e3d9d08cd33c5983a2c49c4101377160c2 -Author: Guus Sliepen -Date: Mon Nov 5 19:09:08 2001 +0000 - - More fixes for Solaris. - -commit 25a804c94ef0dbc4e5582ea6d8459d5f9a3fe06c -Author: Guus Sliepen -Date: Mon Nov 5 19:06:07 2001 +0000 - - Various fixes needed for Solaris. - -commit b2d5002ff1ccd44fbf3a94e4c41909ab6141f3bb -Author: Guus Sliepen -Date: Sun Nov 4 23:48:27 2001 +0000 - - Correctly check if subnet owner exists. - -commit ede6671c1354eeab86936efda32f6cdb3b3fd8d5 -Author: Guus Sliepen -Date: Sun Nov 4 23:29:50 2001 +0000 - - Be liberal in what you accept: allow unknown edges to be deleted. - -commit cf0e133e191cb40954bf5b6ee0a579442fe4b60b -Author: Guus Sliepen -Date: Sat Nov 3 22:53:02 2001 +0000 - - *** empty log message *** - -commit e5047d2835f0828a9c334cc3d928c2322abfefb7 -Author: Guus Sliepen -Date: Sat Nov 3 21:22:02 2001 +0000 - - Several bugfixes. - -commit 8910cbd67e13450e93816ecafa0cc5be5e4c2378 -Author: Guus Sliepen -Date: Sat Nov 3 21:21:04 2001 +0000 - - Use PEM functions as suggested by OpenSSL docs. - -commit 8e74c5bee48f2ef363193044d5309a65e91c70d8 -Author: Guus Sliepen -Date: Wed Oct 31 20:37:54 2001 +0000 - - Some very small fixes - -commit ffb88ff6410f33de92db108bd1e0c3a915368214 -Author: Guus Sliepen -Date: Wed Oct 31 20:22:52 2001 +0000 - - Avoid connecting to another node twice, and check name of outgoing connections. - -commit 6d333ad680465c26953ad4c8ca9140e27da868c5 -Author: Guus Sliepen -Date: Wed Oct 31 20:07:17 2001 +0000 - - Show cfg->variable instead of cfg->value when complaining about wrong type. - -commit 54b756f7dfb71c5622b7738fd449e126da959864 -Author: Guus Sliepen -Date: Wed Oct 31 20:02:06 2001 +0000 - - Don't forget to read public RSA key when making an outgoing connection. - -commit c0a3f67a5d66088aaf526f1461986f9e86d5dd1f -Author: Guus Sliepen -Date: Wed Oct 31 12:50:24 2001 +0000 - - - Small fixes to graph algorithms - - More control over tap device, ability to set interface name to something - other than the netname. - - Export NETNAME, DEVICE and INTERFACE environment variables to scripts. - -commit 2165931c62f0433fd97bd3ac6aefea3627218946 -Author: Guus Sliepen -Date: Tue Oct 30 16:34:32 2001 +0000 - - More updates to protocol handlers and reimplemented terminate_connection(). - -commit 87ad5c97a9a73a65050ad7adce34503f856d8665 -Author: Guus Sliepen -Date: Tue Oct 30 12:59:12 2001 +0000 - - Various fixes, tinc is now somewhat capable of actually working again. - -commit cc9473d8c6467e9eaa82fe8a639d8edba232ee76 -Author: Guus Sliepen -Date: Mon Oct 29 13:14:57 2001 +0000 - - Working version of Kruskal's algorithm. The running time is very bad though. - -commit b6298e2c082035b8238ea08673ced15d0fb7b89a -Author: Guus Sliepen -Date: Sun Oct 28 22:42:49 2001 +0000 - - - More changes needed for Kruskal's algorithm - - Implemented a breadth-first search algorithm as a cheap substitution for a - single-source shortest path algorithm. - -commit 66067cc9c1347fb2de35660d531fdd4be8aede6a -Author: Guus Sliepen -Date: Sun Oct 28 10:16:18 2001 +0000 - - - More s/vertex/edge/g - - Implementation of Kruskal's minimum spanning tree algorithm. - -commit 94497336efc1cc60561575e74d420e9e8e8c657e -Author: Guus Sliepen -Date: Sun Oct 28 08:41:19 2001 +0000 - - What was I thinking? s/vertex/edge/g. - -commit b98d9787fdde54f33dcdb376e1e018cd418aff8d -Author: Guus Sliepen -Date: Sat Oct 27 15:19:13 2001 +0000 - - Various small fixes to make tinc runnable again. - -commit ac066bb057dcb187bf91670793ba5e6ca456e052 -Author: Guus Sliepen -Date: Sat Oct 27 13:13:35 2001 +0000 - - Make sure everything links. - -commit 82e383710980534d38bb9a8ef22f20677cd85861 -Author: Guus Sliepen -Date: Sat Oct 27 12:13:17 2001 +0000 - - Big bad commit: - - Transition to new node/vertex/connection structures - - Use new configuration handling everywhere - - Linux tun/tap device handling cleanup - - Start of IPv6 support in route.c - - It compiles, but it won't link. - -commit 1935c44a1e8ab7c31c836f90215e3c5b5f8dd776 -Author: Guus Sliepen -Date: Sat Oct 13 13:53:07 2001 +0000 - - Support new files (node/vertex/device.[ch]) and OpenBSD. - -commit 26e517dd37e995fe9db518f7ebeff023fc73ff1b -Author: Guus Sliepen -Date: Fri Oct 12 15:52:03 2001 +0000 - - Forgot the tun specific stuff. - -commit ad61c20f42d2bee5cc7976bec4370cf4747b42c3 -Author: Guus Sliepen -Date: Fri Oct 12 15:49:11 2001 +0000 - - Added OpenBSD tun device handling. Untested though. - -commit 0c6321a67f92981d3adbaf4f5c2b9867c7968964 -Author: Guus Sliepen -Date: Fri Oct 12 15:38:35 2001 +0000 - - Forgot to remove some old #ifdef stuff. - -commit 6014c7e6374089bfccea7467c2c7f4b23fefa265 -Author: Guus Sliepen -Date: Fri Oct 12 15:33:21 2001 +0000 - - Solaris tun device handling cleaned up a bit and added. - -commit 623c7ee0308aede8eada552d6ae33710ae24d176 -Author: Guus Sliepen -Date: Fri Oct 12 15:22:59 2001 +0000 - - Added FreeBSD tap device handling. - -commit ec34f25228d7a0007ce6bcb1e97f263868e9129d -Author: Guus Sliepen -Date: Fri Oct 12 15:16:03 2001 +0000 - - - Split tap device stuff out of net.[ch] - - Each OS gets it's own device.c to get rid of evil #ifdefs. - - Cleaned up Linux ethertap and tun/tap handling. - -commit 0bbace18e96cd6fc32dfa23ffd55f73ff96e8c6f -Author: Guus Sliepen -Date: Wed Oct 10 20:35:10 2001 +0000 - - More updates to new node/vertex/connection combo. - -commit ea607d2d9292d3969f9d164b432dc64a33c2dade -Author: Guus Sliepen -Date: Wed Oct 10 20:34:27 2001 +0000 - - Revamp configuration handling: - - Store everything in AVL trees (fast lookup) - - No need for hazahaza anymore - - Parse values when needed - - This simplifies a lot of config variable lookups. - -commit 5904806dc80830d4eddca857a41db2fc25598201 -Author: Guus Sliepen -Date: Wed Oct 10 09:42:29 2001 +0000 - - Removed everything from connection.c that has already been moved to node.c and - vertex.c. - -commit ec0c16b9b63f361b11a757ee1641d562e4811f93 -Author: Guus Sliepen -Date: Wed Oct 10 08:49:47 2001 +0000 - - Further implementation of doc/CONNECTIVITY. connection.[ch] is now split into a - node, vertex and connection part. - -commit 75e1ae3a287642ca4281792c94ecd07332f39c08 -Author: Wessel Dankers -Date: Tue Oct 9 19:41:56 2001 +0000 - - make is not always GNU make. - -commit f22b9417510cca258785f8958c8dfed90e26d81b -Author: Guus Sliepen -Date: Tue Oct 9 19:37:10 2001 +0000 - - Small corrections. - -commit 49a2cd806c73cff1ab6a712a996c7f7d4e1f32c0 -Author: Guus Sliepen -Date: Tue Oct 9 19:30:30 2001 +0000 - - Started implementing doc/CONNECTIVITY. - -commit 5926c82b9a29031a8c619432869d1549b51b62a0 -Author: Guus Sliepen -Date: Mon Oct 8 15:47:30 2001 +0000 - - Updated dutch translation. - -commit fcc3ded75fe9f831aeb8678ee5e3926bf4168906 -Author: Guus Sliepen -Date: Mon Oct 8 15:37:14 2001 +0000 - - Fix bug when dropping an old connection in favour of a new one from the - same host. - -commit 1ef90a87fd9fd53c25a43455ffaac5274a63dc08 -Author: Guus Sliepen -Date: Mon Oct 8 13:37:30 2001 +0000 - - - Use ping timeout mechanism to close connections that don't authenticate - in time. - - Fix potential segmentation fault in check_dead_connections(). - -commit ce9fd32c04adf83cbaf668ee42a29575ba256002 -Author: Guus Sliepen -Date: Mon Oct 8 11:59:08 2001 +0000 - - Fix bug where tinc would crash because of a portscan or a connection from a - tinc daemon with a different version. - -commit 21027b1d5702c331b1ebb262bb149c75be1f24b1 -Author: Guus Sliepen -Date: Mon Oct 8 11:47:55 2001 +0000 - - - Renamed lastbutonehop to prevhop. - - Added connection_t *via to connection_t, this keeps record of where - to send UDP packets to. - -commit 18d1233c40a5705e9123edd6f4c6764a5178003b -Author: Guus Sliepen -Date: Tue Sep 25 13:39:11 2001 +0000 - - Fill in next- and lastbutonehop for myself. - -commit ec100a58b44e412a3d2606e5213af9ec5f30235b -Author: Guus Sliepen -Date: Tue Sep 25 13:35:45 2001 +0000 - - Try next connectto instead of the same over and over. - -commit 4d3de3b6a9b55bc783c649ff33e5415b0c7b5f25 -Author: Guus Sliepen -Date: Mon Sep 24 14:16:29 2001 +0000 - - Show next- and lastbutonehop when dumping connectionlist to syslog. - -commit 24a2c7e51a0b080c4bdb55f697b3f0458ebc3fb1 -Author: Guus Sliepen -Date: Mon Sep 24 14:12:00 2001 +0000 - - Not only keep track of nexthop, but also of lastbutonehop. If destination cl - wants indirectdata, send it to the lastbutonehop instead, unless it too has - requested so, and so on. - -commit 154733927af0b27cdadb83f03b845301ce8bfbfd -Author: Guus Sliepen -Date: Mon Sep 24 13:31:15 2001 +0000 - - - Try old TUN/TAP ioctl() request if the one from if_tun.h fails. - - Be more verbose about the kind of tap device used. - -commit 950c934e0bda28e5952d699d6008ee783d81982b -Author: Ivo Timmermans -Date: Wed Sep 5 18:38:09 2001 +0000 - - Killing tincd with SIGINT causes it to toggle between the current - debug level and level 5. Useful to debug a running tincd. - -commit a54ec980e047d13ecff7f1f337aa2665072febfd -Author: Guus Sliepen -Date: Sat Sep 1 12:46:49 2001 +0000 - - config_t* is a const parameter in get_config_val(). - -commit 68e23b1c9e69b2a218b3be821ad1ba3b3b6a64f2 -Author: Guus Sliepen -Date: Sat Sep 1 12:36:53 2001 +0000 - - Optional signal number for -k option. - -commit 8ed27d40f358581d021319cc26313c9f6ddf9a71 -Author: Guus Sliepen -Date: Sat Sep 1 12:36:06 2001 +0000 - - Revised reconnection mechanism, always try out all ConnectTo lines. - -commit ef1facc60709e9474197aa3fde9d517dfd96dc87 -Author: Guus Sliepen -Date: Sat Sep 1 12:02:39 2001 +0000 - - Remove IndirectData support for now, new implementation will be added - later. - -commit 8b5e4211304aaa5d39bc95f04398bd5ecaa887d8 -Author: Guus Sliepen -Date: Tue Aug 28 20:52:39 2001 +0000 - - Fix signed comparison bug in lookup_subnet_ipv4(). - -commit e1184ad15d6b2e7d58bdcb4489026dd0a35b4e5f -Author: Guus Sliepen -Date: Fri Aug 17 18:14:04 2001 +0000 - - Don't send DEL_HOSTs when !status.meta - -commit 30d22474ccc8da9a5685a90e0b2304ec627475af -Author: Guus Sliepen -Date: Tue Jul 24 20:14:30 2001 +0000 - - Explicitly log which type of tunnel device is used. - -commit 7e86cf91e3399905e19882bcf2d5677d7986aca5 -Author: Guus Sliepen -Date: Tue Jul 24 20:13:42 2001 +0000 - - The val variable in a config_t is never used as a long. - -commit 43923d2b106bfbe9300cc8e364cf098444cd649e -Author: Guus Sliepen -Date: Tue Jul 24 20:04:22 2001 +0000 - - Write public key to rsa_key.pub instead of rsa_key.priv (if not host - configuration file is found). - -commit 44e9d6a2872fac55f7eb701ba576ed9f39a22e08 -Author: Guus Sliepen -Date: Tue Jul 24 20:03:40 2001 +0000 - - Don't use %m in fprintf(). - -commit cbd03caece25d45015a4526b94b04a34ab87b0f2 -Author: Guus Sliepen -Date: Tue Jul 24 08:51:36 2001 +0000 - - More on edges. - -commit 3cd238f4e338f257ff61d58a9979b54344ee462f -Author: Guus Sliepen -Date: Mon Jul 23 22:06:22 2001 +0000 - - Discuss how sending ADD_EDGEs would be better than sending ADD_HOSTs. - -commit 5333cada0dfc4dfc3be728e6c78d8d42dc2ace52 -Author: Guus Sliepen -Date: Sun Jul 22 17:41:52 2001 +0000 - - Written down a possible solution. - -commit 995ab86fce506e9fabcf5a9ead7d43b30f12ab09 -Author: Guus Sliepen -Date: Sun Jul 22 15:25:13 2001 +0000 - - Correctie. - -commit d7b4de0e73baf664964f6daaf63526606b6a890b -Author: Guus Sliepen -Date: Sun Jul 22 14:58:18 2001 +0000 - - Small update. - -commit 71b9041f484128219f81cbf4f22a4e11388f879d -Author: Guus Sliepen -Date: Sun Jul 22 14:46:11 2001 +0000 - - Described problem in more detail. - -commit c1a98cd37ea20f6020487b2a5586e6de432398e7 -Author: Guus Sliepen -Date: Sun Jul 22 14:04:38 2001 +0000 - - Started writing a document about how daemons connect to each other. - -commit fcbe215d64d7e2f3b159fff6422d750417877ac4 -Author: Guus Sliepen -Date: Sat Jul 21 20:21:25 2001 +0000 - - Woohoo! tinc now compiles, runs and actually *works* on Solaris! - Tested on a SparcStation 20MP running Solaris 7. (Thanks, jiggel!) - -commit 533ee1206fb6433a1f0e616db999b3655addfaf2 -Author: Guus Sliepen -Date: Sat Jul 21 15:46:34 2001 +0000 - - Always close all sockets in terminate_connection(). - -commit acb853205d6d582d919c59879393b301ad4f4fde -Author: Guus Sliepen -Date: Sat Jul 21 15:34:18 2001 +0000 - - Updated terminate_connection() so you can choose if DEL_HOSTs should be - sent or not. - -commit 12f6b80429bc05a828051d72cc46f173e4657180 -Author: Guus Sliepen -Date: Fri Jul 20 20:25:10 2001 +0000 - - Added purge_tree for connection_t's which are no longer in the connection, - active or id trees, but which may still be referenced. This tree is flushed - when it is safe, this replaces purge_connection_tree(). - - Also lots of bugfixes related to the new trees. - -commit 37ed4265fa73d4c06c74362514d78c92029b2f05 -Author: Guus Sliepen -Date: Fri Jul 20 13:54:19 2001 +0000 - - Remove all unnecessary status.meta and status.active checks. - -commit 5e2ded68bfc7b3a1bfa600c1ce46144eb50e57a2 -Author: Guus Sliepen -Date: Thu Jul 19 12:29:40 2001 +0000 - - Correctly use the active_tree. - -commit 319e0cb48eb00565a11c85b901f54141f8160334 -Author: Guus Sliepen -Date: Sun Jul 15 18:07:31 2001 +0000 - - Split connection list into two lists: - - one list to handle all incoming/outgoing TCP connections - - another list to handle all UDP connections - - This will prevent race conditions. - -commit b3074590b184c141419cf4926820dc0d78380535 -Author: Guus Sliepen -Date: Sun Jul 15 14:21:12 2001 +0000 - - Correct inclusion of standard if_tun.h header file. - -commit 5dc4ade0b9c127a3c144d9c59894bf13527fe060 -Author: Guus Sliepen -Date: Wed Jul 4 08:43:32 2001 +0000 - - Don't load table of verbose OpenSSL errormessages. - -commit 1e2bdc2b6d28c76c63fc9fd36169b90fa0994388 -Author: Guus Sliepen -Date: Wed Jul 4 08:41:36 2001 +0000 - - - Always use instead of just - - Check if RAND_pseudo_bytes() exists, otherwise just use RAND_bytes() - -commit 6bd93e4c064578b545cb6dcaa28fffb229c929ff -Author: Guus Sliepen -Date: Sun Jul 1 21:42:13 2001 +0000 - - Check for all potential duplicate entries in the id tree. - -commit 9645cabc8e8364ed4df187fab8065b0991afa6af -Author: Guus Sliepen -Date: Sun Jul 1 09:21:14 2001 +0000 - - Fix compiler warning. - -commit 6365d0627b9b1e9a31371ec891db0d2cfb4d6ed4 -Author: Guus Sliepen -Date: Sun Jul 1 09:21:01 2001 +0000 - - Fix printf format bug. - -commit 33d6de0cd5c05cbf37211924a45e4231fec3a416 -Author: Guus Sliepen -Date: Sun Jul 1 09:06:17 2001 +0000 - - More items marked as done. - -commit a111593a082ff1df26f54168ab00f83ab3a1ab49 -Author: Guus Sliepen -Date: Fri Jun 29 15:38:40 2001 +0000 - - Dutch translation updated. - -commit 748dabdbe93f7439ed7eddf491a556279250e7ac -Author: Guus Sliepen -Date: Fri Jun 29 15:33:18 2001 +0000 - - Update of RedHat build scripts. - -commit 343c8fb6388ffd4f5c41cebd666aa8a045b20bdd -Author: Guus Sliepen -Date: Fri Jun 29 15:32:26 2001 +0000 - - It appears that autogen.sh doesn't like es.po if it isn't mentioned in - the makefile/configure scripts. - -commit 9391efe4e88077723840a7c085388ba2765ca17c -Author: Guus Sliepen -Date: Fri Jun 29 14:15:46 2001 +0000 - - Check for dlopen in standard libraries first (needed for DEC OSF). - -commit c9591bd1de1abcfe10459bd8c8cdd81a7b441ec0 -Author: Guus Sliepen -Date: Fri Jun 29 13:09:55 2001 +0000 - - Fix gcc 3.0 warnings. - -commit 402b85c48284a06fbfc56aca102b33be3a4260b0 -Author: Guus Sliepen -Date: Fri Jun 29 13:09:32 2001 +0000 - - Log error if two hosts connect with same IP/port tuple. - -commit 0d3bd912acdb00dc0a8015e337f981c942aa21bc -Author: Guus Sliepen -Date: Fri Jun 29 11:09:13 2001 +0000 - - Also remove po/Makefile.in.in, which is generated by autogen.sh. - -commit 67c16924c10b25d37957843a69d993b934dd1776 -Author: Guus Sliepen -Date: Fri Jun 29 11:03:27 2001 +0000 - - es.po revived. - -commit 5d3450357482176ce92ed4832ec944519d197744 -Author: Guus Sliepen -Date: Fri Jun 29 10:30:18 2001 +0000 - - Execute tinc-down BEFORE tap device is closed. This is a. more symmetric - (tinc-up is started after tap device is opened) and b. is needed for - tun/tap device, where the interface does not exist anymore after the - device file is closed. - -commit 6666acd0012c82c0bb4d1abae87332cec3dda77a -Author: Guus Sliepen -Date: Fri Jun 29 10:27:57 2001 +0000 - - Don't build Spanish translation. - -commit 77f635e871060f63c3e62fcf879d184326c690a4 -Author: Guus Sliepen -Date: Fri Jun 29 10:27:33 2001 +0000 - - ABOUT-NLS is created by autogen.sh. - -commit 333be8fbb8790237577761e580126a6d757a46e4 -Author: Guus Sliepen -Date: Fri Jun 29 10:23:46 2001 +0000 - - Spanish translation removed. Nobody maintains it, and it is severely - outdated. - -commit 3503ba995012f658f087a196dad0cb9fd45eff3b -Author: Ivo Timmermans -Date: Tue Jun 26 22:00:57 2001 +0000 - - Small fix to make it compile again - -commit 7fc068fe5421f7ec556b0b7db6f814e18b3326a4 -Author: Guus Sliepen -Date: Thu Jun 21 18:28:52 2001 +0000 - - Reinstated search for if_tun.h in kernel source tree, because apparently - /usr/include/linux does not always have the same contents as the include - files from the currently running kernel. - -commit 9e96840da810437c45af1c4b139578f7d74d65db -Author: Guus Sliepen -Date: Thu Jun 21 16:37:47 2001 +0000 - - Remove #warnings I used for debugging stuff. - -commit b1e97ece9c495ac67e54b8c2675b1eacc645eb1c -Author: Guus Sliepen -Date: Thu Jun 21 16:37:05 2001 +0000 - - Check for and add -ldl. - -commit 04ec0b82ab9c6a2662300a9257a5aff1c4dd56e7 -Author: Guus Sliepen -Date: Thu Jun 21 16:16:32 2001 +0000 - - - Solaris compile fixes - - Set mymac to broadcast MAC so that ifconfig hw ether <...> is really not - needed anymore. - - Forwarding of indirect packets when in switch mode (because the kernel - will not do it for us then). - -commit 353a9230bb70b70028f2dc6c651a28e30b13dc63 -Author: Ivo Timmermans -Date: Wed Jun 20 21:32:40 2001 +0000 - - Don't include the debian/ dir in a release - -commit 9a0a50cd3cf2570b39e00edf1a92123acbac41b4 -Author: Guus Sliepen -Date: Sat Jun 9 10:00:34 2001 +0000 - - Woops - big bug in send_key_changed fixed. - -commit ba918dce287788aaf6a90b3c7a9f349b197068d6 -Author: Guus Sliepen -Date: Fri Jun 8 18:02:10 2001 +0000 - - Only reset seconds_till_retry when we activate the outgoing connection. - -commit c5c02a0861bf540e07fe64704cb97aae29c4cacf -Author: Guus Sliepen -Date: Thu Jun 7 07:51:04 2001 +0000 - - Changed drastically because it didn't work correctly: - - Don't cache the --with-openssl-* option arguments - - Only search for openssl/*.h, the openssl include files include other - files only from an openssl/ directory too - - Set CPPFLAGS before AC_CHECK_HEADERS - -commit 053e78654097cf353aa59b4d34e608726edd5dad -Author: Guus Sliepen -Date: Thu Jun 7 07:48:11 2001 +0000 - - Save configure cache more often. - -commit 96ef7becdd71fc63c3489e3696117c1f137eade5 -Author: Guus Sliepen -Date: Wed Jun 6 19:12:38 2001 +0000 - - Fixes to make switching work between hosts that have no meta-connection. - -commit ce6c8e6d089abac81520c517185c6ef81b09f051 -Author: Guus Sliepen -Date: Wed Jun 6 19:11:16 2001 +0000 - - Log and warn about duplicate subnet_add()'s for the same subnet. - -commit 9cd9b0392388e24ade19a43206221081b61806e7 -Author: Guus Sliepen -Date: Tue Jun 5 19:45:47 2001 +0000 - - Add missing? counting of total_socket_in. - -commit 7bd7f5b4363f222340e5c058c243d31c576fba88 -Author: Guus Sliepen -Date: Tue Jun 5 19:39:54 2001 +0000 - - You can now put an option "Mode" in tinc.conf, and choose from: - - - Mode = router (default, work like tinc has always worked) - - Mode = switch (work like a switch) - - Mode = hub (work like a hub, broadcasting everything) - -commit edd6734faa37d043b8a2cc75b125db3b1c2130fa -Author: Guus Sliepen -Date: Tue Jun 5 18:07:14 2001 +0000 - - Fix bug where lookup_subnet_ipv4() could go into an infinite loop. - -commit fa376fbd4e5151ae43e86441a1e99073eeaf46a5 -Author: Guus Sliepen -Date: Tue Jun 5 16:31:59 2001 +0000 - - - This oneliner removes the need for ifconfig tap? hw ether fe:fd:0:0:0:0 - -commit 7a736d47b264065371f35cd9da64485d798cbc80 -Author: Guus Sliepen -Date: Tue Jun 5 16:15:48 2001 +0000 - - Updated dutch translation. - -commit 92924e8482f000eb33130ce9feadc08450ff349d -Author: Guus Sliepen -Date: Tue Jun 5 16:13:41 2001 +0000 - - Changed some stuff to allow correct generation of po/Makefile after a - make cvs-clean. - -commit 4f9dad0972ac0f665a1b6050b059bd52f93e6221 -Author: Guus Sliepen -Date: Tue Jun 5 16:09:55 2001 +0000 - - - tinc can now act as a switch or a hub too (as opposed to a router only) - - cleaner initialisation of "UNKNOWN" and "MYSELF" names - -commit 428482d86f860d1fb09de722c1b6576ec2eef1ce -Author: Guus Sliepen -Date: Mon Jun 4 11:14:35 2001 +0000 - - Added proxy-arp support. No more ifconfig -arp needed. Works like a charm - under FreeBSD now :). - -commit 0a3c8cefd4a154948799baaaa246cf0eba050eff -Author: Guus Sliepen -Date: Fri Jun 1 08:02:09 2001 +0000 - - Fix subnet_lookup() for overlapping subnets. Needs rethinking. - -commit 7db1b999c82611d6c68a5d79b4754db19669d5c6 -Author: Guus Sliepen -Date: Mon May 28 08:56:57 2001 +0000 - - Make sure Solaris is happy too. - -commit 65247c063b36a76dd68156fe17b017c7460d982f -Author: Guus Sliepen -Date: Mon May 28 08:21:43 2001 +0000 - - Small fixes to allow correct compilation under FreeBSD (tested with 4.3) - -commit 4e959ee40542733e647c36831c1fc87ed8098233 -Author: Ivo Timmermans -Date: Sat May 26 09:35:28 2001 +0000 - - Don't distribute autogen.sh in a release - -commit 514f8f579d5c0608aee8ca4a43d7414ecee5c11c -Author: Ivo Timmermans -Date: Sat May 26 09:35:00 2001 +0000 - - Changed version number to 1.0-cvs - -commit 20c2b62b1802390c0f5a1757641a0a1cea8103a8 -Author: Ivo Timmermans -Date: Sat May 26 09:34:11 2001 +0000 - - New make target: `make release' - -commit 8d307c2fbf2c20eb53909f74c81e03db838fb55e -Author: Guus Sliepen -Date: Fri May 25 18:57:37 2001 +0000 - - Fix sample configuration to show keys in PEM format and correct tapdevice. - -commit e12d41f39d8dd1cd30058d08effd2e5b66cdd4fd -Author: Guus Sliepen -Date: Fri May 25 13:24:34 2001 +0000 - - Documents are merged. Now we only need to check the ports and the TCPonly - and IndirectData options. - -commit f0c64a3dac3b0469ea05fa5d44a1e7bdbfa64900 -Author: Guus Sliepen -Date: Fri May 25 12:45:37 2001 +0000 - - Merged PROTOCOL, NETWORK and SECURITY2 with the texinfo manual. - -commit fcf869cd4250a240ea8d443f70fa373e4fbacf07 -Author: Guus Sliepen -Date: Fri May 25 11:54:28 2001 +0000 - - TCPonly now works (in a relatively clean way too). - -commit a5e2ae6b2b2e1629cf05bb2a57df75f13c0f120a -Author: Guus Sliepen -Date: Fri May 25 10:08:11 2001 +0000 - - With recent kernels the tun device file is located in /dev/net. - -commit 6e09c2a99c8ac3c1391f4f2eee16d6c235c10e90 -Author: Guus Sliepen -Date: Fri May 25 10:06:13 2001 +0000 - - Small corrections to the manuals. - -commit 4dee76522e177dcb4af5d6d844a5f3b74070e4b7 -Author: Guus Sliepen -Date: Fri May 25 08:36:11 2001 +0000 - - Small fixes: - - - Fix compiler warnings (one was a real (but harmless) bug) - - Don't send PING packets if there is UDP traffic - - Correctly terminate strings containing salt for PING/PONG packets - -commit bfc5d6014e3c1563f7b6a2f10698e9ba23ba3e96 -Author: Guus Sliepen -Date: Thu May 24 21:52:26 2001 +0000 - - Only send key_changed if it was previously requested. - -commit 1a248fd5bd5aa24fa0f6a2c395f05dd569f0898d -Author: Guus Sliepen -Date: Thu May 24 21:32:30 2001 +0000 - - All features for 1.0 are implemented now, we just have to check the - FreeBSD and Solaris ports and merge some docs. - -commit 58893f0875369aafff8481825af271683c975a2a -Author: Guus Sliepen -Date: Thu May 24 21:30:36 2001 +0000 - - Since this is incompatible with some earlier versions, PROT_CURRENT is - increased. - -commit d1b597758eab68bb80d97855f25cb6dda55eeb0b -Author: Guus Sliepen -Date: Thu May 24 21:29:09 2001 +0000 - - Add randomness to PING/PONG packets to prevent crypto attacks on quiet - tunnels. - -commit 4493b0650bd487990ca9d2802496ad0ee7c06247 -Author: Guus Sliepen -Date: Thu May 24 20:40:13 2001 +0000 - - Changed URL from kernelnotes.org to linuxdoc.org. - -commit 3360c6270bcc19a8b3d81da185266fc33b5c5421 -Author: Guus Sliepen -Date: Thu May 24 20:24:12 2001 +0000 - - More revisions to the documentation: - - - Removed cruft - - Reordered some sections to make it more logical for the beginner - - Added small examples and hints about configuration files - -commit 6f7f8659a2048fd6d616f4286ccdd0e661084493 -Author: Guus Sliepen -Date: Sat May 19 15:50:51 2001 +0000 - - - Make sure correct information is supplied for both old kernels (with - ethertap) and for new kernels (with TUN/TAP driver). - - Revised example configuration and made it conform to latest (CVS) version of - tinc. - -commit e4f3d93ec62871d1ae11b460627aef0da1b23cd2 -Author: Guus Sliepen -Date: Mon May 7 19:08:46 2001 +0000 - - - s/ip_t/ipv4_t/g - - Add "salt" to the beginning of UDP packets. Replaces length field which - is not useful anyway. - -commit a26081467c197cc6b26a0c36c4508361b242fc85 -Author: Guus Sliepen -Date: Fri May 4 18:45:02 2001 +0000 - - Correctly cycle through ConnectTo variables. - -commit 80b4a851a6b62cbbf503c2225f93305966f058c0 -Author: Guus Sliepen -Date: Fri Apr 13 10:30:04 2001 +0000 - - Depend on new ssl package and install alias for universal TUN/TAP module. - -commit 156ec676525ed789364b7a77926dd0717d0cf5d7 -Author: Guus Sliepen -Date: Tue Mar 13 21:33:31 2001 +0000 - - Check indirectdata option before forwarding certain requests. - -commit c426e981eeaed3fa4801221720ee8f74d40e9223 -Author: Guus Sliepen -Date: Tue Mar 13 21:32:24 2001 +0000 - - Ignore alarm signals if we do not need to respond to them. - -commit b413257e10ae0645da43583dd8f84a1f74df5bd7 -Author: Guus Sliepen -Date: Tue Mar 13 09:55:14 2001 +0000 - - Fixed bug in setup_signals() that would make tinc die when unexpected - signals were caught. - -commit f1a082823c48d00171b814f7e14e07e6dd4632fb -Author: Guus Sliepen -Date: Mon Mar 12 23:58:19 2001 +0000 - - Fixed a race condition triggered by receive_meta() and the new - authentication scheme. - -commit f4887b981f109fc4264f50170b2d12c4033bf5e9 -Author: Guus Sliepen -Date: Sun Mar 4 14:00:24 2001 +0000 - - Added a description of what is going on in net.c and route.c, and how - packets flow through tinc. - -commit 9d5c9bf6ba74e4e8bbd12b97fdda6c665155fec6 -Author: Guus Sliepen -Date: Sun Mar 4 13:59:53 2001 +0000 - - Updated translation. - -commit 34f9e6cf2d6d2b81eb63f9f28963b447a2157740 -Author: Guus Sliepen -Date: Sun Mar 4 13:59:32 2001 +0000 - - - route.c is now used to determine destination - - flags are removed, since they were not used at all. Use options instead. - - indirectdata works now, tcponly almost... - - made functions that don't return useful information void - -commit d2a54597e029f9d4f7bd29837be1be33909d78b1 -Author: Guus Sliepen -Date: Fri Mar 2 11:25:56 2001 +0000 - - Added explaination of our key exchange using RSA encryption. - -commit 125c4978812cffa5154ce5378a276f43f78417d8 -Author: Guus Sliepen -Date: Thu Mar 1 21:32:04 2001 +0000 - - Various small fixes. - -commit 099cc867c1a0831add7f1b4046f22ad6bfa5a1ef -Author: Guus Sliepen -Date: Tue Feb 27 16:50:29 2001 +0000 - - Removed compiler warning. - -commit 4fa12eb85d72f039df5004abc201f01f5573c2e4 -Author: Guus Sliepen -Date: Tue Feb 27 16:37:31 2001 +0000 - - Removed lots of compiler warnings. - -commit 173d606514d82fc5ae7895a178238d0abcaf6606 -Author: Guus Sliepen -Date: Tue Feb 27 16:17:04 2001 +0000 - - - Fixed Interface option (untested) - - Removed error handling for non-critical socket options - - Added TCP_NODELAY and IPTOS_LOWDELAY options for meta sockets. - -commit fb4ba9b265666d9949b03209a3ff52ff1263226b -Author: Ivo Timmermans -Date: Tue Feb 27 16:15:14 2001 +0000 - - Authentication done - -commit 24fa68585923d2b52718390f3f38d1aaacef12f0 -Author: Guus Sliepen -Date: Tue Feb 27 15:33:39 2001 +0000 - - Don't forget to reconnect if outgoing connection fails during - authentication. - -commit 34b7a876c3583f7a34585cff6a694bc9e35cdc87 -Author: Guus Sliepen -Date: Mon Feb 26 11:37:20 2001 +0000 - - - Make sure METAKEY is smaller than the modulus of the RSA key - - Get symmetric key from the least significant bytes of the RSA message - -commit 4b0ad4d97abd3643c44f45841d52f3000a34ba60 -Author: Guus Sliepen -Date: Sun Feb 25 20:17:46 2001 +0000 - - Added process.c to the translated files. - -commit 82455be966027a087a2ac23e3464594c81d7b111 -Author: Guus Sliepen -Date: Sun Feb 25 19:09:45 2001 +0000 - - Implemented new authentication scheme from doc/SECURITY2. - -commit 54881faf6fdbf04fb5ee56b7809439fbc50c65cb -Author: Guus Sliepen -Date: Sun Feb 25 16:34:19 2001 +0000 - - Encrypt network packets in CBC mode instead of CFB mode. - (This breaks compatibility with all previous versions!) - -commit 9de5787574b21e94c80ddc60def2b3e514aff755 -Author: Guus Sliepen -Date: Sun Feb 25 16:04:00 2001 +0000 - - Copy packets before putting them in the queue. - -commit 38adc479a44b64afcb220cd757f77ab105cb9bcd -Author: Guus Sliepen -Date: Sun Feb 25 15:34:50 2001 +0000 - - Free node->data and node, not node->data twice. - -commit e250d64300cea2a83059866e7cbabcb33684160e -Author: Guus Sliepen -Date: Sun Feb 25 14:51:42 2001 +0000 - - Add missing \n. - -commit 153fc35e57c0104aa4ea9103bcdbca3665e4934c -Author: Guus Sliepen -Date: Sun Feb 25 11:09:29 2001 +0000 - - Corrected check for errors after read() calls. - -commit 0b0c2a372ff5d11f73af172e07a93b2656374a42 -Author: Wessel Dankers -Date: Tue Feb 20 21:53:18 2001 +0000 - - Important bugfix in avl_insert_before() and avl_insert_after() - -commit 11f8465dd9a4f81b43a31f1cb6a7fc2d76bb7838 -Author: Ivo Timmermans -Date: Sun Feb 18 02:13:26 2001 +0000 - - tinc_TUNTAP now substitutes the values outside the AC_CACHE_CHECK - block. configure should now correctly set HAVE_TUNTAP. - -commit bb0870498037565209e24fbb2ffa07b815350a0b -Author: Guus Sliepen -Date: Tue Feb 13 09:54:29 2001 +0000 - - Added description of the proposed new authentication scheme. - -commit cebb6efeb0f39bf05ca7836b7a393c8385b49335 -Author: Ivo Timmermans -Date: Sun Feb 11 11:55:28 2001 +0000 - - More files to ignore in CVS - -commit 603781831f251d2e8111e8282d8e624b8e40b175 -Author: Guus Sliepen -Date: Sun Feb 11 11:50:09 2001 +0000 - - - Updated CVS_CREATED to remove intl/ directory and some other - autogenerated files. - - Checked if all INCLUDES/LIBS/etc directives inherit the global variables. - -commit 88dfdc9dbac3f5d0aa70b77509b4a87513433987 -Author: Guus Sliepen -Date: Sun Feb 11 11:46:14 2001 +0000 - - Ignore file for src/ - -commit ef0fc4f687fc25e97551e589941d6a2a2d8ade42 -Author: Guus Sliepen -Date: Sun Feb 11 11:44:32 2001 +0000 - - Added .cvsignore files to get rid of warnings and prevent autogenerated - files from being added accidentaly. - -commit f1cb3d8fa5f69840f353ca5a62f363dad47eb46f -Author: Guus Sliepen -Date: Tue Feb 6 10:42:27 2001 +0000 - - Removed another local definition of the variable "errno" - -commit 0f715887c617723e4b450083f8b77641f8b62e80 -Author: Guus Sliepen -Date: Tue Feb 6 10:13:44 2001 +0000 - - Updated dutch translation. - -commit 4bc394a3e29f2f90434bbbfc9f23d5587398471b -Author: Guus Sliepen -Date: Tue Feb 6 10:13:22 2001 +0000 - - Fix memory leak in avl_insert() if item was already inserted. - -commit f777c1807d663eaef3e36c395094451214886898 -Author: Guus Sliepen -Date: Tue Feb 6 10:12:51 2001 +0000 - - FreeBSD compile fixes (thanks to XeF4) - -commit bb4457d6caf6e424aeaf9b09222d4e62cab939da -Author: Ivo Timmermans -Date: Thu Jan 18 13:02:34 2001 +0000 - - Unpack sample-config.tar.gz when installing - -commit fe61e1ffef186aa509a50be3be83955fe1cbb514 -Author: Ivo Timmermans -Date: Thu Jan 18 13:01:42 2001 +0000 - - Distribute the sample config as a .tar.gz - -commit a73ec9caa45bda7738376a610030c8ba9b934445 -Author: Ivo Timmermans -Date: Thu Jan 18 13:00:57 2001 +0000 - - Fixed some errors - -commit b33c5f6640e63cc4cd35285367bcb2827b732229 -Author: Ivo Timmermans -Date: Wed Jan 17 16:24:24 2001 +0000 - - First try to create a graphical frontend for tinc configuration - -commit 6bc77a7710adcbc33331c45e1b6adf7089a42075 -Author: Ivo Timmermans -Date: Wed Jan 17 01:48:44 2001 +0000 - - Get the PO files up to date with the current source - -commit 664f7e5c0b9056d88e2b63b3626ea33c4894387b -Author: Ivo Timmermans -Date: Wed Jan 17 01:47:39 2001 +0000 - - Get the Debian changelog up to date - -commit 1d898e00a964ef922617683a1d29ff24e56ed8ff -Author: Ivo Timmermans -Date: Wed Jan 17 01:40:46 2001 +0000 - - Merged documentation with various updates I had lying around - -commit 457c6fa7b63a7f2971314d8d63af71c880ec6f53 -Author: Ivo Timmermans -Date: Wed Jan 17 01:34:08 2001 +0000 - - Second draft of the release notes - -commit b236ddb1df16f8eb025d485b75153c4f25f4afc6 -Author: Ivo Timmermans -Date: Wed Jan 17 01:31:56 2001 +0000 - - Change version to 1.0pre4 - -commit a893b05cb017c04871c2faf4099f104985f4ad75 -Author: Ivo Timmermans -Date: Wed Jan 17 01:30:32 2001 +0000 - - Set Architecture to `any' - -commit 54e19d34663cfe4af05e9e1dac94f76e39858f18 -Author: Ivo Timmermans -Date: Wed Jan 17 01:30:05 2001 +0000 - - Fix error reporting of read_config - -commit a56df1e06be3f47a775919e564c147687e961b5d -Author: Guus Sliepen -Date: Sat Jan 13 16:36:23 2001 +0000 - - - Allow ASN1 style keys to be in the config files. - Note: tinc ignores private key in the main config file, tinc.conf, - because it should really be in a separate file. - - When generating new keys, check if name is known and by default append - the public key to the host configuration file (otherwise rsa_key.pub). - -commit 44c85ab07ed07165b80140da4e2910ca51fa8887 -Author: Guus Sliepen -Date: Sat Jan 13 14:56:46 2001 +0000 - - - Copy entire sample-config directory to /etc/tinc/example upon installing. - -commit b195e8815f0abb2c5527119221886b524d719019 -Author: Guus Sliepen -Date: Sat Jan 13 14:38:18 2001 +0000 - - Added sample configuration directory. - -commit d646f4e094b63720f97bfd37bb3489bd9d6231a0 -Author: Guus Sliepen -Date: Thu Jan 11 11:19:08 2001 +0000 - - - Only send out DEL_HOSTs for hosts with a meta connection - -commit c8beaf35ee923c209ee23bedcb3dc892d2c2dae3 -Author: Guus Sliepen -Date: Mon Jan 8 21:32:30 2001 +0000 - - - Cleaned up subnet_t - -commit e5e1c20a99b0d72792f28e9a075a9f4a7e8b2c95 -Author: Guus Sliepen -Date: Mon Jan 8 21:32:00 2001 +0000 - - - Sign was wrong in search_closest_smaller/greater - -commit 11f3e9d138daf6b726631cc124b14d66dfa4d1f7 -Author: Guus Sliepen -Date: Mon Jan 8 20:35:30 2001 +0000 - - - Squashed another nasty bug. - -commit 447a43d63960802a7a29201c512246be11eb9c94 -Author: Guus Sliepen -Date: Sun Jan 7 20:19:35 2001 +0000 - - - Added indirectdata and tcponly functionality. - -commit 7cd2baedc6027ef6a5b941342bc6d3931d7220ba -Author: Guus Sliepen -Date: Sun Jan 7 20:19:08 2001 +0000 - - - Fixed IPv6 subnet lookup routine. - -commit d3f889c8076dff9c00ebfe1459cb36425f8da41d -Author: Guus Sliepen -Date: Sun Jan 7 17:09:07 2001 +0000 - - - It's 2001, all copyright notices are updated. - -commit 96b6f958bc733c3963dd164caacd42513be47a86 -Author: Guus Sliepen -Date: Sun Jan 7 17:08:03 2001 +0000 - - - Description of protocol and authentication updated. - -commit 7109526c6789c73a18bbe6b228ca35f0374c8d36 -Author: Guus Sliepen -Date: Sun Jan 7 15:27:30 2001 +0000 - - - Added header file for route.c. The routing routines in it are not used - yet, but have a look at the source for the ideas behind it. - -commit 07a08f5539f441e66946d1db1711dc584f8621c4 -Author: Guus Sliepen -Date: Sun Jan 7 15:25:49 2001 +0000 - - - Reinstated a queue for outgoing packets. - -commit 049ff67817e0db5afbba30930531d8ea3f7f2d18 -Author: Guus Sliepen -Date: Sun Jan 7 15:24:52 2001 +0000 - - - Changed list routines to give it the same look'n'feel as the rbl and - avl tree library. - -commit 8b4bc5b3a7e31c198c001610c99c2993e1612376 -Author: Guus Sliepen -Date: Sat Jan 6 20:43:03 2001 +0000 - - - Typo. - -commit 3d7289cf743f89cab4c71815482a4837a21f6703 -Author: Guus Sliepen -Date: Sat Jan 6 20:02:21 2001 +0000 - - - Updated texinfo manual. - -commit 0d99ae59bd7c640d396ce978045f0911567fb9bf -Author: Guus Sliepen -Date: Sat Jan 6 18:44:55 2001 +0000 - - - Updated manual pages. - -commit 90bf1b21fa7e94d73719da0593e7c0356d05e18f -Author: Guus Sliepen -Date: Sat Jan 6 18:21:17 2001 +0000 - - - Changed license of AVL tree library to GPL. - -commit f7bb205022e02c02c02733cd43544c231373115d -Author: Guus Sliepen -Date: Sat Jan 6 18:03:41 2001 +0000 - - - Check and follow symlinks in is_safe_path - - By default write keys to tinc config directory - - Small fix in protocol.c - -commit 1398edec37336853bfca6ea3dcca7c402f102ea2 -Author: Guus Sliepen -Date: Sat Jan 6 16:51:14 2001 +0000 - - - Updated dutch translation. - -commit e924096f62655d711cd2d114a8d1ef0fecbb593b -Author: Guus Sliepen -Date: Fri Jan 5 23:53:53 2001 +0000 - - - Let user choose whether keys are in the config files or separate - - Use AVL trees instead of RBL trees - - Fixed a lot of annoying subtle bugs! Thanks to gdb... - -commit 052fbc0bdf36e0dbe2a0867ce770d426c9a44841 -Author: Guus Sliepen -Date: Fri Jan 5 23:51:41 2001 +0000 - - - Doubled size of trace buffer for easier debugging. - -commit 77509da76c61b881c9967bfb7cdafeaf6b56eb6d -Author: Guus Sliepen -Date: Fri Jan 5 23:50:56 2001 +0000 - - - AVL tree routines: faster than RBL, and also more stable. - -commit e1707f7739f450c729e26b921e459d5da07602f9 -Author: Guus Sliepen -Date: Fri Dec 22 21:34:24 2000 +0000 - - - Don't even think about using sscanf with %as anymore - - Allow keys to be inside the config files or in a seperate file - - Small fixes - -commit ecae72de94222302aa326888f70cfacdbd775b23 -Author: Ivo Timmermans -Date: Fri Dec 22 17:15:26 2000 +0000 - - Added lint target, requires lclint. - -commit c5fac35c6ce9b9fcc47508810d69aeab83d08c25 -Author: Ivo Timmermans -Date: Fri Dec 22 17:10:25 2000 +0000 - - Forget router.c - -commit 37544990e96fe5ea161e644f6417f505d666cd00 -Author: Ivo Timmermans -Date: Fri Dec 22 16:59:16 2000 +0000 - - Include autogen.sh (needed for the Debian package). - -commit 8a4daf4ea7758270a47a358f43ad97a64eb1c3ff -Author: Ivo Timmermans -Date: Fri Dec 22 16:54:56 2000 +0000 - - Various small changes. - -commit e469fca4d78e9d23698fe1e6b29b232198cc499e -Author: Ivo Timmermans -Date: Wed Dec 6 13:33:49 2000 +0000 - - Re-introduced MyVirtualIP and VpnMask, as dummy options. - -commit e50e4a54d6b40b988041a7e9bfdfbf708657f3a5 -Author: Ivo Timmermans -Date: Tue Dec 5 09:04:32 2000 +0000 - - Give a warning about having to re-create the keys - -commit 4610d98c04641fce65747e07d65cbdd03fb6fe30 -Author: Ivo Timmermans -Date: Tue Dec 5 09:03:41 2000 +0000 - - Ported it back to /bin/sh. - -commit 1e38dcc3fa6c0da2fdb21f83a588338fa8a41818 -Author: Ivo Timmermans -Date: Tue Dec 5 09:03:19 2000 +0000 - - Install a file in /etc/modutils/tinc, containing all necessary aliases - and options for kernel modules. - -commit 6327f32f43dc9109fad9952fd50a23876d0acaf0 -Author: Ivo Timmermans -Date: Tue Dec 5 08:59:30 2000 +0000 - - Tiny bits of code beautifying - -commit 9267bed9f516244b00d5c86c8dae44b7eb78a96c -Author: Ivo Timmermans -Date: Tue Dec 5 08:56:44 2000 +0000 - - Oops. I did some VERY wrong things with readline(). Fixed now. - -commit 6ddc9109d7313503895227c7876309b36681393d -Author: Ivo Timmermans -Date: Tue Dec 5 08:54:22 2000 +0000 - - Massive long awaited documentation update. It's not finished yet, - most notably the example configuration is still old. - -commit bc22ee16e6903d2caf9d22afa85020d1e3e10b56 -Author: Ivo Timmermans -Date: Sun Dec 3 12:23:06 2000 +0000 - - Option -d accepts an argument to set the debug level immediately. - -commit 01d23601a273d128ebfd13c2ffa10892e9b13094 -Author: Ivo Timmermans -Date: Sun Dec 3 12:22:19 2000 +0000 - - Sort configuration directives - -commit d6b77e18b58ad8f9bcd9b60864b95cd2a74482c5 -Author: Ivo Timmermans -Date: Sun Dec 3 12:21:20 2000 +0000 - - Added documentation merger - -commit e985f6d3cdbebdeb17333bbd3d3c20d4618128cf -Author: Ivo Timmermans -Date: Fri Dec 1 13:46:26 2000 +0000 - - Include COPYING.README in the distribution. - -commit 94192b3db10fe51ce45fa569ec068423a4491b0b -Author: Ivo Timmermans -Date: Fri Dec 1 13:45:46 2000 +0000 - - Stated that distributing executables linked with OpenSSL is permitted - provided that all other requirements of the GPL are complied with. - -commit 52575a573c1d87ee125a54a2e0b4044698904cae -Author: Ivo Timmermans -Date: Fri Dec 1 12:38:42 2000 +0000 - - Use buffer instead of line in read_config_file(), line may be assigned - NULL, so buffer always holds the pointer to the allocated space. - -commit ab33c1aa6081f07333bf1de00e4036dd2b4628a6 -Author: Ivo Timmermans -Date: Fri Dec 1 12:36:36 2000 +0000 - - readline() accepts two extra parameters, buf and buflen, to avoid - mallocing and freeing for every line that is read. - -commit 6c56a8416eded8f19076a619a27ad7b153dd91f3 -Author: Ivo Timmermans -Date: Thu Nov 30 23:44:07 2000 +0000 - - Tagged `Storing private key in separate file' as done. - -commit 8fe83e98da043e930a88ddd6b2de6c14aa791335 -Author: Ivo Timmermans -Date: Thu Nov 30 23:39:55 2000 +0000 - - All full stops have two spaces after them. (Silly commit, I know.) - -commit a0f7af3ed79c55d9680cbb0a569b3c8987581d43 -Author: Ivo Timmermans -Date: Thu Nov 30 23:18:21 2000 +0000 - - New function read_rsa_public_key(); - In net.c/setup_myself deleted old code to read the public key (which - is now implicitly read in together with the private key). - -commit 28deaeac14d619efb9830d03fd61dc7cca70a701 -Author: Ivo Timmermans -Date: Thu Nov 30 22:48:48 2000 +0000 - - Avoid printing duplicate messages from read_rsa_keys - -commit 2293304748f7e4e9a18ee848b8264bdecebae37f -Author: Ivo Timmermans -Date: Thu Nov 30 22:33:16 2000 +0000 - - Better error checking when reading the RSA private key. - -commit bf4e969899bb6cdeb05570d96a567c2833ac83bd -Author: Ivo Timmermans -Date: Thu Nov 30 22:32:14 2000 +0000 - - In readline(): initialise the line to zero length; - In read_config_file(): Test for EOF, and print the variable name that - caused an error. - -commit 113198d9c0b3be9904057673cfed165406803f86 -Author: Ivo Timmermans -Date: Thu Nov 30 21:11:03 2000 +0000 - - The file is safe if it doesn't exist. - -commit 09260b43d1ff037c22f86c82a6af830e9a6d6ae5 -Author: Ivo Timmermans -Date: Thu Nov 30 20:08:41 2000 +0000 - - Read the PEM file pointed to by the configuration directive - PrivateKey. This means thatt he meaning of this variable has changed, - it no longer should contain the private key directly. - - WARNING: This code is untested. - -commit 8ccb1ede92fbd55481fa2317c2450bb9dd94a180 -Author: Ivo Timmermans -Date: Thu Nov 30 00:24:13 2000 +0000 - - Implemented is_safe_path, and extended ask_and_safe_open. - - is_safe_path needs more work before it is useable. - -commit 75e3c296b4fa1eb02df2f5f84a1280e791f88603 -Author: Ivo Timmermans -Date: Wed Nov 29 15:22:04 2000 +0000 - - Updated Dutch translation - -commit d36da1948abdd27e9d0740c2baceb0bd155c18c6 -Author: Ivo Timmermans -Date: Wed Nov 29 14:30:07 2000 +0000 - - Also free the pointer returned by readline(). - -commit 9e55426d72fd77fda891edd0023dab2f9909639e -Author: Ivo Timmermans -Date: Wed Nov 29 14:27:24 2000 +0000 - - Use readline() in read_config_file() instead of fgets. - -commit 8ea23d9ec3f2fe0c113eac5caafb7c2bd03f3016 -Author: Ivo Timmermans -Date: Wed Nov 29 14:23:08 2000 +0000 - - xstrdup now takes a const pointer as an argument. - -commit 54ef13bf75a7a1e787716ce395ffe847fa74673f -Author: Ivo Timmermans -Date: Wed Nov 29 14:24:40 2000 +0000 - - Implemented a readline() function that will read an entire line into a - dynamically allocated buffer; - - Ask for a file name in ask_and_safe_open(). - -commit 9175d2048382c617a639fd3d437a9e06baa66d0f -Author: Ivo Timmermans -Date: Wed Nov 29 01:37:50 2000 +0000 - - Added a check for a scanf that knows about %as. - -commit 1ca04711aeab615161746c6bbb5d137388c73263 -Author: Ivo Timmermans -Date: Wed Nov 29 00:33:15 2000 +0000 - - Check for get_current_dir_name. There is a replacement function in - dropin.c. - -commit c94f7637427f4c89d56c41fe4c75f2970b664a63 -Author: Ivo Timmermans -Date: Tue Nov 28 23:23:41 2000 +0000 - - dropin.c/h contain a set of drop-in replacements for non-standard C - library functions (read: GNU extensions). - -commit 3ff76eb10acc55b6f269c1075de6bbaa5bc83516 -Author: Ivo Timmermans -Date: Tue Nov 28 23:12:57 2000 +0000 - - Save RSA public and private keys to a separate file, instead of - wanting to copy them into a configuration file. - -commit 4c502b005bfd24821e817c134e8a442a5f4606de -Author: Ivo Timmermans -Date: Tue Nov 28 08:59:27 2000 +0000 - - Use sigaction to set signal handlers, the previous commit (1.1.2.16) - already contained a large portion of what should have gone in this - one. - -commit e44dc004b3d1ce8f857971f479c917931eda7091 -Author: Ivo Timmermans -Date: Mon Nov 27 20:52:55 2000 +0000 - - Sort items to either 1.0 or future release goals. - -commit 699f3b4c93482055c0832c9a6b76dc0294967003 -Author: Ivo Timmermans -Date: Sun Nov 26 22:46:53 2000 +0000 - - Check for the function strsignal, and define it to "" if it is not - available. - -commit 67a4abda707b28b9c77cb35ff1e800e6a5b0991c -Author: Ivo Timmermans -Date: Sun Nov 26 22:42:34 2000 +0000 - - Give an error message if daemon() failed. - -commit 702e55306dfebe5c6f9a6587ed029c3bc3efbe8f -Author: Ivo Timmermans -Date: Sun Nov 26 22:32:52 2000 +0000 - - Updated Spanish translation, provided by Enrique Zanardi. - -commit 1eedf54681d4556c6874f7baee8e810cab867756 -Author: Guus Sliepen -Date: Sat Nov 25 13:33:33 2000 +0000 - - - Use only one socket for all UDP traffic (for compatibility) - - Write pidfile again after detaching - - Check OS (for handling FreeBSD/Solaris tun/tap stuff) - -commit 0806605ce383b7e89fa26eda56f8a5f3bbed9dd3 -Author: Guus Sliepen -Date: Fri Nov 24 23:30:50 2000 +0000 - - - Added daemon() replacement. - -commit cfb828784ebbcf4b3e40eb9bb351b6ed10a84b35 -Author: Guus Sliepen -Date: Fri Nov 24 23:14:52 2000 +0000 - - - Added Armijn to the list - -commit cf49b2c0647554613874cce495e4a7937a9f7863 -Author: Guus Sliepen -Date: Fri Nov 24 23:13:07 2000 +0000 - - Another big & bad commit: - - Added some extra search functions to rbl routines - - Fix subnet_lookup() - - Reorder some syslog messages to make more sense - - daemon() is back - - Don't let scripts execute in parallel (gives race conditions, and - anyway something MIGHT just be configured which is necessary for further - execution of tinc itself) - - Accidently merged check_child() with execute_script(). - - Small fixes - -commit 97c54ffb35312caf38034952b9ed2733f7e374f9 -Author: Ivo Timmermans -Date: Fri Nov 24 16:52:57 2000 +0000 - - Add default tinc-up and tinc-down scripts for a Debian system. These - do not yet work, it's just old code from init.d. - -commit b42c9abafdc102db0641f3d444bdb30fbc29140a -Author: Ivo Timmermans -Date: Fri Nov 24 14:15:20 2000 +0000 - - Call autogen.sh instead of configure alone; and make cvs-clean instead - of distclean. This way you can just cvs checkout && dpkg-buildpackage - in one go. - -commit edb9b4cad09855a9bb3c57c5d4b1b174fde1de6c -Author: Ivo Timmermans -Date: Fri Nov 24 14:13:51 2000 +0000 - - Explain how to tell configure where OpenSSL lives. - -commit 4cb4a7d298d560593f84d974bf77d0ee8a911a50 -Author: Ivo Timmermans -Date: Fri Nov 24 14:13:06 2000 +0000 - - Set errno to 0 before trying to kill the other process. - -commit ef88db63120503a8c9d34d86073795c99dedc3a9 -Author: Ivo Timmermans -Date: Fri Nov 24 14:12:31 2000 +0000 - - Alter CFLAGS, somehow INCLUDES doesn't propagate properly. Still - doesn't work exactly like it should, but getting there. - -commit b17822840150f5ba8cfb8e5a44fc10d66bd15a97 -Author: Ivo Timmermans -Date: Fri Nov 24 14:04:49 2000 +0000 - - Set CFLAGS to -O2 -Wall when running configure - -commit eb36b0c1ef7b5ed8ff59c3b41cbb361ed37d5f01 -Author: Ivo Timmermans -Date: Fri Nov 24 14:00:32 2000 +0000 - - Use cvs2cl instead of rcs2log to generate the ChangeLog. - -commit 2f37f2bd8ab6b89eb6b6c2b4bdd6ffe449b1aa98 -Author: Ivo Timmermans -Date: Fri Nov 24 14:03:13 2000 +0000 - - Set localstatedir to /var - -commit 31aa4298463498cbb755db747e901e4269cd1ef6 -Author: Ivo Timmermans -Date: Fri Nov 24 13:33:48 2000 +0000 - - Do not attempt to retreive ChangeLog information only from the CABAL - tag, it doesn't work anyway. - -commit f2dd7bb42c1f4bfa708f542e430f4a56fd43e74f -Author: Ivo Timmermans -Date: Fri Nov 24 13:32:26 2000 +0000 - - Do not check for the daemon() system call - -commit b0ff879e7c68edd447328f3d806c1ad9e336fece -Author: Ivo Timmermans -Date: Fri Nov 24 12:44:39 2000 +0000 - - Do not use the C library's daemon() call. - -commit cebcf78b9a24f70902009bea23514e55d84b096a -Author: Guus Sliepen -Date: Thu Nov 23 09:30:33 2000 +0000 - - - Don't link with -ldl anymore - - Let's not use bash' built-in pwd function anymore... it does not follow - symlinks. - -commit 7aa7895629d72391eccfcb23f3cb6290a9e3abc3 -Author: Guus Sliepen -Date: Wed Nov 22 23:09:38 2000 +0000 - - - #include instead of - -commit dac256505e1af78505c9f905bd55c11d4b87345c -Author: Guus Sliepen -Date: Wed Nov 22 22:18:03 2000 +0000 - - - Fixed all (except 2) compiler warnings gcc -Wall gave. - -commit 6f373e690236334d8f8333710b61f97ccad54bf1 -Author: Guus Sliepen -Date: Wed Nov 22 22:05:37 2000 +0000 - - - More porting to FreeBSD and Solaris. - -commit 5971e352dae2cf189f1cbdeacffa4ccdd1e98304 -Author: Guus Sliepen -Date: Wed Nov 22 20:25:27 2000 +0000 - - - Work with the correct key buffer in ans_key_h - -commit a07602c4fddfca9894f1d738959ae359695f5bf9 -Author: Guus Sliepen -Date: Wed Nov 22 19:55:53 2000 +0000 - - - No more %as. - -commit 394ed3fb174bb629bfb4b441fe58842562f955de -Author: Guus Sliepen -Date: Wed Nov 22 19:14:09 2000 +0000 - - - Write pidfile AFTER detaching... - - Minor cleanups - -commit f8b4a000d008082e5c7e511a49318b8dea8fd08d -Author: Guus Sliepen -Date: Wed Nov 22 18:54:08 2000 +0000 - - - Cleaned up and checked for some more NULL pointers in rbl.c - - Two connection lists: one for incoming connections, sorted on ip/port, - one for connections whose identity we know, sorted on id ofcourse... - -commit 785684f0ec5c9250788b4b32c0eab3f358c9db61 -Author: Ivo Timmermans -Date: Wed Nov 22 17:49:16 2000 +0000 - - Declare fd. - -commit e42255ae1374fe65e92de72de4508a84bdb91fa1 -Author: Ivo Timmermans -Date: Wed Nov 22 17:48:15 2000 +0000 - - Add more checks to ensure that filedescriptors are right in - _execute_script(). - -commit 2ed68134047a19e708c2a2af32c58968835a7043 -Author: Ivo Timmermans -Date: Wed Nov 22 16:19:07 2000 +0000 - - Honor the --localstatedir option to configure, instead of hardcoded /var. - -commit 9e9e1925b901dff87518f0e1534a33e48eab8303 -Author: Guus Sliepen -Date: Tue Nov 21 09:13:59 2000 +0000 - - - Check for NULL tree->delete callback - - Add xstrdup() function - -commit da9a1e8084a9b73306bdbc541ee8af938c3e7754 -Author: Guus Sliepen -Date: Mon Nov 20 23:29:47 2000 +0000 - - - More fixes. - -commit 3a6200c1e39b61b249db3d1f9bcffa77351863bd -Author: Guus Sliepen -Date: Mon Nov 20 22:13:14 2000 +0000 - - - Various small fixes. - -commit 06afd357b0cf4aab778b1ccabbd1be61a9500d10 -Author: Ivo Timmermans -Date: Mon Nov 20 19:56:01 2000 +0000 - - Get rid of all libtool references at once. libtool was only used by - libblowfish, which was superseded by openssl. - -commit 1857b3c97c261dda9978a67d07b315bb3ca68841 -Author: Guus Sliepen -Date: Mon Nov 20 19:41:13 2000 +0000 - - - Proper initialization of rbltree structures. - -commit 408ca91766088b6c2d38e198b0692bf394b41248 -Author: Guus Sliepen -Date: Mon Nov 20 19:12:17 2000 +0000 - - - Integrate rbl trees into tinc. - -commit 9024e01ce649b89d304a4aa5b1d6ef0b56b5a12c -Author: Ivo Timmermans -Date: Mon Nov 20 18:06:17 2000 +0000 - - Also include process.h - -commit 3cc063d23a6e3a23fd01f03b0bc99825c2b13e16 -Author: Ivo Timmermans -Date: Mon Nov 20 18:05:34 2000 +0000 - - More function and header checks - -commit 59aa15d3d1db4e948113f202dd2183f4bb23970d -Author: Ivo Timmermans -Date: Mon Nov 20 18:02:15 2000 +0000 - - Added this release - -commit 8f273f0ee265c75dd8eea65b2f1cd60a79691cd6 -Author: Guus Sliepen -Date: Sun Nov 19 22:12:46 2000 +0000 - - - Small fixes - -commit cc7c078774db955cece9b263022e6c1ca955fc10 -Author: Guus Sliepen -Date: Sun Nov 19 11:05:59 2000 +0000 - - - Deletion also works now. - -commit 3526f1e151b7a189f075d88c9d88cacaece31d02 -Author: Guus Sliepen -Date: Sun Nov 19 02:04:29 2000 +0000 - - - Fixed a lot of small things. Tested everything except deletions. - -commit 4f68e5b6133480478edba0959cb87d4eb149a8e7 -Author: Guus Sliepen -Date: Sat Nov 18 23:22:44 2000 +0000 - - - Fix tree head/tail upon insertion - -commit 880cd6f1a94ef76ebebc5bd96dd26d62e3d829f4 -Author: Guus Sliepen -Date: Sat Nov 18 23:21:01 2000 +0000 - - - Implemented deletions - - Added rbl_foreach() function - -commit 00e5d572621ad5f0263999dbfbfcb11e023bf48b -Author: Guus Sliepen -Date: Sat Nov 18 18:14:57 2000 +0000 - - - Fixed searching - - Insertion implemented - -commit 7fcc0c6415488ed6ce0089a67ab7cfdd5d0d83ca -Author: Guus Sliepen -Date: Fri Nov 17 10:03:02 2000 +0000 - - - Removed stray @INCLUDE@ (how did that get there?) - - Use 0 instead of FALSE - -commit 44cbd13e5248880b074b5068df14a4634204a1d3 -Author: Guus Sliepen -Date: Fri Nov 17 00:56:49 2000 +0000 - - - Simplified do_detach - -commit 2626c641aa714a8d776f1bb16340586d935aa6b1 -Author: Ivo Timmermans -Date: Thu Nov 16 22:13:09 2000 +0000 - - Use proper prototypes. - -commit 5d1145f2c4b3b8261ca0aa0e89a2daf321640f0b -Author: Ivo Timmermans -Date: Thu Nov 16 22:12:23 2000 +0000 - - Move more functions from tincd.c into process.c. - -commit 485f7a5043a4b3345bd02e5063502603550b4c76 -Author: Ivo Timmermans -Date: Thu Nov 16 22:11:40 2000 +0000 - - Delete struct ifr - -commit 30f34015ee11bbe1106c07e381288a702f12dac5 -Author: Ivo Timmermans -Date: Thu Nov 16 18:06:39 2000 +0000 - - New function: xmalloc_and_zero, which initialises the allocated memory - to all zeroes. - -commit 2764532ea72200d0a27ad2d79e6e299c00c62404 -Author: Ivo Timmermans -Date: Thu Nov 16 17:54:29 2000 +0000 - - Move all process-related functions into process.c. - -commit aa755206da4bcce3261ecd5dbfa41570a0155c73 -Author: Guus Sliepen -Date: Thu Nov 16 09:18:38 2000 +0000 - - - Added balanced tree management stuff as well. (It is not finished yet.) - -commit 7f87c3d9134612041d56180ea7fc3e6c37991f6b -Author: Ivo Timmermans -Date: Wed Nov 15 22:07:36 2000 +0000 - - Keep a list of running children, and in each loop in main_loop(), - check if one has exited. - -commit d9ce5a7f3f5eddb193b6a9b5974c7c49eac41ea1 -Author: Ivo Timmermans -Date: Wed Nov 15 22:04:48 2000 +0000 - - List management and manipulation routines. - -commit e118ba0a648000c48d6a401c9b9249a844d6dbcf -Author: Guus Sliepen -Date: Wed Nov 15 13:33:27 2000 +0000 - - Porting to FreeBSD: - - Reorganized and added some #includes - -commit 596e248bc588323cc7ee751286dbcaf677b5c653 -Author: Ivo Timmermans -Date: Wed Nov 15 01:28:21 2000 +0000 - - Let the output from an executed script in execute_script() go to - syslog, with proper error detection. - -commit bb2495e569fb161b42efd633eb1c471b8222b1fb -Author: Ivo Timmermans -Date: Wed Nov 15 01:06:13 2000 +0000 - - Use the HAVE_OPENSSL_xxx_H defined from m4/openssl.m4 during - configure. - -commit 6fb4a5b6be5628ece9b391b46e7858fdf5957a80 -Author: Ivo Timmermans -Date: Wed Nov 15 01:02:30 2000 +0000 - - Also check for sha.h. - -commit 8eb60d0ccde2f1de6fd917db7300e537f271783e -Author: Ivo Timmermans -Date: Wed Nov 15 00:57:26 2000 +0000 - - Also check for rand.h and err.h. If any of these files does not - exist, try the next alternative path. - -commit c5c8e99afd3fae3868f20b5c7a4f8754498b39ad -Author: Ivo Timmermans -Date: Tue Nov 14 23:18:19 2000 +0000 - - Get rid of the annoying empty line - -commit c467ee02d3ef8bed7ec2cc52cb1527ec60cdc93a -Author: Ivo Timmermans -Date: Tue Nov 14 23:02:08 2000 +0000 - - Oops, small error. - -commit 9ddb37cee0f754ef88a55f692a508010fe18c782 -Author: Ivo Timmermans -Date: Tue Nov 14 22:57:19 2000 +0000 - - Better checks for OpenSSL. I think it can now detect almost all conceivable installations. - -commit 72c3776d6ac103fa25d216c42847ecba3a4f58e5 -Author: Ivo Timmermans -Date: Mon Nov 13 22:29:22 2000 +0000 - - Identify version as 1.0pre4-cvs - -commit 5344832be1126967ff340cf6bd270a377bb8e487 -Author: Ivo Timmermans -Date: Mon Nov 13 22:01:27 2000 +0000 - - Add a check for openssl that accepts explicit file locations. - -commit 5b74909ea070fbd482340dc42193e33366a9dddb -Author: Ivo Timmermans -Date: Thu Nov 9 21:33:18 2000 +0000 - - Add prototype for destroy_queue - -commit 6e27618708233998db7e5886ed9afaa21bb9d938 -Author: Ivo Timmermans -Date: Thu Nov 9 21:29:58 2000 +0000 - - Updates, updates - -commit a91eae538d9cff8aed399a175c0bbc7d744cd22a -Author: Ivo Timmermans -Date: Thu Nov 9 20:59:35 2000 +0000 - - Bop version number to 1.0pre3-1 - -commit e65a93053cca3f8aebf63094cf160835c3108e25 -Author: Ivo Timmermans -Date: Thu Nov 9 20:42:16 2000 +0000 - - Wrapped text to 70 (72?) columns for easy reading - -commit 4310b17be9cefcc1814ddef471e4c5cd8f9f867e -Author: Ivo Timmermans -Date: Thu Nov 9 20:41:13 2000 +0000 - - Final release notes added, also edited release notes for 1.0pre2 to what the announcement on the mailing list looked like. - -commit 16847ea255fa8a7c0ed922af80a2f36b7bdf4b3b -Author: Guus Sliepen -Date: Wed Nov 8 20:52:37 2000 +0000 - - - Make checkpoint tracing a compile time option (off by default) - -commit 55d7b5a2bb1df6f55f0a93e9cfed77c1da337588 -Author: Guus Sliepen -Date: Wed Nov 8 18:05:06 2000 +0000 - - - Add Jamie :) - -commit 5055e1dedc9fe984c497448c1b2ffc4afdf18aa3 -Author: Guus Sliepen -Date: Wed Nov 8 17:56:34 2000 +0000 - - - Applied Jamie Brigg's patch (close sockets after error) - -commit 74326df7adc514798565df0a8719421adbb5fef3 -Author: Guus Sliepen -Date: Wed Nov 8 00:20:06 2000 +0000 - - - Fixed --config - - Show warning when both netname and config directory are given. - -commit f8f1007bf469d44480d95d0d78ddc156d00e059f -Author: Guus Sliepen -Date: Wed Nov 8 00:10:50 2000 +0000 - - Porting to SunOS 5.8: - - More #includes Linux doesn't seem to need - - Don't do unsetenv() on SunOS - - Use a replacement asprintf() in case the OS doesn't support it - It now compiles properly under SunOS. - -commit 56bd0864e4c5680fee59af48228b1ec3fb97b57b -Author: Guus Sliepen -Date: Tue Nov 7 22:33:33 2000 +0000 - - Porting to SunOS 5.8: - - Include all header files necessary - - Check for flock() function - -commit 7d0f82bd4b7044a5151835e25e830fd28dfaaebd -Author: Guus Sliepen -Date: Tue Nov 7 22:02:14 2000 +0000 - - - Open UDP connection for all known hosts. Comments please. - -commit f95cc86d0c14ca4c47e5459af4bb6d1170baa9f5 -Author: Guus Sliepen -Date: Tue Nov 7 21:43:28 2000 +0000 - - Changed execution of tinc-up: - - Do not free() strings that have been putenv()d, see man page of the - latter. - - Do not set IFNAME anymore, it appears that the ioctl to get the name of - the interface does not work at all. Since it is set to NETNAME in case - of tun/tap and it is known beforehand in case of ethertap, there is no - need for it anyway... (though it would've simplified things). - -commit efc3a2a466937da942afc84dde080ba8b1731140 -Author: Ivo Timmermans -Date: Sun Nov 5 02:19:58 2000 +0000 - - Build-Depends on gettext - -commit 698191fd2f512f3618e2d60592fcd57cd750b965 -Author: Guus Sliepen -Date: Sat Nov 4 22:57:33 2000 +0000 - - - Prepended config_ to all configuration option names, because it confused - everything (including myself). - - Use connection oriented UDP sockets for both incoming and outgoing - packets. - -commit afc05797077641baa33b024ffeaafd6cad3ff7a7 -Author: Guus Sliepen -Date: Sat Nov 4 20:44:28 2000 +0000 - - - Simplified ping mechanism. - -commit 2191d894bfd615e8fa7857d031ea630edc12a854 -Author: Ivo Timmermans -Date: Sat Nov 4 17:29:45 2000 +0000 - - Build-depends on libtool - -commit 5019dd879177b5ab9413e5c0aa72a15d0e585acf -Author: Guus Sliepen -Date: Sat Nov 4 17:09:10 2000 +0000 - - - Check for packets that are looping back. - -commit 20dd5aff4d2898d8b59f371671cc110b870fa09c -Author: Ivo Timmermans -Date: Sat Nov 4 17:04:17 2000 +0000 - - Updated Dutch translation - -commit 3f177e9bf02b6121055414a2cc7fd3f4cff01cba -Author: Ivo Timmermans -Date: Sat Nov 4 17:01:55 2000 +0000 - - Add route.c to the list of source files. - -commit ac47586552710425417ed80878f8f853c313b421 -Author: Guus Sliepen -Date: Sat Nov 4 16:54:21 2000 +0000 - - - Forward keys in hex notation, not as binary data. - -commit 3f8f067e8b559366b9b41dee6a4312702c82042f -Author: Guus Sliepen -Date: Sat Nov 4 16:39:19 2000 +0000 - - - Don't forget to set packet cipher for added hosts. - -commit 433858d410c1fedf8d2a5f2b4ecd7c980dd79dd2 -Author: Guus Sliepen -Date: Sat Nov 4 15:34:07 2000 +0000 - - - connlist.c added to translation - -commit 15246df85d6171c92478541a835effb96d6085c4 -Author: Ivo Timmermans -Date: Sat Nov 4 15:32:05 2000 +0000 - - In execute_script: - - add an environment variable NETNAME. - - chdir to the configuration directory before execing the script. - -commit 69618c01385eb7226cd6eab0918d1f30b0ed6c66 -Author: Ivo Timmermans -Date: Sat Nov 4 15:18:58 2000 +0000 - - Do not include the passphrases directory - -commit 417f36a07990ff9bc7de7d4e63e57146bef0dd75 -Author: Guus Sliepen -Date: Sat Nov 4 15:17:02 2000 +0000 - - - Removed manpage for no longer existing genauth. - -commit 3d7189a444fe3efed58dc93a071129007041aebf -Author: Guus Sliepen -Date: Sat Nov 4 14:52:40 2000 +0000 - - - Resolve scriptname after fork() - -commit d38772ebc42f5ad1d946ee89d955f5d43bb2fe8c -Author: Ivo Timmermans -Date: Sat Nov 4 14:16:46 2000 +0000 - - Use putenv() instead of clumsy do-it-yourself in execute_script. - -commit f83803c1bf6557d5af93982e7cd987e151eba401 -Author: Ivo Timmermans -Date: Sat Nov 4 13:25:15 2000 +0000 - - Small change to the way the environment is copied. - -commit ed0bf283e37642f9f7673f664713a16d916bd70f -Author: Guus Sliepen -Date: Sat Nov 4 11:49:58 2000 +0000 - - - Removed even more warnings. - -commit dc699f8b1265deb7606d553e36326527dbd29746 -Author: Guus Sliepen -Date: Sat Nov 4 10:37:27 2000 +0000 - - - Removed unused MAC strip/add functions. - -commit 5065ea32c32e27478d93c00a1bba0c812b7a2b8c -Author: Ivo Timmermans -Date: Fri Nov 3 22:35:12 2000 +0000 - - Warnings removal pass: always include config.h first; add a few - prototypes in the header files. - - This also fixes a few lint errors/warnings. - -commit 73aa7fbf7e1b623398d1bc1493f567ce4d846f22 -Author: Ivo Timmermans -Date: Fri Nov 3 22:33:16 2000 +0000 - - Run the scripts tinc-up and tinc-down from a separate function, which - sets the environment as it should be and checks for errors. - -commit 4ad1e382d6f10acf94ce59d85b80925cee7553a6 -Author: Ivo Timmermans -Date: Fri Nov 3 22:31:55 2000 +0000 - - Save the environment on startup. - -commit 7612c6da3890ce5a0730e4dfde9d5ba07bdbf5b3 -Author: Ivo Timmermans -Date: Thu Nov 2 23:02:49 2000 +0000 - - Minor cosmetic change. - -commit 6a10e42f734e8bec9848a11e73bc2a8211a9f401 -Author: Ivo Timmermans -Date: Thu Nov 2 22:51:16 2000 +0000 - - - If necessary, patch po/Makefile.in from po-Makefile.in.in.diff to - get DESTDIR installation (required to get locales installed - correctly). - - Use dh_perl to get accurate perl dependencies. - -commit ef12849c1a03b3aaf85dd46786d6631f66b104bd -Author: Ivo Timmermans -Date: Thu Nov 2 22:11:18 2000 +0000 - - Oops, and include doc-base.tinc (new file). - -commit 5672ddd6cb9116420a1904f7741fdbed89c2ec54 -Author: Ivo Timmermans -Date: Thu Nov 2 22:10:09 2000 +0000 - - Don't include shlibs, as it no longer exists. - -commit 013fcb0e9f9c0222f4f63ddf42a2f25bfc4a5546 -Author: Ivo Timmermans -Date: Thu Nov 2 22:05:36 2000 +0000 - - Changed a few messages wrt. system calls; updated and changed the Dutch translation a bit. - -commit c444305c0bb965aa515a503406844ceeb483c285 -Author: Ivo Timmermans -Date: Thu Nov 2 21:43:03 2000 +0000 - - Mention fileutils, add a pointer to THANKS for more details - -commit 84c842def74c5d0e9c4a69e4f584fe9eb66eb728 -Author: Ivo Timmermans -Date: Thu Nov 2 21:41:53 2000 +0000 - - Change wsl to Wessel's name and email address in the ChangeLog creation - -commit 5b6815751e581bedd64bfc63aea5b42c746bbceb -Author: Ivo Timmermans -Date: Thu Nov 2 21:40:33 2000 +0000 - - More exhaustive list of changes - perhaps it can be worded differently? - -commit e954fc8f0c731e7116fd27f38c176b83cca519f7 -Author: Ivo Timmermans -Date: Thu Nov 2 21:39:57 2000 +0000 - - Changed `I' to `We' - small change, lots of difference :) - -commit 3db3a41667f90ce74bfd0197fc867cc71a087e50 -Author: Ivo Timmermans -Date: Thu Nov 2 21:38:55 2000 +0000 - - Only check for linux/if_tun.h once - -commit 1b11bcb0128ca65580cbf28ffb16078c81e6d678 -Author: Ivo Timmermans -Date: Thu Nov 2 21:34:45 2000 +0000 - - Added a perl example to turn an IP address into a MAC address. - -commit cadf81fe67aed424504758865c2ea2bb263c76fb -Author: Ivo Timmermans -Date: Thu Nov 2 21:26:51 2000 +0000 - - Do not include $(top_srcdir)/cipher, it does no longer exist. - -commit fd32d771a84765281ea4ab8a5d9dbf5cebfa2911 -Author: Ivo Timmermans -Date: Thu Nov 2 20:29:03 2000 +0000 - - - Synchronized changelog with the package's changelog. - - Changed maintainer email address. - - New file doc-base.tinc. - - Better Build-Depends and Depends lines. - -commit a13d9c9da7434154b33e666c2236844011b87d46 -Author: Ivo Timmermans -Date: Thu Nov 2 20:25:35 2000 +0000 - - This file is no longer needed. - -commit 59528ec892e8b9a599f2b39bf432a3d842e963fe -Author: Guus Sliepen -Date: Tue Oct 31 16:22:49 2000 +0000 - - Removed config file parsing and interface setup. This will be handled by - the tinc-up and tinc-down scripts from now on. - -commit af565d00220b7536b9987c48e2a71459b45027b4 -Author: Guus Sliepen -Date: Tue Oct 31 16:10:17 2000 +0000 - - - Update. - -commit b4c1d4e2d3287acd7ca438455c64e50a2828ad24 -Author: Guus Sliepen -Date: Mon Oct 30 10:19:06 2000 +0000 - - - Fixed some spelling mistakes and terminology here and there. - -commit 4811afa073c871f2a52dfd5139bd0171046365eb -Author: Guus Sliepen -Date: Mon Oct 30 00:22:54 2000 +0000 - - - Small cleanups - - Updated dutch translation - - Updated man pages - -commit b7d4d4c17712e0bb9ee8bd497a2f525b79d5f40d -Author: Guus Sliepen -Date: Sun Oct 29 22:55:15 2000 +0000 - - - Finishing touch: encrypt the meta connections - -commit ec12269355f7979fdc0783dc15d109832f1e83cd -Author: Guus Sliepen -Date: Sun Oct 29 22:10:44 2000 +0000 - - - Use CFB mode for encrypting packets: it works and we don't need padding. - -commit cea3d8f3056d3c6aaaef473443240b8470c8ea2d -Author: Guus Sliepen -Date: Sun Oct 29 10:39:08 2000 +0000 - - - Small fixes - - Do proper key exchange - - Encrypt packets - it works, but there is something wrong with the MAC - header after decryption... - -commit 8fa9bc017d89b53798903df3fa98311067d4de90 -Author: Guus Sliepen -Date: Sun Oct 29 09:19:27 2000 +0000 - - - Removed old encr stuff - -commit a26d371d0df3bee1bdc6e9d7046e949ee29e6de7 -Author: Guus Sliepen -Date: Sun Oct 29 02:07:41 2000 +0000 - - - Updated dutch translation. - - Shutdown properly. - -commit e8391bd49975aa29fa62d6ae1d2d2ee398e0eb3e -Author: Guus Sliepen -Date: Sun Oct 29 01:27:23 2000 +0000 - - - Moved connlist stuff to the proper header file. - -commit 2689690dc37c384c4a022d03ab80f2cfb7fb9553 -Author: Guus Sliepen -Date: Sun Oct 29 01:08:09 2000 +0000 - - - Enforce correct order of authentication requests - -commit 3b9802a542f1fa439321d3386763ec33989194b5 -Author: Guus Sliepen -Date: Sun Oct 29 00:46:43 2000 +0000 - - - Hit people who can't figure out subnet address/mask pairs with a - (clue)bat. - -commit 7398002ade1397bd857953f009f4aed65ffc9218 -Author: Guus Sliepen -Date: Sun Oct 29 00:24:31 2000 +0000 - - - Fixed ans_key_h - - Removed tapsubnet configuration option. - -commit 35932fe6c8cb481eb687f98424776ce429570c21 -Author: Guus Sliepen -Date: Sun Oct 29 00:02:20 2000 +0000 - - - Very big cleanup. - -commit db21f015161aac244ec5600c4d0ff685549892c2 -Author: Guus Sliepen -Date: Sat Oct 28 21:52:22 2000 +0000 - - - Override destination ethernet address on incoming packets with - FE:FD:00:00:00:00 - -commit 8738c007b15eea024bc4ca6ee0f972b2f5bf259f -Author: Guus Sliepen -Date: Sat Oct 28 21:25:21 2000 +0000 - - - Fixed offsets when reading/writing from/to tap device - -commit f25868fd2b58bc0b350a5cfaf342480f28f804cf -Author: Guus Sliepen -Date: Sat Oct 28 21:05:20 2000 +0000 - - - Lots of small fixes - - Exchange subnets on acknowledgement of connection - - Do proper lookup when incoming packets from tap - - off-by-a small number-error when reading/sending tap packets - -commit ba6b8005ebe3a53877590c242ff581dc5dee5eae -Author: Ivo Timmermans -Date: Sat Oct 28 19:34:53 2000 +0000 - - Skip the check for Linux kernel sources - -commit d47d5932a3bbc4940aa6453ebfe617ef330783c8 -Author: Guus Sliepen -Date: Sat Oct 28 16:41:40 2000 +0000 - - - Updated subnet list handling. Subnets are added to two lists now, the - owner's list and a global list. It is all fucked up but it probably - works anyway, good enough for pre3 :). - -commit 9c2f805255fa36b05e8fe9391f639581d938b653 -Author: Guus Sliepen -Date: Tue Oct 24 15:46:18 2000 +0000 - - - Lots of little stuff modified - - Succesfully reads in subnets from host config file now and adds them to - the list. - -commit 60401d99b18ae01d91ca65faf8d2b32fac2b4474 -Author: Ivo Timmermans -Date: Mon Oct 23 21:56:56 2000 +0000 - - Oops, echelon change committed to cabal... :) - -commit c46e84837d1c84a8590e0e3507227670368884a7 -Author: Guus Sliepen -Date: Mon Oct 23 13:52:54 2000 +0000 - - - route.c will contain the routing logic. - -commit 76d794eaf7c1664a47f4d0080fcd80e4a551740b -Author: Ivo Timmermans -Date: Sun Oct 22 13:47:41 2000 +0000 - - read_server_config: Check for result of read_config_file. - -commit 56d8e862409ae91c63a27968b01a48a94aafb205 -Author: Ivo Timmermans -Date: Sun Oct 22 13:37:15 2000 +0000 - - Include linux/sockios.h and net/if.h anyway, regardless of the value of HAVE_TUNTAP. - -commit 52b842f8076d507d3a6ea07045d085ae21d1aa10 -Author: Guus Sliepen -Date: Sat Oct 21 11:52:08 2000 +0000 - - - Fixed all debug levels. - - Seed PRNG before generating a challenge - - Strange thing in challenge decryption: it fails if first bit is set!? - -commit 73f7efddd723b25c1477ec1139dc7211307ff660 -Author: Guus Sliepen -Date: Fri Oct 20 19:46:58 2000 +0000 - - - Removed last reference to genauth from Makefile.am - - Tinc spawns tinc-up and tinc-down scripts which can be used to configure - the network device. The environment variable IFNAME is set to the name - of the interface. - -commit fba19c30c92d39e74f5fd5594053793b036f30f4 -Author: Guus Sliepen -Date: Fri Oct 20 16:49:20 2000 +0000 - - - Made Makefile.am stub for doc/es/ - - Merged genauth into tincd - - Updated dutch translation - -commit 97ec5685b92ea727fe8f8b4bb8cf289a20f8580b -Author: Ivo Timmermans -Date: Fri Oct 20 16:44:32 2000 +0000 - - Generalized list and hash handling functions - -commit 699e159a7a1711034f1d16d68ad1974a82e12dfc -Author: Ivo Timmermans -Date: Fri Oct 20 16:43:13 2000 +0000 - - New function: xalloc_and_zero() - -commit 4059151732afb7d8fb52121d80e54f2ee325d30e -Author: Ivo Timmermans -Date: Fri Oct 20 16:42:22 2000 +0000 - - Add all the new files to the sources list for the utility library - -commit 9f64499e40a95a8c05c82924219517aa017fc411 -Author: Guus Sliepen -Date: Fri Oct 20 15:34:38 2000 +0000 - - - tinc now really does public/private key encryption! It even works, whee! - -commit 71f05ff8956cb2e62181fcef763709b0de8faa68 -Author: Ivo Timmermans -Date: Thu Oct 19 20:56:49 2000 +0000 - - Generalized error handling functions - -commit 95f4e8620ef8e2cdec1cc3b2ccb8cc8e3ce94e40 -Author: Ivo Timmermans -Date: Thu Oct 19 20:39:04 2000 +0000 - - Add check for the syslog function - -commit 430e14162918864f9f18aad0ec0badc1ccc3e01f -Author: Ivo Timmermans -Date: Thu Oct 19 17:29:22 2000 +0000 - - Changed changelog - -commit d5fd1344e668da0bc8536e798f347041d5377843 -Author: Guus Sliepen -Date: Thu Oct 19 14:42:00 2000 +0000 - - - Seed the PRNG using /dev/random before generating the keys. - -commit 30df5e95dbe585c6076d743d3771a42ad7c78590 -Author: Ivo Timmermans -Date: Wed Oct 18 20:12:10 2000 +0000 - - Bring head revision up to date with cabal (try #3) - -commit 571cfb5846c710a0a3cdbdddce8936f6b34f1cf1 -Author: Ivo Timmermans -Date: Wed Oct 18 19:44:11 2000 +0000 - - Get the head revision up to date with cabal - -commit e75315dae609f32041ca5ed939fd2a1b69d32d3e -Author: Ivo Timmermans -Date: Tue Oct 17 10:15:20 2000 +0000 - - Don't declare cp_file and cp_line in xmalloc() - -commit 31c543ad0fa1d19667a03a9bd183c668def23da0 -Author: Ivo Timmermans -Date: Tue Oct 17 10:14:25 2000 +0000 - - Process subdir es/ - -commit 20301888b7a0a206119d2cfc48ccf1a667bb4add -Author: Guus Sliepen -Date: Mon Oct 16 19:04:47 2000 +0000 - - - More fixing. Tinc daemons can now even create activated connections. - -commit bb3d18d56fa0dd2bc5146d0a0044b6ef0880bdb4 -Author: Guus Sliepen -Date: Mon Oct 16 16:33:30 2000 +0000 - - - Fixing little things - - Two tinc daemons can connect to eachother now (but they disconnect right - after the ACKs). - -commit 6e32b870ee127555888a115163922362c99009f9 -Author: Ivo Timmermans -Date: Mon Oct 16 11:35:10 2000 +0000 - - Output doc/es/Makefile - -commit baeac83bf465a47d46082e1de40ea14dcf1d39af -Author: Guus Sliepen -Date: Sun Oct 15 20:30:39 2000 +0000 - - Corrected #ifdefs for tun/tap support. - -commit 782171fd2c59b7cc5568d2d4b33ce041834710ec -Author: Ivo Timmermans -Date: Sun Oct 15 20:21:27 2000 +0000 - - Really #include the if_tun.h files now - -commit 8a54c51238672abd7a72c1dbdc7d17b9956a0d35 -Author: Ivo Timmermans -Date: Sun Oct 15 20:13:55 2000 +0000 - - Linearized checks for if_tun.h - -commit e5130495d7d4083d58ab76c26001aa27f5fc13db -Author: Ivo Timmermans -Date: Sun Oct 15 19:53:15 2000 +0000 - - Wrap the tun/tap code in #ifdef HAVE_TUNTAP - -commit 3b455b8f318528206b08121f5ce93d16e4ea01df -Author: Ivo Timmermans -Date: Sun Oct 15 17:26:31 2000 +0000 - - Add checks for the presence of the universal tun/tap device driver. - -commit 85adeef21275633b78a234b2660cbe3bc9dd2c33 -Author: Guus Sliepen -Date: Sun Oct 15 00:59:37 2000 +0000 - - - The daemon actually runs now (somewhat) - - Added support for tun/tap driver (autodetect!) - - More sophisticated checkpoint functionality - - Updated dutch translation - -commit 97ce045189e330e121873d1b4be1959c60062cbb -Author: Ivo Timmermans -Date: Sat Oct 14 22:22:06 2000 +0000 - - Add CVS id lines - -commit 2e159d0139e77041ad82e96bf0abef6aaf64a258 -Author: Ivo Timmermans -Date: Sat Oct 14 22:17:29 2000 +0000 - - Fix `Requirements'-section for GMP and OpenSSL libraries. - -commit 1d5bb49f261b4346b5a440ae6bbf58fe391ea46e -Author: Ivo Timmermans -Date: Sat Oct 14 22:00:09 2000 +0000 - - Update Depends lines to reflect the dependencies on OpenSSL - -commit e9635ae38e0e2e3eb92568a1e234f8348856dd69 -Author: Guus Sliepen -Date: Sat Oct 14 17:04:16 2000 +0000 - - - Second fixing-things pass: it even links now. - - Lots of FIXME comments added to the source code. - -commit 6a8c2e346e6125e58aab428e6730c18a949abe12 -Author: Ivo Timmermans -Date: Fri Oct 13 23:34:56 2000 +0000 - - Don't look for GMP header files - -commit f18e30dab3c208fd353af11e365791035534f444 -Author: Ivo Timmermans -Date: Fri Oct 13 23:30:11 2000 +0000 - - Updated new requirements, pointers to the manual - -commit a96f2f0fc8a02593d4cda5976df3c76fc5c99eae -Author: Ivo Timmermans -Date: Fri Oct 13 23:29:35 2000 +0000 - - Link with OpenSSL, forget libGMP - -commit 183a8edd22ba4bc682392c73ae02fc9e121eda68 -Author: Guus Sliepen -Date: Wed Oct 11 22:01:02 2000 +0000 - - - Fixing-things pass: every source file compiles into an object file now, - but linking tincd does not work yet (must link with openssl libs and - define some missing functions). - -commit 6e39481d8f2406e60b5e329ace08b5a005d5cc43 -Author: Guus Sliepen -Date: Wed Oct 11 13:42:52 2000 +0000 - - - Generalized config file parsing to support multiple configuration trees. - -commit 451e9e3e7a968151de541de68603a01f0922b415 -Author: Guus Sliepen -Date: Wed Oct 11 12:07:27 2000 +0000 - - - Changed genauth to produce rsa keypairs instead of random passphrases. - -commit 950fb8e916b0e248dcaa72c96859acd6046683aa -Author: Guus Sliepen -Date: Wed Oct 11 10:35:17 2000 +0000 - - Big and bad commit of my current tree... - - Added seperate file for connection list handling - - Updating everything to use connlist, meta and subnet files - - Removed dependency on libgmp - - Lots of other stuff... - -commit 73d0dcfcc1019ee745a422982b4e3ede9d59dd91 -Author: Guus Sliepen -Date: Wed Oct 4 15:09:57 2000 +0000 - - Removing cipher directory (all will be covered by OpenSSL). - -commit 2228b16159a7aff64e6559ee1635716154e67fe6 -Author: Guus Sliepen -Date: Sun Oct 1 03:21:49 2000 +0000 - - - Added subnet handling code - - Other small changes to header files - -commit 676b1c0ea111406eb94a74ae12878dfd5ad9f56d -Author: Ivo Timmermans -Date: Wed Sep 27 20:32:29 2000 +0000 - - Many updates, parts rewritten, added, shuffled around. - -commit c78a204f06182f50b0812c8e4fef6163e82097bf -Author: Guus Sliepen -Date: Tue Sep 26 14:06:11 2000 +0000 - - - Added meta.c which contains functions to send, receive and broadcast - metadata. It will also handle encryption and decryption, and possibly - compression and checksumming. - - Moved request dispatcher to protocol.c. - -commit 2c412009e5805f04c650889b19fcb38531f2aa50 -Author: Guus Sliepen -Date: Mon Sep 25 20:08:50 2000 +0000 - - - Very detailed example of the authentication phase. - -commit 361690b18c1f5464db7b9cef235c648784780dfb -Author: Guus Sliepen -Date: Fri Sep 22 16:20:07 2000 +0000 - - - Removed options "string" stuff. It was a bad idea... - - free() everything that is allocated. - -commit 5afc1e98f436c4a2ed5da4b64293275b09632c79 -Author: Guus Sliepen -Date: Fri Sep 22 15:06:28 2000 +0000 - - - Severe code reduction and simplification of challenge requests - - "Finished" [add|del]_subnet_h - - Added lots of sanity checks to [add|del]_host_h - -commit 5d0b3516d5e8a46ca2268bdb32657b72295501ec -Author: Guus Sliepen -Date: Sun Sep 17 21:42:05 2000 +0000 - - - Updated authentication scheme. - - Removed all trailing spaces from all lines. - - Added things to add_ and del_subnet_h. - -commit 84f210edd9e72a65ca8b034a0d3bbc12e506c580 -Author: Guus Sliepen -Date: Sun Sep 17 20:11:59 2000 +0000 - - - Included authentication scheme from protocol.c - - Added a few comments about the symmetric cipher. - -commit 2863134a4113b7805a662f45a21a1be0ae9606cb -Author: Guus Sliepen -Date: Sun Sep 17 19:57:39 2000 +0000 - - Added document about the used cryptographic algorithms and the reasons - behind them. Feel very free to comment on this! - -commit 33a5b4547141c11b5128d9f4863fcf6cf8e33452 -Author: Ivo Timmermans -Date: Sun Sep 17 10:28:57 2000 +0000 - - Added Spanish translation of the docs by Matias Carrasco - -commit 7f3ab38c222809b15da2fe8dd655d35432eaafe0 -Author: Ivo Timmermans -Date: Fri Sep 15 12:58:40 2000 +0000 - - Second round of fixes - -commit ed397b6ac676329b237e219c806143cccf456b3c -Author: Ivo Timmermans -Date: Thu Sep 14 21:51:21 2000 +0000 - - First round of needed fixes after the overhaul - -commit 296171d115614d61480d896cd77898f5393c191d -Author: Ivo Timmermans -Date: Thu Sep 14 14:34:38 2000 +0000 - - New directive: Name. - -commit d335c6d0d7328fd86154dc60b22deb7953ab0228 -Author: Ivo Timmermans -Date: Thu Sep 14 14:32:34 2000 +0000 - - Added some structures and types that are needed for the overhaul. - -commit c04c84c98055c6b9e9e7890d3992648a3b715a1a -Author: Guus Sliepen -Date: Thu Sep 14 11:54:51 2000 +0000 - - - Lots of small changes. - -commit cd6695df82c55454a3f5b644f5c20a8ed31e7c97 -Author: Ivo Timmermans -Date: Mon Sep 11 11:40:46 2000 +0000 - - Better checks for SunOS libraries - -commit 9c75350ac6c14886195b6d368af2f118fd5d60e0 -Author: Guus Sliepen -Date: Mon Sep 11 10:05:35 2000 +0000 - - - Fixed modulo in keylength check - - Updated header file to reflect new protocol code - -commit 76b5f255c6cb0c5dfb5a870c371ec6f7c7879bb2 -Author: Guus Sliepen -Date: Sun Sep 10 23:11:37 2000 +0000 - - - Some key exchange stuff. (Last commit before going to bed.) - -commit 675ed08a71ec28d8ae99e10e993d5c7cb717f017 -Author: Guus Sliepen -Date: Sun Sep 10 22:49:46 2000 +0000 - - - Lots of functions added for the new protocol. - -commit 9926dae4646a96ee647a2ca7d728e91600dd1cca -Author: Ivo Timmermans -Date: Sun Sep 10 21:57:11 2000 +0000 - - Add Guus' name and shift out old protocol requests - -commit 74157d3f4501f4d1ec913a986b7167d2b847e41e -Author: Ivo Timmermans -Date: Sun Sep 10 18:37:46 2000 +0000 - - Correct filenames for passphrases given in the example - -commit 6b9ec9ed1e818d5e50dda4418ffb4d02c898bcba -Author: Guus Sliepen -Date: Sun Sep 10 16:15:35 2000 +0000 - - - Added more function skeletons for the new protocol. - -commit 28cc30159565a7eda4f66215a5994d84b46b47ad -Author: Guus Sliepen -Date: Sun Sep 10 15:18:03 2000 +0000 - - - New protocol. Will break everything else for now. - -commit 7884d3ecaf78006b3f288d99f10ef541fc97087e -Author: Ivo Timmermans -Date: Sun Sep 10 15:16:07 2000 +0000 - - Support for -lsocket and -lnsl on SunOS - -commit 14554e6f421e881b01be20879e9279545f375154 -Author: Ivo Timmermans -Date: Sun Sep 10 15:15:38 2000 +0000 - - Include openssl/blowfish.h - -commit 45ea3ca432a031ff1b8072d934709aadaae12534 -Author: Ivo Timmermans -Date: Sun Sep 10 15:07:41 2000 +0000 - - Updated text, removed protocol flowchart - -commit ae17572e6b94c6e7a2123ddeb45bf66d389ac7a0 -Author: Ivo Timmermans -Date: Sun Sep 10 15:05:45 2000 +0000 - - Link with OpenSSL crypto libraries instead of own blowfish library - -commit 4dde583bc91985c3ff19ac1d1f1bc791b50658ff -Author: Guus Sliepen -Date: Wed Sep 6 11:49:05 2000 +0000 - - - Use strerror() instead of sys_errlist[] for increased portability - (Needed for SunOS) - -commit 66e535a729dd5a9e45600ab74dc19c2b4062ee96 -Author: Ivo Timmermans -Date: Sun Aug 27 11:05:47 2000 +0000 - - Changed CVSROOT path in `make ChangeLog' - -commit 39e159fbe6bbffb3229542258f956fc412bd871c -Author: Guus Sliepen -Date: Tue Aug 22 14:55:04 2000 +0000 - - Fix rules (thanks to Laurence) - -commit 47992fe59f4c1b4116e4872d59251b143edc6763 -Author: Ivo Timmermans -Date: Mon Aug 21 20:35:47 2000 +0000 - - Added a rule to create an rpm - -commit d9af4f32330a495789d8eecdabbbb49928f074a7 -Author: Guus Sliepen -Date: Mon Aug 21 12:50:15 2000 +0000 - - Updated tinc.conf manual. - -commit 94a32c4b2d2ff5d4bb1376fe5ec96c6dec55f630 -Author: Ivo Timmermans -Date: Sun Aug 20 23:08:17 2000 +0000 - - Also chomp $VPNMASK - -commit 861e808fef1f6796d837215f9ad135fb4cb50f5c -Author: Ivo Timmermans -Date: Sun Aug 20 23:07:18 2000 +0000 - - (Quoting Laurence Lane:) - - The prefix is correctly set for /usr, but is - overridden with the current make install. DESTDIR is the clean way to - relocate the installation into the debian/tmp build dir. - -commit d3f41b803bf3c38910f24f1f268f182466723149 -Author: Guus Sliepen -Date: Fri Aug 18 14:45:38 2000 +0000 - - Updated the manual: - - incorporated comments from Stefan Hartsuiker - - updated configuration variables section - - added some text about key types - -commit 5c78e158d414595ab32399645678a43bb4469be6 -Author: Guus Sliepen -Date: Fri Aug 18 11:17:09 2000 +0000 - - Commented on some size calculations. - -commit d2c062a0a440d2871939b4ffdc2dbb137a4d45e7 -Author: Guus Sliepen -Date: Thu Aug 17 17:22:01 2000 +0000 - - Ran update-po and updated dutch translation. - -commit 3831f51a53088bfcc1d148fd54b3083afe7fde32 -Author: Guus Sliepen -Date: Thu Aug 17 16:51:08 2000 +0000 - - Fixed all sprintf() spl01ts. - -commit 9acd4379f705edc8b736e21b9011434e63f7dd95 -Author: Guus Sliepen -Date: Wed Aug 9 14:02:16 2000 +0000 - - - Added two extra configuration options, Interface and InterfaceIP, to - bind the listen socket to a network device or a specific IP. - -commit f6d79366b3efaef0a458717aac5e6754630dd434 -Author: Guus Sliepen -Date: Wed Aug 9 09:34:21 2000 +0000 - - - Reinstated O_NONBLOCK for meta socket - - Set SO_KEEPALIVE on meta socket - -commit 3cfc9424f255c26f2a7775b6fa059f1e3e47a76e -Author: Guus Sliepen -Date: Tue Aug 8 17:07:48 2000 +0000 - - - Moved TCP packet reception to meta handler: less kludgy and less buggy! - -commit e092d15be17db1d69c37f2aba46c66e03631c099 -Author: Guus Sliepen -Date: Tue Aug 8 14:54:57 2000 +0000 - - - Added date/time of build and protocol number to --version output. - -commit ff87f385c3a81499eff6b848aed8548cf6e5132e -Author: Guus Sliepen -Date: Tue Aug 8 13:47:57 2000 +0000 - - Removed calling add_queue for tcponly packets. - -commit ac73c72488dd8b33464fac1f392e89df48f7a23b -Author: Guus Sliepen -Date: Tue Aug 8 08:48:50 2000 +0000 - - Fixed PACKET read loop. - -commit b6997b0050e78a2f2e517beba3ff01d9232b3d1f -Author: Guus Sliepen -Date: Mon Aug 7 16:27:29 2000 +0000 - - - Lots o' buglets fixed (-Wall helps) - - Made TCPonly work :) - -commit fdc6a2f106315cd9ed22943d8c0bd279631e66b4 -Author: Guus Sliepen -Date: Mon Aug 7 14:52:16 2000 +0000 - - - Added experimental hackish tunneling-over-TCP support. - Just use TCPonly = true in the configuration file. - -commit 42455e97a057fb4386f9d8fb2f8963b2ec6ddf24 -Author: Guus Sliepen -Date: Sun Jul 2 13:40:57 2000 +0000 - - - Fixed typo. - -commit b1ecbf977722ec473fc8007acd39eb0de581de1a -Author: Guus Sliepen -Date: Sun Jul 2 13:36:18 2000 +0000 - - - Delayed address resolving for ConnectTo lines in configuration file to - allow DynDNS to work without restarting tincd. - -commit 6642ec2ea4e97a2fb3e737653ab1b9351ac759e9 -Author: Guus Sliepen -Date: Sun Jul 2 12:48:04 2000 +0000 - - - Updated THANKS file - -commit e0de803c7e80621600409a0c760241a3d97617bd -Author: Ivo Timmermans -Date: Sun Jul 2 12:41:03 2000 +0000 - - Include the Spanish translation in the distribution/build process. - -commit 721d85f77277813345bdb63a610e984cec996613 -Author: Guus Sliepen -Date: Sun Jul 2 12:35:28 2000 +0000 - - - Added Spanish translation from Enrique Zanardi. - -commit e821a22876d15c921a4c1fbc0f792d83e90916f6 -Author: Guus Sliepen -Date: Sat Jul 1 14:40:56 2000 +0000 - - - Forgot to mention ourselves in the tincd manual page! :) - -commit 09f4ec190119298187cec09dd5049af8fd8bad94 -Author: Guus Sliepen -Date: Sat Jul 1 14:32:24 2000 +0000 - - - Updated PROTOCOL (a bit) - - Included a real tincd.8 describing the options, signals, debug levels - and files used by tincd. - -commit d3ea434b3684093d6d160b8077c1f51a50ac7f61 -Author: Ivo Timmermans -Date: Sat Jul 1 10:39:28 2000 +0000 - - Autogenerated by gettextize. - -commit 1b28f88808b9ac3193cf9a0db7a81a89eed8b4ef -Author: Guus Sliepen -Date: Sat Jul 1 07:49:21 2000 +0000 - - - Removed a single unused bit from status_bits_t. - -commit 7fdc881b86fe379216f09dd5703bb88d398c87a8 -Author: Wessel Dankers -Date: Sat Jul 1 07:29:32 2000 +0000 - - Added architecture section, made a start with the kernel section. - ToDo: install tinc myself to see if everything is as I say =) - -commit 8ec648abf438bb5fcfe84e3a1c6a31192dc32b2e -Author: Guus Sliepen -Date: Fri Jun 30 22:38:58 2000 +0000 - - - Added documentation for the protocols (most important the meta protocol) - used by tinc. - -commit ce72275a4342ff4e21d21bb740ee88dca1ddb5f1 -Author: Wessel Dankers -Date: Fri Jun 30 21:16:52 2000 +0000 - - Grrr, recommit - -commit bbbdda255d6e7a8730906a1b6c2bfdd2ce1b94cf -Author: Wessel Dankers -Date: Fri Jun 30 21:11:34 2000 +0000 - - This file is now only in the CABAL revision. - -commit 28a140668f892873b01afe104d21db4adb8fd8c7 -Author: Wessel Dankers -Date: Fri Jun 30 21:09:32 2000 +0000 - - More about keys - -commit 1a1ebefd572c18d6af187750847b024ce07551ae -Author: Guus Sliepen -Date: Fri Jun 30 21:03:51 2000 +0000 - - - Made tinc even more silent if no -d flag is given at all. - -commit 79ad21c392e56cad2556e7693b9639d8e2346a59 -Author: Wessel Dankers -Date: Fri Jun 30 20:57:30 2000 +0000 - - Added extra bit about keys. - -commit 8309e9b869c25677d674f5cecb8b7ac5469d1758 -Author: Wessel Dankers -Date: Fri Jun 30 20:50:47 2000 +0000 - - File added to CABAL (hopefully) - -commit 5cd0f940c7334959534d3ab4e1f3c7cac67ee38a -Author: Wessel Dankers -Date: Fri Jun 30 20:42:07 2000 +0000 - - added bit on config file, split up sections, added Id: tag - -commit 6f5aac4e39cd6fb2fb76c0121de3f3782f72f18e -Author: Wessel Dankers -Date: Fri Jun 30 20:16:15 2000 +0000 - - Initial revision. Lots of loose ends, not usable yet. - -commit c5737583c8a5d099a71174e1eb997e0972ae03e9 -Author: Guus Sliepen -Date: Fri Jun 30 12:41:06 2000 +0000 - - - Instead of logging an error when remote end closes the connection, - we print a nice message if appropiate debug level is set. - - If we get ADD_HOSTs or DEL_HOSTs for ourself, then connection lists - are really messed up. We restart, and hope our problems go away. - -commit 24874d0806bac5d75663ea9de67a71171bfc97b6 -Author: Guus Sliepen -Date: Fri Jun 30 11:45:16 2000 +0000 - - - Removed segfault bug in conf.c (must have been there for ages!) - - Made main_loop() signal proof - - #defined MAXTIMEOUT (15 minutes) - - If something really really bad happens, close all connections, wait - for MAXTIMEOUT seconds, and then restart tinc - -commit 0f9ad1f047efec53590dc43f07d225e5f20456cb -Author: Guus Sliepen -Date: Thu Jun 29 19:47:04 2000 +0000 - - - Fixed memory leak. - - Implemented SIGHUP configuration file reloading. - - Other small changes. - -commit 18c85caac36f7236454deef11b9eba74328dbd96 -Author: Guus Sliepen -Date: Thu Jun 29 17:09:08 2000 +0000 - - - New semantics for BASIC_INFO, ADD_HOST and DEL_HOST requests. This will - improve connection list consistency, ensures the tree property, and - allows for recovery from situations where track of connections is lost. - -commit e8e7379311ca3bf6e1fdd7d0f477a43e510e2317 -Author: Guus Sliepen -Date: Thu Jun 29 13:04:15 2000 +0000 - - - Removed all IP_ADDR_S macros, because gettext doesn't like them. Each - connection now has two hostnames: real_hostname (replacing the old), - and vpn_hostname. In those places where hostnames really aren't usefull - IP_ADDR_S has been replaced by %d.%d.%d.%d. - -commit e0ddb638d1fb7abf19969ac887f3b7a2bd8225c1 -Author: Guus Sliepen -Date: Thu Jun 29 07:11:23 2000 +0000 - - - Updated Dutch translation. - -commit 0a155580a3d55633bbc3a1e7dcbe8906f41913be -Author: Ivo Timmermans -Date: Wed Jun 28 21:06:40 2000 +0000 - - Oops, and mention Guus too. - -commit f2c9e7f3bbada3fbfe80f622ebc06540afb60c21 -Author: Ivo Timmermans -Date: Wed Jun 28 21:01:45 2000 +0000 - - Removed Free Software Foundation copyright, because Guus Sliepen contributed significantly. - -commit 3df9b89204626afdd514d5b7323801af76a5cd26 -Author: Guus Sliepen -Date: Wed Jun 28 14:34:40 2000 +0000 - - - Added log message when SIGCHLD is received ("thanks" to Ivo van Dong) - -commit 8c6c60adf3d5942c6368bafe9a4d4377ffad1abe -Author: Guus Sliepen -Date: Wed Jun 28 13:41:02 2000 +0000 - - - Fixed a message in nl.po - - Woops, we forgot to send our connection list to our uplink when we - connect to it... Fixed. - -commit 63c5192d570e2ba5952b4e5a807e4ab4d6fdad76 -Author: Guus Sliepen -Date: Wed Jun 28 11:39:40 2000 +0000 - - - Fixed missing " in nl.po - -commit ea40d3f1a05e9edf4ccfb77f4e9e0f8355e94a83 -Author: Guus Sliepen -Date: Wed Jun 28 11:38:01 2000 +0000 - - - Fixed some spelling errors. - - Paar zpelvautjes gerepareerd, en de Nederlandse vertaling weer bij de - tijd gebracht. - -commit dba2995db73313b1c0a56ce13395dac0bc7571a5 -Author: Guus Sliepen -Date: Wed Jun 28 10:11:10 2000 +0000 - - - Extra check op EINTR bij inlezen requests - -commit 4ee53e7dac93d1edad8664edffdfaf142438b85d -Author: Guus Sliepen -Date: Tue Jun 27 21:05:07 2000 +0000 - - - Fixes a silly little insignificant buglet. - -commit 070ad08118a33755835b31174e2b04e84f75556e -Author: Guus Sliepen -Date: Tue Jun 27 20:55:12 2000 +0000 - - - Purge old connections that are ADD_HOSTed. - -commit 4aeaea5e590fbd38aebbfacf2672304d04ba4ad1 -Author: Guus Sliepen -Date: Tue Jun 27 20:10:48 2000 +0000 - - - Improved handling of errors on connection attempts. - -commit 45a28b1e893d4da9d7977945a35ec6a8e4554830 -Author: Guus Sliepen -Date: Tue Jun 27 15:08:58 2000 +0000 - - - Fixed indirectdata=no problem - - Added support for multiple ConnectTo lines in tinc.conf. - -commit 4faed1b8546563def6a426c563cec2a26d927eda -Author: Guus Sliepen -Date: Tue Jun 27 12:58:04 2000 +0000 - - - Fixed KEY_CHANGED notification. A lot of notify_others() calls were - wrong (first two arguments swapped). Should probably be doublechecked. - - Don't retry to connect to hosts with different protocol versions. - -commit 04cb206298df033d254ca007205d13f9a670c402 -Author: Guus Sliepen -Date: Mon Jun 26 20:30:21 2000 +0000 - - - Moved all connection messages to debug level 1, without -d's only the - startup message will be logged. - - Fixed DEL_HOST rebound. - -commit 783c8298610d5670f6e118f49bd3d1fdfa61ae1d -Author: Guus Sliepen -Date: Mon Jun 26 19:39:34 2000 +0000 - - - Indirectdata finally REALLY REALLY works now! - - More precise debug messages - -commit b3681ebf6c255daf082ed254282cbf493af8fa93 -Author: Guus Sliepen -Date: Mon Jun 26 17:20:58 2000 +0000 - - Fixes some hostlookups. Fixes indirectdata for real now (hopefully). - -commit 03af6d8c8056d0b7006f7d8fb19bb33d303ac8f9 -Author: Ivo Timmermans -Date: Sun Jun 25 20:52:29 2000 +0000 - - Version 1.0pre3. - -commit a473ece8a0d83be5f7992888a6a3ff938dc4fb72 -Author: Guus Sliepen -Date: Sun Jun 25 16:39:17 2000 +0000 - - - More verbose connection list - - Added "myself" as hostname when logging indirect ADD_HOSTs - -commit f1f901112e44beaecd3037dae27407ea83edd86e -Author: Guus Sliepen -Date: Sun Jun 25 16:20:27 2000 +0000 - - Hostlookup() is actually being called now. - -commit 54079bdf03e74c686f556f86082b9d14b5be227c -Author: Guus Sliepen -Date: Sun Jun 25 16:01:12 2000 +0000 - - Hostnames are back! - -commit e4b586ed070908f866a450292f9759004e6affa8 -Author: Guus Sliepen -Date: Sun Jun 25 15:45:09 2000 +0000 - - - Log possible spoofing attacks. - - Don't broadcast DEL_HOSTs for hosts that haven't been activated yet. - - If a host sends a TERMREQ, deactivate them. - -commit 9a1103a7be86de3da5548fd6446e6e4fe554cc08 -Author: Ivo Timmermans -Date: Sun Jun 25 15:42:40 2000 +0000 - - Changed version number to 1.0pre3. - -commit d8d2b83350e890adae9c9cede6e21ea4169abe00 -Author: Ivo Timmermans -Date: Sun Jun 25 15:42:40 2000 +0000 - - Changed version number to 1.0pre3. - -commit 7648bc606596851942dd6437ddaa93f53ab20f09 -Author: Guus Sliepen -Date: Sun Jun 25 15:22:16 2000 +0000 - - Added CVS Id tags to header files. - -commit 7f7e158aae8df5c65211bcfa82516e7c243cdd2e -Author: Guus Sliepen -Date: Sun Jun 25 15:16:12 2000 +0000 - - Large cleanup: - - Removed hostname lookup (it blocks, and you can always do it yourself) - - Reorganized debug levels (after hints from Axel M�ller): - 0 Startup message and errors - 1 Connection logging - 2 Meta protocol information - 3 Verbose meta protocol (includes copy of transmitted requests) - 4 Packet information (logs transmission/errors of UDP packets) - 5 Verbose packet information (every single byte, not implemented yet - to protect ourselves from filling up /var/log directories) - - Made log messages more consistent - -commit 3c54a513b0c0a3acac60e03403ab4abfa0688c62 -Author: Guus Sliepen -Date: Sat Jun 24 12:35:42 2000 +0000 - - If we have "indirectdata" flag set, we only send data to our uplink. - -commit d8e2f7104c3203edbf23d2349656c765a4310dee -Author: Guus Sliepen -Date: Fri Jun 23 19:27:03 2000 +0000 - - First step for implementation of the "indirectdata" directive. This should - allow _leaf_ tincds to be behind firewalls. - The protocol has changed and is INCOMPATIBLE with previous versions. The - PROT_CURRENT value has been incremented. - -commit 33c3a25a66251606cbf20d3bd5b392d8837116e3 -Author: Ivo Timmermans -Date: Sat Jun 17 20:55:54 2000 +0000 - - Configuration directive `IndirectData'. - -commit 1c8adb5e1f12894fc9a478fbf29678fb662e03ab -Author: Ivo Timmermans -Date: Sat Jun 17 20:30:44 2000 +0000 - - Merge changes from 1.6-1.8. - -commit 0d167e1f5d8778674a9a77b2256050e3afe2896e -Author: Guus Sliepen -Date: Sat Jun 17 08:30:45 2000 +0000 - - Added another semicolon for bash2 compliance (thanks to Jamie Briggs) - -commit 00f316810aa808368cdff620b1a1efdd1fcade20 -Author: Guus Sliepen -Date: Fri Jun 16 05:44:26 2000 +0000 - - Applied patch from Jamie Briggs for bash2 conformance. - -commit ef294a69678bc7cba6d2ee0be96f683249672222 -Author: Ivo Timmermans -Date: Tue Jun 6 10:24:33 2000 +0000 - - Include ../intl in the include path, and add @INTLLIBS@ to the list of libraries. - -commit 66e98068051bc52fa064650710260f89c09f8cfd -Author: Ivo Timmermans -Date: Sun Jun 4 12:14:31 2000 +0000 - - These files are created by gettextize (run by autogen.sh) (should have known that). - -commit d1d4a524dee9d75b067ac8e25770557cf22f4afe -Author: Ivo Timmermans -Date: Sun Jun 4 11:50:46 2000 +0000 - - Check for __gmpz_powm for libgmp3. - -commit 377c4df245ceb8c19cabfe6d7a7c76841c07ba52 -Author: Ivo Timmermans -Date: Sat Jun 3 23:32:03 2000 +0000 - - Don't touch VPNMASK if it's defined, otherwise use $MSK. - -commit 9193aee8159ce53b349557ba1ad8ed23111042bb -Author: Guus Sliepen -Date: Sat Jun 3 08:27:16 2000 +0000 - - Removed items in TODO list that are already implemented. Only two items - left. - -commit 5796d2f5b7310fa8841f76bbc7bbcf2385d960c3 -Author: Ivo Timmermans -Date: Fri Jun 2 17:30:33 2000 +0000 - - Alphabetized the list, added Lubom�r Bulej, removed Sander Smeenk and Tijs van Bakel, put merits after all names. - -commit 18b3084d2525c59f62b75346fa657ccce6459712 -Author: Guus Sliepen -Date: Thu Jun 1 20:21:27 2000 +0000 - - Debian init.d script automatically sets tap device's MTU to 1448 now. - -commit 77be52422d8c28735f787b1c233b4cec73d4db56 -Author: Ivo Timmermans -Date: Wed May 31 18:23:06 2000 +0000 - - Miscellaneous copyright updates. - -commit 8cb4bb619d777022a55255c5fa17a1a55a270ff3 -Author: Ivo Timmermans -Date: Wed May 31 18:21:27 2000 +0000 - - Handle locale settings. - -commit f20df109a638ac3a86efa70fac39e1dae8e87208 -Author: Ivo Timmermans -Date: Wed May 31 18:19:33 2000 +0000 - - Version 1.0pre2-1. - -commit 4ae74c50b7faadf31086bc61af0f8158a465e521 -Author: Ivo Timmermans -Date: Wed May 31 18:18:21 2000 +0000 - - Updated Dutch translation. - -commit 7037286586151e28b7c5f1fe09dd6c5faca18cdc -Author: Ivo Timmermans -Date: Wed May 31 18:17:45 2000 +0000 - - Tell about /etc/tinc/nets.boot. - -commit 65a9eedb05387b8cf77dbbbc56347b44a28de624 -Author: Ivo Timmermans -Date: Wed May 31 18:17:27 2000 +0000 - - Include news for 1.0pre2. - -commit 17fa07510ad74d0f96f9700538d32eb8e7b2a0ce -Author: Ivo Timmermans -Date: Tue May 30 21:36:16 2000 +0000 - - Only accept an ADD_HOST request for a host that already exists in our conn_list if the nexthop field matches the sender. This is a workaround for older clients. - -commit e7f22d2f5f0a5fcd52da7512ab734b0ba52c623f -Author: Ivo Timmermans -Date: Tue May 30 12:38:15 2000 +0000 - - In terminate_connection, only send a notification to hosts that are directly connected to us. (DEL_HOST gets forwarded automatically.) - -commit 2fdda8e4fa6c6ace5f7e9421f0644a3ffec388c9 -Author: Ivo Timmermans -Date: Tue May 30 12:31:41 2000 +0000 - - When a connection is terminated, all hosts that are still connected get notified of the lost connections. - -commit f826301889e1fa1a22770919f0385c3ca04c740a -Author: Ivo Timmermans -Date: Tue May 30 11:18:12 2000 +0000 - - Added new configuration directive `Hostnames', which controls the resolving of IP addresses to hostnames. - -commit a7ad161d2b115b6a2a69c5dc8ddd33008d3562d0 -Author: Guus Sliepen -Date: Mon May 29 23:40:05 2000 +0000 - - Only activate a connection upon receiving it's public key if it's an - incoming connection. When it's outgoing, we need to receive an ack first. - -commit 5654e156a31d05ac3026790f7749d0401b2eaabc -Author: Ivo Timmermans -Date: Mon May 29 22:27:15 2000 +0000 - - Updated changes list for version 1.0pre2. - -commit a822c7466aa91a819c498336f91c63d224c3af11 -Author: Ivo Timmermans -Date: Mon May 29 22:20:04 2000 +0000 - - Bounds check for request id (between 0 and 255). - -commit 0f2cf48d304e20abb9b3cded2aaa693828c9d412 -Author: Ivo Timmermans -Date: Mon May 29 22:15:38 2000 +0000 - - Dutch translation of tinc. - -commit 386a62ff57f283b415fd757a8c4645b24c3bd3bb -Author: Ivo Timmermans -Date: Mon May 29 21:40:51 2000 +0000 - - Define LOCALEDIR in CFLAGS. - -commit 4cd009f774e4c50cdacc06d351cac19ca3247b6b -Author: Ivo Timmermans -Date: Mon May 29 21:40:20 2000 +0000 - - Include GNU gettext checks. - -commit 5814939c9d0e801bdbed6c96092fd90b6dcd859c -Author: Ivo Timmermans -Date: Mon May 29 21:38:02 2000 +0000 - - Update acconfig.h to include values for gettext inclusion. - -commit b200b0d812763563dbe09e5da116c55e45f89e4f -Author: Ivo Timmermans -Date: Mon May 29 21:36:28 2000 +0000 - - Include system.h and ABOUT-NLS. - -commit b9ea0633c7243de552d581f4486902c67aefd695 -Author: Ivo Timmermans -Date: Mon May 29 21:04:55 2000 +0000 - - Include intl/ directory in the list of subdirs. - -commit 9fd02ffcb0cacf3de26e876de5f30510bff137a3 -Author: Ivo Timmermans -Date: Mon May 29 21:01:26 2000 +0000 - - Internationalization of tinc. - -commit 61e71ab74ad9b5edb044b84ccf1111a33eb468cb -Author: Guus Sliepen -Date: Sat May 27 20:23:01 2000 +0000 - - Terminate a connection on any error. Furthermore, disallow del_host, - add_host and other important requests until remote host has properly - authenticated itself. - -commit cc01b18bc6d0bfb12e6770fc0a007c278f355d9e -Author: Guus Sliepen -Date: Sat May 27 19:44:04 2000 +0000 - - Made tinc persistent. If no outgoing connection can be established right - after the start of the daemon, it won't quit anymore but will retry in 5 - minutes. Also, 5 minutes is now the maximum time to wait for a retry. - -commit 028659bfbf164cb7a72831506896e291010b251f -Author: Guus Sliepen -Date: Sat May 27 19:23:20 2000 +0000 - - Fixed typos. When terminating a connection, it's status is not only set to - remove=1 but also active=0. - -commit e4ff969a9868ecc25a85daab620f97227de8d493 -Author: Guus Sliepen -Date: Sat May 27 19:04:12 2000 +0000 - - Fix for a DoS attack: - A remote user could telnet to the tinc daemon and type only this line: - 61 6 00000000/00000000:28f - This would deny any packets to be sent to other tinc networks (except - for to the hosts that run tincd's themselves). Solution is to skip - hosts in lookup_conn() that have not been activated yet. - Fixed potential conn_list table corruption: - If a new connection is accepted but a connection with the same subnet - would already exist in the connection list, the OLD connection is - terminated. - -commit 4d71de15e8abd137702a5dc04a743d246c3f1110 -Author: Guus Sliepen -Date: Sat May 27 13:21:20 2000 +0000 - - Documentation updates. Removed all references to configuration variable - "AllowConnect", since it is NOT used in tinc. Added information about - "VpnMask". Elaborated a bit about "private" and "virtual" networks. - -commit 85e3c1f2716c622ca8cada83d833703bf8a3ecc6 -Author: Ivo Timmermans -Date: Fri May 26 11:25:59 2000 +0000 - - Updated by Lubomir Bulej and Mads Kiilerich: it uses /etc/tinc/nets.boot and the VpnMask directive in the config files. - -commit 3a6ffe6895b681377a9553c01e3777f499b90d4a -Author: Ivo Timmermans -Date: Sun May 21 23:01:28 2000 +0000 - - Create an empty /etc/tinc/nets.boot. - -commit b9a86ec70ed4ffe5009c4979454f0d99c8559b45 -Author: Ivo Timmermans -Date: Sun May 21 22:40:41 2000 +0000 - - Use /etc/tinc/example as a base directory for an example. /etc/tinc/example/README points to /usr/share/doc/tinc/README.Debian. - -commit 63847abdfdad03a69bfd967929336e113cdeb09e -Author: Ivo Timmermans -Date: Sun May 21 22:38:01 2000 +0000 - - Add an example of using VpnMask. - -commit 2469acc0900edeb8f1e3263fbf58bf74639c1b12 -Author: Ivo Timmermans -Date: Sun May 21 22:27:31 2000 +0000 - - When VpnMask is not present in the config file, silently use $MSK as vpnmask. - -commit 73b3e7ce03cacb644a8101610933b221fdf432d6 -Author: Guus Sliepen -Date: Sun May 21 22:21:38 2000 +0000 - - Fixed last typo. Init.d now uses ifconfig command to set both the tap's IP - address as well as the correct route. Furthermore, if no VpnMask is given, - a default of 255.255.0.0 is chosen and a warning issued. - -commit 2ad4f1cc5b6013be2deee82b0cb3f731adb51616 -Author: Guus Sliepen -Date: Sun May 21 22:08:21 2000 +0000 - - Typo. - -commit e25fc3a3dc4bc407bd0645fb9891ac127a83f468 -Author: Guus Sliepen -Date: Sun May 21 22:04:56 2000 +0000 - - VpnMask truely works now. - -commit 9ec4decec17f95cc7d5be66cc18bb040cce84d47 -Author: Ivo Timmermans -Date: Fri May 19 01:17:32 2000 +0000 - - Mask the vpn net with the vpn netmask, route would give an error if the netmask didn't match the net. - -commit 20e404ab5716b06b53a4a5443f8098f227770907 -Author: Ivo Timmermans -Date: Fri May 19 00:58:01 2000 +0000 - - Fixed typo. - -commit 44af1094be90878bd6fc09c40882cf2463046908 -Author: Ivo Timmermans -Date: Fri May 19 00:33:44 2000 +0000 - - Updated copyright notice. - -commit 01352f4c525862f05988ed8687f26210c5ba10a2 -Author: Ivo Timmermans -Date: Fri May 19 00:15:37 2000 +0000 - - Errors will not terminate the script or result in a nonzero exit code. - -commit 4ef2a8cfdb13c7eb2d811fc8c9f04df8970293c5 -Author: Ivo Timmermans -Date: Fri May 19 00:14:34 2000 +0000 - - Include postinst in the distribution. - -commit 59ca017df4c9d0f7861693b4d2ec4b7dc8c98b1e -Author: Ivo Timmermans -Date: Fri May 19 00:09:20 2000 +0000 - - Find networks in instead of . - -commit 0354962c9885f04801d8469214c172cc012cdcec -Author: Ivo Timmermans -Date: Thu May 18 23:33:44 2000 +0000 - - Don't distribute the file files. - -commit b56705e18ceec9234578d7ac12939f7c59cff066 -Author: Ivo Timmermans -Date: Thu May 18 23:28:51 2000 +0000 - - Version 1.0pre2-0.3 - -commit cbf6efb617f45ffc608fe5f61d09abdd85f444ad -Author: Ivo Timmermans -Date: Thu May 18 23:18:54 2000 +0000 - - Create a default /etc/tinc/nets.boot after installation, containing all directories under /etc/tinc by default. - -commit e7d583adfaa50370d20f4cfe88ba5b6da399911d -Author: Ivo Timmermans -Date: Thu May 18 23:09:31 2000 +0000 - - Read /etc/tinc/nets.boot to find the networks that have to be started. - -commit 8d4ab991b8c35382c9cd46dd65af873d9d08f63f -Author: Ivo Timmermans -Date: Wed May 17 23:13:51 2000 +0000 - - This file is generated with dpkg-buildpackage. - -commit ffc79bcd20b2b8085c906a446318817808bc36ae -Author: Guus Sliepen -Date: Tue May 16 16:07:15 2000 +0000 - - TODO file reinstated: - - Append your name to items if you're working on them. - - Remove them if you fixed the problem/implemented that feature. - - Add any (suspected) bugs. - -commit cdab82d6fb7d7d32194cb2162a814fbc89b7db4c -Author: Ivo Timmermans -Date: Tue May 16 14:34:44 2000 +0000 - - Use the new VpnMask directive to add a route to the rest of the VPN. - -commit 85963f4c857abc2d9a4c5a3245cc11257140b9a6 -Author: Guus Sliepen -Date: Tue May 16 13:09:15 2000 +0000 - - Stub for VpnMask config directive. - -commit 30aff5ea2aebcfc0e97e60e73ed3edc2363634a0 -Author: Ivo Timmermans -Date: Tue May 16 13:03:32 2000 +0000 - - Look if the tap devices exist before bluntly remaking them. - -commit 0761eed64c4d6d2b8e9fa6a335ccdca8ea4b95db -Author: Ivo Timmermans -Date: Tue May 16 07:56:05 2000 +0000 - - *** empty log message *** - -commit 0a2e2b0c8d20baf22b550f735b1fe63b0a1d377a -Author: Ivo Timmermans -Date: Mon May 15 19:48:46 2000 +0000 - - Depend on perl5. - -commit 7e817fcf0fdd25aae58259930006c61048b017cd -Author: Ivo Timmermans -Date: Mon May 15 18:28:45 2000 +0000 - - Unlimited length in the config file, thanks to Cris van Pelt. - -commit b18af982af810ff4c050891ad2026960c43620a0 -Author: Ivo Timmermans -Date: Mon May 15 17:15:52 2000 +0000 - - Exit with zero status if is empty. - -commit 4711a87922c84241e9bb312755d7b943ea8ae4b6 -Author: Ivo Timmermans -Date: Mon May 15 15:54:37 2000 +0000 - - Updated to newer version. - -commit a0c4e7fe6d46988f3fb1100ef00db7b747c86f72 -Author: Guus Sliepen -Date: Mon May 15 09:41:34 2000 +0000 - - Test for existence of configured tinc networks. This will also make - first install of tinc possible without errors. - -commit 265bda08cd00feebb68243d4079854916b03638e -Author: Ivo Timmermans -Date: Sun May 14 23:03:37 2000 +0000 - - .deb version number 1.0pre2-0.4. - -commit 7a450d704b5a242f8bf9129af60593c90c63df5a -Author: Ivo Timmermans -Date: Sun May 14 23:00:44 2000 +0000 - - tincd->tinc - Delete libblowfish.y not be in the .deb. - -commit 7fbfa990fcd38b8241281ce6f1a4e2992239986f -Author: Ivo Timmermans -Date: Sun May 14 22:59:47 2000 +0000 - - Mention both upstream authors. - -commit f7b04ea142623a43413f74e19b1b6a9a247647ff -Author: Ivo Timmermans -Date: Sun May 14 22:59:19 2000 +0000 - - Add description, better dependancies. - -commit 9f07fe55dc4930920b9a5909d7057ca7bc16bad9 -Author: Ivo Timmermans -Date: Sun May 14 22:58:47 2000 +0000 - - Add initscript, tincd->tinc. - -commit df10baa50c3b421b03ac9eeaed4a4a19a47f611e -Author: Ivo Timmermans -Date: Sun May 14 21:18:10 2000 +0000 - - Inserted useful content. - -commit 6c722da77cc9185e48e22818ef88f2a88cf2efc7 -Author: Ivo Timmermans -Date: Sun May 14 21:14:23 2000 +0000 - - Add shlibs control file for the blowfish library. - -commit 803f908078e87f433727a3ddf2d61734e1ed9233 -Author: Ivo Timmermans -Date: Sun May 14 21:07:16 2000 +0000 - - Give IP address instead of hex number when connecting tcp socket failed. - -commit 4b1a1c2123626b50bd1a5382867986260440e9e7 -Author: Ivo Timmermans -Date: Sun May 14 21:04:53 2000 +0000 - - Changed version to 1.0pre2. - -commit ca900d388b996c629f0c87c7a62efb52bd219065 -Author: Ivo Timmermans -Date: Sun May 14 20:58:34 2000 +0000 - - Version 1.0pre1-0.1. - -commit 7d433ebd7610e0ff7e7b4c59979c446c0a1dfd03 -Author: Ivo Timmermans -Date: Sun May 14 20:56:41 2000 +0000 - - Add check for mpz_powm in libgmp3. - -commit de09916eadd4c558937d1a6367f5319ca26ed07c -Author: Ivo Timmermans -Date: Sun May 14 13:50:10 2000 +0000 - - Only print an error with send_termreq if debug_lvl is 2 or more. - -commit 9d023b1f2e7750f4a0e506c0f61498a44c0b95a8 -Author: Guus Sliepen -Date: Sun May 14 13:06:52 2000 +0000 - - Fixed typos. - -commit e20e143f1e99bdc0a7d92e97da1bd0dc40e8a83b -Author: Guus Sliepen -Date: Sun May 14 13:02:20 2000 +0000 - - Changed ping behaviour (backwards compatible). If we don't have any data - to send, we don't need to check if the connection is still alive. - Furthermore, if we receive any kind of data from the other end, we know - it's alive, so we don't need to check it either. So, PING requests are - only sent if we send packets but there is no response. - -commit ee96ccabbbf0180d5631d3c22838456f28ee9c15 -Author: Guus Sliepen -Date: Sun May 14 12:22:42 2000 +0000 - - Cleanups. - -commit 8caa1b9d750bb7467d1c3330780b05ac2bbf9883 -Author: Guus Sliepen -Date: Sun May 14 11:39:18 2000 +0000 - - Proxymode removed. - -commit 269067bb22e8f80deb43d3ac903f4e0d67af63d2 -Author: Ivo Timmermans -Date: Sat May 13 00:54:27 2000 +0000 - - Perl version of the system startup script. - -commit 12adf1af548b7d2f2baa4be16d2df956048b7855 -Author: Ivo Timmermans -Date: Fri May 12 13:31:00 2000 +0000 - - Deleted the protocol description. - -commit d0ba34ccae02d07051bc3f7012a6c116cfb3b653 -Author: Guus Sliepen -Date: Mon May 8 18:44:15 2000 +0000 - - Added new config variable "ProxyMode". If enabled, all outgoing packets - are sent to the uplink (ConnectTo), which will have to forward them for - us (kernel should do that). This is for people behind firewalls. - -commit 92387475ace9b06af39987c71ac563cf29427009 -Author: Ivo Timmermans -Date: Fri May 5 10:48:54 2000 +0000 - - Added semicolons required by bash2 (Mads Kiilerich). - -commit bce2179fe350bf34cde0caab97f72c0930539840 -Author: Ivo Timmermans -Date: Thu May 4 23:26:24 2000 +0000 - - Copied most of the code from the redhat script. - -commit 74b0cbecce5194dc5c594cc4e2aa3e97c14ea6c1 -Author: Ivo Timmermans -Date: Thu May 4 23:17:02 2000 +0000 - - Include sys/types.h. - -commit 2f7e532d703bbf6997ae04658379df0b0d844f62 -Author: Ivo Timmermans -Date: Thu May 4 23:16:43 2000 +0000 - - Don't link in libdl. - -commit d4ef7ea0e79ee0d2b7063893f7af5ece886d838b -Author: Ivo Timmermans -Date: Thu May 4 00:01:05 2000 +0000 - - Check for the existance of libdl. - -commit 87ccd613cab1947878ef60e3c927f717df089233 -Author: Ivo Timmermans -Date: Thu May 4 00:00:50 2000 +0000 - - More for getopt support. - -commit 6182664859383a86a47846cafdc1f6fcd73b5a76 -Author: Ivo Timmermans -Date: Thu May 4 00:00:06 2000 +0000 - - Include stdio.h for fprintf. - -commit 88a8826cf72297a784d597ba5a2b47058e1faf72 -Author: Ivo Timmermans -Date: Wed May 3 23:47:06 2000 +0000 - - getopt_long() support for platforms that don't have it. - -commit 3d218a31145cf6a4c625ed287cdf3f99e4fd9a03 -Author: Ivo Timmermans -Date: Wed May 3 23:00:38 2000 +0000 - - Don't use error.h or error(), put #error in front of cpp errors. - -commit a083b1cf305f3d241f2f4b36968a5b1ed9117612 -Author: Guus Sliepen -Date: Wed May 3 18:02:15 2000 +0000 - - Squashed gcc warning. - -commit 78532475238b23eb52ac88d905fbf966d97a79d2 -Author: Guus Sliepen -Date: Wed May 3 17:59:07 2000 +0000 - - Fixes typo and UDP network byte order. - -commit 505b5ec2cd9d6cf3dc655284a8c4041ce8527a07 -Author: Guus Sliepen -Date: Wed May 3 15:37:32 2000 +0000 - - Outgoing packets now use network byte order in header. - -commit 2bc7a0c92831802eec167ad193515962a63690dd -Author: Ivo Timmermans -Date: Wed May 3 15:01:54 2000 +0000 - - Fix a typo, better handling of the info document. (from Mads Kiilerich) - -commit 89610e3fbada1dee79769b8146a500c8357fd81d -Author: Guus Sliepen -Date: Tue May 2 10:16:50 2000 +0000 - - Replaced sprintf() by safer snprintf(), removed possible buffer overflow - by one byte. - -commit aeccaca829842910b4a5c8a5fa61e1738492bea6 -Author: Guus Sliepen -Date: Tue May 2 09:55:34 2000 +0000 - - Previous fix fixed. Meta protocol should be really flawless from now on! - -commit 989d7edc07fd407e7f7838b45986f4e37359ef97 -Author: Guus Sliepen -Date: Tue May 2 09:10:33 2000 +0000 - - Fixed small mistake that would prevent forwarding requests. - -commit 069c146656b8f952e465492c53ab5b514e959565 -Author: Ivo Timmermans -Date: Mon May 1 22:00:02 2000 +0000 - - Mentioned new metaprotocol. - -commit bd0325655867b1dff740d52d0505773bba0606a6 -Author: Ivo Timmermans -Date: Mon May 1 21:47:12 2000 +0000 - - More tincd->tinc updates. - -commit a9247e6f2c57bda9dc62ed050f41048847109e83 -Author: Ivo Timmermans -Date: Mon May 1 21:31:59 2000 +0000 - - Fixed meta protocol. - -commit 9ea27f76fab3663c9c83a7fe7de95f74cbfd59be -Author: Ivo Timmermans -Date: Mon May 1 21:31:17 2000 +0000 - - Committed by Mads Kiilerich. - -commit a92604fa5dffef589fc3042c5ae09ae8878e8cff -Author: Ivo Timmermans -Date: Mon May 1 19:17:09 2000 +0000 - - Updates by Mads Kiilerich. - -commit ca6abd41ea0cdf2ca6491c3945fb3c62fd40ab98 -Author: Guus Sliepen -Date: Mon May 1 18:07:12 2000 +0000 - - Meta protocol overhaul. Tinc is now incompatible with previous versions, - furthermore this version does NOT work yet because of a problem with - sending keys (these should be converted to base36 or something like that). - It is possible to telnet to the tinc daemon now and type some commands - by hand though :). - -commit 3219be5770716bdb0c8b6e9e4c674a447c5085f2 -Author: Ivo Timmermans -Date: Mon May 1 16:28:28 2000 +0000 - - Committed by Lubom�r Bulej. - -commit 33cfdf43f4309c17d6df811b3c5d0af3a1c8679f -Author: Ivo Timmermans -Date: Sun Apr 30 20:48:48 2000 +0000 - - Key forwarding, write one byte extra. - -commit 75d351eaf1264cfb7aa47166469e8ec722712a89 -Author: Ivo Timmermans -Date: Sun Apr 30 19:49:49 2000 +0000 - - Protocol fix (ANS_KEY). This breaks 0.3.3 protocol compatibility. - -commit b4290c3f4360f3cf01bb44957da0d8a20eac75f3 -Author: Ivo Timmermans -Date: Sun Apr 30 19:03:00 2000 +0000 - - Send one less byte from an ANS_KEY request. - -commit d878230ebef5f1a14a23c266dc425666d9e805eb -Author: Ivo Timmermans -Date: Sun Apr 30 18:57:16 2000 +0000 - - Read one less byte from an ANS_KEY request. - -commit 789a4c4f400de31d43b9c5f349f1de417443074a -Author: Ivo Timmermans -Date: Sun Apr 30 16:34:31 2000 +0000 - - Removed debug messages. - -commit eb1c9814e6b2a5206be1fadf19e0dc779690a69e -Author: Ivo Timmermans -Date: Sun Apr 30 16:31:23 2000 +0000 - - Read public keys the right way (tm). - -commit ca73b722cbad5a08ec9bb5026ed5129da9a24bd8 -Author: Ivo Timmermans -Date: Sun Apr 30 16:11:05 2000 +0000 - - New way of handling the meta protocol. - -commit cd12345032e8547a50a1f7450814364f39f0c4ec -Author: Ivo Timmermans -Date: Sun Apr 30 13:23:53 2000 +0000 - - Replaced check for status.active by status.dataopen in check_network_activity. - -commit 4b076ee87fcf8aaf1d9a2bd3c27524b4e3840167 -Author: Ivo Timmermans -Date: Sun Apr 30 01:16:51 2000 +0000 - - Initially, the vpn_mask of a connection is 255.255.255.255 to avoid confusion with lookup_conn. - -commit 1c007c0627ad5e71b8218fcb086240970e955c87 -Author: Ivo Timmermans -Date: Sun Apr 30 01:15:47 2000 +0000 - - Got rid of the nasty hacks... and replaced it by another one. - -commit c02745991422ac3d8097b126e8b256a9b33ad24b -Author: Ivo Timmermans -Date: Sat Apr 29 20:39:36 2000 +0000 - - Filled up the protocol structs with unused bytes. - -commit d3e8e8ca54928e48400584d8a70c42bbf4ae6aeb -Author: Ivo Timmermans -Date: Sat Apr 29 20:38:23 2000 +0000 - - Added `deb' target. - -commit 4dbf7022a25e678969856a38501318db4d420936 -Author: Ivo Timmermans -Date: Sat Apr 29 13:56:06 2000 +0000 - - More updates wrt. the change from tincd->tinc. - -commit 23715510149179089952eef0a2d6f87571ac0e7e -Author: Guus Sliepen -Date: Fri Apr 28 11:33:25 2000 +0000 - - Oops! Reference to write_n() removed and changed into neat write() call. - -commit bb8fff92e1bc594a085c2cbd12b215d334695feb -Author: Guus Sliepen -Date: Thu Apr 27 20:57:18 2000 +0000 - - Removed write_n() function. - -commit 4fec0cc45774ba313d1823cc64c3afdda3204a2e -Author: Ivo Timmermans -Date: Thu Apr 27 13:47:51 2000 +0000 - - Default config file name is tinc.conf, and pidfile is tinc.pid. - -commit eebb708cb29a121ea8d58bb6ca6caf41dea3c3b4 -Author: Ivo Timmermans -Date: Thu Apr 27 00:07:17 2000 +0000 - - Updated version number to 1.0. - -commit 5797d3fcb1ff56ad3ff577f7eb988b70f9d4d709 -Author: Ivo Timmermans -Date: Thu Apr 27 00:01:00 2000 +0000 - - Filled in the details, license from libblowfish copied. - -commit a3ccc15ac0979c4103f98e740b525634e8e17a0a -Author: Ivo Timmermans -Date: Wed Apr 26 23:56:22 2000 +0000 - - Version to 1.0pre1; - Create Makefile and build in debian/. - -commit d928703db1c4aa6caa6e4fbb0894037b10dce820 -Author: Ivo Timmermans -Date: Wed Apr 26 23:23:01 2000 +0000 - - Omit TODO. - -commit d0ea9c8ff287e879e531af9f1b52529421c0512f -Author: Ivo Timmermans -Date: Wed Apr 26 22:42:15 2000 +0000 - - Add an entry to dir. - -commit e5a7291543d41d435cc0fae56e52dc62a119a225 -Author: Ivo Timmermans -Date: Wed Apr 26 22:01:01 2000 +0000 - - The make command is in /usr/bin. - -commit 44f9449888344866406c75b178eff83b392b3530 -Author: Guus Sliepen -Date: Wed Apr 26 17:42:55 2000 +0000 - - Cleanups: - - Changed recv/send calls into read/write calls for streams - - Made all sizeof() functions use a variable name instead of type - -commit fca84d8a7d116c62423faf88e841daf1bee714e1 -Author: Ivo Timmermans -Date: Wed Apr 26 14:54:43 2000 +0000 - - From Mads Kiilerich. - -commit 8efe4874dabdfdf03a747ea98cf38b11cb591ef5 -Author: Guus Sliepen -Date: Tue Apr 25 22:15:28 2000 +0000 - - Converted every &variable[0] to variable. - -commit 643d8712eb2f82bde21f206306cdb6491eee7e08 -Author: Ivo Timmermans -Date: Tue Apr 25 22:00:49 2000 +0000 - - Debug level tweaking. - -commit 468f1d2efcce53937b7f5e0540269ae18f29ebac -Author: Guus Sliepen -Date: Tue Apr 25 20:50:59 2000 +0000 - - When trying to talk to a host that is in the netmask of a tinc server but - not the tinc server itself, and no keys have been exchanged yet, the key - request would be directed to the host instead of the server. Fixed. - -commit 6461a4b607f5e422b5809acb772e4bfe810b5570 -Author: Ivo Timmermans -Date: Tue Apr 25 20:42:54 2000 +0000 - - *** empty log message *** - -commit dad90e82d3c7af95820b1c04903bed7074e2b175 -Author: Guus Sliepen -Date: Tue Apr 25 20:17:44 2000 +0000 - - Fixed typo and removed some unnecessary variables. - -commit 5b7242285795f5143770b663055b87ebb5dd15b8 -Author: Guus Sliepen -Date: Tue Apr 25 20:10:37 2000 +0000 - - Packet queues fixed. They caused the trouble when resending keys. - -commit 04db888b1a94a7d63fdf9800cfd722aa9c16cd26 -Author: Ivo Timmermans -Date: Tue Apr 25 19:23:23 2000 +0000 - - Create a ChangeLog file, automake requires it. - -commit c78b76c53f516cf944ee738fad3e7d4607f282ab -Author: Ivo Timmermans -Date: Tue Apr 25 19:21:19 2000 +0000 - - *** empty log message *** - -commit 45b275e2542b4e8e7deac9e5e9eeddacfdbce90f -Author: Ivo Timmermans -Date: Tue Apr 25 19:11:02 2000 +0000 - - Initial CVS. - -commit 3a3356865267ff4c1e4f7d73f6d1486952d641b5 -Author: Guus Sliepen -Date: Tue Apr 25 18:57:23 2000 +0000 - - Added checkpoints to beginning and ending of every function. - -commit b6bdb9079a9e80b77443efe6c8b6da19e57e8505 -Author: Ivo Timmermans -Date: Tue Apr 25 17:38:54 2000 +0000 - - Remove ChangeLog with a `make cvs-clean'. - -commit ca373c61944a7bd2fe26faf081edea136104d326 -Author: Ivo Timmermans -Date: Tue Apr 25 17:35:45 2000 +0000 - - Don't include TODO in the dist. - -commit e1e590fe9a8c5c767933c68979418911f36d3a89 -Author: Ivo Timmermans -Date: Tue Apr 25 15:08:10 2000 +0000 - - Propagate CFLAGS from configure to gcc. - -commit 8a90de94a1b0e6cdaf51559d44f04a75d5f9ab0e -Author: Ivo Timmermans -Date: Tue Apr 25 15:07:21 2000 +0000 - - Delete all the files that are created by autogen.sh on a `make cvs-clean'. - -commit 24ee68b683de9937e917898075c62ff5f43ee46a -Author: Ivo Timmermans -Date: Tue Apr 25 10:40:08 2000 +0000 - - Spelling fixes. - -commit 4d85552c5bf134ada1d1083ec86dabbe41497c4a -Author: Ivo Timmermans -Date: Tue Apr 25 10:27:44 2000 +0000 - - Contributed by Mads Kiilerich. - -commit 94921d6e57e01b378ab8b1d8ea9cf3da9511fbef -Author: Ivo Timmermans -Date: Tue Apr 25 10:22:26 2000 +0000 - - Generate this Makefile.am from Makefile.am.in. - -commit 8c2b6537d32720b38554815181009c3098423414 -Author: Ivo Timmermans -Date: Tue Apr 25 09:43:50 2000 +0000 - - *** empty log message *** - -commit 03fa76dbf9965cc174eebe8a152307b8fbb63079 -Author: Ivo Timmermans -Date: Tue Apr 25 09:42:52 2000 +0000 - - Added Mads Kiilerich, removed Guus Sliepen. - -commit 7c665712d69d5a502d4c2f098ad85df3b17bfb92 -Author: Ivo Timmermans -Date: Tue Apr 25 01:45:34 2000 +0000 - - Changes largely from Mads Kiilerich. - Removed section about encryption. - -commit ce98ee1ed4121fbbf5d0e13e158511064ced6b16 -Author: Ivo Timmermans -Date: Tue Apr 25 01:26:35 2000 +0000 - - Remove test for GNOME. - -commit 6c99feb3e3cf6d69bcf52ae87b6c64ddbf3ffca5 -Author: Ivo Timmermans -Date: Tue Apr 25 01:25:18 2000 +0000 - - Use `make ChangeLog' to create this file from the CVS logs. - -commit f9eef5210dbc9c0fe54637cc4c3c0be134a51409 -Author: Ivo Timmermans -Date: Tue Apr 25 01:23:31 2000 +0000 - - Don't define HAVE_NAMESPACES and HAVE_STL. - -commit ea9d2f379a170077f93569a957c713452768d0a4 -Author: Ivo Timmermans -Date: Tue Apr 25 01:22:01 2000 +0000 - - Remove check for bigendianness. - -commit 18b204d17a054e991d90b7c4047ea106df64cdaf -Author: Ivo Timmermans -Date: Tue Apr 25 01:15:28 2000 +0000 - - This file is obsolete, most of the ideas are already in echelon. - -commit 62d5384ee01ae818906f2f8ba1456372a13a2420 -Author: Ivo Timmermans -Date: Tue Apr 25 01:10:38 2000 +0000 - - s/Gnome/tinc/g - -commit f0101589959496593db672c6a35704ea5fb33238 -Author: Ivo Timmermans -Date: Tue Apr 25 00:50:48 2000 +0000 - - The shell script autogen.sh can create all these removed files, but be - sure to have autoconf, automake, libtool and more installed. - -commit 6990a7455521665d3b67518e3f2297968108190b -Author: Ivo Timmermans -Date: Tue Apr 25 00:11:33 2000 +0000 - - Don't try to create cipher/idea/Makefile. - -commit cfecc82c9a3f5e8c4648eec058da2c6427cd76af -Author: Ivo Timmermans -Date: Mon Apr 24 21:12:32 2000 +0000 - - Don't include idea/idea.h. - -commit 63540ceff5c7bb7c76d96a4cef4ba803ce915ce1 -Author: Ivo Timmermans -Date: Mon Apr 24 21:10:33 2000 +0000 - - Don't compile in `idea'. - -commit 74315f4218ba50cc5ba32b6ecc8e8afa2b5cd704 -Author: Ivo Timmermans -Date: Mon Apr 24 20:57:22 2000 +0000 - - These files are not needed in release 1.0. - -commit 16d581be68bb52c08569e34e8a6b87f66b87e8ee -Author: Guus Sliepen -Date: Mon Apr 24 09:39:50 2000 +0000 - - Bug found! Wrong pointer was used for handling multiple ADD_HOST requests - at once. (See line 606.) - -commit f6802d349d946090bf9d1b6c761077c80065afa5 -Author: Guus Sliepen -Date: Mon Apr 24 08:32:57 2000 +0000 - - Added extra checks for desynchronized connection lists. Hopefully this will - fix those strange segmentation faults. - -commit 10749179127c681ce040fcf612038174b2bd474a -Author: Ivo Timmermans -Date: Thu Apr 20 22:50:48 2000 +0000 - - Added cvs-clean. - -commit c92701fcf007b67725d82a23ffaef3e6e5c2b0e1 -Author: Ivo Timmermans -Date: Thu Apr 20 19:14:09 2000 +0000 - - Keep make dist(dir) happy. - -commit 7db17968fc84127212ebba0fbccec1e75ced2bdc -Author: Ivo Timmermans -Date: Tue Apr 18 20:44:29 2000 +0000 - - A short notice from Mads Kiilerich. - -commit 2c5a555d7aefcf5699c68cb5d5f00f604b2542c7 -Author: Ivo Timmermans -Date: Tue Apr 18 20:43:24 2000 +0000 - - Submitted changes by Mads Kiilerich. - -commit 375b668dbc1e0268b49ea12901da72bbf5247ce5 -Author: Ivo Timmermans -Date: Tue Apr 18 20:30:20 2000 +0000 - - Include genauth.8 in the distribution. - -commit 57d8c30e4cbecea3b4216e4e650c4c0a3e160ed2 -Author: Ivo Timmermans -Date: Tue Apr 18 20:26:49 2000 +0000 - - Include the directory redhat in the build process. - -commit 0b02ebc4d98182cf79c670e7e556ac7f4f859b75 -Author: Ivo Timmermans -Date: Tue Apr 18 16:04:10 2000 +0000 - - Address for bugreports changed to tinc@nl.linux.org. - -commit 8770211c84cfb69f71bd204926593900d74ab579 -Author: Ivo Timmermans -Date: Tue Apr 18 15:59:42 2000 +0000 - - Updated manpages. - -commit 8cdb84951019feb6d4954cd11eb9663c5b9ce363 -Author: Ivo Timmermans -Date: Tue Apr 18 15:59:22 2000 +0000 - - New manpage for genauth. - -commit d11cfcec74e25ee2b88acea62ca5ef973ab7204b -Author: Ivo Timmermans -Date: Tue Apr 18 15:09:11 2000 +0000 - - Submitted by Mads Kiilerich. - -commit 93287d2b2c77d4b9e3f85f36ef4f9230fe3bf9b3 -Author: Ivo Timmermans -Date: Mon Apr 17 17:04:33 2000 +0000 - - Default passphrase length of 1024, added -h/--help options. - -commit 9c2ac77594d83a810c53faf6979e0b76006ecd0e -Author: Ivo Timmermans -Date: Mon Apr 17 16:59:42 2000 +0000 - - Check if stdout is a terminal, if so, print a verbose message. - -commit c9246896901ff1ebad91ac399a4ea79fad941f75 -Author: Ivo Timmermans -Date: Mon Apr 17 16:52:58 2000 +0000 - - Check for an illegal length of passphrase in read_passphrase(). - -commit baebae274913d912d76ba1d545f337dfb945fc5c -Author: Ivo Timmermans -Date: Mon Apr 17 16:23:29 2000 +0000 - - Pass the requested size from xmalloc() and xrealloc() on to xalloc_fail_func() - -commit 210a92cae90deb5b4a410b1b7d5c625c5c5f2ffb -Author: Ivo Timmermans -Date: Mon Apr 17 15:38:47 2000 +0000 - - Only one round of reading bits out of urandom; - Reading `bytes' bytes out of it; - Print a newline after completion. - -commit 5b44b91eb408d76af646b031da2364a769b44771 -Author: Ivo Timmermans -Date: Wed Apr 12 16:22:39 2000 +0000 - - Moved to version number 1.0. - -commit 18e044bde3b508c991910218989b4bacc3a4934e -Author: Ivo Timmermans -Date: Thu Apr 6 18:28:29 2000 +0000 - - New option -D, don't detach. - -commit 523c80c4e35b7ff8ad94b41a6071dbe2b8ff6ec7 -Author: Ivo Timmermans -Date: Tue Mar 28 19:16:27 2000 +0000 - - Ignore SIGCHLD. - -commit f2076e3e7031ac8ad87eb6aab0cea40f379dd0c6 -Author: Ivo Timmermans -Date: Tue Mar 28 19:09:52 2000 +0000 - - Kill the parent after any error conditions in detach(). - -commit 98de35c742498878a27fb29becd3b7154525a60f -Author: Ivo Timmermans -Date: Mon Mar 27 22:59:16 2000 +0000 - - Upon regeneration, free the old encryption key `securely\' by overwriting it. - -commit b50523dc44bbb32f03d24573e195c071cbff3fc4 -Author: Ivo Timmermans -Date: Mon Mar 27 22:30:27 2000 +0000 - - Get rid of the message `zxnrbl\'. - -commit 1243156a5e03a666b36bc4400f1402243a85c9a7 -Author: Ivo Timmermans -Date: Sun Mar 26 00:33:07 2000 +0000 - - Initial revision diff --git a/Makefile.am b/Makefile.am index e69542e..8e43fe5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,39 +2,14 @@ AUTOMAKE_OPTIONS = gnu -SUBDIRS = src doc test systemd +SUBDIRS = src doc systemd -ACLOCAL_AMFLAGS = -I m4 +ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = COPYING.README README.android -@CODE_COVERAGE_RULES@ - -# If git describe works, force autoconf to run in order to make sure we have the -# current version number from git in the resulting configure script. -configure-version: - -cd $(srcdir) && git describe && autoconf --force - -# Triggering the README target means we are building a distribution (make dist). -README: configure-version - ChangeLog: - (cd $(srcdir) && git log) > ChangeLog - -deb: - dpkg-buildpackage -rfakeroot - -rpm: dist - cp $(distdir).tar.gz /usr/src/redhat/SOURCES/ - cp redhat/tinc.spec /usr/src/redhat/SOURCES/ - cd /usr/src/redhat/SOURCES/ && rpm -bb tinc.spec - -release: - rm -f ChangeLog - $(MAKE) ChangeLog - echo "Please edit the NEWS file now..." - /usr/bin/editor $(srcdir)/NEWS - $(MAKE) dist + git log > ChangeLog astyle: astyle --options=.astylerc -nQ src/*.[ch] src/*/*.[ch] diff --git a/Makefile.in b/Makefile.in index e462e23..e1f2745 100644 --- a/Makefile.in +++ b/Makefile.in @@ -94,12 +94,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/attribute.m4 \ $(top_srcdir)/m4/ax_cflags_warn_all.m4 \ $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_check_link_flag.m4 \ - $(top_srcdir)/m4/ax_code_coverage.m4 \ - $(top_srcdir)/m4/ax_require_defined.m4 \ - $(top_srcdir)/m4/curses.m4 $(top_srcdir)/m4/libgcrypt.m4 \ - $(top_srcdir)/m4/lzo.m4 $(top_srcdir)/m4/miniupnpc.m4 \ - $(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/readline.m4 \ - $(top_srcdir)/m4/zlib.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/ax_require_defined.m4 $(top_srcdir)/m4/lzo.m4 \ + $(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/zlib.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ @@ -222,15 +219,8 @@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_CPPFLAGS = @CODE_COVERAGE_CPPFLAGS@ -CODE_COVERAGE_CXXFLAGS = @CODE_COVERAGE_CXXFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CODE_COVERAGE_LIBS = @CODE_COVERAGE_LIBS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ -CURSES_LIBS = @CURSES_LIBS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ @@ -239,21 +229,17 @@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ -GCOV = @GCOV@ -GENHTML = @GENHTML@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LCOV = @LCOV@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ -MINIUPNPC_LIBS = @MINIUPNPC_LIBS@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ @@ -264,8 +250,6 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -READLINE_LIBS = @READLINE_LIBS@ -SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -323,8 +307,8 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = gnu -SUBDIRS = src doc test systemd -ACLOCAL_AMFLAGS = -I m4 +SUBDIRS = src doc systemd +ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = COPYING.README README.android all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive @@ -489,6 +473,12 @@ distdir: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) distdir-am distdir-am: $(DISTFILES) + @case `sed 15q $(srcdir)/NEWS` in \ + *"$(VERSION)"*) : ;; \ + *) \ + echo "NEWS not updated; not releasing" 1>&2; \ + exit 1;; \ + esac $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -801,33 +791,8 @@ uninstall-am: .PRECIOUS: Makefile -@CODE_COVERAGE_RULES@ - -# If git describe works, force autoconf to run in order to make sure we have the -# current version number from git in the resulting configure script. -configure-version: - -cd $(srcdir) && git describe && autoconf --force - -# Triggering the README target means we are building a distribution (make dist). -README: configure-version - ChangeLog: - (cd $(srcdir) && git log) > ChangeLog - -deb: - dpkg-buildpackage -rfakeroot - -rpm: dist - cp $(distdir).tar.gz /usr/src/redhat/SOURCES/ - cp redhat/tinc.spec /usr/src/redhat/SOURCES/ - cd /usr/src/redhat/SOURCES/ && rpm -bb tinc.spec - -release: - rm -f ChangeLog - $(MAKE) ChangeLog - echo "Please edit the NEWS file now..." - /usr/bin/editor $(srcdir)/NEWS - $(MAKE) dist + git log > ChangeLog astyle: astyle --options=.astylerc -nQ src/*.[ch] src/*/*.[ch] diff --git a/NEWS b/NEWS index a458dd9..c587e87 100644 --- a/NEWS +++ b/NEWS @@ -1,732 +1,758 @@ -# Version 1.1pre17 October 8 2018 +Version 1.0.36 August 26 2019 -* Prevent oracle attacks in the legacy protocol (CVE-2018-16737, - CVE-2018-16738). -* Prevent a MITM from forcing a NULL cipher for UDP in the legacy protocol - (CVE-2018-16758). -* AutoConnect is now enabled by default. -* Per-node network traffic statistics are now shown in the output of "info" and - "dump nodes" commands. + * Fix compiling tinc with certain versions of the OpenSSL library. + * Fix parsing some IPv6 addresses with :: in them. + * Fix GraphDumpFile output to handle node names starting with a digit. + * Fix a potential segmentation fault when fragmenting packets. -Thanks to volth and Rafael Sadowski for their contributions to this version of -tinc. - -# Version 1.1pre16 June 12 2018 - -* Fixed building with support for UML sockets. -* Documentation updates and spelling fixes. -* Support for MSS clamping of IP-in-IP packets. -* Fixed parsing of the -b flag. -* Added the ability to set a firemall mark on sockets on Linux. -* Minor improvements to the build system. -* Added a cache of recently seen addresses of peers. -* Add support for --runstatedir to the configure script. -* Fixed linking with libncurses on some distributions. -* Automatically disable PMTUDiscovery when TCPOnly is enabled. -* Fixed removing the tinc service on Windows in some situations. -* Fixed the TAP-Win32 device locking up after waking up from suspend. - -Thanks to Todd C. Miller, Etienne Dechamps, Daniel Lublin, -Gjergji Ramku, Mike Sullivan and Oliver Freyermuth for their +Thanks to Rosen Penev, Quentin Rameau and Werner Schreiber for their contributions to this version of tinc. -# Version 1.1pre15 September 2 2017 +Version 1.0.35 October 5 2018 -* Detect when the machine is resuming from suspension or hibernation. -* When an old PID file is found, check whether the old daemon is still alive. -* Remember scope_id for IPv6 addresses when sending UDP packets to link-local - addresses. -* Ensure compatibility with OpenSSL 1.1. -* Only log about dropped packets with debug level 5. -* Warn when trying to generate RSA keys less than 2048 bits. -* Use AES256 and SHA256 as the default encryption and digest algorithms. -* Add DeviceType = fd to support tinc on Android without requiring root. -* Support PriorityInheritance for IPv6 packets. -* Fixes for Solaris tun/tap support. -* Add a configurable expiration time for invitations. -* Store invitation data after a successful join. -* Exit gracefully when the tun/tap device is in a bad state. -* Add the LogLevel option. -* AutoConnect now actively tries to heal split networks. + * Prevent oracle attacks (CVE-2018-16737, CVE-2018-16738). + * Prevent a MITM from forcing a NULL cipher for UDP (CVE-2018-16758). + * Minor fixes in the documentation. -Thanks to Etienne Dechamps, Rafał Leśniak, Sean McVeigh, Vittorio Gambaletta, -Dennis Lan, Pacien Tran-Girard, Roman Savelyev, lemoer and volth for their -contributions to this version of tinc. +Thanks to Amine Amri and Rafael Sadowski for their contributions to this +version of tinc. -# Version 1.1pre14 May 1 2016 +Version 1.0.34 June 12 2018 -* Add tinc.service back. + * Fix a potential segmentation fault when connecting to an IPv6 peer via a + proxy. + * Minor improvements to the build system. + * Make the systemd service file identical to the one from the 1.1 branch. + * Fix a potential problem causing IPv4 sockets to not work on macOS. -# Version 1.1pre13 April 30 2016 +Thanks to Maximilian Stein and Wang Liu Shuai for their contributions to this +version of tinc. -* Fix BSD tun device support that was broken in 1.1pre12. -* Speed up AutoConnect when there are many host config files present without - an Address. +Version 1.0.33 November 4 2017 -# Version 1.1pre12 April 24 2016 + * Allow compilation from a build directory. + * Source code cleanups. + * Fix some options specified on the command line not surviving a HUP signal. + * Handle tun/tap device returning EPERM or EBUSY. + * Disable PMTUDiscovery when TCPOnly is used. + * Support the --runstatedir option of the autoconf 2.70. -* Added a "--syslog" option to force logging to syslog even if running in the - foreground. -* Fixes and improvements to the DecrementTTL function. -* Improved PMTU discovery and UDP keepalive probes. -* More efficient relaying of UDP packets through intermediate nodes. -* Improved compatibility with newer TAP-Win32 drivers. -* Added support for UPnP. -* Allow tinc to be compiled without LibreSSL or OpenSSL (this drops - compatibility with nodes running 1.0.x). -* Added a "fsck" command to check the configuration files for problems. -* Tinc "start" now checks whether the daemon really started successfully, and - displays error messages otherwise. -* Added systemd service files. -* Use the recvmmsg() function if available. -* Support ToS/Diffserv on IPv6 connections. -* Updated support for BSD tun/tap devices. -* Added support for OS X utun interfaces. -* Dropped support for Windows 2000. -* Initial support for generating a tinc-up script from an invitation. -* Many small fixes, documentation updates. +Thanks to Rafael Sadowski and Pierre-Olivier Mercier for their contributions to +this version of tinc. -Thanks to Etienne Dechamps, Rafał Leśniak, Vittorio Gambaletta, Martin Weinelt, -Sven-Haegar Koch, Florian Klink, LunnarShadow, Dato Simó, Jo-Philipp Wich, -Jochen Voss, Nathan Stratton Treadway, Pierre Emeriaud, xentec, Samuel -Thibault and Michael Tokarev for their contributions to this version of tinc. +Version 1.0.32 September 2 2017 -# Version 1.1pre11 December 27 2014 + * Fix segmentation fault when using Cipher = none. + * Fix Proxy = exec. + * Support PriorityInheritance for IPv6 packets. + * Fixes for Solaris tun/tap support. + * Bind outgoing TCP sockets when ListenAddress is used. -* Added a "network" command to list or switch networks. -* Switched to Ed25519 keys and the ChaCha-Poly1305 cipher for the new protocol. -* AutoConnect is now a boolean option, when enabled tinc always tries to keep - at least three meta-connections open. -* The new protocol now uses UDP much more often. -* Tinc "del" and "get" commands now return a non-zero exit code when they - don't find the requested variable. -* Updated documentation. -* Added a "DeviceStandby" option to defer running tinc-up until a working - connection is made, and which on Windows will also change the network - interface link status accordingly. -* Tinc now tells the resolver to reload /etc/resolv.conf when it receives - SIGALRM. -* Improved error messages and event loop handling on Windows. -* LocalDiscovery now uses local address learned from other nodes, and is - enabled by default. -* Added a "BroadcastSubnet" option to change the behavior of broadcast packets - in router mode. -* Added support for dotted quad notation in IPv6 (e.g. ::1.2.3.4). -* Improved format of printed Subnets, MAC and IPv6 addresses. -* Added a "--batch" option to force the tinc CLI to run in non-interactive - mode. -* Improve default Device selection on *BSD and Mac OS X. -* Allow running tinc without RSA keys. +Thanks to Vittorio Gambaletta for his contribution to this version of tinc. -Thanks to Etienne Dechamps, Sven-Haegar Koch, William A. Kennington III, -Baptiste Jonglez, Alexis Hildebrandt, Armin Fisslthaler, Franz Pletz, Alexander -Ried and Saverio Proto for their contributions to this version of tinc. +Version 1.0.31 January 15 2017 -# Version 1.1pre10 February 7 2014 + * Remove ExecStop in tinc@.service. -* Added a benchmark tool (sptps_speed) for the new protocol. -* Fixed a crash when using Name = $HOST while $HOST is not set. -* Use AES-256-GCM for the new protocol. -* Updated support for Solaris. -* Allow running tincd without a private ECDSA key present when - ExperimentalProtocol is not explicitly set. -* Enable various compiler hardening flags by default. -* Added support for a "conf.d" configuration directory. -* Fix tinc-gui on Windows, also allowing it to connect to a 32-bits tincd when - tinc-gui is run in a 64-bits Python environment. -* Added a "ListenAddress" option, which like BindToAddress adds more listening - address/ports, but doesn't bind to them for outgoing sockets. -* Make invitations work better when the "invite" and "join" commands are not - run interactively. -* When creating meta-connections to a node for which no Address statement is - specified, try to use addresses learned from other nodes. +Thanks to Élie Bouttier for his contribution to this version of tinc. -Thanks to Dennis Joachimsthaler and Florent Clairambault for their contribution -to this version of tinc. +Version 1.0.30 October 30 2016 -# Version 1.1pre9 September 8 2013 + * Fix troubles connecting to some HTTP proxies. -* The UNIX socket is now created before tinc-up is called. -* Windows users can now use any extension that is in %PATHEXT% for scripts, - not only .bat. -* Outgoing sockets are bound to the address of the listening sockets again, - when there is no ambiguity. -* Added invitation-created and invitation-accepted scripts. -* Invited nodes now learn of the Mode and Broadcast settings of the VPN. -* Joining a VPN with an invitation now also works on Windows. -* The port number tincd is listening on is now always included in the - invitation URL. -* A running tincd is now correctly informed when a new invitation has been - generated. -* Several bug fixes for the new protocol. -* Added a test suite. + * Add mitigations for the Sweet32 attack when using a 64-bit block cipher. + + * Use AES256 and SHA256 as the default encryption and digest algorithms. + +Version 1.0.29 October 9 2016 + + * Fix UDP communication with peers with link-local IPv6 addresses. + + * Ensure compatibility with OpenSSL 1.1.0. + + * Ensure autoreconf can be run without requiring autoconf-archive. + + * Log warnings about dropped packets only at debug level 5. + +Version 1.0.28 April 10 2016 + + * Fix compilation on BSD platforms. + + * Add systemd service files. + +Version 1.0.27 April 10 2016 + + * When using Proxy, let the proxy resolve hostnames if tinc can't. + + * Fixes and improvements of the DecrementTTL option. + + * Fixed the $NAME variable in subnet-up/down scripts for the local Subnets. + + * Fixed potentially wrong checksum generation when clamping the MSS. + + * Properly choose between the system's or our own copy of getopt. + + * Fixed compiling tinc for Cygwin with MinGW installed. + + * Added support for OS X utun interfaces. + + * Documentation updates and minor fixes. + +Thanks to Vittorio Gambaletta, LunarShaddow, Florian Weik and Nathan Stratton +Treadway for their contributions to this version of tinc. + +Version 1.0.26 July 5 2015 + + * Tinc now forces glibc to reload /etc/resolv.conf for every hostname lookup. + + * Fixed --logfile without a filename on Windows. + + * Ensure tinc can be compiled when using musl libc. + +Thanks to Jo-Philipp Wich for his contribution to this version of tinc. + +Version 1.0.25 December 22 2014 + + * Documentation updates. + + * Support linking against -lresolv on Mac OS X. + + * Fix scripts on Windows when using the ScriptsInterpreter option. + + * Allow a minimum reconnect timeout to be specified. + + * Support PriorityInheritance on IPv6 sockets. + +Thanks to David Pflug, Baptiste Jonglez, Alexis Hildebrandt, Borg, Jochen Voss, +Tomislav Čohar and VittGam for their contributions to this version of tinc. + +Version 1.0.24 May 11 2014 + + * Various compiler hardening flags are enabled by default. + + * Updated support for Solaris, allowing switch mode on Solaris 11. + + * Configuration will now also be read from a conf.d directory. + + * Various updates to the documentation. + + * Tinc now forces glibc to reload /etc/resolv.conf after it receives SIGALRM. + + * Fixed a potential routing loop when IndirectData or TCPOnly is used and + broadcast packets are being sent. + + * Improved security with constant time memcmp and stricter use of OpenSSL's + RNG functions. + + * Fixed all issues found by Coverity. + +Thanks to Florent Clairambault, Vilbrekin, luckyhacky, Armin Fisslthaler, Loïc +Dachary and Steffan Karger for their contributions to this version of tinc. + +Version 1.0.23 October 19 2013 + + * Start authentication immediately on outgoing connections (useful for sslh). + + * Fixed segfault when Name = $HOST but $HOST is not set. + + * Updated the build system and the documentation. + + * Clean up child processes left over from Proxy = exec. + +Version 1.0.22 August 13 2013 + + * Fixed the combination of Mode = router and DeviceType = tap. + + * The $NAME variable is now set in subnet-up/down scripts. + + * Tinc now gives an error when unknown options are given on the command line. + + * Tinc now correctly handles a space between a short command line option and + an optional argument. Thanks to Etienne Dechamps for his contribution to this version of tinc. -# Version 1.1pre8 August 13 2013 +Version 1.0.21 April 22 2013 -* ExperimentalProtocol is now enabled by default. -* Added an invitation protocol that makes it easy to invite new nodes. -* Added the LocalDiscoveryAddress option to change the broadcast address used - to find local nodes. -* Limit the rate of incoming meta-connections. -* Many small bug fixes and code cleanups. - -Thanks to Etienne Dechamps and Sven-Haegar Koch for their contributions to this -version of tinc. - -# Version 1.1pre7 April 22 2013 - -* Fixed large latencies on Windows. -* Renamed the tincctl tool to tinc. -* Simplified changing the configuration using the tinc tool. -* Added a full description of the ExperimentalProtocol to the manual. -* Drop packets forwarded via TCP if they are too big (CVE-2013-1428). - -Thanks to Martin Schobert for auditing tinc and reporting the vulnerability. - -# Version 1.1pre6 February 20 2013 - -* Fixed tincd exitting immediately on Windows. -* Detect PMTU increases. -* Fixed crashes when using a SOCKS5 proxy. -* Fixed control connection when using a proxy. - -# Version 1.1pre5 January 20 2013 - -* Fixed long delays and possible hangs on Windows. -* Fixed support for the tunemu device on iOS, the UML and VDE devices. -* Small improvements to the documentation and error messages. -* Fixed broadcast packets not reaching the whole VPN. -* Tincctl now connects via a UNIX socket to the tincd on platforms that - support this. -* The PriorityInheritance option now also works in switch mode. - -# Version 1.1pre4 December 5 2012 - -* Added the "AutoConnect" option which will let tinc automatically select - which nodes to connect to. -* Improved performance of VLAN-tagged IP traffic inside the VPN. -* Ensured LocalDiscovery works with multiple BindToAddress statements and/or - IPv6-only LANs. -* Dropped dependency on libevent. -* Fixed Windows version not reading packets from the TAP adapter. - -# Version 1.1pre3 October 14 2012 - -* New experimental protocol: - * Uses 521 bit ECDSA keys for authentication. - * Uses AES-256-CTR and HMAC-SHA256. - * Always provides perfect forward secrecy. - * Used for both meta-connections and VPN packets. - * VPN packets are encrypted end-to-end. -* Many improvements to tincctl: - * "config" command shows/adds/changes configuration variables. - * "export" and "import" commands help exchange configuration files. - * "init" command sets up initial configuration files. - * "info" command shows details about a node, subnet or address. - * "log" command shows live log messages. - * Without a command it acts as a shell, with history and TAB completion. - * Improved starting/stopping tincd. - * Improved graph output. -* When trying to directly send UDP packets to a node for which multiple - addresses are known, all of them are tried. -* Many small fixes, code cleanups and documentation updates. - -# Version 1.1pre2 July 17 2011 - -* .cookie files are renamed to .pid files, which are compatible with 1.0.x. -* Experimental protocol enhancements that can be enabled with the option - ExperimentalProtocol = yes: - - * Ephemeral ECDH key exchange will be used for both the meta protocol and - UDP session keys. - * Key exchanges are signed with ECDSA. - * ECDSA public keys are automatically exchanged after RSA authentication if - nodes do not know each other's ECDSA public key yet. - -# Version 1.1pre1 June 25 2011 - -* Control interface allows control of a running tinc daemon. Used by: - * tincctl, a commandline utility - * tinc-gui, a preliminary GUI implemented in Python/wxWidgets -* Code cleanups and reorganization. -* Repleacable cryptography backend, currently supports OpenSSL and libgcrypt. -* Use libevent to handle I/O events and timeouts. -* Use splay trees instead of AVL trees to manage internal datastructures. - -Thanks to Scott Lamb and Sven-Haegar Koch for their contributions to this -version of tinc. - -# Version 1.0.22 August 13 2013 - -* Fixed the combination of Mode = router and DeviceType = tap. -* The $NAME variable is now set in subnet-up/down scripts. -* Tinc now gives an error when unknown options are given on the command line. -* Tinc now correctly handles a space between a short command line option and - an optional argument. - -Thanks to Etienne Dechamps for his contribution to this version of tinc. - -# Version 1.0.21 April 22 2013 - -* Drop packets forwarded via TCP if they are too big (CVE-2013-1428). + * Drop packets forwarded via TCP if they are too big (CVE-2013-1428). Thanks to Martin Schobert for auditing tinc and reporting this vulnerability. -# Version 1.0.20 March 03 2013 +Version 1.0.20 March 03 2013 -* Use /dev/tap0 by default on FreeBSD and NetBSD when using switch mode. -* Minor improvements and clarifications in the documentation. -* Allow tinc to be cross-compiled with Android's NDK. -* The discovered PMTU is now also applied to VLAN tagged traffic. -* The LocalDiscovery option now makes use of all addresses tinc is bound to. -* Fixed support for tunemu on iOS devices. -* The PriorityInheritance option now also works with switch mode. -* Fixed tinc crashing when using a SOCKS5 proxy. + * Use /dev/tap0 by default on FreeBSD and NetBSD when using switch mode. + + * Minor improvements and clarifications in the documentation. + + * Allow tinc to be cross-compiled with Android's NDK. + + * The discovered PMTU is now also applied to VLAN tagged traffic. + + * The LocalDiscovery option now makes use of all addresses tinc is bound to. + + * Fixed support for tunemu on iOS devices. + + * The PriorityInheritance option now also works with switch mode. + + * Fixed tinc crashing when using a SOCKS5 proxy. Thanks to Mesar Hameed, Vilbrekin and Martin Schürrer for their contributions to this version of tinc. -# Version 1.0.19 June 25 2012 +Version 1.0.19 June 25 2012 -* Allow :: notation in IPv6 Subnets. -* Add support for systemd style socket activation. -* Allow environment variables to be used for the Name option. -* Add basic support for SOCKS proxies, HTTP proxies, and proxying through an - external command. + * Allow :: notation in IPv6 Subnets. -# Version 1.0.18 March 25 2012 + * Add support for systemd style socket activation. -* Fixed IPv6 in switch mode by turning off DecrementTTL by default. -* Allow a port number to be specified in BindToAddress, which also allows tinc - to listen on multiple ports. -* Add support for multicast communication with UML/QEMU/KVM. + * Allow environment variables to be used for the Name option. -# Version 1.0.17 March 10 2012 + * Add basic support for SOCKS proxies, HTTP proxies, and proxying through an + external command. -* The DeviceType option can now be used to select dummy, raw socket, UML and - VDE devices without needing to recompile tinc. -* Allow multiple BindToAddress statements. -* Decrement TTL value of IPv4 and IPv6 packets. -* Add LocalDiscovery option allowing tinc to detect peers that are behind the - same NAT. -* Accept Subnets passed with the -o option when StrictSubnets = yes. -* Disabling old RSA keys when generating new ones now also works properly on - Windows. +Thanks to Anthony G. Basile and Michael Tokarev for their contributions to +this version of tinc. -# Version 1.0.16 July 23 2011 +Version 1.0.18 March 25 2012 -* Fixed a performance issue with TCP communication under Windows. -* Fixed code that, during network outages, would cause tinc to exit when it - thought two nodes with identical Names were on the VPN. + * Fixed IPv6 in switch mode by turning off DecrementTTL by default. -# Version 1.0.15 June 24 2011 + * Allow a port number to be specified in BindToAddress, which also allows tinc + to listen on multiple ports. -* Improved logging to file. -* Reduced amount of process wakeups on platforms which support pselect(). -* Fixed ProcessPriority option under Windows. + * Add support for multicast communication with UML/QEMU/KVM. - Thanks to Loïc Grenié for his contribution to this version of tinc. +Version 1.0.17 March 10 2012 -# Version 1.0.14 May 8 2011 + * The DeviceType option can now be used to select dummy, raw socket, UML and + VDE devices without needing to recompile tinc. -* Fixed reading configuration files that do not end with a newline. Again. -* Allow arbitrary configuration options being specified on the command line. -* Allow all options in both tinc.conf and the local host config file. -* Configurable replay window, UDP send and receive buffers for performance tuning. -* Try harder to get UDP communication back after falling back to TCP. -* Initial support for attaching tinc to a VDE switch. -* DragonFly BSD support. -* Allow linking with OpenSSL 1.0.0. + * Allow multiple BindToAddress statements. -Thanks to Brandon Black, Julien Muchembled, Michael Tokarev, Rumko and Timothy -Redaelli for their contributions to this version of tinc. + * Decrement TTL value of IPv4 and IPv6 packets. -# Version 1.0.13 Apr 11 2010 + * Add LocalDiscovery option allowing tinc to detect peers that are behind the + same NAT. -* Allow building tinc without LZO and/or Zlib. -* Clamp MSS of TCP packets in both directions. -* Experimental StrictSubnets, Forwarding and DirectOnly options, - giving more control over information and packets received from/sent to other - nodes. -* Ensure tinc never sends symbolic names for ports over the wire. + * Accept Subnets passed with the -o option when StrictSubnets = yes. -# Version 1.0.12 Feb 3 2010 + * Disabling old RSA keys when generating new ones now also works properly on + Windows. -* Really allow fast roaming of hosts to other nodes in a switched VPN. -* Fixes missing or incorrect environment variables when calling host-up/down - and subnet-up/down scripts in some cases. -* Allow port to be specified in Address statements. -* Clamp MSS of TCP packets to the discovered path MTU. -* Let two nodes behind NAT learn each others current UDP address and port via - a third node, potentially allowing direct communications in a similar way to - STUN. +Thanks to Nick Hibma for his contribution to this version of tinc. -# Version 1.0.11 Nov 1 2009 +Version 1.0.16 July 23 2011 -* Fixed potential crash when the HUP signal is sent. -* Fixes handling of weighted Subnets in switch and hub modes, preventing - unnecessary broadcasts. -* Works around a MinGW bug that caused packets to Windows nodes to always be - sent via TCP. -* Improvements to the PMTU discovery code, especially on Windows. -* Use UDP again in certain cases where 1.0.10 was too conservative and fell - back to TCP unnecessarily. -* Allow fast roaming of hosts to other nodes in a switched VPN. + * Fixed a performance issue with TCP communication under Windows. -# Version 1.0.10 Oct 18 2009 + * Fixed code that, during network outages, would cause tinc to exit when it + thought two nodes with identical Names were on the VPN. -* Fixed potential crashes during shutdown and (in rare conditions) when other - nodes disconnected from the VPN. -* Improved NAT handling: tinc now copes with mangled port numbers, and will - automatically fall back to TCP if direct UDP connection between nodes is not - possible. The TCPOnly option should not have to be used anymore. -* Allow configuration files with CRLF line endings to be read on UNIX. -* Disable old RSA keys when generating new ones, and raise the default size of - new RSA keys to 2048 bits. -* Many fixes in the path MTU discovery code, especially when Compression is - being used. -* Tinc can now drop privileges and/or chroot itself. -* The TunnelServer code now just ignores information from clients instead of - disconnecting them. -* Improved performance on Windows by using the new ProcessPriority option and - by making the handling of packets received from the TAP-Win32 adapter more - efficient. -* Code cleanups: tinc now follows the C99 standard, copyright headers have - been updated to include patch authors, checkpoint tracing and localisation - features have been removed. -* Support for (jailbroken) iPhone and iPod Touch has been added. +Version 1.0.15 June 24 2011 -Thanks to Florian Forster, Grzegorz Dymarek and especially Michael Tokarev for -their contributions to this version of tinc. + * Improved logging to file. -# Version 1.0.9 Dec 26 2008 + * Reduced amount of process wakeups on platforms which support pselect(). -* Fixed tinc as a service under Windows 2003. -* Fixed reading configuration files that do not end with a newline. -* Fixed crashes in situations where hostnames could not be resolved or hosts - would disconnect at the same time as session keys were exchanged. -* Improved default settings of tun and tap devices on BSD platforms. -* Make IPv6 sockets bind only to IPv6 on Linux. -* Enable path MTU discovery by default. -* Fixed a memory leak that occurred when connections were closed. + * Fixed ProcessPriority option under Windows. -Thanks to Max Rijevski for his contributions to this version of tinc. +Version 1.0.14 May 8 2011 -# Version 1.0.8 May 16 2007 + * Fixed reading configuration files that do not end with a newline. Again. -* Fixed some memory and resource leaks. -* Made network sockets non-blocking under Windows. + * Allow arbitrary configuration options being specified on the command line. -Thanks to Scott Lamb and "dnk" for their contributions to this version of tinc. + * Allow all options in both tinc.conf and the local host config file. -# Version 1.0.7 Jan 5 2007 + * Configurable replay window, UDP send and receive buffers for performance tuning. -* Fixed a bug that caused slow network speeds on Windows. -* Fixed a bug that caused tinc unable to write packets to the tun device on - OpenBSD. + * Try harder to get UDP communication back after falling back to TCP. -# Version 1.0.6 Dec 18 2006 + * Initial support for attaching tinc to a VDE switch. -* More flexible detection of the LZO libraries when compiling. -* Fixed a bug where broadcasts in switch and hub modes sometimes would not - work anymore when part of the VPN had become disconnected from the rest. + * DragonFly BSD support. -# Version 1.0.5 Nov 14 2006 + * Allow linking with OpenSSL 1.0.0. -* Lots of small fixes. -* Broadcast packets no longer grow in size with each hop. This should - fix switch mode (again). -* Generic host-up and host-down scripts. -* Optionally dump graph in graphviz format to a file or a script. -* Support LZO 2.0 and later. + Thanks to Brandon Black, Julien Muchembled, Michael Tokarev, Rumko and Timothy + Redaelli for their contributions to this version of tinc. -Thanks to Scott Lamb for his contributions to this version of tinc. +Version 1.0.13 Apr 11 2010 -# Version 1.0.4 May 4 2005 + * Allow building tinc without LZO and/or Zlib. -* Fix switch and hub modes. -* Optionally start scripts when a Subnet becomes (un)reachable. + * Clamp MSS of TCP packets in both directions. -# Version 1.0.3 Nov 11 2004 + * Experimental StrictSubnets, Forwarding and DirectOnly options, + giving more control over information and packets received from/sent to other + nodes. + + * Ensure tinc never sends symbolic names for ports over the wire. + +Version 1.0.12 Feb 3 2010 + + * Really allow fast roaming of hosts to other nodes in a switched VPN. + + * Fixes missing or incorrect environment variables when calling host-up/down + and subnet-up/down scripts in some cases. + + * Allow port to be specified in Address statements. + + * Clamp MSS of TCP packets to the discovered path MTU. + + * Let two nodes behind NAT learn each others current UDP address and port via + a third node, potentially allowing direct communications in a similar way to + STUN. + +Version 1.0.11 Nov 1 2009 + + * Fixed potential crash when the HUP signal is sent. + + * Fixes handling of weighted Subnets in switch and hub modes, preventing + unnecessary broadcasts. + + * Works around a MinGW bug that caused packets to Windows nodes to always be + sent via TCP. + + * Improvements to the PMTU discovery code, especially on Windows. + + * Use UDP again in certain cases where 1.0.10 was too conservative and fell + back to TCP unnecessarily. + + * Allow fast roaming of hosts to other nodes in a switched VPN. + +Version 1.0.10 Oct 18 2009 + + * Fixed potential crashes during shutdown and (in rare conditions) when other + nodes disconnected from the VPN. + + * Improved NAT handling: tinc now copes with mangled port numbers, and will + automatically fall back to TCP if direct UDP connection between nodes is not + possible. The TCPOnly option should not have to be used anymore. + + * Allow configuration files with CRLF line endings to be read on UNIX. + + * Disable old RSA keys when generating new ones, and raise the default size of + new RSA keys to 2048 bits. + + * Many fixes in the path MTU discovery code, especially when Compression is + being used. + + * Tinc can now drop privileges and/or chroot itself. + + * The TunnelServer code now just ignores information from clients instead of + disconnecting them. + + * Improved performance on Windows by using the new ProcessPriority option and + by making the handling of packets received from the TAP-Win32 adapter more + efficient. + + * Code cleanups: tinc now follows the C99 standard, copyright headers have + been updated to include patch authors, checkpoint tracing and localisation + features have been removed. + + * Support for (jailbroken) iPhone and iPod Touch has been added. + + Thanks to Florian Forster, Grzegorz Dymarek and especially Michael Tokarev for + their contributions to this version of tinc. + +Version 1.0.9 Dec 26 2008 + + * Fixed tinc as a service under Windows 2003. + + * Fixed reading configuration files that do not end with a newline. + + * Fixed crashes in situations where hostnames could not be resolved or hosts + would disconnect at the same time as session keys were exchanged. + + * Improved default settings of tun and tap devices on BSD platforms. + + * Make IPv6 sockets bind only to IPv6 on Linux. + + * Enable path MTU discovery by default. + + * Fixed a memory leak that occurred when connections were closed. + + Thanks to Max Rijevski for his contributions to this version of tinc. + +Version 1.0.8 May 16 2007 + + * Fixed some memory and resource leaks. + + * Made network sockets non-blocking under Windows. + + Thanks to Scott Lamb and "dnk" for their contributions to this version of tinc. + +Version 1.0.7 Jan 5 2007 + + * Fixed a bug that caused slow network speeds on Windows. + + * Fixed a bug that caused tinc unable to write packets to the tun device on + OpenBSD. + +Version 1.0.6 Dec 18 2006 + + * More flexible detection of the LZO libraries when compiling. + + * Fixed a bug where broadcasts in switch and hub modes sometimes would not + work anymore when part of the VPN had become disconnected from the rest. + +version 1.0.5 Nov 14 2006 + + * Lots of small fixes. + + * Broadcast packets no longer grow in size with each hop. This should + fix switch mode (again). + + * Generic host-up and host-down scripts. + + * Optionally dump graph in graphviz format to a file or a script. + + * Support LZO 2.0 and later. + + Thanks to Scott Lamb for his contributions to this version of tinc. + +version 1.0.4 May 4 2005 + + * Fix switch and hub modes. + + * Optionally start scripts when a Subnet becomes (un)reachable. + +version 1.0.3 Nov 11 2004 * Show error message when failing to write a PID file. + * Ignore spaces at end of lines in config files. + * Fix handling of late packets. + * Unify BSD tun/tap device handling. This allows IPv6 on tun devices and anything on tap devices as long as the underlying OS supports it. + * Handle IPv6 on Solaris tun devices. + * Allow tinc to work properly under Windows XP SP2. + * Allow VLAN tagged Ethernet frames in switch and hub mode. + * Experimental PMTUDiscovery, TunnelServer and BlockingTCP options. -# Version 1.0.2 Nov 8 2003 +version 1.0.2 Nov 8 2003 * Fix address and hostname resolving under Windows. + * Remove warnings about non-existing scripts and unsupported address families. + * Use the event logger under Windows. + * Fix quoting of filenames and command line arguments under Windows. + * Strict checks for length incoming network packets and return values of cryptographic functions, + * Fix a bug in metadata handling that made the tinc daemon abort. -# Version 1.0.1 Aug 14 2003 +version 1.0.1 Aug 14 2003 * Allow empty lines in config files. + * Fix handling of spaces and backslashes in filenames under native Windows. + * Allow scripts to be executed under native Windows. + * Update documentation, make it less Linux specific. -# Version 1.0 Aug 4 2003 +version 1.0 Aug 4 2003 * Lots of small bugfixes and code cleanups. + * Throughput doubled and latency reduced. + * Added support for LZO compression. + * No need to set MAC address or disable ARP anymore. + * Added support for Windows 2000 and XP, both natively and in a Cygwin environment. -# Version 1.0pre8 Sep 16 2002 +version 1.0pre8 Sep 16 2002 * More fixes for subnets with prefixlength undivisible by 8. + * Added support for NetBSD and MacOS/X. + * Switched from undirected graphs to directed graphs to avoid certain race conditions and improve scalability. + * Generalized broadcasting and forwarding of protocol messages. + * Cleanup of source code. -# Version 1.0pre7 Apr 7 2002 + +version 1.0pre7 Apr 7 2002 * Don't do blocking read()s when getting a signal. + * Remove RSA key checking code, since it sometimes thinks perfectly good RSA keys are bad. + * Fix handling of subnets when prefixlength isn't divisible by 8. -# Version 1.0pre6 Mar 27 2002 + +version 1.0pre6 Mar 27 2002 * Improvement of redundant links: + * Non-blocking connects. + * Protocol broadcast messages can no longer go into an infinite loop. + * Graph algorithm updated to look harder for direct connections. + * Good support for routing IPv6 packets over the VPN. Works on Linux, FreeBSD, possibly OpenBSD but not on Solaris. + * Support for tunnels over IPv6 networks. Works on all supported operating systems. + * Optional compression of UDP connections using zlib. + * Optionally let UDP connections inherit TOS field of tunneled packets. + * Optionally start scripts when certain hosts become (un)reachable. -# Version 1.0pre5 Feb 9 2002 + +version 1.0pre5 Feb 9 2002 * Security enhancements: + * Added sequence number and optional message authentication code to the packets. + * Configurable encryption cipher and digest algorithms. + * More robust handling of dis- and reconnects. + * Added a "switch" and a "hub" mode to allow bridging setups. + * Preliminary support for routing of IPv6 packets. + * Supports Linux, FreeBSD, OpenBSD and Solaris. -# Version 1.0pre4 Jan 17 2001 + +It looks like this might be the last release before 1.0. + + +version 1.0pre4 Jan 17 2001 * Updated documentation; the documentation now reflects the configuration as it is. + * Some internal changes to make tinc scale better for large networks, such as using AVL trees instead of linked lists for the - connection list. + connection list. + * RSA keys can be stored in separate files if needed. See the documentation for more information. -* Tinc has now been reported to run on Linux PowerPC and FreeBSD x86. -# Version 1.0pre3 Oct 31 2000 +* tinc has now been reported to run on Linux PowerPC and FreeBSD x86. + + + +version 1.0pre3 Oct 31 2000 * The protocol has been redesigned, and although some details are still under discussion, this is secure. Care has been taken to resist most, if not all, attacks. + * Unfortunately this protocol is not compatible with earlier versions, nor are earlier versions compatible with this version. Because the older protocol has huge security flaws, we feel that not implementing backwards compatibility is justified. + * Some data about the protocol: + * It uses public/private RSA keys for authentication (this is the actual fix for the security hole). + * All cryptographic functions have been taken out of tinc, instead it uses the OpenSSL library functions. + * Offers support for multiple subnets per tinc daemon. + * New is also the support for the universal tun/tap device. This means better portability to FreeBSD and Solaris. -* Tinc is tested to compile on Solaris, Linux x86, Linux alpha. -* Tinc now uses the OpenSSL library for cryptographic operations. + +* tinc is tested to compile on Solaris, Linux x86, Linux alpha. + +* tinc now uses the OpenSSL library for cryptographic operations. More information on getting and installing OpenSSL is in the manual. This also means that the GMP library is no longer required. + * Further, thanks to Enrique Zanardi, we have Spanish messages; Matias Carrasco provided us with a Spanish translation of the manual. -# Version 1.0pre2 May 31 2000 -* This version has been internationalized; and a Dutch translation has - been included. -* Two configuration variables have been added: - * VpnMask - the IP network mask for the entire VPN, not just our - subnet (as given by MyVirtualIP). The Redhat and Debian packages - use this variable in their system startup scripts, but it is - ignored by tinc. - * Hostnames - if set to `yes', look up the names of IP addresses - trying to connect to us. Default set to `no', to prevent lockups - during lookups. -* The system startup scripts for Debian and Redhat use - /etc/tinc/nets.boot to find out which networks need to be started - during system boot. -* Fixes to prevent denial of service attacks by sending random data - after connecting (and even when the connection has been established), - either random garbage or just nonsensical protocol fields. -* Tinc will retry to connect upon startup, does not quit if it doesn't - work the first time. -* Hosts that are disconnected implicitly if we lose a connection get - deleted from the internal list, to prevent hogging each other with - add and delete requests when the connection is restored. +What still needs to be done before 1.0: -# Version 1.0pre1 May 12 2000 +* Documentation. Especially since the protocol has changed, and a lot + of configuration directives have been added. -* New meta-protocol -* Various other bugfixes -* Documentation updates -# Version 0.3.3 Feb 9 2000 -* Fixed bug that made tinc stop working with latest kernels -* Updated the manual -# Version 0.3.2 Nov 12 1999 +version 1.0pre2 May 31 2000 -* No more `Invalid filedescriptor' when working with multiple - connections. -* Forward unknown packets to uplink. +* This version has been internationalized; and a Dutch translation has + been included. + +* Two configuration variables have been added: + * VpnMask - the IP network mask for the entire VPN, not just our + subnet (as given by MyVirtualIP). The Redhat and Debian packages + use this variable in their system startup scripts, but it is + ignored by tinc. + * Hostnames - if set to `yes', look up the names of IP addresses + trying to connect to us. Default set to `no', to prevent lockups + during lookups. + +* The system startup scripts for Debian and Redhat use + /etc/tinc/nets.boot to find out which networks need to be started + during system boot. + +* Fixes to prevent denial of service attacks by sending random data + after connecting (and even when the connection has been established), + either random garbage or just nonsensical protocol fields. + +* tinc will retry to connect upon startup, does not quit if it doesn't + work the first time. + +* Hosts that are disconnected implicitly if we lose a connection get + deleted from the internal list, to prevent hogging eachother with + add and delete requests when the connection is restored. + + +What still needs to be done before 1.0: + +* Documentation. +* Failover ConnectTo lines, try another one if the first doesn't work. -# Version 0.3.1 Oct 20 1999 -* Fixed a bug where tinc would exit without a trace. -# Version 0.3 Aug 20 1999 -* Pings now work immediately. -* All packet sizes get transmitted correctly. +version 1.0pre1 May 12 2000 + * New meta-protocol + * Various other bugfixes + * Documentation updates -# Version 0.2.26 Aug 15 1999 +version 0.3.3 Feb 9 2000 + * Fixed bug that made tinc stop working with latest kernels (Guus + Sliepen) + * Updated the manual -* Fixed some remaining bugs. -* --sysconfdir works with configure. -* Last version before 0.3. +version 0.3.2 Nov 12 1999 + * no more `Invalid filedescriptor' when working with multiple + connections + * forward unknown packets to uplink -# Version 0.2.25 Aug 8 1999 +version 0.3.1 Oct 20 1999 + * fixed a bug where tinc would exit without a trace -* Improved stability, going towards 0.3 now. +version 0.3 Aug 20 1999 + * pings now work immediately + * all packet sizes get transmitted correctly -# Version 0.2.24 Aug 7 1999 +version 0.2.26 Aug 15 1999 + * fixed some remaining bugs + * --sysconfdir works with configure + * last version before 0.3 -* Added key aging, there's a new config variable, KeyExpire. -* Updated man and info pages. +version 0.2.25 Aug 8 1999 + * improved stability, going towards 0.3 now. -# Version 0.2.23 Aug 5 1999 +version 0.2.24 Aug 7 1999 + * added key aging, there's a new config variable, KeyExpire. + * updated man and info pages -* All known bugs fixed, this is a candidate for 0.3. +version 0.2.23 Aug 5 1999 + * all known bugs fixed, this is a candidate for 0.3 -# Version 0.2.22 Apr 11 1999 +version 0.2.22 Apr 11 1999 + * multiconnection thing is now working nearly perfect :) -* Multiconnection thing is now working nearly perfect :) - -# Version 0.2.21 Apr 10 1999 - -* You shouldn't notice a thing, but a lot has changed wrt key +version 0.2.21 Apr 10 1999 + * You shouldn't notice a thing, but a lot has changed wrt key management - except that it refuses to talk to versions < 0.2.20 -# Version 0.2.19 Apr 3 1999 +version 0.2.20 -* Don't install a libcipher.so. +version 0.2.19 Apr 3 1999 + * don't install a libcipher.so -# Version 0.2.18 Apr 3 1999 +version 0.2.18 Apr 3 1999 + * blowfish library dynamically loaded upon execution + * included Eric Young's IDEA library -* Blowfish library dynamically loaded upon execution. -* Included Eric Young's IDEA library. +version 0.2.17 Apr 1 1999 + * tincd now re-executes itself in case of a segmentation fault. -# Version 0.2.17 Apr 1 1999 +version 0.2.16 Apr 1 1999 + * wrote tincd.conf(5) man page, which still needs a lot of work. + * config file now accepts and tolerates spaces, and any integer base +for integer variables, and better error reporting. See +doc/tincd.conf.sample for an example. -* Tincd now re-executes itself in case of a segmentation fault. +version 0.2.15 Mar 29 1999 + * fixed bugs -# Version 0.2.16 Apr 1 1999 +version 0.2.14 Feb 10 1999 + * added --timeout flag and PingTimeout configuration + * did some first syslog cleanup work -* Wrote tincd.conf(5) man page, which still needs a lot of work. -* Config file now accepts and tolerates spaces, and any integer base - for integer variables, and better error reporting. See - doc/tincd.conf.sample for an example. +version 0.2.13 Jan 23 1999 + * bugfixes -# Version 0.2.15 Mar 29 1999 +version 0.2.12 Jan 23 1999 + * fixed nauseating bug so that it would crash whenever a connection +got lost -* Fixed bugs. +version 0.2.11 Jan 22 1999 + * framework for multiple connections has been done + * simple manpage for tincd -# Version 0.2.14 Feb 10 1999 +version 0.2.10 Jan 18 1999 + * passphrase support added -* Added --timeout flag and PingTimeout configuration. -* Did some first syslog cleanup work. +version 0.2.9 Jan 13 1999 + * bugs fixed. -# Version 0.2.13 Jan 23 1999 +version 0.2.8 Jan 11 1999 + * a reworked protocol version + * a ping/pong system + * more reliable networking code + * automatic reconnection + * still does not work with more than one connection :) + * strips MAC addresses before sending, so there's less overhead, and +less redundancy -* Bugfixes. +version 0.2.7 Jan 3 1999 + * several updates to make extending more easy. -# Version 0.2.12 Jan 23 1999 +version 0.2.6 Dec 20 1998 + * Point-to-Point connections have been established, including +blowfish encryption and a secret key-exchange. -* Fixed nauseating bug so that it would crash whenever a connection - got lost. +version 0.2.5 Dec 16 1998 + * Project renamed to tinc, in honour of TINC. -# Version 0.2.11 Jan 22 1999 +version 0.2.4 Dec 16 1998 + * now it really does ;) -* Framework for multiple connections has been done. -* Simple manpage for tincd. +version 0.2.3 Nov 24 1998 + * it sort of works now -# Version 0.2.10 Jan 18 1999 +version 0.2.2 Nov 20 1998 + * uses GNU gmp. -* Passphrase support added. +version 0.2.1 Nov 14 1998 -# Version 0.2.9 Jan 13 1999 - -* Bugs fixed. - -# Version 0.2.8 Jan 11 1999 - -* A reworked protocol version. -* A ping/pong system. -* More reliable networking code. -* Automatic reconnection. -* Still does not work with more than one connection :) -* Strips MAC addresses before sending, so there's less overhead, and - less redundancy. - -# Version 0.2.7 Jan 3 1999 - -* Several updates to make extending more easy. - -# Version 0.2.6 Dec 20 1998 - -* Point-to-Point connections have been established, including - Blowfish encryption and a secret key-exchange. - -# Version 0.2.5 Dec 16 1998 - -* Project renamed to tinc, in honour of TINC. - -# Version 0.2.4 Dec 16 1998 - -* Now it really does ;) - -# Version 0.2.3 Nov 24 1998 - -* It sort of works now. - -# Version 0.2.2 Nov 20 1998 - -* Uses GNU gmp. - -# Version 0.2.1 Nov 14 1998 - -* Bare version. + * Bare version. diff --git a/README b/README index 873e2dd..127cde2 100644 --- a/README +++ b/README @@ -1,7 +1,11 @@ -This is the README file for tinc version 1.1pre17. Installation +This is the README file for tinc version 1.0.36. Installation instructions may be found in the INSTALL file. -tinc is Copyright © 1998-2018 Ivo Timmermans, Guus Sliepen , and others. +tinc is Copyright (C) 1998-2019 by: + +Ivo Timmermans, +Guus Sliepen , +and others. For a complete list of authors see the AUTHORS file. @@ -11,94 +15,119 @@ the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See the file COPYING for more details. -This is a pre-release ---------------------- - -Please note that this is NOT a stable release. Until version 1.1.0 is released, -please use one of the 1.0.x versions if you need a stable version of tinc. - -Although tinc 1.1 will be protocol compatible with tinc 1.0.x, the -functionality of the tinc program may still change, and the control socket -protocol is not fixed yet. - - Security statement ------------------ -This version uses an experimental and unfinished cryptographic protocol. Use it -at your own risk. +In August 2000, we discovered the existence of a security hole in all versions +of tinc up to and including 1.0pre2. This had to do with the way we exchanged +keys. Since then, we have been working on a new authentication scheme to make +tinc as secure as possible. The current version uses the OpenSSL library and +uses strong authentication with RSA keys. -When connecting to nodes that use the legacy protocol used in tinc 1.0, be -aware that any security issues in tinc 1.0 will apply to tinc 1.1 as well. On -September 6th, 2018, Michael Yonly contacted us and provided proof-of-concept -code that allowed a remote attacker to create an authenticated, one-way -connection with a node using the legacy protocol, and also that there was a +On the 29th of December 2001, Jerome Etienne posted a security analysis of tinc +1.0pre4. Due to a lack of sequence numbers and a message authentication code +for each packet, an attacker could possibly disrupt certain network services or +launch a denial of service attack by replaying intercepted packets. The current +version adds sequence numbers and message authentication codes to prevent such +attacks. + +On September the 15th of 2003, Peter Gutmann contacted us and showed us a +writeup describing various security issues in several VPN daemons. He showed +that tinc lacks perfect forward security, the connection authentication could +be done more properly, that the sequence number we use as an IV is not the best +practice and that the default length of the HMAC for packets is too short in +his opinion. We do not know of a way to exploit these weaknesses, but these +issues are being addressed in the tinc 1.1 branch. + +The Sweet32 attack affects versions of tinc prior to 1.0.30. + +On September 6th, 2018, Michael Yonly contacted us and provided +proof-of-concept code that allowed a remote attacker to create an +authenticated, one-way connection with a node, and also that there was a possibility for a man-in-the-middle to force UDP packets from a node to be sent in plaintext. The first issue was trivial to exploit on tinc versions prior to 1.0.30, but the changes in 1.0.30 to mitigate the Sweet32 attack made this -weakness much harder to exploit. These issues have been fixed in tinc 1.0.35 -and tinc 1.1pre17. The new protocol in the tinc 1.1 branch is not susceptible -to these issues. However, be aware that SPTPS is only used between nodes -running tinc 1.1pre* or later, and in a VPN with nodes running different -versions, the security might only be as good as that of the oldest version. +weakness much harder to exploit. These issues have been fixed in tinc 1.0.35. +The new protocol in the tinc 1.1 branch is not susceptible to these issues. + +Cryptography is a hard thing to get right. We cannot make any +guarantees. Time, review and feedback are the only things that can +prove the security of any cryptographic product. If you wish to review +tinc or give us feedback, you are strongly encouraged to do so. Compatibility ------------- -Version 1.1pre17 is compatible with 1.0pre8, 1.0 and later, but not with older -versions of tinc. - -When the ExperimentalProtocol option is used, tinc is still compatible with -1.0.X, 1.1pre11 and later, but not with any version between 1.1pre1 and -1.1pre10. +Version 1.0.35 is compatible with 1.0pre8, 1.0 and later, but not with older +versions of tinc. Note that since version 1.0.30, tinc requires all nodes in +the VPN to be compiled with a version of LibreSSL or OpenSSL that supports the +AES256 and SHA256 algorithms. Requirements ------------ -In order to compile tinc, you will need a GNU C compiler environment. Please -ensure you have the latest stable versions of all the required libraries: +The OpenSSL library is used for all cryptographic functions. You can find it at +https://www.openssl.org/. You will need version 1.0.1 or later with support for +AES256 and SHA256 enabled. If this library is not installed on your system, the +configure script will fail. The manual in doc/tinc.texi contains more detailed +information on how to install this library. Alternatively, you may also use the +LibreSSL library. -- LibreSSL (http://www.libressl.org/) or OpenSSL (https://openssl.org/) version 1.0.0 or later. +The zlib library is used for optional compression. You can +find it at https://zlib.net/. Because of a possible exploit in +earlier versions we recommend that you download version 1.1.4 or later. -The following libraries are used by default, but can be disabled if necessary: +The LZO library is also used for optional compression. You can +find it at https://www.oberhumer.com/opensource/lzo/. -- zlib (https://zlib.net/) -- LZO (https://www.oberhumer.com/opensource/lzo/) -- ncurses (https://invisible-island.net/ncurses/) -- readline (https://cnswww.cns.cwru.edu/php/chet/readline/rltop.html) +In order to compile tinc, you will need a C99 compliant compiler. Features -------- -Tinc is a peer-to-peer VPN daemon that supports VPNs with an arbitrary number -of nodes. Instead of configuring tunnels, you give tinc the location and -public key of a few nodes in the VPN. After making the initial connections to -those nodes, tinc will learn about all other nodes on the VPN, and will make -connections automatically. When direct connections are not possible, data will -be forwarded by intermediate nodes. +This version of tinc supports multiple virtual networks at once. To +use this feature, you may supply a netname via the -n or --net +options. The standard locations for the config files will then be +/etc/tinc//. -Tinc 1.1 support two protocols. The first is a legacy protocol that provides -backwards compatibility with tinc 1.0 nodes, and which by default uses 2048 bit -RSA keys for authentication, and encrypts traffic using AES256 in CBC mode -and HMAC-SHA256. The second is a new protocol which uses Curve25519 keys for -authentication, and encrypts traffic using Chacha20-Poly1305, and provides -forward secrecy. +tincd regenerates its encryption key pairs. It does this on the first +activity after the keys have expired. This period is adjustable in the +configuration file, and the default time is 3600 seconds (one hour). -Tinc fully supports IPv6. +This version supports multiple subnets at once. They are also sorted +on subnet mask size. This means that it is possible to have +overlapping subnets on the VPN, as long as their subnet mask sizes +differ. -Tinc can operate in several routing modes. In the default mode, "router", every -node is associated with one or more IPv4 and/or IPv6 Subnets. The other two -modes, "switch" and "hub", let the tinc daemons work together to form a virtual -Ethernet network switch or hub. +Since pre5, tinc can operate in several routing modes. The default mode, +"router", works exactly like the older version, and uses Subnet lines to +determine the destination of packets. The other two modes, "switch" and "hub", +allow the tinc daemons to work together like a single network switch or hub. +This is useful for bridging networks. The latter modes only work properly on +Linux, FreeBSD and Windows. + +The algorithms used for encryption and generating message authentication codes +can now be changed in the configuration files. All cipher and digest algorithms +supported by OpenSSL can be used. Useful ciphers are "blowfish" (default), +"bf-ofb", "des", "des3", et cetera. Useful digests are "sha1" (default), "md5", +et cetera. + +Support for routing IPv6 packets has been added. Just add Subnet lines with +IPv6 addresses (without using :: abbreviations) and use ifconfig or ip (from +the iproute package) to give the virtual network interface corresponding IPv6 +addresses. tinc does not provide autoconfiguration for IPv6 hosts. Consider +using radvd or zebra if you need it. + +It is also possible to make tunnels to other tinc daemons over IPv6 networks, +if the operating system supports IPv6. tinc will automatically use both IPv6 +and IPv4 when available, but this can be changed by adding the option +"AddressFamily = ipv4" or "AddressFamily = ipv6" to the tinc.conf file. Normally, when started tinc will detach and run in the background. In a native Windows environment this means tinc will install itself as a service, which will -restart after reboots. To prevent tinc from detaching or running as a service, +restart after reboots. To prevent tinc from detaching or running as a service, use the -D option. -The status of the VPN can be queried using the "tinc" command, which connects -to a running tinc daemon via a control connection. The same tool also makes it -easy to start and stop tinc, and to change its configuration. diff --git a/README.android b/README.android index 7d8e853..7925bdb 100644 --- a/README.android +++ b/README.android @@ -1,23 +1,25 @@ -Quick how-to cross compile tinc for Android (done from $HOME/android/): +Quick how-to cross compile tinc for android (done from $HOME/android/): -- Download Android NDK and setup local ARM toolchain: +- Download android NDK and setup local ARM toolchain: +wget http://dl.google.com/android/ndk/android-ndk-r9d-linux-x86.tar.bz2 +tar xfj android-ndk-r9d-linux-x86.tar.bz2 +./android-ndk-r9d/build/tools/make-standalone-toolchain.sh --platform=android-5 --install-dir=/tmp/my-android-toolchain - wget http://dl.google.com/android/ndk/android-ndk-r8b-linux-x86.tar.bz2 - tar xfj android-ndk-r8b-linux-x86.tar.bz2 - ./android-ndk-r8b/build/tools/make-standalone-toolchain.sh --platform=android-5 --install-dir=/tmp/my-android-toolchain - -- Download and cross-compile OpenSSL for ARM: - - wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz - tar xfz openssl-1.0.1c.tar.gz - cd openssl-1.0.1c - ./Configure dist - make CC=/tmp/my-android-toolchain/bin/arm-linux-androideabi-gcc AR="/tmp/my-android-toolchain/bin/arm-linux-androideabi-ar r" RANLIB=/tmp/my-android-toolchain/bin/arm-linux-androideabi-ranlib +- Download and cross-compile openSSL for ARM: +wget http://www.openssl.org/source/openssl-1.0.1h.tar.gz +tar xfz openssl-1.0.1h.tar.gz +cd openssl-1.0.1h +./Configure dist +make CC=/tmp/my-android-toolchain/bin/arm-linux-androideabi-gcc AR="/tmp/my-android-toolchain/bin/arm-linux-androideabi-ar r" RANLIB=/tmp/my-android-toolchain/bin/arm-linux-androideabi-ranlib +cd - - Clone and cross-compile tinc: +git clone git://tinc-vpn.org/tinc +cd tinc +autoreconf -fsi +CC=/tmp/my-android-toolchain/bin/arm-linux-androideabi-gcc ./configure --host=arm-linux --disable-lzo --with-openssl-lib=$HOME/android/openssl-1.0.1g --with-openssl-include=$HOME/android/openssl-1.0.1g/include/ --disable-hardening +make -j5 + +- Strip tincd binary to make it smaller +/tmp/my-android-toolchain/bin/arm-linux-androideabi-strip src/tincd - git clone git://tinc-vpn.org/tinc - cd tinc - autoreconf -fsi - CC=/tmp/my-android-toolchain/bin/arm-linux-androideabi-gcc ./configure --host=arm-linux --disable-lzo --with-openssl-lib=$HOME/android/openssl-1.0.1c --with-openssl-include=$HOME/android/openssl-1.0.1c/include/ - make -j5 diff --git a/THANKS b/THANKS index e814641..a0f7966 100644 --- a/THANKS +++ b/THANKS @@ -22,6 +22,7 @@ We would like to thank the following people for their contributions to tinc: * Delf Eldkraft * Dennis Joachimsthaler * dnk +* Егор Палкин * Élie Bouttier * Enrique Zanardi * Erik Tews @@ -37,11 +38,12 @@ We would like to thank the following people for their contributions to tinc: * Gusariev Oleksandr * Hans Bayle * Harvest -* Ivo Smits * Ivo van Dong +* Ivo Smits * James Cook * James MacLean * Jamie Briggs +* Jan Štembera * Jason Harper * Jason Livesay * Jasper Krijgsman @@ -49,8 +51,8 @@ We would like to thank the following people for their contributions to tinc: * Jeroen Domburg * Jeroen Ubbink * Jerome Etienne -* Jochen Voss * Jo-Philipp Wich +* Jochen Voss * Julien Muchembled * Lavrans Laading * Loïc Dachary @@ -71,21 +73,24 @@ We would like to thank the following people for their contributions to tinc: * Max Rijevski * Menno Smits * Mesar Hameed +* Michael Taylor * Michael Tokarev * Michael Yonli * Miles Nordin -* Murat Donmez * Nathan Stratton Treadway +* Murat Donmez * Nick Hibma * Nick Patavalis * Paul Littlefield * Philipp Babel * Pierre Emeriaud * Pierre-Olivier Mercier +* Rafael Wolf * Rafael Sadowski * Rafał Leśniak * Rhosyn Celyn * Robert van der Meulen +* Robert Waniek * Rumko * Ryan Miller * Sam Bryan @@ -104,6 +109,7 @@ We would like to thank the following people for their contributions to tinc: * Tonnerre Lombard * Ulrich Seifert * Vil Brekin +* Vincent Laurent * Vittorio Gambaletta * Wendy Willard * Wessel Dankers diff --git a/aclocal.m4 b/aclocal.m4 index 4ba9316..06685b5 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1138,12 +1138,7 @@ m4_include([m4/ax_append_flag.m4]) m4_include([m4/ax_cflags_warn_all.m4]) m4_include([m4/ax_check_compile_flag.m4]) m4_include([m4/ax_check_link_flag.m4]) -m4_include([m4/ax_code_coverage.m4]) m4_include([m4/ax_require_defined.m4]) -m4_include([m4/curses.m4]) -m4_include([m4/libgcrypt.m4]) m4_include([m4/lzo.m4]) -m4_include([m4/miniupnpc.m4]) m4_include([m4/openssl.m4]) -m4_include([m4/readline.m4]) m4_include([m4/zlib.m4]) diff --git a/config.h.in b/config.h.in index 9c494c8..cc68348 100644 --- a/config.h.in +++ b/config.h.in @@ -1,8 +1,5 @@ /* config.h.in. Generated from configure.ac by autoheader. */ -/* Disable support for the legacy (tinc 1.0) protocol */ -#undef DISABLE_LEGACY - /* Support for jumbograms (packets up to 9000 bytes) */ #undef ENABLE_JUMBOGRAMS @@ -18,6 +15,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_INET_H +/* Define to 1 if you have the header file. */ +#undef HAVE_ARPA_NAMESER_H + /* Define to 1 if you have the `asprintf' function. */ #undef HAVE_ASPRINTF @@ -27,12 +27,6 @@ /* Unknown BSD variant */ #undef HAVE_BSD -/* have curses support */ -#undef HAVE_CURSES - -/* Define to 1 if you have the header file. */ -#undef HAVE_CURSES_H - /* Cygwin */ #undef HAVE_CYGWIN @@ -46,6 +40,22 @@ you don't. */ #undef HAVE_DECL_EVP_AES_256_CFB +/* Define to 1 if you have the declaration of `freeaddrinfo', and to 0 if you + don't. */ +#undef HAVE_DECL_FREEADDRINFO + +/* Define to 1 if you have the declaration of `gai_strerror', and to 0 if you + don't. */ +#undef HAVE_DECL_GAI_STRERROR + +/* Define to 1 if you have the declaration of `getaddrinfo', and to 0 if you + don't. */ +#undef HAVE_DECL_GETADDRINFO + +/* Define to 1 if you have the declaration of `getnameinfo', and to 0 if you + don't. */ +#undef HAVE_DECL_GETNAMEINFO + /* Define to 1 if you have the declaration of `OpenSSL_add_all_algorithms', and to 0 if you don't. */ #undef HAVE_DECL_OPENSSL_ADD_ALL_ALGORITHMS @@ -63,9 +73,6 @@ /* DragonFly */ #undef HAVE_DRAGONFLY -/* Define to 1 if you have the `ERR_remove_state' function. */ -#undef HAVE_ERR_REMOVE_STATE - /* Define to 1 if you have the `EVP_CIPHER_CTX_new' function. */ #undef HAVE_EVP_CIPHER_CTX_NEW @@ -87,9 +94,6 @@ /* FreeBSD */ #undef HAVE_FREEBSD -/* Define to 1 if you have the header file. */ -#undef HAVE_GCRYPT_H - /* Define to 1 if you have the header file. */ #undef HAVE_GETOPT_H @@ -99,12 +103,12 @@ /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY -/* Define to 1 if you have the `HMAC_CTX_new' function. */ -#undef HAVE_HMAC_CTX_NEW - /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H +/* Define to 1 if you have the `nsl' library (-lnsl). */ +#undef HAVE_LIBNSL + /* Define to 1 if you have the `resolv' library (-lresolv). */ #undef HAVE_LIBRESOLV @@ -138,18 +142,9 @@ /* MinGW */ #undef HAVE_MINGW -/* have miniupnpc support */ -#undef HAVE_MINIUPNPC - -/* Define to 1 if you have the header file. */ -#undef HAVE_MINIUPNPC_MINIUPNPC_H - /* Define to 1 if you have the `mlockall' function. */ #undef HAVE_MLOCKALL -/* Define to 1 if you have the `nanosleep' function. */ -#undef HAVE_NANOSLEEP - /* NetBSD */ #undef HAVE_NETBSD @@ -237,30 +232,24 @@ /* Define to 1 if you have the header file. */ #undef HAVE_OPENSSL_SHA_H +/* Define to 1 if you have the `pselect' function. */ +#undef HAVE_PSELECT + /* Define to 1 if you have the `putenv' function. */ #undef HAVE_PUTENV /* Define to 1 if you have the `RAND_bytes' function. */ #undef HAVE_RAND_BYTES -/* have readline support */ -#undef HAVE_READLINE - -/* Define to 1 if you have the header file. */ -#undef HAVE_READLINE_HISTORY_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_READLINE_READLINE_H - -/* Define to 1 if you have the `recvmmsg' function. */ -#undef HAVE_RECVMMSG - /* Define to 1 if you have the header file. */ #undef HAVE_RESOLV_H /* Define to 1 if you have the `RSA_set0_key' function. */ #undef HAVE_RSA_SET0_KEY +/* Define to 1 if the system has the type `socklen_t'. */ +#undef HAVE_SOCKLEN_T + /* Solaris/SunOS */ #undef HAVE_SOLARIS @@ -279,6 +268,9 @@ /* Define to 1 if you have the `strsignal' function. */ #undef HAVE_STRSIGNAL +/* Define to 1 if the system has the type `struct addrinfo'. */ +#undef HAVE_STRUCT_ADDRINFO + /* Define to 1 if the system has the type `struct arphdr'. */ #undef HAVE_STRUCT_ARPHDR @@ -294,6 +286,12 @@ /* Define to 1 if the system has the type `struct icmp6_hdr'. */ #undef HAVE_STRUCT_ICMP6_HDR +/* Define to 1 if the system has the type `struct in6_addr'. */ +#undef HAVE_STRUCT_IN6_ADDR + +/* Define to 1 if the system has the type `struct in_addr'. */ +#undef HAVE_STRUCT_IN_ADDR + /* Define to 1 if the system has the type `struct ip'. */ #undef HAVE_STRUCT_IP @@ -306,9 +304,15 @@ /* Define to 1 if the system has the type `struct nd_opt_hdr'. */ #undef HAVE_STRUCT_ND_OPT_HDR +/* Define to 1 if the system has the type `struct sockaddr_in6'. */ +#undef HAVE_STRUCT_SOCKADDR_IN6 + /* Define to 1 if you have the header file. */ #undef HAVE_SYSLOG_H +/* Define to 1 if you have the `system' function. */ +#undef HAVE_SYSTEM + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_FILE_H @@ -336,8 +340,8 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_UN_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_UIO_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_WAIT_H @@ -348,6 +352,9 @@ /* Define to 1 if you have the `unsetenv' function. */ #undef HAVE_UNSETENV +/* Define to 1 if you have the `usleep' function. */ +#undef HAVE_USLEEP + /* Define to 1 if you have the `vsyslog' function. */ #undef HAVE_VSYSLOG @@ -412,6 +419,9 @@ /* Version number of package */ #undef VERSION +/* Compile with support for Windows 2000 */ +#undef WITH_WINDOWS2000 + /* Define to 1 if on MINIX. */ #undef _MINIX @@ -428,8 +438,5 @@ /* Defined if the __malloc__ attribute is not supported. */ #undef __malloc__ -/* Defined if the __nonnull__ attribute is not supported. */ -#undef __nonnull__ - -/* Defined if the __warn_unused_result__ attribute is not supported. */ -#undef __warn_unused_result__ +/* Define to `int' if does not define. */ +#undef pid_t diff --git a/configure b/configure index ebad571..7828190 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for tinc 1.1pre17. +# Generated by GNU Autoconf 2.69 for tinc 1.0.36. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -577,8 +577,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='tinc' PACKAGE_TARNAME='tinc' -PACKAGE_VERSION='1.1pre17' -PACKAGE_STRING='tinc 1.1pre17' +PACKAGE_VERSION='1.0.36' +PACKAGE_STRING='tinc 1.0.36' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -623,15 +623,6 @@ ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS -MINIUPNPC_FALSE -MINIUPNPC_TRUE -MINIUPNPC_LIBS -GCRYPT_FALSE -GCRYPT_TRUE -OPENSSL_FALSE -OPENSSL_TRUE -READLINE_LIBS -CURSES_LIBS GETOPT_FALSE GETOPT_TRUE WITH_SYSTEMD_FALSE @@ -661,19 +652,6 @@ build_os build_vendor build_cpu build -CODE_COVERAGE_RULES -CODE_COVERAGE_LDFLAGS -CODE_COVERAGE_LIBS -CODE_COVERAGE_CXXFLAGS -CODE_COVERAGE_CFLAGS -CODE_COVERAGE_CPPFLAGS -GENHTML -LCOV -GCOV -CODE_COVERAGE_ENABLED -CODE_COVERAGE_ENABLED_FALSE -CODE_COVERAGE_ENABLED_TRUE -SED EGREP GREP CPP @@ -765,22 +743,12 @@ ac_user_opts=' enable_option_checking enable_silent_rules enable_dependency_tracking -with_gcov -enable_code_coverage enable_uml enable_vde enable_tunemu +with_windows2000 with_systemd enable_hardening -enable_legacy_protocol -enable_curses -with_curses -with_curses_include -with_curses_lib -enable_readline -with_readline -with_readline_include -with_readline_lib enable_zlib with_zlib with_zlib_include @@ -789,16 +757,9 @@ enable_lzo with_lzo with_lzo_include with_lzo_lib -with_libgcrypt -with_libgcrypt_include -with_libgcrypt_lib with_openssl with_openssl_include with_openssl_lib -enable_miniupnpc -with_miniupnpc -with_miniupnpc_include -with_miniupnpc_lib enable_jumbograms ' ac_precious_vars='build_alias @@ -1360,7 +1321,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures tinc 1.1pre17 to adapt to many kinds of systems. +\`configure' configures tinc 1.0.36 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1431,7 +1392,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of tinc 1.1pre17:";; + short | recursive ) echo "Configuration of tinc 1.0.36:";; esac cat <<\_ACEOF @@ -1445,56 +1406,32 @@ Optional Features: do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build - --enable-code-coverage Whether to enable code coverage support --enable-uml enable support for User Mode Linux --enable-vde enable support for Virtual Distributed Ethernet --enable-tunemu enable support for the tunemu driver --disable-hardening disable compiler and linker hardening flags - --disable-legacy-protocol - disable support for the legacy (tinc 1.0) protocol - --disable-curses disable curses support - --disable-readline disable readline support --disable-zlib disable zlib compression support --disable-lzo disable lzo compression support - --enable-miniupnpc enable miniupnpc support --enable-jumbograms enable support for jumbograms (packets up to 9000 bytes) Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-gcov=GCOV use given GCOV for coverage (GCOV=gcov). + --with-windows2000 compile with support for Windows 2000. This disables + support for tunneling over existing IPv6 networks. --with-systemd[=DIR] install systemd service files [to DIR if specified] - --with-curses=DIR curses base directory, or: - --with-curses-include=DIR - curses headers directory - --with-curses-lib=DIR curses library directory - --with-readline=DIR readline base directory, or: - --with-readline-include=DIR - readline headers directory - --with-readline-lib=DIR readline library directory --with-zlib=DIR zlib base directory, or: --with-zlib-include=DIR zlib headers directory --with-zlib-lib=DIR zlib library directory --with-lzo=DIR lzo base directory, or: --with-lzo-include=DIR lzo headers directory --with-lzo-lib=DIR lzo library directory - --with-libgcrypt=DIR libgcrypt base directory, or: - --with-libgcrypt-include=DIR - libgcrypt headers directory (without trailing - /libgcrypt) - --with-libgcrypt-lib=DIR - libgcrypt library directory --with-openssl=DIR LibreSSL/OpenSSL base directory, or: --with-openssl-include=DIR LibreSSL/OpenSSL headers directory (without trailing /openssl) --with-openssl-lib=DIR LibreSSL/OpenSSL library directory - --with-miniupnpc=DIR miniupnpc base directory, or: - --with-miniupnpc-include=DIR - miniupnpc headers directory - --with-miniupnpc-lib=DIR - miniupnpc library directory Some influential environment variables: CC C compiler command @@ -1572,7 +1509,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -tinc configure 1.1pre17 +tinc configure 1.0.36 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2037,7 +1974,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by tinc $as_me 1.1pre17, which was +It was created by tinc $as_me 1.0.36, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2901,7 +2838,7 @@ fi # Define the identity of the package. PACKAGE='tinc' - VERSION='1.1pre17' + VERSION='1.0.36' cat >>confdefs.h <<_ACEOF @@ -4860,448 +4797,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 -$as_echo_n "checking for a sed that does not truncate output... " >&6; } -if ${ac_cv_path_SED+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ - for ac_i in 1 2 3 4 5 6 7; do - ac_script="$ac_script$as_nl$ac_script" - done - echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed - { ac_script=; unset ac_script;} - if test -z "$SED"; then - ac_path_SED_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_SED" || continue -# Check for GNU ac_path_SED and select it if it is found. - # Check for GNU $ac_path_SED -case `"$ac_path_SED" --version 2>&1` in -*GNU*) - ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo '' >> "conftest.nl" - "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_SED_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_SED="$ac_path_SED" - ac_path_SED_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_SED_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_SED"; then - as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 - fi -else - ac_cv_path_SED=$SED -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 -$as_echo "$ac_cv_path_SED" >&6; } - SED="$ac_cv_path_SED" - rm -f conftest.sed - - - - - # allow to override gcov location - -# Check whether --with-gcov was given. -if test "${with_gcov+set}" = set; then : - withval=$with_gcov; _AX_CODE_COVERAGE_GCOV_PROG_WITH=$with_gcov -else - _AX_CODE_COVERAGE_GCOV_PROG_WITH=gcov -fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build with code coverage support" >&5 -$as_echo_n "checking whether to build with code coverage support... " >&6; } - # Check whether --enable-code-coverage was given. -if test "${enable_code_coverage+set}" = set; then : - enableval=$enable_code_coverage; -else - enable_code_coverage=no -fi - - - if test x$enable_code_coverage = xyes; then - CODE_COVERAGE_ENABLED_TRUE= - CODE_COVERAGE_ENABLED_FALSE='#' -else - CODE_COVERAGE_ENABLED_TRUE='#' - CODE_COVERAGE_ENABLED_FALSE= -fi - - CODE_COVERAGE_ENABLED=$enable_code_coverage - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_code_coverage" >&5 -$as_echo "$enable_code_coverage" >&6; } - - if test "$enable_code_coverage" = "yes" ; then : - - # check for gcov - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}$_AX_CODE_COVERAGE_GCOV_PROG_WITH", so it can be a program name with args. -set dummy ${ac_tool_prefix}$_AX_CODE_COVERAGE_GCOV_PROG_WITH; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_GCOV+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$GCOV"; then - ac_cv_prog_GCOV="$GCOV" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_GCOV="${ac_tool_prefix}$_AX_CODE_COVERAGE_GCOV_PROG_WITH" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -GCOV=$ac_cv_prog_GCOV -if test -n "$GCOV"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GCOV" >&5 -$as_echo "$GCOV" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_GCOV"; then - ac_ct_GCOV=$GCOV - # Extract the first word of "$_AX_CODE_COVERAGE_GCOV_PROG_WITH", so it can be a program name with args. -set dummy $_AX_CODE_COVERAGE_GCOV_PROG_WITH; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_GCOV+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_GCOV"; then - ac_cv_prog_ac_ct_GCOV="$ac_ct_GCOV" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_GCOV="$_AX_CODE_COVERAGE_GCOV_PROG_WITH" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_GCOV=$ac_cv_prog_ac_ct_GCOV -if test -n "$ac_ct_GCOV"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_GCOV" >&5 -$as_echo "$ac_ct_GCOV" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_GCOV" = x; then - GCOV=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - GCOV=$ac_ct_GCOV - fi -else - GCOV="$ac_cv_prog_GCOV" -fi - - if test "X$GCOV" = "X:"; then : - as_fn_error $? "gcov is needed to do coverage" "$LINENO" 5 -fi - - - if test "$GCC" = "no" ; then : - - as_fn_error $? "not compiling with gcc, which is required for gcov code coverage" "$LINENO" 5 - -fi - - # Extract the first word of "lcov", so it can be a program name with args. -set dummy lcov; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_LCOV+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$LCOV"; then - ac_cv_prog_LCOV="$LCOV" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_LCOV="lcov" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -LCOV=$ac_cv_prog_LCOV -if test -n "$LCOV"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LCOV" >&5 -$as_echo "$LCOV" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - # Extract the first word of "genhtml", so it can be a program name with args. -set dummy genhtml; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_GENHTML+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$GENHTML"; then - ac_cv_prog_GENHTML="$GENHTML" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_GENHTML="genhtml" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -GENHTML=$ac_cv_prog_GENHTML -if test -n "$GENHTML"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GENHTML" >&5 -$as_echo "$GENHTML" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - - if test -z "$LCOV" ; then : - - as_fn_error $? "To enable code coverage reporting you must have lcov installed" "$LINENO" 5 - -fi - - if test -z "$GENHTML" ; then : - - as_fn_error $? "Could not find genhtml from the lcov package" "$LINENO" 5 - -fi - - CODE_COVERAGE_CPPFLAGS="-DNDEBUG" - CODE_COVERAGE_CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage" - CODE_COVERAGE_CXXFLAGS="-O0 -g -fprofile-arcs -ftest-coverage" - CODE_COVERAGE_LIBS="-lgcov" - CODE_COVERAGE_LDFLAGS="$CODE_COVERAGE_LIBS" - - - - - - - - CODE_COVERAGE_RULES_CHECK=' - -$(A''M_V_at)$(MAKE) $(AM_MAKEFLAGS) -k check - $(A''M_V_at)$(MAKE) $(AM_MAKEFLAGS) code-coverage-capture -' - CODE_COVERAGE_RULES_CAPTURE=' - $(code_coverage_v_lcov_cap)$(LCOV) $(code_coverage_quiet) $(addprefix --directory ,$(CODE_COVERAGE_DIRECTORY)) --capture --output-file "$(CODE_COVERAGE_OUTPUT_FILE).tmp" --test-name "$(call code_coverage_sanitize,$(PACKAGE_NAME)-$(PACKAGE_VERSION))" --no-checksum --compat-libtool $(CODE_COVERAGE_LCOV_SHOPTS) $(CODE_COVERAGE_LCOV_OPTIONS) - $(code_coverage_v_lcov_ign)$(LCOV) $(code_coverage_quiet) $(addprefix --directory ,$(CODE_COVERAGE_DIRECTORY)) --remove "$(CODE_COVERAGE_OUTPUT_FILE).tmp" "/tmp/*" $(CODE_COVERAGE_IGNORE_PATTERN) --output-file "$(CODE_COVERAGE_OUTPUT_FILE)" $(CODE_COVERAGE_LCOV_SHOPTS) $(CODE_COVERAGE_LCOV_RMOPTS) - -@rm -f $(CODE_COVERAGE_OUTPUT_FILE).tmp - $(code_coverage_v_genhtml)LANG=C $(GENHTML) $(code_coverage_quiet) $(addprefix --prefix ,$(CODE_COVERAGE_DIRECTORY)) --output-directory "$(CODE_COVERAGE_OUTPUT_DIRECTORY)" --title "$(PACKAGE_NAME)-$(PACKAGE_VERSION) Code Coverage" --legend --show-details "$(CODE_COVERAGE_OUTPUT_FILE)" $(CODE_COVERAGE_GENHTML_OPTIONS) - @echo "file://$(abs_builddir)/$(CODE_COVERAGE_OUTPUT_DIRECTORY)/index.html" -' - CODE_COVERAGE_RULES_CLEAN=' -clean: code-coverage-clean -distclean: code-coverage-clean -code-coverage-clean: - -$(LCOV) --directory $(top_builddir) -z - -rm -rf $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_FILE).tmp $(CODE_COVERAGE_OUTPUT_DIRECTORY) - -find . \( -name "*.gcda" -o -name "*.gcno" -o -name "*.gcov" \) -delete -' - -else - - CODE_COVERAGE_RULES_CHECK=' - @echo "Need to reconfigure with --enable-code-coverage" -' - CODE_COVERAGE_RULES_CAPTURE="$CODE_COVERAGE_RULES_CHECK" - CODE_COVERAGE_RULES_CLEAN='' - -fi - -CODE_COVERAGE_RULES=' -# Code coverage -# -# Optional: -# - CODE_COVERAGE_DIRECTORY: Top-level directory for code coverage reporting. -# Multiple directories may be specified, separated by whitespace. -# (Default: $(top_builddir)) -# - CODE_COVERAGE_OUTPUT_FILE: Filename and path for the .info file generated -# by lcov for code coverage. (Default: -# $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage.info) -# - CODE_COVERAGE_OUTPUT_DIRECTORY: Directory for generated code coverage -# reports to be created. (Default: -# $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage) -# - CODE_COVERAGE_BRANCH_COVERAGE: Set to 1 to enforce branch coverage, -# set to 0 to disable it and leave empty to stay with the default. -# (Default: empty) -# - CODE_COVERAGE_LCOV_SHOPTS_DEFAULT: Extra options shared between both lcov -# instances. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE) -# - CODE_COVERAGE_LCOV_SHOPTS: Extra options to shared between both lcov -# instances. (Default: $CODE_COVERAGE_LCOV_SHOPTS_DEFAULT) -# - CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH: --gcov-tool pathtogcov -# - CODE_COVERAGE_LCOV_OPTIONS_DEFAULT: Extra options to pass to the -# collecting lcov instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH) -# - CODE_COVERAGE_LCOV_OPTIONS: Extra options to pass to the collecting lcov -# instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_DEFAULT) -# - CODE_COVERAGE_LCOV_RMOPTS_DEFAULT: Extra options to pass to the filtering -# lcov instance. (Default: empty) -# - CODE_COVERAGE_LCOV_RMOPTS: Extra options to pass to the filtering lcov -# instance. (Default: $CODE_COVERAGE_LCOV_RMOPTS_DEFAULT) -# - CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT: Extra options to pass to the -# genhtml instance. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE) -# - CODE_COVERAGE_GENHTML_OPTIONS: Extra options to pass to the genhtml -# instance. (Default: $CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT) -# - CODE_COVERAGE_IGNORE_PATTERN: Extra glob pattern of files to ignore -# -# The generated report will be titled using the $(PACKAGE_NAME) and -# $(PACKAGE_VERSION). In order to add the current git hash to the title, -# use the git-version-gen script, available online. - -# Optional variables -CODE_COVERAGE_DIRECTORY ?= $(top_builddir) -CODE_COVERAGE_OUTPUT_FILE ?= $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage.info -CODE_COVERAGE_OUTPUT_DIRECTORY ?= $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage -CODE_COVERAGE_BRANCH_COVERAGE ?= -CODE_COVERAGE_LCOV_SHOPTS_DEFAULT ?= $(if $(CODE_COVERAGE_BRANCH_COVERAGE),\ ---rc lcov_branch_coverage=$(CODE_COVERAGE_BRANCH_COVERAGE)) -CODE_COVERAGE_LCOV_SHOPTS ?= $(CODE_COVERAGE_LCOV_SHOPTS_DEFAULT) -CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH ?= --gcov-tool "$(GCOV)" -CODE_COVERAGE_LCOV_OPTIONS_DEFAULT ?= $(CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH) -CODE_COVERAGE_LCOV_OPTIONS ?= $(CODE_COVERAGE_LCOV_OPTIONS_DEFAULT) -CODE_COVERAGE_LCOV_RMOPTS_DEFAULT ?= -CODE_COVERAGE_LCOV_RMOPTS ?= $(CODE_COVERAGE_LCOV_RMOPTS_DEFAULT) -CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT ?=\ -$(if $(CODE_COVERAGE_BRANCH_COVERAGE),\ ---rc genhtml_branch_coverage=$(CODE_COVERAGE_BRANCH_COVERAGE)) -CODE_COVERAGE_GENHTML_OPTIONS ?= $(CODE_COVERAGE_GENHTML_OPTIONS_DEFAULTS) -CODE_COVERAGE_IGNORE_PATTERN ?= - -code_coverage_v_lcov_cap = $(code_coverage_v_lcov_cap_$(V)) -code_coverage_v_lcov_cap_ = $(code_coverage_v_lcov_cap_$(AM_DEFAULT_VERBOSITY)) -code_coverage_v_lcov_cap_0 = @echo " LCOV --capture"\ - $(CODE_COVERAGE_OUTPUT_FILE); -code_coverage_v_lcov_ign = $(code_coverage_v_lcov_ign_$(V)) -code_coverage_v_lcov_ign_ = $(code_coverage_v_lcov_ign_$(AM_DEFAULT_VERBOSITY)) -code_coverage_v_lcov_ign_0 = @echo " LCOV --remove /tmp/*"\ - $(CODE_COVERAGE_IGNORE_PATTERN); -code_coverage_v_genhtml = $(code_coverage_v_genhtml_$(V)) -code_coverage_v_genhtml_ = $(code_coverage_v_genhtml_$(AM_DEFAULT_VERBOSITY)) -code_coverage_v_genhtml_0 = @echo " GEN " $(CODE_COVERAGE_OUTPUT_DIRECTORY); -code_coverage_quiet = $(code_coverage_quiet_$(V)) -code_coverage_quiet_ = $(code_coverage_quiet_$(AM_DEFAULT_VERBOSITY)) -code_coverage_quiet_0 = --quiet - -# sanitizes the test-name: replaces with underscores: dashes and dots -code_coverage_sanitize = $(subst -,_,$(subst .,_,$(1))) - -# Use recursive makes in order to ignore errors during check -check-code-coverage:'"$CODE_COVERAGE_RULES_CHECK"' - -# Capture code coverage data -code-coverage-capture: code-coverage-capture-hook'"$CODE_COVERAGE_RULES_CAPTURE"' - -# Hook rule executed before code-coverage-capture, overridable by the user -code-coverage-capture-hook: - -'"$CODE_COVERAGE_RULES_CLEAN"' - -GITIGNOREFILES ?= -GITIGNOREFILES += $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_DIRECTORY) - -A''M_DISTCHECK_CONFIGURE_FLAGS ?= -A''M_DISTCHECK_CONFIGURE_FLAGS += --disable-code-coverage - -.PHONY: check-code-coverage code-coverage-capture code-coverage-capture-hook code-coverage-clean -' - - - - -if test "x$enable_code_coverage" = "xyes" -a "x$origcflags" = "x"; then : - CFLAGS="" -fi # Make sure we can run config.sub. @@ -5438,9 +4933,7 @@ $as_echo "#define HAVE_CYGWIN 1" >>confdefs.h $as_echo "#define HAVE_MINGW 1" >>confdefs.h - LIBS="$LIBS -lws2_32 -lgdi32 -lcrypt32 -liphlpapi" - LDFLAGS="$LDFLAGS -static" - CPPFLAGS="$CPPFLAGS -DMINIUPNP_STATICLIB" + LIBS="$LIBS -lws2_32 -lgdi32 -lcrypt32" ;; *) as_fn_error $? "\"Unknown operating system.\"" "$LINENO" 5 @@ -5516,6 +5009,19 @@ fi +# Check whether --with-windows2000 was given. +if test "${with_windows2000+set}" = set; then : + withval=$with_windows2000; if test "x$with_windows2000" = "xyes"; then : + +$as_echo "#define WITH_WINDOWS2000 1" >>confdefs.h + +fi + + +fi + + + # Check whether --with-systemd was given. if test "${with_systemd+set}" = set; then : withval=$with_systemd; systemd=true; systemd_path="$with_systemd" @@ -5695,10 +5201,10 @@ $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi rm -f confcache -if test -d /sw/include; then : +if test -d /sw/include ; then CPPFLAGS="$CPPFLAGS -I/sw/include" fi -if test -d /sw/lib; then : +if test -d /sw/lib ; then LIBS="$LIBS -L/sw/lib" fi @@ -5744,36 +5250,26 @@ $as_echo "$ac_cv_cflags_warn_all" >&6; } case ".$ac_cv_cflags_warn_all" in .ok|.ok,*) ;; .|.no|.no,*) ;; - *) -if ${CFLAGS+:} false; then : - - case " $CFLAGS " in #( - *" $ac_cv_cflags_warn_all "*) : - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$ac_cv_cflags_warn_all"; } >&5 + *) if ${CFLAGS+:} false; then : + case " $CFLAGS " in + *" $ac_cv_cflags_warn_all "*) + { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$ac_cv_cflags_warn_all"; } >&5 (: CFLAGS already contains $ac_cv_cflags_warn_all) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } ;; #( - *) : - - as_fn_append CFLAGS " $ac_cv_cflags_warn_all" - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS\""; } >&5 - (: CFLAGS="$CFLAGS") 2>&5 + test $ac_status = 0; } + ;; + *) + { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$ac_cv_cflags_warn_all\""; } >&5 + (: CFLAGS="$CFLAGS $ac_cv_cflags_warn_all") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } - ;; -esac - + CFLAGS="$CFLAGS $ac_cv_cflags_warn_all" + ;; + esac else - - CFLAGS=$ac_cv_cflags_warn_all - { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS\""; } >&5 - (: CFLAGS="$CFLAGS") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - + CFLAGS="$ac_cv_cflags_warn_all" fi ;; esac @@ -6122,7 +5618,8 @@ fi fi; -for ac_header in syslog.h sys/file.h sys/ioctl.h sys/mman.h sys/param.h sys/resource.h sys/socket.h sys/time.h sys/un.h sys/wait.h netdb.h arpa/inet.h dirent.h getopt.h + +for ac_header in syslog.h sys/file.h sys/ioctl.h sys/mman.h sys/param.h sys/resource.h sys/socket.h sys/time.h sys/uio.h sys/wait.h netdb.h arpa/inet.h arpa/nameser.h dirent.h getopt.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -6135,7 +5632,7 @@ fi done -for ac_header in net/if.h net/if_types.h net/ethernet.h net/if_arp.h netinet/in_systm.h netinet/in.h netinet/in6.h netpacket/packet.h +for ac_header in net/if.h net/if_types.h linux/if_tun.h net/if_tun.h net/if_utun.h net/tun/if_tun.h net/if_tap.h net/tap/if_tap.h net/ethernet.h net/if_arp.h netinet/in_systm.h netinet/in.h netinet/in6.h netpacket/packet.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#include \"$srcdir/src/have.h\" @@ -6181,6 +5678,18 @@ fi done +ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" +if test "x$ac_cv_type_pid_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define pid_t int +_ACEOF + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working __malloc__ attribute" >&5 $as_echo_n "checking for working __malloc__ attribute... " >&6; } @@ -6216,74 +5725,17 @@ $as_echo "#define __malloc__ /**/" >>confdefs.h fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working __nonnull__ attribute" >&5 -$as_echo_n "checking for working __nonnull__ attribute... " >&6; } -if ${tinc_cv_attribute___nonnull__+:} false; then : - $as_echo_n "(cached) " >&6 -else +ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "#include \"$srcdir/src/have.h\" - tempcflags="$CFLAGS" - CFLAGS="$CFLAGS -Wall -Werror" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -void *test(void) __attribute__ ((__nonnull__)); - void *test(void) { return (void *)0; } +" +if test "x$ac_cv_type_socklen_t" = xyes; then : +cat >>confdefs.h <<_ACEOF +#define HAVE_SOCKLEN_T 1 _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - tinc_cv_attribute___nonnull__=yes -else - tinc_cv_attribute___nonnull__=no + fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS="$tempcflags" - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tinc_cv_attribute___nonnull__" >&5 -$as_echo "$tinc_cv_attribute___nonnull__" >&6; } - - if test ${tinc_cv_attribute___nonnull__} = no; then - -$as_echo "#define __nonnull__ /**/" >>confdefs.h - - fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working __warn_unused_result__ attribute" >&5 -$as_echo_n "checking for working __warn_unused_result__ attribute... " >&6; } -if ${tinc_cv_attribute___warn_unused_result__+:} false; then : - $as_echo_n "(cached) " >&6 -else - - tempcflags="$CFLAGS" - CFLAGS="$CFLAGS -Wall -Werror" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -void *test(void) __attribute__ ((__warn_unused_result__)); - void *test(void) { return (void *)0; } - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - tinc_cv_attribute___warn_unused_result__=yes -else - tinc_cv_attribute___warn_unused_result__=no - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS="$tempcflags" - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tinc_cv_attribute___warn_unused_result__" >&5 -$as_echo "$tinc_cv_attribute___warn_unused_result__" >&6; } - - if test ${tinc_cv_attribute___warn_unused_result__} = no; then - -$as_echo "#define __warn_unused_result__ /**/" >>confdefs.h - - fi - - ac_fn_c_check_type "$LINENO" "struct ether_header" "ac_cv_type_struct_ether_header" "#include \"$srcdir/src/have.h\" " @@ -6316,6 +5768,28 @@ cat >>confdefs.h <<_ACEOF _ACEOF +fi +ac_fn_c_check_type "$LINENO" "struct in_addr" "ac_cv_type_struct_in_addr" "#include \"$srcdir/src/have.h\" + +" +if test "x$ac_cv_type_struct_in_addr" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_IN_ADDR 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "struct addrinfo" "ac_cv_type_struct_addrinfo" "#include \"$srcdir/src/have.h\" + +" +if test "x$ac_cv_type_struct_addrinfo" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_ADDRINFO 1 +_ACEOF + + fi ac_fn_c_check_type "$LINENO" "struct ip" "ac_cv_type_struct_ip" "#include \"$srcdir/src/have.h\" @@ -6338,6 +5812,28 @@ cat >>confdefs.h <<_ACEOF _ACEOF +fi +ac_fn_c_check_type "$LINENO" "struct in6_addr" "ac_cv_type_struct_in6_addr" "#include \"$srcdir/src/have.h\" + +" +if test "x$ac_cv_type_struct_in6_addr" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_IN6_ADDR 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "struct sockaddr_in6" "ac_cv_type_struct_sockaddr_in6" "#include \"$srcdir/src/have.h\" + +" +if test "x$ac_cv_type_struct_sockaddr_in6" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_SOCKADDR_IN6 1 +_ACEOF + + fi ac_fn_c_check_type "$LINENO" "struct ip6_hdr" "ac_cv_type_struct_ip6_hdr" "#include \"$srcdir/src/have.h\" @@ -6418,7 +5914,7 @@ cat >>confdefs.h <<_ACEOF _ACEOF -for ac_func in asprintf daemon fchmod flock fork gettimeofday mlockall putenv recvmmsg strsignal nanosleep unsetenv vsyslog devname fdevname +for ac_func in asprintf daemon fchmod flock fork gettimeofday mlockall pselect putenv strsignal system unsetenv usleep vsyslog devname fdevname do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -6449,6 +5945,164 @@ else fi + +ac_fn_c_check_func "$LINENO" "socket" "ac_cv_func_socket" +if test "x$ac_cv_func_socket" = xyes; then : + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5 +$as_echo_n "checking for connect in -lsocket... " >&6; } +if ${ac_cv_lib_socket_connect+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsocket $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char connect (); +int +main () +{ +return connect (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_socket_connect=yes +else + ac_cv_lib_socket_connect=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5 +$as_echo "$ac_cv_lib_socket_connect" >&6; } +if test "x$ac_cv_lib_socket_connect" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSOCKET 1 +_ACEOF + + LIBS="-lsocket $LIBS" + +fi + + +fi + +ac_fn_c_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname" +if test "x$ac_cv_func_gethostbyname" = xyes; then : + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5 +$as_echo_n "checking for gethostbyname in -lnsl... " >&6; } +if ${ac_cv_lib_nsl_gethostbyname+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lnsl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char gethostbyname (); +int +main () +{ +return gethostbyname (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_nsl_gethostbyname=yes +else + ac_cv_lib_nsl_gethostbyname=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5 +$as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; } +if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBNSL 1 +_ACEOF + + LIBS="-lnsl $LIBS" + +fi + + +fi + + +ac_fn_c_check_decl "$LINENO" "freeaddrinfo" "ac_cv_have_decl_freeaddrinfo" "#include \"$srcdir/src/have.h\" + +" +if test "x$ac_cv_have_decl_freeaddrinfo" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FREEADDRINFO $ac_have_decl +_ACEOF +ac_fn_c_check_decl "$LINENO" "gai_strerror" "ac_cv_have_decl_gai_strerror" "#include \"$srcdir/src/have.h\" + +" +if test "x$ac_cv_have_decl_gai_strerror" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_GAI_STRERROR $ac_have_decl +_ACEOF +ac_fn_c_check_decl "$LINENO" "getaddrinfo" "ac_cv_have_decl_getaddrinfo" "#include \"$srcdir/src/have.h\" + +" +if test "x$ac_cv_have_decl_getaddrinfo" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_GETADDRINFO $ac_have_decl +_ACEOF +ac_fn_c_check_decl "$LINENO" "getnameinfo" "ac_cv_have_decl_getnameinfo" "#include \"$srcdir/src/have.h\" + +" +if test "x$ac_cv_have_decl_getnameinfo" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_GETNAMEINFO $ac_have_decl +_ACEOF + + ac_fn_c_check_decl "$LINENO" "res_init" "ac_cv_have_decl_res_init" " #include #include @@ -6512,99 +6166,6 @@ fi fi -case $host_os in - *linux*) - for ac_header in linux/if_tun.h -do : - ac_fn_c_check_header_compile "$LINENO" "linux/if_tun.h" "ac_cv_header_linux_if_tun_h" "#include \"$srcdir/src/have.h\" - -" -if test "x$ac_cv_header_linux_if_tun_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LINUX_IF_TUN_H 1 -_ACEOF - -else - as_fn_error $? "Required header file missng" "$LINENO" 5 -fi - -done - - ;; - *bsd*|*dragonfly*|*darwin*) - for ac_header in net/if_tun.h net/if_utun.h net/tun/if_tun.h net/if_tap.h net/tap/if_tap.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#include \"$srcdir/src/have.h\" - -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - ;; - *solaris*) - ac_fn_c_check_func "$LINENO" "socket" "ac_cv_func_socket" -if test "x$ac_cv_func_socket" = xyes; then : - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5 -$as_echo_n "checking for connect in -lsocket... " >&6; } -if ${ac_cv_lib_socket_connect+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lsocket $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char connect (); -int -main () -{ -return connect (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_socket_connect=yes -else - ac_cv_lib_socket_connect=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5 -$as_echo "$ac_cv_lib_socket_connect" >&6; } -if test "x$ac_cv_lib_socket_connect" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBSOCKET 1 -_ACEOF - - LIBS="-lsocket $LIBS" - -fi - -fi - - ;; - *) - ;; -esac - cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure @@ -6691,309 +6252,6 @@ $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi rm -f confcache -# Check whether --enable-legacy-protocol was given. -if test "${enable_legacy_protocol+set}" = set; then : - enableval=$enable_legacy_protocol; if test "x$enable_legacy_protocol" = "xno"; then : - -$as_echo "#define DISABLE_LEGACY 1" >>confdefs.h - -fi - - -fi - - - - - - # Check whether --enable-curses was given. -if test "${enable_curses+set}" = set; then : - enableval=$enable_curses; -fi - - if test "x$enable_curses" != "xno"; then : - - -$as_echo "#define HAVE_CURSES 1" >>confdefs.h - - curses=true - -# Check whether --with-curses was given. -if test "${with_curses+set}" = set; then : - withval=$with_curses; curses="$withval" - CPPFLAGS="$CPPFLAGS -I$withval/include" - LDFLAGS="$LDFLAGS -L$withval/lib" - -fi - - - -# Check whether --with-curses-include was given. -if test "${with_curses_include+set}" = set; then : - withval=$with_curses_include; curses_include="$withval" - CPPFLAGS="$CPPFLAGS -I$withval" - -fi - - - -# Check whether --with-curses-lib was given. -if test "${with_curses_lib+set}" = set; then : - withval=$with_curses_lib; curses_lib="$withval" - LDFLAGS="$LDFLAGS -L$withval" - -fi - - - for ac_header in curses.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "curses.h" "ac_cv_header_curses_h" "$ac_includes_default" -if test "x$ac_cv_header_curses_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_CURSES_H 1 -_ACEOF - -else - as_fn_error $? "\"curses header files not found.\"" "$LINENO" 5; break - -fi - -done - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for initscr in -lncurses" >&5 -$as_echo_n "checking for initscr in -lncurses... " >&6; } -if ${ac_cv_lib_ncurses_initscr+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lncurses $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char initscr (); -int -main () -{ -return initscr (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_ncurses_initscr=yes -else - ac_cv_lib_ncurses_initscr=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncurses_initscr" >&5 -$as_echo "$ac_cv_lib_ncurses_initscr" >&6; } -if test "x$ac_cv_lib_ncurses_initscr" = xyes; then : - CURSES_LIBS="-lncurses"; { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wtimeout in -ltinfo" >&5 -$as_echo_n "checking for wtimeout in -ltinfo... " >&6; } -if ${ac_cv_lib_tinfo_wtimeout+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ltinfo $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char wtimeout (); -int -main () -{ -return wtimeout (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_tinfo_wtimeout=yes -else - ac_cv_lib_tinfo_wtimeout=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_tinfo_wtimeout" >&5 -$as_echo "$ac_cv_lib_tinfo_wtimeout" >&6; } -if test "x$ac_cv_lib_tinfo_wtimeout" = xyes; then : - CURSES_LIBS+=" -ltinfo" -fi - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for initscr in -lcurses" >&5 -$as_echo_n "checking for initscr in -lcurses... " >&6; } -if ${ac_cv_lib_curses_initscr+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lcurses $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char initscr (); -int -main () -{ -return initscr (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_curses_initscr=yes -else - ac_cv_lib_curses_initscr=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_initscr" >&5 -$as_echo "$ac_cv_lib_curses_initscr" >&6; } -if test "x$ac_cv_lib_curses_initscr" = xyes; then : - CURSES_LIBS="-lcurses" -else - as_fn_error $? "\"curses libraries not found.\"" "$LINENO" 5 - -fi - - -fi - - -fi - - - - - # Check whether --enable-readline was given. -if test "${enable_readline+set}" = set; then : - enableval=$enable_readline; -fi - - if test "x$enable_readline" != "xno"; then : - - -$as_echo "#define HAVE_READLINE 1" >>confdefs.h - - readline=true - -# Check whether --with-readline was given. -if test "${with_readline+set}" = set; then : - withval=$with_readline; readline="$withval" - CPPFLAGS="$CPPFLAGS -I$withval/include" - LDFLAGS="$LDFLAGS -L$withval/lib" - -fi - - - -# Check whether --with-readline-include was given. -if test "${with_readline_include+set}" = set; then : - withval=$with_readline_include; readline_include="$withval" - CPPFLAGS="$CPPFLAGS -I$withval" - -fi - - - -# Check whether --with-readline-lib was given. -if test "${with_readline_lib+set}" = set; then : - withval=$with_readline_lib; readline_lib="$withval" - LDFLAGS="$LDFLAGS -L$withval" - -fi - - - for ac_header in readline/readline.h readline/history.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -else - as_fn_error $? "\"readline header files not found.\"" "$LINENO" 5; break - -fi - -done - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for readline in -lreadline" >&5 -$as_echo_n "checking for readline in -lreadline... " >&6; } -if ${ac_cv_lib_readline_readline+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lreadline $CURSES_LIBS - $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char readline (); -int -main () -{ -return readline (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_readline_readline=yes -else - ac_cv_lib_readline_readline=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_readline" >&5 -$as_echo "$ac_cv_lib_readline_readline" >&6; } -if test "x$ac_cv_lib_readline_readline" = xyes; then : - READLINE_LIBS="-lreadline" -else - as_fn_error $? "\"readline library not found.\"" "$LINENO" 5 -fi - - -fi - - # Check whether --enable-zlib was given. @@ -7274,99 +6532,6 @@ done fi -if test "x$enable_legacy_protocol" != "xno"; then : - if test -n "$with_libgcrypt"; then : - gcrypt=true; - -# Check whether --with-libgcrypt was given. -if test "${with_libgcrypt+set}" = set; then : - withval=$with_libgcrypt; libgcrypt="$withval" - CPPFLAGS="$CPPFLAGS -I$withval/include" - LDFLAGS="$LDFLAGS -L$withval/lib" - -fi - - - -# Check whether --with-libgcrypt-include was given. -if test "${with_libgcrypt_include+set}" = set; then : - withval=$with_libgcrypt_include; libgcrypt_include="$withval" - CPPFLAGS="$CPPFLAGS -I$withval" - -fi - - - -# Check whether --with-libgcrypt-lib was given. -if test "${with_libgcrypt_lib+set}" = set; then : - withval=$with_libgcrypt_lib; libgcrypt_lib="$withval" - LDFLAGS="$LDFLAGS -L$withval" - -fi - - - for ac_header in gcrypt.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "gcrypt.h" "ac_cv_header_gcrypt_h" "$ac_includes_default" -if test "x$ac_cv_header_gcrypt_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_GCRYPT_H 1 -_ACEOF - -else - as_fn_error $? "libgcrypt header files not found." "$LINENO" 5; break - -fi - -done - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcry_cipher_encrypt in -lgcrypt" >&5 -$as_echo_n "checking for gcry_cipher_encrypt in -lgcrypt... " >&6; } -if ${ac_cv_lib_gcrypt_gcry_cipher_encrypt+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lgcrypt $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char gcry_cipher_encrypt (); -int -main () -{ -return gcry_cipher_encrypt (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_gcrypt_gcry_cipher_encrypt=yes -else - ac_cv_lib_gcrypt_gcry_cipher_encrypt=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gcrypt_gcry_cipher_encrypt" >&5 -$as_echo "$ac_cv_lib_gcrypt_gcry_cipher_encrypt" >&6; } -if test "x$ac_cv_lib_gcrypt_gcry_cipher_encrypt" = xyes; then : - LIBS="-lgcrypt $LIBS" -else - as_fn_error $? "libgcrypt libraries not found." "$LINENO" 5 - -fi - - -else - openssl=true; case $host_os in *mingw*) ;; @@ -7564,7 +6729,7 @@ else fi - for ac_func in BN_GENCB_new ERR_remove_state RSA_set0_key + for ac_func in BN_GENCB_new RSA_set0_key do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -7576,150 +6741,6 @@ _ACEOF fi done - for ac_func in HMAC_CTX_new -do : - ac_fn_c_check_func "$LINENO" "HMAC_CTX_new" "ac_cv_func_HMAC_CTX_new" -if test "x$ac_cv_func_HMAC_CTX_new" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_HMAC_CTX_NEW 1 -_ACEOF - -fi -done - - -fi - - -fi - - if test -n "$openssl"; then - OPENSSL_TRUE= - OPENSSL_FALSE='#' -else - OPENSSL_TRUE='#' - OPENSSL_FALSE= -fi - - if test -n "$gcrypt"; then - GCRYPT_TRUE= - GCRYPT_FALSE='#' -else - GCRYPT_TRUE='#' - GCRYPT_FALSE= -fi - - - - # Check whether --enable-miniupnpc was given. -if test "${enable_miniupnpc+set}" = set; then : - enableval=$enable_miniupnpc; -fi - - if test "x$enable_miniupnpc" = "xyes"; then : - - -$as_echo "#define HAVE_MINIUPNPC 1" >>confdefs.h - - -# Check whether --with-miniupnpc was given. -if test "${with_miniupnpc+set}" = set; then : - withval=$with_miniupnpc; miniupnpc="$withval" - CPPFLAGS="$CPPFLAGS -I$withval/include" - LDFLAGS="$LDFLAGS -L$withval/lib" - -fi - - - -# Check whether --with-miniupnpc-include was given. -if test "${with_miniupnpc_include+set}" = set; then : - withval=$with_miniupnpc_include; miniupnpc_include="$withval" - CPPFLAGS="$CPPFLAGS -I$withval" - -fi - - - -# Check whether --with-miniupnpc-lib was given. -if test "${with_miniupnpc_lib+set}" = set; then : - withval=$with_miniupnpc_lib; miniupnpc_lib="$withval" - LDFLAGS="$LDFLAGS -L$withval" - -fi - - - for ac_header in miniupnpc/miniupnpc.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "miniupnpc/miniupnpc.h" "ac_cv_header_miniupnpc_miniupnpc_h" "$ac_includes_default" -if test "x$ac_cv_header_miniupnpc_miniupnpc_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_MINIUPNPC_MINIUPNPC_H 1 -_ACEOF - -else - as_fn_error $? "\"miniupnpc header files not found.\"" "$LINENO" 5; break - -fi - -done - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for upnpDiscover in -lminiupnpc" >&5 -$as_echo_n "checking for upnpDiscover in -lminiupnpc... " >&6; } -if ${ac_cv_lib_miniupnpc_upnpDiscover+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lminiupnpc $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char upnpDiscover (); -int -main () -{ -return upnpDiscover (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_miniupnpc_upnpDiscover=yes -else - ac_cv_lib_miniupnpc_upnpDiscover=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_miniupnpc_upnpDiscover" >&5 -$as_echo "$ac_cv_lib_miniupnpc_upnpDiscover" >&6; } -if test "x$ac_cv_lib_miniupnpc_upnpDiscover" = xyes; then : - MINIUPNPC_LIBS="$LIBS -lminiupnpc" -else - as_fn_error $? "\"miniupnpc libraries not found.\"" "$LINENO" 5 - -fi - - -fi - - - - if test "x$enable_miniupnpc" = "xyes"; then - MINIUPNPC_TRUE= - MINIUPNPC_FALSE='#' -else - MINIUPNPC_TRUE='#' - MINIUPNPC_FALSE= -fi # Check whether --enable-jumbograms was given. @@ -7739,7 +6760,7 @@ if test "x$runstatedir" = "x"; then fi -ac_config_files="$ac_config_files Makefile src/Makefile doc/Makefile test/Makefile systemd/Makefile" +ac_config_files="$ac_config_files Makefile src/Makefile doc/Makefile systemd/Makefile" cat >confcache <<\_ACEOF @@ -7875,10 +6896,6 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${CODE_COVERAGE_ENABLED_TRUE}" && test -z "${CODE_COVERAGE_ENABLED_FALSE}"; then - as_fn_error $? "conditional \"CODE_COVERAGE_ENABLED\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi if test -z "${LINUX_TRUE}" && test -z "${LINUX_FALSE}"; then as_fn_error $? "conditional \"LINUX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -7919,18 +6936,6 @@ if test -z "${GETOPT_TRUE}" && test -z "${GETOPT_FALSE}"; then as_fn_error $? "conditional \"GETOPT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${OPENSSL_TRUE}" && test -z "${OPENSSL_FALSE}"; then - as_fn_error $? "conditional \"OPENSSL\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${GCRYPT_TRUE}" && test -z "${GCRYPT_FALSE}"; then - as_fn_error $? "conditional \"GCRYPT\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${MINIUPNPC_TRUE}" && test -z "${MINIUPNPC_FALSE}"; then - as_fn_error $? "conditional \"MINIUPNPC\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 @@ -8328,7 +7333,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by tinc $as_me 1.1pre17, which was +This file was extended by tinc $as_me 1.0.36, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -8394,7 +7399,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -tinc config.status 1.1pre17 +tinc config.status 1.0.36 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -8528,7 +7533,6 @@ do "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; - "test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;; "systemd/Makefile") CONFIG_FILES="$CONFIG_FILES systemd/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; diff --git a/configure.ac b/configure.ac index 241f172..ca2948a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,9 @@ dnl Process this file with autoconf to produce a configure script. -origcflags="$CFLAGS" - AC_PREREQ(2.61) -AC_INIT([tinc], m4_esyscmd_s((git describe || echo UNKNOWN) | sed 's/release-//')) +AC_INIT([tinc], [1.0.36]) AC_CONFIG_SRCDIR([src/tincd.c]) -AM_INIT_AUTOMAKE([std-options subdir-objects nostdinc silent-rules -Wall]) +AM_INIT_AUTOMAKE([1.11 check-news std-options subdir-objects nostdinc silent-rules -Wall]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) AM_SILENT_RULES([yes]) @@ -20,11 +18,8 @@ dnl Checks for programs. AC_PROG_CC_C99 AC_PROG_CPP AC_PROG_INSTALL -AM_PROG_CC_C_O -dnl Check whether to enable code coverage testing, and if so, clear the default CFLAGS. -AX_CODE_COVERAGE -AS_IF([test "x$enable_code_coverage" = "xyes" -a "x$origcflags" = "x"], [CFLAGS=""]) +AM_PROG_CC_C_O dnl Check and set OS @@ -71,9 +66,7 @@ case $host_os in *mingw*) mingw=true AC_DEFINE(HAVE_MINGW, 1, [MinGW]) - LIBS="$LIBS -lws2_32 -lgdi32 -lcrypt32 -liphlpapi" - LDFLAGS="$LDFLAGS -static" - CPPFLAGS="$CPPFLAGS -DMINIUPNP_STATICLIB" + LIBS="$LIBS -lws2_32 -lgdi32 -lcrypt32" ;; *) AC_MSG_ERROR("Unknown operating system.") @@ -114,6 +107,13 @@ AC_ARG_ENABLE(tunemu, [tunemu=false] ) +AC_ARG_WITH(windows2000, + AS_HELP_STRING([--with-windows2000], [compile with support for Windows 2000. This disables support for tunneling over existing IPv6 networks.]), + [ AS_IF([test "x$with_windows2000" = "xyes"], + [AC_DEFINE(WITH_WINDOWS2000, 1, [Compile with support for Windows 2000])]) + ] +) + AC_ARG_WITH(systemd, AS_HELP_STRING([--with-systemd@<:@=DIR@:>@], [install systemd service files @<:@to DIR if specified@:>@]), [ systemd=true; systemd_path="$with_systemd" ], @@ -137,8 +137,12 @@ AM_CONDITIONAL(WITH_SYSTEMD, test "$systemd" = true) AC_CACHE_SAVE -AS_IF([test -d /sw/include], [CPPFLAGS="$CPPFLAGS -I/sw/include"]) -AS_IF([test -d /sw/lib], [LIBS="$LIBS -L/sw/lib"]) +if test -d /sw/include ; then + CPPFLAGS="$CPPFLAGS -I/sw/include" +fi +if test -d /sw/lib ; then + LIBS="$LIBS -L/sw/lib" +fi dnl Compiler hardening flags dnl No -fstack-protector-all because it doesn't work on all platforms or architectures. @@ -165,11 +169,13 @@ AS_IF([test "x$enable_hardening" != "xno"], ] ); +dnl Checks for libraries. + dnl Checks for header files. dnl We do this in multiple stages, because unlike Linux all the other operating systems really suck and don't include their own dependencies. -AC_CHECK_HEADERS([syslog.h sys/file.h sys/ioctl.h sys/mman.h sys/param.h sys/resource.h sys/socket.h sys/time.h sys/un.h sys/wait.h netdb.h arpa/inet.h dirent.h getopt.h]) -AC_CHECK_HEADERS([net/if.h net/if_types.h net/ethernet.h net/if_arp.h netinet/in_systm.h netinet/in.h netinet/in6.h netpacket/packet.h], +AC_CHECK_HEADERS([syslog.h sys/file.h sys/ioctl.h sys/mman.h sys/param.h sys/resource.h sys/socket.h sys/time.h sys/uio.h sys/wait.h netdb.h arpa/inet.h arpa/nameser.h dirent.h getopt.h]) +AC_CHECK_HEADERS([net/if.h net/if_types.h linux/if_tun.h net/if_tun.h net/if_utun.h net/tun/if_tun.h net/if_tap.h net/tap/if_tap.h net/ethernet.h net/if_arp.h netinet/in_systm.h netinet/in.h netinet/in6.h netpacket/packet.h], [], [], [#include "$srcdir/src/have.h"] ) AC_CHECK_HEADERS([netinet/if_ether.h netinet/ip.h netinet/ip6.h resolv.h], @@ -180,78 +186,48 @@ AC_CHECK_HEADERS([netinet/tcp.h netinet/ip_icmp.h netinet/icmp6.h], ) dnl Checks for typedefs, structures, and compiler characteristics. -tinc_ATTRIBUTE(__malloc__) -tinc_ATTRIBUTE(__nonnull__) -tinc_ATTRIBUTE(__warn_unused_result__) +AC_TYPE_PID_T -AC_CHECK_TYPES([struct ether_header, struct arphdr, struct ether_arp, struct ip, struct icmp, struct ip6_hdr, struct icmp6_hdr, struct nd_neighbor_solicit, struct nd_opt_hdr], , , +tinc_ATTRIBUTE(__malloc__) + +AC_CHECK_TYPES([socklen_t, struct ether_header, struct arphdr, struct ether_arp, struct in_addr, struct addrinfo, struct ip, struct icmp, struct in6_addr, struct sockaddr_in6, struct ip6_hdr, struct icmp6_hdr, struct nd_neighbor_solicit, struct nd_opt_hdr], , , [#include "$srcdir/src/have.h"] ) dnl Checks for library functions. AC_TYPE_SIGNAL -AC_CHECK_FUNCS([asprintf daemon fchmod flock fork gettimeofday mlockall putenv recvmmsg strsignal nanosleep unsetenv vsyslog devname fdevname], +AC_CHECK_FUNCS([asprintf daemon fchmod flock fork gettimeofday mlockall pselect putenv strsignal system unsetenv usleep vsyslog devname fdevname], [], [], [#include "$srcdir/src/have.h"] ) AC_CHECK_FUNC(getopt_long, [getopt=true; AC_DEFINE(HAVE_GETOPT_LONG, 1, [getopt_long()])], [getopt=false]) AM_CONDITIONAL(GETOPT, test "$getopt" = true) +dnl Support for SunOS + +AC_CHECK_FUNC(socket, [], [ + AC_CHECK_LIB(socket, connect) +]) +AC_CHECK_FUNC(gethostbyname, [], [ + AC_CHECK_LIB(nsl, gethostbyname) +]) + +AC_CHECK_DECLS([freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo], + [], [], [#include "$srcdir/src/have.h"] +) + AC_CHECK_DECLS([res_init], [AC_CHECK_LIB(resolv, res_init)], [], [ #include #include ]) -dnl Operating system specific checks -case $host_os in - *linux*) - AC_CHECK_HEADERS([linux/if_tun.h], - [], [AC_MSG_ERROR([Required header file missng])], [#include "$srcdir/src/have.h"] - ) - ;; - *bsd*|*dragonfly*|*darwin*) - AC_CHECK_HEADERS([net/if_tun.h net/if_utun.h net/tun/if_tun.h net/if_tap.h net/tap/if_tap.h], - [], [], [#include "$srcdir/src/have.h"] - ) - ;; - *solaris*) - AC_CHECK_FUNC(socket, [], [AC_CHECK_LIB(socket, connect)]) - ;; - *) - ;; -esac - AC_CACHE_SAVE -AC_ARG_ENABLE(legacy-protocol, - AS_HELP_STRING([--disable-legacy-protocol], [disable support for the legacy (tinc 1.0) protocol]), - [ AS_IF([test "x$enable_legacy_protocol" = "xno"], - [ AC_DEFINE(DISABLE_LEGACY, 1, [Disable support for the legacy (tinc 1.0) protocol]) ]) - ] -) - dnl These are defined in files in m4/ -dnl AC_ARG_WITH(libgcrypt, AC_HELP_STRING([--with-libgcrypt], [enable use of libgcrypt instead of OpenSSL])], []) -dnl AC_ARG_WITH(openssl, AC_HELP_STRING([--without-openssl], [disable support for OpenSSL])], []) - -tinc_CURSES -tinc_READLINE tinc_ZLIB tinc_LZO - -AS_IF([test "x$enable_legacy_protocol" != "xno"], - [AS_IF([test -n "$with_libgcrypt"], - [gcrypt=true; tinc_LIBGCRYPT], - [openssl=true; tinc_OPENSSL]) - ] -) - -AM_CONDITIONAL(OPENSSL, test -n "$openssl") -AM_CONDITIONAL(GCRYPT, test -n "$gcrypt") - -tinc_MINIUPNPC -AM_CONDITIONAL(MINIUPNPC, test "x$enable_miniupnpc" = "xyes") +tinc_OPENSSL dnl Check if support for jumbograms is requested AC_ARG_ENABLE(jumbograms, @@ -266,6 +242,6 @@ if test "x$runstatedir" = "x"; then AC_SUBST([runstatedir], ['${localstatedir}/run']) fi -AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile test/Makefile systemd/Makefile]) +AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile systemd/Makefile]) AC_OUTPUT diff --git a/doc/Makefile.am b/doc/Makefile.am index e5f3a04..29d6ffd 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -3,23 +3,20 @@ info_TEXINFOS = tinc.texi tinc_TEXINFOS = tincinclude.texi -man_MANS = tincd.8 tinc.8 tinc.conf.5 tinc-gui.8 +man_MANS = tincd.8 tinc.conf.5 -EXTRA_DIST = tincinclude.texi.in tincd.8.in tinc.8.in tinc.conf.5.in tinc-gui.8.in sample-config +EXTRA_DIST = tincinclude.texi.in tincd.8.in tinc.conf.5.in sample-config -CLEANFILES = *.html tincd.8 tinc.8 tinc.conf.5 tinc-gui.8 tincinclude.texi +CLEANFILES = *.html tincd.8 tinc.conf.5 tincinclude.texi + +texi2html: tinc.texi + $(AM_V_GEN)texi2html -split=chapter $< tincd.8.html: tincd.8 - $(AM_V_GEN)w3mman2html $? > $@ - -tinc.8.html: tinc.8 - $(AM_V_GEN)w3mman2html $? > $@ - -tinc-gui.8.html: tinc-gui.8 - $(AM_V_GEN)w3mman2html $? > $@ + $(AM_V_GEN)w3mman2html $< > $@ tinc.conf.5.html: tinc.conf.5 - $(AM_V_GEN)w3mman2html $? > $@ + $(AM_V_GEN)w3mman2html $< > $@ substitute = sed \ -e s,'@PACKAGE\@',"$(PACKAGE)",g \ @@ -31,12 +28,6 @@ substitute = sed \ tincd.8: $(srcdir)/tincd.8.in $(AM_V_GEN)$(substitute) $(srcdir)/tincd.8.in > $@ -tinc.8: $(srcdir)/tinc.8.in - $(AM_V_GEN)$(substitute) $(srcdir)/tinc.8.in > $@ - -tinc-gui.8: $(srcdir)/tinc-gui.8.in - $(AM_V_GEN)$(substitute) $(srcdir)/tinc-gui.8.in > $@ - tinc.conf.5: $(srcdir)/tinc.conf.5.in $(AM_V_GEN)$(substitute) $(srcdir)/tinc.conf.5.in > $@ diff --git a/doc/Makefile.in b/doc/Makefile.in index 82bcd01..86497e4 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -94,12 +94,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/attribute.m4 \ $(top_srcdir)/m4/ax_cflags_warn_all.m4 \ $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_check_link_flag.m4 \ - $(top_srcdir)/m4/ax_code_coverage.m4 \ - $(top_srcdir)/m4/ax_require_defined.m4 \ - $(top_srcdir)/m4/curses.m4 $(top_srcdir)/m4/libgcrypt.m4 \ - $(top_srcdir)/m4/lzo.m4 $(top_srcdir)/m4/miniupnpc.m4 \ - $(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/readline.m4 \ - $(top_srcdir)/m4/zlib.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/ax_require_defined.m4 $(top_srcdir)/m4/lzo.m4 \ + $(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/zlib.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) @@ -212,15 +209,8 @@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_CPPFLAGS = @CODE_COVERAGE_CPPFLAGS@ -CODE_COVERAGE_CXXFLAGS = @CODE_COVERAGE_CXXFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CODE_COVERAGE_LIBS = @CODE_COVERAGE_LIBS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ -CURSES_LIBS = @CURSES_LIBS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ @@ -229,21 +219,17 @@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ -GCOV = @GCOV@ -GENHTML = @GENHTML@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LCOV = @LCOV@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ -MINIUPNPC_LIBS = @MINIUPNPC_LIBS@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ @@ -254,8 +240,6 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -READLINE_LIBS = @READLINE_LIBS@ -SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -314,9 +298,9 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ info_TEXINFOS = tinc.texi tinc_TEXINFOS = tincinclude.texi -man_MANS = tincd.8 tinc.8 tinc.conf.5 tinc-gui.8 -EXTRA_DIST = tincinclude.texi.in tincd.8.in tinc.8.in tinc.conf.5.in tinc-gui.8.in sample-config -CLEANFILES = *.html tincd.8 tinc.8 tinc.conf.5 tinc-gui.8 tincinclude.texi +man_MANS = tincd.8 tinc.conf.5 +EXTRA_DIST = tincinclude.texi.in tincd.8.in tinc.conf.5.in sample-config +CLEANFILES = *.html tincd.8 tinc.conf.5 tincinclude.texi substitute = sed \ -e s,'@PACKAGE\@',"$(PACKAGE)",g \ -e s,'@VERSION\@',"$(VERSION)",g \ @@ -846,27 +830,18 @@ uninstall-man: uninstall-man5 uninstall-man8 .PRECIOUS: Makefile +texi2html: tinc.texi + $(AM_V_GEN)texi2html -split=chapter $< + tincd.8.html: tincd.8 - $(AM_V_GEN)w3mman2html $? > $@ - -tinc.8.html: tinc.8 - $(AM_V_GEN)w3mman2html $? > $@ - -tinc-gui.8.html: tinc-gui.8 - $(AM_V_GEN)w3mman2html $? > $@ + $(AM_V_GEN)w3mman2html $< > $@ tinc.conf.5.html: tinc.conf.5 - $(AM_V_GEN)w3mman2html $? > $@ + $(AM_V_GEN)w3mman2html $< > $@ tincd.8: $(srcdir)/tincd.8.in $(AM_V_GEN)$(substitute) $(srcdir)/tincd.8.in > $@ -tinc.8: $(srcdir)/tinc.8.in - $(AM_V_GEN)$(substitute) $(srcdir)/tinc.8.in > $@ - -tinc-gui.8: $(srcdir)/tinc-gui.8.in - $(AM_V_GEN)$(substitute) $(srcdir)/tinc-gui.8.in > $@ - tinc.conf.5: $(srcdir)/tinc.conf.5.in $(AM_V_GEN)$(substitute) $(srcdir)/tinc.conf.5.in > $@ diff --git a/doc/sample-config/tinc.conf b/doc/sample-config/tinc.conf index 25a61a7..7081764 100644 --- a/doc/sample-config/tinc.conf +++ b/doc/sample-config/tinc.conf @@ -16,7 +16,7 @@ Name = alpha ConnectTo = beta # The tap device tinc will use. -# Default is /dev/tap0 for ethertap or FreeBSD, -# /dev/tun0 for Solaris and OpenBSD, -# and /dev/net/tun for Linux tun/tap device. +# /dev/tap0 for ethertap, FreeBSD or OpenBSD +# /dev/tun0 for Solaris +# /dev/net/tun for Linux tun/tap Device = /dev/net/tun diff --git a/doc/tinc-gui.8.in b/doc/tinc-gui.8.in deleted file mode 100644 index e554a85..0000000 --- a/doc/tinc-gui.8.in +++ /dev/null @@ -1,57 +0,0 @@ -.Dd 2011-06-26 -.Dt TINC-GUI 8 -.\" Manual page created by: -.\" Guus Sliepen -.Sh NAME -.Nm tinc-gui -.Nd tinc GUI -.Sh SYNOPSIS -.Nm -.Op Fl n -.Op Fl -net Ns = Ns Ar NETNAME -.Op Fl -pidfile Ns = Ns Ar FILENAME -.Op Fl -help -.Sh DESCRIPTION -This is a Python/wxWidgets based graphical user interface for tinc, a secure virtual private network (VPN) project. -.Nm -communicates with -.Xr tincd 8 -to alter and inspect the running VPN's state. -It can show the current settings, the list of connections, nodes, subnets, and edges. -For now, the debug level can be changed from the GUI, and by right-clicking on a node in the list of connections, -a pop-up menu will appear that allows one to disconnect that node. -.Sh OPTIONS -.Bl -tag -width indent -.It Fl n, -net Ns = Ns Ar NETNAME -Communicate with tincd(8) connected with -.Ar NETNAME . -.It Fl -pidfile Ns = Ns Ar FILENAME -Use the cookie from -.Ar FILENAME -to authenticate with a running tinc daemon. -If unspecified, the default is -.Pa @runstatedir@/tinc. Ns Ar NETNAME Ns Pa .pid. -.It Fl -help -Display short list of options. -.El -.Sh BUGS -The GUI is not finished yet, the final version will have much more functionality. -If you find any bugs, report them to tinc@tinc-vpn.org. -.Sh SEE ALSO -.Xr tincd 8 , -.Pa http://www.tinc-vpn.org/ . -.Pp -The full documentation for tinc is maintained as a Texinfo manual. -If the info and tinc programs are properly installed at your site, -the command -.Ic info tinc -should give you access to the complete manual. -.Pp -tinc comes with ABSOLUTELY NO WARRANTY. -This is free software, and you are welcome to redistribute it under certain conditions; -see the file COPYING for details. -.Sh AUTHORS -.An "Ivo Timmermans" -.An "Guus Sliepen" Aq guus@tinc-vpn.org -.Pp -And thanks to many others for their contributions to tinc! diff --git a/doc/tinc.8.in b/doc/tinc.8.in deleted file mode 100644 index aaa3547..0000000 --- a/doc/tinc.8.in +++ /dev/null @@ -1,345 +0,0 @@ -.Dd 2014-01-16 -.Dt TINCCTL 8 -.\" Manual page created by: -.\" Scott Lamb -.Sh NAME -.Nm tinc -.Nd tinc VPN control -.Sh SYNOPSIS -.Nm -.Op Fl bcn -.Op Fl -config Ns = Ns Ar DIR -.Op Fl -net Ns = Ns Ar NETNAME -.Op Fl -pidfile Ns = Ns Ar FILENAME -.Op Fl -batch -.Op Fl -force -.Op Fl -help -.Op Fl -version -.Op Ar COMMAND -.Sh DESCRIPTION -This is the control program of tinc, a secure virtual private network (VPN) -project. -.Nm -can start and stop -.Xr tincd 8 , -and can to alter and inspect the state of a running VPN. -It can also be used to change the configuration, -or to import or export host configuration files from other nodes. - -If -.Nm -is started with a -.Ar COMMAND , -this command is immediately executed, after which -.Nm -exits. -If no -.Ar COMMAND -is given, -.Nm -will act as a shell; -it will display a prompt, and commands can be entered on the prompt. -If -.Nm -is compiled with libreadline, history and command completion are available on the prompt. -One can also pipe a script containing commands through -.Nm . -In that case, lines starting with a # symbol will be ignored. -.Sh OPTIONS -.Bl -tag -width indent -.It Fl n, -net Ns = Ns Ar NETNAME -Communicate with tincd(8) connected with -.Ar NETNAME . -.It Fl -pidfile Ns = Ns Ar FILENAME -Use the cookie from -.Ar FILENAME -to authenticate with a running tinc daemon. -If unspecified, the default is -.Pa @runstatedir@/tinc. Ns Ar NETNAME Ns Pa .pid. -.It Fl b, -batch -Don't ask for anything (non-interactive mode). -.It Fl -force -Force some commands to work despite warnings. -.It Fl -help -Display short list of options. -.It Fl -version -Output version information and exit. -.El -.Sh ENVIRONMENT VARIABLES -.Bl -tag -width indent -.It Ev NETNAME -If no netname is specified on the command line with the -.Fl n -option, the value of this environment variable is used. -.El -.Sh COMMANDS -.Bl -tag -width indent -.It init Op Ar name -Create initial configuration files and RSA and Ed25519 keypairs with default length. -If no -.Ar name -for this node is given, it will be asked for. -.It get Ar variable -Print the current value of configuration variable -.Ar variable . -If more than one variable with the same name exists, -the value of each of them will be printed on a separate line. -.It set Ar variable Ar value -Set configuration variable -.Ar variable -to the given -.Ar value . -All previously existing configuration variables with the same name are removed. -To set a variable for a specific host, use the notation -.Ar host Ns Li . Ns Ar variable . -.It add Ar variable Ar value -As above, but without removing any previously existing configuration variables. -If the variable already exists with the given value, nothing happens. -.It del Ar variable Op Ar value -Remove configuration variables with the same name and -.Ar value . -If no -.Ar value -is given, all configuration variables with the same name will be removed. -.It edit Ar filename -Start an editor for the given configuration file. -You do not need to specify the full path to the file. -.It export -Export the host configuration file of the local node to standard output. -.It export-all -Export all host configuration files to standard output. -.It import -Import host configuration data generated by the -.Nm -export command from standard input. -Already existing host configuration files are not overwritten unless the option -.Fl -force -is used. -.It exchange -The same as export followed by import. -.It exchange-all -The same as export-all followed by import. -.It invite Ar name -Prepares an invitation for a new node with the given -.Ar name , -and prints a short invitation URL that can be used with the join command. -.It join Op Ar URL -Join an existing VPN using an invitation URL created using the invite command. -If no -.Ar URL -is given, it will be read from standard input. -.It start Op tincd options -Start -.Xr tincd 8 , -optionally with the given extra options. -.It stop -Stop -.Xr tincd 8 . -.It restart Op tincd options -Restart -.Xr tincd 8 , -optionally with the given extra options. -.It reload -Partially rereads configuration files. Connections to hosts whose host -config files are removed are closed. New outgoing connections specified -in -.Xr tinc.conf 5 -will be made. -.It pid -Shows the PID of the currently running -.Xr tincd 8 . -.It generate-keys Op bits -Generate both RSA and Ed25519 keypairs (see below) and exit. -.It generate-ed25519-keys -Generate public/private Ed25519 keypair and exit. -.It generate-rsa-keys Op bits -Generate public/private RSA keypair and exit. -If -.Ar bits -is omitted, the default length will be 2048 bits. -When saving keys to existing files, tinc will not delete the old keys; -you have to remove them manually. -.It dump [reachable] nodes -Dump a list of all known nodes in the VPN. -If the keyword reachable is used, only lists reachable nodes. -.It dump edges -Dump a list of all known connections in the VPN. -.It dump subnets -Dump a list of all known subnets in the VPN. -.It dump connections -Dump a list of all meta connections with ourself. -.It dump graph | digraph -Dump a graph of the VPN in -.Xr dotty 1 -format. -Nodes are colored according to their reachability: -red nodes are unreachable, orange nodes are indirectly reachable, green nodes are directly reachable. -Black nodes are either directly or indirectly reachable, but direct reachability has not been tried yet. -.It dump invitations -Dump a list of outstanding invitations. -The filename of the invitation, as well as the name of the node that is being invited is shown for each invitation. -.It info Ar node | subnet | address -Show information about a particular node, subnet or address. -If an address is given, any matching subnet will be shown. -.It purge -Purges all information remembered about unreachable nodes. -.It debug Ar N -Sets debug level to -.Ar N . -.It log Op Ar N -Capture log messages from a running tinc daemon. -An optional debug level can be given that will be applied only for log messages sent to -.Nm tinc . -.It retry -Forces -.Xr tincd 8 -to try to connect to all uplinks immediately. -Usually -.Xr tincd 8 -attempts to do this itself, -but increases the time it waits between the attempts each time it failed, -and if -.Xr tincd 8 -didn't succeed to connect to an uplink the first time after it started, -it defaults to the maximum time of 15 minutes. -.It disconnect Ar NODE -Closes the meta connection with the given -.Ar NODE . -.It top -If -.Nm -is compiled with libcurses support, this will display live traffic statistics -for all the known nodes, similar to the UNIX -.Xr top 1 -command. -See below for more information. -.It pcap -Dump VPN traffic going through the local tinc node in -.Xr pcap-savefile 5 -format to standard output, -from where it can be redirected to a file or piped through a program that can parse it directly, -such as -.Xr tcpdump 8 . -.It network Op Ar netname -If -.Ar netname -is given, switch to that network. -Otherwise, display a list of all networks for which configuration files exist. -.It fsck -This will check the configuration files for possible problems, -such as unsafe file permissions, missing executable bit on script, -unknown and obsolete configuration variables, wrong public and/or private keys, and so on. -.Pp -When problems are found, this will be printed on a line with WARNING or ERROR in front of it. -Most problems must be corrected by the user itself, however in some cases (like file permissions and missing public keys), -tinc will ask if it should fix the problem. -.It sign Op Ar filename -Sign a file with the local node's private key. -If no -.Ar filename -is given, the file is read from standard input. -The signed file is written to standard output. -.It verify Ar name Op Ar filename -Check the signature of a file against a node's public key. -The -.Ar name -of the node must be given, -or can be -.Li . -to check against the local node's public key, or -.Li * -to allow a signature from any node whose public key is known. -If no -.Ar filename -is given, the file is read from standard input. -If the verification is successful, -a copy of the input with the signature removed is written to standard output, -and the exit code will be zero. -If the verification failed, -nothing will be written to standard output, and the exit code will be non-zero. -.El -.Sh EXAMPLES -Examples of some commands: -.Bd -literal -offset indent -tinc -n vpn dump graph | circo -Txlib -tinc -n vpn pcap | tcpdump -r - -tinc -n vpn top -.Pp -.Ed -Examples of changing the configuration using -.Nm : -.Bd -literal -offset indent -tinc -n vpn init foo -tinc -n vpn add Subnet 192.168.1.0/24 -tinc -n vpn add bar.Address bar.example.com -tinc -n vpn add ConnectTo bar -tinc -n vpn export | gpg --clearsign | mail -s "My config" vpnmaster@example.com -.Ed -.Sh TOP -The top command connects to a running tinc daemon and repeatedly queries its per-node traffic counters. -It displays a list of all the known nodes in the left-most column, -and the amount of bytes and packets read from and sent to each node in the other columns. -By default, the information is updated every second. -The behaviour of the top command can be changed using the following keys: -.Bl -tag -.It Ic s -Change the interval between updates. -After pressing the -.Ic s -key, enter the desired interval in seconds, followed by enter. -Fractional seconds are honored. -Intervals lower than 0.1 seconds are not allowed. -.It Ic c -Toggle between displaying current traffic rates (in packets and bytes per second) -and cumulative traffic (total packets and bytes since the tinc daemon started). -.It Ic n -Sort the list of nodes by name. -.It Ic i -Sort the list of nodes by incoming amount of bytes. -.It Ic I -Sort the list of nodes by incoming amount of packets. -.It Ic o -Sort the list of nodes by outgoing amount of bytes. -.It Ic O -Sort the list of nodes by outgoing amount of packets. -.It Ic t -Sort the list of nodes by sum of incoming and outgoing amount of bytes. -.It Ic T -Sort the list of nodes by sum of incoming and outgoing amount of packets. -.It Ic b -Show amount of traffic in bytes. -.It Ic k -Show amount of traffic in kilobytes. -.It Ic M -Show amount of traffic in megabytes. -.It Ic G -Show amount of traffic in gigabytes. -.It Ic q -Quit. -.El -.Sh BUGS -If you find any bugs, report them to tinc@tinc-vpn.org. -.Sh SEE ALSO -.Xr tincd 8 , -.Xr tinc.conf 5 , -.Xr dotty 1 , -.Xr pcap-savefile 5 , -.Xr tcpdump 8 , -.Xr top 1 , -.Pa http://www.tinc-vpn.org/ , -.Pa http://www.cabal.org/ . -.Pp -The full documentation for tinc is maintained as a Texinfo manual. -If the info and tinc programs are properly installed at your site, -the command -.Ic info tinc -should give you access to the complete manual. -.Pp -tinc comes with ABSOLUTELY NO WARRANTY. -This is free software, and you are welcome to redistribute it under certain conditions; -see the file COPYING for details. -.Sh AUTHORS -.An "Ivo Timmermans" -.An "Guus Sliepen" Aq guus@tinc-vpn.org -.Pp -And thanks to many others for their contributions to tinc! diff --git a/doc/tinc.conf.5.in b/doc/tinc.conf.5.in index 6897ba6..cd7d1a0 100644 --- a/doc/tinc.conf.5.in +++ b/doc/tinc.conf.5.in @@ -1,4 +1,4 @@ -.Dd 2017-09-02 +.Dd 2016-10-29 .Dt TINC.CONF 5 .\" Manual page created by: .\" Ivo Timmermans @@ -11,12 +11,20 @@ The files in the .Pa @sysconfdir@/tinc/ directory contain runtime and security information for the tinc daemon. .Sh NETWORKS -To distinguish multiple instances of tinc running on one computer, -you can use the -.Fl n -option to assign a network name to each tinc daemon. +It is perfectly ok for you to run more than one tinc daemon. +However, in its default form, +you will soon notice that you can't use two different configuration files without the +.Fl c +option. .Pp -The effect of this option is that the daemon will set its configuration root to +We have thought of another way of dealing with this: network names. +This means that you call +.Nm +with the +.Fl n +option, which will assign a name to this daemon. +.Pp +The effect of this is that the daemon will set its configuration root to .Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa / , where .Ar NETNAME @@ -24,14 +32,13 @@ is your argument to the .Fl n option. You'll notice that messages appear in syslog as coming from -.Nm tincd. Ns Ar NETNAME , -and on Linux, unless specified otherwise, the name of the virtual network interface will be the same as the network name. +.Nm tincd. Ns Ar NETNAME . .Pp -It is recommended that you use network names even if you run only one instance of tinc. -However, you can choose not to use the +However, it is not strictly necessary that you call tinc with the .Fl n option. -In this case, the network name would just be empty, and +In this case, the network name would just be empty, +and it will be used as such. .Nm tinc now looks for files in .Pa @sysconfdir@/tinc/ , @@ -41,6 +48,11 @@ the configuration file should be .Pa @sysconfdir@/tinc/tinc.conf , and the host configuration files are now expected to be in .Pa @sysconfdir@/tinc/hosts/ . +.Pp +But it is highly recommended that you use this feature of +.Nm tinc , +because it will be so much clearer whom your daemon talks to. +Hence, we will assume that you use it. .Sh NAMES Each tinc daemon must have a name that is unique in the network which it will be part of. The name will be used by other tinc daemons for identification. @@ -51,34 +63,24 @@ file. To make things easy, choose something that will give unique and easy to remember names to your tinc daemon(s). You could try things like hostnames, owner surnames or location names. -However, you are only allowed to use alphanumerical characters (a-z, A-Z, and 0-9) and underscores (_) in the name. -.Sh INITIAL CONFIGURATION -If you have not configured tinc yet, you can easily create a basic configuration using the following command: -.Bd -literal -offset indent -.Nm tinc Fl n Ar NETNAME Li init Ar NAME -.Ed -.Pp -You can further change the configuration as needed either by manually editing the configuration files, -or by using -.Xr tinc 8 . .Sh PUBLIC/PRIVATE KEYS -The -.Nm tinc Li init -command will have generated both RSA and Ed25519 public/private keypairs. -The private keys should be stored in files named -.Pa rsa_key.priv -and -.Pa ed25519_key.priv -in the directory -.Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa / -The public keys should be stored in the host configuration file -.Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /hosts/ Ns Va NAME . -The RSA keys are used for backwards compatibility with tinc version 1.0. -If you are upgrading from version 1.0 to 1.1, you can keep the old configuration files, -but you will need to create Ed25519 keys using the following command: -.Bd -literal -offset indent -.Nm tinc Fl n Ar NETNAME Li generate-ed25519-keys -.Ed +You should use +.Ic tincd -K +to generate public/private keypairs. +It will generate two keys. +The private key should be stored in a separate file +.Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /rsa_key.priv +\-\- where +.Ar NETNAME +stands for the network (see +.Sx NETWORKS ) +above. +The public key should be stored in the host configuration file +.Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /hosts/ Ns Va NAME +\-\- where +.Va NAME +stands for the name of the local tinc daemon (see +.Sx NAMES ) . .Sh SERVER CONFIGURATION The server configuration of the daemon is done in the file .Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /tinc.conf . @@ -101,10 +103,6 @@ Although all configuration options for the local host listed in this document ca it is recommended to put host specific configuration options in the host configuration file, as this makes it easy to exchange with other nodes. .Pp -You can edit the config file manually, but it is recommended that you use -.Xr tinc 8 -to change configuration variables for you. -.Pp Here are all valid variables, listed in alphabetical order. The default value is given between parentheses. .Bl -tag -width indent @@ -114,24 +112,26 @@ If .Qq any is selected, then depending on the operating system both IPv4 and IPv6 or just IPv6 listening sockets will be created. -.It Va AutoConnect Li = yes | no Po yes -If set to yes, +.It Va BindToAddress Li = Ar address Oo Ar port Oc Bq experimental +If your computer has more than one IPv4 or IPv6 address, .Nm tinc -will automatically set up meta connections to other nodes, -without requiring -.Va ConnectTo -variables. -.Pp -Note: it is not possible to connect to nodes using zero (system-assigned) ports in this way. -.It Va BindToAddress Li = Ar address Op Ar port -This is the same as -.Va ListenAddress , -however the address given with the +will by default listen on all of them for incoming connections. +Multiple .Va BindToAddress -option will also be used for outgoing connections. This is useful if your -computer has more than one IPv4 or IPv6 address, and you want -.Nm tinc -to only use a specific one for outgoing packets. +variables may be specified, +in which case listening sockets for each specified address are made. +.Pp +If no +.Ar port +is specified, the socket will be bound to the port specified by the +.Va Port +option, or to port 655 if neither is given. +To only bind to a specific port but not to a specific address, use +.Li * +for the +.Ar address . +.Pp +This option may not work on all platforms. .It Va BindToInterface Li = Ar interface Bq experimental If your computer has more than one network interface, .Nm tinc @@ -157,13 +157,6 @@ Broadcast packets are sent directly to all nodes that can be reached directly. Broadcast packets received from other nodes are never forwarded. If the IndirectData option is also set, broadcast packets will only be sent to nodes which we have a meta connection to. .El -.It Va BroadcastSubnet Li = Ar address Ns Op Li / Ns Ar prefixlength -Declares a broadcast subnet. Any packet with a destination address falling into such a subnet will be routed as a broadcast (provided all nodes have it declared). -This is most useful to declare subnet broadcast addresses (e.g. 10.42.255.255), otherwise -.Nm tinc -won't know what to do with them. -.Pp -Note that global broadcast addresses (MAC ff:ff:ff:ff:ff:ff, IPv4 255.255.255.255), as well as multicast space (IPv4 224.0.0.0/4, IPv6 ff00::/8) are always considered broadcast addresses and don't need to be declared. .It Va ConnectTo Li = Ar name Specifies which other tinc daemon to connect to on startup. Multiple @@ -176,9 +169,7 @@ The names should be known to this tinc daemon line). .Pp If you don't specify a host with -.Va ConnectTo -and have disabled -.Va AutoConnect , +.Va ConnectTo , .Nm tinc won't try to connect to other daemons at all, and will instead just listen for incoming connections. @@ -202,13 +193,6 @@ instead of .Va Device . The info pages of the tinc package contain more information about configuring the virtual network device. -.It Va DeviceStandby Li = yes | no Po no Pc -When disabled, -.Nm tinc -calls tinc-up on startup, and tinc-down on shutdown. When enabled, -.Nm tinc -will only call tinc-up when at least one node is reachable, and will call tinc-down as soon as no nodes are reachable. -On Windows, this also determines when the virtual network interface "cable" is "plugged". .It Va DeviceType Li = Ar type Pq platform dependent The type of the virtual network device. Tinc will normally automatically select the right type of tun/tap interface, and this option should not be used. @@ -234,10 +218,6 @@ Do NOT connect multiple .Nm tinc daemons to the same multicast address, this will very likely cause routing loops. Also note that this can cause decrypted VPN packets to be sent out on a real network if misconfigured. -.It fd -Use a file descriptor. -All packets are read from this interface. -Packets received for the local node are written to it. .It uml Pq not compiled in by default Create a UNIX socket with the filename specified by .Va Device , @@ -284,17 +264,6 @@ When this option is enabled, packets that cannot be sent directly to the destina but which would have to be forwarded by an intermediate node, are dropped instead. When combined with the IndirectData option, packets for nodes for which we do not have a meta connection with are also dropped. -.It Va Ed25519PrivateKeyFile Li = Ar filename Po Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /ed25519_key.priv Pc -The file in which the private Ed25519 key of this tinc daemon resides. -This is only used if -.Va ExperimentalProtocol -is enabled. -.It Va ExperimentalProtocol Li = yes | no Pq yes -When this option is enabled, the SPTPS protocol will be used when connecting to nodes that also support it. -Ephemeral ECDH will be used for key exchanges, -and Ed25519 will be used instead of RSA for authentication. -When enabled, an Ed25519 key must have been generated before with -.Nm tinc generate-ed25519-keys . .It Va Forwarding Li = off | internal | kernel Po internal Pc Bq experimental This option selects the way indirect packets are forwarded. .Bl -tag -width indent @@ -306,16 +275,22 @@ Incoming packets that are meant for another node are forwarded by tinc internall .Pp This is the default mode, and unless you really know you need another forwarding mode, don't change it. .It kernel -Incoming packets using the legacy protocol are always sent to the TUN/TAP device, -even if the packets are not for the local node. +Incoming packets are always sent to the TUN/TAP device, even if the packets are not for the local node. This is less efficient, but allows the kernel to apply its routing and firewall rules on them, and can also help debugging. -Incoming packets using the SPTPS protocol are dropped, since they are end-to-end encrypted. .El -.It Va FWMark Li = Ar value Po 0 Pc Bq experimental -When set to a non-zero value, all TCP and UDP sockets created by tinc will use the given value as the firewall mark. -This can be used for mark-based routing or for packet filtering. -This option is currently only supported on Linux. +.It Va GraphDumpFile Li = Ar filename Bq experimental +If this option is present, +.Nm tinc +will dump the current network graph to the file +.Ar filename +every minute, unless there were no changes to the graph. +The file is in a format that can be read by graphviz tools. +If +.Ar filename +starts with a pipe symbol |, +then the rest of the filename is interpreted as a shell command +that is executed, the graph is then sent to stdin. .It Va Hostnames Li = yes | no Pq no This option selects whether IP addresses (both real and on the VPN) should be resolved. Since DNS lookups are blocking, it might affect tinc's @@ -333,40 +308,11 @@ Under Windows, this variable is used to select which network interface will be u If you specified a .Va Device , this variable is almost always already correctly set. -.It Va InvitationExpire Li = Ar seconds Pq 604800 -This option controls the period invitations are valid. .It Va KeyExpire Li = Ar seconds Pq 3600 This option controls the period the encryption keys used to encrypt the data are valid. It is common practice to change keys at regular intervals to make it even harder for crackers, even though it is thought to be nearly impossible to crack a single key. -.It Va ListenAddress Li = Ar address Op Ar port -If your computer has more than one IPv4 or IPv6 address, -.Nm tinc -will by default listen on all of them for incoming connections. -This option can be used to restrict which addresses tinc listens on. -Multiple -.Va ListenAddress -variables may be specified, -in which case listening sockets for each specified address are made. -.Pp -If no -.Ar port -is specified, the socket will listen on the port specified by the -.Va Port -option, or to port 655 if neither is given. -To only listen on a specific port but not on a specific address, use -.Li * -for the -.Ar address . -.Pp -If -.Ar port -is set to zero, it will be randomly assigned by the system. This is useful to randomize source ports of UDP packets, which can improve UDP hole punching reliability. In this case it is recommended to set -.Va AddressFamily -as well, otherwise -.Nm tinc -will assign different ports to different address families but other nodes can only know of one. -.It Va LocalDiscovery Li = yes | no Pq yes +.It Va LocalDiscovery Li = yes | no Po no Pc Bq experimental When enabled, .Nm tinc will try to detect peers that are on the same local network. @@ -374,20 +320,14 @@ This will allow direct communication using LAN addresses, even if both peers are and they only ConnectTo a third node outside the NAT, which normally would prevent the peers from learning each other's LAN address. .Pp -Currently, local discovery is implemented by sending some packets to the local address of the node during UDP discovery. This will not work with old nodes that don't transmit their local address. -.It Va LogLevel Li = level Pq 0 -This option controls the verbosity of the logging. The higher the debug level, the more messages it will log. +Currently, local discovery is implemented by sending broadcast packets to the LAN during path MTU discovery. +This feature may not work in all possible situations. .It Va MACExpire Li = Ar seconds Pq 600 This option controls the amount of time MAC addresses are kept before they are removed. This only has effect when .Va Mode is set to .Qq switch . -.It Va MaxConnectionBurst Li = Ar count Pq 100 -This option controls how many connections tinc accepts in quick succession. -If there are more connections than the given number in a short time interval, -tinc will reduce the number of accepted connections to only one per second, -until the burst has passed. .It Va MaxTimeout Li = Ar seconds Pq 900 This is the maximum delay before trying to reconnect to other tinc daemons. .It Va Mode Li = router | switch | hub Pq router @@ -397,7 +337,7 @@ This option selects the way packets are routed to other daemons. In this mode .Va Subnet variables in the host configuration files will be used to form a routing table. -Only packets of routable protocols (IPv4 and IPv6) are supported in this mode. +Only unicast packets of routable protocols (IPv4 and IPv6) are supported in this mode. .Pp This is the default mode, and unless you really know you need another mode, don't change it. .It switch @@ -415,8 +355,7 @@ while no routing table is managed. .It Va Name Li = Ar name Bq required This is the name which identifies this tinc daemon. It must be unique for the virtual private network this daemon will connect to. -.Va Name -may only consist of alphanumeric and underscore characters (a-z, A-Z, 0-9 and _), and is case sensitive. +The Name may only consist of alphanumeric and underscore characters. If .Va Name starts with a @@ -446,9 +385,7 @@ It will allow this tinc daemon to authenticate itself to other daemons. .It Va PrivateKeyFile Li = Ar filename Po Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /rsa_key.priv Pc The file in which the private RSA key of this tinc daemon resides. .It Va ProcessPriority Li = low | normal | high -When this option is used the priority of the -.Nm tincd -process will be adjusted. +When this option is used the priority of the tincd process will be adjusted. Increasing the priority may help to reduce latency and packet loss on the VPN. .It Va Proxy Li = socks4 | socks5 | http | exec Ar ... Bq experimental Use a proxy when making outgoing connections. @@ -482,13 +419,13 @@ and .Ev REMOTEPORT are available. .El -.It Va ReplayWindow Li = Ar bytes Pq 32 +.It Va ReplayWindow Li = Ar bytes Pq 16 This is the size of the replay tracking window for each remote node, in bytes. The window is a bitfield which tracks 1 packet per bit, so for example -the default setting of 32 will track up to 256 packets in the window. In high +the default setting of 16 will track up to 128 packets in the window. In high bandwidth scenarios, setting this to a higher value can reduce packet loss from the interaction of replay tracking with underlying real packet loss and/or -reordering. Setting this to zero will disable replay tracking completely and +reordering. Setting this to zero will disable replay tracking completely and pass all traffic, but leaves tinc vulnerable to replay-based attacks on your traffic. .It Va StrictSubnets Li = yes | no Po no Pc Bq experimental @@ -503,42 +440,12 @@ and will only allow connections with nodes for which host config files are prese .Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /hosts/ directory. Setting this options also implicitly sets StrictSubnets. -.It Va UDPDiscovery Li = yes | no Po yes Pc -When this option is enabled tinc will try to establish UDP connectivity to nodes, -using TCP while it determines if a node is reachable over UDP. If it is disabled, -tinc always assumes a node is reachable over UDP. -Note that tinc will never use UDP with nodes that have -.Va TCPOnly -enabled. -.It Va UDPDiscoveryKeepaliveInterval Li = Ar seconds Pq 9 -The minimum amount of time between sending UDP ping datagrams to check UDP connectivity once it has been established. -Note that these pings are large, since they are used to verify link MTU as well. -.It Va UDPDiscoveryInterval Li = Ar seconds Pq 2 -The minimum amount of time between sending UDP ping datagrams to try to establish UDP connectivity. -.It Va UDPDiscoveryTimeout Li = Ar seconds Pq 30 -If tinc doesn't receive any UDP ping replies over the specified interval, -it will assume UDP communication is broken and will fall back to TCP. -.It Va UDPInfoInterval Li = Ar seconds Pq 5 -The minimum amount of time between sending periodic updates about UDP addresses, which are mostly useful for UDP hole punching. -.It Va UDPRcvBuf Li = Ar bytes Pq 1048576 +.It Va UDPRcvBuf Li = Ar bytes Pq OS default Sets the socket receive buffer size for the UDP socket, in bytes. -If set to zero, the default buffer size will be used by the operating system. -Note: this setting can have a significant impact on performance, especially raw throughput. -.It Va UDPSndBuf Li = Ar bytes Pq 1048576 +If unset, the default buffer size will be used by the operating system. +.It Va UDPSndBuf Li = Ar bytes Pq OS default Sets the socket send buffer size for the UDP socket, in bytes. -If set to zero, the default buffer size will be used by the operating system. -Note: this setting can have a significant impact on performance, especially raw throughput. -.It Va UPnP Li = yes | udponly | no Po no Pc -If this option is enabled then tinc will search for UPnP-IGD devices on the local network. -It will then create and maintain port mappings for tinc's listening TCP and UDP ports. -If set to "udponly", tinc will only create a mapping for its UDP (data) port, not for its TCP (metaconnection) port. -Note that tinc must have been built with miniupnpc support for this feature to be available. -Furthermore, be advised that enabling this can have security implications, because the miniupnpc library that -tinc uses might not be well-hardened with regard to malicious UPnP replies. -.It Va UPnPDiscoverWait Li = Ar seconds Pq 5 -The amount of time to wait for replies when probing the local network for UPnP devices. -.It Va UPnPRefreshPeriod Li = Ar seconds Pq 60 -How often tinc will re-add the port mapping, in case it gets reset on the UPnP device. This also controls the duration of the port mapping itself, which will be set to twice that duration. +If unset, the default buffer size will be used by the operating system. .El .Sh HOST CONFIGURATION FILES The host configuration files contain all information needed @@ -561,15 +468,13 @@ Multiple .Va Address variables can be specified, in which case each address will be tried until a working connection has been established. -.It Va Cipher Li = Ar cipher Pq blowfish +.It Va Cipher Li = Ar cipher Pq aes-256-cbc The symmetric cipher algorithm used to encrypt UDP packets. Any cipher supported by LibreSSL or OpenSSL is recognised. Furthermore, specifying .Qq none will turn off packet encryption. It is best to use only those ciphers which support CBC mode. -This option has no effect for connections between nodes using -.Va ExperimentalProtocol . .It Va ClampMSS Li = yes | no Pq yes This option specifies whether tinc should clamp the maximum segment size (MSS) of TCP packets to the path MTU. This helps in situations where ICMP @@ -578,14 +483,12 @@ Fragmentation Needed or Packet too Big messages are dropped by firewalls. This option sets the level of compression used for UDP packets. Possible values are 0 (off), 1 (fast zlib) and any integer up to 9 (best zlib), 10 (fast lzo) and 11 (best lzo). -.It Va Digest Li = Ar digest Pq sha1 +.It Va Digest Li = Ar digest Pq sha256 The digest algorithm used to authenticate UDP packets. Any digest supported by LibreSSL or OpenSSL is recognised. Furthermore, specifying .Qq none will turn off packet authentication. -This option has no effect for connections between nodes using -.Va ExperimentalProtocol . .It Va IndirectData Li = yes | no Pq no When set to yes, only nodes which already have a meta connection to you will try to establish direct communication with you. @@ -595,28 +498,16 @@ The length of the message authentication code used to authenticate UDP packets. Can be anything from .Qq 0 up to the length of the digest produced by the digest algorithm. -This option has no effect for connections between nodes using -.Va ExperimentalProtocol . .It Va PMTU Li = Ar mtu Po 1514 Pc This option controls the initial path MTU to this node. .It Va PMTUDiscovery Li = yes | no Po yes Pc When this option is enabled, tinc will try to discover the path MTU to this node. After the path MTU has been discovered, it will be enforced on the VPN. -.It Va MTUInfoInterval Li = Ar seconds Pq 5 -The minimum amount of time between sending periodic updates about relay path MTU. Useful for quickly determining MTU to indirect nodes. .It Va Port Li = Ar port Pq 655 The port number on which this tinc daemon is listening for incoming connections, which is used if no port number is specified in an .Va Address statement. -.Pp -If this is set to zero, the port will be randomly assigned by the system. This is useful to randomize source ports of UDP packets, which can improve UDP hole punching reliability. When setting -.Va Port -to zero it is recommended to set -.Va AddressFamily -as well, otherwise -.Nm tinc -will assign different ports to different address families but other nodes can only know of one. .It Va PublicKey Li = Ar key Bq obsolete The public RSA key of this tinc daemon. It will be used to cryptographically verify it's identity and to set up a secure connection. @@ -651,7 +542,7 @@ IPv6 subnets are notated like fec0:0:0:1::/64. MAC addresses are notated like 0:1a:2b:3c:4d:5e. .Pp A Subnet can be given a weight to indicate its priority over identical Subnets -owned by different nodes. The default weight is 10. Lower values indicate +owned by different nodes. The default weight is 10. Lower values indicate higher priority. Packets will be sent to the node with the highest priority, unless that node is not reachable, in which case the node with the next highest priority will be tried, and so on. @@ -665,12 +556,6 @@ Setting this options also implicitly sets IndirectData. .Pp Since version 1.0.10, tinc will automatically detect whether communication via UDP is possible or not. -.It Va Weight Li = Ar weight -If this variable is set, it overrides the weight given to connections made with -another host. A higher -.Ar weight -means a lower priority is given to this connection when broadcasting or -forwarding packets. .El .Sh SCRIPTS Apart from reading the server and host configuration files, @@ -684,23 +569,17 @@ This guarantees that scripts will execute in the exact same order as the events If you need to run commands asynchronously, you have to ensure yourself that they are being run in the background. .Pp Under Windows (not Cygwin), the scripts must have the extension -.Pa .bat -or -.Pa .cmd . +.Pa .bat . .Bl -tag -width indent .It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /tinc-up This is the most important script. -If it is present it will be executed right after the tinc daemon has been started and has connected to the virtual network device (or when the first node becomes reachable if -.Va DeviceStandby -is used). +If it is present it will be executed right after the tinc daemon has been started and has connected to the virtual network device. It should be used to set up the corresponding network interface, but can also be used to start other things. .Pp Under Windows you can use the Network Connections control panel instead of creating this script. .It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /tinc-down -This script is started right before the tinc daemon quits (or when the last node becomes unreachable if -.Va DeviceStandby -is used). +This script is started right before the tinc daemon quits. .It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /hosts/ Ns Ar HOST Ns Pa -up This script is started when the tinc daemon with name .Ar HOST @@ -718,10 +597,6 @@ This script is started when a Subnet becomes reachable. The Subnet and the node it belongs to are passed in environment variables. .It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /subnet-down This script is started when a Subnet becomes unreachable. -.It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /invitation-created -This script is started when a new invitation has been created. -.It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /invitation-accepted -This script is started when an invitation has been used. .El .Pp The scripts are started without command line arguments, but can make use of certain environment variables. @@ -730,8 +605,6 @@ Under UNIX like operating systems the names of environment variables must be pre in scripts. Under Windows, in .Pa .bat -or -.Pa .cmd files, they have to be put between .Li % signs. @@ -757,14 +630,6 @@ When a host becomes (un)reachable, this is set to the port number it uses for co When a subnet becomes (un)reachable, this is set to the subnet. .It Ev WEIGHT When a subnet becomes (un)reachable, this is set to the subnet weight. -.It Ev INVITATION_FILE -When the -.Pa invitation-created -script is called, this is set to the file where the invitation details will be stored. -.It Ev INVITATION_URL -When the -.Pa invitation-created -script is called, this is set to the invitation URL that has been created. .El .Pp Do not forget that under UNIX operating systems, you have to make the scripts executable, using the command @@ -778,7 +643,7 @@ The top directory for configuration files. The default name of the server configuration file for net .Ar NETNAME . .It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /conf.d/ -Optional directory from which any .conf file will be loaded +Optional directory from which any *.conf file will be loaded .It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /hosts/ Host configuration files are kept in this directory. .It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /tinc-up @@ -789,14 +654,9 @@ It can be used to set up the corresponding network interface. If an executable file with this name exists, it will be executed right before the tinc daemon is going to close its connection to the virtual network device. -.It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /invitations/ -This directory contains outstanding invitations. -.It Pa @sysconfdir@/tinc/ Ns Ar NETNAME Ns Pa /invitation-data -After a successful join, this file contains a copy of the invitation data received. .El .Sh SEE ALSO .Xr tincd 8 , -.Xr tinc 8 , .Pa https://www.tinc-vpn.org/ , .Pa http://www.tldp.org/LDP/nag2/ . .Pp diff --git a/doc/tinc.info b/doc/tinc.info index 86f8682..44720f3 100644 --- a/doc/tinc.info +++ b/doc/tinc.info @@ -1,14 +1,14 @@ -This is tinc.info, produced by makeinfo version 6.5 from tinc.texi. +This is tinc.info, produced by makeinfo version 6.6 from tinc.texi. INFO-DIR-SECTION Networking tools START-INFO-DIR-ENTRY * tinc: (tinc). The tinc Manual. END-INFO-DIR-ENTRY -This is the info manual for tinc version 1.1pre17, a Virtual Private +This is the info manual for tinc version 1.0.36, a Virtual Private Network daemon. - Copyright (C) 1998-2018 Ivo Timmermans, Guus Sliepen + Copyright (C) 1998-2019 Ivo Timmermans, Guus Sliepen and Wessel Dankers . Permission is granted to make and distribute verbatim copies of this @@ -33,8 +33,6 @@ Top * Installation:: * Configuration:: * Running tinc:: -* Controlling tinc:: -* Invitations:: * Technical information:: * Platform specific information:: * About us:: @@ -50,13 +48,13 @@ Tinc is a Virtual Private Network (VPN) daemon that uses tunneling and encryption to create a secure private network between hosts on the Internet. -Because the tunnel appears to the IP level network code as a normal + Because the tunnel appears to the IP level network code as a normal network device, there is no need to adapt any existing software. The encrypted tunnels allows VPN sites to share information with each other over the Internet without exposing any information to others. -This document is the manual for tinc. Included are chapters on how to -configure your computer to use tinc, as well as the configuration + This document is the manual for tinc. Included are chapters on how +to configure your computer to use tinc, as well as the configuration process of tinc itself. * Menu: @@ -75,7 +73,7 @@ A Virtual Private Network or VPN is a network that can only be accessed by a few elected computers that participate. This goal is achievable in more than just one way. -Private networks can consist of a single stand-alone Ethernet LAN. Or + Private networks can consist of a single stand-alone Ethernet LAN. Or even two computers hooked up using a null-modem cable. In these cases, it is obvious that the network is _private_, no one can access it from the outside. But if your computers are linked to the Internet, the @@ -83,7 +81,7 @@ network is not private anymore, unless one uses firewalls to block all private traffic. But then, there is no way to send private data to trusted computers on the other end of the Internet. -This problem can be solved by using _virtual_ networks. Virtual + This problem can be solved by using _virtual_ networks. Virtual networks can live on top of other networks, but they use encapsulation to keep using their private address space so they do not interfere with the Internet. Mostly, virtual networks appear like a single LAN, even @@ -91,14 +89,14 @@ though they can span the entire world. But virtual networks can't be secured by using firewalls, because the traffic that flows through it has to go through the Internet, where other people can look at it. -As is the case with either type of VPN, anybody could eavesdrop. Or + As is the case with either type of VPN, anybody could eavesdrop. Or worse, alter data. Hence it's probably advisable to encrypt the data that flows over the network. -When one introduces encryption, we can form a true VPN. Other people may -see encrypted traffic, but if they don't know how to decipher it (they -need to know the key for that), they cannot read the information that -flows through the VPN. This is what tinc was made for. + When one introduces encryption, we can form a true VPN. Other people +may see encrypted traffic, but if they don't know how to decipher it +(they need to know the key for that), they cannot read the information +that flows through the VPN. This is what tinc was made for.  File: tinc.info, Node: tinc, Next: Supported platforms, Prev: Virtual Private Networks, Up: Introduction @@ -112,26 +110,26 @@ used the ethertap device that Linux knows of since somewhere about kernel 2.1.60. It didn't work immediately and he improved it a bit. At this stage, the project was still simply called "vpnd". -Since then, a lot has changed--to say the least. + Since then, a lot has changed--to say the least. -Tinc now supports encryption, it consists of a single daemon (tincd) for -both the receiving and sending end, it has become largely + Tinc now supports encryption, it consists of a single daemon (tincd) +for both the receiving and sending end, it has become largely runtime-configurable--in short, it has become a full-fledged professional package. -Tinc also allows more than two sites to connect to each other and form a -single VPN. Traditionally VPNs are created by making tunnels, which only -have two endpoints. Larger VPNs with more sites are created by adding -more tunnels. Tinc takes another approach: only endpoints are + Tinc also allows more than two sites to connect to each other and +form a single VPN. Traditionally VPNs are created by making tunnels, +which only have two endpoints. Larger VPNs with more sites are created +by adding more tunnels. Tinc takes another approach: only endpoints are specified, the software itself will take care of creating the tunnels. This allows for easier configuration and improved scalability. -A lot can--and will be--changed. We have a number of things that we + A lot can--and will be--changed. We have a number of things that we would like to see in the future releases of tinc. Not everything will be available in the near future. Our first objective is to make tinc work perfectly as it stands, and then add more advanced features. -Meanwhile, we're always open-minded towards new ideas. And we're + Meanwhile, we're always open-minded towards new ideas. And we're available too.  @@ -141,15 +139,15 @@ File: tinc.info, Node: Supported platforms, Prev: tinc, Up: Introduction ======================= Tinc has been verified to work under Linux, FreeBSD, OpenBSD, NetBSD, -MacOS/X (Darwin), Solaris, and Windows (both natively and in a Cygwin +Mac OS X (Darwin), Solaris, and Windows (both natively and in a Cygwin environment), with various hardware architectures. These are some of the platforms that are supported by the universal tun/tap device driver or other virtual network device drivers. Without such a driver, tinc will most likely compile and run, but it will not be able to send or receive data packets. -For an up to date list of supported platforms, please check the list on -our website: . + For an up to date list of supported platforms, please check the list +on our website: .  File: tinc.info, Node: Preparations, Next: Installation, Prev: Introduction, Up: Top @@ -178,7 +176,7 @@ File: tinc.info, Node: Configuring the kernel, Next: Libraries, Up: Preparati * Configuration of OpenBSD kernels:: * Configuration of NetBSD kernels:: * Configuration of Solaris kernels:: -* Configuration of Darwin (MacOS/X) kernels:: +* Configuration of Darwin (Mac OS X) kernels:: * Configuration of Windows::  @@ -196,11 +194,11 @@ Here are the options you have to turn on when configuring a new kernel: Network device support Universal tun/tap device driver support -It's not necessary to compile this driver as a module, even if you are -going to run more than one instance of tinc. + It's not necessary to compile this driver as a module, even if you +are going to run more than one instance of tinc. -If you decide to build the tun/tap driver as a kernel module, add these -lines to '/etc/modules.conf': + If you decide to build the tun/tap driver as a kernel module, add +these lines to '/etc/modules.conf': alias char-major-10-200 tun @@ -233,10 +231,10 @@ File: tinc.info, Node: Configuration of NetBSD kernels, Next: Configuration of For NetBSD version 1.5.2 and higher, the tun driver is included in the default kernel configuration. -Tunneling IPv6 may not work on NetBSD's tun device. + Tunneling IPv6 may not work on NetBSD's tun device.  -File: tinc.info, Node: Configuration of Solaris kernels, Next: Configuration of Darwin (MacOS/X) kernels, Prev: Configuration of NetBSD kernels, Up: Configuring the kernel +File: tinc.info, Node: Configuration of Solaris kernels, Next: Configuration of Darwin (Mac OS X) kernels, Prev: Configuration of NetBSD kernels, Up: Configuring the kernel 2.1.5 Configuration of Solaris kernels -------------------------------------- @@ -249,24 +247,24 @@ sparc64 architectures, precompiled versions can be found at header file is missing, install it from the source package.  -File: tinc.info, Node: Configuration of Darwin (MacOS/X) kernels, Next: Configuration of Windows, Prev: Configuration of Solaris kernels, Up: Configuring the kernel +File: tinc.info, Node: Configuration of Darwin (Mac OS X) kernels, Next: Configuration of Windows, Prev: Configuration of Solaris kernels, Up: Configuring the kernel -2.1.6 Configuration of Darwin (MacOS/X) kernels ------------------------------------------------ +2.1.6 Configuration of Darwin (Mac OS X) kernels +------------------------------------------------ Tinc on Darwin relies on a tunnel driver for its data acquisition from the kernel. OS X version 10.6.8 and later have a built-in tun driver called "utun". Tinc also supports the driver from , which supports both tun and tap -style devices, +style devices. -By default, tinc expects the tuntaposx driver to be installed. To use -the utun driver, set add 'Device = utunX' to 'tinc.conf', where X is the -desired number for the utun interface. You can also omit the number, in -which case the first free number will be chosen. + By default, tinc expects the tuntaposx driver to be installed. To +use the utun driver, set add 'Device = utunX' to 'tinc.conf', where X is +the desired number for the utun interface. You can also omit the +number, in which case the first free number will be chosen.  -File: tinc.info, Node: Configuration of Windows, Prev: Configuration of Darwin (MacOS/X) kernels, Up: Configuring the kernel +File: tinc.info, Node: Configuration of Windows, Prev: Configuration of Darwin (Mac OS X) kernels, Up: Configuring the kernel 2.1.7 Configuration of Windows ------------------------------ @@ -285,17 +283,15 @@ File: tinc.info, Node: Libraries, Prev: Configuring the kernel, Up: Preparati ============= Before you can configure or build tinc, you need to have the LibreSSL or -OpenSSL, zlib, LZO, curses and readline libraries installed on your -system. If you try to configure tinc without having them installed, -configure will give you an error message, and stop. +OpenSSL, zlib and lzo libraries installed on your system. If you try to +configure tinc without having them installed, configure will give you an +error message, and stop. * Menu: * LibreSSL/OpenSSL:: * zlib:: -* LZO:: -* libcurses:: -* libreadline:: +* lzo::  File: tinc.info, Node: LibreSSL/OpenSSL, Next: zlib, Up: Libraries @@ -306,25 +302,25 @@ File: tinc.info, Node: LibreSSL/OpenSSL, Next: zlib, Up: Libraries For all cryptography-related functions, tinc uses the functions provided by the LibreSSL or the OpenSSL library. -If this library is not installed, you will get an error when configuring -tinc for build. Support for running tinc with other cryptographic -libraries installed _may_ be added in the future. + If this library is not installed, you will get an error when +configuring tinc for build. Support for running tinc with other +cryptographic libraries installed _may_ be added in the future. -You can use your operating system's package manager to install this if -available. Make sure you install the development AND runtime versions -of this package. + You can use your operating system's package manager to install this +if available. Make sure you install the development AND runtime +versions of this package. -If your operating system comes neither with LibreSSL or OpenSSL, you + If your operating system comes neither with LibreSSL or OpenSSL, you have to install one manually. It is recommended that you get the latest -version of LibreSSL from . Instructions on +version of LibreSSL from . Instructions on how to configure, build and install this package are included within the package. Please make sure you build development and runtime libraries (which is the default). -If you installed the LibreSSL or OpenSSL libraries from source, it may -be necessary to let configure know where they are, by passing configure -one of the -with-openssl-* parameters. Note that you even have to use --with-openssl-* if you are using LibreSSL. + If you installed the LibreSSL or OpenSSL libraries from source, it +may be necessary to let configure know where they are, by passing +configure one of the -with-openssl-* parameters. Note that you even +have to use -with-openssl-* if you are using LibreSSL. --with-openssl=DIR LibreSSL/OpenSSL library and headers prefix --with-openssl-include=DIR LibreSSL/OpenSSL headers directory @@ -347,8 +343,8 @@ everyone to create a statically or dynamically linked executable: You may provide binary packages linked to the OpenSSL libraries, provided that all other requirements of the GPL are met. -Since the LZO library used by tinc is also covered by the GPL, we also -present the following exemption: + Since the LZO library used by tinc is also covered by the GPL, we +also present the following exemption: Hereby I grant a special exception to the tinc VPN project (https://www.tinc-vpn.org/) to link the LZO library with the @@ -357,7 +353,7 @@ present the following exemption: Markus F.X.J. Oberhumer  -File: tinc.info, Node: zlib, Next: LZO, Prev: LibreSSL/OpenSSL, Up: Libraries +File: tinc.info, Node: zlib, Next: lzo, Prev: LibreSSL/OpenSSL, Up: Libraries 2.2.2 zlib ---------- @@ -365,94 +361,47 @@ File: tinc.info, Node: zlib, Next: LZO, Prev: LibreSSL/OpenSSL, Up: Librarie For the optional compression of UDP packets, tinc uses the functions provided by the zlib library. -If this library is not installed, you will get an error when running the -configure script. You can either install the zlib library, or disable -support for zlib compression by using the "-disable-zlib" option when -running the configure script. Note that if you disable support for + If this library is not installed, you will get an error when running +the configure script. You can either install the zlib library, or +disable support for zlib compression by using the "-disable-zlib" option +when running the configure script. Note that if you disable support for zlib, the resulting binary will not work correctly on VPNs where zlib compression is used. -You can use your operating system's package manager to install this if -available. Make sure you install the development AND runtime versions -of this package. + You can use your operating system's package manager to install this +if available. Make sure you install the development AND runtime +versions of this package. -If you have to install zlib manually, you can get the source code from -. Instructions on how to configure, build and + If you have to install zlib manually, you can get the source code +from . Instructions on how to configure, build and install this package are included within the package. Please make sure you build development and runtime libraries (which is the default).  -File: tinc.info, Node: LZO, Next: libcurses, Prev: zlib, Up: Libraries +File: tinc.info, Node: lzo, Prev: zlib, Up: Libraries -2.2.3 LZO +2.2.3 lzo --------- Another form of compression is offered using the LZO library. -If this library is not installed, you will get an error when running the -configure script. You can either install the LZO library, or disable -support for LZO compression by using the "-disable-lzo" option when -running the configure script. Note that if you disable support for LZO, -the resulting binary will not work correctly on VPNs where LZO + If this library is not installed, you will get an error when running +the configure script. You can either install the LZO library, or +disable support for LZO compression by using the "-disable-lzo" option +when running the configure script. Note that if you disable support for +LZO, the resulting binary will not work correctly on VPNs where LZO compression is used. -You can use your operating system's package manager to install this if -available. Make sure you install the development AND runtime versions -of this package. + You can use your operating system's package manager to install this +if available. Make sure you install the development AND runtime +versions of this package. -If you have to install LZO manually, you can get the source code from + If you have to install lzo manually, you can get the source code from . Instructions on how to configure, build and install this package are included within the package. Please make sure you build development and runtime libraries (which is the default). - -File: tinc.info, Node: libcurses, Next: libreadline, Prev: LZO, Up: Libraries - -2.2.4 libcurses ---------------- - -For the "tinc top" command, tinc requires a curses library. - -If this library is not installed, you will get an error when running the -configure script. You can either install a suitable curses library, or -disable all functionality that depends on a curses library by using the -"-disable-curses" option when running the configure script. - -There are several curses libraries. It is recommended that you install -"ncurses" (), however other -curses libraries should also work. In particular, "PDCurses" -() is recommended if you want to -compile tinc for Windows. - -You can use your operating system's package manager to install this if -available. Make sure you install the development AND runtime versions -of this package. - - -File: tinc.info, Node: libreadline, Prev: libcurses, Up: Libraries - -2.2.5 libreadline ------------------ - -For the "tinc" command's shell functionality, tinc uses the readline -library. - -If this library is not installed, you will get an error when running the -configure script. You can either install a suitable readline library, -or disable all functionality that depends on a readline library by using -the "-disable-readline" option when running the configure script. - -You can use your operating system's package manager to install this if -available. Make sure you install the development AND runtime versions -of this package. - -If you have to install libreadline manually, you can get the source code -from . Instructions on how to -configure, build and install this package are included within the -package. Please make sure you build development and runtime libraries -(which is the default). -  File: tinc.info, Node: Installation, Next: Configuration, Prev: Preparations, Up: Top @@ -463,13 +412,13 @@ If you use Debian, you may want to install one of the precompiled packages for your system. These packages are equipped with system startup scripts and sample configurations. -If you cannot use one of the precompiled packages, or you want to + If you cannot use one of the precompiled packages, or you want to compile tinc for yourself, you can use the source. The source is distributed under the GNU General Public License (GPL). Download the source from the download page (https://www.tinc-vpn.org/download/). -Tinc comes in a convenient autoconf/automake package, which you can just -treat the same as any other package. Which is just untar it, type + Tinc comes in a convenient autoconf/automake package, which you can +just treat the same as any other package. Which is just untar it, type './configure' and then 'make'. More detailed instructions are in the file 'INSTALL', which is included in the source distribution. @@ -487,32 +436,33 @@ File: tinc.info, Node: Building and installing tinc, Next: System files, Up: Detailed instructions on configuring the source, building tinc and installing tinc can be found in the file called 'INSTALL'. -If you happen to have a binary package for tinc for your distribution, -you can use the package management tools of that distribution to install -tinc. The documentation that comes along with your distribution will -tell you how to do that. + If you happen to have a binary package for tinc for your +distribution, you can use the package management tools of that +distribution to install tinc. The documentation that comes along with +your distribution will tell you how to do that. * Menu: -* Darwin (MacOS/X) build environment:: +* Darwin (Mac OS X) build environment:: * Cygwin (Windows) build environment:: * MinGW (Windows) build environment::  -File: tinc.info, Node: Darwin (MacOS/X) build environment, Next: Cygwin (Windows) build environment, Up: Building and installing tinc +File: tinc.info, Node: Darwin (Mac OS X) build environment, Next: Cygwin (Windows) build environment, Up: Building and installing tinc -3.1.1 Darwin (MacOS/X) build environment ----------------------------------------- +3.1.1 Darwin (Mac OS X) build environment +----------------------------------------- In order to build tinc on Darwin, you need to install Xcode from . It might also help to install a recent version of Fink from . -You need to download and install LibreSSL (or OpenSSL) and LZO, either -directly from their websites (see *note Libraries::) or using Fink. + You need to download and install LibreSSL (or OpenSSL) and LZO, +either directly from their websites (see *note Libraries::) or using +Fink.  -File: tinc.info, Node: Cygwin (Windows) build environment, Next: MinGW (Windows) build environment, Prev: Darwin (MacOS/X) build environment, Up: Building and installing tinc +File: tinc.info, Node: Cygwin (Windows) build environment, Next: MinGW (Windows) build environment, Prev: Darwin (Mac OS X) build environment, Up: Building and installing tinc 3.1.2 Cygwin (Windows) build environment ---------------------------------------- @@ -520,7 +470,7 @@ File: tinc.info, Node: Cygwin (Windows) build environment, Next: MinGW (Window If Cygwin hasn't already been installed, install it directly from . -When tinc is compiled in a Cygwin environment, it can only be run in + When tinc is compiled in a Cygwin environment, it can only be run in this environment, but all programs, including those started outside the Cygwin environment, will be able to use the VPN. It will also support all features. @@ -535,10 +485,10 @@ You will need to install the MinGW environment from . You also need to download and install LibreSSL (or OpenSSL) and LZO. -When tinc is compiled using MinGW it runs natively under Windows, it is -not necessary to keep MinGW installed. + When tinc is compiled using MinGW it runs natively under Windows, it +is not necessary to keep MinGW installed. -When detaching, tinc will install itself as a service, which will be + When detaching, tinc will install itself as a service, which will be restarted automatically after reboots.  @@ -564,8 +514,8 @@ File: tinc.info, Node: Device files, Next: Other files, Up: System files Most operating systems nowadays come with the necessary device files by default, or they have a mechanism to create them on demand. -If you use Linux and do not have udev installed, you may need to create -the following device file if it does not exist: + If you use Linux and do not have udev installed, you may need to +create the following device file if it does not exist: mknod -m 600 /dev/net/tun c 10 200 @@ -606,6 +556,7 @@ File: tinc.info, Node: Configuration, Next: Running tinc, Prev: Installation, * Multiple networks:: * How connections work:: * Configuration files:: +* Generating keypairs:: * Network interfaces:: * Example configuration:: @@ -625,19 +576,13 @@ Do you want to run tinc in router mode or switch mode? These questions can only be answered by yourself, you will not find the answers in this documentation. Make sure you have an adequate understanding of networks in general. A good resource on networking is the Linux Network -Administrators Guide (https://www.tldp.org/LDP/nag2/). +Administrators Guide (http://www.tldp.org/LDP/nag2/). -If you have everything clearly pictured in your mind, proceed in the -following order: First, create the initial configuration files and -public/private keypairs using the following command: - tinc -n NETNAME init NAME -Second, use 'tinc -n NETNAME add ...' to further configure tinc. -Finally, export your host configuration file using 'tinc -n NETNAME -export' and send it to those people or computers you want tinc to -connect to. They should send you their host configuration file back, -which you can import using 'tinc -n NETNAME import'. - -These steps are described in the subsections below. + If you have everything clearly pictured in your mind, proceed in the +following order: First, generate the configuration files ('tinc.conf', +your host configuration file, 'tinc-up' and perhaps 'tinc-down'). Then +generate the keypairs. Finally, distribute the host configuration +files. These steps are described in the subsections below.  File: tinc.info, Node: Multiple networks, Next: How connections work, Prev: Configuration introduction, Up: Configuration @@ -648,25 +593,27 @@ File: tinc.info, Node: Multiple networks, Next: How connections work, Prev: C In order to allow you to run more than one tinc daemon on one computer, for instance if your computer is part of more than one VPN, you can assign a NETNAME to your VPN. It is not required if you only run one -tinc daemon, it doesn't even have to be the same on all the nodes of +tinc daemon, it doesn't even have to be the same on all the sites of your VPN, but it is recommended that you choose one anyway. -We will assume you use a netname throughout this document. This means -that you call tinc with the -n argument, which will specify the netname. + We will assume you use a netname throughout this document. This +means that you call tincd with the -n argument, which will assign a +netname to this daemon. -The effect of this option is that tinc will set its configuration root + The effect of this is that the daemon will set its configuration root to '/etc/tinc/NETNAME/', where NETNAME is your argument to the -n -option. You will also notice that log messages it appears in syslog as -coming from 'tinc.NETNAME', and on Linux, unless specified otherwise, -the name of the virtual network interface will be the same as the -network name. +option. You'll notice that it appears in syslog as 'tinc.NETNAME'. -However, it is not strictly necessary that you call tinc with the -n -option. If you do not use it, the network name will just be empty, and -tinc will look for files in '/etc/tinc/' instead of -'/etc/tinc/NETNAME/'; the configuration file will then be -'/etc/tinc/tinc.conf', and the host configuration files are expected to -be in '/etc/tinc/hosts/'. + However, it is not strictly necessary that you call tinc with the -n +option. In this case, the network name would just be empty, and it will +be used as such. tinc now looks for files in '/etc/tinc/', instead of +'/etc/tinc/NETNAME/'; the configuration file should be +'/etc/tinc/tinc.conf', and the host configuration files are now expected +to be in '/etc/tinc/hosts/'. + + But it is highly recommended that you use this feature of tinc, +because it will be so much clearer whom your daemon talks to. Hence, we +will assume that you use it.  File: tinc.info, Node: How connections work, Next: Configuration files, Prev: Multiple networks, Up: Configuration @@ -675,43 +622,25 @@ File: tinc.info, Node: How connections work, Next: Configuration files, Prev: ======================== When tinc starts up, it parses the command-line options and then reads -in the configuration file tinc.conf. It will then start listening for -incoming connection from other daemons, and will by default also -automatically try to connect to known peers. By default, tinc will try -to keep at least 3 working meta-connections alive at all times. +in the configuration file tinc.conf. If it sees one or more 'ConnectTo' +values pointing to other tinc daemons in that file, it will try to +connect to those other daemons. Whether this succeeds or not and +whether 'ConnectTo' is specified or not, tinc will listen for incoming +connection from other daemons. If you did specify a 'ConnectTo' value +and the other side is not responding, tinc will keep retrying. This +means that once started, tinc will stay running until you tell it to +stop, and failures to connect to other tinc daemons will not stop your +tinc daemon for trying again later. This means you don't have to +intervene if there are temporary network problems. -There is no real distinction between a server and a client in tinc. If -you wish, you can view a tinc daemon without a 'ConnectTo' statement in -tinc.conf and 'AutoConnect = no' as a server, and one which does have -one or more 'ConnectTo' statements or 'Autoconnect = yes' (which is the -default) as a client. It does not matter if two tinc daemons have a -'ConnectTo' value pointing to each other however. - -Connections specified using 'ConnectTo' are so-called meta-connections. -Tinc daemons exchange information about all other daemon they know about -via these meta-connections. After learning about all the daemons in the -VPN, tinc will create other connections as necessary in order to -communicate with them. For example, if there are three daemons named A, -B and C, and A has 'ConnectTo = B' in its tinc.conf file, and C has -'ConnectTo = B' in its tinc.conf file, then A will learn about C from B, -and will be able to exchange VPN packets with C without the need to have -'ConnectTo = C' in its tinc.conf file. - -It could be that some daemons are located behind a Network Address -Translation (NAT) device, or behind a firewall. In the above scenario -with three daemons, if A and C are behind a NAT, B will automatically -help A and C punch holes through their NAT, in a way similar to the STUN -protocol, so that A and C can still communicate with each other -directly. It is not always possible to do this however, and firewalls -might also prevent direct communication. In that case, VPN packets -between A and C will be forwarded by B. - -In effect, all nodes in the VPN will be able to talk to each other, as -long as there is a path of meta-connections between them, and whenever -possible, two nodes will communicate with each other directly. + There is no real distinction between a server and a client in tinc. +If you wish, you can view a tinc daemon without a 'ConnectTo' value as a +server, and one which does specify such a value as a client. It does +not matter if two tinc daemons have a 'ConnectTo' value pointing to each +other however.  -File: tinc.info, Node: Configuration files, Next: Network interfaces, Prev: How connections work, Up: Configuration +File: tinc.info, Node: Configuration files, Next: Generating keypairs, Prev: How connections work, Up: Configuration 4.4 Configuration files ======================= @@ -720,32 +649,29 @@ The actual configuration of the daemon is done in the file '/etc/tinc/NETNAME/tinc.conf' and at least one other file in the directory '/etc/tinc/NETNAME/hosts/'. -An optional directory '/etc/tinc/NETNAME/conf.d' can be added from which -any .conf file will be read. + An optional directory '/etc/tinc/NETNAME/conf.d' can be added from +which any .conf file will be read. -These file consists of comments (lines started with a #) or assignments -in the form of + These file consists of comments (lines started with a #) or +assignments in the form of Variable = Value. -The variable names are case insensitive, and any spaces, tabs, newlines -and carriage returns are ignored. Note: it is not required that you put -in the '=' sign, but doing so improves readability. If you leave it -out, remember to replace it with at least one space character. + The variable names are case insensitive, and any spaces, tabs, +newlines and carriage returns are ignored. Note: it is not required +that you put in the '=' sign, but doing so improves readability. If you +leave it out, remember to replace it with at least one space character. -The server configuration is complemented with host specific + The server configuration is complemented with host specific configuration (see the next section). Although all host configuration options for the local node listed in this document can also be put in '/etc/tinc/NETNAME/tinc.conf', it is recommended to put host specific configuration options in the host configuration file, as this makes it easy to exchange with other nodes. -You can edit the config file manually, but it is recommended that you -use the tinc command to change configuration variables for you. - -In the following two subsections all valid variables are listed in -alphabetical order. The default value is given between parentheses, -other comments are between square brackets. + In this section all valid variables are listed in alphabetical order. +The default value is given between parentheses, other comments are +between square brackets. * Menu: @@ -766,16 +692,18 @@ AddressFamily = (any) system both IPv4 and IPv6 or just IPv6 listening sockets will be created. -AutoConnect = (yes) - If set to yes, tinc will automatically set up meta connections to - other nodes, without requiring CONNECTTO variables. +BindToAddress =
[] [experimental] + If your computer has more than one IPv4 or IPv6 address, tinc will + by default listen on all of them for incoming connections. + Multiple BindToAddress variables may be specified, in which case + listening sockets for each specified address are made. -BindToAddress =
[] - This is the same as ListenAddress, however the address given with - the BindToAddress option will also be used for outgoing - connections. This is useful if your computer has more than one - IPv4 or IPv6 address, and you want tinc to only use a specific one - for outgoing packets. + If no PORT is specified, the socket will be bound to the port + specified by the Port option, or to port 655 if neither is given. + To only bind to a specific port but not to a specific address, use + "*" for the ADDRESS. + + This option may not work on all platforms. BindToInterface = [experimental] If you have more than one network interface in your computer, tinc @@ -783,9 +711,7 @@ BindToInterface = [experimental] is possible to bind tinc to a single interface like eth0 or ppp0 with this variable. - This option may not work on all platforms. Also, on some platforms - it will not actually bind to an interface, but rather to the - address that the interface has at the moment a socket is created. + This option may not work on all platforms. Broadcast = (mst) [experimental] This option selects the way broadcast packets are sent to other @@ -807,18 +733,6 @@ Broadcast = (mst) [experimental] broadcast packets will only be sent to nodes which we have a meta connection to. -BroadcastSubnet = ADDRESS[/PREFIXLENGTH] - Declares a broadcast subnet. Any packet with a destination address - falling into such a subnet will be routed as a broadcast (provided - all nodes have it declared). This is most useful to declare subnet - broadcast addresses (e.g. 10.42.255.255), otherwise tinc won't - know what to do with them. - - Note that global broadcast addresses (MAC ff:ff:ff:ff:ff:ff, IPv4 - 255.255.255.255), as well as multicast space (IPv4 224.0.0.0/4, - IPv6 ff00::/8) are always considered broadcast addresses and don't - need to be declared. - ConnectTo = Specifies which other tinc daemon to connect to on startup. Multiple ConnectTo variables may be specified, in which case @@ -826,9 +740,9 @@ ConnectTo = names should be known to this tinc daemon (i.e., there should be a host configuration file for the name on the ConnectTo line). - If you don't specify a host with ConnectTo and have disabled - AutoConnect, tinc won't try to connect to other daemons at all, and - will instead just listen for incoming connections. + If you don't specify a host with ConnectTo, tinc won't try to + connect to other daemons at all, and will instead just listen for + incoming connections. DecrementTTL = (no) [experimental] When enabled, tinc will decrement the Time To Live field in IPv4 @@ -841,17 +755,9 @@ DecrementTTL = (no) [experimental] Device = ('/dev/tap0', '/dev/net/tun' or other depending on platform) The virtual network device to use. Tinc will automatically detect - what kind of device it is. Note that you can only use one device - per daemon. Under Windows, use INTERFACE instead of DEVICE. Note - that you can only use one device per daemon. See also *note Device - files::. - -DeviceStandby = (no) - When disabled, tinc calls 'tinc-up' on startup, and 'tinc-down' on - shutdown. When enabled, tinc will only call 'tinc-up' when at - least one node is reachable, and will call 'tinc-down' as soon as - no nodes are reachable. On Windows, this also determines when the - virtual network interface "cable" is "plugged". + what kind of device it is. Under Windows, use INTERFACE instead of + DEVICE. Note that you can only use one device per daemon. See + also *note Device files::. DeviceType = (platform dependent) The type of the virtual network device. Tinc will normally @@ -883,11 +789,6 @@ DeviceType = (platform dependent) that this can cause decrypted VPN packets to be sent out on a real network if misconfigured. - fd - Use a file descriptor. All packets are read from this - interface. Packets received for the local node are written to - it. - uml (not compiled in by default) Create a UNIX socket with the filename specified by DEVICE, or '/var/run/NETNAME.umlsocket' if not specified. Tinc will wait @@ -935,17 +836,6 @@ DirectOnly = (no) [experimental] IndirectData option, packets for nodes for which we do not have a meta connection with are also dropped. -Ed25519PrivateKeyFile = ('/etc/tinc/NETNAME/ed25519_key.priv') - The file in which the private Ed25519 key of this tinc daemon - resides. This is only used if ExperimentalProtocol is enabled. - -ExperimentalProtocol = (yes) - When this option is enabled, the SPTPS protocol will be used when - connecting to nodes that also support it. Ephemeral ECDH will be - used for key exchanges, and Ed25519 will be used instead of RSA for - authentication. When enabled, an Ed25519 key must have been - generated before with 'tinc generate-ed25519-keys'. - Forwarding = (internal) [experimental] This option selects the way indirect packets are forwarded. @@ -961,18 +851,18 @@ Forwarding = (internal) [experimental] another forwarding mode, don't change it. kernel - Incoming packets using the legacy protocol are always sent to - the TUN/TAP device, even if the packets are not for the local - node. This is less efficient, but allows the kernel to apply - its routing and firewall rules on them, and can also help - debugging. Incoming packets using the SPTPS protocol are - dropped, since they are end-to-end encrypted. + Incoming packets are always sent to the TUN/TAP device, even + if the packets are not for the local node. This is less + efficient, but allows the kernel to apply its routing and + firewall rules on them, and can also help debugging. -FWMark = (0) [experimental] - When set to a non-zero value, all TCP and UDP sockets created by - tinc will use the given value as the firewall mark. This can be - used for mark-based routing or for packet filtering. This option - is currently only supported on Linux. +GraphDumpFile = [experimental] + If this option is present, tinc will dump the current network graph + to the file FILENAME every minute, unless there were no changes to + the graph. The file is in a format that can be read by graphviz + tools. If FILENAME starts with a pipe symbol |, then the rest of + the filename is interpreted as a shell command that is executed, + the graph is then sent to stdin. Hostnames = (no) This option selects whether IP addresses (both real and on the VPN) @@ -985,6 +875,9 @@ Hostnames = (no) configuration file, but whether hostnames should be resolved while logging. +IffOneQueue = (no) [experimental] + (Linux only) Set IFF_ONE_QUEUE flag on TUN/TAP devices. + Interface = Defines the name of the interface corresponding to the virtual network device. Depending on the operating system and the type of @@ -993,39 +886,38 @@ Interface = interface will be used. If you specified a Device, this variable is almost always already correctly set. -ListenAddress =
[] - If your computer has more than one IPv4 or IPv6 address, tinc will - by default listen on all of them for incoming connections. This - option can be used to restrict which addresses tinc listens on. - Multiple ListenAddress variables may be specified, in which case - listening sockets for each specified address are made. +KeyExpire = (3600) + This option controls the time the encryption keys used to encrypt + the data are valid. It is common practice to change keys at + regular intervals to make it even harder for crackers, even though + it is thought to be nearly impossible to crack a single key. - If no PORT is specified, the socket will listen on the port - specified by the Port option, or to port 655 if neither is given. - To only listen on a specific port but not to a specific address, - use "*" for the ADDRESS. - -LocalDiscovery = (no) +LocalDiscovery = (no) [experimental] When enabled, tinc will try to detect peers that are on the same local network. This will allow direct communication using LAN addresses, even if both peers are behind a NAT and they only ConnectTo a third node outside the NAT, which normally would prevent the peers from learning each other's LAN address. - Currently, local discovery is implemented by sending some packets - to the local address of the node during UDP discovery. This will - not work with old nodes that don't transmit their local address. + Currently, local discovery is implemented by sending broadcast + packets to the LAN during path MTU discovery. This feature may not + work in all possible situations. -LogLevel = (0) - This option controls the verbosity of the logging. See *note Debug - levels::. +MACExpire = (600) + This option controls the amount of time MAC addresses are kept + before they are removed. This only has effect when Mode is set to + "switch". + +MaxTimeout = (900) + This is the maximum delay before trying to reconnect to other tinc + daemons. Mode = (router) This option selects the way packets are routed to other daemons. router In this mode Subnet variables in the host configuration files - will be used to form a routing table. Only packets of + will be used to form a routing table. Only unicast packets of routable protocols (IPv4 and IPv6) are supported in this mode. This is the default mode, and unless you really know you need @@ -1047,30 +939,10 @@ Mode = (router) every packet will be broadcast to the other daemons while no routing table is managed. -InvitationExpire = (604800) - This option controls the time invitations are valid. - -KeyExpire = (3600) - This option controls the time the encryption keys used to encrypt - the data are valid. It is common practice to change keys at - regular intervals to make it even harder for crackers, even though - it is thought to be nearly impossible to crack a single key. - -MACExpire = (600) - This option controls the amount of time MAC addresses are kept - before they are removed. This only has effect when Mode is set to - "switch". - -MaxConnectionBurst = (100) - This option controls how many connections tinc accepts in quick - succession. If there are more connections than the given number in - a short time interval, tinc will reduce the number of accepted - connections to only one per second, until the burst has passed. - Name = [required] This is a symbolic name for this connection. The name must consist - only of alfanumeric and underscore characters (a-z, A-Z, 0-9 and - _), and is case sensitive. + only of alphanumeric and underscore characters (a-z, A-Z, 0-9 and + _). If Name starts with a $, then the contents of the environment variable that follows will be used. In that case, invalid @@ -1101,8 +973,8 @@ PrivateKey = [obsolete] PrivateKeyFile = ('/etc/tinc/NETNAME/rsa_key.priv') This is the full path name of the RSA private key file that was - generated by 'tinc generate-keys'. It must be a full path, not a - relative directory. + generated by 'tincd --generate-keys'. It must be a full path, not + a relative directory. ProcessPriority = When this option is used the priority of the tincd process will be @@ -1132,10 +1004,10 @@ Proxy = socks4 | socks5 | http | exec ... [experimental] connection. The environment variables 'NAME', 'NODE', 'REMOTEADDRES' and 'REMOTEPORT' are available. -ReplayWindow = (32) +ReplayWindow = (16) This is the size of the replay tracking window for each remote node, in bytes. The window is a bitfield which tracks 1 packet per - bit, so for example the default setting of 32 will track up to 256 + bit, so for example the default setting of 16 will track up to 128 packets in the window. In high bandwidth scenarios, setting this to a higher value can reduce packet loss from the interaction of replay tracking with underlying real packet loss and/or reordering. @@ -1157,63 +1029,15 @@ TunnelServer = (no) [experimental] '/etc/tinc/NETNAME/hosts/' directory. Setting this options also implicitly sets StrictSubnets. -UDPDiscovery = (yes) - When this option is enabled tinc will try to establish UDP - connectivity to nodes, using TCP while it determines if a node is - reachable over UDP. If it is disabled, tinc always assumes a node - is reachable over UDP. Note that tinc will never use UDP with nodes - that have TCPOnly enabled. - -UDPDiscoveryKeepaliveInterval = (9) - The minimum amount of time between sending UDP ping datagrams to - check UDP connectivity once it has been established. Note that - these pings are large, since they are used to verify link MTU as - well. - -UDPDiscoveryInterval = (2) - The minimum amount of time between sending UDP ping datagrams to - try to establish UDP connectivity. - -UDPDiscoveryTimeout = (30) - If tinc doesn't receive any UDP ping replies over the specified - interval, it will assume UDP communication is broken and will fall - back to TCP. - -UDPInfoInterval = (5) - The minimum amount of time between sending periodic updates about - UDP addresses, which are mostly useful for UDP hole punching. - -UDPRcvBuf = (1048576) +UDPRcvBuf = (OS default) Sets the socket receive buffer size for the UDP socket, in bytes. - If set to zero, the default buffer size will be used by the - operating system. Note: this setting can have a significant impact - on performance, especially raw throughput. + If unset, the default buffer size will be used by the operating + system. -UDPSndBuf = (1048576) +UDPSndBuf = Pq OS default Sets the socket send buffer size for the UDP socket, in bytes. If - set to zero, the default buffer size will be used by the operating - system. Note: this setting can have a significant impact on - performance, especially raw throughput. - -UPnP = (no) - If this option is enabled then tinc will search for UPnP-IGD - devices on the local network. It will then create and maintain - port mappings for tinc's listening TCP and UDP ports. If set to - "udponly", tinc will only create a mapping for its UDP (data) port, - not for its TCP (metaconnection) port. Note that tinc must have - been built with miniupnpc support for this feature to be available. - Furthermore, be advised that enabling this can have security - implications, because the miniupnpc library that tinc uses might - not be well-hardened with regard to malicious UPnP replies. - -UPnPDiscoverWait = (5) - The amount of time to wait for replies when probing the local - network for UPnP devices. - -UPnPRefreshPeriod = (5) - How often tinc will re-add the port mapping, in case it gets reset - on the UPnP device. This also controls the duration of the port - mapping itself, which will be set to twice that duration. + unset, the default buffer size will be used by the operating + system.  File: tinc.info, Node: Host configuration variables, Next: Scripts, Prev: Main configuration variables, Up: Configuration files @@ -1229,13 +1053,11 @@ Address = [] [recommended] can be specified, in which case each address will be tried until a working connection has been established. -Cipher = (blowfish) - The symmetric cipher algorithm used to encrypt UDP packets using - the legacy protocol. Any cipher supported by LibreSSL or OpenSSL - is recognized. Furthermore, specifying "none" will turn off packet - encryption. It is best to use only those ciphers which support CBC - mode. This option has no effect for connections using the SPTPS - protocol, which always use AES-256-CTR. +Cipher = (aes-256-cbc) + The symmetric cipher algorithm used to encrypt UDP packets. Any + cipher supported by LibreSSL or OpenSSL is recognized. + Furthermore, specifying "none" will turn off packet encryption. It + is best to use only those ciphers which support CBC mode. ClampMSS = (yes) This option specifies whether tinc should clamp the maximum segment @@ -1246,26 +1068,25 @@ ClampMSS = (yes) Compression = (0) This option sets the level of compression used for UDP packets. Possible values are 0 (off), 1 (fast zlib) and any integer up to 9 - (best zlib), 10 (fast LZO) and 11 (best LZO). + (best zlib), 10 (fast lzo) and 11 (best lzo). -Digest = (sha1) - The digest algorithm used to authenticate UDP packets using the - legacy protocol. Any digest supported by LibreSSL or OpenSSL is - recognized. Furthermore, specifying "none" will turn off packet - authentication. This option has no effect for connections using - the SPTPS protocol, which always use HMAC-SHA-256. +Digest = (sha256) + The digest algorithm used to authenticate UDP packets. Any digest + supported by LibreSSL or OpenSSL is recognized. Furthermore, + specifying "none" will turn off packet authentication. IndirectData = (no) - When set to yes, other nodes which do not already have a meta - connection to you will not try to establish direct communication - with you. It is best to leave this option out or set it to no. + This option specifies whether other tinc daemons besides the one + you specified with ConnectTo can make a direct connection to you. + This is especially useful if you are behind a firewall and it is + impossible to make a connection from the outside to your tinc + daemon. Otherwise, it is best to leave this option out or set it + to no. MACLength = (4) The length of the message authentication code used to authenticate - UDP packets using the legacy protocol. Can be anything from 0 up - to the length of the digest produced by the digest algorithm. This - option has no effect for connections using the SPTPS protocol, - which never truncate MACs. + UDP packets. Can be anything from 0 up to the length of the digest + produced by the digest algorithm. PMTU = (1514) This option controls the initial path MTU to this node. @@ -1275,11 +1096,6 @@ PMTUDiscovery = (yes) to this node. After the path MTU has been discovered, it will be enforced on the VPN. -MTUInfoInterval = (5) - The minimum amount of time between sending periodic updates about - relay path MTU. Useful for quickly determining MTU to indirect - nodes. - Port = (655) This is the port this tinc daemon listens on. You can use decimal portnumbers or symbolic names (as listed in '/etc/services'). @@ -1289,8 +1105,8 @@ PublicKey = [obsolete] PublicKeyFile = [obsolete] This is the full path name of the RSA public key file that was - generated by 'tinc generate-keys'. It must be a full path, not a - relative directory. + generated by 'tincd --generate-keys'. It must be a full path, not + a relative directory. From version 1.0pre4 on tinc will store the public key directly into the host configuration file in PEM format, the above two @@ -1328,18 +1144,15 @@ Subnet = reachable, in which case the node with the next highest priority will be tried, and so on. -TCPonly = (no) +TCPonly = (no) [deprecated] If this variable is set to yes, then the packets are tunnelled over a TCP connection instead of a UDP connection. This is especially useful for those who want to run a tinc daemon from behind a masquerading firewall, or if UDP packet routing is disabled somehow. Setting this options also implicitly sets IndirectData. -Weight = - If this variable is set, it overrides the weight given to - connections made with another host. A higher weight means a lower - priority is given to this connection when broadcasting or - forwarding packets. + Since version 1.0.10, tinc will automatically detect whether + communication via UDP is possible or not.  File: tinc.info, Node: Scripts, Next: How to configure, Prev: Host configuration variables, Up: Configuration files @@ -1352,14 +1165,13 @@ also run scripts at certain moments. Below is a list of filenames of scripts and a description of when they are run. A script is only run if it exists and if it is executable. -Scripts are run synchronously; this means that tinc will temporarily + Scripts are run synchronously; this means that tinc will temporarily stop processing packets until the called script finishes executing. This guarantees that scripts will execute in the exact same order as the events that trigger them. If you need to run commands asynchronously, you have to ensure yourself that they are being run in the background. -Under Windows (not Cygwin), the scripts should have the extension '.bat' -or '.cmd'. + Under Windows (not Cygwin), the scripts must have the extension .bat. '/etc/tinc/NETNAME/tinc-up' This is the most important script. If it is present it will be @@ -1389,23 +1201,16 @@ or '.cmd'. This script is started when any host becomes unreachable. '/etc/tinc/NETNAME/subnet-up' - This script is started when a Subnet becomes reachable. The Subnet + This script is started when a subnet becomes reachable. The Subnet and the node it belongs to are passed in environment variables. '/etc/tinc/NETNAME/subnet-down' - This script is started when a Subnet becomes unreachable. + This script is started when a subnet becomes unreachable. -'/etc/tinc/NETNAME/invitation-created' - This script is started when a new invitation has been created. - -'/etc/tinc/NETNAME/invitation-accepted' - This script is started when an invitation has been used. - -The scripts are started without command line arguments, but can make use -of certain environment variables. Under UNIX like operating systems the -names of environment variables must be preceded by a $ in scripts. -Under Windows, in '.bat' or '.cmd' files, they have to be put between % -signs. + The scripts are started without command line arguments, but can make +use of certain environment variables. Under UNIX like operating systems +the names of environment variables must be preceded by a $ in scripts. +Under Windows, in '.bat' files, they have to be put between % signs. 'NETNAME' If a netname was specified, this environment variable contains it. @@ -1439,162 +1244,95 @@ signs. When a subnet becomes (un)reachable, this is set to the subnet weight. -'INVITATION_FILE' - When the 'invitation-created' script is called, this is set to the - file where the invitation details will be stored. - -'INVITATION_URL' - When the 'invitation-created' script is called, this is set to the - invitation URL that has been created. - -Do not forget that under UNIX operating systems, you have to make the -scripts executable, using the command 'chmod a+x script'. -  File: tinc.info, Node: How to configure, Prev: Scripts, Up: Configuration files 4.4.4 How to configure ---------------------- -Step 1. Creating initial configuration files. -............................................. - -The initial directory structure, configuration files and public/private -keypairs are created using the following command: - - tinc -n NETNAME init NAME - -(You will need to run this as root, or use "sudo".) This will create -the configuration directory '/etc/tinc/NETNAME.', and inside it will -create another directory named 'hosts/'. In the configuration -directory, it will create the file 'tinc.conf' with the following -contents: - - Name = NAME - -It will also create private RSA and Ed25519 keys, which will be stored -in the files 'rsa_key.priv' and 'ed25519_key.priv'. It will also create -a host configuration file 'hosts/NAME', which will contain the -corresponding public RSA and Ed25519 keys. - -Finally, on UNIX operating systems, it will create an executable script -'tinc-up', which will initially not do anything except warning that you -should edit it. - -Step 2. Modifying the initial configuration. +Step 1. Creating the main configuration file ............................................ -Unless you want to use tinc in switch mode, you should now configure -which range of addresses you will use on the VPN. Let's assume you will -be part of a VPN which uses the address range 192.168.0.0/16, and you -yourself have a smaller portion of that range: 192.168.2.0/24. Then you -should run the following command: +The main configuration file will be called +'/etc/tinc/NETNAME/tinc.conf'. Adapt the following example to create a +basic configuration file: - tinc -n NETNAME add subnet 192.168.2.0/24 + Name = YOURNAME + Device = /dev/tap0 -This will add a Subnet statement to your host configuration file. Try -opening the file '/etc/tinc/NETNAME/hosts/NAME' in an editor. You -should now see a file containing the public RSA and Ed25519 keys (which -looks like a bunch of random characters), and the following line at the -bottom: + Then, if you know to which other tinc daemon(s) yours is going to +connect, add 'ConnectTo' values. - Subnet = 192.168.2.0/24 +Step 2. Creating your host configuration file +............................................. -If you will use more than one address range, you can add more Subnets. -For example, if you also use the IPv6 subnet fec0:0:0:2::/64, you can -add it as well: +If you added a line containing 'Name = yourname' in the main +configuration file, you will need to create a host configuration file +'/etc/tinc/NETNAME/hosts/yourname'. Adapt the following example to +create a host configuration file: - tinc -n NETNAME add subnet fec0:0:0:2::/24 + Address = your.real.hostname.org + Subnet = 192.168.1.0/24 -This will add another line to the file 'hosts/NAME'. If you make a -mistake, you can undo it by simply using 'del' instead of 'add'. - -If you want other tinc daemons to create meta-connections to your -daemon, you should add your public IP address or hostname to your host -configuration file. For example, if your hostname is foo.example.org, -run: - - tinc -n NETNAME add address foo.example.org - -Step 2. Exchanging configuration files. -....................................... - -In order for two tinc daemons to be able to connect to each other, they -each need the other's host configuration files. So if you want foo to -be able to connect with bar, You should send 'hosts/NAME' to bar, and -bar should send you his file which you should move to 'hosts/bar'. If -you are on a UNIX platform, you can easily send an email containing the -necessary information using the following command (assuming the owner of -bar has the email address bar@example.org): - - tinc -n NETNAME export | mail -s "My config file" bar@example.org - -If the owner of bar does the same to send his host configuration file to -you, you can probably pipe his email through the following command, or -you can just start this command in a terminal and copy&paste the email: - - tinc -n NETNAME import - -If you are the owner of bar yourself, and you have SSH access to that -computer, you can also swap the host configuration files using the -following command: - - tinc -n NETNAME export \ - | ssh bar.example.org tinc -n NETNAME exchange \ - | tinc -n NETNAME import - -You can repeat this for a few other nodes as well. It is not necessary -to manually exchange host config files between all nodes; after the -initial connections are made tinc will learn about all the other nodes -in the VPN, and will automatically make other connections as necessary. + You can also use an IP address instead of a hostname. The 'Subnet' +specifies the address range that is local for _your part of the VPN +only_. If you have multiple address ranges you can specify more than +one 'Subnet'. You might also need to add a 'Port' if you want your tinc +daemon to run on a different port number than the default (655).  -File: tinc.info, Node: Network interfaces, Next: Example configuration, Prev: Configuration files, Up: Configuration +File: tinc.info, Node: Generating keypairs, Next: Network interfaces, Prev: Configuration files, Up: Configuration -4.5 Network interfaces +4.5 Generating keypairs +======================= + +Now that you have already created the main configuration file and your +host configuration file, you can easily create a public/private keypair +by entering the following command: + + tincd -n NETNAME -K + + Tinc will generate a public and a private key and ask you where to +put them. Just press enter to accept the defaults. + + +File: tinc.info, Node: Network interfaces, Next: Example configuration, Prev: Generating keypairs, Up: Configuration + +4.6 Network interfaces ====================== Before tinc can start transmitting data over the tunnel, it must set up the virtual network interface. -First, decide which IP addresses you want to have associated with these -devices, and what network mask they must have. + First, decide which IP addresses you want to have associated with +these devices, and what network mask they must have. -Tinc will open a virtual network device ('/dev/tun', '/dev/tap0' or + Tinc will open a virtual network device ('/dev/tun', '/dev/tap0' or similar), which will also create a network interface called something like 'tun0', 'tap0'. If you are using the Linux tun/tap driver, the network interface will by default have the same name as the NETNAME. Under Windows you can change the name of the network interface from the Network Connections control panel. -You can configure the network interface by putting ordinary ifconfig, + You can configure the network interface by putting ordinary ifconfig, route, and other commands to a script named '/etc/tinc/NETNAME/tinc-up'. When tinc starts, this script will be executed. When tinc exits, it will execute the script named '/etc/tinc/NETNAME/tinc-down', but -normally you don't need to create that script. You can manually open -the script in an editor, or use the following command: +normally you don't need to create that script. - tinc -n NETNAME edit tinc-up - -An example 'tinc-up' script, that would be appropriate for the scenario -in the previous section, is: + An example 'tinc-up' script: #!/bin/sh - ifconfig $INTERFACE 192.168.2.1 netmask 255.255.0.0 - ip addr add fec0:0:0:2::/48 dev $INTERFACE + ifconfig $INTERFACE 192.168.1.1 netmask 255.255.0.0 -The first command gives the interface an IPv4 address and a netmask. -The kernel will also automatically add an IPv4 route to this interface, -so normally you don't need to add route commands to the 'tinc-up' -script. The kernel will also bring the interface up after this command. -The netmask is the mask of the _entire_ VPN network, not just your own -subnet. The second command gives the interface an IPv6 address and -netmask, which will also automatically add an IPv6 route. If you only -want to use "ip addr" commands on Linux, don't forget that it doesn't -bring the interface up, unlike ifconfig, so you need to add 'ip link set -$INTERFACE up' in that case. + This script gives the interface an IP address and a netmask. The +kernel will also automatically add a route to this interface, so +normally you don't need to add route commands to the 'tinc-up' script. +The kernel will also bring the interface up after this command. The +netmask is the mask of the _entire_ VPN network, not just your own +subnet. -The exact syntax of the ifconfig and route commands differs from + The exact syntax of the ifconfig and route commands differs from platform to platform. You can look up the commands for setting addresses and adding routes in *note Platform specific information::, but it is best to consult the manpages of those utilities on your @@ -1603,56 +1341,52 @@ platform.  File: tinc.info, Node: Example configuration, Prev: Network interfaces, Up: Configuration -4.6 Example configuration +4.7 Example configuration ========================= Imagine the following situation. Branch A of our example 'company' wants to connect three branch offices in B, C and D using the Internet. All four offices have a 24/7 connection to the Internet. -A is going to serve as the center of the network. B and C will connect -to A, and D will connect to C. Each office will be assigned their own IP -network, 10.x.0.0. + A is going to serve as the center of the network. B and C will +connect to A, and D will connect to C. Each office will be assigned +their own IP network, 10.x.0.0. A: net 10.1.0.0 mask 255.255.0.0 gateway 10.1.54.1 internet IP 1.2.3.4 B: net 10.2.0.0 mask 255.255.0.0 gateway 10.2.1.12 internet IP 2.3.4.5 C: net 10.3.0.0 mask 255.255.0.0 gateway 10.3.69.254 internet IP 3.4.5.6 D: net 10.4.0.0 mask 255.255.0.0 gateway 10.4.3.32 internet IP 4.5.6.7 -Here, "gateway" is the VPN IP address of the machine that is running the -tincd, and "internet IP" is the IP address of the firewall, which does -not need to run tincd, but it must do a port forwarding of TCP and UDP -on port 655 (unless otherwise configured). + Here, "gateway" is the VPN IP address of the machine that is running +the tincd, and "internet IP" is the IP address of the firewall, which +does not need to run tincd, but it must do a port forwarding of TCP and +UDP on port 655 (unless otherwise configured). -In this example, it is assumed that eth0 is the interface that points to -the inner (physical) LAN of the office, although this could also be the -same as the interface that leads to the Internet. The configuration of -the real interface is also shown as a comment, to give you an idea of + In this example, it is assumed that eth0 is the interface that points +to the inner (physical) LAN of the office, although this could also be +the same as the interface that leads to the Internet. The configuration +of the real interface is also shown as a comment, to give you an idea of how these example host is set up. All branches use the netname 'company' for this particular VPN. -Each branch is set up using the 'tinc init' and 'tinc config' commands, -here we just show the end results: - For Branch A ............ _BranchA_ would be configured like this: -In '/etc/tinc/company/tinc-up': - - #!/bin/sh + In '/etc/tinc/company/tinc-up': # Real interface of internal network: # ifconfig eth0 10.1.54.1 netmask 255.255.0.0 ifconfig $INTERFACE 10.1.54.1 netmask 255.0.0.0 -and in '/etc/tinc/company/tinc.conf': + and in '/etc/tinc/company/tinc.conf': Name = BranchA + Device = /dev/tap0 -On all hosts, '/etc/tinc/company/hosts/BranchA' contains: + On all hosts, '/etc/tinc/company/hosts/BranchA' contains: Subnet = 10.1.0.0/16 Address = 1.2.3.4 @@ -1661,32 +1395,32 @@ On all hosts, '/etc/tinc/company/hosts/BranchA' contains: ... -----END RSA PUBLIC KEY----- -Note that the IP addresses of eth0 and the VPN interface are the same. -This is quite possible, if you make sure that the netmasks of the -interfaces are different. It is in fact recommended to give both real -internal network interfaces and VPN interfaces the same IP address, -since that will make things a lot easier to remember and set up. + Note that the IP addresses of eth0 and tap0 are the same. This is +quite possible, if you make sure that the netmasks of the interfaces are +different. It is in fact recommended to give both real internal network +interfaces and tap interfaces the same IP address, since that will make +things a lot easier to remember and set up. For Branch B ............ In '/etc/tinc/company/tinc-up': - #!/bin/sh - # Real interface of internal network: # ifconfig eth0 10.2.43.8 netmask 255.255.0.0 ifconfig $INTERFACE 10.2.1.12 netmask 255.0.0.0 -and in '/etc/tinc/company/tinc.conf': + and in '/etc/tinc/company/tinc.conf': Name = BranchB + ConnectTo = BranchA -Note here that the internal address (on eth0) doesn't have to be the -same as on the VPN interface. + Note here that the internal address (on eth0) doesn't have to be the +same as on the tap0 device. Also, ConnectTo is given so that this node +will always try to connect to BranchA. -On all hosts, in '/etc/tinc/company/hosts/BranchB': + On all hosts, in '/etc/tinc/company/hosts/BranchB': Subnet = 10.2.0.0/16 Address = 2.3.4.5 @@ -1700,22 +1434,22 @@ For Branch C In '/etc/tinc/company/tinc-up': - #!/bin/sh - # Real interface of internal network: # ifconfig eth0 10.3.69.254 netmask 255.255.0.0 ifconfig $INTERFACE 10.3.69.254 netmask 255.0.0.0 -and in '/etc/tinc/company/tinc.conf': + and in '/etc/tinc/company/tinc.conf': Name = BranchC + ConnectTo = BranchA + Device = /dev/tap1 -C already has another daemon that runs on port 655, so they have to + C already has another daemon that runs on port 655, so they have to reserve another port for tinc. It knows the portnumber it has to listen on from it's own host configuration file. -On all hosts, in '/etc/tinc/company/hosts/BranchC': + On all hosts, in '/etc/tinc/company/hosts/BranchC': Address = 3.4.5.6 Subnet = 10.3.0.0/16 @@ -1730,21 +1464,24 @@ For Branch D In '/etc/tinc/company/tinc-up': - #!/bin/sh - # Real interface of internal network: # ifconfig eth0 10.4.3.32 netmask 255.255.0.0 ifconfig $INTERFACE 10.4.3.32 netmask 255.0.0.0 -and in '/etc/tinc/company/tinc.conf': + and in '/etc/tinc/company/tinc.conf': Name = BranchD + ConnectTo = BranchC + Device = /dev/net/tun -D will be connecting to C, which has a tincd running for this network on -port 2000. It knows the port number from the host configuration file. + D will be connecting to C, which has a tincd running for this network +on port 2000. It knows the port number from the host configuration +file. Also note that since D uses the tun/tap driver, the network +interface will not be called 'tun' or 'tap0' or something like that, but +will have the same name as netname. -On all hosts, in '/etc/tinc/company/hosts/BranchD': + On all hosts, in '/etc/tinc/company/hosts/BranchD': Subnet = 10.4.0.0/16 Address = 4.5.6.7 @@ -1756,12 +1493,16 @@ On all hosts, in '/etc/tinc/company/hosts/BranchD': Key files ......... -A, B, C and D all have their own public/private keypairs: +A, B, C and D all have generated a public/private keypair with the +following command: -The private RSA key is stored in '/etc/tinc/company/rsa_key.priv', the -private Ed25519 key is stored in '/etc/tinc/company/ed25519_key.priv', -and the public RSA and Ed25519 keys are put into the host configuration -file in the '/etc/tinc/company/hosts/' directory. + tincd -n company -K + + The private key is stored in '/etc/tinc/company/rsa_key.priv', the +public key is put into the host configuration file in the +'/etc/tinc/company/hosts/' directory. During key generation, tinc +automatically guesses the right filenames based on the -n option and the +Name directive in the 'tinc.conf' file (if it is available). Starting ........ @@ -1773,7 +1514,7 @@ have started their daemons, tinc will try connecting until they are available.  -File: tinc.info, Node: Running tinc, Next: Controlling tinc, Prev: Configuration, Up: Top +File: tinc.info, Node: Running tinc, Next: Technical information, Prev: Configuration, Up: Top 5 Running tinc ************** @@ -1781,12 +1522,12 @@ File: tinc.info, Node: Running tinc, Next: Controlling tinc, Prev: Configurat If everything else is done, you can start tinc by typing the following command: - tinc -n NETNAME start + tincd -n NETNAME -Tinc will detach from the terminal and continue to run in the background -like a good daemon. If there are any problems however you can try to -increase the debug level and look in the syslog to find out what the -problems are. + Tinc will detach from the terminal and continue to run in the +background like a good daemon. If there are any problems however you +can try to increase the debug level and look in the syslog to find out +what the problems are. * Menu: @@ -1818,15 +1559,25 @@ command line options. Set debug level to LEVEL. The higher the debug level, the more gets logged. Everything goes via syslog. +'-k, --kill[=SIGNAL]' + Attempt to kill a running tincd (optionally with the specified + SIGNAL instead of SIGTERM) and exit. Use it in conjunction with + the -n option to make sure you kill the right tinc daemon. Under + native Windows the optional argument is ignored, the service will + always be stopped and removed. + '-n, --net=NETNAME' Use configuration for net NETNAME. This will let tinc read all configuration files from '/etc/tinc/NETNAME/'. Specifying . for NETNAME is the same as not specifying any NETNAME. *Note Multiple networks::. -'--pidfile=FILENAME' - Store a cookie in FILENAME which allows tinc to authenticate. If - unspecified, the default is '/var/run/tinc.NETNAME.pid'. +'-K, --generate-keys[=BITS]' + Generate public/private keypair of BITS length. If BITS is not + specified, 2048 is the default. tinc will ask where you want to + store the files, but will default to the configuration directory + (you can use the -c or -n option in combination with -K). After + that, tinc will quit. '-o, --option=[HOST.]KEY=VALUE' Without specifying a HOST, this will set server configuration @@ -1840,8 +1591,6 @@ command line options. shared private keys to be written to the system swap files/partitions. - This option is not supported on all platforms. - '--logfile[=FILE]' Write log entries to a file instead of to the system logging facility. If FILE is omitted, the default is @@ -1871,14 +1620,11 @@ command line options. you must ensure the appropriate shell is also installed in the chroot, along with all its dependencies. - This option is not supported on all platforms. '-U, --user=USER' Switch to the given USER after initialization, at the same time as chroot is performed (see -chroot above). With this option tinc drops privileges, for added security. - This option is not supported on all platforms. - '--help' Display a short reminder of these runtime options and terminate. @@ -1907,6 +1653,20 @@ You can also send the following signals to a running tincd process: used, this will also close and reopen the log file, useful when log rotation is used. +'INT' + Temporarily increases debug level to 5. Send this signal again to + revert to the original level. + +'USR1' + Dumps the connection list to syslog. + +'USR2' + Dumps virtual network device statistics, all known nodes, edges and + subnets to syslog. + +'WINCH' + Purges all information remembered about unreachable nodes. +  File: tinc.info, Node: Debug levels, Next: Solving problems, Prev: Signals, Up: Running tinc @@ -1953,7 +1713,7 @@ directly see everything tinc logs: tincd -n NETNAME -d5 -D -If tinc does not log any error messages, then you might want to check + If tinc does not log any error messages, then you might want to check the following things: * 'tinc-up' script Does this script contain the right commands? @@ -1972,7 +1732,9 @@ the following things: it, make sure that it forwards TCP and UDP traffic to port 655 to the host running tinc. You can add 'TCPOnly = yes' to your host config file to force tinc to only use a single TCP connection, this - works through most firewalls and NATs. + works through most firewalls and NATs. Since version 1.0.10, tinc + will automatically fall back to TCP if direct communication via UDP + is not possible.  File: tinc.info, Node: Error messages, Next: Sending bug reports, Prev: Solving problems, Up: Running tinc @@ -2063,11 +1825,6 @@ high enough. * If you see this only sporadically, it is harmless and caused by a node sending packets using an old key. - * If you see this often and another node is not reachable - anymore, then a NAT (masquerading firewall) is changing the - source address of UDP packets. You can add 'TCPOnly = yes' to - host configuration files to force all VPN traffic to go over a - TCP connection. 'Got bad/bogus/unauthorized REQUEST from foo (1.2.3.4 port 12345)' @@ -2101,508 +1858,9 @@ bugreport: ping or traceroute).  -File: tinc.info, Node: Controlling tinc, Next: Invitations, Prev: Running tinc, Up: Top +File: tinc.info, Node: Technical information, Next: Platform specific information, Prev: Running tinc, Up: Top -6 Controlling tinc -****************** - -You can start, stop, control and inspect a running tincd through the -tinc command. A quick example: - - tinc -n NETNAME reload - -If tinc is started without a command, it will act as a shell; it will -display a prompt, and commands can be entered on the prompt. If tinc is -compiled with libreadline, history and command completion are available -on the prompt. One can also pipe a script containing commands through -tinc. In that case, lines starting with a # symbol will be ignored. - -* Menu: - -* tinc runtime options:: -* tinc environment variables:: -* tinc commands:: -* tinc examples:: -* tinc top:: - - -File: tinc.info, Node: tinc runtime options, Next: tinc environment variables, Up: Controlling tinc - -6.1 tinc runtime options -======================== - -'-c, --config=PATH' - Read configuration options from the directory PATH. The default is - '/etc/tinc/NETNAME/'. - -'-n, --net=NETNAME' - Use configuration for net NETNAME. *Note Multiple networks::. - -'--pidfile=FILENAME' - Use the cookie from FILENAME to authenticate with a running tinc - daemon. If unspecified, the default is - '/var/run/tinc.NETNAME.pid'. - -'-b, --batch' - Don't ask for anything (non-interactive mode). - -'--force' - Force some commands to work despite warnings. - -'--help' - Display a short reminder of runtime options and commands, then - terminate. - -'--version' - Output version information and exit. - - -File: tinc.info, Node: tinc environment variables, Next: tinc commands, Prev: tinc runtime options, Up: Controlling tinc - -6.2 tinc environment variables -============================== - -'NETNAME' - If no netname is specified on the command line with the '-n' - option, the value of this environment variable is used. - - -File: tinc.info, Node: tinc commands, Next: tinc examples, Prev: tinc environment variables, Up: Controlling tinc - -6.3 tinc commands -================= - -'init [NAME]' - Create initial configuration files and RSA and Ed25519 keypairs - with default length. If no NAME for this node is given, it will be - asked for. - -'get VARIABLE' - Print the current value of configuration variable VARIABLE. If - more than one variable with the same name exists, the value of each - of them will be printed on a separate line. - -'set VARIABLE VALUE' - Set configuration variable VARIABLE to the given VALUE. All - previously existing configuration variables with the same name are - removed. To set a variable for a specific host, use the notation - HOST.VARIABLE. - -'add VARIABLE VALUE' - As above, but without removing any previously existing - configuration variables. If the variable already exists with the - given value, nothing happens. - -'del VARIABLE [VALUE]' - Remove configuration variables with the same name and VALUE. If no - VALUE is given, all configuration variables with the same name will - be removed. - -'edit FILENAME' - Start an editor for the given configuration file. You do not need - to specify the full path to the file. - -'export' - Export the host configuration file of the local node to standard - output. - -'export-all' - Export all host configuration files to standard output. - -'import' - Import host configuration file(s) generated by the tinc export - command from standard input. Already existing host configuration - files are not overwritten unless the option -force is used. - -'exchange' - The same as export followed by import. - -'exchange-all' - The same as export-all followed by import. - -'invite NAME' - Prepares an invitation for a new node with the given NAME, and - prints a short invitation URL that can be used with the join - command. - -'join [URL]' - Join an existing VPN using an invitation URL created using the - invite command. If no URL is given, it will be read from standard - input. - -'start [tincd options]' - Start 'tincd', optionally with the given extra options. - -'stop' - Stop 'tincd'. - -'restart [tincd options]' - Restart 'tincd', optionally with the given extra options. - -'reload' - Partially rereads configuration files. Connections to hosts whose - host config files are removed are closed. New outgoing connections - specified in 'tinc.conf' will be made. - -'pid' - Shows the PID of the currently running 'tincd'. - -'generate-keys [BITS]' - Generate both RSA and Ed25519 keypairs (see below) and exit. tinc - will ask where you want to store the files, but will default to the - configuration directory (you can use the -c or -n option). - -'generate-ed25519-keys' - Generate public/private Ed25519 keypair and exit. - -'generate-rsa-keys [BITS]' - Generate public/private RSA keypair and exit. If BITS is omitted, - the default length will be 2048 bits. When saving keys to existing - files, tinc will not delete the old keys; you have to remove them - manually. - -'dump [reachable] nodes' - Dump a list of all known nodes in the VPN. If the reachable keyword - is used, only lists reachable nodes. - -'dump edges' - Dump a list of all known connections in the VPN. - -'dump subnets' - Dump a list of all known subnets in the VPN. - -'dump connections' - Dump a list of all meta connections with ourself. - -'dump graph | digraph' - Dump a graph of the VPN in dotty format. Nodes are colored - according to their reachability: red nodes are unreachable, orange - nodes are indirectly reachable, green nodes are directly reachable. - Black nodes are either directly or indirectly reachable, but direct - reachability has not been tried yet. - -'dump invitations' - Dump a list of outstanding invitations. The filename of the - invitation, as well as the name of the node that is being invited - is shown for each invitation. - -'info NODE | SUBNET | ADDRESS' - Show information about a particular NODE, SUBNET or ADDRESS. If an - ADDRESS is given, any matching subnet will be shown. - -'purge' - Purges all information remembered about unreachable nodes. - -'debug LEVEL' - Sets debug level to LEVEL. - -'log [LEVEL]' - Capture log messages from a running tinc daemon. An optional debug - level can be given that will be applied only for log messages sent - to tinc. - -'retry' - Forces tinc to try to connect to all uplinks immediately. Usually - tinc attempts to do this itself, but increases the time it waits - between the attempts each time it failed, and if tinc didn't - succeed to connect to an uplink the first time after it started, it - defaults to the maximum time of 15 minutes. - -'disconnect NODE' - Closes the meta connection with the given NODE. - -'top' - If tinc is compiled with libcurses support, this will display live - traffic statistics for all the known nodes, similar to the UNIX top - command. See below for more information. - -'pcap' - Dump VPN traffic going through the local tinc node in pcap-savefile - format to standard output, from where it can be redirected to a - file or piped through a program that can parse it directly, such as - tcpdump. - -'network [NETNAME]' - If NETNAME is given, switch to that network. Otherwise, display a - list of all networks for which configuration files exist. - -'fsck' - This will check the configuration files for possible problems, such - as unsafe file permissions, missing executable bit on script, - unknown and obsolete configuration variables, wrong public and/or - private keys, and so on. - - When problems are found, this will be printed on a line with - WARNING or ERROR in front of it. Most problems must be corrected - by the user itself, however in some cases (like file permissions - and missing public keys), tinc will ask if it should fix the - problem. - -'sign [FILENAME]' - Sign a file with the local node's private key. If no FILENAME is - given, the file is read from standard input. The signed file is - written to standard output. - -'verify NAME [FILENAME]' - - Check the signature of a file against a node's public key. The - NAME of the node must be given, or can be "." to check against the - local node's public key, or "*" to allow a signature from any node - whose public key is known. If no FILENAME is given, the file is - read from standard input. If the verification is successful, a - copy of the input with the signature removed is written to standard - output, and the exit code will be zero. If the verification - failed, nothing will be written to standard output, and the exit - code will be non-zero. - - -File: tinc.info, Node: tinc examples, Next: tinc top, Prev: tinc commands, Up: Controlling tinc - -6.4 tinc examples -================= - -Examples of some commands: - - tinc -n vpn dump graph | circo -Txlib - tinc -n vpn pcap | tcpdump -r - - tinc -n vpn top - -Examples of changing the configuration using tinc: - - tinc -n vpn init foo - tinc -n vpn add Subnet 192.168.1.0/24 - tinc -n vpn add bar.Address bar.example.com - tinc -n vpn set Mode switch - tinc -n vpn export | gpg --clearsign | mail -s "My config" vpnmaster@example.com - - -File: tinc.info, Node: tinc top, Prev: tinc examples, Up: Controlling tinc - -6.5 tinc top -============ - -The top command connects to a running tinc daemon and repeatedly queries -its per-node traffic counters. It displays a list of all the known -nodes in the left-most column, and the amount of bytes and packets read -from and sent to each node in the other columns. By default, the -information is updated every second. The behaviour of the top command -can be changed using the following keys: - - - Change the interval between updates. After pressing the key, - enter the desired interval in seconds, followed by enter. - Fractional seconds are honored. Intervals lower than 0.1 seconds - are not allowed. - - - Toggle between displaying current traffic rates (in packets and - bytes per second) and cumulative traffic (total packets and bytes - since the tinc daemon started). - - - Sort the list of nodes by name. - - - Sort the list of nodes by incoming amount of bytes. - - - Sort the list of nodes by incoming amount of packets. - - - Sort the list of nodes by outgoing amount of bytes. - - - Sort the list of nodes by outgoing amount of packets. - - - Sort the list of nodes by sum of incoming and outgoing amount of - bytes. - - - Sort the list of nodes by sum of incoming and outgoing amount of - packets. - - - Show amount of traffic in bytes. - - - Show amount of traffic in kilobytes. - - - Show amount of traffic in megabytes. - - - Show amount of traffic in gigabytes. - - - Quit. - - -File: tinc.info, Node: Invitations, Next: Technical information, Prev: Controlling tinc, Up: Top - -7 Invitations -************* - -Invitations are an easy way to add new nodes to an existing VPN. -Invitations can be created on an existing node using the 'tinc invite' -command, which generates a relatively short URL which can be given to -someone else, who uses the 'tinc join' command to automatically set up -tinc so it can connect to the inviting node. The next sections describe -how invitations actually work, and how to further automate the -invitations. - -* Menu: - -* How invitations work:: -* Invitation file format:: -* Writing an invitation-created script:: - - -File: tinc.info, Node: How invitations work, Next: Invitation file format, Up: Invitations - -7.1 How invitations work -======================== - -When an invitation is created on a node (which from now on we will call -the server) using the 'tinc invite' command, an invitation file is -created that contains all the information necessary for the invitee -(which we will call the client) to create its configuration files. The -invitation file is stays on the server, but a URL is generated that has -enough information for the client to contact the server and to retrieve -the invitation file. The whole URL is around 80 characters long and -looks like this: - - server.example.org:12345/cW1NhLHS-1WPFlcFio8ztYHvewTTKYZp8BjEKg3vbMtDz7w4 - -It is composed of four parts: - - hostname : port / keyhash cookie - -The hostname and port tell the client how to reach the tinc daemon on -the server. The part after the slash looks like one blob, but is -composed of two parts. The keyhash is the hash of the public key of the -server. The cookie is a shared secret that identifies the client to the -server. - -When the client connects to the server in order to join the VPN, the -client and server will exchange temporary public keys. The client -verifies that the hash of the server's public key matches the keyhash -from the invitation URL. If not, it will immediately exit with an error. -Otherwise, an ECDH exchange will happen so the client and server can -communicate privately with each other. The client will then present the -cookie to the server. The server uses this to look up the corresponding -invitation file it generated earlier. If it exists, it will send the -invitation file to the client. The client will also create a permanent -public key, and send it to the server. After the exchange is completed, -the connection is broken. The server creates a host config file for the -client containing the client's permanent public key, and the client -creates tinc.conf, host config files and possibly a tinc-up script based -on the information in the invitation file. - -It is important that the invitation URL is kept secret until it is used; -if another person gets a copy of the invitation URL before the real -client runs the 'tinc join' command, then that other person can try to -join the VPN. - - -File: tinc.info, Node: Invitation file format, Next: Writing an invitation-created script, Prev: How invitations work, Up: Invitations - -7.2 Invitation file format -========================== - -The contents of an invitation file that is generated by the 'tinc -invite' command looks like this: - - Name = client - Netname = vpn - ConnectTo = server - #-------------------------------------# - Name = server - Ed25519PublicKey = augbnwegoij123587... - Address = server.example.com - -The file is basically a concatenation of several host config blocks. -Each host config block starts with 'Name = ...'. Lines that look like -'#---#' are not important, it just makes it easier for humans to read -the file. However, the first line of an invitation file _must_ always -start with 'Name = ...'. - -The first host config block is always the one representing the invitee. -So the first Name statement determines the name that the invitee will -get. From the first block, the 'tinc.conf' and 'hosts/client' files -will be generated; the 'tinc join' command on the client will -automatically separate statements based on whether they should be in -'tinc.conf' or in a host config file. Some statements are special and -are treated differently: - -Netname = - This is a hint to the invitee which netname to use for the VPN. It - is used if the invitee did not already specify a netname, and if - there is no pre-existing configuration with the same netname. - -Ifconfig = - This is a hint for generating a 'tinc-up' script. If an address is - specified, a command will be added to 'tinc-up' so the VPN - interface will be configured to have the given address. If it is - the word "dhcp", a command will be added to start a DHCP client on - the VPN interface. If it is the word dhcpv6, it will be a DHCPv6 - client. If it is "slaac", then it will add commands to enable IPv6 - stateless address autoconfiguration. It is also possible to - specify a MAC address, in which case a command will be added to set - the MAC address of the VPN interface. - - The exact commands added to the 'tinc-up' script depends on the - operating system the client is using. Multiple Ifconfig statements - can be specified, however one should only use one Ifconfig - statement per address family. - -Route = [] - This is a hint for generating a 'tinc-up' script. Route statements - are similar to Ifconfig statements, but add routes instead of - addresses. These only allow IPv4 and IPv6 routes. If no gateway - address is specified, the route is directed to the VPN interface. - In general, a gateway is only necessary when running tinc in switch - mode. - -Subsequent host config blocks are copied verbatim into their respective -files in 'hosts/'. The invitation file generated by 'tinc invite' will -normally only contain two blocks; one for the client and one for the -server. - - -File: tinc.info, Node: Writing an invitation-created script, Prev: Invitation file format, Up: Invitations - -7.3 Writing an invitation-created script -======================================== - -When an invitation is generated, the "invitation-created" script is -called (if it exists) right after the invitation file is written, but -before the URL has been written to stdout. This allows one to change -the invitation file automatically before the invitation URL is passed to -the invitee. Here is an example shell script that approximately -recreates the default invitation file: - - #!/bin/sh - - cat >$INVITATION_FILE <>$INVITATION_FILE - -You can add more ConnectTo statements, and change 'tinc export' to 'tinc -export-all' for example. But you can also use the script to -automatically hand out a Subnet to the invitee. Note that the script -doesn't have to be a shell script, you can use any language, it just has -to be executable. - - -File: tinc.info, Node: Technical information, Next: Platform specific information, Prev: Invitations, Up: Top - -8 Technical information +6 Technical information *********************** * Menu: @@ -2614,7 +1872,7 @@ File: tinc.info, Node: Technical information, Next: Platform specific informat  File: tinc.info, Node: The connection, Next: The meta-protocol, Up: Technical information -8.1 The connection +6.1 The connection ================== Tinc is a daemon that takes VPN data and transmit that to another host @@ -2628,7 +1886,7 @@ computer over the existing Internet infrastructure.  File: tinc.info, Node: The UDP tunnel, Next: The meta-connection, Up: The connection -8.1.1 The UDP tunnel +6.1.1 The UDP tunnel -------------------- The data itself is read from a character device file, the so-called @@ -2640,43 +1898,43 @@ are point-to-point devices which can only handle IPv4 and/or IPv6 packets, and 'tap' style, which are Ethernet devices and handle complete Ethernet frames. -So when tinc reads an Ethernet frame from the device, it determines its -type. When tinc is in it's default routing mode, it can handle IPv4 and -IPv6 packets. Depending on the Subnet lines, it will send the packets -off to their destination IP address. In the 'switch' and 'hub' mode, -tinc will use broadcasts and MAC address discovery to deduce the + So when tinc reads an Ethernet frame from the device, it determines +its type. When tinc is in its default routing mode, it can handle IPv4 +and IPv6 packets. Depending on the Subnet lines, it will send the +packets off to their destination IP address. In the 'switch' and 'hub' +mode, tinc will use broadcasts and MAC address discovery to deduce the destination of the packets. Since the latter modes only depend on the link layer information, any protocol that runs over Ethernet is supported (for instance IPX and Appletalk). However, only 'tap' style devices provide this information. -After the destination has been determined, the packet will be compressed -(optionally), a sequence number will be added to the packet, the packet -will then be encrypted and a message authentication code will be -appended. + After the destination has been determined, the packet will be +compressed (optionally), a sequence number will be added to the packet, +the packet will then be encrypted and a message authentication code will +be appended. -When that is done, time has come to actually transport the packet to the -destination computer. We do this by sending the packet over an UDP + When that is done, time has come to actually transport the packet to +the destination computer. We do this by sending the packet over an UDP connection to the destination host. This is called _encapsulating_, the VPN packet (though now encrypted) is encapsulated in another IP datagram. -When the destination receives this packet, the same thing happens, only -in reverse. So it checks the message authentication code, decrypts the -contents of the UDP datagram, checks the sequence number and writes the -decrypted information to its own virtual network device. + When the destination receives this packet, the same thing happens, +only in reverse. So it checks the message authentication code, decrypts +the contents of the UDP datagram, checks the sequence number and writes +the decrypted information to its own virtual network device. -If the virtual network device is a 'tun' device (a point-to-point + If the virtual network device is a 'tun' device (a point-to-point tunnel), there is no problem for the kernel to accept a packet. However, if it is a 'tap' device (this is the only available type on FreeBSD), the destination MAC address must match that of the virtual -network interface. If tinc is in it's default routing mode, ARP does -not work, so the correct destination MAC can not be known by the sending +network interface. If tinc is in its default routing mode, ARP does not +work, so the correct destination MAC can not be known by the sending host. Tinc solves this by letting the receiving end detect the MAC address of its own virtual network interface and overwriting the destination MAC address of the received packet. -In switch or hub modes ARP does work so the sender already knows the + In switch or hub modes ARP does work so the sender already knows the correct destination MAC address. In those modes every interface should have a unique MAC address, so make sure they are not the same. Because switch and hub modes rely on MAC addresses to function correctly, these @@ -2686,28 +1944,28 @@ a 'tap' style virtual network device: NetBSD, Darwin and Solaris.  File: tinc.info, Node: The meta-connection, Prev: The UDP tunnel, Up: The connection -8.1.2 The meta-connection +6.1.2 The meta-connection ------------------------- Having only a UDP connection available is not enough. Though suitable for transmitting data, we want to be able to reliably send other information, such as routing and session key information to somebody. -TCP is a better alternative, because it already contains protection + TCP is a better alternative, because it already contains protection against information being lost, unlike UDP. -So we establish two connections. One for the encrypted VPN data, and + So we establish two connections. One for the encrypted VPN data, and one for other information, the meta-data. Hence, we call the second connection the meta-connection. We can now be sure that the meta-information doesn't get lost on the way to another computer. -Like with any communication, we must have a protocol, so that everybody -knows what everything stands for, and how she should react. Because we -have two connections, we also have two protocols. The protocol used for -the UDP data is the "data-protocol," the other one is the -"meta-protocol." + Like with any communication, we must have a protocol, so that +everybody knows what everything stands for, and how she should react. +Because we have two connections, we also have two protocols. The +protocol used for the UDP data is the "data-protocol," the other one is +the "meta-protocol." -The reason we don't use TCP for both protocols is that UDP is much + The reason we don't use TCP for both protocols is that UDP is much better for encapsulation, even while it is less reliable. The real problem is that when TCP would be used to encapsulate a TCP stream that's on the private network, for every packet sent there would be @@ -2718,24 +1976,24 @@ re-sending packets.  File: tinc.info, Node: The meta-protocol, Next: Security, Prev: The connection, Up: Technical information -8.2 The meta-protocol +6.2 The meta-protocol ===================== The meta protocol is used to tie all tinc daemons together, and exchange information about which tinc daemon serves which virtual subnet. -The meta protocol consists of requests that can be sent to the other + The meta protocol consists of requests that can be sent to the other side. Each request has a unique number and several parameters. All requests are represented in the standard ASCII character set. It is possible to use tools such as telnet or netcat to connect to a tinc daemon started with the -bypass-security option and to read and write requests by hand, provided that one understands the numeric codes sent. -The authentication scheme is described in *note Security::. After a -successful authentication, the server and the client will exchange all -the information about other tinc daemons and subnets they know of, so -that both sides (and all the other tinc daemons behind them) have their -information synchronised. + The authentication scheme is described in *note Authentication +protocol::. After a successful authentication, the server and the +client will exchange all the information about other tinc daemons and +subnets they know of, so that both sides (and all the other tinc daemons +behind them) have their information synchronised. message ------------------------------------------------------------------ @@ -2753,13 +2011,13 @@ information synchronised. +------------------> owner of this subnet ------------------------------------------------------------------ -The ADD_EDGE messages are to inform other tinc daemons that a connection -between two nodes exist. The address of the destination node is -available so that VPN packets can be sent directly to that node. + The ADD_EDGE messages are to inform other tinc daemons that a +connection between two nodes exist. The address of the destination node +is available so that VPN packets can be sent directly to that node. -The ADD_SUBNET messages inform other tinc daemons that certain subnets -belong to certain nodes. tinc will use it to determine to which node a -VPN packet has to be sent. + The ADD_SUBNET messages inform other tinc daemons that certain +subnets belong to certain nodes. tinc will use it to determine to which +node a VPN packet has to be sent. message ------------------------------------------------------------------ @@ -2773,10 +2031,10 @@ VPN packet has to be sent. +------------------> owner of this subnet ------------------------------------------------------------------ -In case a connection between two daemons is closed or broken, DEL_EDGE -messages are sent to inform the other daemons of that fact. Each daemon -will calculate a new route to the the daemons, or mark them unreachable -if there isn't any. + In case a connection between two daemons is closed or broken, +DEL_EDGE messages are sent to inform the other daemons of that fact. +Each daemon will calculate a new route to the the daemons, or mark them +unreachable if there isn't any. message ------------------------------------------------------------------ @@ -2796,20 +2054,20 @@ if there isn't any. +--> daemon that has changed it's packet key ------------------------------------------------------------------ -The keys used to encrypt VPN packets are not sent out directly. This is -because it would generate a lot of traffic on VPNs with many daemons, + The keys used to encrypt VPN packets are not sent out directly. This +is because it would generate a lot of traffic on VPNs with many daemons, and chances are that not every tinc daemon will ever send a packet to every other daemon. Instead, if a daemon needs a key it sends a request for it via the meta connection of the nearest hop in the direction of the destination. - daemon message + daemon message ------------------------------------------------------------------ - origin PING - dest. PONG + origin PING + dest. PONG ------------------------------------------------------------------ -There is also a mechanism to check if hosts are still alive. Since + There is also a mechanism to check if hosts are still alive. Since network failures or a crash can cause a daemon to be killed without properly shutting down the TCP connection, this is necessary to keep an up to date connection list. PINGs are sent at regular intervals, except @@ -2818,12 +2076,12 @@ data) is added with each PING and PONG message, to make sure that long sequences of PING/PONG messages without any other traffic won't result in known plaintext. -This basically covers what is sent over the meta connection by tinc. + This basically covers what is sent over the meta connection by tinc.  File: tinc.info, Node: Security, Prev: The meta-protocol, Up: Technical information -8.3 Security +6.3 Security ============ Tinc got its name from "TINC," short for _There Is No Cabal_; the @@ -2831,33 +2089,33 @@ alleged Cabal was/is an organisation that was said to keep an eye on the entire Internet. As this is exactly what you _don't_ want, we named the tinc project after TINC. -But in order to be "immune" to eavesdropping, you'll have to encrypt + But in order to be "immune" to eavesdropping, you'll have to encrypt your data. Because tinc is a _Secure_ VPN (SVPN) daemon, it does -exactly that: encrypt. However, encryption in itself does not prevent -an attacker from modifying the encrypted data. Therefore, tinc also -authenticates the data. Finally, tinc uses sequence numbers (which -themselves are also authenticated) to prevent an attacker from replaying -valid packets. - -Since version 1.1pre3, tinc has two protocols used to protect your data; -the legacy protocol, and the new Simple Peer-to-Peer Security (SPTPS) -protocol. The SPTPS protocol is designed to address some weaknesses in -the legacy protocol. The new authentication protocol is used when two -nodes connect to each other that both have the ExperimentalProtocol -option set to yes, otherwise the legacy protocol will be used. +exactly that: encrypt. Tinc by default uses blowfish encryption with +128 bit keys in CBC mode, 32 bit sequence numbers and 4 byte long +message authentication codes to make sure eavesdroppers cannot get and +cannot change any information at all from the packets they can +intercept. The encryption algorithm and message authentication +algorithm can be changed in the configuration. The length of the +message authentication codes is also adjustable. The length of the key +for the encryption algorithm is always the default length used by +LibreSSL/OpenSSL. * Menu: -* Legacy authentication protocol:: -* Simple Peer-to-Peer Security:: +* Authentication protocol:: * Encryption of network packets:: * Security issues::  -File: tinc.info, Node: Legacy authentication protocol, Next: Simple Peer-to-Peer Security, Up: Security +File: tinc.info, Node: Authentication protocol, Next: Encryption of network packets, Up: Security -8.3.1 Legacy authentication protocol ------------------------------------- +6.3.1 Authentication protocol +----------------------------- + +A new scheme for authentication in tinc has been devised, which offers +some improvements over the protocol used in 1.0pre2 and 1.0pre3. +Explanation is below. daemon message -------------------------------------------------------------------------- @@ -2865,46 +2123,28 @@ File: tinc.info, Node: Legacy authentication protocol, Next: Simple Peer-to-Pe server - client ID client 17.2 - | | +-> minor protocol version - | +----> major protocol version - +--------> name of tinc daemon + client ID client 12 + | +---> version + +-------> name of tinc daemon - server ID server 17.2 - | | +-> minor protocol version - | +----> major protocol version - +--------> name of tinc daemon + server ID server 12 + | +---> version + +-------> name of tinc daemon - client META_KEY 94 64 0 0 5f0823a93e35b69e...7086ec7866ce582b - | | | | \_________________________________/ - | | | | +-> RSAKEYLEN bits totally random string S1, - | | | | encrypted with server's public RSA key - | | | +-> compression level - | | +---> MAC length - | +------> digest algorithm NID - +---------> cipher algorithm NID + client META_KEY 5f0823a93e35b69e...7086ec7866ce582b + \_________________________________/ + +-> RSAKEYLEN bits totally random string S1, + encrypted with server's public RSA key - server META_KEY 94 64 0 0 6ab9c1640388f8f0...45d1a07f8a672630 - | | | | \_________________________________/ - | | | | +-> RSAKEYLEN bits totally random string S2, - | | | | encrypted with client's public RSA key - | | | +-> compression level - | | +---> MAC length - | +------> digest algorithm NID - +---------> cipher algorithm NID - -------------------------------------------------------------------------- + server META_KEY 6ab9c1640388f8f0...45d1a07f8a672630 + \_________________________________/ + +-> RSAKEYLEN bits totally random string S2, + encrypted with client's public RSA key -The protocol allows each side to specify encryption algorithms and -parameters, but in practice they are always fixed, since older versions -of tinc did not allow them to be different from the default values. The -cipher is always Blowfish in OFB mode, the digest is SHA1, but the MAC -length is zero and no compression is used. + From now on: + - the client will symmetrically encrypt outgoing traffic using S1 + - the server will symmetrically encrypt outgoing traffic using S2 -From now on: - * the client will symmetrically encrypt outgoing traffic using S1 - * the server will symmetrically encrypt outgoing traffic using S2 - - -------------------------------------------------------------------------- client CHALLENGE da02add1817c1920989ba6ae2a49cecbda0 \_________________________________/ +-> CHALLEN bits totally random string H1 @@ -2924,204 +2164,74 @@ From now on: client ACK 655 123 0 | | +-> options - | +----> estimated weight - +--------> listening port of client + | +----> estimated weight + +--------> listening port of client server ACK 655 321 0 | | +-> options - | +----> estimated weight - +--------> listening port of server + | +----> estimated weight + +--------> listening port of server -------------------------------------------------------------------------- -This legacy authentication protocol has several weaknesses, pointed out -by security export Peter Gutmann. First, data is encrypted with RSA -without padding. Padding schemes are designed to prevent attacks when -the size of the plaintext is not equal to the size of the RSA key. Tinc -always encrypts random nonces that have the same size as the RSA key, so -we do not believe this leads to a break of the security. There might be -timing or other side-channel attacks against RSA encryption and -decryption, tinc does not employ any protection against those. -Furthermore, both sides send identical messages to each other, there is -no distinction between server and client, which could make a MITM attack -easier. However, no exploit is known in which a third party who is not -already trusted by other nodes in the VPN could gain access. Finally, -the RSA keys are used to directly encrypt the session keys, which means -that if the RSA keys are compromised, it is possible to decrypt all -previous VPN traffic. In other words, the legacy protocol does not -provide perfect forward secrecy. + This new scheme has several improvements, both in efficiency and +security. + + First of all, the server sends exactly the same kind of messages over +the wire as the client. The previous versions of tinc first +authenticated the client, and then the server. This scheme even allows +both sides to send their messages simultaneously, there is no need to +wait for the other to send something first. This means that any +calculations that need to be done upon sending or receiving a message +can also be done in parallel. This is especially important when doing +RSA encryption/decryption. Given that these calculations are the main +part of the CPU time spent for the authentication, speed is improved by +a factor 2. + + Second, only one RSA encrypted message is sent instead of two. This +reduces the amount of information attackers can see (and thus use for a +cryptographic attack). It also improves speed by a factor two, making +the total speedup a factor 4. + + Third, and most important: The symmetric cipher keys are exchanged +first, the challenge is done afterwards. In the previous authentication +scheme, because a man-in-the-middle could pass the challenge/chal_reply +phase (by just copying the messages between the two real tinc daemons), +but no information was exchanged that was really needed to read the rest +of the messages, the challenge/chal_reply phase was of no real use. The +man-in-the-middle was only stopped by the fact that only after the ACK +messages were encrypted with the symmetric cipher. Potentially, it +could even send it's own symmetric key to the server (if it knew the +server's public key) and read some of the metadata the server would send +it (it was impossible for the mitm to read actual network packets +though). The new scheme however prevents this. + + This new scheme makes sure that first of all, symmetric keys are +exchanged. The rest of the messages are then encrypted with the +symmetric cipher. Then, each side can only read received messages if +they have their private key. The challenge is there to let the other +side know that the private key is really known, because a challenge +reply can only be sent back if the challenge is decrypted correctly, and +that can only be done with knowledge of the private key. + + Fourth: the first thing that is sent via the symmetric cipher +encrypted connection is a totally random string, so that there is no +known plaintext (for an attacker) in the beginning of the encrypted +stream.  -File: tinc.info, Node: Simple Peer-to-Peer Security, Next: Encryption of network packets, Prev: Legacy authentication protocol, Up: Security +File: tinc.info, Node: Encryption of network packets, Next: Security issues, Prev: Authentication protocol, Up: Security -8.3.2 Simple Peer-to-Peer Security ----------------------------------- - -The SPTPS protocol is designed to address the weaknesses in the legacy -protocol. SPTPS is based on TLS 1.2, but has been simplified: there is -no support for exchanging public keys, and there is no cipher suite -negotiation. Instead, SPTPS always uses a very strong cipher suite: -peers authenticate each other using 521 bits ECC keys, Diffie-Hellman -using ephemeral 521 bits ECC keys is used to provide perfect forward -secrecy (PFS), AES-256-CTR is used for encryption, and HMAC-SHA-256 for -message authentication. - -Similar to TLS, messages are split up in records. A complete logical -record contains the following information: - - * uint32_t seqno (network byte order) - * uint16_t length (network byte order) - * uint8_t type - * opaque data[length] - * opaque hmac[HMAC_SIZE] (HMAC over all preceding fields) - -Depending on whether SPTPS records are sent via TCP or UDP, either the -seqno or the length field is omitted on the wire (but they are still -included in the calculation of the HMAC); for TCP packets are guaranteed -to arrive in-order so we can infer the seqno, but packets can be split -or merged, so we still need the length field to determine the boundaries -between records; for UDP packets we know that there is exactly one -record per packet, and we know the length of a packet, but packets can -be dropped, duplicated and/or reordered, so we need to include the -seqno. - -The type field is used to distinguish between application records or -handshake records. Types 0 to 127 are application records, type 128 is -a handshake record, and types 129 to 255 are reserved. - -Before the initial handshake, no fields are encrypted, and the HMAC -field is not present. After the authentication handshake, the length -(if present), type and data fields are encrypted, and the HMAC field is -present. For UDP packets, the seqno field is not encrypted, as it is -used to determine the value of the counter used for encryption. - -The authentication consists of an exchange of Key EXchange, SIGnature -and ACKnowledge messages, transmitted using type 128 records. - -Overview: - - Initiator Responder - --------------------- - KEX -> - <- KEX - SIG -> - <- SIG - - ...encrypt and HMAC using session keys from now on... - - App -> - <- App - ... - ... - - ...key renegotiation starts here... - - KEX -> - <- KEX - SIG -> - <- SIG - ACK -> - <- ACK - - ...encrypt and HMAC using new session keys from now on... - - App -> - <- App - ... - ... - --------------------- - -Note that the responder does not need to wait before it receives the -first KEX message, it can immediately send its own once it has accepted -an incoming connection. - -Key EXchange message: - - * uint8_t kex_version (always 0 in this version of SPTPS) - * opaque nonce[32] (random number) - * opaque ecdh_key[ECDH_SIZE] - -SIGnature message: - - * opaque ecdsa_signature[ECDSA_SIZE] - -ACKnowledge message: - - * empty (only sent after key renegotiation) - -Remarks: - - * At the start, both peers generate a random nonce and an Elliptic - Curve public key and send it to the other in the KEX message. - * After receiving the other's KEX message, both KEX messages are - concatenated (see below), and the result is signed using ECDSA. The - result is sent to the other. - * After receiving the other's SIG message, the signature is verified. - If it is correct, the shared secret is calculated from the public - keys exchanged in the KEX message using the Elliptic Curve - Diffie-Helman algorithm. - * The shared secret key is expanded using a PRF. Both nonces and the - application specific label are also used as input for the PRF. - * An ACK message is sent only when doing key renegotiation, and is - sent using the old encryption keys. - * The expanded key is used to key the encryption and HMAC algorithms. - -The signature is calculated over this string: - - * uint8_t initiator (0 = local peer, 1 = remote peer is initiator) - * opaque remote_kex_message[1 + 32 + ECDH_SIZE] - * opaque local_kex_message[1 + 32 + ECDH_SIZE] - * opaque label[label_length] - -The PRF is calculated as follows: - - * A HMAC using SHA512 is used, the shared secret is used as the key. - * For each block of 64 bytes, a HMAC is calculated. For block n: - hmac[n] = HMAC_SHA512(hmac[n - 1] + seed) - * For the first block (n = 1), hmac[0] is given by HMAC_SHA512(zeroes - + seed), where zeroes is a block of 64 zero bytes. - -The seed is as follows: - - * const char[13] "key expansion" - * opaque responder_nonce[32] - * opaque initiator_nonce[32] - * opaque label[label_length] - -The expanded key is used as follows: - - * opaque responder_cipher_key[CIPHER_KEYSIZE] - * opaque responder_digest_key[DIGEST_KEYSIZE] - * opaque initiator_cipher_key[CIPHER_KEYSIZE] - * opaque initiator_digest_key[DIGEST_KEYSIZE] - -Where initiator_cipher_key is the key used by session initiator to -encrypt messages sent to the responder. - -When using 256 bits Ed25519 keys, the AES-256-CTR cipher and -HMAC-SHA-256 digest algorithm, the sizes are as follows: - - ECDH_SIZE: 32 (= 256/8) - ECDSA_SIZE: 64 (= 2 * 256/8) - CIPHER_KEYSIZE: 48 (= 256/8 + 128/8) - DIGEST_KEYSIZE: 32 (= 256/8) - -Note that the cipher key also includes the initial value for the -counter. - - -File: tinc.info, Node: Encryption of network packets, Next: Security issues, Prev: Simple Peer-to-Peer Security, Up: Security - -8.3.3 Encryption of network packets +6.3.2 Encryption of network packets ----------------------------------- A data packet can only be sent if the encryption key is known to both parties, and the connection is activated. If the encryption key is not known, a request is sent to the destination using the meta connection to -retrieve it. +retrieve it. The packet is stored in a queue while waiting for the key +to arrive. -The UDP packets can be either encrypted with the legacy protocol or with -SPTPS. In case of the legacy protocol, the UDP packet containing the -network packet from the VPN has the following layout: + The UDP packet containing the network packet from the VPN has the +following layout: ... | IP header | UDP header | seqno | VPN packet | MAC | UDP trailer \___________________/\_____/ @@ -3129,39 +2239,18 @@ network packet from the VPN has the following layout: V +---> digest algorithm Encrypted with symmetric cipher -So, the entire VPN packet is encrypted using a symmetric cipher, + So, the entire VPN packet is encrypted using a symmetric cipher, including a 32 bits sequence number that is added in front of the actual VPN packet, to act as a unique IV for each packet and to prevent replay attacks. A message authentication code is added to the UDP packet to -prevent alteration of packets. Tinc by default encrypts network packets -using Blowfish with 128 bit keys in CBC mode and uses 4 byte long -message authentication codes to make sure eavesdroppers cannot get and -cannot change any information at all from the packets they can -intercept. The encryption algorithm and message authentication -algorithm can be changed in the configuration. The length of the -message authentication codes is also adjustable. The length of the key -for the encryption algorithm is always the default length used by -LibreSSL/OpenSSL. - -The SPTPS protocol is described in *note Simple Peer-to-Peer Security::. -For comparison, this is how SPTPS UDP packets look: - - ... | IP header | UDP header | seqno | type | VPN packet | MAC | UDP trailer - \__________________/\_____/ - | | - V +---> digest algorithm - Encrypted with symmetric cipher - -The difference is that the seqno is not encrypted, since the encryption -cipher is used in CTR mode, and therefore the seqno must be known before -the packet can be decrypted. Furthermore, the MAC is never truncated. -The SPTPS protocol always uses the AES-256-CTR cipher and HMAC-SHA-256 -digest, this cannot be changed. +prevent alteration of packets. By default the first 4 bytes of the +digest are used for this, but this can be changed using the MACLength +configuration variable.  File: tinc.info, Node: Security issues, Prev: Encryption of network packets, Up: Security -8.3.4 Security issues +6.3.3 Security issues --------------------- In August 2000, we discovered the existence of a security hole in all @@ -3171,40 +2260,22 @@ authentication scheme to make tinc as secure as possible. The current version uses the LibreSSL or OpenSSL library and uses strong authentication with RSA keys. -On the 29th of December 2001, Jerome Etienne posted a security analysis -of tinc 1.0pre4. Due to a lack of sequence numbers and a message -authentication code for each packet, an attacker could possibly disrupt -certain network services or launch a denial of service attack by + On the 29th of December 2001, Jerome Etienne posted a security +analysis of tinc 1.0pre4. Due to a lack of sequence numbers and a +message authentication code for each packet, an attacker could possibly +disrupt certain network services or launch a denial of service attack by replaying intercepted packets. The current version adds sequence numbers and message authentication codes to prevent such attacks. -On the 15th of September 2003, Peter Gutmann posted a security analysis -of tinc 1.0.1. He argues that the 32 bit sequence number used by tinc -is not a good IV, that tinc's default length of 4 bytes for the MAC is -too short, and he doesn't like tinc's use of RSA during authentication. -We do not know of a security hole in the legacy protocol of tinc, but it -is not as strong as TLS or IPsec. + On the 15th of September 2003, Peter Gutmann posted a security +analysis of tinc 1.0.1. He argues that the 32 bit sequence number used +by tinc is not a good IV, that tinc's default length of 4 bytes for the +MAC is too short, and he doesn't like tinc's use of RSA during +authentication. We do not know of a security hole in this version of +tinc, but tinc's security is not as strong as TLS or IPsec. We will +address these issues in tinc 2.0. -The Sweet32 attack affects versions of tinc prior to 1.0.30. - -On September 6th, 2018, Michael Yonly contacted us and provided -proof-of-concept code that allowed a remote attacker to create an -authenticated, one-way connection with a node, and also that there was a -possibility for a man-in-the-middle to force UDP packets from a node to -be sent in plaintext. The first issue was trivial to exploit on tinc -versions prior to 1.0.30, but the changes in 1.0.30 to mitigate the -Sweet32 attack made this weakness much harder to exploit. These issues -have been fixed in tinc 1.0.35. - -This version of tinc comes with an improved protocol, called Simple -Peer-to-Peer Security (SPTPS), which aims to be as strong as TLS with -one of the strongest cipher suites. None of the above security issues -affected SPTPS. However, be aware that SPTPS is only used between nodes -running tinc 1.1pre* or later, and in a VPN with nodes running different -versions, the security might only be as good as that of the oldest -version. - -Cryptography is a hard thing to get right. We cannot make any + Cryptography is a hard thing to get right. We cannot make any guarantees. Time, review and feedback are the only things that can prove the security of any cryptographic product. If you wish to review tinc or give us feedback, you are strongly encouraged to do so. @@ -3212,7 +2283,7 @@ tinc or give us feedback, you are strongly encouraged to do so.  File: tinc.info, Node: Platform specific information, Next: About us, Prev: Technical information, Up: Top -9 Platform specific information +7 Platform specific information ******************************* * Menu: @@ -3224,7 +2295,7 @@ File: tinc.info, Node: Platform specific information, Next: About us, Prev: T  File: tinc.info, Node: Interface configuration, Next: Routes, Up: Platform specific information -9.1 Interface configuration +7.1 Interface configuration =========================== When configuring an interface, one normally assigns it an address and a @@ -3236,40 +2307,40 @@ to that interface. Because all packets for the entire VPN should go to the virtual network interface used by tinc, the netmask should be such that it encompasses the entire VPN. -For IPv4 addresses: + For IPv4 addresses: -Linux 'ifconfig' INTERFACE ADDRESS 'netmask' NETMASK -Linux iproute2 'ip addr add' ADDRESS'/'PREFIXLENGTH 'dev' INTERFACE -FreeBSD 'ifconfig' INTERFACE ADDRESS 'netmask' NETMASK -OpenBSD 'ifconfig' INTERFACE ADDRESS 'netmask' NETMASK -NetBSD 'ifconfig' INTERFACE ADDRESS 'netmask' NETMASK -Solaris 'ifconfig' INTERFACE ADDRESS 'netmask' NETMASK -Darwin (MacOS/X) 'ifconfig' INTERFACE ADDRESS 'netmask' NETMASK -Windows 'netsh interface ip set address' INTERFACE 'static' ADDRESS NETMASK +Linux 'ifconfig' INTERFACE ADDRESS 'netmask' NETMASK +Linux iproute2 'ip addr add' ADDRESS'/'PREFIXLENGTH 'dev' INTERFACE +FreeBSD 'ifconfig' INTERFACE ADDRESS 'netmask' NETMASK +OpenBSD 'ifconfig' INTERFACE ADDRESS 'netmask' NETMASK +NetBSD 'ifconfig' INTERFACE ADDRESS 'netmask' NETMASK +Solaris 'ifconfig' INTERFACE ADDRESS 'netmask' NETMASK +Darwin (Mac OS X) 'ifconfig' INTERFACE ADDRESS 'netmask' NETMASK +Windows 'netsh interface ip set address' INTERFACE 'static' ADDRESS NETMASK -For IPv6 addresses: + For IPv6 addresses: -Linux 'ifconfig' INTERFACE 'add' ADDRESS'/'PREFIXLENGTH -FreeBSD 'ifconfig' INTERFACE 'inet6' ADDRESS 'prefixlen' PREFIXLENGTH -OpenBSD 'ifconfig' INTERFACE 'inet6' ADDRESS 'prefixlen' PREFIXLENGTH -NetBSD 'ifconfig' INTERFACE 'inet6' ADDRESS 'prefixlen' PREFIXLENGTH -Solaris 'ifconfig' INTERFACE 'inet6 plumb up' - 'ifconfig' INTERFACE 'inet6 addif' ADDRESS ADDRESS -Darwin (MacOS/X) 'ifconfig' INTERFACE 'inet6' ADDRESS 'prefixlen' PREFIXLENGTH -Windows 'netsh interface ipv6 add address' INTERFACE 'static' ADDRESS/PREFIXLENGTH +Linux 'ifconfig' INTERFACE 'add' ADDRESS'/'PREFIXLENGTH +FreeBSD 'ifconfig' INTERFACE 'inet6' ADDRESS 'prefixlen' PREFIXLENGTH +OpenBSD 'ifconfig' INTERFACE 'inet6' ADDRESS 'prefixlen' PREFIXLENGTH +NetBSD 'ifconfig' INTERFACE 'inet6' ADDRESS 'prefixlen' PREFIXLENGTH +Solaris 'ifconfig' INTERFACE 'inet6 plumb up' + 'ifconfig' INTERFACE 'inet6 addif' ADDRESS ADDRESS +Darwin (Mac OS X) 'ifconfig' INTERFACE 'inet6' ADDRESS 'prefixlen' PREFIXLENGTH +Windows 'netsh interface ipv6 add address' INTERFACE 'static' ADDRESS/PREFIXLENGTH -On Linux, it is possible to create a persistent tun/tap interface which -will continue to exist even if tinc quit, although this is normally not -required. It can be useful to set up a tun/tap interface owned by a -non-root user, so tinc can be started without needing any root -privileges at all. + On Linux, it is possible to create a persistent tun/tap interface +which will continue to exist even if tinc quit, although this is +normally not required. It can be useful to set up a tun/tap interface +owned by a non-root user, so tinc can be started without needing any +root privileges at all. -Linux 'ip tuntap add dev' INTERFACE 'mode' TUN|TAP 'user' USERNAME +Linux 'ip tuntap add dev' INTERFACE 'mode' TUN|TAP 'user' USERNAME  File: tinc.info, Node: Routes, Next: Automatically starting tinc, Prev: Interface configuration, Up: Platform specific information -9.2 Routes +7.2 Routes ========== In some cases it might be necessary to add more routes to the virtual @@ -3279,33 +2350,33 @@ another way is to specify the (local) address that is assigned to that interface (LOCAL_ADDRESS). The former way is unambiguous and therefore preferable, but not all platforms support this. -Adding routes to IPv4 subnets: + Adding routes to IPv4 subnets: -Linux 'route add -net' NETWORK_ADDRESS 'netmask' NETMASK INTERFACE -Linux iproute2 'ip route add' NETWORK_ADDRESS'/'PREFIXLENGTH 'dev' INTERFACE -FreeBSD 'route add' NETWORK_ADDRESS'/'PREFIXLENGTH LOCAL_ADDRESS -OpenBSD 'route add' NETWORK_ADDRESS'/'PREFIXLENGTH LOCAL_ADDRESS -NetBSD 'route add' NETWORK_ADDRESS'/'PREFIXLENGTH LOCAL_ADDRESS -Solaris 'route add' NETWORK_ADDRESS'/'PREFIXLENGTH LOCAL_ADDRESS '-interface' -Darwin (MacOS/X) 'route add' NETWORK_ADDRESS'/'PREFIXLENGTH LOCAL_ADDRESS -Windows 'netsh routing ip add persistentroute' NETWORK_ADDRESS NETMASK INTERFACE - LOCAL_ADDRESS +Linux 'route add -net' NETWORK_ADDRESS 'netmask' NETMASK INTERFACE +Linux iproute2 'ip route add' NETWORK_ADDRESS'/'PREFIXLENGTH 'dev' INTERFACE +FreeBSD 'route add' NETWORK_ADDRESS'/'PREFIXLENGTH LOCAL_ADDRESS +OpenBSD 'route add' NETWORK_ADDRESS'/'PREFIXLENGTH LOCAL_ADDRESS +NetBSD 'route add' NETWORK_ADDRESS'/'PREFIXLENGTH LOCAL_ADDRESS +Solaris 'route add' NETWORK_ADDRESS'/'PREFIXLENGTH LOCAL_ADDRESS '-interface' +Darwin (Mac OS X) 'route add' NETWORK_ADDRESS'/'PREFIXLENGTH '-interface' INTERFACE +Windows 'netsh routing ip add persistentroute' NETWORK_ADDRESS NETMASK INTERFACE + LOCAL_ADDRESS -Adding routes to IPv6 subnets: + Adding routes to IPv6 subnets: -Linux 'route add -A inet6' NETWORK_ADDRESS'/'PREFIXLENGTH INTERFACE -Linux iproute2 'ip route add' NETWORK_ADDRESS'/'PREFIXLENGTH 'dev' INTERFACE -FreeBSD 'route add -inet6' NETWORK_ADDRESS'/'PREFIXLENGTH LOCAL_ADDRESS -OpenBSD 'route add -inet6' NETWORK_ADDRESS LOCAL_ADDRESS '-prefixlen' PREFIXLENGTH -NetBSD 'route add -inet6' NETWORK_ADDRESS LOCAL_ADDRESS '-prefixlen' PREFIXLENGTH -Solaris 'route add -inet6' NETWORK_ADDRESS'/'PREFIXLENGTH LOCAL_ADDRESS '-interface' -Darwin (MacOS/X) ? -Windows 'netsh interface ipv6 add route' NETWORK ADDRESS/PREFIXLENGTH INTERFACE +Linux 'route add -A inet6' NETWORK_ADDRESS'/'PREFIXLENGTH INTERFACE +Linux iproute2 'ip route add' NETWORK_ADDRESS'/'PREFIXLENGTH 'dev' INTERFACE +FreeBSD 'route add -inet6' NETWORK_ADDRESS'/'PREFIXLENGTH LOCAL_ADDRESS +OpenBSD 'route add -inet6' NETWORK_ADDRESS LOCAL_ADDRESS '-prefixlen' PREFIXLENGTH +NetBSD 'route add -inet6' NETWORK_ADDRESS LOCAL_ADDRESS '-prefixlen' PREFIXLENGTH +Solaris 'route add -inet6' NETWORK_ADDRESS'/'PREFIXLENGTH LOCAL_ADDRESS '-interface' +Darwin (Mac OS X) 'route add -inet6' NETWORK_ADDRESS'/'PREFIXLENGTH '-interface' INTERFACE +Windows 'netsh interface ipv6 add route' NETWORK ADDRESS/PREFIXLENGTH INTERFACE  File: tinc.info, Node: Automatically starting tinc, Prev: Routes, Up: Platform specific information -9.3 Automatically starting tinc +7.3 Automatically starting tinc =============================== * Menu: @@ -3317,7 +2388,7 @@ File: tinc.info, Node: Automatically starting tinc, Prev: Routes, Up: Platfor  File: tinc.info, Node: Linux, Next: Windows, Up: Automatically starting tinc -9.3.1 Linux +7.3.1 Linux ----------- There are many Linux distributions, and historically, many of them had @@ -3334,35 +2405,35 @@ ensure it is started at boot time: systemctl enable tinc systemctl enable tinc@foo -To start the tinc daemon immediately if it wasn't already running, use -the following command: + To start the tinc daemon immediately if it wasn't already running, +use the following command: systemctl start tinc@foo -You can also use 'systemctl start tinc', this will start all tinc + You can also use 'systemctl start tinc', this will start all tinc daemons that are enabled. You can stop and disable tinc networks in the same way. -If your system is not using systemd, then you have to look up your + If your system is not using systemd, then you have to look up your distribution's way of starting tinc at boot time.  File: tinc.info, Node: Windows, Next: Other platforms, Prev: Linux, Up: Automatically starting tinc -9.3.2 Windows +7.3.2 Windows ------------- -On Windows, if tinc is started with the 'tinc start' command without -using the '-D' or '--no-detach' option, it will automatically register -itself as a service that is started at boot time. When tinc is stopped -using the 'tinc stop' command, it will also automatically unregister -itself. Once tinc is registered as a service, it is also possible to -stop and start tinc using the Windows Services Manager. +On Windows, if tinc is started without the '-D' or '--no-detach' option, +it will automatically register itself as a service that is started at +boot time. When tinc is stopped using the '-k' or '--kill', it will +also automatically unregister itself. Once tinc is registered as a +service, it is also possible to stop and start tinc using the Windows +Services Manager.  File: tinc.info, Node: Other platforms, Prev: Windows, Up: Automatically starting tinc -9.3.3 Other platforms +7.3.3 Other platforms --------------------- On platforms other than the ones mentioned in the earlier sections, you @@ -3371,8 +2442,8 @@ have to look up your platform's way of starting programs at boot time.  File: tinc.info, Node: About us, Next: Concept Index, Prev: Platform specific information, Up: Top -10 About us -*********** +8 About us +********** * Menu: @@ -3382,29 +2453,29 @@ File: tinc.info, Node: About us, Next: Concept Index, Prev: Platform specific  File: tinc.info, Node: Contact information, Next: Authors, Up: About us -10.1 Contact information -======================== +8.1 Contact information +======================= Tinc's website is at , this server is located in the Netherlands. -We have an IRC channel on the FreeNode and OFTC IRC networks. Connect -to irc.freenode.net (https://freenode.net/) or irc.oftc.net + We have an IRC channel on the FreeNode and OFTC IRC networks. +Connect to irc.freenode.net (https://freenode.net/) or irc.oftc.net (https://www.oftc.net/) and join channel #tinc.  File: tinc.info, Node: Authors, Prev: Contact information, Up: About us -10.2 Authors -============ +8.2 Authors +=========== Ivo Timmermans (zarq) Guus Sliepen (guus) () -We have received a lot of valuable input from users. With their help, -tinc has become the flexible and robust tool that it is today. We have -composed a list of contributions, in the file called 'THANKS' in the -source distribution. + We have received a lot of valuable input from users. With their +help, tinc has become the flexible and robust tool that it is today. We +have composed a list of contributions, in the file called 'THANKS' in +the source distribution.  File: tinc.info, Node: Concept Index, Prev: About us, Up: Top @@ -3415,9 +2486,8 @@ Concept Index [index] * Menu: -* ACK: Legacy authentication protocol. - (line 6) -* add: tinc commands. (line 22) +* ACK: Authentication protocol. + (line 10) * Address: Host configuration variables. (line 6) * AddressFamily: Main configuration variables. @@ -3425,296 +2495,214 @@ Concept Index * ADD_EDGE: The meta-protocol. (line 22) * ADD_SUBNET: The meta-protocol. (line 22) * ANS_KEY: The meta-protocol. (line 63) -* AutoConnect: Main configuration variables. - (line 12) -* batch: tinc runtime options. - (line 18) +* authentication: Authentication protocol. + (line 6) * binary package: Building and installing tinc. (line 9) * BindToAddress: Main configuration variables. - (line 16) + (line 12) * BindToInterface: Main configuration variables. - (line 23) + (line 25) * Broadcast: Main configuration variables. (line 33) -* BroadcastSubnet: Main configuration variables. - (line 53) * Cabal: Security. (line 6) -* CHALLENGE: Legacy authentication protocol. - (line 6) -* CHAL_REPLY: Legacy authentication protocol. - (line 6) +* CHALLENGE: Authentication protocol. + (line 10) +* CHAL_REPLY: Authentication protocol. + (line 10) * CIDR notation: Host configuration variables. - (line 101) + (line 93) * Cipher: Host configuration variables. (line 14) * ClampMSS: Host configuration variables. - (line 22) + (line 20) * client: How connections work. - (line 12) + (line 18) * command line: Runtime options. (line 9) -* command line interface: Controlling tinc. (line 6) * Compression: Host configuration variables. - (line 28) + (line 26) * connection: The connection. (line 6) * ConnectTo: Main configuration variables. - (line 65) + (line 53) * daemon: Running tinc. (line 11) * data-protocol: The meta-connection. (line 18) -* debug: tinc commands. (line 127) * debug level: Runtime options. (line 17) * debug levels: Debug levels. (line 6) * DecrementTTL: Main configuration variables. - (line 76) -* del: tinc commands. (line 27) + (line 64) * DEL_EDGE: The meta-protocol. (line 46) * DEL_SUBNET: The meta-protocol. (line 46) * Device: Main configuration variables. - (line 85) -* DEVICE: Scripts. (line 72) + (line 73) +* DEVICE: Scripts. (line 64) * device files: Device files. (line 6) -* DeviceStandby: Main configuration variables. - (line 92) * DeviceType: Main configuration variables. - (line 99) + (line 79) * Digest: Host configuration variables. - (line 33) + (line 31) * DirectOnly: Main configuration variables. - (line 174) -* disconnect: tinc commands. (line 142) + (line 149) * dummy: Main configuration variables. - (line 106) -* dump: tinc commands. (line 95) -* Ed25519PrivateKeyFile: Main configuration variables. - (line 181) -* edit: tinc commands. (line 32) + (line 86) * encapsulating: The UDP tunnel. (line 30) * encryption: Encryption of network packets. (line 6) -* environment variables: Scripts. (line 60) +* environment variables: Scripts. (line 53) * example: Example configuration. (line 6) -* exchange: tinc commands. (line 48) -* exchange-all: tinc commands. (line 51) * exec: Main configuration variables. - (line 373) -* ExperimentalProtocol: Main configuration variables. - (line 185) -* export: tinc commands. (line 36) -* export-all: tinc commands. (line 40) -* fd: Main configuration variables. - (line 129) + (line 319) * Forwarding: Main configuration variables. - (line 192) + (line 156) * frame type: The UDP tunnel. (line 6) -* fsck: tinc commands. (line 160) -* FWMark: Main configuration variables. - (line 214) -* generate-ed25519-keys: tinc commands. (line 86) -* generate-keys: tinc commands. (line 81) -* generate-rsa-keys: tinc commands. (line 89) -* get: tinc commands. (line 11) -* graph: tinc commands. (line 108) +* GraphDumpFile: Main configuration variables. + (line 176) * Hostnames: Main configuration variables. - (line 220) + (line 184) * http: Main configuration variables. - (line 370) + (line 316) * hub: Main configuration variables. - (line 288) -* ID: Legacy authentication protocol. - (line 6) -* Ifconfig: Invitation file format. - (line 36) -* import: tinc commands. (line 43) + (line 254) +* ID: Authentication protocol. + (line 10) +* IffOneQueue: Main configuration variables. + (line 195) * IndirectData: Host configuration variables. - (line 40) -* info: tinc commands. (line 120) -* init: tinc commands. (line 6) + (line 36) * Interface: Main configuration variables. - (line 231) -* INTERFACE: Scripts. (line 75) -* InvitationExpire: Main configuration variables. - (line 293) -* INVITATION_FILE: Scripts. (line 98) -* INVITATION_URL: Scripts. (line 102) -* invite: tinc commands. (line 54) + (line 198) +* INTERFACE: Scripts. (line 67) * IRC: Contact information. (line 9) -* join: tinc commands. (line 59) +* key generation: Generating keypairs. (line 6) * KeyExpire: Main configuration variables. - (line 296) + (line 206) * KEY_CHANGED: The meta-protocol. (line 63) -* legacy authentication protocol: Legacy authentication protocol. - (line 6) -* libcurses: libcurses. (line 6) * libraries: Libraries. (line 6) -* libreadline: libreadline. (line 6) * LibreSSL: LibreSSL/OpenSSL. (line 6) * license: LibreSSL/OpenSSL. (line 38) -* ListenAddress: Main configuration variables. - (line 239) * LocalDiscovery: Main configuration variables. - (line 251) -* log: tinc commands. (line 130) -* LogLevel: Main configuration variables. - (line 262) -* LZO: LZO. (line 6) + (line 212) +* lzo: lzo. (line 6) * MACExpire: Main configuration variables. - (line 302) + (line 223) * MACLength: Host configuration variables. - (line 45) -* MaxConnectionBurst: Main configuration variables. - (line 307) + (line 44) +* MaxTimeout: Main configuration variables. + (line 228) * meta-protocol: The meta-connection. (line 18) -* META_KEY: Legacy authentication protocol. - (line 6) +* META_KEY: Authentication protocol. + (line 10) * Mode: Main configuration variables. - (line 266) -* MTUInfoInterval: Host configuration variables. - (line 60) + (line 232) * multicast: Main configuration variables. - (line 118) + (line 98) * multiple networks: Multiple networks. (line 6) * Name: Main configuration variables. - (line 313) -* NAME: Scripts. (line 69) -* netmask: Network interfaces. (line 39) + (line 259) +* NAME: Scripts. (line 61) +* netmask: Network interfaces. (line 33) * netname: Multiple networks. (line 6) -* NETNAME: Scripts. (line 66) -* NETNAME <1>: tinc environment variables. - (line 6) -* network: tinc commands. (line 156) +* NETNAME: Scripts. (line 58) * Network Administrators Guide: Configuration introduction. (line 15) -* NODE: Scripts. (line 79) +* NODE: Scripts. (line 71) * OpenSSL: LibreSSL/OpenSSL. (line 6) * options: Runtime options. (line 9) -* pcap: tinc commands. (line 150) * PEM format: Host configuration variables. - (line 77) -* pid: tinc commands. (line 78) + (line 69) * PING: The meta-protocol. (line 88) * PingInterval: Main configuration variables. - (line 324) + (line 270) * PingTimeout: Main configuration variables. - (line 328) + (line 274) * platforms: Supported platforms. (line 6) * PMTU: Host configuration variables. - (line 52) + (line 49) * PMTUDiscovery: Host configuration variables. - (line 55) + (line 52) * PONG: The meta-protocol. (line 88) * Port: Host configuration variables. - (line 65) + (line 57) * port numbers: Other files. (line 17) * PriorityInheritance: Main configuration variables. - (line 334) + (line 280) * private: Virtual Private Networks. (line 10) * PrivateKey: Main configuration variables. - (line 339) + (line 285) * PrivateKeyFile: Main configuration variables. - (line 345) + (line 291) * ProcessPriority: Main configuration variables. - (line 350) + (line 296) * Proxy: Main configuration variables. - (line 355) + (line 301) * PublicKey: Host configuration variables. - (line 69) + (line 61) * PublicKeyFile: Host configuration variables. - (line 72) -* purge: tinc commands. (line 124) + (line 64) * raw_socket: Main configuration variables. - (line 111) + (line 91) * release: Supported platforms. (line 14) -* reload: tinc commands. (line 73) -* REMOTEADDRESS: Scripts. (line 84) -* REMOTEPORT: Scripts. (line 87) +* REMOTEADDRESS: Scripts. (line 76) +* REMOTEPORT: Scripts. (line 79) * ReplayWindow: Main configuration variables. - (line 378) + (line 324) * requirements: Libraries. (line 6) * REQ_KEY: The meta-protocol. (line 63) -* restart: tinc commands. (line 70) -* retry: tinc commands. (line 135) -* Route: Invitation file format. - (line 52) * router: Main configuration variables. - (line 269) + (line 235) * runtime options: Runtime options. (line 9) * scalability: tinc. (line 19) * scripts: Scripts. (line 6) * server: How connections work. - (line 12) -* set: tinc commands. (line 16) -* shell: Controlling tinc. (line 11) -* sign: tinc commands. (line 172) + (line 18) * signals: Signals. (line 6) * socks4: Main configuration variables. - (line 359) + (line 305) * socks5: Main configuration variables. - (line 364) -* SPTPS: Simple Peer-to-Peer Security. - (line 6) -* start: tinc commands. (line 64) -* stop: tinc commands. (line 67) + (line 310) * StrictSubnets: Main configuration variables. - (line 389) + (line 335) * Subnet: Host configuration variables. - (line 84) -* SUBNET: Scripts. (line 91) + (line 76) +* SUBNET: Scripts. (line 83) +* Subnet weight: Host configuration variables. + (line 98) * SVPN: Security. (line 11) * switch: Main configuration variables. - (line 277) + (line 243) * systemd: Linux. (line 6) * TCP: The meta-connection. (line 10) * TCPonly: Host configuration variables. - (line 113) + (line 105) * tinc: Introduction. (line 6) * TINC: Security. (line 6) -* tinc-down: Scripts. (line 30) -* tinc-up: Scripts. (line 20) +* tinc-down: Scripts. (line 29) +* tinc-up: Scripts. (line 19) * tinc-up <1>: Network interfaces. (line 19) * tincd: tinc. (line 14) -* top: tinc commands. (line 145) -* top <1>: tinc top. (line 6) * traditional VPNs: tinc. (line 19) * tunifhead: Main configuration variables. - (line 158) + (line 133) * TunnelServer: Main configuration variables. - (line 396) + (line 342) * tunnohead: Main configuration variables. - (line 152) + (line 127) * UDP: The UDP tunnel. (line 30) * UDP <1>: Encryption of network packets. - (line 11) -* UDPDiscoveryInterval: Main configuration variables. - (line 416) -* UDPDiscoveryKeepaliveInterval: Main configuration variables. - (line 410) -* UDPDiscoveryTimeout: Main configuration variables. - (line 420) -* UDPDiscovey: Main configuration variables. - (line 403) -* UDPInfoInterval: Main configuration variables. - (line 425) + (line 12) * UDPRcvBuf: Main configuration variables. - (line 429) + (line 349) * UDPSndBuf: Main configuration variables. - (line 435) + (line 354) * UML: Main configuration variables. - (line 134) + (line 109) * Universal tun/tap: Configuration of Linux kernels. (line 6) -* UPnP: Main configuration variables. - (line 441) -* UPnPDiscoverWait: Main configuration variables. - (line 452) -* UPnPRefreshPeriod: Main configuration variables. - (line 456) * utun: Main configuration variables. - (line 165) + (line 140) * VDE: Main configuration variables. - (line 139) -* verify: tinc commands. (line 177) + (line 114) * virtual: Virtual Private Networks. (line 18) * virtual network device: The UDP tunnel. (line 6) @@ -3722,90 +2710,76 @@ Concept Index (line 6) * vpnd: tinc. (line 6) * website: Contact information. (line 6) -* Weight: Host configuration variables. - (line 120) -* WEIGHT: Scripts. (line 94) +* WEIGHT: Scripts. (line 86) * zlib: zlib. (line 6)  Tag Table: -Node: Top808 -Node: Introduction1144 -Node: Virtual Private Networks1948 -Node: tinc3660 -Node: Supported platforms5173 -Node: Preparations5870 -Node: Configuring the kernel6126 -Node: Configuration of Linux kernels6535 -Node: Configuration of FreeBSD kernels7384 -Node: Configuration of OpenBSD kernels7849 -Node: Configuration of NetBSD kernels8206 -Node: Configuration of Solaris kernels8608 -Node: Configuration of Darwin (MacOS/X) kernels9270 -Node: Configuration of Windows10083 -Node: Libraries10622 -Node: LibreSSL/OpenSSL11079 -Node: zlib13607 -Node: LZO14627 -Node: libcurses15619 -Node: libreadline16531 -Node: Installation17470 -Node: Building and installing tinc18374 -Node: Darwin (MacOS/X) build environment19030 -Node: Cygwin (Windows) build environment19589 -Node: MinGW (Windows) build environment20174 -Node: System files20762 -Node: Device files21027 -Node: Other files21440 -Node: Configuration22053 -Node: Configuration introduction22340 -Node: Multiple networks23862 -Node: How connections work25230 -Node: Configuration files27494 -Node: Main configuration variables29125 -Node: Host configuration variables50523 -Node: Scripts56595 -Node: How to configure60495 -Node: Network interfaces64406 -Node: Example configuration66785 -Node: Running tinc71726 -Node: Runtime options72313 -Node: Signals75581 -Node: Debug levels76430 -Node: Solving problems77366 -Node: Error messages78792 -Node: Sending bug reports83109 -Node: Controlling tinc84056 -Node: tinc runtime options84792 -Node: tinc environment variables85608 -Node: tinc commands85937 -Node: tinc examples92796 -Node: tinc top93356 -Node: Invitations94940 -Node: How invitations work95603 -Node: Invitation file format97896 -Node: Writing an invitation-created script100907 -Node: Technical information101970 -Node: The connection102200 -Node: The UDP tunnel102512 -Node: The meta-connection105548 -Node: The meta-protocol107006 -Node: Security111989 -Node: Legacy authentication protocol113326 -Node: Simple Peer-to-Peer Security117943 -Node: Encryption of network packets123588 -Node: Security issues126226 -Node: Platform specific information128818 -Node: Interface configuration129078 -Node: Routes131348 -Node: Automatically starting tinc133295 -Node: Linux133518 -Node: Windows134730 -Node: Other platforms135274 -Node: About us135556 -Node: Contact information135733 -Node: Authors136136 -Node: Concept Index136540 +Node: Top806 +Node: Introduction1105 +Node: Virtual Private Networks1915 +Node: tinc3639 +Node: Supported platforms5167 +Node: Preparations5868 +Node: Configuring the kernel6124 +Node: Configuration of Linux kernels6534 +Node: Configuration of FreeBSD kernels7389 +Node: Configuration of OpenBSD kernels7854 +Node: Configuration of NetBSD kernels8211 +Node: Configuration of Solaris kernels8616 +Node: Configuration of Darwin (Mac OS X) kernels9279 +Node: Configuration of Windows10098 +Node: Libraries10638 +Node: LibreSSL/OpenSSL11047 +Node: zlib13589 +Node: lzo14618 +Node: Installation15601 +Node: Building and installing tinc16511 +Node: Darwin (Mac OS X) build environment17171 +Node: Cygwin (Windows) build environment17736 +Node: MinGW (Windows) build environment18325 +Node: System files18919 +Node: Device files19184 +Node: Other files19600 +Node: Configuration20213 +Node: Configuration introduction20524 +Node: Multiple networks21792 +Node: How connections work23218 +Node: Configuration files24440 +Node: Main configuration variables25934 +Node: Host configuration variables42190 +Node: Scripts47722 +Node: How to configure50988 +Node: Generating keypairs52246 +Node: Network interfaces52745 +Node: Example configuration54593 +Node: Running tinc59918 +Node: Runtime options60508 +Node: Signals64137 +Node: Debug levels65328 +Node: Solving problems66264 +Node: Error messages67816 +Node: Sending bug reports71825 +Node: Technical information72772 +Node: The connection73003 +Node: The UDP tunnel73315 +Node: The meta-connection76367 +Node: The meta-protocol77836 +Node: Security82853 +Node: Authentication protocol83995 +Node: Encryption of network packets89040 +Node: Security issues90416 +Node: Platform specific information92056 +Node: Interface configuration92316 +Node: Routes94612 +Node: Automatically starting tinc96662 +Node: Linux96885 +Node: Windows98106 +Node: Other platforms98611 +Node: About us98893 +Node: Contact information99068 +Node: Authors99471 +Node: Concept Index99876  End Tag Table diff --git a/doc/tinc.texi b/doc/tinc.texi index c7021dd..0420e6f 100644 --- a/doc/tinc.texi +++ b/doc/tinc.texi @@ -15,7 +15,7 @@ This is the info manual for @value{PACKAGE} version @value{VERSION}, a Virtual Private Network daemon. -Copyright @copyright{} 1998-2018 Ivo Timmermans, +Copyright @copyright{} 1998-2019 Ivo Timmermans, Guus Sliepen and Wessel Dankers . @@ -30,10 +30,6 @@ permission notice identical to this one. @end ifinfo -@afourpaper -@paragraphindent none -@finalout - @titlepage @title tinc Manual @subtitle Setting up a Virtual Private Network with tinc @@ -43,7 +39,7 @@ permission notice identical to this one. @vskip 0pt plus 1filll This is the info manual for @value{PACKAGE} version @value{VERSION}, a Virtual Private Network daemon. -Copyright @copyright{} 1998-2018 Ivo Timmermans, +Copyright @copyright{} 1998-2019 Ivo Timmermans, Guus Sliepen and Wessel Dankers . @@ -69,8 +65,6 @@ permission notice identical to this one. * Installation:: * Configuration:: * Running tinc:: -* Controlling tinc:: -* Invitations:: * Technical information:: * Platform specific information:: * About us:: @@ -182,7 +176,7 @@ available too. @section Supported platforms @cindex platforms -Tinc has been verified to work under Linux, FreeBSD, OpenBSD, NetBSD, MacOS/X (Darwin), Solaris, and Windows (both natively and in a Cygwin environment), +Tinc has been verified to work under Linux, FreeBSD, OpenBSD, NetBSD, Mac OS X (Darwin), Solaris, and Windows (both natively and in a Cygwin environment), with various hardware architectures. These are some of the platforms that are supported by the universal tun/tap device driver or other virtual network device drivers. Without such a driver, tinc will most @@ -230,7 +224,7 @@ support tinc. * Configuration of OpenBSD kernels:: * Configuration of NetBSD kernels:: * Configuration of Solaris kernels:: -* Configuration of Darwin (MacOS/X) kernels:: +* Configuration of Darwin (Mac OS X) kernels:: * Configuration of Windows:: @end menu @@ -299,13 +293,13 @@ If the @file{net/if_tun.h} header file is missing, install it from the source pa @c ================================================================== -@node Configuration of Darwin (MacOS/X) kernels -@subsection Configuration of Darwin (MacOS/X) kernels +@node Configuration of Darwin (Mac OS X) kernels +@subsection Configuration of Darwin (Mac OS X) kernels Tinc on Darwin relies on a tunnel driver for its data acquisition from the kernel. OS X version 10.6.8 and later have a built-in tun driver called "utun". Tinc also supports the driver from @uref{http://tuntaposx.sourceforge.net/}, -which supports both tun and tap style devices, +which supports both tun and tap style devices. By default, tinc expects the tuntaposx driver to be installed. To use the utun driver, set add @code{Device = utunX} to @file{tinc.conf}, @@ -330,17 +324,14 @@ as explained in the rest of the documentation. @cindex requirements @cindex libraries -Before you can configure or build tinc, you need to have the LibreSSL or OpenSSL, zlib, -LZO, curses and readline libraries installed on your system. If you try to -configure tinc without having them installed, configure will give you an error -message, and stop. +Before you can configure or build tinc, you need to have the LibreSSL or OpenSSL, +zlib and lzo libraries installed on your system. If you try to configure tinc without +having them installed, configure will give you an error message, and stop. @menu * LibreSSL/OpenSSL:: * zlib:: -* LZO:: -* libcurses:: -* libreadline:: +* lzo:: @end menu @@ -363,7 +354,7 @@ of this package. If your operating system comes neither with LibreSSL or OpenSSL, you have to install one manually. It is recommended that you get the latest version of -LibreSSL from @url{https://www.libressl.org/}. Instructions on how to +LibreSSL from @url{http://www.libressl.org/}. Instructions on how to configure, build and install this package are included within the package. Please make sure you build development and runtime libraries (which is the default). @@ -437,10 +428,10 @@ default). @c ================================================================== -@node LZO -@subsection LZO +@node lzo +@subsection lzo -@cindex LZO +@cindex lzo Another form of compression is offered using the LZO library. If this library is not installed, you will get an error when running the @@ -453,58 +444,13 @@ You can use your operating system's package manager to install this if available. Make sure you install the development AND runtime versions of this package. -If you have to install LZO manually, you can get the source code +If you have to install lzo manually, you can get the source code from @url{https://www.oberhumer.com/opensource/lzo/}. Instructions on how to configure, build and install this package are included within the package. Please make sure you build development and runtime libraries (which is the default). -@c ================================================================== -@node libcurses -@subsection libcurses - -@cindex libcurses -For the "tinc top" command, tinc requires a curses library. - -If this library is not installed, you will get an error when running the -configure script. You can either install a suitable curses library, or disable -all functionality that depends on a curses library by using the -"--disable-curses" option when running the configure script. - -There are several curses libraries. It is recommended that you install -"ncurses" (@url{https://invisible-island.net/ncurses/}), -however other curses libraries should also work. -In particular, "PDCurses" (@url{https://pdcurses.sourceforge.io/}) -is recommended if you want to compile tinc for Windows. - -You can use your operating system's package manager to install this if -available. Make sure you install the development AND runtime versions -of this package. - - -@c ================================================================== -@node libreadline -@subsection libreadline - -@cindex libreadline -For the "tinc" command's shell functionality, tinc uses the readline library. - -If this library is not installed, you will get an error when running the -configure script. You can either install a suitable readline library, or -disable all functionality that depends on a readline library by using the -"--disable-readline" option when running the configure script. - -You can use your operating system's package manager to install this if -available. Make sure you install the development AND runtime versions -of this package. - -If you have to install libreadline manually, you can get the source code from -@url{https://www.gnu.org/software/readline/}. Instructions on how to configure, -build and install this package are included within the package. Please make -sure you build development and runtime libraries (which is the default). - - @c @c @c @@ -552,15 +498,15 @@ you can use the package management tools of that distribution to install tinc. The documentation that comes along with your distribution will tell you how to do that. @menu -* Darwin (MacOS/X) build environment:: +* Darwin (Mac OS X) build environment:: * Cygwin (Windows) build environment:: * MinGW (Windows) build environment:: @end menu @c ================================================================== -@node Darwin (MacOS/X) build environment -@subsection Darwin (MacOS/X) build environment +@node Darwin (Mac OS X) build environment +@subsection Darwin (Mac OS X) build environment In order to build tinc on Darwin, you need to install Xcode from @uref{https://developer.apple.com/xcode/}. It might also help to install a recent version of Fink from @uref{http://www.finkproject.org/}. @@ -669,6 +615,7 @@ tinc 655/udp TINC * Multiple networks:: * How connections work:: * Configuration files:: +* Generating keypairs:: * Network interfaces:: * Example configuration:: @end menu @@ -691,19 +638,13 @@ you will not find the answers in this documentation. Make sure you have an adequate understanding of networks in general. @cindex Network Administrators Guide A good resource on networking is the -@uref{https://www.tldp.org/LDP/nag2/, Linux Network Administrators Guide}. +@uref{http://www.tldp.org/LDP/nag2/, Linux Network Administrators Guide}. If you have everything clearly pictured in your mind, proceed in the following order: -First, create the initial configuration files and public/private keypairs using the following command: -@example -tinc -n @var{NETNAME} init @var{NAME} -@end example -Second, use @samp{tinc -n @var{NETNAME} add ...} to further configure tinc. -Finally, export your host configuration file using @samp{tinc -n @var{NETNAME} export} and send it to those -people or computers you want tinc to connect to. -They should send you their host configuration file back, which you can import using @samp{tinc -n @var{NETNAME} import}. - +First, generate the configuration files (@file{tinc.conf}, your host configuration file, @file{tinc-up} and perhaps @file{tinc-down}). +Then generate the keypairs. +Finally, distribute the host configuration files. These steps are described in the subsections below. @@ -713,29 +654,30 @@ These steps are described in the subsections below. @cindex multiple networks @cindex netname - In order to allow you to run more than one tinc daemon on one computer, for instance if your computer is part of more than one VPN, you can assign a @var{netname} to your VPN. It is not required if you only run one tinc daemon, -it doesn't even have to be the same on all the nodes of your VPN, +it doesn't even have to be the same on all the sites of your VPN, but it is recommended that you choose one anyway. We will assume you use a netname throughout this document. -This means that you call tinc with the -n argument, -which will specify the netname. +This means that you call tincd with the -n argument, +which will assign a netname to this daemon. -The effect of this option is that tinc will set its configuration -root to @file{@value{sysconfdir}/tinc/@var{netname}/}, where @var{netname} is your argument to the -n option. -You will also notice that log messages it appears in syslog as coming from @file{tinc.@var{netname}}, -and on Linux, unless specified otherwise, the name of the virtual network interface will be the same as the network name. +The effect of this is that the daemon will set its configuration +root to @file{@value{sysconfdir}/tinc/@var{netname}/}, where @var{netname} is your argument to the -n +option. You'll notice that it appears in syslog as @file{tinc.@var{netname}}. However, it is not strictly necessary that you call tinc with the -n -option. If you do not use it, the network name will just be empty, and -tinc will look for files in @file{@value{sysconfdir}/tinc/} instead of -@file{@value{sysconfdir}/tinc/@var{netname}/}; -the configuration file will then be @file{@value{sysconfdir}/tinc/tinc.conf}, -and the host configuration files are expected to be in @file{@value{sysconfdir}/tinc/hosts/}. +option. In this case, the network name would just be empty, and it will +be used as such. tinc now looks for files in @file{@value{sysconfdir}/tinc/}, instead of +@file{@value{sysconfdir}/tinc/@var{netname}/}; the configuration file should be @file{@value{sysconfdir}/tinc/tinc.conf}, +and the host configuration files are now expected to be in @file{@value{sysconfdir}/tinc/hosts/}. + +But it is highly recommended that you use this feature of tinc, because +it will be so much clearer whom your daemon talks to. Hence, we will +assume that you use it. @c ================================================================== @@ -744,36 +686,24 @@ and the host configuration files are expected to be in @file{@value{sysconfdir}/ When tinc starts up, it parses the command-line options and then reads in the configuration file tinc.conf. -It will then start listening for incoming connection from other daemons, -and will by default also automatically try to connect to known peers. -By default, tinc will try to keep at least 3 working meta-connections alive at all times. +If it sees one or more `ConnectTo' values pointing to other tinc daemons in that file, +it will try to connect to those other daemons. +Whether this succeeds or not and whether `ConnectTo' is specified or not, +tinc will listen for incoming connection from other daemons. +If you did specify a `ConnectTo' value and the other side is not responding, +tinc will keep retrying. +This means that once started, tinc will stay running until you tell it to stop, +and failures to connect to other tinc daemons will not stop your tinc daemon +for trying again later. +This means you don't have to intervene if there are temporary network problems. @cindex client @cindex server There is no real distinction between a server and a client in tinc. -If you wish, you can view a tinc daemon without a `ConnectTo' statement in tinc.conf and `AutoConnect = no' as a server, -and one which does have one or more `ConnectTo' statements or `Autoconnect = yes' (which is the default) as a client. +If you wish, you can view a tinc daemon without a `ConnectTo' value as a server, +and one which does specify such a value as a client. It does not matter if two tinc daemons have a `ConnectTo' value pointing to each other however. -Connections specified using `ConnectTo' are so-called meta-connections. -Tinc daemons exchange information about all other daemon they know about via these meta-connections. -After learning about all the daemons in the VPN, -tinc will create other connections as necessary in order to communicate with them. -For example, if there are three daemons named A, B and C, and A has @samp{ConnectTo = B} in its tinc.conf file, -and C has @samp{ConnectTo = B} in its tinc.conf file, then A will learn about C from B, -and will be able to exchange VPN packets with C without the need to have @samp{ConnectTo = C} in its tinc.conf file. - -It could be that some daemons are located behind a Network Address Translation (NAT) device, or behind a firewall. -In the above scenario with three daemons, if A and C are behind a NAT, -B will automatically help A and C punch holes through their NAT, -in a way similar to the STUN protocol, so that A and C can still communicate with each other directly. -It is not always possible to do this however, and firewalls might also prevent direct communication. -In that case, VPN packets between A and C will be forwarded by B. - -In effect, all nodes in the VPN will be able to talk to each other, as long as -there is a path of meta-connections between them, and whenever possible, two -nodes will communicate with each other directly. - @c ================================================================== @node Configuration files @@ -805,10 +735,7 @@ listed in this document can also be put in put host specific configuration options in the host configuration file, as this makes it easy to exchange with other nodes. -You can edit the config file manually, but it is recommended that you use -the tinc command to change configuration variables for you. - -In the following two subsections all valid variables are listed in alphabetical order. +In this section all valid variables are listed in alphabetical order. The default value is given between parentheses, other comments are between square brackets. @@ -831,17 +758,18 @@ This option affects the address family of listening and outgoing sockets. If any is selected, then depending on the operating system both IPv4 and IPv6 or just IPv6 listening sockets will be created. -@cindex AutoConnect -@item AutoConnect = (yes) -If set to yes, tinc will automatically set up meta connections to other nodes, -without requiring @var{ConnectTo} variables. - @cindex BindToAddress -@item BindToAddress = <@var{address}> [<@var{port}>] -This is the same as ListenAddress, however the address given with the BindToAddress option -will also be used for outgoing connections. -This is useful if your computer has more than one IPv4 or IPv6 address, -and you want tinc to only use a specific one for outgoing packets. +@item BindToAddress = <@var{address}> [<@var{port}>] [experimental] +If your computer has more than one IPv4 or IPv6 address, tinc +will by default listen on all of them for incoming connections. +Multiple BindToAddress variables may be specified, +in which case listening sockets for each specified address are made. + +If no @var{port} is specified, the socket will be bound to the port specified by the Port option, +or to port 655 if neither is given. +To only bind to a specific port but not to a specific address, use "*" for the @var{address}. + +This option may not work on all platforms. @cindex BindToInterface @item BindToInterface = <@var{interface}> [experimental] @@ -851,8 +779,6 @@ possible to bind tinc to a single interface like eth0 or ppp0 with this variable. This option may not work on all platforms. -Also, on some platforms it will not actually bind to an interface, -but rather to the address that the interface has at the moment a socket is created. @cindex Broadcast @item Broadcast = (mst) [experimental] @@ -873,18 +799,6 @@ Broadcast packets received from other nodes are never forwarded. If the IndirectData option is also set, broadcast packets will only be sent to nodes which we have a meta connection to. @end table -@cindex BroadcastSubnet -@item BroadcastSubnet = @var{address}[/@var{prefixlength}] -Declares a broadcast subnet. -Any packet with a destination address falling into such a subnet will be routed as a broadcast -(provided all nodes have it declared). -This is most useful to declare subnet broadcast addresses (e.g. 10.42.255.255), -otherwise tinc won't know what to do with them. - -Note that global broadcast addresses (MAC ff:ff:ff:ff:ff:ff, IPv4 255.255.255.255), -as well as multicast space (IPv4 224.0.0.0/4, IPv6 ff00::/8) -are always considered broadcast addresses and don't need to be declared. - @cindex ConnectTo @item ConnectTo = <@var{name}> Specifies which other tinc daemon to connect to on startup. @@ -893,7 +807,7 @@ in which case outgoing connections to each specified tinc daemon are made. The names should be known to this tinc daemon (i.e., there should be a host configuration file for the name on the ConnectTo line). -If you don't specify a host with ConnectTo and have disabled AutoConnect, +If you don't specify a host with ConnectTo, tinc won't try to connect to other daemons at all, and will instead just listen for incoming connections. @@ -910,18 +824,10 @@ Do not use this option if you use switch mode and want to use IPv6. @item Device = <@var{device}> (@file{/dev/tap0}, @file{/dev/net/tun} or other depending on platform) The virtual network device to use. Tinc will automatically detect what kind of device it is. -Note that you can only use one device per daemon. Under Windows, use @var{Interface} instead of @var{Device}. Note that you can only use one device per daemon. See also @ref{Device files}. -@cindex DeviceStandby -@item DeviceStandby = (no) -When disabled, tinc calls @file{tinc-up} on startup, and @file{tinc-down} on shutdown. -When enabled, tinc will only call @file{tinc-up} when at least one node is reachable, -and will call @file{tinc-down} as soon as no nodes are reachable. -On Windows, this also determines when the virtual network interface "cable" is "plugged". - @cindex DeviceType @item DeviceType = <@var{type}> (platform dependent) The type of the virtual network device. @@ -951,12 +857,6 @@ This can be used to connect to UML, QEMU or KVM instances listening on the same Do NOT connect multiple tinc daemons to the same multicast address, this will very likely cause routing loops. Also note that this can cause decrypted VPN packets to be sent out on a real network if misconfigured. -@cindex fd -@item fd -Use a file descriptor. -All packets are read from this interface. -Packets received for the local node are written to it. - @cindex UML @item uml (not compiled in by default) Create a UNIX socket with the filename specified by @@ -1013,19 +913,6 @@ but which would have to be forwarded by an intermediate node, are dropped instea When combined with the IndirectData option, packets for nodes for which we do not have a meta connection with are also dropped. -@cindex Ed25519PrivateKeyFile -@item Ed25519PrivateKeyFile = <@var{path}> (@file{@value{sysconfdir}/tinc/@var{netname}/ed25519_key.priv}) -The file in which the private Ed25519 key of this tinc daemon resides. -This is only used if ExperimentalProtocol is enabled. - -@cindex ExperimentalProtocol -@item ExperimentalProtocol = (yes) -When this option is enabled, the SPTPS protocol will be used when connecting to nodes that also support it. -Ephemeral ECDH will be used for key exchanges, -and Ed25519 will be used instead of RSA for authentication. -When enabled, an Ed25519 key must have been generated before with -@samp{tinc generate-ed25519-keys}. - @cindex Forwarding @item Forwarding = (internal) [experimental] This option selects the way indirect packets are forwarded. @@ -1041,18 +928,20 @@ Incoming packets that are meant for another node are forwarded by tinc internall This is the default mode, and unless you really know you need another forwarding mode, don't change it. @item kernel -Incoming packets using the legacy protocol are always sent to the TUN/TAP device, -even if the packets are not for the local node. +Incoming packets are always sent to the TUN/TAP device, even if the packets are not for the local node. This is less efficient, but allows the kernel to apply its routing and firewall rules on them, and can also help debugging. -Incoming packets using the SPTPS protocol are dropped, since they are end-to-end encrypted. @end table -@cindex FWMark -@item FWMark = <@var{value}> (0) [experimental] -When set to a non-zero value, all TCP and UDP sockets created by tinc will use the given value as the firewall mark. -This can be used for mark-based routing or for packet filtering. -This option is currently only supported on Linux. +@cindex GraphDumpFile +@item GraphDumpFile = <@var{filename}> [experimental] +If this option is present, +tinc will dump the current network graph to the file @var{filename} +every minute, unless there were no changes to the graph. +The file is in a format that can be read by graphviz tools. +If @var{filename} starts with a pipe symbol |, +then the rest of the filename is interpreted as a shell command +that is executed, the graph is then sent to stdin. @cindex Hostnames @item Hostnames = (no) @@ -1064,6 +953,10 @@ it does a lookup if your DNS server is not responding. This does not affect resolving hostnames to IP addresses from the configuration file, but whether hostnames should be resolved while logging. +@cindex IffOneQueue +@item IffOneQueue = (no) [experimental] +(Linux only) Set IFF_ONE_QUEUE flag on TUN/TAP devices. + @cindex Interface @item Interface = <@var{interface}> Defines the name of the interface corresponding to the virtual network device. @@ -1071,32 +964,31 @@ Depending on the operating system and the type of device this may or may not act Under Windows, this variable is used to select which network interface will be used. If you specified a Device, this variable is almost always already correctly set. -@cindex ListenAddress -@item ListenAddress = <@var{address}> [<@var{port}>] -If your computer has more than one IPv4 or IPv6 address, tinc -will by default listen on all of them for incoming connections. -This option can be used to restrict which addresses tinc listens on. -Multiple ListenAddress variables may be specified, -in which case listening sockets for each specified address are made. - -If no @var{port} is specified, the socket will listen on the port specified by the Port option, -or to port 655 if neither is given. -To only listen on a specific port but not to a specific address, use "*" for the @var{address}. +@cindex KeyExpire +@item KeyExpire = <@var{seconds}> (3600) +This option controls the time the encryption keys used to encrypt the data +are valid. It is common practice to change keys at regular intervals to +make it even harder for crackers, even though it is thought to be nearly +impossible to crack a single key. @cindex LocalDiscovery -@item LocalDiscovery = (no) +@item LocalDiscovery = (no) [experimental] When enabled, tinc will try to detect peers that are on the same local network. This will allow direct communication using LAN addresses, even if both peers are behind a NAT and they only ConnectTo a third node outside the NAT, which normally would prevent the peers from learning each other's LAN address. -Currently, local discovery is implemented by sending some packets to the local address of the node during UDP discovery. -This will not work with old nodes that don't transmit their local address. +Currently, local discovery is implemented by sending broadcast packets to the LAN during path MTU discovery. +This feature may not work in all possible situations. -@cindex LogLevel -@item LogLevel = <@var{level}> (0) -This option controls the verbosity of the logging. -See @ref{Debug levels}. +@cindex MACExpire +@item MACExpire = <@var{seconds}> (600) +This option controls the amount of time MAC addresses are kept before they are removed. +This only has effect when Mode is set to "switch". + +@cindex MaxTimeout +@item MaxTimeout = <@var{seconds}> (900) +This is the maximum delay before trying to reconnect to other tinc daemons. @cindex Mode @item Mode = (router) @@ -1107,7 +999,7 @@ This option selects the way packets are routed to other daemons. @item router In this mode Subnet variables in the host configuration files will be used to form a routing table. -Only packets of routable protocols (IPv4 and IPv6) are supported in this mode. +Only unicast packets of routable protocols (IPv4 and IPv6) are supported in this mode. This is the default mode, and unless you really know you need another mode, don't change it. @@ -1127,33 +1019,10 @@ every packet will be broadcast to the other daemons while no routing table is managed. @end table -@cindex InvitationExpire -@item InvitationExpire = <@var{seconds}> (604800) -This option controls the time invitations are valid. - -@cindex KeyExpire -@item KeyExpire = <@var{seconds}> (3600) -This option controls the time the encryption keys used to encrypt the data -are valid. It is common practice to change keys at regular intervals to -make it even harder for crackers, even though it is thought to be nearly -impossible to crack a single key. - -@cindex MACExpire -@item MACExpire = <@var{seconds}> (600) -This option controls the amount of time MAC addresses are kept before they are removed. -This only has effect when Mode is set to "switch". - -@cindex MaxConnectionBurst -@item MaxConnectionBurst = <@var{count}> (100) -This option controls how many connections tinc accepts in quick succession. -If there are more connections than the given number in a short time interval, -tinc will reduce the number of accepted connections to only one per second, -until the burst has passed. - @cindex Name @item Name = <@var{name}> [required] This is a symbolic name for this connection. -The name must consist only of alfanumeric and underscore characters (a-z, A-Z, 0-9 and _), and is case sensitive. +The name must consist only of alphanumeric and underscore characters (a-z, A-Z, 0-9 and _). If Name starts with a $, then the contents of the environment variable that follows will be used. In that case, invalid characters will be converted to underscores. @@ -1185,7 +1054,7 @@ accidental eavesdropping if you are editing the configuration file. @cindex PrivateKeyFile @item PrivateKeyFile = <@var{path}> (@file{@value{sysconfdir}/tinc/@var{netname}/rsa_key.priv}) This is the full path name of the RSA private key file that was -generated by @samp{tinc generate-keys}. It must be a full path, not a +generated by @samp{tincd --generate-keys}. It must be a full path, not a relative directory. @cindex ProcessPriority @@ -1221,10 +1090,10 @@ The environment variables @env{NAME}, @env{NODE}, @env{REMOTEADDRES} and @env{RE @end table @cindex ReplayWindow -@item ReplayWindow = (32) +@item ReplayWindow = (16) This is the size of the replay tracking window for each remote node, in bytes. The window is a bitfield which tracks 1 packet per bit, so for example -the default setting of 32 will track up to 256 packets in the window. In high +the default setting of 16 will track up to 128 packets in the window. In high bandwidth scenarios, setting this to a higher value can reduce packet loss from the interaction of replay tracking with underlying real packet loss and/or reordering. Setting this to zero will disable replay tracking completely and @@ -1246,60 +1115,15 @@ and will only allow connections with nodes for which host config files are prese @file{@value{sysconfdir}/tinc/@var{netname}/hosts/} directory. Setting this options also implicitly sets StrictSubnets. -@cindex UDPDiscovey -@item UDPDiscovery = (yes) -When this option is enabled tinc will try to establish UDP connectivity to nodes, -using TCP while it determines if a node is reachable over UDP. If it is disabled, -tinc always assumes a node is reachable over UDP. -Note that tinc will never use UDP with nodes that have TCPOnly enabled. - -@cindex UDPDiscoveryKeepaliveInterval -@item UDPDiscoveryKeepaliveInterval = (9) -The minimum amount of time between sending UDP ping datagrams to check UDP connectivity once it has been established. -Note that these pings are large, since they are used to verify link MTU as well. - -@cindex UDPDiscoveryInterval -@item UDPDiscoveryInterval = (2) -The minimum amount of time between sending UDP ping datagrams to try to establish UDP connectivity. - -@cindex UDPDiscoveryTimeout -@item UDPDiscoveryTimeout = (30) -If tinc doesn't receive any UDP ping replies over the specified interval, -it will assume UDP communication is broken and will fall back to TCP. - -@cindex UDPInfoInterval -@item UDPInfoInterval = (5) -The minimum amount of time between sending periodic updates about UDP addresses, which are mostly useful for UDP hole punching. - @cindex UDPRcvBuf -@item UDPRcvBuf = (1048576) +@item UDPRcvBuf = (OS default) Sets the socket receive buffer size for the UDP socket, in bytes. -If set to zero, the default buffer size will be used by the operating system. -Note: this setting can have a significant impact on performance, especially raw throughput. +If unset, the default buffer size will be used by the operating system. @cindex UDPSndBuf -@item UDPSndBuf = (1048576) +@item UDPSndBuf = Pq OS default Sets the socket send buffer size for the UDP socket, in bytes. -If set to zero, the default buffer size will be used by the operating system. -Note: this setting can have a significant impact on performance, especially raw throughput. - -@cindex UPnP -@item UPnP = (no) -If this option is enabled then tinc will search for UPnP-IGD devices on the local network. -It will then create and maintain port mappings for tinc's listening TCP and UDP ports. -If set to "udponly", tinc will only create a mapping for its UDP (data) port, not for its TCP (metaconnection) port. -Note that tinc must have been built with miniupnpc support for this feature to be available. -Furthermore, be advised that enabling this can have security implications, because the miniupnpc library that -tinc uses might not be well-hardened with regard to malicious UPnP replies. - -@cindex UPnPDiscoverWait -@item UPnPDiscoverWait = (5) -The amount of time to wait for replies when probing the local network for UPnP devices. - -@cindex UPnPRefreshPeriod -@item UPnPRefreshPeriod = (5) -How often tinc will re-add the port mapping, in case it gets reset on the UPnP device. -This also controls the duration of the port mapping itself, which will be set to twice that duration. +If unset, the default buffer size will be used by the operating system. @end table @@ -1319,12 +1143,11 @@ Multiple Address variables can be specified, in which case each address will be tried until a working connection has been established. @cindex Cipher -@item Cipher = <@var{cipher}> (blowfish) -The symmetric cipher algorithm used to encrypt UDP packets using the legacy protocol. +@item Cipher = <@var{cipher}> (aes-256-cbc) +The symmetric cipher algorithm used to encrypt UDP packets. Any cipher supported by LibreSSL or OpenSSL is recognized. Furthermore, specifying "none" will turn off packet encryption. It is best to use only those ciphers which support CBC mode. -This option has no effect for connections using the SPTPS protocol, which always use AES-256-CTR. @cindex ClampMSS @item ClampMSS = (yes) @@ -1336,27 +1159,27 @@ Fragmentation Needed or Packet too Big messages are dropped by firewalls. @item Compression = <@var{level}> (0) This option sets the level of compression used for UDP packets. Possible values are 0 (off), 1 (fast zlib) and any integer up to 9 (best zlib), -10 (fast LZO) and 11 (best LZO). +10 (fast lzo) and 11 (best lzo). @cindex Digest -@item Digest = <@var{digest}> (sha1) -The digest algorithm used to authenticate UDP packets using the legacy protocol. +@item Digest = <@var{digest}> (sha256) +The digest algorithm used to authenticate UDP packets. Any digest supported by LibreSSL or OpenSSL is recognized. Furthermore, specifying "none" will turn off packet authentication. -This option has no effect for connections using the SPTPS protocol, which always use HMAC-SHA-256. @cindex IndirectData @item IndirectData = (no) -When set to yes, other nodes which do not already have a meta connection to you -will not try to establish direct communication with you. -It is best to leave this option out or set it to no. +This option specifies whether other tinc daemons besides the one you +specified with ConnectTo can make a direct connection to you. This is +especially useful if you are behind a firewall and it is impossible to +make a connection from the outside to your tinc daemon. Otherwise, it +is best to leave this option out or set it to no. @cindex MACLength @item MACLength = <@var{bytes}> (4) -The length of the message authentication code used to authenticate UDP packets using the legacy protocol. +The length of the message authentication code used to authenticate UDP packets. Can be anything from 0 up to the length of the digest produced by the digest algorithm. -This option has no effect for connections using the SPTPS protocol, which never truncate MACs. @cindex PMTU @item PMTU = <@var{mtu}> (1514) @@ -1367,10 +1190,6 @@ This option controls the initial path MTU to this node. When this option is enabled, tinc will try to discover the path MTU to this node. After the path MTU has been discovered, it will be enforced on the VPN. -@cindex MTUInfoInterval -@item MTUInfoInterval = (5) -The minimum amount of time between sending periodic updates about relay path MTU. Useful for quickly determining MTU to indirect nodes. - @cindex Port @item Port = <@var{port}> (655) This is the port this tinc daemon listens on. @@ -1383,7 +1202,7 @@ This is the RSA public key for this host. @cindex PublicKeyFile @item PublicKeyFile = <@var{path}> [obsolete] This is the full path name of the RSA public key file that was generated -by @samp{tinc generate-keys}. It must be a full path, not a relative +by @samp{tincd --generate-keys}. It must be a full path, not a relative directory. @cindex PEM format @@ -1418,6 +1237,7 @@ example: netmask 255.255.255.0 would become /24, 255.255.252.0 becomes /22. This conforms to standard CIDR notation as described in @uref{https://www.ietf.org/rfc/rfc1519.txt, RFC1519} +@cindex Subnet weight A Subnet can be given a weight to indicate its priority over identical Subnets owned by different nodes. The default weight is 10. Lower values indicate higher priority. Packets will be sent to the node with the highest priority, @@ -1425,18 +1245,15 @@ unless that node is not reachable, in which case the node with the next highest priority will be tried, and so on. @cindex TCPonly -@item TCPonly = (no) +@item TCPonly = (no) [deprecated] If this variable is set to yes, then the packets are tunnelled over a TCP connection instead of a UDP connection. This is especially useful for those who want to run a tinc daemon from behind a masquerading firewall, or if UDP packet routing is disabled somehow. Setting this options also implicitly sets IndirectData. -@cindex Weight -@item Weight = -If this variable is set, it overrides the weight given to connections made with -another host. A higher weight means a lower priority is given to this -connection when broadcasting or forwarding packets. +Since version 1.0.10, tinc will automatically detect whether communication via +UDP is possible or not. @end table @@ -1455,7 +1272,7 @@ this means that tinc will temporarily stop processing packets until the called s This guarantees that scripts will execute in the exact same order as the events that trigger them. If you need to run commands asynchronously, you have to ensure yourself that they are being run in the background. -Under Windows (not Cygwin), the scripts should have the extension @file{.bat} or @file{.cmd}. +Under Windows (not Cygwin), the scripts must have the extension .bat. @table @file @cindex tinc-up @@ -1485,25 +1302,18 @@ This script is started when any host becomes reachable. This script is started when any host becomes unreachable. @item @value{sysconfdir}/tinc/@var{netname}/subnet-up -This script is started when a Subnet becomes reachable. +This script is started when a subnet becomes reachable. The Subnet and the node it belongs to are passed in environment variables. @item @value{sysconfdir}/tinc/@var{netname}/subnet-down -This script is started when a Subnet becomes unreachable. - -@item @value{sysconfdir}/tinc/@var{netname}/invitation-created -This script is started when a new invitation has been created. - -@item @value{sysconfdir}/tinc/@var{netname}/invitation-accepted -This script is started when an invitation has been used. - +This script is started when a subnet becomes unreachable. @end table @cindex environment variables The scripts are started without command line arguments, but can make use of certain environment variables. Under UNIX like operating systems the names of environment variables must be preceded by a $ in scripts. -Under Windows, in @file{.bat} or @file{.cmd} files, they have to be put between % signs. +Under Windows, in @file{.bat} files, they have to be put between % signs. @table @env @cindex NETNAME @@ -1545,122 +1355,57 @@ When a subnet becomes (un)reachable, this is set to the subnet. @item WEIGHT When a subnet becomes (un)reachable, this is set to the subnet weight. -@cindex INVITATION_FILE -@item INVITATION_FILE -When the @file{invitation-created} script is called, -this is set to the file where the invitation details will be stored. - -@cindex INVITATION_URL -@item INVITATION_URL -When the @file{invitation-created} script is called, -this is set to the invitation URL that has been created. @end table -Do not forget that under UNIX operating systems, -you have to make the scripts executable, using the command @samp{chmod a+x script}. - @c ================================================================== @node How to configure @subsection How to configure -@subsubheading Step 1. Creating initial configuration files. +@subsubheading Step 1. Creating the main configuration file -The initial directory structure, configuration files and public/private keypairs are created using the following command: +The main configuration file will be called @file{@value{sysconfdir}/tinc/@var{netname}/tinc.conf}. +Adapt the following example to create a basic configuration file: @example -tinc -n @var{netname} init @var{name} +Name = @var{yourname} +Device = @file{/dev/tap0} @end example -(You will need to run this as root, or use "sudo".) -This will create the configuration directory @file{@value{sysconfdir}/tinc/@var{netname}.}, -and inside it will create another directory named @file{hosts/}. -In the configuration directory, it will create the file @file{tinc.conf} with the following contents: +Then, if you know to which other tinc daemon(s) yours is going to connect, +add `ConnectTo' values. + +@subsubheading Step 2. Creating your host configuration file + +If you added a line containing `Name = yourname' in the main configuration file, +you will need to create a host configuration file @file{@value{sysconfdir}/tinc/@var{netname}/hosts/yourname}. +Adapt the following example to create a host configuration file: @example -Name = @var{name} +Address = your.real.hostname.org +Subnet = 192.168.1.0/24 @end example -It will also create private RSA and Ed25519 keys, which will be stored in the files @file{rsa_key.priv} and @file{ed25519_key.priv}. -It will also create a host configuration file @file{hosts/@var{name}}, -which will contain the corresponding public RSA and Ed25519 keys. +You can also use an IP address instead of a hostname. +The `Subnet' specifies the address range that is local for @emph{your part of the VPN only}. +If you have multiple address ranges you can specify more than one `Subnet'. +You might also need to add a `Port' if you want your tinc daemon to run on a different port number than the default (655). -Finally, on UNIX operating systems, it will create an executable script @file{tinc-up}, -which will initially not do anything except warning that you should edit it. -@subsubheading Step 2. Modifying the initial configuration. +@c ================================================================== +@node Generating keypairs +@section Generating keypairs -Unless you want to use tinc in switch mode, -you should now configure which range of addresses you will use on the VPN. -Let's assume you will be part of a VPN which uses the address range 192.168.0.0/16, -and you yourself have a smaller portion of that range: 192.168.2.0/24. -Then you should run the following command: +@cindex key generation +Now that you have already created the main configuration file and your host configuration file, +you can easily create a public/private keypair by entering the following command: @example -tinc -n @var{netname} add subnet 192.168.2.0/24 +tincd -n @var{netname} -K @end example -This will add a Subnet statement to your host configuration file. -Try opening the file @file{@value{sysconfdir}/tinc/@var{netname}/hosts/@var{name}} in an editor. -You should now see a file containing the public RSA and Ed25519 keys (which looks like a bunch of random characters), -and the following line at the bottom: - -@example -Subnet = 192.168.2.0/24 -@end example - -If you will use more than one address range, you can add more Subnets. -For example, if you also use the IPv6 subnet fec0:0:0:2::/64, you can add it as well: - -@example -tinc -n @var{netname} add subnet fec0:0:0:2::/24 -@end example - -This will add another line to the file @file{hosts/@var{name}}. -If you make a mistake, you can undo it by simply using @samp{del} instead of @samp{add}. - -If you want other tinc daemons to create meta-connections to your daemon, -you should add your public IP address or hostname to your host configuration file. -For example, if your hostname is foo.example.org, run: - -@example -tinc -n @var{netname} add address foo.example.org -@end example - -@subsubheading Step 2. Exchanging configuration files. - -In order for two tinc daemons to be able to connect to each other, -they each need the other's host configuration files. -So if you want foo to be able to connect with bar, -You should send @file{hosts/@var{name}} to bar, and bar should send you his file which you should move to @file{hosts/bar}. -If you are on a UNIX platform, you can easily send an email containing the necessary information using the following command -(assuming the owner of bar has the email address bar@@example.org): - -@example -tinc -n @var{netname} export | mail -s "My config file" bar@@example.org -@end example - -If the owner of bar does the same to send his host configuration file to you, -you can probably pipe his email through the following command, -or you can just start this command in a terminal and copy&paste the email: - -@example -tinc -n @var{netname} import -@end example - -If you are the owner of bar yourself, and you have SSH access to that computer, -you can also swap the host configuration files using the following command: - -@example -tinc -n @var{netname} export \ - | ssh bar.example.org tinc -n @var{netname} exchange \ - | tinc -n @var{netname} import -@end example - -You can repeat this for a few other nodes as well. -It is not necessary to manually exchange host config files between all nodes; -after the initial connections are made tinc will learn about all the other nodes in the VPN, -and will automatically make other connections as necessary. +Tinc will generate a public and a private key and ask you where to put them. +Just press enter to accept the defaults. @c ================================================================== @@ -1683,31 +1428,21 @@ You can configure the network interface by putting ordinary ifconfig, route, and to a script named @file{@value{sysconfdir}/tinc/@var{netname}/tinc-up}. When tinc starts, this script will be executed. When tinc exits, it will execute the script named @file{@value{sysconfdir}/tinc/@var{netname}/tinc-down}, but normally you don't need to create that script. -You can manually open the script in an editor, or use the following command: -@example -tinc -n @var{netname} edit tinc-up -@end example - -An example @file{tinc-up} script, that would be appropriate for the scenario in the previous section, is: +An example @file{tinc-up} script: @example #!/bin/sh -ifconfig $INTERFACE 192.168.2.1 netmask 255.255.0.0 -ip addr add fec0:0:0:2::/48 dev $INTERFACE +ifconfig $INTERFACE 192.168.1.1 netmask 255.255.0.0 @end example -The first command gives the interface an IPv4 address and a netmask. -The kernel will also automatically add an IPv4 route to this interface, so normally you don't need +This script gives the interface an IP address and a netmask. +The kernel will also automatically add a route to this interface, so normally you don't need to add route commands to the @file{tinc-up} script. The kernel will also bring the interface up after this command. @cindex netmask The netmask is the mask of the @emph{entire} VPN network, not just your own subnet. -The second command gives the interface an IPv6 address and netmask, -which will also automatically add an IPv6 route. -If you only want to use "ip addr" commands on Linux, don't forget that it doesn't bring the interface up, unlike ifconfig, -so you need to add @samp{ip link set $INTERFACE up} in that case. The exact syntax of the ifconfig and route commands differs from platform to platform. You can look up the commands for setting addresses and adding routes in @ref{Platform specific information}, @@ -1747,9 +1482,6 @@ the real interface is also shown as a comment, to give you an idea of how these example host is set up. All branches use the netname `company' for this particular VPN. -Each branch is set up using the @samp{tinc init} and @samp{tinc config} commands, -here we just show the end results: - @subsubheading For Branch A @emph{BranchA} would be configured like this: @@ -1757,8 +1489,6 @@ here we just show the end results: In @file{@value{sysconfdir}/tinc/company/tinc-up}: @example -#!/bin/sh - # Real interface of internal network: # ifconfig eth0 10.1.54.1 netmask 255.255.0.0 @@ -1769,6 +1499,7 @@ and in @file{@value{sysconfdir}/tinc/company/tinc.conf}: @example Name = BranchA +Device = /dev/tap0 @end example On all hosts, @file{@value{sysconfdir}/tinc/company/hosts/BranchA} contains: @@ -1782,9 +1513,9 @@ Address = 1.2.3.4 -----END RSA PUBLIC KEY----- @end example -Note that the IP addresses of eth0 and the VPN interface are the same. +Note that the IP addresses of eth0 and tap0 are the same. This is quite possible, if you make sure that the netmasks of the interfaces are different. -It is in fact recommended to give both real internal network interfaces and VPN interfaces the same IP address, +It is in fact recommended to give both real internal network interfaces and tap interfaces the same IP address, since that will make things a lot easier to remember and set up. @@ -1793,8 +1524,6 @@ since that will make things a lot easier to remember and set up. In @file{@value{sysconfdir}/tinc/company/tinc-up}: @example -#!/bin/sh - # Real interface of internal network: # ifconfig eth0 10.2.43.8 netmask 255.255.0.0 @@ -1805,10 +1534,12 @@ and in @file{@value{sysconfdir}/tinc/company/tinc.conf}: @example Name = BranchB +ConnectTo = BranchA @end example Note here that the internal address (on eth0) doesn't have to be the -same as on the VPN interface. +same as on the tap0 device. Also, ConnectTo is given so that this node will +always try to connect to BranchA. On all hosts, in @file{@value{sysconfdir}/tinc/company/hosts/BranchB}: @@ -1827,8 +1558,6 @@ Address = 2.3.4.5 In @file{@value{sysconfdir}/tinc/company/tinc-up}: @example -#!/bin/sh - # Real interface of internal network: # ifconfig eth0 10.3.69.254 netmask 255.255.0.0 @@ -1839,6 +1568,8 @@ and in @file{@value{sysconfdir}/tinc/company/tinc.conf}: @example Name = BranchC +ConnectTo = BranchA +Device = /dev/tap1 @end example C already has another daemon that runs on port 655, so they have to @@ -1863,8 +1594,6 @@ Port = 2000 In @file{@value{sysconfdir}/tinc/company/tinc-up}: @example -#!/bin/sh - # Real interface of internal network: # ifconfig eth0 10.4.3.32 netmask 255.255.0.0 @@ -1875,10 +1604,15 @@ and in @file{@value{sysconfdir}/tinc/company/tinc.conf}: @example Name = BranchD +ConnectTo = BranchC +Device = /dev/net/tun @end example D will be connecting to C, which has a tincd running for this network on port 2000. It knows the port number from the host configuration file. +Also note that since D uses the tun/tap driver, the network interface +will not be called `tun' or `tap0' or something like that, but will +have the same name as netname. On all hosts, in @file{@value{sysconfdir}/tinc/company/hosts/BranchD}: @@ -1893,11 +1627,16 @@ Address = 4.5.6.7 @subsubheading Key files -A, B, C and D all have their own public/private keypairs: +A, B, C and D all have generated a public/private keypair with the following command: -The private RSA key is stored in @file{@value{sysconfdir}/tinc/company/rsa_key.priv}, -the private Ed25519 key is stored in @file{@value{sysconfdir}/tinc/company/ed25519_key.priv}, -and the public RSA and Ed25519 keys are put into the host configuration file in the @file{@value{sysconfdir}/tinc/company/hosts/} directory. +@example +tincd -n company -K +@end example + +The private key is stored in @file{@value{sysconfdir}/tinc/company/rsa_key.priv}, +the public key is put into the host configuration file in the @file{@value{sysconfdir}/tinc/company/hosts/} directory. +During key generation, tinc automatically guesses the right filenames based on the -n option and +the Name directive in the @file{tinc.conf} file (if it is available). @subsubheading Starting @@ -1914,7 +1653,7 @@ their daemons, tinc will try connecting until they are available. If everything else is done, you can start tinc by typing the following command: @example -tinc -n @var{netname} start +tincd -n @var{netname} @end example @cindex daemon @@ -1957,6 +1696,12 @@ This will also disable the automatic restart mechanism for fatal errors. Set debug level to @var{level}. The higher the debug level, the more gets logged. Everything goes via syslog. +@item -k, --kill[=@var{signal}] +Attempt to kill a running tincd (optionally with the specified @var{signal} instead of SIGTERM) and exit. +Use it in conjunction with the -n option to make sure you kill the right tinc daemon. +Under native Windows the optional argument is ignored, +the service will always be stopped and removed. + @item -n, --net=@var{netname} Use configuration for net @var{netname}. This will let tinc read all configuration files from @@ -1964,10 +1709,11 @@ This will let tinc read all configuration files from Specifying . for @var{netname} is the same as not specifying any @var{netname}. @xref{Multiple networks}. -@item --pidfile=@var{filename} -Store a cookie in @var{filename} which allows tinc to authenticate. -If unspecified, the default is -@file{@value{runstatedir}/tinc.@var{netname}.pid}. +@item -K, --generate-keys[=@var{bits}] +Generate public/private keypair of @var{bits} length. If @var{bits} is not specified, +2048 is the default. tinc will ask where you want to store the files, +but will default to the configuration directory (you can use the -c or -n option +in combination with -K). After that, tinc will quit. @item -o, --option=[@var{HOST}.]@var{KEY}=@var{VALUE} Without specifying a @var{HOST}, this will set server configuration variable @var{KEY} to @var{VALUE}. @@ -1979,8 +1725,6 @@ This option can be used more than once to specify multiple configuration variabl Lock tinc into main memory. This will prevent sensitive data like shared private keys to be written to the system swap files/partitions. -This option is not supported on all platforms. - @item --logfile[=@var{file}] Write log entries to a file instead of to the system logging facility. If @var{file} is omitted, the default is @file{@value{localstatedir}/log/tinc.@var{netname}.log}. @@ -2008,14 +1752,11 @@ you must copy @file{/etc/resolv.conf} into the chroot directory. If you want to be able to run scripts other than @file{tinc-up} in the chroot, you must ensure the appropriate shell is also installed in the chroot, along with all its dependencies. -This option is not supported on all platforms. @item -U, --user=@var{user} Switch to the given @var{user} after initialization, at the same time as chroot is performed (see --chroot above). With this option tinc drops privileges, for added security. -This option is not supported on all platforms. - @item --help Display a short reminder of these runtime options and terminate. @@ -2048,6 +1789,19 @@ New outgoing connections specified in @file{tinc.conf} will be made. If the --logfile option is used, this will also close and reopen the log file, useful when log rotation is used. +@item INT +Temporarily increases debug level to 5. +Send this signal again to revert to the original level. + +@item USR1 +Dumps the connection list to syslog. + +@item USR2 +Dumps virtual network device statistics, all known nodes, edges and subnets to syslog. + +@item WINCH +Purges all information remembered about unreachable nodes. + @end table @c ================================================================== @@ -2111,7 +1865,7 @@ Do you have a firewall or a NAT device (a masquerading firewall or perhaps an AD If so, check that it allows TCP and UDP traffic on port 655. If it masquerades and the host running tinc is behind it, make sure that it forwards TCP and UDP traffic to port 655 to the host running tinc. You can add @samp{TCPOnly = yes} to your host config file to force tinc to only use a single TCP connection, -this works through most firewalls and NATs. +this works through most firewalls and NATs. Since version 1.0.10, tinc will automatically fall back to TCP if direct communication via UDP is not possible. @end itemize @@ -2210,8 +1964,6 @@ or if that is not the case, try changing the prefix length into /32. @itemize @item If you see this only sporadically, it is harmless and caused by a node sending packets using an old key. -@item If you see this often and another node is not reachable anymore, then a NAT (masquerading firewall) is changing the source address of UDP packets. -You can add @samp{TCPOnly = yes} to host configuration files to force all VPN traffic to go over a TCP connection. @end itemize @item Got bad/bogus/unauthorized REQUEST from foo (1.2.3.4 port 12345) @@ -2242,526 +1994,6 @@ Be sure to include the following information in your bugreport: @item The output of any command that fails to work as it should (like ping or traceroute). @end itemize -@c ================================================================== -@node Controlling tinc -@chapter Controlling tinc - -@cindex command line interface -You can start, stop, control and inspect a running tincd through the tinc -command. A quick example: - -@example -tinc -n @var{netname} reload -@end example - -@cindex shell -If tinc is started without a command, it will act as a shell; it will display a -prompt, and commands can be entered on the prompt. If tinc is compiled with -libreadline, history and command completion are available on the prompt. One -can also pipe a script containing commands through tinc. In that case, lines -starting with a # symbol will be ignored. - -@menu -* tinc runtime options:: -* tinc environment variables:: -* tinc commands:: -* tinc examples:: -* tinc top:: -@end menu - - -@c ================================================================== -@node tinc runtime options -@section tinc runtime options - -@c from the manpage -@table @option -@item -c, --config=@var{path} -Read configuration options from the directory @var{path}. The default is -@file{@value{sysconfdir}/tinc/@var{netname}/}. - -@item -n, --net=@var{netname} -Use configuration for net @var{netname}. @xref{Multiple networks}. - -@item --pidfile=@var{filename} -Use the cookie from @var{filename} to authenticate with a running tinc daemon. -If unspecified, the default is -@file{@value{runstatedir}/tinc.@var{netname}.pid}. - -@cindex batch -@item -b, --batch -Don't ask for anything (non-interactive mode). - -@item --force -Force some commands to work despite warnings. - -@item --help -Display a short reminder of runtime options and commands, then terminate. - -@item --version -Output version information and exit. - -@end table - -@c ================================================================== -@node tinc environment variables -@section tinc environment variables - -@table @env -@cindex NETNAME -@item NETNAME -If no netname is specified on the command line with the @option{-n} option, -the value of this environment variable is used. -@end table - -@c ================================================================== -@node tinc commands -@section tinc commands - -@c from the manpage -@table @code - -@cindex init -@item init [@var{name}] -Create initial configuration files and RSA and Ed25519 keypairs with default length. -If no @var{name} for this node is given, it will be asked for. - -@cindex get -@item get @var{variable} -Print the current value of configuration variable @var{variable}. -If more than one variable with the same name exists, -the value of each of them will be printed on a separate line. - -@cindex set -@item set @var{variable} @var{value} -Set configuration variable @var{variable} to the given @var{value}. -All previously existing configuration variables with the same name are removed. -To set a variable for a specific host, use the notation @var{host}.@var{variable}. - -@cindex add -@item add @var{variable} @var{value} -As above, but without removing any previously existing configuration variables. -If the variable already exists with the given value, nothing happens. - -@cindex del -@item del @var{variable} [@var{value}] -Remove configuration variables with the same name and @var{value}. -If no @var{value} is given, all configuration variables with the same name will be removed. - -@cindex edit -@item edit @var{filename} -Start an editor for the given configuration file. -You do not need to specify the full path to the file. - -@cindex export -@item export -Export the host configuration file of the local node to standard output. - -@cindex export-all -@item export-all -Export all host configuration files to standard output. - -@cindex import -@item import -Import host configuration file(s) generated by the tinc export command from standard input. -Already existing host configuration files are not overwritten unless the option --force is used. - -@cindex exchange -@item exchange -The same as export followed by import. - -@cindex exchange-all -@item exchange-all -The same as export-all followed by import. - -@cindex invite -@item invite @var{name} -Prepares an invitation for a new node with the given @var{name}, -and prints a short invitation URL that can be used with the join command. - -@cindex join -@item join [@var{URL}] -Join an existing VPN using an invitation URL created using the invite command. -If no @var{URL} is given, it will be read from standard input. - -@cindex start -@item start [tincd options] -Start @samp{tincd}, optionally with the given extra options. - -@cindex stop -@item stop -Stop @samp{tincd}. - -@cindex restart -@item restart [tincd options] -Restart @samp{tincd}, optionally with the given extra options. - -@cindex reload -@item reload -Partially rereads configuration files. Connections to hosts whose host -config files are removed are closed. New outgoing connections specified -in @file{tinc.conf} will be made. - -@cindex pid -@item pid -Shows the PID of the currently running @samp{tincd}. - -@cindex generate-keys -@item generate-keys [@var{bits}] -Generate both RSA and Ed25519 keypairs (see below) and exit. -tinc will ask where you want to store the files, but will default to the -configuration directory (you can use the -c or -n option). - -@cindex generate-ed25519-keys -@item generate-ed25519-keys -Generate public/private Ed25519 keypair and exit. - -@cindex generate-rsa-keys -@item generate-rsa-keys [@var{bits}] -Generate public/private RSA keypair and exit. If @var{bits} is omitted, the -default length will be 2048 bits. When saving keys to existing files, tinc -will not delete the old keys; you have to remove them manually. - -@cindex dump -@item dump [reachable] nodes -Dump a list of all known nodes in the VPN. -If the reachable keyword is used, only lists reachable nodes. - -@item dump edges -Dump a list of all known connections in the VPN. - -@item dump subnets -Dump a list of all known subnets in the VPN. - -@item dump connections -Dump a list of all meta connections with ourself. - -@cindex graph -@item dump graph | digraph -Dump a graph of the VPN in dotty format. -Nodes are colored according to their reachability: -red nodes are unreachable, orange nodes are indirectly reachable, green nodes are directly reachable. -Black nodes are either directly or indirectly reachable, but direct reachability has not been tried yet. - -@item dump invitations -Dump a list of outstanding invitations. -The filename of the invitation, as well as the name of the node that is being invited is shown for each invitation. - -@cindex info -@item info @var{node} | @var{subnet} | @var{address} -Show information about a particular @var{node}, @var{subnet} or @var{address}. -If an @var{address} is given, any matching subnet will be shown. - -@cindex purge -@item purge -Purges all information remembered about unreachable nodes. - -@cindex debug -@item debug @var{level} -Sets debug level to @var{level}. - -@cindex log -@item log [@var{level}] -Capture log messages from a running tinc daemon. -An optional debug level can be given that will be applied only for log messages sent to tinc. - -@cindex retry -@item retry -Forces tinc to try to connect to all uplinks immediately. -Usually tinc attempts to do this itself, -but increases the time it waits between the attempts each time it failed, -and if tinc didn't succeed to connect to an uplink the first time after it started, -it defaults to the maximum time of 15 minutes. - -@cindex disconnect -@item disconnect @var{node} -Closes the meta connection with the given @var{node}. - -@cindex top -@item top -If tinc is compiled with libcurses support, this will display live traffic statistics for all the known nodes, -similar to the UNIX top command. -See below for more information. - -@cindex pcap -@item pcap -Dump VPN traffic going through the local tinc node in pcap-savefile format to standard output, -from where it can be redirected to a file or piped through a program that can parse it directly, -such as tcpdump. - -@cindex network -@item network [@var{netname}] -If @var{netname} is given, switch to that network. -Otherwise, display a list of all networks for which configuration files exist. - -@cindex fsck -@item fsck -This will check the configuration files for possible problems, -such as unsafe file permissions, missing executable bit on script, -unknown and obsolete configuration variables, wrong public and/or private keys, and so on. - -When problems are found, this will be printed on a line with WARNING or ERROR in front of it. -Most problems must be corrected by the user itself, however in some cases (like file permissions and missing public keys), -tinc will ask if it should fix the problem. - -@cindex sign -@item sign [@var{filename}] -Sign a file with the local node's private key. -If no @var{filename} is given, the file is read from standard input. -The signed file is written to standard output. - -@cindex verify -@item verify @var{name} [@var{filename}] - -Check the signature of a file against a node's public key. -The @var{name} of the node must be given, -or can be "." to check against the local node's public key, -or "*" to allow a signature from any node whose public key is known. -If no @var{filename} is given, the file is read from standard input. -If the verification is successful, a copy of the input with the signature removed is written to standard output, and the exit code will be zero. -If the verification failed, nothing will be written to standard output, and the exit code will be non-zero. - -@end table - -@c ================================================================== -@node tinc examples -@section tinc examples - -Examples of some commands: - -@example -tinc -n vpn dump graph | circo -Txlib -tinc -n vpn pcap | tcpdump -r - -tinc -n vpn top -@end example - -Examples of changing the configuration using tinc: - -@example -tinc -n vpn init foo -tinc -n vpn add Subnet 192.168.1.0/24 -tinc -n vpn add bar.Address bar.example.com -tinc -n vpn set Mode switch -tinc -n vpn export | gpg --clearsign | mail -s "My config" vpnmaster@@example.com -@end example - -@c ================================================================== -@node tinc top -@section tinc top - -@cindex top -The top command connects to a running tinc daemon and repeatedly queries its per-node traffic counters. -It displays a list of all the known nodes in the left-most column, -and the amount of bytes and packets read from and sent to each node in the other columns. -By default, the information is updated every second. -The behaviour of the top command can be changed using the following keys: - -@table @key - -@item s -Change the interval between updates. -After pressing the @key{s} key, enter the desired interval in seconds, followed by enter. -Fractional seconds are honored. -Intervals lower than 0.1 seconds are not allowed. - -@item c -Toggle between displaying current traffic rates (in packets and bytes per second) -and cumulative traffic (total packets and bytes since the tinc daemon started). - -@item n -Sort the list of nodes by name. - -@item i -Sort the list of nodes by incoming amount of bytes. - -@item I -Sort the list of nodes by incoming amount of packets. - -@item o -Sort the list of nodes by outgoing amount of bytes. - -@item O -Sort the list of nodes by outgoing amount of packets. - -@item t -Sort the list of nodes by sum of incoming and outgoing amount of bytes. - -@item T -Sort the list of nodes by sum of incoming and outgoing amount of packets. - -@item b -Show amount of traffic in bytes. - -@item k -Show amount of traffic in kilobytes. - -@item M -Show amount of traffic in megabytes. - -@item G -Show amount of traffic in gigabytes. - -@item q -Quit. - -@end table - - -@c ================================================================== -@node Invitations -@chapter Invitations - -Invitations are an easy way to add new nodes to an existing VPN. Invitations -can be created on an existing node using the @code{tinc invite} command, which -generates a relatively short URL which can be given to someone else, who uses -the @code{tinc join} command to automatically set up tinc so it can connect to -the inviting node. The next sections describe how invitations actually work, -and how to further automate the invitations. - -@menu -* How invitations work:: -* Invitation file format:: -* Writing an invitation-created script:: -@end menu - - -@c ================================================================== -@node How invitations work -@section How invitations work - -When an invitation is created on a node (which from now on we will call the -server) using the @code{tinc invite} command, an invitation file is created -that contains all the information necessary for the invitee (which we will call -the client) to create its configuration files. The invitation file is stays on -the server, but a URL is generated that has enough information for the client -to contact the server and to retrieve the invitation file. The whole URL is -around 80 characters long and looks like this: - -@example -server.example.org:12345/cW1NhLHS-1WPFlcFio8ztYHvewTTKYZp8BjEKg3vbMtDz7w4 -@end example - -It is composed of four parts: - -@example -hostname : port / keyhash cookie -@end example - -The hostname and port tell the client how to reach the tinc daemon on the server. -The part after the slash looks like one blob, but is composed of two parts. -The keyhash is the hash of the public key of the server. -The cookie is a shared secret that identifies the client to the server. - -When the client connects to the server in order to join the VPN, the client and -server will exchange temporary public keys. The client verifies that the hash -of the server's public key matches the keyhash from the invitation URL. If -not, it will immediately exit with an error. Otherwise, an ECDH exchange will -happen so the client and server can communicate privately with each other. The -client will then present the cookie to the server. The server uses this to -look up the corresponding invitation file it generated earlier. If it exists, -it will send the invitation file to the client. The client will also create a -permanent public key, and send it to the server. After the exchange is -completed, the connection is broken. The server creates a host config file for -the client containing the client's permanent public key, and the client creates -tinc.conf, host config files and possibly a tinc-up script based on the -information in the invitation file. - -It is important that the invitation URL is kept secret until it is used; if -another person gets a copy of the invitation URL before the real client runs -the @code{tinc join} command, then that other person can try to join the VPN. - - -@c ================================================================== -@node Invitation file format -@section Invitation file format - -The contents of an invitation file that is generated by the @code{tinc invite} -command looks like this: - -@example -Name = client -Netname = vpn -ConnectTo = server -#-------------------------------------# -Name = server -Ed25519PublicKey = augbnwegoij123587... -Address = server.example.com -@end example - -The file is basically a concatenation of several host config blocks. Each host -config block starts with @code{Name = ...}. Lines that look like @code{#---#} -are not important, it just makes it easier for humans to read the file. -However, the first line of an invitation file @emph{must} always start with -@code{Name = ...}. - -The first host config block is always the one representing the invitee. So the -first Name statement determines the name that the invitee will get. From the -first block, the @file{tinc.conf} and @file{hosts/client} files will be -generated; the @code{tinc join} command on the client will automatically -separate statements based on whether they should be in @file{tinc.conf} or in a -host config file. Some statements are special and are treated differently: - -@table @asis -@item Netname = <@var{netname}> -This is a hint to the invitee which netname to use for the VPN. It is used if -the invitee did not already specify a netname, and if there is no pre-existing -configuration with the same netname. - -@cindex Ifconfig -@item Ifconfig = <@var{address}[/@var{netmask}] | dhcp | dhcp6 | slaac> -This is a hint for generating a @file{tinc-up} script. -If an address is specified, a command will be added to @file{tinc-up} so the VPN interface will be configured to have the given address. -If it is the word "dhcp", a command will be added to start a DHCP client on the VPN interface. -If it is the word dhcpv6, it will be a DHCPv6 client. -If it is "slaac", then it will add commands to enable IPv6 stateless address autoconfiguration. -It is also possible to specify a MAC address, in which case a command will be added to set the MAC address of the VPN interface. - -The exact commands added to the @file{tinc-up} script depends on the operating system the client is using. -Multiple Ifconfig statements can be specified, however one should only use one Ifconfig statement per address family. - -@cindex Route -@item Route = <@var{address}[/@var{netmask}]> [<@var{gateway}>] -This is a hint for generating a @file{tinc-up} script. -Route statements are similar to Ifconfig statements, but add routes instead of addresses. -These only allow IPv4 and IPv6 routes. -If no gateway address is specified, the route is directed to the VPN interface. -In general, a gateway is only necessary when running tinc in switch mode. -@end table - -Subsequent host config blocks are copied verbatim into their respective files -in @file{hosts/}. The invitation file generated by @code{tinc invite} will -normally only contain two blocks; one for the client and one for the server. - - -@c ================================================================== -@node Writing an invitation-created script -@section Writing an invitation-created script - -When an invitation is generated, the "invitation-created" script is called (if -it exists) right after the invitation file is written, but before the URL has -been written to stdout. This allows one to change the invitation file -automatically before the invitation URL is passed to the invitee. Here is an -example shell script that approximately recreates the default invitation file: - -@example -#!/bin/sh - -cat >$INVITATION_FILE <>$INVITATION_FILE -@end example - -You can add more ConnectTo statements, and change `tinc export` to `tinc -export-all` for example. But you can also use the script to automatically hand -out a Subnet to the invitee. Note that the script doesn't have to be a shell script, -you can use any language, it just has to be executable. - - @c ================================================================== @node Technical information @chapter Technical information @@ -2803,7 +2035,7 @@ There are two possible types of virtual network devices: and `tap' style, which are Ethernet devices and handle complete Ethernet frames. So when tinc reads an Ethernet frame from the device, it determines its -type. When tinc is in it's default routing mode, it can handle IPv4 and IPv6 +type. When tinc is in its default routing mode, it can handle IPv4 and IPv6 packets. Depending on the Subnet lines, it will send the packets off to their destination IP address. In the `switch' and `hub' mode, tinc will use broadcasts and MAC address discovery to deduce the destination of the packets. @@ -2834,7 +2066,7 @@ If the virtual network device is a `tun' device (a point-to-point tunnel), there is no problem for the kernel to accept a packet. However, if it is a `tap' device (this is the only available type on FreeBSD), the destination MAC address must match that of the virtual network interface. -If tinc is in it's default routing mode, ARP does not work, so the correct destination MAC +If tinc is in its default routing mode, ARP does not work, so the correct destination MAC can not be known by the sending host. Tinc solves this by letting the receiving end detect the MAC address of its own virtual network interface and overwriting the destination MAC address of the received packet. @@ -2896,7 +2128,7 @@ daemon started with the --bypass-security option and to read and write requests by hand, provided that one understands the numeric codes sent. -The authentication scheme is described in @ref{Security}. After a +The authentication scheme is described in @ref{Authentication protocol}. After a successful authentication, the server and the client will exchange all the information about other tinc daemons and subnets they know of, so that both sides (and all the other tinc daemons behind them) have their information @@ -2983,10 +2215,10 @@ destination. @cindex PING @cindex PONG @example -daemon message +daemon message ------------------------------------------------------------------ -origin PING -dest. PONG +origin PING +dest. PONG ------------------------------------------------------------------ @end example @@ -3014,30 +2246,31 @@ the tinc project after TINC. @cindex SVPN But in order to be ``immune'' to eavesdropping, you'll have to encrypt -your data. Because tinc is a @emph{Secure} VPN (SVPN) daemon, it does +your data. Because tinc is a @emph{Secure} VPN (SVPN) daemon, it does exactly that: encrypt. -However, encryption in itself does not prevent an attacker from modifying the encrypted data. -Therefore, tinc also authenticates the data. -Finally, tinc uses sequence numbers (which themselves are also authenticated) to prevent an attacker from replaying valid packets. - -Since version 1.1pre3, tinc has two protocols used to protect your data; the legacy protocol, and the new Simple Peer-to-Peer Security (SPTPS) protocol. -The SPTPS protocol is designed to address some weaknesses in the legacy protocol. -The new authentication protocol is used when two nodes connect to each other that both have the ExperimentalProtocol option set to yes, -otherwise the legacy protocol will be used. +Tinc by default uses blowfish encryption with 128 bit keys in CBC mode, 32 bit +sequence numbers and 4 byte long message authentication codes to make sure +eavesdroppers cannot get and cannot change any information at all from the +packets they can intercept. The encryption algorithm and message authentication +algorithm can be changed in the configuration. The length of the message +authentication codes is also adjustable. The length of the key for the +encryption algorithm is always the default length used by LibreSSL/OpenSSL. @menu -* Legacy authentication protocol:: -* Simple Peer-to-Peer Security:: +* Authentication protocol:: * Encryption of network packets:: * Security issues:: @end menu @c ================================================================== -@node Legacy authentication protocol -@subsection Legacy authentication protocol +@node Authentication protocol +@subsection Authentication protocol -@cindex legacy authentication protocol +@cindex authentication +A new scheme for authentication in tinc has been devised, which offers some +improvements over the protocol used in 1.0pre2 and 1.0pre3. Explanation is +below. @cindex ID @cindex META_KEY @@ -3051,50 +2284,28 @@ client server -client ID client 17.2 - | | +-> minor protocol version - | +----> major protocol version - +--------> name of tinc daemon +client ID client 12 + | +---> version + +-------> name of tinc daemon -server ID server 17.2 - | | +-> minor protocol version - | +----> major protocol version - +--------> name of tinc daemon +server ID server 12 + | +---> version + +-------> name of tinc daemon -client META_KEY 94 64 0 0 5f0823a93e35b69e...7086ec7866ce582b - | | | | \_________________________________/ - | | | | +-> RSAKEYLEN bits totally random string S1, - | | | | encrypted with server's public RSA key - | | | +-> compression level - | | +---> MAC length - | +------> digest algorithm NID - +---------> cipher algorithm NID +client META_KEY 5f0823a93e35b69e...7086ec7866ce582b + \_________________________________/ + +-> RSAKEYLEN bits totally random string S1, + encrypted with server's public RSA key -server META_KEY 94 64 0 0 6ab9c1640388f8f0...45d1a07f8a672630 - | | | | \_________________________________/ - | | | | +-> RSAKEYLEN bits totally random string S2, - | | | | encrypted with client's public RSA key - | | | +-> compression level - | | +---> MAC length - | +------> digest algorithm NID - +---------> cipher algorithm NID --------------------------------------------------------------------------- -@end example - -The protocol allows each side to specify encryption algorithms and parameters, -but in practice they are always fixed, since older versions of tinc did not -allow them to be different from the default values. The cipher is always -Blowfish in OFB mode, the digest is SHA1, but the MAC length is zero and no -compression is used. +server META_KEY 6ab9c1640388f8f0...45d1a07f8a672630 + \_________________________________/ + +-> RSAKEYLEN bits totally random string S2, + encrypted with client's public RSA key From now on: -@itemize -@item the client will symmetrically encrypt outgoing traffic using S1 -@item the server will symmetrically encrypt outgoing traffic using S2 -@end itemize + - the client will symmetrically encrypt outgoing traffic using S1 + - the server will symmetrically encrypt outgoing traffic using S2 -@example --------------------------------------------------------------------------- client CHALLENGE da02add1817c1920989ba6ae2a49cecbda0 \_________________________________/ +-> CHALLEN bits totally random string H1 @@ -3114,188 +2325,57 @@ their identity. Further information is exchanged. client ACK 655 123 0 | | +-> options - | +----> estimated weight - +--------> listening port of client + | +----> estimated weight + +--------> listening port of client server ACK 655 321 0 | | +-> options - | +----> estimated weight - +--------> listening port of server + | +----> estimated weight + +--------> listening port of server -------------------------------------------------------------------------- @end example -This legacy authentication protocol has several weaknesses, pointed out by security export Peter Gutmann. -First, data is encrypted with RSA without padding. -Padding schemes are designed to prevent attacks when the size of the plaintext is not equal to the size of the RSA key. -Tinc always encrypts random nonces that have the same size as the RSA key, so we do not believe this leads to a break of the security. -There might be timing or other side-channel attacks against RSA encryption and decryption, tinc does not employ any protection against those. -Furthermore, both sides send identical messages to each other, there is no distinction between server and client, -which could make a MITM attack easier. -However, no exploit is known in which a third party who is not already trusted by other nodes in the VPN could gain access. -Finally, the RSA keys are used to directly encrypt the session keys, which means that if the RSA keys are compromised, it is possible to decrypt all previous VPN traffic. -In other words, the legacy protocol does not provide perfect forward secrecy. +This new scheme has several improvements, both in efficiency and security. -@c ================================================================== -@node Simple Peer-to-Peer Security -@subsection Simple Peer-to-Peer Security -@cindex SPTPS +First of all, the server sends exactly the same kind of messages over the wire +as the client. The previous versions of tinc first authenticated the client, +and then the server. This scheme even allows both sides to send their messages +simultaneously, there is no need to wait for the other to send something first. +This means that any calculations that need to be done upon sending or receiving +a message can also be done in parallel. This is especially important when doing +RSA encryption/decryption. Given that these calculations are the main part of +the CPU time spent for the authentication, speed is improved by a factor 2. -The SPTPS protocol is designed to address the weaknesses in the legacy protocol. -SPTPS is based on TLS 1.2, but has been simplified: there is no support for exchanging public keys, and there is no cipher suite negotiation. -Instead, SPTPS always uses a very strong cipher suite: -peers authenticate each other using 521 bits ECC keys, -Diffie-Hellman using ephemeral 521 bits ECC keys is used to provide perfect forward secrecy (PFS), -AES-256-CTR is used for encryption, and HMAC-SHA-256 for message authentication. +Second, only one RSA encrypted message is sent instead of two. This reduces the +amount of information attackers can see (and thus use for a cryptographic +attack). It also improves speed by a factor two, making the total speedup a +factor 4. -Similar to TLS, messages are split up in records. -A complete logical record contains the following information: +Third, and most important: +The symmetric cipher keys are exchanged first, the challenge is done +afterwards. In the previous authentication scheme, because a man-in-the-middle +could pass the challenge/chal_reply phase (by just copying the messages between +the two real tinc daemons), but no information was exchanged that was really +needed to read the rest of the messages, the challenge/chal_reply phase was of +no real use. The man-in-the-middle was only stopped by the fact that only after +the ACK messages were encrypted with the symmetric cipher. Potentially, it +could even send it's own symmetric key to the server (if it knew the server's +public key) and read some of the metadata the server would send it (it was +impossible for the mitm to read actual network packets though). The new scheme +however prevents this. -@itemize -@item uint32_t seqno (network byte order) -@item uint16_t length (network byte order) -@item uint8_t type -@item opaque data[length] -@item opaque hmac[HMAC_SIZE] (HMAC over all preceding fields) -@end itemize +This new scheme makes sure that first of all, symmetric keys are exchanged. The +rest of the messages are then encrypted with the symmetric cipher. Then, each +side can only read received messages if they have their private key. The +challenge is there to let the other side know that the private key is really +known, because a challenge reply can only be sent back if the challenge is +decrypted correctly, and that can only be done with knowledge of the private +key. -Depending on whether SPTPS records are sent via TCP or UDP, either the seqno or the length field is omitted on the wire -(but they are still included in the calculation of the HMAC); -for TCP packets are guaranteed to arrive in-order so we can infer the seqno, but packets can be split or merged, so we still need the length field to determine the boundaries between records; -for UDP packets we know that there is exactly one record per packet, and we know the length of a packet, but packets can be dropped, duplicated and/or reordered, so we need to include the seqno. +Fourth: the first thing that is sent via the symmetric cipher encrypted +connection is a totally random string, so that there is no known plaintext (for +an attacker) in the beginning of the encrypted stream. -The type field is used to distinguish between application records or handshake records. -Types 0 to 127 are application records, type 128 is a handshake record, and types 129 to 255 are reserved. - -Before the initial handshake, no fields are encrypted, and the HMAC field is not present. -After the authentication handshake, the length (if present), type and data fields are encrypted, and the HMAC field is present. -For UDP packets, the seqno field is not encrypted, as it is used to determine the value of the counter used for encryption. - -The authentication consists of an exchange of Key EXchange, SIGnature and ACKnowledge messages, transmitted using type 128 records. - -Overview: - -@example -Initiator Responder ---------------------- -KEX -> - <- KEX -SIG -> - <- SIG - -...encrypt and HMAC using session keys from now on... - -App -> - <- App -... - ... - -...key renegotiation starts here... - -KEX -> - <- KEX -SIG -> - <- SIG -ACK -> - <- ACK - -...encrypt and HMAC using new session keys from now on... - -App -> - <- App -... - ... ---------------------- -@end example - -Note that the responder does not need to wait before it receives the first KEX message, -it can immediately send its own once it has accepted an incoming connection. - -Key EXchange message: - -@itemize -@item uint8_t kex_version (always 0 in this version of SPTPS) -@item opaque nonce[32] (random number) -@item opaque ecdh_key[ECDH_SIZE] -@end itemize - -SIGnature message: - -@itemize -@item opaque ecdsa_signature[ECDSA_SIZE] -@end itemize - -ACKnowledge message: - -@itemize -@item empty (only sent after key renegotiation) -@end itemize - -Remarks: - -@itemize -@item At the start, both peers generate a random nonce and an Elliptic Curve public key and send it to the other in the KEX message. -@item After receiving the other's KEX message, both KEX messages are concatenated (see below), - and the result is signed using ECDSA. - The result is sent to the other. -@item After receiving the other's SIG message, the signature is verified. - If it is correct, the shared secret is calculated from the public keys exchanged in the KEX message using the Elliptic Curve Diffie-Helman algorithm. -@item The shared secret key is expanded using a PRF. - Both nonces and the application specific label are also used as input for the PRF. -@item An ACK message is sent only when doing key renegotiation, and is sent using the old encryption keys. -@item The expanded key is used to key the encryption and HMAC algorithms. -@end itemize - -The signature is calculated over this string: - -@itemize -@item uint8_t initiator (0 = local peer, 1 = remote peer is initiator) -@item opaque remote_kex_message[1 + 32 + ECDH_SIZE] -@item opaque local_kex_message[1 + 32 + ECDH_SIZE] -@item opaque label[label_length] -@end itemize - -The PRF is calculated as follows: - -@itemize -@item A HMAC using SHA512 is used, the shared secret is used as the key. -@item For each block of 64 bytes, a HMAC is calculated. For block n: hmac[n] = - HMAC_SHA512(hmac[n - 1] + seed) -@item For the first block (n = 1), hmac[0] is given by HMAC_SHA512(zeroes + seed), - where zeroes is a block of 64 zero bytes. -@end itemize - -The seed is as follows: - -@itemize -@item const char[13] "key expansion" -@item opaque responder_nonce[32] -@item opaque initiator_nonce[32] -@item opaque label[label_length] -@end itemize - -The expanded key is used as follows: - -@itemize -@item opaque responder_cipher_key[CIPHER_KEYSIZE] -@item opaque responder_digest_key[DIGEST_KEYSIZE] -@item opaque initiator_cipher_key[CIPHER_KEYSIZE] -@item opaque initiator_digest_key[DIGEST_KEYSIZE] -@end itemize - -Where initiator_cipher_key is the key used by session initiator to encrypt -messages sent to the responder. - -When using 256 bits Ed25519 keys, the AES-256-CTR cipher and HMAC-SHA-256 digest algorithm, -the sizes are as follows: - -@example -ECDH_SIZE: 32 (= 256/8) -ECDSA_SIZE: 64 (= 2 * 256/8) -CIPHER_KEYSIZE: 48 (= 256/8 + 128/8) -DIGEST_KEYSIZE: 32 (= 256/8) -@end example - -Note that the cipher key also includes the initial value for the counter. @c ================================================================== @node Encryption of network packets @@ -3305,11 +2385,11 @@ Note that the cipher key also includes the initial value for the counter. A data packet can only be sent if the encryption key is known to both parties, and the connection is activated. If the encryption key is not known, a request is sent to the destination using the meta connection -to retrieve it. +to retrieve it. The packet is stored in a queue while waiting for the +key to arrive. @cindex UDP -The UDP packets can be either encrypted with the legacy protocol or with SPTPS. -In case of the legacy protocol, the UDP packet containing the network packet from the VPN has the following layout: +The UDP packet containing the network packet from the VPN has the following layout: @example ... | IP header | UDP header | seqno | VPN packet | MAC | UDP trailer @@ -3319,38 +2399,12 @@ In case of the legacy protocol, the UDP packet containing the network packet fro Encrypted with symmetric cipher @end example - - - So, the entire VPN packet is encrypted using a symmetric cipher, including a 32 bits sequence number that is added in front of the actual VPN packet, to act as a unique IV for each packet and to prevent replay attacks. A message authentication code -is added to the UDP packet to prevent alteration of packets. -Tinc by default encrypts network packets using Blowfish with 128 bit keys in CBC mode -and uses 4 byte long message authentication codes to make sure -eavesdroppers cannot get and cannot change any information at all from the -packets they can intercept. The encryption algorithm and message authentication -algorithm can be changed in the configuration. The length of the message -authentication codes is also adjustable. The length of the key for the -encryption algorithm is always the default length used by LibreSSL/OpenSSL. - -The SPTPS protocol is described in @ref{Simple Peer-to-Peer Security}. -For comparison, this is how SPTPS UDP packets look: - -@example -... | IP header | UDP header | seqno | type | VPN packet | MAC | UDP trailer - \__________________/\_____/ - | | - V +---> digest algorithm - Encrypted with symmetric cipher -@end example - -The difference is that the seqno is not encrypted, since the encryption cipher is used in CTR mode, -and therefore the seqno must be known before the packet can be decrypted. -Furthermore, the MAC is never truncated. -The SPTPS protocol always uses the AES-256-CTR cipher and HMAC-SHA-256 digest, -this cannot be changed. - +is added to the UDP packet to prevent alteration of packets. By default the +first 4 bytes of the digest are used for this, but this can be changed using +the MACLength configuration variable. @c ================================================================== @node Security issues @@ -3373,24 +2427,8 @@ On the 15th of September 2003, Peter Gutmann posted a security analysis of tinc 1.0.1. He argues that the 32 bit sequence number used by tinc is not a good IV, that tinc's default length of 4 bytes for the MAC is too short, and he doesn't like tinc's use of RSA during authentication. We do not know of a security hole -in the legacy protocol of tinc, but it is not as strong as TLS or IPsec. - -The Sweet32 attack affects versions of tinc prior to 1.0.30. - -On September 6th, 2018, Michael Yonly contacted us and provided -proof-of-concept code that allowed a remote attacker to create an -authenticated, one-way connection with a node, and also that there was a -possibility for a man-in-the-middle to force UDP packets from a node to be sent -in plaintext. The first issue was trivial to exploit on tinc versions prior to -1.0.30, but the changes in 1.0.30 to mitigate the Sweet32 attack made this -weakness much harder to exploit. These issues have been fixed in tinc 1.0.35. - -This version of tinc comes with an improved protocol, called Simple -Peer-to-Peer Security (SPTPS), which aims to be as strong as TLS with one of -the strongest cipher suites. None of the above security issues affected SPTPS. -However, be aware that SPTPS is only used between nodes running tinc 1.1pre* or -later, and in a VPN with nodes running different versions, the security might -only be as good as that of the oldest version. +in this version of tinc, but tinc's security is not as strong as TLS or IPsec. +We will address these issues in tinc 2.0. Cryptography is a hard thing to get right. We cannot make any guarantees. Time, review and feedback are the only things that can @@ -3422,7 +2460,7 @@ netmask should be such that it encompasses the entire VPN. For IPv4 addresses: -@multitable {Darwin (MacOS/X)} {ifconfig route add -bla network address netmask netmask prefixlength interface} +@multitable {Darwin (Mac OS X)} {ifconfig route add -bla network address netmask netmask prefixlength interface} @item Linux @tab @code{ifconfig} @var{interface} @var{address} @code{netmask} @var{netmask} @item Linux iproute2 @@ -3435,7 +2473,7 @@ For IPv4 addresses: @tab @code{ifconfig} @var{interface} @var{address} @code{netmask} @var{netmask} @item Solaris @tab @code{ifconfig} @var{interface} @var{address} @code{netmask} @var{netmask} -@item Darwin (MacOS/X) +@item Darwin (Mac OS X) @tab @code{ifconfig} @var{interface} @var{address} @code{netmask} @var{netmask} @item Windows @tab @code{netsh interface ip set address} @var{interface} @code{static} @var{address} @var{netmask} @@ -3443,7 +2481,7 @@ For IPv4 addresses: For IPv6 addresses: -@multitable {Darwin (MacOS/X)} {ifconfig route add -bla network address netmask netmask prefixlength interface} +@multitable {Darwin (Mac OS X)} {ifconfig route add -bla network address netmask netmask prefixlength interface} @item Linux @tab @code{ifconfig} @var{interface} @code{add} @var{address}@code{/}@var{prefixlength} @item FreeBSD @@ -3456,7 +2494,7 @@ For IPv6 addresses: @tab @code{ifconfig} @var{interface} @code{inet6 plumb up} @item @tab @code{ifconfig} @var{interface} @code{inet6 addif} @var{address} @var{address} -@item Darwin (MacOS/X) +@item Darwin (Mac OS X) @tab @code{ifconfig} @var{interface} @code{inet6} @var{address} @code{prefixlen} @var{prefixlength} @item Windows @tab @code{netsh interface ipv6 add address} @var{interface} @code{static} @var{address}/@var{prefixlength} @@ -3467,7 +2505,7 @@ continue to exist even if tinc quit, although this is normally not required. It can be useful to set up a tun/tap interface owned by a non-root user, so tinc can be started without needing any root privileges at all. -@multitable {Darwin (MacOS/X)} {ifconfig route add -bla network address netmask netmask prefixlength interface} +@multitable {Darwin (Mac OS X)} {ifconfig route add -bla network address netmask netmask prefixlength interface} @item Linux @tab @code{ip tuntap add dev} @var{interface} @code{mode} @var{tun|tap} @code{user} @var{username} @end multitable @@ -3485,7 +2523,7 @@ support this. Adding routes to IPv4 subnets: -@multitable {Darwin (MacOS/X)} {ifconfig route add -bla network address netmask netmask prefixlength interface} +@multitable {Darwin (Mac OS X)} {ifconfig route add -bla network address netmask netmask prefixlength interface} @item Linux @tab @code{route add -net} @var{network_address} @code{netmask} @var{netmask} @var{interface} @item Linux iproute2 @@ -3498,15 +2536,15 @@ Adding routes to IPv4 subnets: @tab @code{route add} @var{network_address}@code{/}@var{prefixlength} @var{local_address} @item Solaris @tab @code{route add} @var{network_address}@code{/}@var{prefixlength} @var{local_address} @code{-interface} -@item Darwin (MacOS/X) -@tab @code{route add} @var{network_address}@code{/}@var{prefixlength} @var{local_address} +@item Darwin (Mac OS X) +@tab @code{route add} @var{network_address}@code{/}@var{prefixlength} @code{-interface} @var{interface} @item Windows @tab @code{netsh routing ip add persistentroute} @var{network_address} @var{netmask} @var{interface} @var{local_address} @end multitable Adding routes to IPv6 subnets: -@multitable {Darwin (MacOS/X)} {ifconfig route add -bla network address netmask netmask prefixlength interface} +@multitable {Darwin (Mac OS X)} {ifconfig route add -bla network address netmask netmask prefixlength interface} @item Linux @tab @code{route add -A inet6} @var{network_address}@code{/}@var{prefixlength} @var{interface} @item Linux iproute2 @@ -3519,8 +2557,8 @@ Adding routes to IPv6 subnets: @tab @code{route add -inet6} @var{network_address} @var{local_address} @code{-prefixlen} @var{prefixlength} @item Solaris @tab @code{route add -inet6} @var{network_address}@code{/}@var{prefixlength} @var{local_address} @code{-interface} -@item Darwin (MacOS/X) -@tab ? +@item Darwin (Mac OS X) +@tab @code{route add -inet6} @var{network_address}@code{/}@var{prefixlength} @code{-interface} @var{interface} @item Windows @tab @code{netsh interface ipv6 add route} @var{network address}/@var{prefixlength} @var{interface} @end multitable @@ -3573,12 +2611,11 @@ distribution's way of starting tinc at boot time. @node Windows @subsection Windows -On Windows, if tinc is started with the @code{tinc start} command without using -the @code{-D} or @code{--no-detach} option, it will automatically register -itself as a service that is started at boot time. When tinc is stopped using -the @code{tinc stop} command, it will also automatically unregister itself. -Once tinc is registered as a service, it is also possible to stop and start -tinc using the Windows Services Manager. +On Windows, if tinc is started without the @code{-D} or @code{--no-detach} +option, it will automatically register itself as a service that is started at +boot time. When tinc is stopped using the @code{-k} or @code{--kill}, it will +also automatically unregister itself. Once tinc is registered as a service, it +is also possible to stop and start tinc using the Windows Services Manager. @c ================================================================== @node Other platforms diff --git a/doc/tincd.8.in b/doc/tincd.8.in index a14eb4e..bdccf9d 100644 --- a/doc/tincd.8.in +++ b/doc/tincd.8.in @@ -1,4 +1,4 @@ -.Dd 2013-01-14 +.Dd 2014-05-11 .Dt TINCD 8 .\" Manual page created by: .\" Ivo Timmermans @@ -8,15 +8,17 @@ .Nd tinc VPN daemon .Sh SYNOPSIS .Nm -.Op Fl cdDKnsoLRU +.Op Fl cdDkKnoLRU .Op Fl -config Ns = Ns Ar DIR .Op Fl -no-detach .Op Fl -debug Ns Op = Ns Ar LEVEL +.Op Fl -kill Ns Op = Ns Ar SIGNAL .Op Fl -net Ns = Ns Ar NETNAME +.Op Fl -generate-keys Ns Op = Ns Ar BITS .Op Fl -option Ns = Ns Ar [HOST.]KEY=VALUE .Op Fl -mlock .Op Fl -logfile Ns Op = Ns Ar FILE -.Op Fl -syslog +.Op Fl -pidfile Ns = Ns Ar FILE .Op Fl -bypass-security .Op Fl -chroot .Op Fl -user Ns = Ns Ar USER @@ -52,6 +54,14 @@ If not mentioned otherwise, this will show log messages on the standard error ou Increase debug level or set it to .Ar LEVEL (see below). +.It Fl k, -kill Ns Op = Ns Ar SIGNAL +Attempt to kill a running +.Nm +(optionally with the specified +.Ar SIGNAL +instead of SIGTERM) and exit. +Under Windows (not Cygwin) the optional argument is ignored, +the service will always be stopped and removed. .It Fl n, -net Ns = Ns Ar NETNAME Connect to net .Ar NETNAME . @@ -63,6 +73,13 @@ for .Ar NETNAME is the same as not specifying any .Ar NETNAME . +.It Fl K, -generate-keys Ns Op = Ns Ar BITS +Generate public/private RSA keypair and exit. +If +.Ar BITS +is omitted, the default length will be 2048 bits. +When saving keys to existing files, tinc will not delete the old keys, +you have to remove them manually. .It Fl o, -option Ns = Ns Ar [HOST.]KEY=VALUE Without specifying a .Ar HOST , @@ -82,25 +99,18 @@ This option can be used more than once to specify multiple configuration variabl .It Fl L, -mlock Lock tinc into main memory. This will prevent sensitive data like shared private keys to be written to the system swap files/partitions. -This option is not supported on all platforms. .It Fl -logfile Ns Op = Ns Ar FILE Write log entries to a file instead of to the system logging facility. If .Ar FILE is omitted, the default is .Pa @localstatedir@/log/tinc. Ns Ar NETNAME Ns Pa .log. -.It Fl s, -syslog -When this option is is set, tinc uses syslog instead of stderr in --no-detach mode. -.It Fl -pidfile Ns = Ns Ar FILENAME -Store a cookie in -.Ar FILENAME -which allows -.Xr tinc 8 -to authenticate. -If +.It Fl -pidfile Ns = Ns Ar FILE +Write PID to .Ar FILE -is omitted, the default is +instead of .Pa @runstatedir@/tinc. Ns Ar NETNAME Ns Pa .pid. +Under Windows this option will be ignored. .It Fl -bypass-security Disables encryption and authentication of the meta protocol. Only useful for debugging. @@ -108,12 +118,10 @@ Only useful for debugging. With this option tinc chroots into the directory where network config is located (@sysconfdir@/tinc/NETNAME if -n option is used, or to the directory specified with -c option) after initialization. -This option is not supported on all platforms. .It Fl U, -user Ns = Ns Ar USER setuid to the specified .Ar USER after initialization. -This option is not supported on all platforms. .It Fl -help Display short list of options. .It Fl -version @@ -143,6 +151,15 @@ If the .Fl -logfile option is used, this will also close and reopen the log file, useful when log rotation is used. +.It INT +Temporarily increases debug level to 5. +Send this signal again to revert to the original level. +.It USR1 +Dumps the connection list to syslog. +.It USR2 +Dumps virtual network device statistics, all known nodes, edges and subnets to syslog. +.It WINCH +Purges all information remembered about unreachable nodes. .El .Sh DEBUG LEVELS The tinc daemon can send a lot of messages to the syslog. @@ -189,7 +206,6 @@ If you find any bugs, report them to tinc@tinc-vpn.org. .Sh TODO A lot, especially security auditing. .Sh SEE ALSO -.Xr tinc 8 , .Xr tinc.conf 5 , .Pa https://www.tinc-vpn.org/ , .Pa http://www.cabal.org/ . diff --git a/doc/tincinclude.texi b/doc/tincinclude.texi index 6bb64ca..b784882 100644 --- a/doc/tincinclude.texi +++ b/doc/tincinclude.texi @@ -1,4 +1,4 @@ -@set VERSION 1.1pre17 +@set VERSION 1.0.36 @set PACKAGE tinc @set sysconfdir /etc @set localstatedir /var diff --git a/m4/ax_append_flag.m4 b/m4/ax_append_flag.m4 index 08f2e07..1d38b76 100644 --- a/m4/ax_append_flag.m4 +++ b/m4/ax_append_flag.m4 @@ -49,23 +49,21 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 6 +#serial 2 AC_DEFUN([AX_APPEND_FLAG], -[dnl -AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF -AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])]) -AS_VAR_SET_IF(FLAGS,[ - AS_CASE([" AS_VAR_GET(FLAGS) "], - [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])], - [ - AS_VAR_APPEND(FLAGS,[" $1"]) - AC_RUN_LOG([: FLAGS="$FLAGS"]) - ]) - ], - [ - AS_VAR_SET(FLAGS,[$1]) - AC_RUN_LOG([: FLAGS="$FLAGS"]) - ]) +[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX +AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])dnl +AS_VAR_SET_IF(FLAGS, + [case " AS_VAR_GET(FLAGS) " in + *" $1 "*) + AC_RUN_LOG([: FLAGS already contains $1]) + ;; + *) + AC_RUN_LOG([: FLAGS="$FLAGS $1"]) + AS_VAR_SET(FLAGS, ["AS_VAR_GET(FLAGS) $1"]) + ;; + esac], + [AS_VAR_SET(FLAGS,["$1"])]) AS_VAR_POPDEF([FLAGS])dnl ])dnl AX_APPEND_FLAG diff --git a/m4/ax_code_coverage.m4 b/m4/ax_code_coverage.m4 deleted file mode 100644 index 0934a44..0000000 --- a/m4/ax_code_coverage.m4 +++ /dev/null @@ -1,264 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_code_coverage.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CODE_COVERAGE() -# -# DESCRIPTION -# -# Defines CODE_COVERAGE_CPPFLAGS, CODE_COVERAGE_CFLAGS, -# CODE_COVERAGE_CXXFLAGS and CODE_COVERAGE_LIBS which should be included -# in the CPPFLAGS, CFLAGS CXXFLAGS and LIBS/LIBADD variables of every -# build target (program or library) which should be built with code -# coverage support. Also defines CODE_COVERAGE_RULES which should be -# substituted in your Makefile; and $enable_code_coverage which can be -# used in subsequent configure output. CODE_COVERAGE_ENABLED is defined -# and substituted, and corresponds to the value of the -# --enable-code-coverage option, which defaults to being disabled. -# -# Test also for gcov program and create GCOV variable that could be -# substituted. -# -# Note that all optimisation flags in CFLAGS must be disabled when code -# coverage is enabled. -# -# Usage example: -# -# configure.ac: -# -# AX_CODE_COVERAGE -# -# Makefile.am: -# -# @CODE_COVERAGE_RULES@ -# my_program_LIBS = ... $(CODE_COVERAGE_LIBS) ... -# my_program_CPPFLAGS = ... $(CODE_COVERAGE_CPPFLAGS) ... -# my_program_CFLAGS = ... $(CODE_COVERAGE_CFLAGS) ... -# my_program_CXXFLAGS = ... $(CODE_COVERAGE_CXXFLAGS) ... -# -# This results in a "check-code-coverage" rule being added to any -# Makefile.am which includes "@CODE_COVERAGE_RULES@" (assuming the module -# has been configured with --enable-code-coverage). Running `make -# check-code-coverage` in that directory will run the module's test suite -# (`make check`) and build a code coverage report detailing the code which -# was touched, then print the URI for the report. -# -# In earlier versions of this macro, CODE_COVERAGE_LDFLAGS was defined -# instead of CODE_COVERAGE_LIBS. They are both still defined, but use of -# CODE_COVERAGE_LIBS is preferred for clarity; CODE_COVERAGE_LDFLAGS is -# deprecated. They have the same value. -# -# This code was derived from Makefile.decl in GLib, originally licenced -# under LGPLv2.1+. -# -# LICENSE -# -# Copyright (c) 2012, 2016 Philip Withnall -# Copyright (c) 2012 Xan Lopez -# Copyright (c) 2012 Christian Persch -# Copyright (c) 2012 Paolo Borelli -# Copyright (c) 2012 Dan Winship -# Copyright (c) 2015 Bastien ROUCARIES -# -# This library is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; either version 2.1 of the License, or (at -# your option) any later version. -# -# This library is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser -# General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see . - -#serial 21 - -AC_DEFUN([AX_CODE_COVERAGE],[ - dnl Check for --enable-code-coverage - AC_REQUIRE([AC_PROG_SED]) - - # allow to override gcov location - AC_ARG_WITH([gcov], - [AS_HELP_STRING([--with-gcov[=GCOV]], [use given GCOV for coverage (GCOV=gcov).])], - [_AX_CODE_COVERAGE_GCOV_PROG_WITH=$with_gcov], - [_AX_CODE_COVERAGE_GCOV_PROG_WITH=gcov]) - - AC_MSG_CHECKING([whether to build with code coverage support]) - AC_ARG_ENABLE([code-coverage], - AS_HELP_STRING([--enable-code-coverage], - [Whether to enable code coverage support]),, - enable_code_coverage=no) - - AM_CONDITIONAL([CODE_COVERAGE_ENABLED], [test x$enable_code_coverage = xyes]) - AC_SUBST([CODE_COVERAGE_ENABLED], [$enable_code_coverage]) - AC_MSG_RESULT($enable_code_coverage) - - AS_IF([ test "$enable_code_coverage" = "yes" ], [ - # check for gcov - AC_CHECK_TOOL([GCOV], - [$_AX_CODE_COVERAGE_GCOV_PROG_WITH], - [:]) - AS_IF([test "X$GCOV" = "X:"], - [AC_MSG_ERROR([gcov is needed to do coverage])]) - AC_SUBST([GCOV]) - - dnl Check if gcc is being used - AS_IF([ test "$GCC" = "no" ], [ - AC_MSG_ERROR([not compiling with gcc, which is required for gcov code coverage]) - ]) - - AC_CHECK_PROG([LCOV], [lcov], [lcov]) - AC_CHECK_PROG([GENHTML], [genhtml], [genhtml]) - - AS_IF([ test -z "$LCOV" ], [ - AC_MSG_ERROR([To enable code coverage reporting you must have lcov installed]) - ]) - - AS_IF([ test -z "$GENHTML" ], [ - AC_MSG_ERROR([Could not find genhtml from the lcov package]) - ]) - - dnl Build the code coverage flags - dnl Define CODE_COVERAGE_LDFLAGS for backwards compatibility - CODE_COVERAGE_CPPFLAGS="-DNDEBUG" - CODE_COVERAGE_CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage" - CODE_COVERAGE_CXXFLAGS="-O0 -g -fprofile-arcs -ftest-coverage" - CODE_COVERAGE_LIBS="-lgcov" - CODE_COVERAGE_LDFLAGS="$CODE_COVERAGE_LIBS" - - AC_SUBST([CODE_COVERAGE_CPPFLAGS]) - AC_SUBST([CODE_COVERAGE_CFLAGS]) - AC_SUBST([CODE_COVERAGE_CXXFLAGS]) - AC_SUBST([CODE_COVERAGE_LIBS]) - AC_SUBST([CODE_COVERAGE_LDFLAGS]) - - [CODE_COVERAGE_RULES_CHECK=' - -$(A''M_V_at)$(MAKE) $(AM_MAKEFLAGS) -k check - $(A''M_V_at)$(MAKE) $(AM_MAKEFLAGS) code-coverage-capture -'] - [CODE_COVERAGE_RULES_CAPTURE=' - $(code_coverage_v_lcov_cap)$(LCOV) $(code_coverage_quiet) $(addprefix --directory ,$(CODE_COVERAGE_DIRECTORY)) --capture --output-file "$(CODE_COVERAGE_OUTPUT_FILE).tmp" --test-name "$(call code_coverage_sanitize,$(PACKAGE_NAME)-$(PACKAGE_VERSION))" --no-checksum --compat-libtool $(CODE_COVERAGE_LCOV_SHOPTS) $(CODE_COVERAGE_LCOV_OPTIONS) - $(code_coverage_v_lcov_ign)$(LCOV) $(code_coverage_quiet) $(addprefix --directory ,$(CODE_COVERAGE_DIRECTORY)) --remove "$(CODE_COVERAGE_OUTPUT_FILE).tmp" "/tmp/*" $(CODE_COVERAGE_IGNORE_PATTERN) --output-file "$(CODE_COVERAGE_OUTPUT_FILE)" $(CODE_COVERAGE_LCOV_SHOPTS) $(CODE_COVERAGE_LCOV_RMOPTS) - -@rm -f $(CODE_COVERAGE_OUTPUT_FILE).tmp - $(code_coverage_v_genhtml)LANG=C $(GENHTML) $(code_coverage_quiet) $(addprefix --prefix ,$(CODE_COVERAGE_DIRECTORY)) --output-directory "$(CODE_COVERAGE_OUTPUT_DIRECTORY)" --title "$(PACKAGE_NAME)-$(PACKAGE_VERSION) Code Coverage" --legend --show-details "$(CODE_COVERAGE_OUTPUT_FILE)" $(CODE_COVERAGE_GENHTML_OPTIONS) - @echo "file://$(abs_builddir)/$(CODE_COVERAGE_OUTPUT_DIRECTORY)/index.html" -'] - [CODE_COVERAGE_RULES_CLEAN=' -clean: code-coverage-clean -distclean: code-coverage-clean -code-coverage-clean: - -$(LCOV) --directory $(top_builddir) -z - -rm -rf $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_FILE).tmp $(CODE_COVERAGE_OUTPUT_DIRECTORY) - -find . \( -name "*.gcda" -o -name "*.gcno" -o -name "*.gcov" \) -delete -'] - ], [ - [CODE_COVERAGE_RULES_CHECK=' - @echo "Need to reconfigure with --enable-code-coverage" -'] - CODE_COVERAGE_RULES_CAPTURE="$CODE_COVERAGE_RULES_CHECK" - CODE_COVERAGE_RULES_CLEAN='' - ]) - -[CODE_COVERAGE_RULES=' -# Code coverage -# -# Optional: -# - CODE_COVERAGE_DIRECTORY: Top-level directory for code coverage reporting. -# Multiple directories may be specified, separated by whitespace. -# (Default: $(top_builddir)) -# - CODE_COVERAGE_OUTPUT_FILE: Filename and path for the .info file generated -# by lcov for code coverage. (Default: -# $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage.info) -# - CODE_COVERAGE_OUTPUT_DIRECTORY: Directory for generated code coverage -# reports to be created. (Default: -# $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage) -# - CODE_COVERAGE_BRANCH_COVERAGE: Set to 1 to enforce branch coverage, -# set to 0 to disable it and leave empty to stay with the default. -# (Default: empty) -# - CODE_COVERAGE_LCOV_SHOPTS_DEFAULT: Extra options shared between both lcov -# instances. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE) -# - CODE_COVERAGE_LCOV_SHOPTS: Extra options to shared between both lcov -# instances. (Default: $CODE_COVERAGE_LCOV_SHOPTS_DEFAULT) -# - CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH: --gcov-tool pathtogcov -# - CODE_COVERAGE_LCOV_OPTIONS_DEFAULT: Extra options to pass to the -# collecting lcov instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH) -# - CODE_COVERAGE_LCOV_OPTIONS: Extra options to pass to the collecting lcov -# instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_DEFAULT) -# - CODE_COVERAGE_LCOV_RMOPTS_DEFAULT: Extra options to pass to the filtering -# lcov instance. (Default: empty) -# - CODE_COVERAGE_LCOV_RMOPTS: Extra options to pass to the filtering lcov -# instance. (Default: $CODE_COVERAGE_LCOV_RMOPTS_DEFAULT) -# - CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT: Extra options to pass to the -# genhtml instance. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE) -# - CODE_COVERAGE_GENHTML_OPTIONS: Extra options to pass to the genhtml -# instance. (Default: $CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT) -# - CODE_COVERAGE_IGNORE_PATTERN: Extra glob pattern of files to ignore -# -# The generated report will be titled using the $(PACKAGE_NAME) and -# $(PACKAGE_VERSION). In order to add the current git hash to the title, -# use the git-version-gen script, available online. - -# Optional variables -CODE_COVERAGE_DIRECTORY ?= $(top_builddir) -CODE_COVERAGE_OUTPUT_FILE ?= $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage.info -CODE_COVERAGE_OUTPUT_DIRECTORY ?= $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage -CODE_COVERAGE_BRANCH_COVERAGE ?= -CODE_COVERAGE_LCOV_SHOPTS_DEFAULT ?= $(if $(CODE_COVERAGE_BRANCH_COVERAGE),\ ---rc lcov_branch_coverage=$(CODE_COVERAGE_BRANCH_COVERAGE)) -CODE_COVERAGE_LCOV_SHOPTS ?= $(CODE_COVERAGE_LCOV_SHOPTS_DEFAULT) -CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH ?= --gcov-tool "$(GCOV)" -CODE_COVERAGE_LCOV_OPTIONS_DEFAULT ?= $(CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH) -CODE_COVERAGE_LCOV_OPTIONS ?= $(CODE_COVERAGE_LCOV_OPTIONS_DEFAULT) -CODE_COVERAGE_LCOV_RMOPTS_DEFAULT ?= -CODE_COVERAGE_LCOV_RMOPTS ?= $(CODE_COVERAGE_LCOV_RMOPTS_DEFAULT) -CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT ?=\ -$(if $(CODE_COVERAGE_BRANCH_COVERAGE),\ ---rc genhtml_branch_coverage=$(CODE_COVERAGE_BRANCH_COVERAGE)) -CODE_COVERAGE_GENHTML_OPTIONS ?= $(CODE_COVERAGE_GENHTML_OPTIONS_DEFAULTS) -CODE_COVERAGE_IGNORE_PATTERN ?= - -code_coverage_v_lcov_cap = $(code_coverage_v_lcov_cap_$(V)) -code_coverage_v_lcov_cap_ = $(code_coverage_v_lcov_cap_$(AM_DEFAULT_VERBOSITY)) -code_coverage_v_lcov_cap_0 = @echo " LCOV --capture"\ - $(CODE_COVERAGE_OUTPUT_FILE); -code_coverage_v_lcov_ign = $(code_coverage_v_lcov_ign_$(V)) -code_coverage_v_lcov_ign_ = $(code_coverage_v_lcov_ign_$(AM_DEFAULT_VERBOSITY)) -code_coverage_v_lcov_ign_0 = @echo " LCOV --remove /tmp/*"\ - $(CODE_COVERAGE_IGNORE_PATTERN); -code_coverage_v_genhtml = $(code_coverage_v_genhtml_$(V)) -code_coverage_v_genhtml_ = $(code_coverage_v_genhtml_$(AM_DEFAULT_VERBOSITY)) -code_coverage_v_genhtml_0 = @echo " GEN " $(CODE_COVERAGE_OUTPUT_DIRECTORY); -code_coverage_quiet = $(code_coverage_quiet_$(V)) -code_coverage_quiet_ = $(code_coverage_quiet_$(AM_DEFAULT_VERBOSITY)) -code_coverage_quiet_0 = --quiet - -# sanitizes the test-name: replaces with underscores: dashes and dots -code_coverage_sanitize = $(subst -,_,$(subst .,_,$(1))) - -# Use recursive makes in order to ignore errors during check -check-code-coverage:'"$CODE_COVERAGE_RULES_CHECK"' - -# Capture code coverage data -code-coverage-capture: code-coverage-capture-hook'"$CODE_COVERAGE_RULES_CAPTURE"' - -# Hook rule executed before code-coverage-capture, overridable by the user -code-coverage-capture-hook: - -'"$CODE_COVERAGE_RULES_CLEAN"' - -GITIGNOREFILES ?= -GITIGNOREFILES += $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_DIRECTORY) - -A''M_DISTCHECK_CONFIGURE_FLAGS ?= -A''M_DISTCHECK_CONFIGURE_FLAGS += --disable-code-coverage - -.PHONY: check-code-coverage code-coverage-capture code-coverage-capture-hook code-coverage-clean -'] - - AC_SUBST([CODE_COVERAGE_RULES]) - m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([CODE_COVERAGE_RULES])]) -]) diff --git a/m4/curses.m4 b/m4/curses.m4 deleted file mode 100644 index 031e1ee..0000000 --- a/m4/curses.m4 +++ /dev/null @@ -1,44 +0,0 @@ -dnl Check to find the curses headers/libraries - -AC_DEFUN([tinc_CURSES], -[ - AC_ARG_ENABLE([curses], - AS_HELP_STRING([--disable-curses], [disable curses support])) - AS_IF([test "x$enable_curses" != "xno"], [ - AC_DEFINE(HAVE_CURSES, 1, [have curses support]) - curses=true - AC_ARG_WITH(curses, - AS_HELP_STRING([--with-curses=DIR], [curses base directory, or:]), - [curses="$withval" - CPPFLAGS="$CPPFLAGS -I$withval/include" - LDFLAGS="$LDFLAGS -L$withval/lib"] - ) - - AC_ARG_WITH(curses-include, - AS_HELP_STRING([--with-curses-include=DIR], [curses headers directory]), - [curses_include="$withval" - CPPFLAGS="$CPPFLAGS -I$withval"] - ) - - AC_ARG_WITH(curses-lib, - AS_HELP_STRING([--with-curses-lib=DIR], [curses library directory]), - [curses_lib="$withval" - LDFLAGS="$LDFLAGS -L$withval"] - ) - - AC_CHECK_HEADERS(curses.h, - [], - [AC_MSG_ERROR("curses header files not found."); break] - ) - - AC_CHECK_LIB(ncurses, initscr, - [CURSES_LIBS="-lncurses"; AC_CHECK_LIB(tinfo, wtimeout, [CURSES_LIBS+=" -ltinfo"], [])], - [AC_CHECK_LIB(curses, initscr, - [CURSES_LIBS="-lcurses"], - [AC_MSG_ERROR("curses libraries not found.")] - )] - ) - ]) - - AC_SUBST(CURSES_LIBS) -]) diff --git a/m4/libgcrypt.m4 b/m4/libgcrypt.m4 deleted file mode 100644 index 01c7478..0000000 --- a/m4/libgcrypt.m4 +++ /dev/null @@ -1,33 +0,0 @@ -dnl Check to find the libgcrypt headers/libraries - -AC_DEFUN([tinc_LIBGCRYPT], -[ - AC_ARG_WITH(libgcrypt, - AS_HELP_STRING([--with-libgcrypt=DIR], [libgcrypt base directory, or:]), - [libgcrypt="$withval" - CPPFLAGS="$CPPFLAGS -I$withval/include" - LDFLAGS="$LDFLAGS -L$withval/lib"] - ) - - AC_ARG_WITH(libgcrypt-include, - AS_HELP_STRING([--with-libgcrypt-include=DIR], [libgcrypt headers directory (without trailing /libgcrypt)]), - [libgcrypt_include="$withval" - CPPFLAGS="$CPPFLAGS -I$withval"] - ) - - AC_ARG_WITH(libgcrypt-lib, - AS_HELP_STRING([--with-libgcrypt-lib=DIR], [libgcrypt library directory]), - [libgcrypt_lib="$withval" - LDFLAGS="$LDFLAGS -L$withval"] - ) - - AC_CHECK_HEADERS([gcrypt.h], - [], - [AC_MSG_ERROR([libgcrypt header files not found.]); break] - ) - - AC_CHECK_LIB(gcrypt, gcry_cipher_encrypt, - [LIBS="-lgcrypt $LIBS"], - [AC_MSG_ERROR([libgcrypt libraries not found.])] - ) -]) diff --git a/m4/miniupnpc.m4 b/m4/miniupnpc.m4 deleted file mode 100644 index c2aca29..0000000 --- a/m4/miniupnpc.m4 +++ /dev/null @@ -1,40 +0,0 @@ -dnl Check to find the miniupnpc headers/libraries - -AC_DEFUN([tinc_MINIUPNPC], -[ - AC_ARG_ENABLE([miniupnpc], - AS_HELP_STRING([--enable-miniupnpc], [enable miniupnpc support])) - AS_IF([test "x$enable_miniupnpc" = "xyes"], [ - AC_DEFINE(HAVE_MINIUPNPC, 1, [have miniupnpc support]) - AC_ARG_WITH(miniupnpc, - AS_HELP_STRING([--with-miniupnpc=DIR], [miniupnpc base directory, or:]), - [miniupnpc="$withval" - CPPFLAGS="$CPPFLAGS -I$withval/include" - LDFLAGS="$LDFLAGS -L$withval/lib"] - ) - - AC_ARG_WITH(miniupnpc-include, - AS_HELP_STRING([--with-miniupnpc-include=DIR], [miniupnpc headers directory]), - [miniupnpc_include="$withval" - CPPFLAGS="$CPPFLAGS -I$withval"] - ) - - AC_ARG_WITH(miniupnpc-lib, - AS_HELP_STRING([--with-miniupnpc-lib=DIR], [miniupnpc library directory]), - [miniupnpc_lib="$withval" - LDFLAGS="$LDFLAGS -L$withval"] - ) - - AC_CHECK_HEADERS(miniupnpc/miniupnpc.h, - [], - [AC_MSG_ERROR("miniupnpc header files not found."); break] - ) - - AC_CHECK_LIB(miniupnpc, upnpDiscover, - [MINIUPNPC_LIBS="$LIBS -lminiupnpc"], - [AC_MSG_ERROR("miniupnpc libraries not found.")] - ) - ]) - - AC_SUBST(MINIUPNPC_LIBS) -]) diff --git a/m4/openssl.m4 b/m4/openssl.m4 index 0ff939b..895c31a 100644 --- a/m4/openssl.m4 +++ b/m4/openssl.m4 @@ -35,7 +35,7 @@ AC_DEFUN([tinc_OPENSSL], LDFLAGS="$LDFLAGS -L$withval"] ) - AC_CHECK_HEADERS([openssl/evp.h openssl/rsa.h openssl/rand.h openssl/err.h openssl/sha.h openssl/pem.h openssl/engine.h], + AC_CHECK_HEADERS(openssl/evp.h openssl/rsa.h openssl/rand.h openssl/err.h openssl/sha.h openssl/pem.h openssl/engine.h, [], [AC_MSG_ERROR([LibreSSL/OpenSSL header files not found.]); break] ) @@ -54,6 +54,5 @@ AC_DEFUN([tinc_OPENSSL], [#include ] ) - AC_CHECK_FUNCS([BN_GENCB_new ERR_remove_state RSA_set0_key], , , [#include ]) - AC_CHECK_FUNCS([HMAC_CTX_new], , , [#include ]) + AC_CHECK_FUNCS([BN_GENCB_new RSA_set0_key], , , [#include ]) ]) diff --git a/m4/readline.m4 b/m4/readline.m4 deleted file mode 100644 index f29e692..0000000 --- a/m4/readline.m4 +++ /dev/null @@ -1,42 +0,0 @@ -dnl Check to find the readline headers/libraries - -AC_DEFUN([tinc_READLINE], -[ - AC_ARG_ENABLE([readline], - AS_HELP_STRING([--disable-readline], [disable readline support])) - AS_IF([test "x$enable_readline" != "xno"], [ - AC_DEFINE(HAVE_READLINE, 1, [have readline support]) - readline=true - AC_ARG_WITH(readline, - AS_HELP_STRING([--with-readline=DIR], [readline base directory, or:]), - [readline="$withval" - CPPFLAGS="$CPPFLAGS -I$withval/include" - LDFLAGS="$LDFLAGS -L$withval/lib"] - ) - - AC_ARG_WITH(readline-include, - AS_HELP_STRING([--with-readline-include=DIR], [readline headers directory]), - [readline_include="$withval" - CPPFLAGS="$CPPFLAGS -I$withval"] - ) - - AC_ARG_WITH(readline-lib, - AS_HELP_STRING([--with-readline-lib=DIR], [readline library directory]), - [readline_lib="$withval" - LDFLAGS="$LDFLAGS -L$withval"] - ) - - AC_CHECK_HEADERS([readline/readline.h readline/history.h], - [], - [AC_MSG_ERROR("readline header files not found."); break] - ) - - AC_CHECK_LIB(readline, readline, - [READLINE_LIBS="-lreadline"], - [AC_MSG_ERROR("readline library not found.")], - [$CURSES_LIBS] - ) - ]) - - AC_SUBST(READLINE_LIBS) -]) diff --git a/src/Makefile.am b/src/Makefile.am index cb188d2..7b3dd97 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,174 +1,54 @@ ## Produce this file with automake to get Makefile.in -sbin_PROGRAMS = tincd tinc -check_PROGRAMS = sptps_test sptps_keypair -EXTRA_PROGRAMS = sptps_test sptps_keypair - -CLEANFILES = version_git.h - -.PHONY: version-stamp -version-stamp: - -version_git.h: version-stamp - $(AM_V_GEN)echo >$@ - @-(cd $(srcdir) && git describe 2>/dev/null >/dev/null) && echo '#define GIT_DESCRIPTION "'`(cd $(srcdir) && git describe) | sed 's/release-//'`'"' >$@ ||: -${srcdir}/version.c: version_git.h - -## Now a hack to appease some versions of BSD make that don't understand that "./foo" is the same as "foo". -if BSD -version.c: ${srcdir}/version.c -endif - -if LINUX -EXTRA_PROGRAMS += sptps_speed -endif - -ed25519_SOURCES = \ - ed25519/ed25519.h \ - ed25519/fe.c ed25519/fe.h \ - ed25519/fixedint.h \ - ed25519/ge.c ed25519/ge.h \ - ed25519/key_exchange.c \ - ed25519/keypair.c \ - ed25519/precomp_data.h \ - ed25519/sc.c ed25519/sc.h \ - ed25519/sha512.c ed25519/sha512.h \ - ed25519/sign.c \ - ed25519/verify.c - -chacha_poly1305_SOURCES = \ - chacha-poly1305/chacha.c chacha-poly1305/chacha.h \ - chacha-poly1305/chacha-poly1305.c chacha-poly1305/chacha-poly1305.h \ - chacha-poly1305/poly1305.c chacha-poly1305/poly1305.h +sbin_PROGRAMS = tincd tincd_SOURCES = \ - address_cache.c address_cache.h \ - autoconnect.c autoconnect.h \ - buffer.c buffer.h \ - cipher.h \ + have.h \ + system.h \ + avl_tree.c avl_tree.h \ conf.c conf.h \ connection.c connection.h \ - control.c control.h \ - control_common.h \ - crypto.h \ device.h \ - digest.h \ dropin.c dropin.h \ dummy_device.c \ - ecdh.h \ - ecdsa.h \ - ecdsagen.h \ edge.c edge.h \ ethernet.h \ event.c event.h \ - fd_device.c \ + fake-getaddrinfo.c fake-getaddrinfo.h \ + fake-getnameinfo.c fake-getnameinfo.h \ graph.c graph.h \ - hash.c hash.h \ - have.h \ ipv4.h \ ipv6.h \ list.c list.h \ logger.c logger.h \ meta.c meta.h \ multicast_device.c \ - names.c names.h \ net.c net.h \ net_packet.c \ net_setup.c \ net_socket.c \ netutl.c netutl.h \ node.c node.h \ - prf.h \ + pidfile.c pidfile.h \ process.c process.h \ protocol.c protocol.h \ protocol_auth.c \ protocol_edge.c \ - protocol_key.c \ protocol_misc.c \ + protocol_key.c \ protocol_subnet.c \ + proxy.c proxy.h \ raw_socket_device.c \ route.c route.h \ - rsa.h \ - rsagen.h \ - script.c script.h \ - splay_tree.c splay_tree.h \ - sptps.c sptps.h \ subnet.c subnet.h \ - subnet_parse.c \ - system.h \ tincd.c \ utils.c utils.h \ - xalloc.h \ - version.c version.h \ - ed25519/ecdh.c \ - ed25519/ecdsa.c \ - $(ed25519_SOURCES) \ - $(chacha_poly1305_SOURCES) - -tinc_SOURCES = \ - dropin.c dropin.h \ - fsck.c fsck.h \ - ifconfig.c ifconfig.h \ - info.c info.h \ - invitation.c invitation.h \ - list.c list.h \ - names.c names.h \ - netutl.c netutl.h \ - script.c script.h \ - sptps.c sptps.h \ - subnet_parse.c subnet.h \ - tincctl.c tincctl.h \ - top.c top.h \ - utils.c utils.h \ - version.c version.h \ - ed25519/ecdh.c \ - ed25519/ecdsa.c \ - ed25519/ecdsagen.c \ - $(ed25519_SOURCES) \ - $(chacha_poly1305_SOURCES) - -sptps_test_SOURCES = \ - logger.c logger.h \ - sptps.c sptps.h \ - sptps_test.c \ - utils.c utils.h \ - ed25519/ecdh.c \ - ed25519/ecdsa.c \ - $(ed25519_SOURCES) \ - $(chacha_poly1305_SOURCES) - -sptps_keypair_SOURCES = \ - sptps_keypair.c \ - utils.c utils.h \ - ed25519/ecdsagen.c \ - $(ed25519_SOURCES) - -sptps_speed_SOURCES = \ - logger.c logger.h \ - sptps.c sptps.h \ - sptps_speed.c \ - utils.c utils.h \ - ed25519/ecdh.c \ - ed25519/ecdsa.c \ - ed25519/ecdsagen.c \ - $(ed25519_SOURCES) \ - $(chacha_poly1305_SOURCES) - -## Conditionally compile device drivers + xalloc.h if !GETOPT tincd_SOURCES += \ getopt.c getopt.h \ getopt1.c -tinc_SOURCES += \ - getopt.c getopt.h \ - getopt1.c -sptps_test_SOURCES += \ - getopt.c getopt.h \ - getopt1.c -sptps_keypair_SOURCES += \ - getopt.c getopt.h \ - getopt1.c endif if LINUX @@ -202,88 +82,8 @@ if VDE tincd_SOURCES += vde_device.c endif -if OPENSSL -tincd_SOURCES += \ - openssl/cipher.c \ - openssl/crypto.c \ - openssl/digest.c openssl/digest.h \ - openssl/prf.c \ - openssl/rsa.c -tinc_SOURCES += \ - openssl/cipher.c \ - openssl/crypto.c \ - openssl/digest.c openssl/digest.h \ - openssl/prf.c \ - openssl/rsa.c \ - openssl/rsagen.c -sptps_test_SOURCES += \ - openssl/crypto.c \ - openssl/digest.c openssl/digest.h \ - openssl/prf.c -sptps_keypair_SOURCES += \ - openssl/crypto.c -sptps_speed_SOURCES += \ - openssl/crypto.c \ - openssl/digest.c openssl/digest.h \ - openssl/prf.c -else -if GCRYPT -tincd_SOURCES += \ - gcrypt/cipher.c \ - gcrypt/crypto.c \ - gcrypt/digest.c gcrypt/digest.h \ - gcrypt/prf.c \ - gcrypt/rsa.c -tinc_SOURCES += \ - gcrypt/cipher.c \ - gcrypt/crypto.c \ - gcrypt/digest.c gcrypt/digest.h \ - gcrypt/prf.c \ - gcrypt/rsa.c \ - gcrypt/rsagen.c -sptps_test_SOURCES += \ - gcrypt/cipher.c \ - gcrypt/crypto.c \ - gcrypt/digest.c gcrypt/digest.h \ - gcrypt/prf.c -sptps_keypair_SOURCES += \ - openssl/crypto.c -sptps_speed_SOURCES += \ - openssl/crypto.c \ - openssl/digest.c openssl/digest.h \ - openssl/prf.c -else -tincd_SOURCES += \ - nolegacy/crypto.c \ - nolegacy/prf.c -tinc_SOURCES += \ - nolegacy/crypto.c \ - nolegacy/prf.c -sptps_test_SOURCES += \ - nolegacy/crypto.c \ - nolegacy/prf.c -sptps_keypair_SOURCES += \ - nolegacy/crypto.c -sptps_speed_SOURCES += \ - nolegacy/crypto.c \ - nolegacy/prf.c -endif -endif - -if MINIUPNPC -tincd_SOURCES += upnp.h upnp.c -tincd_LDADD = $(MINIUPNPC_LIBS) -tincd_LDFLAGS = -pthread -endif - -tinc_LDADD = $(READLINE_LIBS) $(CURSES_LIBS) -sptps_speed_LDADD = -lrt - -LIBS = @LIBS@ -lm $(CODE_COVERAGE_LIBS) - if TUNEMU LIBS += -lpcap endif -AM_CFLAGS = -DCONFDIR=\"$(sysconfdir)\" -DRUNSTATEDIR=\"$(runstatedir)\" -DLOCALSTATEDIR=\"$(localstatedir)\" -DSBINDIR=\"$(sbindir)\" -iquote. $(CODE_COVERAGE_CFLAGS) -AM_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS) +AM_CPPFLAGS = -DCONFDIR=\"$(sysconfdir)\" -DRUNSTATEDIR=\"$(runstatedir)\" -DLOCALSTATEDIR=\"$(localstatedir)\" -I $(abs_top_builddir)/ diff --git a/src/Makefile.in b/src/Makefile.in index 6651ad9..93039a2 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -88,113 +88,20 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -sbin_PROGRAMS = tincd$(EXEEXT) tinc$(EXEEXT) -check_PROGRAMS = sptps_test$(EXEEXT) sptps_keypair$(EXEEXT) -EXTRA_PROGRAMS = sptps_test$(EXEEXT) sptps_keypair$(EXEEXT) \ - $(am__EXEEXT_1) -@LINUX_TRUE@am__append_1 = sptps_speed -@GETOPT_FALSE@am__append_2 = \ +sbin_PROGRAMS = tincd$(EXEEXT) +@GETOPT_FALSE@am__append_1 = \ @GETOPT_FALSE@ getopt.c getopt.h \ @GETOPT_FALSE@ getopt1.c -@GETOPT_FALSE@am__append_3 = \ -@GETOPT_FALSE@ getopt.c getopt.h \ -@GETOPT_FALSE@ getopt1.c - -@GETOPT_FALSE@am__append_4 = \ -@GETOPT_FALSE@ getopt.c getopt.h \ -@GETOPT_FALSE@ getopt1.c - -@GETOPT_FALSE@am__append_5 = \ -@GETOPT_FALSE@ getopt.c getopt.h \ -@GETOPT_FALSE@ getopt1.c - -@LINUX_TRUE@am__append_6 = linux/device.c -@BSD_TRUE@am__append_7 = bsd/device.c -@BSD_TRUE@@TUNEMU_TRUE@am__append_8 = bsd/tunemu.c bsd/tunemu.h -@SOLARIS_TRUE@am__append_9 = solaris/device.c -@MINGW_TRUE@am__append_10 = mingw/device.c mingw/common.h -@CYGWIN_TRUE@am__append_11 = cygwin/device.c -@UML_TRUE@am__append_12 = uml_device.c -@VDE_TRUE@am__append_13 = vde_device.c -@OPENSSL_TRUE@am__append_14 = \ -@OPENSSL_TRUE@ openssl/cipher.c \ -@OPENSSL_TRUE@ openssl/crypto.c \ -@OPENSSL_TRUE@ openssl/digest.c openssl/digest.h \ -@OPENSSL_TRUE@ openssl/prf.c \ -@OPENSSL_TRUE@ openssl/rsa.c - -@OPENSSL_TRUE@am__append_15 = \ -@OPENSSL_TRUE@ openssl/cipher.c \ -@OPENSSL_TRUE@ openssl/crypto.c \ -@OPENSSL_TRUE@ openssl/digest.c openssl/digest.h \ -@OPENSSL_TRUE@ openssl/prf.c \ -@OPENSSL_TRUE@ openssl/rsa.c \ -@OPENSSL_TRUE@ openssl/rsagen.c - -@OPENSSL_TRUE@am__append_16 = \ -@OPENSSL_TRUE@ openssl/crypto.c \ -@OPENSSL_TRUE@ openssl/digest.c openssl/digest.h \ -@OPENSSL_TRUE@ openssl/prf.c - -@OPENSSL_TRUE@am__append_17 = \ -@OPENSSL_TRUE@ openssl/crypto.c - -@OPENSSL_TRUE@am__append_18 = \ -@OPENSSL_TRUE@ openssl/crypto.c \ -@OPENSSL_TRUE@ openssl/digest.c openssl/digest.h \ -@OPENSSL_TRUE@ openssl/prf.c - -@GCRYPT_TRUE@@OPENSSL_FALSE@am__append_19 = \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/cipher.c \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/crypto.c \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/digest.c gcrypt/digest.h \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/prf.c \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/rsa.c - -@GCRYPT_TRUE@@OPENSSL_FALSE@am__append_20 = \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/cipher.c \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/crypto.c \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/digest.c gcrypt/digest.h \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/prf.c \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/rsa.c \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/rsagen.c - -@GCRYPT_TRUE@@OPENSSL_FALSE@am__append_21 = \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/cipher.c \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/crypto.c \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/digest.c gcrypt/digest.h \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/prf.c - -@GCRYPT_TRUE@@OPENSSL_FALSE@am__append_22 = \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ openssl/crypto.c - -@GCRYPT_TRUE@@OPENSSL_FALSE@am__append_23 = \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ openssl/crypto.c \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ openssl/digest.c openssl/digest.h \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ openssl/prf.c - -@GCRYPT_FALSE@@OPENSSL_FALSE@am__append_24 = \ -@GCRYPT_FALSE@@OPENSSL_FALSE@ nolegacy/crypto.c \ -@GCRYPT_FALSE@@OPENSSL_FALSE@ nolegacy/prf.c - -@GCRYPT_FALSE@@OPENSSL_FALSE@am__append_25 = \ -@GCRYPT_FALSE@@OPENSSL_FALSE@ nolegacy/crypto.c \ -@GCRYPT_FALSE@@OPENSSL_FALSE@ nolegacy/prf.c - -@GCRYPT_FALSE@@OPENSSL_FALSE@am__append_26 = \ -@GCRYPT_FALSE@@OPENSSL_FALSE@ nolegacy/crypto.c \ -@GCRYPT_FALSE@@OPENSSL_FALSE@ nolegacy/prf.c - -@GCRYPT_FALSE@@OPENSSL_FALSE@am__append_27 = \ -@GCRYPT_FALSE@@OPENSSL_FALSE@ nolegacy/crypto.c - -@GCRYPT_FALSE@@OPENSSL_FALSE@am__append_28 = \ -@GCRYPT_FALSE@@OPENSSL_FALSE@ nolegacy/crypto.c \ -@GCRYPT_FALSE@@OPENSSL_FALSE@ nolegacy/prf.c - -@MINIUPNPC_TRUE@am__append_29 = upnp.h upnp.c -@TUNEMU_TRUE@am__append_30 = -lpcap +@LINUX_TRUE@am__append_2 = linux/device.c +@BSD_TRUE@am__append_3 = bsd/device.c +@BSD_TRUE@@TUNEMU_TRUE@am__append_4 = bsd/tunemu.c bsd/tunemu.h +@SOLARIS_TRUE@am__append_5 = solaris/device.c +@MINGW_TRUE@am__append_6 = mingw/device.c mingw/common.h +@CYGWIN_TRUE@am__append_7 = cygwin/device.c +@UML_TRUE@am__append_8 = uml_device.c +@VDE_TRUE@am__append_9 = vde_device.c +@TUNEMU_TRUE@am__append_10 = -lpcap subdir = src ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/attribute.m4 \ @@ -202,12 +109,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/attribute.m4 \ $(top_srcdir)/m4/ax_cflags_warn_all.m4 \ $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_check_link_flag.m4 \ - $(top_srcdir)/m4/ax_code_coverage.m4 \ - $(top_srcdir)/m4/ax_require_defined.m4 \ - $(top_srcdir)/m4/curses.m4 $(top_srcdir)/m4/libgcrypt.m4 \ - $(top_srcdir)/m4/lzo.m4 $(top_srcdir)/m4/miniupnpc.m4 \ - $(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/readline.m4 \ - $(top_srcdir)/m4/zlib.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/ax_require_defined.m4 $(top_srcdir)/m4/lzo.m4 \ + $(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/zlib.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) @@ -215,202 +119,51 @@ mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = -@LINUX_TRUE@am__EXEEXT_1 = sptps_speed$(EXEEXT) am__installdirs = "$(DESTDIR)$(sbindir)" PROGRAMS = $(sbin_PROGRAMS) -am__sptps_keypair_SOURCES_DIST = sptps_keypair.c utils.c utils.h \ - ed25519/ecdsagen.c ed25519/ed25519.h ed25519/fe.c ed25519/fe.h \ - ed25519/fixedint.h ed25519/ge.c ed25519/ge.h \ - ed25519/key_exchange.c ed25519/keypair.c \ - ed25519/precomp_data.h ed25519/sc.c ed25519/sc.h \ - ed25519/sha512.c ed25519/sha512.h ed25519/sign.c \ - ed25519/verify.c getopt.c getopt.h getopt1.c openssl/crypto.c \ - nolegacy/crypto.c -am__dirstamp = $(am__leading_dot)dirstamp -am__objects_1 = ed25519/fe.$(OBJEXT) ed25519/ge.$(OBJEXT) \ - ed25519/key_exchange.$(OBJEXT) ed25519/keypair.$(OBJEXT) \ - ed25519/sc.$(OBJEXT) ed25519/sha512.$(OBJEXT) \ - ed25519/sign.$(OBJEXT) ed25519/verify.$(OBJEXT) -@GETOPT_FALSE@am__objects_2 = getopt.$(OBJEXT) getopt1.$(OBJEXT) -@OPENSSL_TRUE@am__objects_3 = openssl/crypto.$(OBJEXT) -@GCRYPT_TRUE@@OPENSSL_FALSE@am__objects_4 = openssl/crypto.$(OBJEXT) -@GCRYPT_FALSE@@OPENSSL_FALSE@am__objects_5 = \ -@GCRYPT_FALSE@@OPENSSL_FALSE@ nolegacy/crypto.$(OBJEXT) -am_sptps_keypair_OBJECTS = sptps_keypair.$(OBJEXT) utils.$(OBJEXT) \ - ed25519/ecdsagen.$(OBJEXT) $(am__objects_1) $(am__objects_2) \ - $(am__objects_3) $(am__objects_4) $(am__objects_5) -sptps_keypair_OBJECTS = $(am_sptps_keypair_OBJECTS) -sptps_keypair_LDADD = $(LDADD) -am__sptps_speed_SOURCES_DIST = logger.c logger.h sptps.c sptps.h \ - sptps_speed.c utils.c utils.h ed25519/ecdh.c ed25519/ecdsa.c \ - ed25519/ecdsagen.c ed25519/ed25519.h ed25519/fe.c ed25519/fe.h \ - ed25519/fixedint.h ed25519/ge.c ed25519/ge.h \ - ed25519/key_exchange.c ed25519/keypair.c \ - ed25519/precomp_data.h ed25519/sc.c ed25519/sc.h \ - ed25519/sha512.c ed25519/sha512.h ed25519/sign.c \ - ed25519/verify.c chacha-poly1305/chacha.c \ - chacha-poly1305/chacha.h chacha-poly1305/chacha-poly1305.c \ - chacha-poly1305/chacha-poly1305.h chacha-poly1305/poly1305.c \ - chacha-poly1305/poly1305.h openssl/crypto.c openssl/digest.c \ - openssl/digest.h openssl/prf.c nolegacy/crypto.c \ - nolegacy/prf.c -am__objects_6 = chacha-poly1305/chacha.$(OBJEXT) \ - chacha-poly1305/chacha-poly1305.$(OBJEXT) \ - chacha-poly1305/poly1305.$(OBJEXT) -@OPENSSL_TRUE@am__objects_7 = openssl/crypto.$(OBJEXT) \ -@OPENSSL_TRUE@ openssl/digest.$(OBJEXT) openssl/prf.$(OBJEXT) -@GCRYPT_TRUE@@OPENSSL_FALSE@am__objects_8 = openssl/crypto.$(OBJEXT) \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ openssl/digest.$(OBJEXT) \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ openssl/prf.$(OBJEXT) -@GCRYPT_FALSE@@OPENSSL_FALSE@am__objects_9 = \ -@GCRYPT_FALSE@@OPENSSL_FALSE@ nolegacy/crypto.$(OBJEXT) \ -@GCRYPT_FALSE@@OPENSSL_FALSE@ nolegacy/prf.$(OBJEXT) -am_sptps_speed_OBJECTS = logger.$(OBJEXT) sptps.$(OBJEXT) \ - sptps_speed.$(OBJEXT) utils.$(OBJEXT) ed25519/ecdh.$(OBJEXT) \ - ed25519/ecdsa.$(OBJEXT) ed25519/ecdsagen.$(OBJEXT) \ - $(am__objects_1) $(am__objects_6) $(am__objects_7) \ - $(am__objects_8) $(am__objects_9) -sptps_speed_OBJECTS = $(am_sptps_speed_OBJECTS) -sptps_speed_DEPENDENCIES = -am__sptps_test_SOURCES_DIST = logger.c logger.h sptps.c sptps.h \ - sptps_test.c utils.c utils.h ed25519/ecdh.c ed25519/ecdsa.c \ - ed25519/ed25519.h ed25519/fe.c ed25519/fe.h ed25519/fixedint.h \ - ed25519/ge.c ed25519/ge.h ed25519/key_exchange.c \ - ed25519/keypair.c ed25519/precomp_data.h ed25519/sc.c \ - ed25519/sc.h ed25519/sha512.c ed25519/sha512.h ed25519/sign.c \ - ed25519/verify.c chacha-poly1305/chacha.c \ - chacha-poly1305/chacha.h chacha-poly1305/chacha-poly1305.c \ - chacha-poly1305/chacha-poly1305.h chacha-poly1305/poly1305.c \ - chacha-poly1305/poly1305.h getopt.c getopt.h getopt1.c \ - openssl/crypto.c openssl/digest.c openssl/digest.h \ - openssl/prf.c gcrypt/cipher.c gcrypt/crypto.c gcrypt/digest.c \ - gcrypt/digest.h gcrypt/prf.c nolegacy/crypto.c nolegacy/prf.c -@GCRYPT_TRUE@@OPENSSL_FALSE@am__objects_10 = gcrypt/cipher.$(OBJEXT) \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/crypto.$(OBJEXT) \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/digest.$(OBJEXT) \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/prf.$(OBJEXT) -am_sptps_test_OBJECTS = logger.$(OBJEXT) sptps.$(OBJEXT) \ - sptps_test.$(OBJEXT) utils.$(OBJEXT) ed25519/ecdh.$(OBJEXT) \ - ed25519/ecdsa.$(OBJEXT) $(am__objects_1) $(am__objects_6) \ - $(am__objects_2) $(am__objects_7) $(am__objects_10) \ - $(am__objects_9) -sptps_test_OBJECTS = $(am_sptps_test_OBJECTS) -sptps_test_LDADD = $(LDADD) -am__tinc_SOURCES_DIST = dropin.c dropin.h fsck.c fsck.h ifconfig.c \ - ifconfig.h info.c info.h invitation.c invitation.h list.c \ - list.h names.c names.h netutl.c netutl.h script.c script.h \ - sptps.c sptps.h subnet_parse.c subnet.h tincctl.c tincctl.h \ - top.c top.h utils.c utils.h version.c version.h ed25519/ecdh.c \ - ed25519/ecdsa.c ed25519/ecdsagen.c ed25519/ed25519.h \ - ed25519/fe.c ed25519/fe.h ed25519/fixedint.h ed25519/ge.c \ - ed25519/ge.h ed25519/key_exchange.c ed25519/keypair.c \ - ed25519/precomp_data.h ed25519/sc.c ed25519/sc.h \ - ed25519/sha512.c ed25519/sha512.h ed25519/sign.c \ - ed25519/verify.c chacha-poly1305/chacha.c \ - chacha-poly1305/chacha.h chacha-poly1305/chacha-poly1305.c \ - chacha-poly1305/chacha-poly1305.h chacha-poly1305/poly1305.c \ - chacha-poly1305/poly1305.h getopt.c getopt.h getopt1.c \ - openssl/cipher.c openssl/crypto.c openssl/digest.c \ - openssl/digest.h openssl/prf.c openssl/rsa.c openssl/rsagen.c \ - gcrypt/cipher.c gcrypt/crypto.c gcrypt/digest.c \ - gcrypt/digest.h gcrypt/prf.c gcrypt/rsa.c gcrypt/rsagen.c \ - nolegacy/crypto.c nolegacy/prf.c -@OPENSSL_TRUE@am__objects_11 = openssl/cipher.$(OBJEXT) \ -@OPENSSL_TRUE@ openssl/crypto.$(OBJEXT) \ -@OPENSSL_TRUE@ openssl/digest.$(OBJEXT) openssl/prf.$(OBJEXT) \ -@OPENSSL_TRUE@ openssl/rsa.$(OBJEXT) openssl/rsagen.$(OBJEXT) -@GCRYPT_TRUE@@OPENSSL_FALSE@am__objects_12 = gcrypt/cipher.$(OBJEXT) \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/crypto.$(OBJEXT) \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/digest.$(OBJEXT) \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/prf.$(OBJEXT) \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/rsa.$(OBJEXT) \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/rsagen.$(OBJEXT) -am_tinc_OBJECTS = dropin.$(OBJEXT) fsck.$(OBJEXT) ifconfig.$(OBJEXT) \ - info.$(OBJEXT) invitation.$(OBJEXT) list.$(OBJEXT) \ - names.$(OBJEXT) netutl.$(OBJEXT) script.$(OBJEXT) \ - sptps.$(OBJEXT) subnet_parse.$(OBJEXT) tincctl.$(OBJEXT) \ - top.$(OBJEXT) utils.$(OBJEXT) version.$(OBJEXT) \ - ed25519/ecdh.$(OBJEXT) ed25519/ecdsa.$(OBJEXT) \ - ed25519/ecdsagen.$(OBJEXT) $(am__objects_1) $(am__objects_6) \ - $(am__objects_2) $(am__objects_11) $(am__objects_12) \ - $(am__objects_9) -tinc_OBJECTS = $(am_tinc_OBJECTS) -am__DEPENDENCIES_1 = -tinc_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) -am__tincd_SOURCES_DIST = address_cache.c address_cache.h autoconnect.c \ - autoconnect.h buffer.c buffer.h cipher.h conf.c conf.h \ - connection.c connection.h control.c control.h control_common.h \ - crypto.h device.h digest.h dropin.c dropin.h dummy_device.c \ - ecdh.h ecdsa.h ecdsagen.h edge.c edge.h ethernet.h event.c \ - event.h fd_device.c graph.c graph.h hash.c hash.h have.h \ - ipv4.h ipv6.h list.c list.h logger.c logger.h meta.c meta.h \ - multicast_device.c names.c names.h net.c net.h net_packet.c \ - net_setup.c net_socket.c netutl.c netutl.h node.c node.h prf.h \ - process.c process.h protocol.c protocol.h protocol_auth.c \ - protocol_edge.c protocol_key.c protocol_misc.c \ - protocol_subnet.c raw_socket_device.c route.c route.h rsa.h \ - rsagen.h script.c script.h splay_tree.c splay_tree.h sptps.c \ - sptps.h subnet.c subnet.h subnet_parse.c system.h tincd.c \ - utils.c utils.h xalloc.h version.c version.h ed25519/ecdh.c \ - ed25519/ecdsa.c ed25519/ed25519.h ed25519/fe.c ed25519/fe.h \ - ed25519/fixedint.h ed25519/ge.c ed25519/ge.h \ - ed25519/key_exchange.c ed25519/keypair.c \ - ed25519/precomp_data.h ed25519/sc.c ed25519/sc.h \ - ed25519/sha512.c ed25519/sha512.h ed25519/sign.c \ - ed25519/verify.c chacha-poly1305/chacha.c \ - chacha-poly1305/chacha.h chacha-poly1305/chacha-poly1305.c \ - chacha-poly1305/chacha-poly1305.h chacha-poly1305/poly1305.c \ - chacha-poly1305/poly1305.h getopt.c getopt.h getopt1.c \ +am__tincd_SOURCES_DIST = have.h system.h avl_tree.c avl_tree.h conf.c \ + conf.h connection.c connection.h device.h dropin.c dropin.h \ + dummy_device.c edge.c edge.h ethernet.h event.c event.h \ + fake-getaddrinfo.c fake-getaddrinfo.h fake-getnameinfo.c \ + fake-getnameinfo.h graph.c graph.h ipv4.h ipv6.h list.c list.h \ + logger.c logger.h meta.c meta.h multicast_device.c net.c net.h \ + net_packet.c net_setup.c net_socket.c netutl.c netutl.h node.c \ + node.h pidfile.c pidfile.h process.c process.h protocol.c \ + protocol.h protocol_auth.c protocol_edge.c protocol_misc.c \ + protocol_key.c protocol_subnet.c proxy.c proxy.h \ + raw_socket_device.c route.c route.h subnet.c subnet.h tincd.c \ + utils.c utils.h xalloc.h getopt.c getopt.h getopt1.c \ linux/device.c bsd/device.c bsd/tunemu.c bsd/tunemu.h \ solaris/device.c mingw/device.c mingw/common.h cygwin/device.c \ - uml_device.c vde_device.c openssl/cipher.c openssl/crypto.c \ - openssl/digest.c openssl/digest.h openssl/prf.c openssl/rsa.c \ - gcrypt/cipher.c gcrypt/crypto.c gcrypt/digest.c \ - gcrypt/digest.h gcrypt/prf.c gcrypt/rsa.c nolegacy/crypto.c \ - nolegacy/prf.c upnp.h upnp.c -@LINUX_TRUE@am__objects_13 = linux/device.$(OBJEXT) -@BSD_TRUE@am__objects_14 = bsd/device.$(OBJEXT) -@BSD_TRUE@@TUNEMU_TRUE@am__objects_15 = bsd/tunemu.$(OBJEXT) -@SOLARIS_TRUE@am__objects_16 = solaris/device.$(OBJEXT) -@MINGW_TRUE@am__objects_17 = mingw/device.$(OBJEXT) -@CYGWIN_TRUE@am__objects_18 = cygwin/device.$(OBJEXT) -@UML_TRUE@am__objects_19 = uml_device.$(OBJEXT) -@VDE_TRUE@am__objects_20 = vde_device.$(OBJEXT) -@OPENSSL_TRUE@am__objects_21 = openssl/cipher.$(OBJEXT) \ -@OPENSSL_TRUE@ openssl/crypto.$(OBJEXT) \ -@OPENSSL_TRUE@ openssl/digest.$(OBJEXT) openssl/prf.$(OBJEXT) \ -@OPENSSL_TRUE@ openssl/rsa.$(OBJEXT) -@GCRYPT_TRUE@@OPENSSL_FALSE@am__objects_22 = gcrypt/cipher.$(OBJEXT) \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/crypto.$(OBJEXT) \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/digest.$(OBJEXT) \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/prf.$(OBJEXT) \ -@GCRYPT_TRUE@@OPENSSL_FALSE@ gcrypt/rsa.$(OBJEXT) -@MINIUPNPC_TRUE@am__objects_23 = upnp.$(OBJEXT) -am_tincd_OBJECTS = address_cache.$(OBJEXT) autoconnect.$(OBJEXT) \ - buffer.$(OBJEXT) conf.$(OBJEXT) connection.$(OBJEXT) \ - control.$(OBJEXT) dropin.$(OBJEXT) dummy_device.$(OBJEXT) \ - edge.$(OBJEXT) event.$(OBJEXT) fd_device.$(OBJEXT) \ - graph.$(OBJEXT) hash.$(OBJEXT) list.$(OBJEXT) logger.$(OBJEXT) \ - meta.$(OBJEXT) multicast_device.$(OBJEXT) names.$(OBJEXT) \ + uml_device.c vde_device.c +@GETOPT_FALSE@am__objects_1 = getopt.$(OBJEXT) getopt1.$(OBJEXT) +am__dirstamp = $(am__leading_dot)dirstamp +@LINUX_TRUE@am__objects_2 = linux/device.$(OBJEXT) +@BSD_TRUE@am__objects_3 = bsd/device.$(OBJEXT) +@BSD_TRUE@@TUNEMU_TRUE@am__objects_4 = bsd/tunemu.$(OBJEXT) +@SOLARIS_TRUE@am__objects_5 = solaris/device.$(OBJEXT) +@MINGW_TRUE@am__objects_6 = mingw/device.$(OBJEXT) +@CYGWIN_TRUE@am__objects_7 = cygwin/device.$(OBJEXT) +@UML_TRUE@am__objects_8 = uml_device.$(OBJEXT) +@VDE_TRUE@am__objects_9 = vde_device.$(OBJEXT) +am_tincd_OBJECTS = avl_tree.$(OBJEXT) conf.$(OBJEXT) \ + connection.$(OBJEXT) dropin.$(OBJEXT) dummy_device.$(OBJEXT) \ + edge.$(OBJEXT) event.$(OBJEXT) fake-getaddrinfo.$(OBJEXT) \ + fake-getnameinfo.$(OBJEXT) graph.$(OBJEXT) list.$(OBJEXT) \ + logger.$(OBJEXT) meta.$(OBJEXT) multicast_device.$(OBJEXT) \ net.$(OBJEXT) net_packet.$(OBJEXT) net_setup.$(OBJEXT) \ net_socket.$(OBJEXT) netutl.$(OBJEXT) node.$(OBJEXT) \ - process.$(OBJEXT) protocol.$(OBJEXT) protocol_auth.$(OBJEXT) \ - protocol_edge.$(OBJEXT) protocol_key.$(OBJEXT) \ - protocol_misc.$(OBJEXT) protocol_subnet.$(OBJEXT) \ - raw_socket_device.$(OBJEXT) route.$(OBJEXT) script.$(OBJEXT) \ - splay_tree.$(OBJEXT) sptps.$(OBJEXT) subnet.$(OBJEXT) \ - subnet_parse.$(OBJEXT) tincd.$(OBJEXT) utils.$(OBJEXT) \ - version.$(OBJEXT) ed25519/ecdh.$(OBJEXT) \ - ed25519/ecdsa.$(OBJEXT) $(am__objects_1) $(am__objects_6) \ - $(am__objects_2) $(am__objects_13) $(am__objects_14) \ - $(am__objects_15) $(am__objects_16) $(am__objects_17) \ - $(am__objects_18) $(am__objects_19) $(am__objects_20) \ - $(am__objects_21) $(am__objects_22) $(am__objects_9) \ - $(am__objects_23) + pidfile.$(OBJEXT) process.$(OBJEXT) protocol.$(OBJEXT) \ + protocol_auth.$(OBJEXT) protocol_edge.$(OBJEXT) \ + protocol_misc.$(OBJEXT) protocol_key.$(OBJEXT) \ + protocol_subnet.$(OBJEXT) proxy.$(OBJEXT) \ + raw_socket_device.$(OBJEXT) route.$(OBJEXT) subnet.$(OBJEXT) \ + tincd.$(OBJEXT) utils.$(OBJEXT) $(am__objects_1) \ + $(am__objects_2) $(am__objects_3) $(am__objects_4) \ + $(am__objects_5) $(am__objects_6) $(am__objects_7) \ + $(am__objects_8) $(am__objects_9) tincd_OBJECTS = $(am_tincd_OBJECTS) -@MINIUPNPC_TRUE@tincd_DEPENDENCIES = $(am__DEPENDENCIES_1) -tincd_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(tincd_LDFLAGS) \ - $(LDFLAGS) -o $@ +tincd_LDADD = $(LDADD) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -426,52 +179,27 @@ am__v_at_1 = DEFAULT_INCLUDES = depcomp = $(SHELL) $(top_srcdir)/depcomp am__maybe_remake_depfiles = depfiles -am__depfiles_remade = ./$(DEPDIR)/address_cache.Po \ - ./$(DEPDIR)/autoconnect.Po ./$(DEPDIR)/buffer.Po \ - ./$(DEPDIR)/conf.Po ./$(DEPDIR)/connection.Po \ - ./$(DEPDIR)/control.Po ./$(DEPDIR)/dropin.Po \ +am__depfiles_remade = ./$(DEPDIR)/avl_tree.Po ./$(DEPDIR)/conf.Po \ + ./$(DEPDIR)/connection.Po ./$(DEPDIR)/dropin.Po \ ./$(DEPDIR)/dummy_device.Po ./$(DEPDIR)/edge.Po \ - ./$(DEPDIR)/event.Po ./$(DEPDIR)/fd_device.Po \ - ./$(DEPDIR)/fsck.Po ./$(DEPDIR)/getopt.Po \ + ./$(DEPDIR)/event.Po ./$(DEPDIR)/fake-getaddrinfo.Po \ + ./$(DEPDIR)/fake-getnameinfo.Po ./$(DEPDIR)/getopt.Po \ ./$(DEPDIR)/getopt1.Po ./$(DEPDIR)/graph.Po \ - ./$(DEPDIR)/hash.Po ./$(DEPDIR)/ifconfig.Po \ - ./$(DEPDIR)/info.Po ./$(DEPDIR)/invitation.Po \ ./$(DEPDIR)/list.Po ./$(DEPDIR)/logger.Po ./$(DEPDIR)/meta.Po \ - ./$(DEPDIR)/multicast_device.Po ./$(DEPDIR)/names.Po \ - ./$(DEPDIR)/net.Po ./$(DEPDIR)/net_packet.Po \ - ./$(DEPDIR)/net_setup.Po ./$(DEPDIR)/net_socket.Po \ - ./$(DEPDIR)/netutl.Po ./$(DEPDIR)/node.Po \ + ./$(DEPDIR)/multicast_device.Po ./$(DEPDIR)/net.Po \ + ./$(DEPDIR)/net_packet.Po ./$(DEPDIR)/net_setup.Po \ + ./$(DEPDIR)/net_socket.Po ./$(DEPDIR)/netutl.Po \ + ./$(DEPDIR)/node.Po ./$(DEPDIR)/pidfile.Po \ ./$(DEPDIR)/process.Po ./$(DEPDIR)/protocol.Po \ ./$(DEPDIR)/protocol_auth.Po ./$(DEPDIR)/protocol_edge.Po \ ./$(DEPDIR)/protocol_key.Po ./$(DEPDIR)/protocol_misc.Po \ - ./$(DEPDIR)/protocol_subnet.Po \ + ./$(DEPDIR)/protocol_subnet.Po ./$(DEPDIR)/proxy.Po \ ./$(DEPDIR)/raw_socket_device.Po ./$(DEPDIR)/route.Po \ - ./$(DEPDIR)/script.Po ./$(DEPDIR)/splay_tree.Po \ - ./$(DEPDIR)/sptps.Po ./$(DEPDIR)/sptps_keypair.Po \ - ./$(DEPDIR)/sptps_speed.Po ./$(DEPDIR)/sptps_test.Po \ - ./$(DEPDIR)/subnet.Po ./$(DEPDIR)/subnet_parse.Po \ - ./$(DEPDIR)/tincctl.Po ./$(DEPDIR)/tincd.Po ./$(DEPDIR)/top.Po \ - ./$(DEPDIR)/uml_device.Po ./$(DEPDIR)/upnp.Po \ - ./$(DEPDIR)/utils.Po ./$(DEPDIR)/vde_device.Po \ - ./$(DEPDIR)/version.Po bsd/$(DEPDIR)/device.Po \ - bsd/$(DEPDIR)/tunemu.Po \ - chacha-poly1305/$(DEPDIR)/chacha-poly1305.Po \ - chacha-poly1305/$(DEPDIR)/chacha.Po \ - chacha-poly1305/$(DEPDIR)/poly1305.Po \ - cygwin/$(DEPDIR)/device.Po ed25519/$(DEPDIR)/ecdh.Po \ - ed25519/$(DEPDIR)/ecdsa.Po ed25519/$(DEPDIR)/ecdsagen.Po \ - ed25519/$(DEPDIR)/fe.Po ed25519/$(DEPDIR)/ge.Po \ - ed25519/$(DEPDIR)/key_exchange.Po ed25519/$(DEPDIR)/keypair.Po \ - ed25519/$(DEPDIR)/sc.Po ed25519/$(DEPDIR)/sha512.Po \ - ed25519/$(DEPDIR)/sign.Po ed25519/$(DEPDIR)/verify.Po \ - gcrypt/$(DEPDIR)/cipher.Po gcrypt/$(DEPDIR)/crypto.Po \ - gcrypt/$(DEPDIR)/digest.Po gcrypt/$(DEPDIR)/prf.Po \ - gcrypt/$(DEPDIR)/rsa.Po gcrypt/$(DEPDIR)/rsagen.Po \ + ./$(DEPDIR)/subnet.Po ./$(DEPDIR)/tincd.Po \ + ./$(DEPDIR)/uml_device.Po ./$(DEPDIR)/utils.Po \ + ./$(DEPDIR)/vde_device.Po bsd/$(DEPDIR)/device.Po \ + bsd/$(DEPDIR)/tunemu.Po cygwin/$(DEPDIR)/device.Po \ linux/$(DEPDIR)/device.Po mingw/$(DEPDIR)/device.Po \ - nolegacy/$(DEPDIR)/crypto.Po nolegacy/$(DEPDIR)/prf.Po \ - openssl/$(DEPDIR)/cipher.Po openssl/$(DEPDIR)/crypto.Po \ - openssl/$(DEPDIR)/digest.Po openssl/$(DEPDIR)/prf.Po \ - openssl/$(DEPDIR)/rsa.Po openssl/$(DEPDIR)/rsagen.Po \ solaris/$(DEPDIR)/device.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ @@ -486,11 +214,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = $(sptps_keypair_SOURCES) $(sptps_speed_SOURCES) \ - $(sptps_test_SOURCES) $(tinc_SOURCES) $(tincd_SOURCES) -DIST_SOURCES = $(am__sptps_keypair_SOURCES_DIST) \ - $(am__sptps_speed_SOURCES_DIST) $(am__sptps_test_SOURCES_DIST) \ - $(am__tinc_SOURCES_DIST) $(am__tincd_SOURCES_DIST) +SOURCES = $(tincd_SOURCES) +DIST_SOURCES = $(am__tincd_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -527,15 +252,8 @@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_CPPFLAGS = @CODE_COVERAGE_CPPFLAGS@ -CODE_COVERAGE_CXXFLAGS = @CODE_COVERAGE_CXXFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CODE_COVERAGE_LIBS = @CODE_COVERAGE_LIBS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ -CURSES_LIBS = @CURSES_LIBS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ @@ -544,21 +262,17 @@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ -GCOV = @GCOV@ -GENHTML = @GENHTML@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LCOV = @LCOV@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -lm $(CODE_COVERAGE_LIBS) $(am__append_30) +LIBS = @LIBS@ $(am__append_10) LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ -MINIUPNPC_LIBS = @MINIUPNPC_LIBS@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ @@ -569,8 +283,6 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -READLINE_LIBS = @READLINE_LIBS@ -SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -627,72 +339,22 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -CLEANFILES = version_git.h -ed25519_SOURCES = \ - ed25519/ed25519.h \ - ed25519/fe.c ed25519/fe.h \ - ed25519/fixedint.h \ - ed25519/ge.c ed25519/ge.h \ - ed25519/key_exchange.c \ - ed25519/keypair.c \ - ed25519/precomp_data.h \ - ed25519/sc.c ed25519/sc.h \ - ed25519/sha512.c ed25519/sha512.h \ - ed25519/sign.c \ - ed25519/verify.c - -chacha_poly1305_SOURCES = \ - chacha-poly1305/chacha.c chacha-poly1305/chacha.h \ - chacha-poly1305/chacha-poly1305.c chacha-poly1305/chacha-poly1305.h \ - chacha-poly1305/poly1305.c chacha-poly1305/poly1305.h - -tincd_SOURCES = address_cache.c address_cache.h autoconnect.c \ - autoconnect.h buffer.c buffer.h cipher.h conf.c conf.h \ - connection.c connection.h control.c control.h control_common.h \ - crypto.h device.h digest.h dropin.c dropin.h dummy_device.c \ - ecdh.h ecdsa.h ecdsagen.h edge.c edge.h ethernet.h event.c \ - event.h fd_device.c graph.c graph.h hash.c hash.h have.h \ - ipv4.h ipv6.h list.c list.h logger.c logger.h meta.c meta.h \ - multicast_device.c names.c names.h net.c net.h net_packet.c \ - net_setup.c net_socket.c netutl.c netutl.h node.c node.h prf.h \ - process.c process.h protocol.c protocol.h protocol_auth.c \ - protocol_edge.c protocol_key.c protocol_misc.c \ - protocol_subnet.c raw_socket_device.c route.c route.h rsa.h \ - rsagen.h script.c script.h splay_tree.c splay_tree.h sptps.c \ - sptps.h subnet.c subnet.h subnet_parse.c system.h tincd.c \ - utils.c utils.h xalloc.h version.c version.h ed25519/ecdh.c \ - ed25519/ecdsa.c $(ed25519_SOURCES) $(chacha_poly1305_SOURCES) \ - $(am__append_2) $(am__append_6) $(am__append_7) \ - $(am__append_8) $(am__append_9) $(am__append_10) \ - $(am__append_11) $(am__append_12) $(am__append_13) \ - $(am__append_14) $(am__append_19) $(am__append_24) \ - $(am__append_29) -tinc_SOURCES = dropin.c dropin.h fsck.c fsck.h ifconfig.c ifconfig.h \ - info.c info.h invitation.c invitation.h list.c list.h names.c \ - names.h netutl.c netutl.h script.c script.h sptps.c sptps.h \ - subnet_parse.c subnet.h tincctl.c tincctl.h top.c top.h \ - utils.c utils.h version.c version.h ed25519/ecdh.c \ - ed25519/ecdsa.c ed25519/ecdsagen.c $(ed25519_SOURCES) \ - $(chacha_poly1305_SOURCES) $(am__append_3) $(am__append_15) \ - $(am__append_20) $(am__append_25) -sptps_test_SOURCES = logger.c logger.h sptps.c sptps.h sptps_test.c \ - utils.c utils.h ed25519/ecdh.c ed25519/ecdsa.c \ - $(ed25519_SOURCES) $(chacha_poly1305_SOURCES) $(am__append_4) \ - $(am__append_16) $(am__append_21) $(am__append_26) -sptps_keypair_SOURCES = sptps_keypair.c utils.c utils.h \ - ed25519/ecdsagen.c $(ed25519_SOURCES) $(am__append_5) \ - $(am__append_17) $(am__append_22) $(am__append_27) -sptps_speed_SOURCES = logger.c logger.h sptps.c sptps.h sptps_speed.c \ - utils.c utils.h ed25519/ecdh.c ed25519/ecdsa.c \ - ed25519/ecdsagen.c $(ed25519_SOURCES) \ - $(chacha_poly1305_SOURCES) $(am__append_18) $(am__append_23) \ - $(am__append_28) -@MINIUPNPC_TRUE@tincd_LDADD = $(MINIUPNPC_LIBS) -@MINIUPNPC_TRUE@tincd_LDFLAGS = -pthread -tinc_LDADD = $(READLINE_LIBS) $(CURSES_LIBS) -sptps_speed_LDADD = -lrt -AM_CFLAGS = -DCONFDIR=\"$(sysconfdir)\" -DRUNSTATEDIR=\"$(runstatedir)\" -DLOCALSTATEDIR=\"$(localstatedir)\" -DSBINDIR=\"$(sbindir)\" -iquote. $(CODE_COVERAGE_CFLAGS) -AM_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS) +tincd_SOURCES = have.h system.h avl_tree.c avl_tree.h conf.c conf.h \ + connection.c connection.h device.h dropin.c dropin.h \ + dummy_device.c edge.c edge.h ethernet.h event.c event.h \ + fake-getaddrinfo.c fake-getaddrinfo.h fake-getnameinfo.c \ + fake-getnameinfo.h graph.c graph.h ipv4.h ipv6.h list.c list.h \ + logger.c logger.h meta.c meta.h multicast_device.c net.c net.h \ + net_packet.c net_setup.c net_socket.c netutl.c netutl.h node.c \ + node.h pidfile.c pidfile.h process.c process.h protocol.c \ + protocol.h protocol_auth.c protocol_edge.c protocol_misc.c \ + protocol_key.c protocol_subnet.c proxy.c proxy.h \ + raw_socket_device.c route.c route.h subnet.c subnet.h tincd.c \ + utils.c utils.h xalloc.h $(am__append_1) $(am__append_2) \ + $(am__append_3) $(am__append_4) $(am__append_5) \ + $(am__append_6) $(am__append_7) $(am__append_8) \ + $(am__append_9) +AM_CPPFLAGS = -DCONFDIR=\"$(sysconfdir)\" -DRUNSTATEDIR=\"$(runstatedir)\" -DLOCALSTATEDIR=\"$(localstatedir)\" -I $(abs_top_builddir)/ all: all-am .SUFFIXES: @@ -726,9 +388,6 @@ $(top_srcdir)/configure: $(am__configure_deps) $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): - -clean-checkPROGRAMS: - -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) install-sbinPROGRAMS: $(sbin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ @@ -787,109 +446,6 @@ installcheck-sbinPROGRAMS: $(sbin_PROGRAMS) else echo "$$f does not support $$opt" 1>&2; bad=1; fi; \ done; \ done; rm -f c$${pid}_.???; exit $$bad -ed25519/$(am__dirstamp): - @$(MKDIR_P) ed25519 - @: > ed25519/$(am__dirstamp) -ed25519/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) ed25519/$(DEPDIR) - @: > ed25519/$(DEPDIR)/$(am__dirstamp) -ed25519/ecdsagen.$(OBJEXT): ed25519/$(am__dirstamp) \ - ed25519/$(DEPDIR)/$(am__dirstamp) -ed25519/fe.$(OBJEXT): ed25519/$(am__dirstamp) \ - ed25519/$(DEPDIR)/$(am__dirstamp) -ed25519/ge.$(OBJEXT): ed25519/$(am__dirstamp) \ - ed25519/$(DEPDIR)/$(am__dirstamp) -ed25519/key_exchange.$(OBJEXT): ed25519/$(am__dirstamp) \ - ed25519/$(DEPDIR)/$(am__dirstamp) -ed25519/keypair.$(OBJEXT): ed25519/$(am__dirstamp) \ - ed25519/$(DEPDIR)/$(am__dirstamp) -ed25519/sc.$(OBJEXT): ed25519/$(am__dirstamp) \ - ed25519/$(DEPDIR)/$(am__dirstamp) -ed25519/sha512.$(OBJEXT): ed25519/$(am__dirstamp) \ - ed25519/$(DEPDIR)/$(am__dirstamp) -ed25519/sign.$(OBJEXT): ed25519/$(am__dirstamp) \ - ed25519/$(DEPDIR)/$(am__dirstamp) -ed25519/verify.$(OBJEXT): ed25519/$(am__dirstamp) \ - ed25519/$(DEPDIR)/$(am__dirstamp) -openssl/$(am__dirstamp): - @$(MKDIR_P) openssl - @: > openssl/$(am__dirstamp) -openssl/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) openssl/$(DEPDIR) - @: > openssl/$(DEPDIR)/$(am__dirstamp) -openssl/crypto.$(OBJEXT): openssl/$(am__dirstamp) \ - openssl/$(DEPDIR)/$(am__dirstamp) -nolegacy/$(am__dirstamp): - @$(MKDIR_P) nolegacy - @: > nolegacy/$(am__dirstamp) -nolegacy/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) nolegacy/$(DEPDIR) - @: > nolegacy/$(DEPDIR)/$(am__dirstamp) -nolegacy/crypto.$(OBJEXT): nolegacy/$(am__dirstamp) \ - nolegacy/$(DEPDIR)/$(am__dirstamp) - -sptps_keypair$(EXEEXT): $(sptps_keypair_OBJECTS) $(sptps_keypair_DEPENDENCIES) $(EXTRA_sptps_keypair_DEPENDENCIES) - @rm -f sptps_keypair$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(sptps_keypair_OBJECTS) $(sptps_keypair_LDADD) $(LIBS) -ed25519/ecdh.$(OBJEXT): ed25519/$(am__dirstamp) \ - ed25519/$(DEPDIR)/$(am__dirstamp) -ed25519/ecdsa.$(OBJEXT): ed25519/$(am__dirstamp) \ - ed25519/$(DEPDIR)/$(am__dirstamp) -chacha-poly1305/$(am__dirstamp): - @$(MKDIR_P) chacha-poly1305 - @: > chacha-poly1305/$(am__dirstamp) -chacha-poly1305/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) chacha-poly1305/$(DEPDIR) - @: > chacha-poly1305/$(DEPDIR)/$(am__dirstamp) -chacha-poly1305/chacha.$(OBJEXT): chacha-poly1305/$(am__dirstamp) \ - chacha-poly1305/$(DEPDIR)/$(am__dirstamp) -chacha-poly1305/chacha-poly1305.$(OBJEXT): \ - chacha-poly1305/$(am__dirstamp) \ - chacha-poly1305/$(DEPDIR)/$(am__dirstamp) -chacha-poly1305/poly1305.$(OBJEXT): chacha-poly1305/$(am__dirstamp) \ - chacha-poly1305/$(DEPDIR)/$(am__dirstamp) -openssl/digest.$(OBJEXT): openssl/$(am__dirstamp) \ - openssl/$(DEPDIR)/$(am__dirstamp) -openssl/prf.$(OBJEXT): openssl/$(am__dirstamp) \ - openssl/$(DEPDIR)/$(am__dirstamp) -nolegacy/prf.$(OBJEXT): nolegacy/$(am__dirstamp) \ - nolegacy/$(DEPDIR)/$(am__dirstamp) - -sptps_speed$(EXEEXT): $(sptps_speed_OBJECTS) $(sptps_speed_DEPENDENCIES) $(EXTRA_sptps_speed_DEPENDENCIES) - @rm -f sptps_speed$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(sptps_speed_OBJECTS) $(sptps_speed_LDADD) $(LIBS) -gcrypt/$(am__dirstamp): - @$(MKDIR_P) gcrypt - @: > gcrypt/$(am__dirstamp) -gcrypt/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) gcrypt/$(DEPDIR) - @: > gcrypt/$(DEPDIR)/$(am__dirstamp) -gcrypt/cipher.$(OBJEXT): gcrypt/$(am__dirstamp) \ - gcrypt/$(DEPDIR)/$(am__dirstamp) -gcrypt/crypto.$(OBJEXT): gcrypt/$(am__dirstamp) \ - gcrypt/$(DEPDIR)/$(am__dirstamp) -gcrypt/digest.$(OBJEXT): gcrypt/$(am__dirstamp) \ - gcrypt/$(DEPDIR)/$(am__dirstamp) -gcrypt/prf.$(OBJEXT): gcrypt/$(am__dirstamp) \ - gcrypt/$(DEPDIR)/$(am__dirstamp) - -sptps_test$(EXEEXT): $(sptps_test_OBJECTS) $(sptps_test_DEPENDENCIES) $(EXTRA_sptps_test_DEPENDENCIES) - @rm -f sptps_test$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(sptps_test_OBJECTS) $(sptps_test_LDADD) $(LIBS) -openssl/cipher.$(OBJEXT): openssl/$(am__dirstamp) \ - openssl/$(DEPDIR)/$(am__dirstamp) -openssl/rsa.$(OBJEXT): openssl/$(am__dirstamp) \ - openssl/$(DEPDIR)/$(am__dirstamp) -openssl/rsagen.$(OBJEXT): openssl/$(am__dirstamp) \ - openssl/$(DEPDIR)/$(am__dirstamp) -gcrypt/rsa.$(OBJEXT): gcrypt/$(am__dirstamp) \ - gcrypt/$(DEPDIR)/$(am__dirstamp) -gcrypt/rsagen.$(OBJEXT): gcrypt/$(am__dirstamp) \ - gcrypt/$(DEPDIR)/$(am__dirstamp) - -tinc$(EXEEXT): $(tinc_OBJECTS) $(tinc_DEPENDENCIES) $(EXTRA_tinc_DEPENDENCIES) - @rm -f tinc$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(tinc_OBJECTS) $(tinc_LDADD) $(LIBS) linux/$(am__dirstamp): @$(MKDIR_P) linux @: > linux/$(am__dirstamp) @@ -935,54 +491,42 @@ cygwin/device.$(OBJEXT): cygwin/$(am__dirstamp) \ tincd$(EXEEXT): $(tincd_OBJECTS) $(tincd_DEPENDENCIES) $(EXTRA_tincd_DEPENDENCIES) @rm -f tincd$(EXEEXT) - $(AM_V_CCLD)$(tincd_LINK) $(tincd_OBJECTS) $(tincd_LDADD) $(LIBS) + $(AM_V_CCLD)$(LINK) $(tincd_OBJECTS) $(tincd_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f bsd/*.$(OBJEXT) - -rm -f chacha-poly1305/*.$(OBJEXT) -rm -f cygwin/*.$(OBJEXT) - -rm -f ed25519/*.$(OBJEXT) - -rm -f gcrypt/*.$(OBJEXT) -rm -f linux/*.$(OBJEXT) -rm -f mingw/*.$(OBJEXT) - -rm -f nolegacy/*.$(OBJEXT) - -rm -f openssl/*.$(OBJEXT) -rm -f solaris/*.$(OBJEXT) distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/address_cache.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/autoconnect.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/buffer.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avl_tree.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conf.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connection.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/control.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dropin.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dummy_device.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edge.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/event.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fd_device.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fsck.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fake-getaddrinfo.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fake-getnameinfo.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt1.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/graph.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifconfig.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/info.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/invitation.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logger.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/meta.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multicast_device.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/names.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_packet.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_setup.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net_socket.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netutl.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/node.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pidfile.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/process.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol_auth.Po@am__quote@ # am--include-marker @@ -990,57 +534,19 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol_key.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol_misc.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol_subnet.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proxy.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/raw_socket_device.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/route.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/script.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/splay_tree.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sptps.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sptps_keypair.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sptps_speed.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sptps_test.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/subnet.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/subnet_parse.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tincctl.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tincd.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/top.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uml_device.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upnp.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vde_device.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bsd/$(DEPDIR)/device.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@bsd/$(DEPDIR)/tunemu.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@chacha-poly1305/$(DEPDIR)/chacha-poly1305.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@chacha-poly1305/$(DEPDIR)/chacha.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@chacha-poly1305/$(DEPDIR)/poly1305.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@cygwin/$(DEPDIR)/device.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@ed25519/$(DEPDIR)/ecdh.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@ed25519/$(DEPDIR)/ecdsa.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@ed25519/$(DEPDIR)/ecdsagen.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@ed25519/$(DEPDIR)/fe.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@ed25519/$(DEPDIR)/ge.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@ed25519/$(DEPDIR)/key_exchange.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@ed25519/$(DEPDIR)/keypair.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@ed25519/$(DEPDIR)/sc.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@ed25519/$(DEPDIR)/sha512.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@ed25519/$(DEPDIR)/sign.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@ed25519/$(DEPDIR)/verify.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@gcrypt/$(DEPDIR)/cipher.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@gcrypt/$(DEPDIR)/crypto.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@gcrypt/$(DEPDIR)/digest.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@gcrypt/$(DEPDIR)/prf.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@gcrypt/$(DEPDIR)/rsa.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@gcrypt/$(DEPDIR)/rsagen.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@linux/$(DEPDIR)/device.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@mingw/$(DEPDIR)/device.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@nolegacy/$(DEPDIR)/crypto.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@nolegacy/$(DEPDIR)/prf.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@openssl/$(DEPDIR)/cipher.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@openssl/$(DEPDIR)/crypto.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@openssl/$(DEPDIR)/digest.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@openssl/$(DEPDIR)/prf.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@openssl/$(DEPDIR)/rsa.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@openssl/$(DEPDIR)/rsagen.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@solaris/$(DEPDIR)/device.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @@ -1151,7 +657,6 @@ distdir-am: $(DISTFILES) fi; \ done check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) check: check-am all-am: Makefile $(PROGRAMS) installdirs: @@ -1180,29 +685,18 @@ install-strip: mostlyclean-generic: clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -rm -f bsd/$(DEPDIR)/$(am__dirstamp) -rm -f bsd/$(am__dirstamp) - -rm -f chacha-poly1305/$(DEPDIR)/$(am__dirstamp) - -rm -f chacha-poly1305/$(am__dirstamp) -rm -f cygwin/$(DEPDIR)/$(am__dirstamp) -rm -f cygwin/$(am__dirstamp) - -rm -f ed25519/$(DEPDIR)/$(am__dirstamp) - -rm -f ed25519/$(am__dirstamp) - -rm -f gcrypt/$(DEPDIR)/$(am__dirstamp) - -rm -f gcrypt/$(am__dirstamp) -rm -f linux/$(DEPDIR)/$(am__dirstamp) -rm -f linux/$(am__dirstamp) -rm -f mingw/$(DEPDIR)/$(am__dirstamp) -rm -f mingw/$(am__dirstamp) - -rm -f nolegacy/$(DEPDIR)/$(am__dirstamp) - -rm -f nolegacy/$(am__dirstamp) - -rm -f openssl/$(DEPDIR)/$(am__dirstamp) - -rm -f openssl/$(am__dirstamp) -rm -f solaris/$(DEPDIR)/$(am__dirstamp) -rm -f solaris/$(am__dirstamp) @@ -1211,40 +705,32 @@ maintainer-clean-generic: @echo "it deletes files that may require special tools to rebuild." clean: clean-am -clean-am: clean-checkPROGRAMS clean-generic clean-sbinPROGRAMS \ - mostlyclean-am +clean-am: clean-generic clean-sbinPROGRAMS mostlyclean-am distclean: distclean-am - -rm -f ./$(DEPDIR)/address_cache.Po - -rm -f ./$(DEPDIR)/autoconnect.Po - -rm -f ./$(DEPDIR)/buffer.Po + -rm -f ./$(DEPDIR)/avl_tree.Po -rm -f ./$(DEPDIR)/conf.Po -rm -f ./$(DEPDIR)/connection.Po - -rm -f ./$(DEPDIR)/control.Po -rm -f ./$(DEPDIR)/dropin.Po -rm -f ./$(DEPDIR)/dummy_device.Po -rm -f ./$(DEPDIR)/edge.Po -rm -f ./$(DEPDIR)/event.Po - -rm -f ./$(DEPDIR)/fd_device.Po - -rm -f ./$(DEPDIR)/fsck.Po + -rm -f ./$(DEPDIR)/fake-getaddrinfo.Po + -rm -f ./$(DEPDIR)/fake-getnameinfo.Po -rm -f ./$(DEPDIR)/getopt.Po -rm -f ./$(DEPDIR)/getopt1.Po -rm -f ./$(DEPDIR)/graph.Po - -rm -f ./$(DEPDIR)/hash.Po - -rm -f ./$(DEPDIR)/ifconfig.Po - -rm -f ./$(DEPDIR)/info.Po - -rm -f ./$(DEPDIR)/invitation.Po -rm -f ./$(DEPDIR)/list.Po -rm -f ./$(DEPDIR)/logger.Po -rm -f ./$(DEPDIR)/meta.Po -rm -f ./$(DEPDIR)/multicast_device.Po - -rm -f ./$(DEPDIR)/names.Po -rm -f ./$(DEPDIR)/net.Po -rm -f ./$(DEPDIR)/net_packet.Po -rm -f ./$(DEPDIR)/net_setup.Po -rm -f ./$(DEPDIR)/net_socket.Po -rm -f ./$(DEPDIR)/netutl.Po -rm -f ./$(DEPDIR)/node.Po + -rm -f ./$(DEPDIR)/pidfile.Po -rm -f ./$(DEPDIR)/process.Po -rm -f ./$(DEPDIR)/protocol.Po -rm -f ./$(DEPDIR)/protocol_auth.Po @@ -1252,57 +738,19 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/protocol_key.Po -rm -f ./$(DEPDIR)/protocol_misc.Po -rm -f ./$(DEPDIR)/protocol_subnet.Po + -rm -f ./$(DEPDIR)/proxy.Po -rm -f ./$(DEPDIR)/raw_socket_device.Po -rm -f ./$(DEPDIR)/route.Po - -rm -f ./$(DEPDIR)/script.Po - -rm -f ./$(DEPDIR)/splay_tree.Po - -rm -f ./$(DEPDIR)/sptps.Po - -rm -f ./$(DEPDIR)/sptps_keypair.Po - -rm -f ./$(DEPDIR)/sptps_speed.Po - -rm -f ./$(DEPDIR)/sptps_test.Po -rm -f ./$(DEPDIR)/subnet.Po - -rm -f ./$(DEPDIR)/subnet_parse.Po - -rm -f ./$(DEPDIR)/tincctl.Po -rm -f ./$(DEPDIR)/tincd.Po - -rm -f ./$(DEPDIR)/top.Po -rm -f ./$(DEPDIR)/uml_device.Po - -rm -f ./$(DEPDIR)/upnp.Po -rm -f ./$(DEPDIR)/utils.Po -rm -f ./$(DEPDIR)/vde_device.Po - -rm -f ./$(DEPDIR)/version.Po -rm -f bsd/$(DEPDIR)/device.Po -rm -f bsd/$(DEPDIR)/tunemu.Po - -rm -f chacha-poly1305/$(DEPDIR)/chacha-poly1305.Po - -rm -f chacha-poly1305/$(DEPDIR)/chacha.Po - -rm -f chacha-poly1305/$(DEPDIR)/poly1305.Po -rm -f cygwin/$(DEPDIR)/device.Po - -rm -f ed25519/$(DEPDIR)/ecdh.Po - -rm -f ed25519/$(DEPDIR)/ecdsa.Po - -rm -f ed25519/$(DEPDIR)/ecdsagen.Po - -rm -f ed25519/$(DEPDIR)/fe.Po - -rm -f ed25519/$(DEPDIR)/ge.Po - -rm -f ed25519/$(DEPDIR)/key_exchange.Po - -rm -f ed25519/$(DEPDIR)/keypair.Po - -rm -f ed25519/$(DEPDIR)/sc.Po - -rm -f ed25519/$(DEPDIR)/sha512.Po - -rm -f ed25519/$(DEPDIR)/sign.Po - -rm -f ed25519/$(DEPDIR)/verify.Po - -rm -f gcrypt/$(DEPDIR)/cipher.Po - -rm -f gcrypt/$(DEPDIR)/crypto.Po - -rm -f gcrypt/$(DEPDIR)/digest.Po - -rm -f gcrypt/$(DEPDIR)/prf.Po - -rm -f gcrypt/$(DEPDIR)/rsa.Po - -rm -f gcrypt/$(DEPDIR)/rsagen.Po -rm -f linux/$(DEPDIR)/device.Po -rm -f mingw/$(DEPDIR)/device.Po - -rm -f nolegacy/$(DEPDIR)/crypto.Po - -rm -f nolegacy/$(DEPDIR)/prf.Po - -rm -f openssl/$(DEPDIR)/cipher.Po - -rm -f openssl/$(DEPDIR)/crypto.Po - -rm -f openssl/$(DEPDIR)/digest.Po - -rm -f openssl/$(DEPDIR)/prf.Po - -rm -f openssl/$(DEPDIR)/rsa.Po - -rm -f openssl/$(DEPDIR)/rsagen.Po -rm -f solaris/$(DEPDIR)/device.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ @@ -1349,36 +797,29 @@ install-ps-am: installcheck-am: installcheck-sbinPROGRAMS maintainer-clean: maintainer-clean-am - -rm -f ./$(DEPDIR)/address_cache.Po - -rm -f ./$(DEPDIR)/autoconnect.Po - -rm -f ./$(DEPDIR)/buffer.Po + -rm -f ./$(DEPDIR)/avl_tree.Po -rm -f ./$(DEPDIR)/conf.Po -rm -f ./$(DEPDIR)/connection.Po - -rm -f ./$(DEPDIR)/control.Po -rm -f ./$(DEPDIR)/dropin.Po -rm -f ./$(DEPDIR)/dummy_device.Po -rm -f ./$(DEPDIR)/edge.Po -rm -f ./$(DEPDIR)/event.Po - -rm -f ./$(DEPDIR)/fd_device.Po - -rm -f ./$(DEPDIR)/fsck.Po + -rm -f ./$(DEPDIR)/fake-getaddrinfo.Po + -rm -f ./$(DEPDIR)/fake-getnameinfo.Po -rm -f ./$(DEPDIR)/getopt.Po -rm -f ./$(DEPDIR)/getopt1.Po -rm -f ./$(DEPDIR)/graph.Po - -rm -f ./$(DEPDIR)/hash.Po - -rm -f ./$(DEPDIR)/ifconfig.Po - -rm -f ./$(DEPDIR)/info.Po - -rm -f ./$(DEPDIR)/invitation.Po -rm -f ./$(DEPDIR)/list.Po -rm -f ./$(DEPDIR)/logger.Po -rm -f ./$(DEPDIR)/meta.Po -rm -f ./$(DEPDIR)/multicast_device.Po - -rm -f ./$(DEPDIR)/names.Po -rm -f ./$(DEPDIR)/net.Po -rm -f ./$(DEPDIR)/net_packet.Po -rm -f ./$(DEPDIR)/net_setup.Po -rm -f ./$(DEPDIR)/net_socket.Po -rm -f ./$(DEPDIR)/netutl.Po -rm -f ./$(DEPDIR)/node.Po + -rm -f ./$(DEPDIR)/pidfile.Po -rm -f ./$(DEPDIR)/process.Po -rm -f ./$(DEPDIR)/protocol.Po -rm -f ./$(DEPDIR)/protocol_auth.Po @@ -1386,57 +827,19 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/protocol_key.Po -rm -f ./$(DEPDIR)/protocol_misc.Po -rm -f ./$(DEPDIR)/protocol_subnet.Po + -rm -f ./$(DEPDIR)/proxy.Po -rm -f ./$(DEPDIR)/raw_socket_device.Po -rm -f ./$(DEPDIR)/route.Po - -rm -f ./$(DEPDIR)/script.Po - -rm -f ./$(DEPDIR)/splay_tree.Po - -rm -f ./$(DEPDIR)/sptps.Po - -rm -f ./$(DEPDIR)/sptps_keypair.Po - -rm -f ./$(DEPDIR)/sptps_speed.Po - -rm -f ./$(DEPDIR)/sptps_test.Po -rm -f ./$(DEPDIR)/subnet.Po - -rm -f ./$(DEPDIR)/subnet_parse.Po - -rm -f ./$(DEPDIR)/tincctl.Po -rm -f ./$(DEPDIR)/tincd.Po - -rm -f ./$(DEPDIR)/top.Po -rm -f ./$(DEPDIR)/uml_device.Po - -rm -f ./$(DEPDIR)/upnp.Po -rm -f ./$(DEPDIR)/utils.Po -rm -f ./$(DEPDIR)/vde_device.Po - -rm -f ./$(DEPDIR)/version.Po -rm -f bsd/$(DEPDIR)/device.Po -rm -f bsd/$(DEPDIR)/tunemu.Po - -rm -f chacha-poly1305/$(DEPDIR)/chacha-poly1305.Po - -rm -f chacha-poly1305/$(DEPDIR)/chacha.Po - -rm -f chacha-poly1305/$(DEPDIR)/poly1305.Po -rm -f cygwin/$(DEPDIR)/device.Po - -rm -f ed25519/$(DEPDIR)/ecdh.Po - -rm -f ed25519/$(DEPDIR)/ecdsa.Po - -rm -f ed25519/$(DEPDIR)/ecdsagen.Po - -rm -f ed25519/$(DEPDIR)/fe.Po - -rm -f ed25519/$(DEPDIR)/ge.Po - -rm -f ed25519/$(DEPDIR)/key_exchange.Po - -rm -f ed25519/$(DEPDIR)/keypair.Po - -rm -f ed25519/$(DEPDIR)/sc.Po - -rm -f ed25519/$(DEPDIR)/sha512.Po - -rm -f ed25519/$(DEPDIR)/sign.Po - -rm -f ed25519/$(DEPDIR)/verify.Po - -rm -f gcrypt/$(DEPDIR)/cipher.Po - -rm -f gcrypt/$(DEPDIR)/crypto.Po - -rm -f gcrypt/$(DEPDIR)/digest.Po - -rm -f gcrypt/$(DEPDIR)/prf.Po - -rm -f gcrypt/$(DEPDIR)/rsa.Po - -rm -f gcrypt/$(DEPDIR)/rsagen.Po -rm -f linux/$(DEPDIR)/device.Po -rm -f mingw/$(DEPDIR)/device.Po - -rm -f nolegacy/$(DEPDIR)/crypto.Po - -rm -f nolegacy/$(DEPDIR)/prf.Po - -rm -f openssl/$(DEPDIR)/cipher.Po - -rm -f openssl/$(DEPDIR)/crypto.Po - -rm -f openssl/$(DEPDIR)/digest.Po - -rm -f openssl/$(DEPDIR)/prf.Po - -rm -f openssl/$(DEPDIR)/rsa.Po - -rm -f openssl/$(DEPDIR)/rsagen.Po -rm -f solaris/$(DEPDIR)/device.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -1455,36 +858,25 @@ ps-am: uninstall-am: uninstall-sbinPROGRAMS -.MAKE: check-am install-am install-strip +.MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ - clean-checkPROGRAMS clean-generic clean-sbinPROGRAMS \ - cscopelist-am ctags ctags-am distclean distclean-compile \ - distclean-generic distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-sbinPROGRAMS install-strip \ - installcheck installcheck-am installcheck-sbinPROGRAMS \ - installdirs maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ - ps ps-am tags tags-am uninstall uninstall-am \ - uninstall-sbinPROGRAMS + clean-generic clean-sbinPROGRAMS cscopelist-am ctags ctags-am \ + distclean distclean-compile distclean-generic distclean-tags \ + distdir dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-sbinPROGRAMS install-strip installcheck \ + installcheck-am installcheck-sbinPROGRAMS installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am uninstall-sbinPROGRAMS .PRECIOUS: Makefile -.PHONY: version-stamp -version-stamp: - -version_git.h: version-stamp - $(AM_V_GEN)echo >$@ - @-(cd $(srcdir) && git describe 2>/dev/null >/dev/null) && echo '#define GIT_DESCRIPTION "'`(cd $(srcdir) && git describe) | sed 's/release-//'`'"' >$@ ||: -${srcdir}/version.c: version_git.h - -@BSD_TRUE@version.c: ${srcdir}/version.c - # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/src/address_cache.c b/src/address_cache.c deleted file mode 100644 index 445cd1c..0000000 --- a/src/address_cache.c +++ /dev/null @@ -1,277 +0,0 @@ -/* - address_cache.c -- Manage cache of recently seen addresses - Copyright (C) 2018 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include "address_cache.h" -#include "conf.h" -#include "names.h" -#include "netutl.h" -#include "xalloc.h" - -static const unsigned int NOT_CACHED = -1; - -// Find edges pointing to this node, and use them to build a list of unique, known addresses. -static struct addrinfo *get_known_addresses(node_t *n) { - struct addrinfo *ai = NULL; - struct addrinfo *oai = NULL; - - for splay_each(edge_t, e, n->edge_tree) { - if(!e->reverse) { - continue; - } - - bool found = false; - - for(struct addrinfo *aip = ai; aip; aip = aip->ai_next) { - if(!sockaddrcmp(&e->reverse->address, (sockaddr_t *)aip->ai_addr)) { - found = true; - break; - } - } - - if(found) { - continue; - } - - oai = ai; - ai = xzalloc(sizeof(*ai)); - ai->ai_family = e->reverse->address.sa.sa_family; - ai->ai_socktype = SOCK_STREAM; - ai->ai_protocol = IPPROTO_TCP; - ai->ai_addrlen = SALEN(e->reverse->address.sa); - ai->ai_addr = xmalloc(ai->ai_addrlen); - memcpy(ai->ai_addr, &e->reverse->address, ai->ai_addrlen); - ai->ai_next = oai; - } - - return ai; -} - -static void free_known_addresses(struct addrinfo *ai) { - for(struct addrinfo *aip = ai, *next; aip; aip = next) { - next = aip->ai_next; - free(aip); - } -} - -static unsigned int find_cached(address_cache_t *cache, const sockaddr_t *sa) { - for(unsigned int i = 0; i < cache->data.used; i++) - if(!sockaddrcmp(&cache->data.address[i], sa)) { - return i; - } - - return NOT_CACHED; -} - -void add_recent_address(address_cache_t *cache, const sockaddr_t *sa) { - // Check if it's already cached - unsigned int pos = find_cached(cache, sa); - - // It's in the first spot, so nothing to do - if(pos == 0) { - return; - } - - // Shift everything, move/add the address to the first slot - if(pos == NOT_CACHED) { - if(cache->data.used < MAX_CACHED_ADDRESSES) { - cache->data.used++; - } - - pos = cache->data.used - 1; - } - - memmove(&cache->data.address[1], &cache->data.address[0], pos * sizeof(cache->data.address[0])); - - cache->data.address[0] = *sa; - - // Write the cache - char fname[PATH_MAX]; - snprintf(fname, sizeof(fname), "%s" SLASH "cache" SLASH "%s", confbase, cache->node->name); - FILE *fp = fopen(fname, "wb"); - - if(fp) { - fwrite(&cache->data, sizeof(cache->data), 1, fp); - fclose(fp); - } -} - -const sockaddr_t *get_recent_address(address_cache_t *cache) { - // Check if there is an address in our cache of recently seen addresses - if(cache->tried < cache->data.used) { - return &cache->data.address[cache->tried++]; - } - - // Next, check any recently seen addresses not in our cache - while(cache->tried == cache->data.used) { - if(!cache->ai) { - cache->aip = cache->ai = get_known_addresses(cache->node); - } - - if(cache->ai) { - if(cache->aip) { - sockaddr_t *sa = (sockaddr_t *)cache->aip->ai_addr; - cache->aip = cache->aip->ai_next; - - if(find_cached(cache, sa) != NOT_CACHED) { - continue; - } - - return sa; - } else { - free_known_addresses(cache->ai); - cache->ai = NULL; - } - } - - cache->tried++; - } - - // Otherwise, check if there are any known Address statements - if(!cache->config_tree) { - init_configuration(&cache->config_tree); - read_host_config(cache->config_tree, cache->node->name, false); - cache->cfg = lookup_config(cache->config_tree, "Address"); - } - - while(cache->cfg && !cache->ai) { - char *address, *port; - - get_config_string(cache->cfg, &address); - - char *space = strchr(address, ' '); - - if(space) { - port = xstrdup(space + 1); - *space = 0; - } else { - if(!get_config_string(lookup_config(cache->config_tree, "Port"), &port)) { - port = xstrdup("655"); - } - } - - cache->aip = cache->ai = str2addrinfo(address, port, SOCK_STREAM); - - if(cache->ai) { - struct addrinfo *ai = NULL; - - for(; cache->aip; cache->aip = cache->aip->ai_next) { - struct addrinfo *oai = ai; - - ai = xzalloc(sizeof(*ai)); - ai->ai_family = cache->aip->ai_family; - ai->ai_socktype = cache->aip->ai_socktype; - ai->ai_protocol = cache->aip->ai_protocol; - ai->ai_addrlen = cache->aip->ai_addrlen; - ai->ai_addr = xmalloc(ai->ai_addrlen); - memcpy(ai->ai_addr, cache->aip->ai_addr, ai->ai_addrlen); - ai->ai_next = oai; - } - - freeaddrinfo(cache->ai); - cache->aip = cache->ai = ai; - } - - free(address); - free(port); - - cache->cfg = lookup_config_next(cache->config_tree, cache->cfg); - } - - if(cache->ai) { - if(cache->aip) { - sockaddr_t *sa = (sockaddr_t *)cache->aip->ai_addr; - - cache->aip = cache->aip->ai_next; - return sa; - } else { - free_known_addresses(cache->ai); - cache->ai = NULL; - } - } - - // We're all out of addresses. - exit_configuration(&cache->config_tree); - return false; -} - -address_cache_t *open_address_cache(node_t *node) { - address_cache_t *cache = xmalloc(sizeof(*cache)); - cache->node = node; - - // Try to open an existing address cache - char fname[PATH_MAX]; - snprintf(fname, sizeof(fname), "%s" SLASH "cache" SLASH "%s", confbase, node->name); - FILE *fp = fopen(fname, "rb"); - - if(!fp || fread(&cache->data, sizeof(cache->data), 1, fp) != 1 || cache->data.version != ADDRESS_CACHE_VERSION) { - memset(&cache->data, 0, sizeof(cache->data)); - } - - if(fp) { - fclose(fp); - } - - // Ensure we have a valid state - cache->config_tree = NULL; - cache->cfg = NULL; - cache->ai = NULL; - cache->aip = NULL; - cache->tried = 0; - cache->data.version = ADDRESS_CACHE_VERSION; - - if(cache->data.used > MAX_CACHED_ADDRESSES) { - cache->data.used = 0; - } - - return cache; -} - -void reset_address_cache(address_cache_t *cache, const sockaddr_t *sa) { - if(sa) { - add_recent_address(cache, sa); - } - - if(cache->config_tree) { - exit_configuration(&cache->config_tree); - } - - if(cache->ai) { - free_known_addresses(cache->ai); - } - - cache->config_tree = NULL; - cache->cfg = NULL; - cache->ai = NULL; - cache->aip = NULL; - cache->tried = 0; -} - -void close_address_cache(address_cache_t *cache) { - if(cache->config_tree) { - exit_configuration(&cache->config_tree); - } - - if(cache->ai) { - free_known_addresses(cache->ai); - } - - free(cache); -} diff --git a/src/address_cache.h b/src/address_cache.h deleted file mode 100644 index 4ce6ec5..0000000 --- a/src/address_cache.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef TINC_ADDRESS_CACHE_H -#define TINC_ADDRESS_CACHE_H - -/* - address_cache.h -- header for address_cache.c - Copyright (C) 2018 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "net.h" - -#define MAX_CACHED_ADDRESSES 8 -#define ADDRESS_CACHE_VERSION 1 - -typedef struct address_cache_t { - struct node_t *node; - struct splay_tree_t *config_tree; - struct config_t *cfg; - struct addrinfo *ai; - struct addrinfo *aip; - unsigned int tried; - - struct { - unsigned int version; - unsigned int used; - sockaddr_t address[MAX_CACHED_ADDRESSES]; - } data; -} address_cache_t; - -void add_recent_address(address_cache_t *cache, const sockaddr_t *sa); -const sockaddr_t *get_recent_address(address_cache_t *cache); - -address_cache_t *open_address_cache(struct node_t *node); -void reset_address_cache(address_cache_t *cache, const sockaddr_t *sa); -void close_address_cache(address_cache_t *cache); - -#endif diff --git a/src/autoconnect.c b/src/autoconnect.c deleted file mode 100644 index 0fa6f4e..0000000 --- a/src/autoconnect.c +++ /dev/null @@ -1,195 +0,0 @@ -/* - autoconnect.c -- automatic connection establishment - Copyright (C) 2017 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include "connection.h" -#include "logger.h" -#include "node.h" -#include "xalloc.h" - -static void make_new_connection() { - /* Select a random node we haven't connected to yet. */ - int count = 0; - - for splay_each(node_t, n, node_tree) { - if(n == myself || n->connection || !(n->status.has_address || n->status.reachable)) { - continue; - } - - count++; - } - - if(!count) { - return; - } - - int r = rand() % count; - - for splay_each(node_t, n, node_tree) { - if(n == myself || n->connection || !(n->status.has_address || n->status.reachable)) { - continue; - } - - if(r--) { - continue; - } - - bool found = false; - - for list_each(outgoing_t, outgoing, outgoing_list) { - if(outgoing->node == n) { - found = true; - break; - } - } - - if(!found) { - logger(DEBUG_CONNECTIONS, LOG_INFO, "Autoconnecting to %s", n->name); - outgoing_t *outgoing = xzalloc(sizeof(*outgoing)); - outgoing->node = n; - list_insert_tail(outgoing_list, outgoing); - setup_outgoing_connection(outgoing, false); - } - - break; - } -} - -static void connect_to_unreachable() { - /* Select a random known node. The rationale is that if there are many - * reachable nodes, and only a few unreachable nodes, we don't want all - * reachable nodes to try to connect to the unreachable ones at the - * same time. This way, we back off automatically. Conversely, if there - * are only a few reachable nodes, and many unreachable ones, we're - * going to try harder to connect to them. */ - - int r = rand() % node_tree->count; - - for splay_each(node_t, n, node_tree) { - if(r--) { - continue; - } - - /* Is it unreachable and do we know an address for it? If not, return. */ - if(n == myself || n->connection || n->status.reachable || !n->status.has_address) { - return; - } - - /* Are we already trying to make an outgoing connection to it? If so, return. */ - for list_each(outgoing_t, outgoing, outgoing_list) { - if(outgoing->node == n) { - return; - } - } - - logger(DEBUG_CONNECTIONS, LOG_INFO, "Autoconnecting to %s", n->name); - outgoing_t *outgoing = xzalloc(sizeof(*outgoing)); - outgoing->node = n; - list_insert_tail(outgoing_list, outgoing); - setup_outgoing_connection(outgoing, false); - - return; - } -} - -static void drop_superfluous_outgoing_connection() { - /* Choose a random outgoing connection to a node that has at least one other connection. */ - int count = 0; - - for list_each(connection_t, c, connection_list) { - if(!c->edge || !c->outgoing || !c->node || c->node->edge_tree->count < 2) { - continue; - } - - count++; - } - - if(!count) { - return; - } - - int r = rand() % count; - - for list_each(connection_t, c, connection_list) { - if(!c->edge || !c->outgoing || !c->node || c->node->edge_tree->count < 2) { - continue; - } - - if(r--) { - continue; - } - - logger(DEBUG_CONNECTIONS, LOG_INFO, "Autodisconnecting from %s", c->name); - list_delete(outgoing_list, c->outgoing); - c->outgoing = NULL; - terminate_connection(c, c->edge); - break; - } -} - -static void drop_superfluous_pending_connections() { - for list_each(outgoing_t, o, outgoing_list) { - /* Only look for connections that are waiting to be retried later. */ - bool found = false; - - for list_each(connection_t, c, connection_list) { - if(c->outgoing == o) { - found = true; - break; - } - } - - if(found) { - continue; - } - - logger(DEBUG_CONNECTIONS, LOG_INFO, "Cancelled outgoing connection to %s", o->node->name); - list_delete_node(outgoing_list, node); - } -} - -void do_autoconnect() { - /* Count number of active connections. */ - int nc = 0; - - for list_each(connection_t, c, connection_list) { - if(c->edge) { - nc++; - } - } - - /* Less than 3 connections? Eagerly try to make a new one. */ - if(nc < 3) { - make_new_connection(); - return; - } - - /* More than 3 connections? See if we can get rid of a superfluous one. */ - if(nc > 3) { - drop_superfluous_outgoing_connection(); - } - - - /* Check if there are unreachable nodes that we should try to connect to. */ - connect_to_unreachable(); - - /* Drop pending outgoing connections from the outgoing list. */ - drop_superfluous_pending_connections(); -} diff --git a/src/autoconnect.h b/src/autoconnect.h deleted file mode 100644 index 82a5043..0000000 --- a/src/autoconnect.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef TINC_AUTOCONNECT_H -#define TINC_AUTOCONNECT_H - -/* - autoconnect.h -- header for autoconnect.c - Copyright (C) 2017 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -extern void do_autoconnect(void); - -#endif diff --git a/src/avl_tree.c b/src/avl_tree.c new file mode 100644 index 0000000..96d3d43 --- /dev/null +++ b/src/avl_tree.c @@ -0,0 +1,757 @@ +/* + avl_tree.c -- avl_ tree and linked list convenience + Copyright (C) 1998 Michael H. Buselli + 2000-2005 Ivo Timmermans, + 2000-2015 Guus Sliepen + 2000-2005 Wessel Dankers + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + Original AVL tree library by Michael H. Buselli . + + Modified 2000-11-28 by Wessel Dankers to use counts + instead of depths, to add the ->next and ->prev and to generally obfuscate + the code. Mail me if you found a bug. + + Cleaned up and incorporated some of the ideas from the red-black tree + library for inclusion into tinc (https://www.tinc-vpn.org/) by + Guus Sliepen . +*/ + +#include "system.h" + +#include "avl_tree.h" +#include "xalloc.h" + +#ifdef AVL_COUNT +#define AVL_NODE_COUNT(n) ((n) ? (n)->count : 0) +#define AVL_L_COUNT(n) (AVL_NODE_COUNT((n)->left)) +#define AVL_R_COUNT(n) (AVL_NODE_COUNT((n)->right)) +#define AVL_CALC_COUNT(n) (AVL_L_COUNT(n) + AVL_R_COUNT(n) + 1) +#endif + +#ifdef AVL_DEPTH +#define AVL_NODE_DEPTH(n) ((n) ? (n)->depth : 0) +#define L_AVL_DEPTH(n) (AVL_NODE_DEPTH((n)->left)) +#define R_AVL_DEPTH(n) (AVL_NODE_DEPTH((n)->right)) +#define AVL_CALC_DEPTH(n) ((L_AVL_DEPTH(n)>R_AVL_DEPTH(n)?L_AVL_DEPTH(n):R_AVL_DEPTH(n)) + 1) +#endif + +#ifndef AVL_DEPTH +static int lg(unsigned int u) __attribute__((__const__)); + +static int lg(unsigned int u) { + int r = 1; + + if(!u) { + return 0; + } + + if(u & 0xffff0000) { + u >>= 16; + r += 16; + } + + if(u & 0x0000ff00) { + u >>= 8; + r += 8; + } + + if(u & 0x000000f0) { + u >>= 4; + r += 4; + } + + if(u & 0x0000000c) { + u >>= 2; + r += 2; + } + + if(u & 0x00000002) { + r++; + } + + return r; +} +#endif + +/* Internal helper functions */ + +static int avl_check_balance(const avl_node_t *node) { +#ifdef AVL_DEPTH + int d; + + d = R_AVL_DEPTH(node) - L_AVL_DEPTH(node); + + return d < -1 ? -1 : d > 1 ? 1 : 0; +#else + /* int d; + * d = lg(AVL_R_COUNT(node)) - lg(AVL_L_COUNT(node)); + * d = d<-1?-1:d>1?1:0; + */ + int pl, r; + + pl = lg(AVL_L_COUNT(node)); + r = AVL_R_COUNT(node); + + if(r >> pl + 1) { + return 1; + } + + if(pl < 2 || r >> pl - 2) { + return 0; + } + + return -1; +#endif +} + +static void avl_rebalance(avl_tree_t *tree, avl_node_t *node) { + avl_node_t *child; + avl_node_t *gchild; + avl_node_t *parent; + avl_node_t **superparent; + + while(node) { + parent = node->parent; + + superparent = + parent ? node == + parent->left ? &parent->left : &parent->right : &tree->root; + + switch(avl_check_balance(node)) { + case -1: + child = node->left; +#ifdef AVL_DEPTH + + if(L_AVL_DEPTH(child) >= R_AVL_DEPTH(child)) { +#else + + if(AVL_L_COUNT(child) >= AVL_R_COUNT(child)) { +#endif + node->left = child->right; + + if(node->left) { + node->left->parent = node; + } + + child->right = node; + node->parent = child; + *superparent = child; + child->parent = parent; +#ifdef AVL_COUNT + node->count = AVL_CALC_COUNT(node); + child->count = AVL_CALC_COUNT(child); +#endif +#ifdef AVL_DEPTH + node->depth = AVL_CALC_DEPTH(node); + child->depth = AVL_CALC_DEPTH(child); +#endif + } else { + gchild = child->right; + node->left = gchild->right; + + if(node->left) { + node->left->parent = node; + } + + child->right = gchild->left; + + if(child->right) { + child->right->parent = child; + } + + gchild->right = node; + + gchild->right->parent = gchild; + gchild->left = child; + + gchild->left->parent = gchild; + + *superparent = gchild; + gchild->parent = parent; +#ifdef AVL_COUNT + node->count = AVL_CALC_COUNT(node); + child->count = AVL_CALC_COUNT(child); + gchild->count = AVL_CALC_COUNT(gchild); +#endif +#ifdef AVL_DEPTH + node->depth = AVL_CALC_DEPTH(node); + child->depth = AVL_CALC_DEPTH(child); + gchild->depth = AVL_CALC_DEPTH(gchild); +#endif + } + + break; + + case 1: + child = node->right; +#ifdef AVL_DEPTH + + if(R_AVL_DEPTH(child) >= L_AVL_DEPTH(child)) { +#else + + if(AVL_R_COUNT(child) >= AVL_L_COUNT(child)) { +#endif + node->right = child->left; + + if(node->right) { + node->right->parent = node; + } + + child->left = node; + node->parent = child; + *superparent = child; + child->parent = parent; +#ifdef AVL_COUNT + node->count = AVL_CALC_COUNT(node); + child->count = AVL_CALC_COUNT(child); +#endif +#ifdef AVL_DEPTH + node->depth = AVL_CALC_DEPTH(node); + child->depth = AVL_CALC_DEPTH(child); +#endif + } else { + gchild = child->left; + node->right = gchild->left; + + if(node->right) { + node->right->parent = node; + } + + child->left = gchild->right; + + if(child->left) { + child->left->parent = child; + } + + gchild->left = node; + + gchild->left->parent = gchild; + gchild->right = child; + + gchild->right->parent = gchild; + + *superparent = gchild; + gchild->parent = parent; +#ifdef AVL_COUNT + node->count = AVL_CALC_COUNT(node); + child->count = AVL_CALC_COUNT(child); + gchild->count = AVL_CALC_COUNT(gchild); +#endif +#ifdef AVL_DEPTH + node->depth = AVL_CALC_DEPTH(node); + child->depth = AVL_CALC_DEPTH(child); + gchild->depth = AVL_CALC_DEPTH(gchild); +#endif + } + + break; + + default: +#ifdef AVL_COUNT + node->count = AVL_CALC_COUNT(node); +#endif +#ifdef AVL_DEPTH + node->depth = AVL_CALC_DEPTH(node); +#endif + } + + node = parent; + } +} + +/* (De)constructors */ + +avl_tree_t *avl_alloc_tree(avl_compare_t compare, avl_action_t delete) { + avl_tree_t *tree; + + tree = xmalloc_and_zero(sizeof(avl_tree_t)); + tree->compare = compare; + tree->delete = delete; + + return tree; +} + +void avl_free_tree(avl_tree_t *tree) { + free(tree); +} + +avl_node_t *avl_alloc_node(void) { + return xmalloc_and_zero(sizeof(avl_node_t)); +} + +void avl_free_node(avl_tree_t *tree, avl_node_t *node) { + if(node->data && tree->delete) { + tree->delete(node->data); + } + + free(node); +} + +/* Searching */ + +void *avl_search(const avl_tree_t *tree, const void *data) { + avl_node_t *node; + + node = avl_search_node(tree, data); + + return node ? node->data : NULL; +} + +void *avl_search_closest(const avl_tree_t *tree, const void *data, int *result) { + avl_node_t *node; + + node = avl_search_closest_node(tree, data, result); + + return node ? node->data : NULL; +} + +void *avl_search_closest_smaller(const avl_tree_t *tree, const void *data) { + avl_node_t *node; + + node = avl_search_closest_smaller_node(tree, data); + + return node ? node->data : NULL; +} + +void *avl_search_closest_greater(const avl_tree_t *tree, const void *data) { + avl_node_t *node; + + node = avl_search_closest_greater_node(tree, data); + + return node ? node->data : NULL; +} + +avl_node_t *avl_search_node(const avl_tree_t *tree, const void *data) { + avl_node_t *node; + int result; + + node = avl_search_closest_node(tree, data, &result); + + return result ? NULL : node; +} + +avl_node_t *avl_search_closest_node(const avl_tree_t *tree, const void *data, + int *result) { + avl_node_t *node; + int c; + + node = tree->root; + + if(!node) { + if(result) { + *result = 0; + } + + return NULL; + } + + for(;;) { + c = tree->compare(data, node->data); + + if(c < 0) { + if(node->left) { + node = node->left; + } else { + if(result) { + *result = -1; + } + + break; + } + } else if(c > 0) { + if(node->right) { + node = node->right; + } else { + if(result) { + *result = 1; + } + + break; + } + } else { + if(result) { + *result = 0; + } + + break; + } + } + + return node; +} + +avl_node_t *avl_search_closest_smaller_node(const avl_tree_t *tree, + const void *data) { + avl_node_t *node; + int result; + + node = avl_search_closest_node(tree, data, &result); + + if(result < 0) { + node = node->prev; + } + + return node; +} + +avl_node_t *avl_search_closest_greater_node(const avl_tree_t *tree, + const void *data) { + avl_node_t *node; + int result; + + node = avl_search_closest_node(tree, data, &result); + + if(result > 0) { + node = node->next; + } + + return node; +} + +/* Insertion and deletion */ + +avl_node_t *avl_insert(avl_tree_t *tree, void *data) { + avl_node_t *closest, *new; + int result; + + if(!tree->root) { + new = avl_alloc_node(); + new->data = data; + avl_insert_top(tree, new); + } else { + closest = avl_search_closest_node(tree, data, &result); + + switch(result) { + case -1: + new = avl_alloc_node(); + new->data = data; + avl_insert_before(tree, closest, new); + break; + + case 1: + new = avl_alloc_node(); + new->data = data; + avl_insert_after(tree, closest, new); + break; + + default: + return NULL; + } + } + +#ifdef AVL_COUNT + new->count = 1; +#endif +#ifdef AVL_DEPTH + new->depth = 1; +#endif + + return new; +} + +avl_node_t *avl_insert_node(avl_tree_t *tree, avl_node_t *node) { + avl_node_t *closest; + int result; + + if(!tree->root) { + avl_insert_top(tree, node); + } else { + closest = avl_search_closest_node(tree, node->data, &result); + + switch(result) { + case -1: + avl_insert_before(tree, closest, node); + break; + + case 1: + avl_insert_after(tree, closest, node); + break; + + case 0: + return NULL; + } + } + +#ifdef AVL_COUNT + node->count = 1; +#endif +#ifdef AVL_DEPTH + node->depth = 1; +#endif + + return node; +} + +void avl_insert_top(avl_tree_t *tree, avl_node_t *node) { + node->prev = node->next = node->parent = NULL; + tree->head = tree->tail = tree->root = node; +} + +void avl_insert_before(avl_tree_t *tree, avl_node_t *before, + avl_node_t *node) { + if(!before) { + if(tree->tail) { + avl_insert_after(tree, tree->tail, node); + } else { + avl_insert_top(tree, node); + } + + return; + } + + node->next = before; + node->parent = before; + node->prev = before->prev; + + if(before->left) { + avl_insert_after(tree, before->prev, node); + return; + } + + if(before->prev) { + before->prev->next = node; + } else { + tree->head = node; + } + + before->prev = node; + before->left = node; + + avl_rebalance(tree, before); +} + +void avl_insert_after(avl_tree_t *tree, avl_node_t *after, avl_node_t *node) { + if(!after) { + if(tree->head) { + avl_insert_before(tree, tree->head, node); + } else { + avl_insert_top(tree, node); + } + + return; + } + + if(after->right) { + avl_insert_before(tree, after->next, node); + return; + } + + node->prev = after; + node->parent = after; + node->next = after->next; + + if(after->next) { + after->next->prev = node; + } else { + tree->tail = node; + } + + after->next = node; + after->right = node; + + avl_rebalance(tree, after); +} + +avl_node_t *avl_unlink(avl_tree_t *tree, void *data) { + avl_node_t *node; + + node = avl_search_node(tree, data); + + if(node) { + avl_unlink_node(tree, node); + } + + return node; +} + +void avl_unlink_node(avl_tree_t *tree, avl_node_t *node) { + avl_node_t *parent; + avl_node_t **superparent; + avl_node_t *subst, *left, *right; + avl_node_t *balnode; + + if(node->prev) { + node->prev->next = node->next; + } else { + tree->head = node->next; + } + + if(node->next) { + node->next->prev = node->prev; + } else { + tree->tail = node->prev; + } + + parent = node->parent; + + superparent = + parent ? node == + parent->left ? &parent->left : &parent->right : &tree->root; + + left = node->left; + right = node->right; + + if(!left) { + *superparent = right; + + if(right) { + right->parent = parent; + } + + balnode = parent; + } else if(!right) { + *superparent = left; + left->parent = parent; + balnode = parent; + } else { + subst = node->prev; + + if(!subst) { // This only happens if node is not actually in a tree at all. + abort(); + } + + if(subst == left) { + balnode = subst; + } else { + balnode = subst->parent; + balnode->right = subst->left; + + if(balnode->right) { + balnode->right->parent = balnode; + } + + subst->left = left; + left->parent = subst; + } + + subst->right = right; + subst->parent = parent; + right->parent = subst; + *superparent = subst; + } + + avl_rebalance(tree, balnode); + + node->next = node->prev = node->parent = node->left = node->right = NULL; + +#ifdef AVL_COUNT + node->count = 0; +#endif +#ifdef AVL_DEPTH + node->depth = 0; +#endif +} + +void avl_delete_node(avl_tree_t *tree, avl_node_t *node) { + avl_unlink_node(tree, node); + avl_free_node(tree, node); +} + +void avl_delete(avl_tree_t *tree, void *data) { + avl_node_t *node; + + node = avl_search_node(tree, data); + + if(node) { + avl_delete_node(tree, node); + } +} + +/* Fast tree cleanup */ + +void avl_delete_tree(avl_tree_t *tree) { + avl_node_t *node, *next; + + for(node = tree->head; node; node = next) { + next = node->next; + avl_free_node(tree, node); + } + + avl_free_tree(tree); +} + +/* Tree walking */ + +void avl_foreach(const avl_tree_t *tree, avl_action_t action) { + avl_node_t *node, *next; + + for(node = tree->head; node; node = next) { + next = node->next; + action(node->data); + } +} + +void avl_foreach_node(const avl_tree_t *tree, avl_action_t action) { + avl_node_t *node, *next; + + for(node = tree->head; node; node = next) { + next = node->next; + action(node); + } +} + +/* Indexing */ + +#ifdef AVL_COUNT +unsigned int avl_count(const avl_tree_t *tree) { + return AVL_NODE_COUNT(tree->root); +} + +avl_node_t *avl_get_node(const avl_tree_t *tree, unsigned int index) { + avl_node_t *node; + unsigned int c; + + node = tree->root; + + while(node) { + c = AVL_L_COUNT(node); + + if(index < c) { + node = node->left; + } else if(index > c) { + node = node->right; + index -= c + 1; + } else { + return node; + } + } + + return NULL; +} + +unsigned int avl_index(const avl_node_t *node) { + avl_node_t *next; + unsigned int index; + + index = AVL_L_COUNT(node); + + while((next = node->parent)) { + if(node == next->right) { + index += AVL_L_COUNT(next) + 1; + } + + node = next; + } + + return index; +} +#endif +#ifdef AVL_DEPTH +unsigned int avl_depth(const avl_tree_t *tree) { + return AVL_NODE_DEPTH(tree->root); +} +#endif diff --git a/src/avl_tree.h b/src/avl_tree.h new file mode 100644 index 0000000..e8cefcf --- /dev/null +++ b/src/avl_tree.h @@ -0,0 +1,142 @@ +#ifndef TINC_AVL_TREE_H +#define TINC_AVL_TREE_H + +/* + avl_tree.h -- header file for avl_tree.c + Copyright (C) 1998 Michael H. Buselli + 2000-2005 Ivo Timmermans, + 2000-2006 Guus Sliepen + 2000-2005 Wessel Dankers + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + Original AVL tree library by Michael H. Buselli . + + Modified 2000-11-28 by Wessel Dankers to use counts + instead of depths, to add the ->next and ->prev and to generally obfuscate + the code. Mail me if you found a bug. + + Cleaned up and incorporated some of the ideas from the red-black tree + library for inclusion into tinc (https://www.tinc-vpn.org/) by + Guus Sliepen . +*/ + +#ifndef AVL_DEPTH +#ifndef AVL_COUNT +#define AVL_DEPTH +#endif +#endif + +typedef struct avl_node_t { + + /* Linked list part */ + + struct avl_node_t *next; + struct avl_node_t *prev; + + /* Tree part */ + + struct avl_node_t *parent; + struct avl_node_t *left; + struct avl_node_t *right; + +#ifdef AVL_COUNT + unsigned int count; +#endif +#ifdef AVL_DEPTH + unsigned char depth; +#endif + + /* Payload */ + + void *data; + +} avl_node_t; + +typedef int (*avl_compare_t)(const void *data1, const void *data2); +typedef void (*avl_action_t)(const void *data); +typedef void (*avl_action_node_t)(const avl_node_t *node); + +typedef struct avl_tree_t { + + /* Linked list part */ + + avl_node_t *head; + avl_node_t *tail; + + /* Tree part */ + + avl_node_t *root; + + avl_compare_t compare; + avl_action_t delete; + +} avl_tree_t; + +/* (De)constructors */ + +extern avl_tree_t *avl_alloc_tree(avl_compare_t compare, avl_action_t delete); +extern void avl_free_tree(avl_tree_t *tree); + +extern avl_node_t *avl_alloc_node(void); +extern void avl_free_node(avl_tree_t *tree, avl_node_t *node); + +/* Insertion and deletion */ + +extern avl_node_t *avl_insert(avl_tree_t *tree, void *data); +extern avl_node_t *avl_insert_node(avl_tree_t *tree, avl_node_t *node); + +extern void avl_insert_top(avl_tree_t *tree, avl_node_t *node); +extern void avl_insert_before(avl_tree_t *tree, avl_node_t *before, avl_node_t *node); +extern void avl_insert_after(avl_tree_t *tree, avl_node_t *after, avl_node_t *node); + +extern avl_node_t *avl_unlink(avl_tree_t *tree, void *data); +extern void avl_unlink_node(avl_tree_t *tree, avl_node_t *node); +extern void avl_delete(avl_tree_t *tree, void *data); +extern void avl_delete_node(avl_tree_t *tree, avl_node_t *node); + +/* Fast tree cleanup */ + +extern void avl_delete_tree(avl_tree_t *tree); + +/* Searching */ + +extern void *avl_search(const avl_tree_t *tree, const void *data); +extern void *avl_search_closest(const avl_tree_t *tree, const void *data, int *result); +extern void *avl_search_closest_smaller(const avl_tree_t *tree, const void *data); +extern void *avl_search_closest_greater(const avl_tree_t *tree, const void *data); + +extern avl_node_t *avl_search_node(const avl_tree_t *tree, const void *data); +extern avl_node_t *avl_search_closest_node(const avl_tree_t *tree, const void *data, int *result); +extern avl_node_t *avl_search_closest_smaller_node(const avl_tree_t *tree, const void *data); +extern avl_node_t *avl_search_closest_greater_node(const avl_tree_t *tree, const void *data); + +/* Tree walking */ + +extern void avl_foreach(const avl_tree_t *tree, avl_action_t action); +extern void avl_foreach_node(const avl_tree_t *tree, avl_action_t action); + +/* Indexing */ + +#ifdef AVL_COUNT +extern unsigned int avl_count(const avl_tree_t *tree); +extern avl_node_t *avl_get_node(const avl_tree_t *tree, unsigned int index); +extern unsigned int avl_index(const avl_node_t *node); +#endif +#ifdef AVL_DEPTH +extern unsigned int avl_depth(const avl_tree_t *tree); +#endif + +#endif diff --git a/src/bsd/device.c b/src/bsd/device.c index 0eeee6e..23d6d69 100644 --- a/src/bsd/device.c +++ b/src/bsd/device.c @@ -1,7 +1,7 @@ /* device.c -- Interaction BSD tun/tap device Copyright (C) 2001-2005 Ivo Timmermans, - 2001-2017 Guus Sliepen + 2001-2016 Guus Sliepen 2009 Grzegorz Dymarek This program is free software; you can redistribute it and/or modify @@ -24,14 +24,13 @@ #include "../conf.h" #include "../device.h" #include "../logger.h" -#include "../names.h" #include "../net.h" #include "../route.h" #include "../utils.h" #include "../xalloc.h" #ifdef ENABLE_TUNEMU -#include "bsd/tunemu.h" +#include "tunemu.h" #endif #ifdef HAVE_NET_IF_UTUN_H @@ -57,6 +56,8 @@ int device_fd = -1; char *device = NULL; char *iface = NULL; static const char *device_info = "OS X utun device"; +static uint64_t device_total_in = 0; +static uint64_t device_total_out = 0; #if defined(ENABLE_TUNEMU) static device_type_t device_type = DEVICE_TYPE_TUNEMU; #elif defined(HAVE_OPENBSD) || defined(HAVE_FREEBSD) || defined(HAVE_DRAGONFLY) @@ -70,7 +71,7 @@ static bool setup_utun(void) { device_fd = socket(PF_SYSTEM, SOCK_DGRAM, SYSPROTO_CONTROL); if(device_fd == -1) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not open PF_SYSTEM socket: %s\n", strerror(errno)); + logger(LOG_ERR, "Could not open PF_SYSTEM socket: %s\n", strerror(errno)); return false; } @@ -79,7 +80,7 @@ static bool setup_utun(void) { strlcpy(info.ctl_name, UTUN_CONTROL_NAME, sizeof(info.ctl_name)); if(ioctl(device_fd, CTLIOCGINFO, &info) == -1) { - logger(DEBUG_ALWAYS, LOG_ERR, "ioctl(CTLIOCGINFO) failed: %s", strerror(errno)); + logger(LOG_ERR, "ioctl(CTLIOCGINFO) failed: %s", strerror(errno)); return false; } @@ -103,7 +104,7 @@ static bool setup_utun(void) { }; if(connect(device_fd, (struct sockaddr *)&sc, sizeof(sc)) == -1) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not connect utun socket: %s\n", strerror(errno)); + logger(LOG_ERR, "Could not connect utun socket: %s\n", strerror(errno)); return false; } @@ -116,14 +117,22 @@ static bool setup_utun(void) { iface = xstrdup(name); } - logger(DEBUG_ALWAYS, LOG_INFO, "%s is a %s", device, device_info); + logger(LOG_INFO, "%s is a %s", device, device_info); return true; } #endif static bool setup_device(void) { - get_config_string(lookup_config(config_tree, "Device"), &device); + // Find out which device file to open + + if(!get_config_string(lookup_config(config_tree, "Device"), &device)) { + if(routing_mode == RMODE_ROUTER) { + device = xstrdup(DEFAULT_TUN_DEVICE); + } else { + device = xstrdup(DEFAULT_TAP_DEVICE); + } + } // Find out if it's supposed to be a tun or a tap device @@ -152,36 +161,26 @@ static bool setup_device(void) { } else if(!strcasecmp(type, "tap")) { device_type = DEVICE_TYPE_TAP; } else { - logger(DEBUG_ALWAYS, LOG_ERR, "Unknown device type %s!", type); + logger(LOG_ERR, "Unknown device type %s!", type); return false; } } else { #ifdef HAVE_NET_IF_UTUN_H - if(device && (strncmp(device, "utun", 4) == 0 || strncmp(device, "/dev/utun", 9) == 0)) { + if(strncmp(device, "utun", 4) == 0 || strncmp(device, "/dev/utun", 9) == 0) { device_type = DEVICE_TYPE_UTUN; } else #endif - if((device && strstr(device, "tap")) || routing_mode != RMODE_ROUTER) { + if(strstr(device, "tap") || routing_mode != RMODE_ROUTER) { device_type = DEVICE_TYPE_TAP; } } if(routing_mode == RMODE_SWITCH && device_type != DEVICE_TYPE_TAP) { - logger(DEBUG_ALWAYS, LOG_ERR, "Only tap devices support switch mode!"); + logger(LOG_ERR, "Only tap devices support switch mode!"); return false; } - // Find out which device file to open - - if(!device) { - if(device_type == DEVICE_TYPE_TAP) { - device = xstrdup(DEFAULT_TAP_DEVICE); - } else { - device = xstrdup(DEFAULT_TUN_DEVICE); - } - } - // Open the device switch(device_type) { @@ -204,7 +203,7 @@ static bool setup_device(void) { } if(device_fd < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not open %s: %s", device, strerror(errno)); + logger(LOG_ERR, "Could not open %s: %s", device, strerror(errno)); return false; } @@ -234,7 +233,7 @@ static bool setup_device(void) { if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) { iface = xstrdup(strrchr(realname, '/') ? strrchr(realname, '/') + 1 : realname); } else if(strcmp(iface, strrchr(realname, '/') ? strrchr(realname, '/') + 1 : realname)) { - logger(DEBUG_ALWAYS, LOG_WARNING, "Warning: Interface does not match Device. $INTERFACE might be set incorrectly."); + logger(LOG_WARNING, "Warning: Interface does not match Device. $INTERFACE might be set incorrectly."); } // Configure the device as best as we can @@ -249,7 +248,7 @@ static bool setup_device(void) { const int zero = 0; if(ioctl(device_fd, TUNSIFHEAD, &zero, sizeof(zero)) == -1) { - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "ioctl", strerror(errno)); + logger(LOG_ERR, "System call `%s' failed: %s", "ioctl", strerror(errno)); return false; } } @@ -271,7 +270,7 @@ static bool setup_device(void) { const int one = 1; if(ioctl(device_fd, TUNSIFHEAD, &one, sizeof(one)) == -1) { - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "ioctl", strerror(errno)); + logger(LOG_ERR, "System call `%s' failed: %s", "ioctl", strerror(errno)); return false; } } @@ -298,7 +297,10 @@ static bool setup_device(void) { struct ifreq ifr; if(ioctl(device_fd, TAPGIFNAME, (void *)&ifr) == 0) { - free(iface); + if(iface) { + free(iface); + } + iface = xstrdup(ifr.ifr_name); } } @@ -321,7 +323,7 @@ static bool setup_device(void) { #endif - logger(DEBUG_ALWAYS, LOG_INFO, "%s is a %s", device, device_info); + logger(LOG_INFO, "%s is a %s", device, device_info); return true; } @@ -339,115 +341,112 @@ static void close_device(void) { close(device_fd); } - device_fd = -1; - free(device); - device = NULL; free(iface); - iface = NULL; - device_info = NULL; } static bool read_packet(vpn_packet_t *packet) { - int inlen; + int lenin; switch(device_type) { case DEVICE_TYPE_TUN: #ifdef ENABLE_TUNEMU case DEVICE_TYPE_TUNEMU: if(device_type == DEVICE_TYPE_TUNEMU) { - inlen = tunemu_read(device_fd, DATA(packet) + 14, MTU - 14); + lenin = tunemu_read(device_fd, packet->data + 14, MTU - 14); } else #endif - inlen = read(device_fd, DATA(packet) + 14, MTU - 14); + lenin = read(device_fd, packet->data + 14, MTU - 14); - if(inlen <= 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from %s %s: %s", device_info, + if(lenin <= 0) { + logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); return false; } - switch(DATA(packet)[14] >> 4) { + switch(packet->data[14] >> 4) { case 4: - DATA(packet)[12] = 0x08; - DATA(packet)[13] = 0x00; + packet->data[12] = 0x08; + packet->data[13] = 0x00; break; case 6: - DATA(packet)[12] = 0x86; - DATA(packet)[13] = 0xDD; + packet->data[12] = 0x86; + packet->data[13] = 0xDD; break; default: - logger(DEBUG_TRAFFIC, LOG_ERR, - "Unknown IP version %d while reading packet from %s %s", - DATA(packet)[14] >> 4, device_info, device); + ifdebug(TRAFFIC) logger(LOG_ERR, + "Unknown IP version %d while reading packet from %s %s", + packet->data[14] >> 4, device_info, device); return false; } - memset(DATA(packet), 0, 12); - packet->len = inlen + 14; + memset(packet->data, 0, 12); + packet->len = lenin + 14; break; case DEVICE_TYPE_UTUN: case DEVICE_TYPE_TUNIFHEAD: { - if((inlen = read(device_fd, DATA(packet) + 10, MTU - 10)) <= 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from %s %s: %s", device_info, + if((lenin = read(device_fd, packet->data + 10, MTU - 10)) <= 0) { + logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); return false; } - switch(DATA(packet)[14] >> 4) { + switch(packet->data[14] >> 4) { case 4: - DATA(packet)[12] = 0x08; - DATA(packet)[13] = 0x00; + packet->data[12] = 0x08; + packet->data[13] = 0x00; break; case 6: - DATA(packet)[12] = 0x86; - DATA(packet)[13] = 0xDD; + packet->data[12] = 0x86; + packet->data[13] = 0xDD; break; default: - logger(DEBUG_TRAFFIC, LOG_ERR, - "Unknown IP version %d while reading packet from %s %s", - DATA(packet)[14] >> 4, device_info, device); + ifdebug(TRAFFIC) logger(LOG_ERR, + "Unknown IP version %d while reading packet from %s %s", + packet->data[14] >> 4, device_info, device); return false; } - memset(DATA(packet), 0, 12); - packet->len = inlen + 10; + memset(packet->data, 0, 12); + packet->len = lenin + 10; break; } case DEVICE_TYPE_TAP: - if((inlen = read(device_fd, DATA(packet), MTU)) <= 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from %s %s: %s", device_info, + if((lenin = read(device_fd, packet->data, MTU)) <= 0) { + logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); return false; } - packet->len = inlen; + packet->len = lenin; break; default: return false; } - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", - packet->len, device_info); + device_total_in += packet->len; + + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", + packet->len, device_info); return true; } static bool write_packet(vpn_packet_t *packet) { - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Writing packet of %d bytes to %s", - packet->len, device_info); + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Writing packet of %d bytes to %s", + packet->len, device_info); switch(device_type) { case DEVICE_TYPE_TUN: - if(write(device_fd, DATA(packet) + 14, packet->len - 14) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while writing to %s %s: %s", device_info, + if(write(device_fd, packet->data + 14, packet->len - 14) < 0) { + logger(LOG_ERR, "Error while writing to %s %s: %s", device_info, device, strerror(errno)); return false; } @@ -456,7 +455,7 @@ static bool write_packet(vpn_packet_t *packet) { case DEVICE_TYPE_UTUN: case DEVICE_TYPE_TUNIFHEAD: { - int af = (DATA(packet)[12] << 8) + DATA(packet)[13]; + int af = (packet->data[12] << 8) + packet->data[13]; uint32_t type; switch(af) { @@ -469,16 +468,16 @@ static bool write_packet(vpn_packet_t *packet) { break; default: - logger(DEBUG_TRAFFIC, LOG_ERR, - "Unknown address family %x while writing packet to %s %s", - af, device_info, device); + ifdebug(TRAFFIC) logger(LOG_ERR, + "Unknown address family %x while writing packet to %s %s", + af, device_info, device); return false; } - memcpy(DATA(packet) + 10, &type, sizeof(type)); + memcpy(packet->data + 10, &type, sizeof(type)); - if(write(device_fd, DATA(packet) + 10, packet->len - 10) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Can't write to %s %s: %s", device_info, device, + if(write(device_fd, packet->data + 10, packet->len - 10) < 0) { + logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, strerror(errno)); return false; } @@ -487,8 +486,8 @@ static bool write_packet(vpn_packet_t *packet) { } case DEVICE_TYPE_TAP: - if(write(device_fd, DATA(packet), packet->len) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while writing to %s %s: %s", device_info, + if(write(device_fd, packet->data, packet->len) < 0) { + logger(LOG_ERR, "Error while writing to %s %s: %s", device_info, device, strerror(errno)); return false; } @@ -498,8 +497,8 @@ static bool write_packet(vpn_packet_t *packet) { #ifdef ENABLE_TUNEMU case DEVICE_TYPE_TUNEMU: - if(tunemu_write(device_fd, DATA(packet) + 14, packet->len - 14) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while writing to %s %s: %s", device_info, + if(tunemu_write(device_fd, packet->data + 14, packet->len - 14) < 0) { + logger(LOG_ERR, "Error while writing to %s %s: %s", device_info, device, strerror(errno)); return false; } @@ -511,12 +510,21 @@ static bool write_packet(vpn_packet_t *packet) { return false; } + device_total_out += packet->len; + return true; } +static void dump_device_stats(void) { + logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); + logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); + logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); +} + const devops_t os_devops = { .setup = setup_device, .close = close_device, .read = read_packet, .write = write_packet, + .dump_stats = dump_device_stats, }; diff --git a/src/bsd/tunemu.c b/src/bsd/tunemu.c index 2248264..7ff6f72 100644 --- a/src/bsd/tunemu.c +++ b/src/bsd/tunemu.c @@ -45,9 +45,9 @@ #define PPPIOCSFLAGS _IOW('t', 89, int) #define PPPIOCSNPMODE _IOW('t', 75, struct npioctl) #define PPPIOCATTCHAN _IOW('t', 56, int) -#define PPPIOCGCHAN _IOR('t', 55, int) +#define PPPIOCGCHAN _IOR('t', 55, int) #define PPPIOCCONNECT _IOW('t', 58, int) -#define PPPIOCGUNIT _IOR('t', 86, int) +#define PPPIOCGUNIT _IOR('t', 86, int) struct sockaddr_ppp { u_int8_t ppp_len; @@ -83,7 +83,7 @@ static char *data_buffer = NULL; static void tun_error(char *format, ...) { va_list vl; va_start(vl, format); - vsnprintf(tunemu_error, sizeof(tunemu_error), format, vl); + vsnprintf(tunemu_error, ERROR_BUFFER_SIZE, format, vl); va_end(vl); } diff --git a/src/buffer.c b/src/buffer.c deleted file mode 100644 index 60adec8..0000000 --- a/src/buffer.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - buffer.c -- buffer management - Copyright (C) 2011 Guus Sliepen , - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include "buffer.h" -#include "xalloc.h" - -void buffer_compact(buffer_t *buffer, uint32_t maxsize) { - if(buffer->len >= maxsize || buffer->offset / 7 > buffer->len / 8) { - memmove(buffer->data, buffer->data + buffer->offset, buffer->len - buffer->offset); - buffer->len -= buffer->offset; - buffer->offset = 0; - } -} - -// Make sure we can add size bytes to the buffer, and return a pointer to the start of those bytes. - -char *buffer_prepare(buffer_t *buffer, uint32_t size) { - if(!buffer->data) { - buffer->maxlen = size; - buffer->data = xmalloc(size); - } else { - if(buffer->offset && buffer->len + size > buffer->maxlen) { - memmove(buffer->data, buffer->data + buffer->offset, buffer->len - buffer->offset); - buffer->len -= buffer->offset; - buffer->offset = 0; - } - - if(buffer->len + size > buffer->maxlen) { - buffer->maxlen = buffer->len + size; - buffer->data = xrealloc(buffer->data, buffer->maxlen); - } - } - - char *start = buffer->data + buffer->len; - - buffer->len += size; - - return start; -} - -// Copy data into the buffer. - -void buffer_add(buffer_t *buffer, const char *data, uint32_t size) { - memcpy(buffer_prepare(buffer, size), data, size); -} - -// Remove given number of bytes from the buffer, return a pointer to the start of them. - -static char *buffer_consume(buffer_t *buffer, uint32_t size) { - char *start = buffer->data + buffer->offset; - - buffer->offset += size; - - if(buffer->offset >= buffer->len) { - buffer->offset = 0; - buffer->len = 0; - } - - return start; -} - -// Check if there is a complete line in the buffer, and if so, return it NULL-terminated. - -char *buffer_readline(buffer_t *buffer) { - char *newline = memchr(buffer->data + buffer->offset, '\n', buffer->len - buffer->offset); - - if(!newline) { - return NULL; - } - - uint32_t len = newline + 1 - (buffer->data + buffer->offset); - *newline = 0; - return buffer_consume(buffer, len); -} - -// Check if we have enough bytes in the buffer, and if so, return a pointer to the start of them. - -char *buffer_read(buffer_t *buffer, uint32_t size) { - if(buffer->len - buffer->offset < size) { - return NULL; - } - - return buffer_consume(buffer, size); -} - -void buffer_clear(buffer_t *buffer) { - free(buffer->data); - buffer->data = NULL; - buffer->maxlen = 0; - buffer->len = 0; - buffer->offset = 0; -} diff --git a/src/buffer.h b/src/buffer.h deleted file mode 100644 index b25c8ad..0000000 --- a/src/buffer.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef TINC_BUFFER_H -#define TINC_BUFFER_H - -typedef struct buffer_t { - char *data; - uint32_t maxlen; - uint32_t len; - uint32_t offset; -} buffer_t; - -extern void buffer_compact(buffer_t *buffer, uint32_t maxsize); -extern char *buffer_prepare(buffer_t *buffer, uint32_t size); -extern void buffer_add(buffer_t *buffer, const char *data, uint32_t size); -extern char *buffer_readline(buffer_t *buffer); -extern char *buffer_read(buffer_t *buffer, uint32_t size); -extern void buffer_clear(buffer_t *buffer); - -#endif diff --git a/src/chacha-poly1305/chacha-poly1305.c b/src/chacha-poly1305/chacha-poly1305.c deleted file mode 100644 index a74c502..0000000 --- a/src/chacha-poly1305/chacha-poly1305.c +++ /dev/null @@ -1,106 +0,0 @@ -#include "../system.h" - -#include "../cipher.h" -#include "../xalloc.h" - -#include "chacha.h" -#include "chacha-poly1305.h" -#include "poly1305.h" - -struct chacha_poly1305_ctx { - struct chacha_ctx main_ctx, header_ctx; -}; - -chacha_poly1305_ctx_t *chacha_poly1305_init(void) { - chacha_poly1305_ctx_t *ctx = xzalloc(sizeof(*ctx)); - return ctx; -} - -void chacha_poly1305_exit(chacha_poly1305_ctx_t *ctx) { - free(ctx); -} - -bool chacha_poly1305_set_key(chacha_poly1305_ctx_t *ctx, const void *vkey) { - const uint8_t *key = vkey; - chacha_keysetup(&ctx->main_ctx, key, 256); - chacha_keysetup(&ctx->header_ctx, key + 32, 256); - return true; -} - -static void put_u64(void *vp, uint64_t v) { - uint8_t *p = (uint8_t *) vp; - - p[0] = (uint8_t)(v >> 56) & 0xff; - p[1] = (uint8_t)(v >> 48) & 0xff; - p[2] = (uint8_t)(v >> 40) & 0xff; - p[3] = (uint8_t)(v >> 32) & 0xff; - p[4] = (uint8_t)(v >> 24) & 0xff; - p[5] = (uint8_t)(v >> 16) & 0xff; - p[6] = (uint8_t)(v >> 8) & 0xff; - p[7] = (uint8_t) v & 0xff; -} - -bool chacha_poly1305_encrypt(chacha_poly1305_ctx_t *ctx, uint64_t seqnr, const void *indata, size_t inlen, void *voutdata, size_t *outlen) { - uint8_t seqbuf[8]; - const uint8_t one[8] = { 1, 0, 0, 0, 0, 0, 0, 0 }; /* NB little-endian */ - uint8_t poly_key[POLY1305_KEYLEN]; - uint8_t *outdata = voutdata; - - /* - * Run ChaCha20 once to generate the Poly1305 key. The IV is the - * packet sequence number. - */ - memset(poly_key, 0, sizeof(poly_key)); - put_u64(seqbuf, seqnr); - chacha_ivsetup(&ctx->main_ctx, seqbuf, NULL); - chacha_encrypt_bytes(&ctx->main_ctx, poly_key, poly_key, sizeof(poly_key)); - - /* Set Chacha's block counter to 1 */ - chacha_ivsetup(&ctx->main_ctx, seqbuf, one); - - chacha_encrypt_bytes(&ctx->main_ctx, indata, outdata, inlen); - poly1305_auth(outdata + inlen, outdata, inlen, poly_key); - - if(outlen) { - *outlen = inlen + POLY1305_TAGLEN; - } - - return true; -} - -bool chacha_poly1305_decrypt(chacha_poly1305_ctx_t *ctx, uint64_t seqnr, const void *vindata, size_t inlen, void *outdata, size_t *outlen) { - uint8_t seqbuf[8]; - const uint8_t one[8] = { 1, 0, 0, 0, 0, 0, 0, 0 }; /* NB little-endian */ - uint8_t expected_tag[POLY1305_TAGLEN], poly_key[POLY1305_KEYLEN]; - const uint8_t *indata = vindata; - - /* - * Run ChaCha20 once to generate the Poly1305 key. The IV is the - * packet sequence number. - */ - memset(poly_key, 0, sizeof(poly_key)); - put_u64(seqbuf, seqnr); - chacha_ivsetup(&ctx->main_ctx, seqbuf, NULL); - chacha_encrypt_bytes(&ctx->main_ctx, poly_key, poly_key, sizeof(poly_key)); - - /* Set Chacha's block counter to 1 */ - chacha_ivsetup(&ctx->main_ctx, seqbuf, one); - - /* Check tag before anything else */ - inlen -= POLY1305_TAGLEN; - const uint8_t *tag = indata + inlen; - - poly1305_auth(expected_tag, indata, inlen, poly_key); - - if(memcmp(expected_tag, tag, POLY1305_TAGLEN)) { - return false; - } - - chacha_encrypt_bytes(&ctx->main_ctx, indata, outdata, inlen); - - if(outlen) { - *outlen = inlen; - } - - return true; -} diff --git a/src/chacha-poly1305/chacha-poly1305.h b/src/chacha-poly1305/chacha-poly1305.h deleted file mode 100644 index af7eaf5..0000000 --- a/src/chacha-poly1305/chacha-poly1305.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef CHACHA_POLY1305_H -#define CHACHA_POLY1305_H - -#define CHACHA_POLY1305_KEYLEN 64 - -typedef struct chacha_poly1305_ctx chacha_poly1305_ctx_t; - -extern chacha_poly1305_ctx_t *chacha_poly1305_init(void); -extern void chacha_poly1305_exit(chacha_poly1305_ctx_t *); -extern bool chacha_poly1305_set_key(chacha_poly1305_ctx_t *ctx, const void *key); - -extern bool chacha_poly1305_encrypt(chacha_poly1305_ctx_t *ctx, uint64_t seqnr, const void *indata, size_t inlen, void *outdata, size_t *outlen); -extern bool chacha_poly1305_decrypt(chacha_poly1305_ctx_t *ctx, uint64_t seqnr, const void *indata, size_t inlen, void *outdata, size_t *outlen); - -#endif //CHACHA_POLY1305_H diff --git a/src/chacha-poly1305/chacha.c b/src/chacha-poly1305/chacha.c deleted file mode 100644 index 696f44a..0000000 --- a/src/chacha-poly1305/chacha.c +++ /dev/null @@ -1,224 +0,0 @@ -/* -chacha-merged.c version 20080118 -D. J. Bernstein -Public domain. -*/ - -#include "../system.h" - -#include "chacha.h" - -typedef struct chacha_ctx chacha_ctx; - -#define U8C(v) (v##U) -#define U32C(v) (v##U) - -#define U8V(v) ((uint8_t)(v) & U8C(0xFF)) -#define U32V(v) ((uint32_t)(v) & U32C(0xFFFFFFFF)) - -#define ROTL32(v, n) \ - (U32V((v) << (n)) | ((v) >> (32 - (n)))) - -#define U8TO32_LITTLE(p) \ - (((uint32_t)((p)[0]) ) | \ - ((uint32_t)((p)[1]) << 8) | \ - ((uint32_t)((p)[2]) << 16) | \ - ((uint32_t)((p)[3]) << 24)) - -#define U32TO8_LITTLE(p, v) \ - do { \ - (p)[0] = U8V((v) ); \ - (p)[1] = U8V((v) >> 8); \ - (p)[2] = U8V((v) >> 16); \ - (p)[3] = U8V((v) >> 24); \ - } while (0) - -#define ROTATE(v,c) (ROTL32(v,c)) -#define XOR(v,w) ((v) ^ (w)) -#define PLUS(v,w) (U32V((v) + (w))) -#define PLUSONE(v) (PLUS((v),1)) - -#define QUARTERROUND(a,b,c,d) \ - a = PLUS(a,b); d = ROTATE(XOR(d,a),16); \ - c = PLUS(c,d); b = ROTATE(XOR(b,c),12); \ - a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \ - c = PLUS(c,d); b = ROTATE(XOR(b,c), 7); - -static const char sigma[16] = "expand 32-byte k"; -static const char tau[16] = "expand 16-byte k"; - -void chacha_keysetup(chacha_ctx *x, const uint8_t *k, uint32_t kbits) { - const char *constants; - - x->input[4] = U8TO32_LITTLE(k + 0); - x->input[5] = U8TO32_LITTLE(k + 4); - x->input[6] = U8TO32_LITTLE(k + 8); - x->input[7] = U8TO32_LITTLE(k + 12); - - if(kbits == 256) { /* recommended */ - k += 16; - constants = sigma; - } else { /* kbits == 128 */ - constants = tau; - } - - x->input[8] = U8TO32_LITTLE(k + 0); - x->input[9] = U8TO32_LITTLE(k + 4); - x->input[10] = U8TO32_LITTLE(k + 8); - x->input[11] = U8TO32_LITTLE(k + 12); - x->input[0] = U8TO32_LITTLE(constants + 0); - x->input[1] = U8TO32_LITTLE(constants + 4); - x->input[2] = U8TO32_LITTLE(constants + 8); - x->input[3] = U8TO32_LITTLE(constants + 12); -} - -void chacha_ivsetup(chacha_ctx *x, const uint8_t *iv, const uint8_t *counter) { - x->input[12] = counter == NULL ? 0 : U8TO32_LITTLE(counter + 0); - x->input[13] = counter == NULL ? 0 : U8TO32_LITTLE(counter + 4); - x->input[14] = U8TO32_LITTLE(iv + 0); - x->input[15] = U8TO32_LITTLE(iv + 4); -} - -void -chacha_encrypt_bytes(chacha_ctx *x, const uint8_t *m, uint8_t *c, uint32_t bytes) { - uint32_t x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15; - uint32_t j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15; - uint8_t *ctarget = NULL; - uint8_t tmp[64]; - uint32_t i; - - if(!bytes) { - return; - } - - j0 = x->input[0]; - j1 = x->input[1]; - j2 = x->input[2]; - j3 = x->input[3]; - j4 = x->input[4]; - j5 = x->input[5]; - j6 = x->input[6]; - j7 = x->input[7]; - j8 = x->input[8]; - j9 = x->input[9]; - j10 = x->input[10]; - j11 = x->input[11]; - j12 = x->input[12]; - j13 = x->input[13]; - j14 = x->input[14]; - j15 = x->input[15]; - - for(;;) { - if(bytes < 64) { - for(i = 0; i < bytes; ++i) { - tmp[i] = m[i]; - } - - m = tmp; - ctarget = c; - c = tmp; - } - - x0 = j0; - x1 = j1; - x2 = j2; - x3 = j3; - x4 = j4; - x5 = j5; - x6 = j6; - x7 = j7; - x8 = j8; - x9 = j9; - x10 = j10; - x11 = j11; - x12 = j12; - x13 = j13; - x14 = j14; - x15 = j15; - - for(i = 20; i > 0; i -= 2) { - QUARTERROUND(x0, x4, x8, x12) - QUARTERROUND(x1, x5, x9, x13) - QUARTERROUND(x2, x6, x10, x14) - QUARTERROUND(x3, x7, x11, x15) - QUARTERROUND(x0, x5, x10, x15) - QUARTERROUND(x1, x6, x11, x12) - QUARTERROUND(x2, x7, x8, x13) - QUARTERROUND(x3, x4, x9, x14) - } - - x0 = PLUS(x0, j0); - x1 = PLUS(x1, j1); - x2 = PLUS(x2, j2); - x3 = PLUS(x3, j3); - x4 = PLUS(x4, j4); - x5 = PLUS(x5, j5); - x6 = PLUS(x6, j6); - x7 = PLUS(x7, j7); - x8 = PLUS(x8, j8); - x9 = PLUS(x9, j9); - x10 = PLUS(x10, j10); - x11 = PLUS(x11, j11); - x12 = PLUS(x12, j12); - x13 = PLUS(x13, j13); - x14 = PLUS(x14, j14); - x15 = PLUS(x15, j15); - - x0 = XOR(x0, U8TO32_LITTLE(m + 0)); - x1 = XOR(x1, U8TO32_LITTLE(m + 4)); - x2 = XOR(x2, U8TO32_LITTLE(m + 8)); - x3 = XOR(x3, U8TO32_LITTLE(m + 12)); - x4 = XOR(x4, U8TO32_LITTLE(m + 16)); - x5 = XOR(x5, U8TO32_LITTLE(m + 20)); - x6 = XOR(x6, U8TO32_LITTLE(m + 24)); - x7 = XOR(x7, U8TO32_LITTLE(m + 28)); - x8 = XOR(x8, U8TO32_LITTLE(m + 32)); - x9 = XOR(x9, U8TO32_LITTLE(m + 36)); - x10 = XOR(x10, U8TO32_LITTLE(m + 40)); - x11 = XOR(x11, U8TO32_LITTLE(m + 44)); - x12 = XOR(x12, U8TO32_LITTLE(m + 48)); - x13 = XOR(x13, U8TO32_LITTLE(m + 52)); - x14 = XOR(x14, U8TO32_LITTLE(m + 56)); - x15 = XOR(x15, U8TO32_LITTLE(m + 60)); - - j12 = PLUSONE(j12); - - if(!j12) { - j13 = PLUSONE(j13); - /* stopping at 2^70 bytes per nonce is user's responsibility */ - } - - U32TO8_LITTLE(c + 0, x0); - U32TO8_LITTLE(c + 4, x1); - U32TO8_LITTLE(c + 8, x2); - U32TO8_LITTLE(c + 12, x3); - U32TO8_LITTLE(c + 16, x4); - U32TO8_LITTLE(c + 20, x5); - U32TO8_LITTLE(c + 24, x6); - U32TO8_LITTLE(c + 28, x7); - U32TO8_LITTLE(c + 32, x8); - U32TO8_LITTLE(c + 36, x9); - U32TO8_LITTLE(c + 40, x10); - U32TO8_LITTLE(c + 44, x11); - U32TO8_LITTLE(c + 48, x12); - U32TO8_LITTLE(c + 52, x13); - U32TO8_LITTLE(c + 56, x14); - U32TO8_LITTLE(c + 60, x15); - - if(bytes <= 64) { - if(bytes < 64) { - for(i = 0; i < bytes; ++i) { - ctarget[i] = c[i]; - } - } - - x->input[12] = j12; - x->input[13] = j13; - return; - } - - bytes -= 64; - c += 64; - m += 64; - } -} diff --git a/src/chacha-poly1305/chacha.h b/src/chacha-poly1305/chacha.h deleted file mode 100644 index 103c3d8..0000000 --- a/src/chacha-poly1305/chacha.h +++ /dev/null @@ -1,24 +0,0 @@ -/* -chacha-merged.c version 20080118 -D. J. Bernstein -Public domain. -*/ - -#ifndef CHACHA_H -#define CHACHA_H - -struct chacha_ctx { - uint32_t input[16]; -}; - -#define CHACHA_MINKEYLEN 16 -#define CHACHA_NONCELEN 8 -#define CHACHA_CTRLEN 8 -#define CHACHA_STATELEN (CHACHA_NONCELEN+CHACHA_CTRLEN) -#define CHACHA_BLOCKLEN 64 - -void chacha_keysetup(struct chacha_ctx *x, const uint8_t *k, uint32_t kbits); -void chacha_ivsetup(struct chacha_ctx *x, const uint8_t *iv, const uint8_t *ctr); -void chacha_encrypt_bytes(struct chacha_ctx *x, const uint8_t *m, uint8_t *c, uint32_t bytes); - -#endif /* CHACHA_H */ diff --git a/src/chacha-poly1305/poly1305.c b/src/chacha-poly1305/poly1305.c deleted file mode 100644 index 4d99b8c..0000000 --- a/src/chacha-poly1305/poly1305.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Public Domain poly1305 from Andrew Moon - * poly1305-donna-unrolled.c from https://github.com/floodyberry/poly1305-donna - */ - -#include "../system.h" - -#include "poly1305.h" - -#define mul32x32_64(a,b) ((uint64_t)(a) * (b)) - -#define U8TO32_LE(p) \ - (((uint32_t)((p)[0])) | \ - ((uint32_t)((p)[1]) << 8) | \ - ((uint32_t)((p)[2]) << 16) | \ - ((uint32_t)((p)[3]) << 24)) - -#define U32TO8_LE(p, v) \ - do { \ - (p)[0] = (uint8_t)((v)); \ - (p)[1] = (uint8_t)((v) >> 8); \ - (p)[2] = (uint8_t)((v) >> 16); \ - (p)[3] = (uint8_t)((v) >> 24); \ - } while (0) - -void -poly1305_auth(unsigned char out[POLY1305_TAGLEN], const unsigned char *m, size_t inlen, const unsigned char key[POLY1305_KEYLEN]) { - uint32_t t0, t1, t2, t3; - uint32_t h0, h1, h2, h3, h4; - uint32_t r0, r1, r2, r3, r4; - uint32_t s1, s2, s3, s4; - uint32_t b, nb; - size_t j; - uint64_t t[5]; - uint64_t f0, f1, f2, f3; - uint32_t g0, g1, g2, g3, g4; - uint64_t c; - unsigned char mp[16]; - - /* clamp key */ - t0 = U8TO32_LE(key + 0); - t1 = U8TO32_LE(key + 4); - t2 = U8TO32_LE(key + 8); - t3 = U8TO32_LE(key + 12); - - /* precompute multipliers */ - r0 = t0 & 0x3ffffff; - t0 >>= 26; - t0 |= t1 << 6; - r1 = t0 & 0x3ffff03; - t1 >>= 20; - t1 |= t2 << 12; - r2 = t1 & 0x3ffc0ff; - t2 >>= 14; - t2 |= t3 << 18; - r3 = t2 & 0x3f03fff; - t3 >>= 8; - r4 = t3 & 0x00fffff; - - s1 = r1 * 5; - s2 = r2 * 5; - s3 = r3 * 5; - s4 = r4 * 5; - - /* init state */ - h0 = 0; - h1 = 0; - h2 = 0; - h3 = 0; - h4 = 0; - - /* full blocks */ - if(inlen < 16) { - goto poly1305_donna_atmost15bytes; - } - -poly1305_donna_16bytes: - m += 16; - inlen -= 16; - - t0 = U8TO32_LE(m - 16); - t1 = U8TO32_LE(m - 12); - t2 = U8TO32_LE(m - 8); - t3 = U8TO32_LE(m - 4); - - h0 += t0 & 0x3ffffff; - h1 += ((((uint64_t) t1 << 32) | t0) >> 26) & 0x3ffffff; - h2 += ((((uint64_t) t2 << 32) | t1) >> 20) & 0x3ffffff; - h3 += ((((uint64_t) t3 << 32) | t2) >> 14) & 0x3ffffff; - h4 += (t3 >> 8) | (1 << 24); - -poly1305_donna_mul: - t[0] = mul32x32_64(h0, r0) + mul32x32_64(h1, s4) + mul32x32_64(h2, s3) + mul32x32_64(h3, s2) + mul32x32_64(h4, s1); - t[1] = mul32x32_64(h0, r1) + mul32x32_64(h1, r0) + mul32x32_64(h2, s4) + mul32x32_64(h3, s3) + mul32x32_64(h4, s2); - t[2] = mul32x32_64(h0, r2) + mul32x32_64(h1, r1) + mul32x32_64(h2, r0) + mul32x32_64(h3, s4) + mul32x32_64(h4, s3); - t[3] = mul32x32_64(h0, r3) + mul32x32_64(h1, r2) + mul32x32_64(h2, r1) + mul32x32_64(h3, r0) + mul32x32_64(h4, s4); - t[4] = mul32x32_64(h0, r4) + mul32x32_64(h1, r3) + mul32x32_64(h2, r2) + mul32x32_64(h3, r1) + mul32x32_64(h4, r0); - - h0 = (uint32_t) t[0] & 0x3ffffff; - c = (t[0] >> 26); - t[1] += c; - h1 = (uint32_t) t[1] & 0x3ffffff; - b = (uint32_t)(t[1] >> 26); - t[2] += b; - h2 = (uint32_t) t[2] & 0x3ffffff; - b = (uint32_t)(t[2] >> 26); - t[3] += b; - h3 = (uint32_t) t[3] & 0x3ffffff; - b = (uint32_t)(t[3] >> 26); - t[4] += b; - h4 = (uint32_t) t[4] & 0x3ffffff; - b = (uint32_t)(t[4] >> 26); - h0 += b * 5; - - if(inlen >= 16) { - goto poly1305_donna_16bytes; - } - - /* final bytes */ -poly1305_donna_atmost15bytes: - - if(!inlen) { - goto poly1305_donna_finish; - } - - for(j = 0; j < inlen; j++) { - mp[j] = m[j]; - } - - mp[j++] = 1; - - for(; j < 16; j++) { - mp[j] = 0; - } - - inlen = 0; - - t0 = U8TO32_LE(mp + 0); - t1 = U8TO32_LE(mp + 4); - t2 = U8TO32_LE(mp + 8); - t3 = U8TO32_LE(mp + 12); - - h0 += t0 & 0x3ffffff; - h1 += ((((uint64_t) t1 << 32) | t0) >> 26) & 0x3ffffff; - h2 += ((((uint64_t) t2 << 32) | t1) >> 20) & 0x3ffffff; - h3 += ((((uint64_t) t3 << 32) | t2) >> 14) & 0x3ffffff; - h4 += (t3 >> 8); - - goto poly1305_donna_mul; - -poly1305_donna_finish: - b = h0 >> 26; - h0 = h0 & 0x3ffffff; - h1 += b; - b = h1 >> 26; - h1 = h1 & 0x3ffffff; - h2 += b; - b = h2 >> 26; - h2 = h2 & 0x3ffffff; - h3 += b; - b = h3 >> 26; - h3 = h3 & 0x3ffffff; - h4 += b; - b = h4 >> 26; - h4 = h4 & 0x3ffffff; - h0 += b * 5; - b = h0 >> 26; - h0 = h0 & 0x3ffffff; - h1 += b; - - g0 = h0 + 5; - b = g0 >> 26; - g0 &= 0x3ffffff; - g1 = h1 + b; - b = g1 >> 26; - g1 &= 0x3ffffff; - g2 = h2 + b; - b = g2 >> 26; - g2 &= 0x3ffffff; - g3 = h3 + b; - b = g3 >> 26; - g3 &= 0x3ffffff; - g4 = h4 + b - (1 << 26); - - b = (g4 >> 31) - 1; - nb = ~b; - h0 = (h0 & nb) | (g0 & b); - h1 = (h1 & nb) | (g1 & b); - h2 = (h2 & nb) | (g2 & b); - h3 = (h3 & nb) | (g3 & b); - h4 = (h4 & nb) | (g4 & b); - - f0 = ((h0) | (h1 << 26)) + (uint64_t) U8TO32_LE(&key[16]); - f1 = ((h1 >> 6) | (h2 << 20)) + (uint64_t) U8TO32_LE(&key[20]); - f2 = ((h2 >> 12) | (h3 << 14)) + (uint64_t) U8TO32_LE(&key[24]); - f3 = ((h3 >> 18) | (h4 << 8)) + (uint64_t) U8TO32_LE(&key[28]); - - U32TO8_LE(&out[0], f0); - f1 += (f0 >> 32); - U32TO8_LE(&out[4], f1); - f2 += (f1 >> 32); - U32TO8_LE(&out[8], f2); - f3 += (f2 >> 32); - U32TO8_LE(&out[12], f3); -} diff --git a/src/chacha-poly1305/poly1305.h b/src/chacha-poly1305/poly1305.h deleted file mode 100644 index 4ece415..0000000 --- a/src/chacha-poly1305/poly1305.h +++ /dev/null @@ -1,16 +0,0 @@ -/* $OpenBSD: poly1305.h,v 1.2 2013/12/19 22:57:13 djm Exp $ */ - -/* - * Public Domain poly1305 from Andrew Moon - * poly1305-donna-unrolled.c from https://github.com/floodyberry/poly1305-donna - */ - -#ifndef POLY1305_H -#define POLY1305_H - -#define POLY1305_KEYLEN 32 -#define POLY1305_TAGLEN 16 - -void poly1305_auth(uint8_t out[POLY1305_TAGLEN], const uint8_t *m, size_t inlen, const uint8_t key[POLY1305_KEYLEN]); - -#endif /* POLY1305_H */ diff --git a/src/cipher.h b/src/cipher.h deleted file mode 100644 index 2845be8..0000000 --- a/src/cipher.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef TINC_CIPHER_H -#define TINC_CIPHER_H - -/* - cipher.h -- header file cipher.c - Copyright (C) 2007-2016 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#define CIPHER_MAX_BLOCK_SIZE 32 -#define CIPHER_MAX_IV_SIZE 16 -#define CIPHER_MAX_KEY_SIZE 32 - -#ifndef DISABLE_LEGACY - -typedef struct cipher cipher_t; - -extern cipher_t *cipher_open_by_name(const char *name) __attribute__((__malloc__)); -extern cipher_t *cipher_open_by_nid(int nid) __attribute__((__malloc__)); -extern void cipher_close(cipher_t *cipher); -extern size_t cipher_keylength(const cipher_t *cipher); -extern size_t cipher_blocksize(const cipher_t *cipher); -extern uint64_t cipher_budget(const cipher_t *cipher); -extern bool cipher_set_key(cipher_t *cipher, void *key, bool encrypt) __attribute__((__warn_unused_result__)); -extern bool cipher_set_key_from_rsa(cipher_t *cipher, void *rsa, size_t len, bool encrypt) __attribute__((__warn_unused_result__)); -extern bool cipher_encrypt(cipher_t *cipher, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) __attribute__((__warn_unused_result__)); -extern bool cipher_decrypt(cipher_t *cipher, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) __attribute__((__warn_unused_result__)); -extern int cipher_get_nid(const cipher_t *cipher); -extern bool cipher_active(const cipher_t *cipher); - -#endif - -#endif diff --git a/src/conf.c b/src/conf.c index a33bdfe..3f81877 100644 --- a/src/conf.c +++ b/src/conf.c @@ -1,11 +1,10 @@ /* conf.c -- configuration code - Copyright (C) 1998 Robert van der Meulen + Copyright (C) 1998 Robert van der Meulen 1998-2005 Ivo Timmermans - 2000 Cris van Pelt + 2000-2014 Guus Sliepen 2010-2011 Julien Muchembled - 2000-2015 Guus Sliepen - 2013 Florent Clairambault + 2000 Cris van Pelt This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,23 +23,25 @@ #include "system.h" -#include "splay_tree.h" +#include "avl_tree.h" #include "connection.h" #include "conf.h" #include "list.h" #include "logger.h" -#include "names.h" -#include "netutl.h" /* for str2address */ +#include "netutl.h" /* for str2address */ #include "protocol.h" -#include "utils.h" /* for cp */ +#include "utils.h" /* for cp */ #include "xalloc.h" -splay_tree_t *config_tree; +avl_tree_t *config_tree; -int pinginterval = 0; /* seconds between pings */ -int pingtimeout = 0; /* seconds to wait for response */ +int pinginterval = 0; /* seconds between pings */ +int pingtimeout = 0; /* seconds to wait for response */ +char *confbase = NULL; /* directory in which all config files are */ +char *netname = NULL; /* name of the vpn network */ list_t *cmdline_conf = NULL; /* global/host configuration values given at the command line */ + static int config_compare(const config_t *a, const config_t *b) { int result; @@ -66,17 +67,17 @@ static int config_compare(const config_t *a, const config_t *b) { } } -void init_configuration(splay_tree_t **config_tree) { - *config_tree = splay_alloc_tree((splay_compare_t) config_compare, (splay_action_t) free_config); +void init_configuration(avl_tree_t **config_tree) { + *config_tree = avl_alloc_tree((avl_compare_t) config_compare, (avl_action_t) free_config); } -void exit_configuration(splay_tree_t **config_tree) { - splay_delete_tree(*config_tree); +void exit_configuration(avl_tree_t **config_tree) { + avl_delete_tree(*config_tree); *config_tree = NULL; } config_t *new_config(void) { - return xzalloc(sizeof(config_t)); + return xmalloc_and_zero(sizeof(config_t)); } void free_config(config_t *cfg) { @@ -86,18 +87,18 @@ void free_config(config_t *cfg) { free(cfg); } -void config_add(splay_tree_t *config_tree, config_t *cfg) { - splay_insert(config_tree, cfg); +void config_add(avl_tree_t *config_tree, config_t *cfg) { + avl_insert(config_tree, cfg); } -config_t *lookup_config(splay_tree_t *config_tree, char *variable) { +config_t *lookup_config(const avl_tree_t *config_tree, char *variable) { config_t cfg, *found; cfg.variable = variable; cfg.file = NULL; cfg.line = 0; - found = splay_search_closest_greater(config_tree, &cfg); + found = avl_search_closest_greater(config_tree, &cfg); if(!found) { return NULL; @@ -110,11 +111,11 @@ config_t *lookup_config(splay_tree_t *config_tree, char *variable) { return found; } -config_t *lookup_config_next(splay_tree_t *config_tree, const config_t *cfg) { - splay_node_t *node; +config_t *lookup_config_next(const avl_tree_t *config_tree, const config_t *cfg) { + avl_node_t *node; config_t *found; - node = splay_search_node(config_tree, cfg); + node = avl_search_node(config_tree, cfg); if(node) { if(node->next) { @@ -142,7 +143,7 @@ bool get_config_bool(const config_t *cfg, bool *result) { return true; } - logger(DEBUG_ALWAYS, LOG_ERR, "\"yes\" or \"no\" expected for configuration variable %s in %s line %d", + logger(LOG_ERR, "\"yes\" or \"no\" expected for configuration variable %s in %s line %d", cfg->variable, cfg->file, cfg->line); return false; @@ -157,7 +158,7 @@ bool get_config_int(const config_t *cfg, int *result) { return true; } - logger(DEBUG_ALWAYS, LOG_ERR, "Integer expected for configuration variable %s in %s line %d", + logger(LOG_ERR, "Integer expected for configuration variable %s in %s line %d", cfg->variable, cfg->file, cfg->line); return false; @@ -187,7 +188,7 @@ bool get_config_address(const config_t *cfg, struct addrinfo **result) { return true; } - logger(DEBUG_ALWAYS, LOG_ERR, "Hostname or IP address expected for configuration variable %s in %s line %d", + logger(LOG_ERR, "Hostname or IP address expected for configuration variable %s in %s line %d", cfg->variable, cfg->file, cfg->line); return false; @@ -201,7 +202,7 @@ bool get_config_subnet(const config_t *cfg, subnet_t **result) { } if(!str2net(&subnet, cfg->value)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Subnet expected for configuration variable %s in %s line %d", + logger(LOG_ERR, "Subnet expected for configuration variable %s in %s line %d", cfg->variable, cfg->file, cfg->line); return false; } @@ -209,10 +210,10 @@ bool get_config_subnet(const config_t *cfg, subnet_t **result) { /* Teach newbies what subnets are... */ if(((subnet.type == SUBNET_IPV4) - && !maskcheck(&subnet.net.ipv4.address, subnet.net.ipv4.prefixlength, sizeof(subnet.net.ipv4.address))) + && !maskcheck(&subnet.net.ipv4.address, subnet.net.ipv4.prefixlength, sizeof(ipv4_t))) || ((subnet.type == SUBNET_IPV6) - && !maskcheck(&subnet.net.ipv6.address, subnet.net.ipv6.prefixlength, sizeof(subnet.net.ipv6.address)))) { - logger(DEBUG_ALWAYS, LOG_ERR, "Network address and prefix length do not match for configuration variable %s in %s line %d", + && !maskcheck(&subnet.net.ipv6.address, subnet.net.ipv6.prefixlength, sizeof(ipv6_t)))) { + logger(LOG_ERR, "Network address and prefix length do not match for configuration variable %s in %s line %d", cfg->variable, cfg->file, cfg->line); return false; } @@ -245,10 +246,9 @@ static char *readline(FILE *fp, char *buf, size_t buflen) { return buf; } - /* kill newline and carriage return if necessary */ - *newline = '\0'; + *newline = '\0'; /* kill newline */ - if(newline > p && newline[-1] == '\r') { + if(newline > p && newline[-1] == '\r') { /* and carriage return if necessary */ newline[-1] = '\0'; } @@ -282,10 +282,10 @@ config_t *parse_config_line(char *line, const char *fname, int lineno) { const char err[] = "No value for variable"; if(fname) - logger(DEBUG_ALWAYS, LOG_ERR, "%s `%s' on line %d while reading config file %s", + logger(LOG_ERR, "%s `%s' on line %d while reading config file %s", err, variable, lineno, fname); else - logger(DEBUG_ALWAYS, LOG_ERR, "%s `%s' in command line option %d", + logger(LOG_ERR, "%s `%s' in command line option %d", err, variable, lineno); return NULL; @@ -304,7 +304,7 @@ config_t *parse_config_line(char *line, const char *fname, int lineno) { Parse a configuration file and put the results in the configuration tree starting at *base. */ -bool read_config_file(splay_tree_t *config_tree, const char *fname, bool verbose) { +bool read_config_file(avl_tree_t *config_tree, const char *fname) { FILE *fp; char buffer[MAX_STRING_SIZE]; char *line; @@ -316,7 +316,7 @@ bool read_config_file(splay_tree_t *config_tree, const char *fname, bool verbose fp = fopen(fname, "r"); if(!fp) { - logger(verbose ? DEBUG_ALWAYS : DEBUG_CONNECTIONS, LOG_ERR, "Cannot open config file %s: %s", fname, strerror(errno)); + logger(LOG_ERR, "Cannot open config file %s: %s", fname, strerror(errno)); return false; } @@ -364,12 +364,11 @@ bool read_config_file(splay_tree_t *config_tree, const char *fname, bool verbose return result; } -void read_config_options(splay_tree_t *config_tree, const char *prefix) { +void read_config_options(avl_tree_t *config_tree, const char *prefix) { size_t prefix_len = prefix ? strlen(prefix) : 0; for(const list_node_t *node = cmdline_conf->tail; node; node = node->prev) { const config_t *cfg = node->data; - config_t *new; if(!prefix) { if(strchr(cfg->variable, '.')) { @@ -382,7 +381,7 @@ void read_config_options(splay_tree_t *config_tree, const char *prefix) { } } - new = new_config(); + config_t *new = new_config(); if(prefix) { new->variable = xstrdup(cfg->variable + prefix_len + 1); @@ -404,14 +403,14 @@ bool read_server_config(void) { read_config_options(config_tree, NULL); - snprintf(fname, sizeof(fname), "%s" SLASH "tinc.conf", confbase); + snprintf(fname, sizeof(fname), "%s/tinc.conf", confbase); errno = 0; - x = read_config_file(config_tree, fname, true); + x = read_config_file(config_tree, fname); // We will try to read the conf files in the "conf.d" dir if(x) { char dname[PATH_MAX]; - snprintf(dname, sizeof(dname), "%s" SLASH "conf.d", confbase); + snprintf(dname, sizeof(dname), "%s/conf.d", confbase); DIR *dir = opendir(dname); // If we can find this dir @@ -424,12 +423,12 @@ bool read_server_config(void) { // And we try to read the ones that end with ".conf" if(l > 5 && !strcmp(".conf", & ep->d_name[ l - 5 ])) { - if((size_t)snprintf(fname, sizeof(fname), "%s" SLASH "%s", dname, ep->d_name) >= sizeof(fname)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Pathname too long: %s/%s", dname, ep->d_name); + if((size_t)snprintf(fname, sizeof(fname), "%s/%s", dname, ep->d_name) >= sizeof(fname)) { + logger(LOG_ERR, "Pathname too long: %s/%s", dname, ep->d_name); return false; } - x = read_config_file(config_tree, fname, true); + x = read_config_file(config_tree, fname); } } @@ -438,32 +437,166 @@ bool read_server_config(void) { } if(!x && errno) { - logger(DEBUG_ALWAYS, LOG_ERR, "Failed to read `%s': %s", fname, strerror(errno)); + logger(LOG_ERR, "Failed to read `%s': %s", fname, strerror(errno)); } return x; } -bool read_host_config(splay_tree_t *config_tree, const char *name, bool verbose) { - read_config_options(config_tree, name); - +bool read_connection_config(connection_t *c) { char fname[PATH_MAX]; - snprintf(fname, sizeof(fname), "%s" SLASH "hosts" SLASH "%s", confbase, name); - return read_config_file(config_tree, fname, verbose); + bool x; + + read_config_options(c->config_tree, c->name); + + snprintf(fname, sizeof(fname), "%s/hosts/%s", confbase, c->name); + x = read_config_file(c->config_tree, fname); + + return x; } -bool append_config_file(const char *name, const char *key, const char *value) { - char fname[PATH_MAX]; - snprintf(fname, sizeof(fname), "%s" SLASH "hosts" SLASH "%s", confbase, name); +static void disable_old_keys(const char *filename) { + char tmpfile[PATH_MAX] = ""; + char buf[1024]; + bool disabled = false; + FILE *r, *w; - FILE *fp = fopen(fname, "a"); + r = fopen(filename, "r"); - if(!fp) { - logger(DEBUG_ALWAYS, LOG_DEBUG, "Cannot open config file %s: %s", fname, strerror(errno)); - return false; + if(!r) { + return; } - fprintf(fp, "\n# The following line was automatically added by tinc\n%s = %s\n", key, value); - fclose(fp); - return true; + int len = snprintf(tmpfile, sizeof(tmpfile), "%s.tmp", filename); + + if(len < 0 || len >= PATH_MAX) { + fprintf(stderr, "Pathname too long: %s.tmp\n", filename); + w = NULL; + } else { + w = fopen(tmpfile, "w"); + } + + while(fgets(buf, sizeof(buf), r)) { + if(!strncmp(buf, "-----BEGIN RSA", 14)) { + buf[11] = 'O'; + buf[12] = 'L'; + buf[13] = 'D'; + disabled = true; + } else if(!strncmp(buf, "-----END RSA", 12)) { + buf[ 9] = 'O'; + buf[10] = 'L'; + buf[11] = 'D'; + disabled = true; + } + + if(w && fputs(buf, w) < 0) { + disabled = false; + break; + } + } + + if(w) { + fclose(w); + } + + fclose(r); + + if(!w && disabled) { + fprintf(stderr, "Warning: old key(s) found, remove them by hand!\n"); + return; + } + + if(disabled) { +#ifdef HAVE_MINGW + // We cannot atomically replace files on Windows. + char bakfile[PATH_MAX] = ""; + snprintf(bakfile, sizeof(bakfile), "%s.bak", filename); + + if(rename(filename, bakfile) || rename(tmpfile, filename)) { + rename(bakfile, filename); +#else + + if(rename(tmpfile, filename)) { +#endif + fprintf(stderr, "Warning: old key(s) found, remove them by hand!\n"); + } else { +#ifdef HAVE_MINGW + unlink(bakfile); +#endif + fprintf(stderr, "Warning: old key(s) found and disabled.\n"); + } + } + + unlink(tmpfile); } + +FILE *ask_and_open(const char *filename, const char *what) { + FILE *r; + char directory[PATH_MAX]; + char line[PATH_MAX]; + char abspath[PATH_MAX]; + const char *fn; + + /* Check stdin and stdout */ + if(!isatty(0) || !isatty(1)) { + /* Argh, they are running us from a script or something. Write + the files to the current directory and let them burn in hell + for ever. */ + fn = filename; + } else { + /* Ask for a file and/or directory name. */ + fprintf(stdout, "Please enter a file to save %s to [%s]: ", + what, filename); + fflush(stdout); + + fn = readline(stdin, line, sizeof(line)); + + if(!fn) { + fprintf(stderr, "Error while reading stdin: %s\n", + strerror(errno)); + return NULL; + } + + if(!strlen(fn)) + /* User just pressed enter. */ + { + fn = filename; + } + } + +#ifdef HAVE_MINGW + + if(fn[0] != '\\' && fn[0] != '/' && !strchr(fn, ':')) { +#else + + if(fn[0] != '/') { +#endif + /* The directory is a relative path or a filename. */ + getcwd(directory, sizeof(directory)); + + if((size_t)snprintf(abspath, sizeof(abspath), "%s/%s", directory, fn) >= sizeof(abspath)) { + fprintf(stderr, "Pathname too long: %s/%s\n", directory, fn); + return NULL; + } + + fn = abspath; + } + + umask(0077); /* Disallow everything for group and other */ + + disable_old_keys(fn); + + /* Open it first to keep the inode busy */ + + r = fopen(fn, "a"); + + if(!r) { + fprintf(stderr, "Error opening file `%s': %s\n", + fn, strerror(errno)); + return NULL; + } + + return r; +} + + diff --git a/src/conf.h b/src/conf.h index 8457124..770ada7 100644 --- a/src/conf.h +++ b/src/conf.h @@ -4,7 +4,7 @@ /* conf.h -- header for conf.c Copyright (C) 1998-2005 Ivo Timmermans - 2000-2013 Guus Sliepen + 2000-2012 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,9 +21,8 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "avl_tree.h" #include "list.h" -#include "splay_tree.h" -#include "subnet.h" typedef struct config_t { char *variable; @@ -32,33 +31,37 @@ typedef struct config_t { int line; } config_t; +#include "subnet.h" -extern splay_tree_t *config_tree; +extern avl_tree_t *config_tree; extern int pinginterval; extern int pingtimeout; extern int maxtimeout; +extern int mintimeout; extern bool bypass_security; +extern char *confbase; +extern char *netname; extern list_t *cmdline_conf; -extern void init_configuration(splay_tree_t **config_tree); -extern void exit_configuration(splay_tree_t **config_tree); +extern void init_configuration(avl_tree_t **config_tree); +extern void exit_configuration(avl_tree_t **config_tree); extern config_t *new_config(void) __attribute__((__malloc__)); -extern void free_config(config_t *config); -extern void config_add(splay_tree_t *config_tree, config_t *config); -extern config_t *lookup_config(splay_tree_t *config_tree, char *variable); -extern config_t *lookup_config_next(splay_tree_t *config_tree, const config_t *config); -extern bool get_config_bool(const config_t *config, bool *result); -extern bool get_config_int(const config_t *config, int *result); -extern bool get_config_string(const config_t *config, char **result); -extern bool get_config_address(const config_t *config, struct addrinfo **result); -extern bool get_config_subnet(const config_t *config, struct subnet_t **result); +extern void free_config(config_t *cfg); +extern void config_add(avl_tree_t *config_tree, config_t *cfg); +extern config_t *lookup_config(const avl_tree_t *config_tree, char *variable); +extern config_t *lookup_config_next(const avl_tree_t *config_tree, const config_t *cfg); +extern bool get_config_bool(const config_t *cfg, bool *result); +extern bool get_config_int(const config_t *cfg, int *result); +extern bool get_config_string(const config_t *cfg, char **result); +extern bool get_config_address(const config_t *cfg, struct addrinfo **result); +extern bool get_config_subnet(const config_t *cfg, struct subnet_t **result); extern config_t *parse_config_line(char *line, const char *fname, int lineno); -extern bool read_config_file(splay_tree_t *config_tree, const char *filename, bool verbose); -extern void read_config_options(splay_tree_t *config_tree, const char *prefix); +extern bool read_config_file(avl_tree_t *config_tree, const char *fname); +extern void read_config_options(avl_tree_t *config_tree, const char *prefix); extern bool read_server_config(void); -extern bool read_host_config(splay_tree_t *config_tree, const char *name, bool verbose); -extern bool append_config_file(const char *name, const char *key, const char *value); +extern bool read_connection_config(struct connection_t *c); +extern FILE *ask_and_open(const char *fname, const char *what); #endif diff --git a/src/connection.c b/src/connection.c index 1c638a4..d137af1 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1,6 +1,6 @@ /* connection.c -- connection list management - Copyright (C) 2000-2013 Guus Sliepen , + Copyright (C) 2000-2016 Guus Sliepen , 2000-2005 Ivo Timmermans 2008 Max Rijevski @@ -21,68 +21,100 @@ #include "system.h" -#include "list.h" -#include "cipher.h" +#include "avl_tree.h" #include "conf.h" -#include "control_common.h" -#include "list.h" #include "logger.h" -#include "net.h" -#include "rsa.h" #include "subnet.h" #include "utils.h" #include "xalloc.h" -list_t *connection_list; +avl_tree_t *connection_tree; /* Meta connections */ connection_t *everyone; +static int connection_compare(const connection_t *a, const connection_t *b) { + return a < b ? -1 : a == b ? 0 : 1; +} + void init_connections(void) { - connection_list = list_alloc((list_action_t) free_connection); + connection_tree = avl_alloc_tree((avl_compare_t) connection_compare, (avl_action_t) free_connection); everyone = new_connection(); everyone->name = xstrdup("everyone"); everyone->hostname = xstrdup("BROADCAST"); } void exit_connections(void) { - list_delete_list(connection_list); + avl_delete_tree(connection_tree); free_connection(everyone); } connection_t *new_connection(void) { - return xzalloc(sizeof(connection_t)); + connection_t *c; + + c = xmalloc_and_zero(sizeof(connection_t)); + + if(!c) { + return NULL; + } + + gettimeofday(&c->start, NULL); + + return c; +} + +void free_connection_partially(connection_t *c) { + free(c->inkey); + free(c->outkey); + free(c->mychallenge); + free(c->hischallenge); + free(c->outbuf); + + c->inkey = NULL; + c->outkey = NULL; + c->mychallenge = NULL; + c->hischallenge = NULL; + c->outbuf = NULL; + + c->status.pinged = false; + c->status.active = false; + c->status.connecting = false; + c->status.timeout = false; + c->status.encryptout = false; + c->status.decryptin = false; + c->status.mst = false; + + c->options = 0; + c->buflen = 0; + c->reqlen = 0; + c->tcplen = 0; + c->allow_request = 0; + c->outbuflen = 0; + c->outbufsize = 0; + c->outbufstart = 0; + c->last_ping_time = 0; + c->last_flushed_time = 0; + c->inbudget = 0; + c->outbudget = 0; + + if(c->inctx) { + EVP_CIPHER_CTX_reset(c->inctx); + free(c->inctx); + c->inctx = NULL; + } + + if(c->outctx) { + EVP_CIPHER_CTX_reset(c->outctx); + free(c->outctx); + c->outctx = NULL; + } + + if(c->rsa_key) { + RSA_free(c->rsa_key); + c->rsa_key = NULL; + } } void free_connection(connection_t *c) { - if(!c) { - return; - } - -#ifndef DISABLE_LEGACY - cipher_close(c->incipher); - digest_close(c->indigest); - cipher_close(c->outcipher); - digest_close(c->outdigest); - rsa_free(c->rsa); -#endif - - sptps_stop(&c->sptps); - ecdsa_free(c->ecdsa); - - free(c->hischallenge); - free(c->mychallenge); - - buffer_clear(&c->inbuf); - buffer_clear(&c->outbuf); - - io_del(&c->io); - - if(c->socket > 0) { - if(c->status.tarpit) { - tarpit(c->socket); - } else { - closesocket(c->socket); - } - } + free_connection_partially(c); free(c->name); free(c->hostname); @@ -95,20 +127,25 @@ void free_connection(connection_t *c) { } void connection_add(connection_t *c) { - list_insert_tail(connection_list, c); + avl_insert(connection_tree, c); } void connection_del(connection_t *c) { - list_delete(connection_list, c); + avl_delete(connection_tree, c); } -bool dump_connections(connection_t *cdump) { - for list_each(connection_t, c, connection_list) { - send_request(cdump, "%d %d %s %s %x %d %x", - CONTROL, REQ_DUMP_CONNECTIONS, - c->name, c->hostname, c->options, c->socket, - bitfield_to_int(&c->status, sizeof(c->status))); +void dump_connections(void) { + avl_node_t *node; + connection_t *c; + + logger(LOG_DEBUG, "Connections:"); + + for(node = connection_tree->head; node; node = node->next) { + c = node->data; + logger(LOG_DEBUG, " %s at %s options %x socket %d status %04x outbuf %d/%d/%d", + c->name, c->hostname, c->options, c->socket, bitfield_to_int(&c->status, sizeof(c->status)), + c->outbufsize, c->outbufstart, c->outbuflen); } - return send_request(cdump, "%d %d", CONTROL, REQ_DUMP_CONNECTIONS); + logger(LOG_DEBUG, "End of connections."); } diff --git a/src/connection.h b/src/connection.h index 206417b..d619e85 100644 --- a/src/connection.h +++ b/src/connection.h @@ -3,7 +3,7 @@ /* connection.h -- header for connection.c - Copyright (C) 2000-2013 Guus Sliepen , + Copyright (C) 2000-2016 Guus Sliepen , 2000-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -21,50 +21,45 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "buffer.h" -#include "cipher.h" -#include "digest.h" -#include "rsa.h" -#include "list.h" -#include "sptps.h" +#include +#include + +#if OPENSSL_VERSION_NUMBER < 0x10100000L +#define EVP_CIPHER_CTX_reset(c) EVP_CIPHER_CTX_cleanup(c) +#endif + +#include "avl_tree.h" #define OPTION_INDIRECT 0x0001 #define OPTION_TCPONLY 0x0002 #define OPTION_PMTU_DISCOVERY 0x0004 #define OPTION_CLAMP_MSS 0x0008 -#define OPTION_VERSION(x) ((x) >> 24) /* Top 8 bits are for protocol minor version */ typedef struct connection_status_t { - unsigned int pinged: 1; /* sent ping */ - unsigned int unused_active: 1; - unsigned int connecting: 1; /* 1 if we are waiting for a non-blocking connect() to finish */ - unsigned int unused_termreq: 1; /* the termination of this connection was requested */ - unsigned int remove_unused: 1; /* Set to 1 if you want this connection removed */ - unsigned int timeout_unused: 1; /* 1 if gotten timeout */ - unsigned int encryptout: 1; /* 1 if we can encrypt outgoing traffic */ - unsigned int decryptin: 1; /* 1 if we have to decrypt incoming traffic */ - unsigned int mst: 1; /* 1 if this connection is part of a minimum spanning tree */ - unsigned int control: 1; /* 1 if this is a control connection */ - unsigned int pcap: 1; /* 1 if this is a control connection requesting packet capture */ - unsigned int log: 1; /* 1 if this is a control connection requesting log dump */ - unsigned int invitation: 1; /* 1 if this is an invitation */ - unsigned int invitation_used: 1; /* 1 if the invitation has been consumed */ - unsigned int tarpit: 1; /* 1 if the connection should be added to the tarpit */ - unsigned int unused: 17; + unsigned int pinged: 1; /* sent ping */ + unsigned int active: 1; /* 1 if active.. */ + unsigned int connecting: 1; /* 1 if we are waiting for a non-blocking connect() to finish */ + unsigned int unused_termreq: 1; /* the termination of this connection was requested */ + unsigned int remove: 1; /* Set to 1 if you want this connection removed */ + unsigned int timeout: 1; /* 1 if gotten timeout */ + unsigned int encryptout: 1; /* 1 if we can encrypt outgoing traffic */ + unsigned int decryptin: 1; /* 1 if we have to decrypt incoming traffic */ + unsigned int mst: 1; /* 1 if this connection is part of a minimum spanning tree */ + unsigned int proxy_passed: 1; /* 1 if we are connecting via a proxy and we have finished talking with it */ + unsigned int tarpit: 1; /* 1 if the connection should be added to the tarpit */ + unsigned int unused: 21; } connection_status_t; -#include "ecdsa.h" #include "edge.h" #include "net.h" #include "node.h" typedef struct connection_t { char *name; /* name he claims to have */ - char *hostname; /* the hostname of its real ip */ union sockaddr_t address; /* his real (internet) ip */ - int protocol_major; /* used protocol */ - int protocol_minor; /* used protocol */ + char *hostname; /* the hostname of its real ip */ + int protocol_version; /* used protocol */ int socket; /* socket used for this connection */ uint32_t options; /* options for this connection */ @@ -76,48 +71,53 @@ typedef struct connection_t { struct node_t *node; /* node associated with the other end */ struct edge_t *edge; /* edge associated with this connection */ -#ifndef DISABLE_LEGACY - rsa_t *rsa; /* his public RSA key */ - cipher_t *incipher; /* Cipher he will use to send data to us */ - cipher_t *outcipher; /* Cipher we will use to send data to him */ - digest_t *indigest; - digest_t *outdigest; - uint64_t inbudget; - uint64_t outbudget; -#endif - - ecdsa_t *ecdsa; /* his public ECDSA key */ - sptps_t sptps; - + RSA *rsa_key; /* his public/private key */ + const EVP_CIPHER *incipher; /* Cipher he will use to send data to us */ + const EVP_CIPHER *outcipher; /* Cipher we will use to send data to him */ + EVP_CIPHER_CTX *inctx; /* Context of encrypted meta data that will come from him to us */ + EVP_CIPHER_CTX *outctx; /* Context of encrypted meta data that will be sent from us to him */ + uint64_t inbudget; /* Encrypted bytes send budget */ + uint64_t outbudget; /* Encrypted bytes receive budget */ + char *inkey; /* His symmetric meta key + iv */ + char *outkey; /* Our symmetric meta key + iv */ + int inkeylength; /* Length of his key + iv */ + int outkeylength; /* Length of our key + iv */ + const EVP_MD *indigest; + const EVP_MD *outdigest; int inmaclength; int outmaclength; int incompression; int outcompression; + char *mychallenge; /* challenge we received from him */ + char *hischallenge; /* challenge we sent to him */ - char *hischallenge; /* The challenge we sent to him */ - char *mychallenge; /* The challenge we received */ - - struct buffer_t inbuf; - struct buffer_t outbuf; - io_t io; /* input/output event on this metadata connection */ - int tcplen; /* length of incoming TCPpacket */ - int sptpslen; /* length of incoming SPTPS packet */ + char buffer[MAXBUFSIZE]; /* metadata input buffer */ + int buflen; /* bytes read into buffer */ + int reqlen; /* length of incoming request */ + length_t tcplen; /* length of incoming TCPpacket */ int allow_request; /* defined if there's only one request possible */ - time_t last_ping_time; /* last time we saw some activity from the other end or pinged them */ + char *outbuf; /* metadata output buffer */ + int outbufstart; /* index of first meaningful byte in output buffer */ + int outbuflen; /* number of meaningful bytes in output buffer */ + int outbufsize; /* number of bytes allocated to output buffer */ - splay_tree_t *config_tree; /* Pointer to configuration tree belonging to him */ + time_t last_ping_time; /* last time we saw some activity from the other end or pinged them */ + time_t last_flushed_time; /* last time buffer was empty. Only meaningful if outbuflen > 0 */ + + avl_tree_t *config_tree; /* Pointer to configuration tree belonging to him */ } connection_t; -extern list_t *connection_list; +extern avl_tree_t *connection_tree; extern connection_t *everyone; extern void init_connections(void); extern void exit_connections(void); extern connection_t *new_connection(void) __attribute__((__malloc__)); extern void free_connection(connection_t *c); +extern void free_connection_partially(connection_t *c); extern void connection_add(connection_t *c); extern void connection_del(connection_t *c); -extern bool dump_connections(struct connection_t *c); +extern void dump_connections(void); #endif diff --git a/src/control.c b/src/control.c deleted file mode 100644 index 71258b5..0000000 --- a/src/control.c +++ /dev/null @@ -1,241 +0,0 @@ -/* - control.c -- Control socket handling. - Copyright (C) 2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" -#include "crypto.h" -#include "conf.h" -#include "control.h" -#include "control_common.h" -#include "graph.h" -#include "logger.h" -#include "meta.h" -#include "names.h" -#include "net.h" -#include "netutl.h" -#include "protocol.h" -#include "route.h" -#include "utils.h" -#include "xalloc.h" - -char controlcookie[65]; - -static bool control_return(connection_t *c, int type, int error) { - return send_request(c, "%d %d %d", CONTROL, type, error); -} - -static bool control_ok(connection_t *c, int type) { - return control_return(c, type, 0); -} - -bool control_h(connection_t *c, const char *request) { - int type; - - if(!c->status.control || c->allow_request != CONTROL) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unauthorized control request from %s (%s)", c->name, c->hostname); - return false; - } - - if(sscanf(request, "%*d %d", &type) != 1) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "CONTROL", c->name, c->hostname); - return false; - } - - switch(type) { - case REQ_STOP: - event_exit(); - return control_ok(c, REQ_STOP); - - case REQ_DUMP_NODES: - return dump_nodes(c); - - case REQ_DUMP_EDGES: - return dump_edges(c); - - case REQ_DUMP_SUBNETS: - return dump_subnets(c); - - case REQ_DUMP_CONNECTIONS: - return dump_connections(c); - - case REQ_PURGE: - purge(); - return control_ok(c, REQ_PURGE); - - case REQ_SET_DEBUG: { - int new_level; - - if(sscanf(request, "%*d %*d %d", &new_level) != 1) { - return false; - } - - send_request(c, "%d %d %d", CONTROL, REQ_SET_DEBUG, debug_level); - - if(new_level >= 0) { - debug_level = new_level; - } - - return true; - } - - case REQ_RETRY: - retry(); - return control_ok(c, REQ_RETRY); - - case REQ_RELOAD: - logger(DEBUG_ALWAYS, LOG_NOTICE, "Got '%s' command", "reload"); - int result = reload_configuration(); - return control_return(c, REQ_RELOAD, result); - - case REQ_DISCONNECT: { - char name[MAX_STRING_SIZE]; - bool found = false; - - if(sscanf(request, "%*d %*d " MAX_STRING, name) != 1) { - return control_return(c, REQ_DISCONNECT, -1); - } - - for list_each(connection_t, other, connection_list) { - if(strcmp(other->name, name)) { - continue; - } - - terminate_connection(other, other->edge); - found = true; - } - - return control_return(c, REQ_DISCONNECT, found ? 0 : -2); - } - - case REQ_DUMP_TRAFFIC: - return dump_traffic(c); - - case REQ_PCAP: - sscanf(request, "%*d %*d %d", &c->outmaclength); - c->status.pcap = true; - pcap = true; - return true; - - case REQ_LOG: - sscanf(request, "%*d %*d %d", &c->outcompression); - c->status.log = true; - logcontrol = true; - return true; - - default: - return send_request(c, "%d %d", CONTROL, REQ_INVALID); - } -} - -bool init_control(void) { - randomize(controlcookie, sizeof(controlcookie) / 2); - bin2hex(controlcookie, controlcookie, sizeof(controlcookie) / 2); - - mode_t mask = umask(0); - umask(mask | 077); - FILE *f = fopen(pidfilename, "w"); - umask(mask); - - if(!f) { - logger(DEBUG_ALWAYS, LOG_ERR, "Cannot write control socket cookie file %s: %s", pidfilename, strerror(errno)); - return false; - } - - // Get the address and port of the first listening socket - - char *localhost = NULL; - sockaddr_t sa = {0}; - socklen_t len = sizeof(sa); - - // Make sure we have a valid address, and map 0.0.0.0 and :: to 127.0.0.1 and ::1. - - if(getsockname(listen_socket[0].tcp.fd, &sa.sa, &len)) { - xasprintf(&localhost, "127.0.0.1 port %s", myport); - } else { - if(sa.sa.sa_family == AF_INET) { - if(sa.in.sin_addr.s_addr == 0) { - sa.in.sin_addr.s_addr = htonl(0x7f000001); - } - } else if(sa.sa.sa_family == AF_INET6) { - static const uint8_t zero[16] = {0}; - - if(!memcmp(sa.in6.sin6_addr.s6_addr, zero, sizeof(zero))) { - sa.in6.sin6_addr.s6_addr[15] = 1; - } - } - - localhost = sockaddr2hostname(&sa); - } - - fprintf(f, "%d %s %s\n", (int)getpid(), controlcookie, localhost); - - free(localhost); - fclose(f); - -#ifndef HAVE_MINGW - int unix_fd = socket(AF_UNIX, SOCK_STREAM, 0); - - if(unix_fd < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not create UNIX socket: %s", sockstrerror(sockerrno)); - return false; - } - - struct sockaddr_un sa_un; - - sa_un.sun_family = AF_UNIX; - - strncpy(sa_un.sun_path, unixsocketname, sizeof(sa_un.sun_path)); - - sa_un.sun_path[sizeof(sa_un.sun_path) - 1] = 0; - - if(connect(unix_fd, (struct sockaddr *)&sa_un, sizeof(sa_un)) >= 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "UNIX socket %s is still in use!", unixsocketname); - return false; - } - - unlink(unixsocketname); - - umask(mask | 077); - int result = bind(unix_fd, (struct sockaddr *)&sa_un, sizeof(sa_un)); - umask(mask); - - if(result < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not bind UNIX socket to %s: %s", unixsocketname, sockstrerror(sockerrno)); - return false; - } - - if(listen(unix_fd, 3) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not listen on UNIX socket %s: %s", unixsocketname, sockstrerror(sockerrno)); - return false; - } - - io_add(&unix_socket, handle_new_unix_connection, &unix_socket, unix_fd, IO_READ); -#endif - - return true; -} - -void exit_control(void) { -#ifndef HAVE_MINGW - unlink(unixsocketname); - io_del(&unix_socket); - close(unix_socket.fd); -#endif - - unlink(pidfilename); -} diff --git a/src/control.h b/src/control.h deleted file mode 100644 index 9398410..0000000 --- a/src/control.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef TINC_CONTROL_H -#define TINC_CONTROL_H - -/* - control.h -- header for control.c. - Copyright (C) 2007 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -extern bool init_control(void); -extern void exit_control(void); -extern char controlcookie[]; - -#endif diff --git a/src/control_common.h b/src/control_common.h deleted file mode 100644 index 2be4abd..0000000 --- a/src/control_common.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef TINC_CONTROL_COMMON_H -#define TINC_CONTROL_COMMON_H - -/* - control_protocol.h -- control socket protocol. - Copyright (C) 2007 Scott Lamb - 2009-2012 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "protocol.h" - -enum request_type { - REQ_INVALID = -1, - REQ_STOP = 0, - REQ_RELOAD, - REQ_RESTART, - REQ_DUMP_NODES, - REQ_DUMP_EDGES, - REQ_DUMP_SUBNETS, - REQ_DUMP_CONNECTIONS, - REQ_DUMP_GRAPH, - REQ_PURGE, - REQ_SET_DEBUG, - REQ_RETRY, - REQ_CONNECT, - REQ_DISCONNECT, - REQ_DUMP_TRAFFIC, - REQ_PCAP, - REQ_LOG, -}; - -#define TINC_CTL_VERSION_CURRENT 0 - -#endif diff --git a/src/crypto.h b/src/crypto.h deleted file mode 100644 index 74bab1b..0000000 --- a/src/crypto.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef TINC_CRYPTO_H -#define TINC_CRYPTO_H - -/* - crypto.h -- header for crypto.c - Copyright (C) 2007-2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -extern void crypto_init(void); -extern void crypto_exit(void); -extern void randomize(void *buf, size_t buflen); - -#endif diff --git a/src/cygwin/device.c b/src/cygwin/device.c index 6d94988..1165d67 100644 --- a/src/cygwin/device.c +++ b/src/cygwin/device.c @@ -1,7 +1,7 @@ /* device.c -- Interaction with Windows tap driver in a Cygwin environment Copyright (C) 2002-2005 Ivo Timmermans, - 2002-2014 Guus Sliepen + 2002-2016 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,7 +27,6 @@ #include "../conf.h" #include "../device.h" #include "../logger.h" -#include "../names.h" #include "../route.h" #include "../utils.h" #include "../xalloc.h" @@ -40,6 +39,9 @@ char *device = NULL; char *iface = NULL; static const char *device_info = "Windows tap device"; +static uint64_t device_total_in = 0; +static uint64_t device_total_out = 0; + static pid_t reader_pid; static int sp[2]; @@ -66,7 +68,7 @@ static bool setup_device(void) { /* Open registry and look for network adapters */ if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, NETWORK_CONNECTIONS_KEY, 0, KEY_READ, &key)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unable to read registry: %s", winerror(GetLastError())); + logger(LOG_ERR, "Unable to read registry: %s", winerror(GetLastError())); return false; } @@ -125,7 +127,7 @@ static bool setup_device(void) { RegCloseKey(key); if(!found) { - logger(DEBUG_ALWAYS, LOG_ERR, "No Windows tap device found!"); + logger(LOG_ERR, "No Windows tap device found!"); return false; } @@ -144,7 +146,7 @@ static bool setup_device(void) { Furthermore I don't really know how to do it the "Windows" way. */ if(socketpair(AF_UNIX, SOCK_DGRAM, PF_UNIX, sp)) { - logger(DEBUG_ALWAYS, LOG_DEBUG, "System call `%s' failed: %s", "socketpair", strerror(errno)); + logger(LOG_DEBUG, "System call `%s' failed: %s", "socketpair", strerror(errno)); return false; } @@ -153,7 +155,7 @@ static bool setup_device(void) { device_handle = CreateFile(tapname, GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM, 0); if(device_handle == INVALID_HANDLE_VALUE) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not open Windows tap device %s (%s) for writing: %s", device, iface, winerror(GetLastError())); + logger(LOG_ERR, "Could not open Windows tap device %s (%s) for writing: %s", device, iface, winerror(GetLastError())); return false; } @@ -162,7 +164,7 @@ static bool setup_device(void) { /* Get MAC address from tap device */ if(!DeviceIoControl(device_handle, TAP_IOCTL_GET_MAC, mymac.x, sizeof(mymac.x), mymac.x, sizeof(mymac.x), &len, 0)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not get MAC address from Windows tap device %s (%s): %s", device, iface, winerror(GetLastError())); + logger(LOG_ERR, "Could not get MAC address from Windows tap device %s (%s): %s", device, iface, winerror(GetLastError())); return false; } @@ -175,7 +177,7 @@ static bool setup_device(void) { reader_pid = fork(); if(reader_pid == -1) { - logger(DEBUG_ALWAYS, LOG_DEBUG, "System call `%s' failed: %s", "fork", strerror(errno)); + logger(LOG_DEBUG, "System call `%s' failed: %s", "fork", strerror(errno)); return false; } @@ -184,20 +186,20 @@ static bool setup_device(void) { It passes everything it reads to the socket. */ char buf[MTU]; - long inlen; + long lenin; CloseHandle(device_handle); device_handle = CreateFile(tapname, GENERIC_READ, FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM, 0); if(device_handle == INVALID_HANDLE_VALUE) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not open Windows tap device %s (%s) for reading: %s", device, iface, winerror(GetLastError())); + logger(LOG_ERR, "Could not open Windows tap device %s (%s) for reading: %s", device, iface, winerror(GetLastError())); buf[0] = 0; write(sp[1], buf, 1); exit(1); } - logger(DEBUG_ALWAYS, LOG_DEBUG, "Tap reader forked and running."); + logger(LOG_DEBUG, "Tap reader forked and running."); /* Notify success */ @@ -207,19 +209,19 @@ static bool setup_device(void) { /* Pass packets */ for(;;) { - ReadFile(device_handle, buf, MTU, &inlen, NULL); - write(sp[1], buf, inlen); + ReadFile(device_handle, buf, MTU, &lenin, NULL); + write(sp[1], buf, lenin); } } read(device_fd, &gelukt, 1); if(gelukt != 1) { - logger(DEBUG_ALWAYS, LOG_DEBUG, "Tap reader failed!"); + logger(LOG_DEBUG, "Tap reader failed!"); return false; } - logger(DEBUG_ALWAYS, LOG_INFO, "%s (%s) is a %s", device, iface, device_info); + logger(LOG_INFO, "%s (%s) is a %s", device, iface, device_info); return true; } @@ -228,51 +230,58 @@ static void close_device(void) { close(sp[0]); close(sp[1]); CloseHandle(device_handle); - device_handle = INVALID_HANDLE_VALUE; kill(reader_pid, SIGKILL); free(device); - device = NULL; free(iface); - iface = NULL; - device_info = NULL; } static bool read_packet(vpn_packet_t *packet) { - int inlen; + int lenin; - if((inlen = read(sp[0], DATA(packet), MTU)) <= 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from %s %s: %s", device_info, + if((lenin = read(sp[0], packet->data, MTU)) <= 0) { + logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); return false; } - packet->len = inlen; + packet->len = lenin; - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, - device_info); + device_total_in += packet->len; + + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, + device_info); return true; } static bool write_packet(vpn_packet_t *packet) { - long outlen; + long lenout; - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Writing packet of %d bytes to %s", - packet->len, device_info); + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Writing packet of %d bytes to %s", + packet->len, device_info); - if(!WriteFile(device_handle, DATA(packet), packet->len, &outlen, NULL)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while writing to %s %s: %s", device_info, device, winerror(GetLastError())); + if(!WriteFile(device_handle, packet->data, packet->len, &lenout, NULL)) { + logger(LOG_ERR, "Error while writing to %s %s: %s", device_info, device, winerror(GetLastError())); return false; } + device_total_out += packet->len; + return true; } +static void dump_device_stats(void) { + logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); + logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); + logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); +} + const devops_t os_devops = { .setup = setup_device, .close = close_device, .read = read_packet, .write = write_packet, + .dump_stats = dump_device_stats, }; diff --git a/src/device.h b/src/device.h index c85671b..6bfc44d 100644 --- a/src/device.h +++ b/src/device.h @@ -25,22 +25,21 @@ extern int device_fd; extern char *device; + extern char *iface; typedef struct devops_t { bool (*setup)(void); void (*close)(void); - bool (*read)(struct vpn_packet_t *); - bool (*write)(struct vpn_packet_t *); - void (*enable)(void); /* optional */ - void (*disable)(void); /* optional */ + bool (*read)(struct vpn_packet_t *packet); + bool (*write)(struct vpn_packet_t *packet); + void (*dump_stats)(void); } devops_t; extern const devops_t os_devops; extern const devops_t dummy_devops; extern const devops_t raw_socket_devops; extern const devops_t multicast_devops; -extern const devops_t fd_devops; extern const devops_t uml_devops; extern const devops_t vde_devops; extern devops_t devops; diff --git a/src/digest.h b/src/digest.h deleted file mode 100644 index 6d7cb41..0000000 --- a/src/digest.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef TINC_DIGEST_H -#define TINC_DIGEST_H - -/* - digest.h -- header file digest.c - Copyright (C) 2007-2016 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#define DIGEST_MAX_SIZE 64 - -#ifndef DISABLE_LEGACY - -typedef struct digest digest_t; - -extern digest_t *digest_open_by_name(const char *name, int maclength) __attribute__((__malloc__)); -extern digest_t *digest_open_by_nid(int nid, int maclength) __attribute__((__malloc__)); -extern void digest_close(digest_t *digest); -extern bool digest_create(digest_t *digest, const void *indata, size_t inlen, void *outdata) __attribute__((__warn_unused_result__)); -extern bool digest_verify(digest_t *digest, const void *indata, size_t inlen, const void *digestdata) __attribute__((__warn_unused_result__)); -extern bool digest_set_key(digest_t *digest, const void *key, size_t len) __attribute__((__warn_unused_result__)); -extern int digest_get_nid(const digest_t *digest); -extern size_t digest_keylength(const digest_t *digest); -extern size_t digest_length(const digest_t *digest); -extern bool digest_active(const digest_t *digest); - -#endif - -#endif diff --git a/src/dropin.c b/src/dropin.c index 74e5676..93511f1 100644 --- a/src/dropin.c +++ b/src/dropin.c @@ -107,6 +107,7 @@ int vasprintf(char **buf, const char *fmt, va_list ap) { va_copy(aq, ap); status = vsnprintf(*buf, len, fmt, aq); + buf[len - 1] = 0; va_end(aq); if(status >= 0) { @@ -114,7 +115,7 @@ int vasprintf(char **buf, const char *fmt, va_list ap) { } if(status > len - 1) { - len = status + 1; + len = status; va_copy(aq, ap); status = vsnprintf(*buf, len, fmt, aq); va_end(aq); @@ -126,25 +127,16 @@ int vasprintf(char **buf, const char *fmt, va_list ap) { #ifndef HAVE_GETTIMEOFDAY int gettimeofday(struct timeval *tv, void *tz) { -#ifdef HAVE_MINGW - FILETIME ft; - GetSystemTimeAsFileTime(&ft); - uint64_t lt = (uint64_t)ft.dwLowDateTime | ((uint64_t)ft.dwHighDateTime << 32); - lt -= 116444736000000000ULL; - tv->tv_sec = lt / 10000000; - tv->tv_usec = (lt / 10) % 1000000; -#else -#warning No high resolution time source! tv->tv_sec = time(NULL); tv->tv_usec = 0; -#endif return 0; } #endif -#ifndef HAVE_NANOSLEEP -int nanosleep(const struct timespec *req, struct timespec *rem) { - struct timeval tv = {req->tv_sec, req->tv_nsec / 1000}; - return select(0, NULL, NULL, NULL, &tv); +#ifndef HAVE_USLEEP +int usleep(long long usec) { + struct timeval tv = {usec / 1000000, (usec / 1000) % 1000}; + select(0, NULL, NULL, NULL, &tv); + return 0; } #endif diff --git a/src/dropin.h b/src/dropin.h index 5033f90..012099b 100644 --- a/src/dropin.h +++ b/src/dropin.h @@ -4,7 +4,7 @@ /* dropin.h -- header file for dropin.c Copyright (C) 2000-2005 Ivo Timmermans, - 2000-2016 Guus Sliepen + 2000-2011 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,50 +21,28 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "fake-getaddrinfo.h" +#include "fake-getnameinfo.h" + #ifndef HAVE_DAEMON -extern int daemon(int, int); +extern int daemon(int nochdir, int noclose); +#endif + +#ifndef HAVE_GET_CURRENT_DIR_NAME +extern char *get_current_dir_name(void); #endif #ifndef HAVE_ASPRINTF -extern int asprintf(char **, const char *, ...); -extern int vasprintf(char **, const char *, va_list ap); +extern int asprintf(char **buf, const char *fmt, ...); +extern int vasprintf(char **buf, const char *fmt, va_list ap); #endif #ifndef HAVE_GETTIMEOFDAY -extern int gettimeofday(struct timeval *, void *); +extern int gettimeofday(struct timeval *tv, void *tz); #endif -#ifndef HAVE_NANOSLEEP -extern int nanosleep(const struct timespec *req, struct timespec *rem); -#endif - -#ifndef timeradd -#define timeradd(a, b, r) do {\ - (r)->tv_sec = (a)->tv_sec + (b)->tv_sec;\ - (r)->tv_usec = (a)->tv_usec + (b)->tv_usec;\ - if((r)->tv_usec >= 1000000)\ - (r)->tv_sec++, (r)->tv_usec -= 1000000;\ - } while (0) -#endif - -#ifndef timersub -#define timersub(a, b, r) do {\ - (r)->tv_sec = (a)->tv_sec - (b)->tv_sec;\ - (r)->tv_usec = (a)->tv_usec - (b)->tv_usec;\ - if((r)->tv_usec < 0)\ - (r)->tv_sec--, (r)->tv_usec += 1000000;\ - } while (0) -#endif - -#ifdef HAVE_MINGW -#define mkdir(a, b) mkdir(a) -#ifndef SHUT_RDWR -#define SHUT_RDWR SD_BOTH -#endif -#endif - -#ifndef EAI_SYSTEM -#define EAI_SYSTEM 0 +#ifndef HAVE_USLEEP +extern int usleep(long long usec); #endif #endif diff --git a/src/dummy_device.c b/src/dummy_device.c index 15f0654..d1d751b 100644 --- a/src/dummy_device.c +++ b/src/dummy_device.c @@ -1,6 +1,6 @@ /* device.c -- Dummy device - Copyright (C) 2011-2012 Guus Sliepen + Copyright (C) 2011 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,14 +26,19 @@ static const char *device_info = "dummy device"; +static uint64_t device_total_in = 0; +static uint64_t device_total_out = 0; + static bool setup_device(void) { device = xstrdup("dummy"); iface = xstrdup("dummy"); - logger(DEBUG_ALWAYS, LOG_INFO, "%s (%s) is a %s", device, iface, device_info); + logger(LOG_INFO, "%s (%s) is a %s", device, iface, device_info); return true; } static void close_device(void) { + free(device); + free(iface); } static bool read_packet(vpn_packet_t *packet) { @@ -42,13 +47,20 @@ static bool read_packet(vpn_packet_t *packet) { } static bool write_packet(vpn_packet_t *packet) { - (void)packet; + device_total_out += packet->len; return true; } +static void dump_device_stats(void) { + logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); + logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); + logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); +} + const devops_t dummy_devops = { .setup = setup_device, .close = close_device, .read = read_packet, .write = write_packet, + .dump_stats = dump_device_stats, }; diff --git a/src/ecdh.h b/src/ecdh.h deleted file mode 100644 index 0bfc271..0000000 --- a/src/ecdh.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef TINC_ECDH_H -#define TINC_ECDH_H - -/* - ecdh.h -- header file for ecdh.c - Copyright (C) 2011-2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#define ECDH_SIZE 32 -#define ECDH_SHARED_SIZE 32 - -#ifndef TINC_ECDH_INTERNAL -typedef struct ecdh ecdh_t; -#endif - -extern ecdh_t *ecdh_generate_public(void *pubkey) __attribute__((__malloc__)); -extern bool ecdh_compute_shared(ecdh_t *ecdh, const void *pubkey, void *shared) __attribute__((__warn_unused_result__)); -extern void ecdh_free(ecdh_t *ecdh); - -#endif diff --git a/src/ecdsa.h b/src/ecdsa.h deleted file mode 100644 index 6cb5434..0000000 --- a/src/ecdsa.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef TINC_ECDSA_H -#define TINC_ECDSA_H - -/* - ecdsa.h -- ECDSA key handling - Copyright (C) 2011-2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#ifndef TINC_ECDSA_INTERNAL -typedef struct ecdsa ecdsa_t; -#endif - -extern ecdsa_t *ecdsa_set_base64_public_key(const char *p) __attribute__((__malloc__)); -extern char *ecdsa_get_base64_public_key(ecdsa_t *ecdsa); -extern ecdsa_t *ecdsa_read_pem_public_key(FILE *fp) __attribute__((__malloc__)); -extern ecdsa_t *ecdsa_read_pem_private_key(FILE *fp) __attribute__((__malloc__)); -extern size_t ecdsa_size(ecdsa_t *ecdsa); -extern bool ecdsa_sign(ecdsa_t *ecdsa, const void *in, size_t inlen, void *out) __attribute__((__warn_unused_result__)); -extern bool ecdsa_verify(ecdsa_t *ecdsa, const void *in, size_t inlen, const void *out) __attribute__((__warn_unused_result__)); -extern bool ecdsa_active(ecdsa_t *ecdsa); -extern void ecdsa_free(ecdsa_t *ecdsa); - -#endif diff --git a/src/ecdsagen.h b/src/ecdsagen.h deleted file mode 100644 index 48cd25b..0000000 --- a/src/ecdsagen.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef TINC_ECDSAGEN_H -#define TINC_ECDSAGEN_H - -/* - ecdsagen.h -- ECDSA key generation and export - Copyright (C) 2011-2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "ecdsa.h" - -extern ecdsa_t *ecdsa_generate(void) __attribute__((__malloc__)); -extern bool ecdsa_write_pem_public_key(ecdsa_t *ecdsa, FILE *fp) __attribute__((__warn_unused_result__)); -extern bool ecdsa_write_pem_private_key(ecdsa_t *ecdsa, FILE *fp) __attribute__((__warn_unused_result__)); - -#endif diff --git a/src/ed25519/ecdh.c b/src/ed25519/ecdh.c deleted file mode 100644 index 302fafd..0000000 --- a/src/ed25519/ecdh.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - ecdh.c -- Diffie-Hellman key exchange handling - Copyright (C) 2011-2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "../system.h" - -#include "ed25519.h" - -#define TINC_ECDH_INTERNAL -typedef struct ecdh_t { - uint8_t private[64]; -} ecdh_t; - -#include "../crypto.h" -#include "../ecdh.h" -#include "../xalloc.h" - -ecdh_t *ecdh_generate_public(void *pubkey) { - ecdh_t *ecdh = xzalloc(sizeof(*ecdh)); - - uint8_t seed[32]; - randomize(seed, sizeof(seed)); - ed25519_create_keypair(pubkey, ecdh->private, seed); - - return ecdh; -} - -bool ecdh_compute_shared(ecdh_t *ecdh, const void *pubkey, void *shared) { - ed25519_key_exchange(shared, pubkey, ecdh->private); - free(ecdh); - return true; -} - -void ecdh_free(ecdh_t *ecdh) { - free(ecdh); -} diff --git a/src/ed25519/ecdsa.c b/src/ed25519/ecdsa.c deleted file mode 100644 index 4bd7155..0000000 --- a/src/ed25519/ecdsa.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - ecdsa.c -- ECDSA key handling - Copyright (C) 2011-2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "../system.h" - -#include "ed25519.h" - -#define TINC_ECDSA_INTERNAL -typedef struct { - uint8_t private[64]; - uint8_t public[32]; -} ecdsa_t; - -#include "../logger.h" -#include "../ecdsa.h" -#include "../utils.h" -#include "../xalloc.h" - -// Get and set ECDSA keys -// -ecdsa_t *ecdsa_set_base64_public_key(const char *p) { - int len = strlen(p); - - if(len != 43) { - logger(DEBUG_ALWAYS, LOG_ERR, "Invalid size %d for public key!", len); - return 0; - } - - ecdsa_t *ecdsa = xzalloc(sizeof(*ecdsa)); - len = b64decode(p, ecdsa->public, len); - - if(len != 32) { - logger(DEBUG_ALWAYS, LOG_ERR, "Invalid format of public key! len = %d", len); - free(ecdsa); - return 0; - } - - return ecdsa; -} - -char *ecdsa_get_base64_public_key(ecdsa_t *ecdsa) { - char *base64 = xmalloc(44); - b64encode(ecdsa->public, base64, sizeof(ecdsa->public)); - - return base64; -} - -// Read PEM ECDSA keys - -static bool read_pem(FILE *fp, const char *type, void *vbuf, size_t size) { - char line[1024]; - bool data = false; - size_t typelen = strlen(type); - char *buf = vbuf; - - while(fgets(line, sizeof(line), fp)) { - if(!data) { - if(strncmp(line, "-----BEGIN ", 11)) { - continue; - } - - if(strncmp(line + 11, type, typelen)) { - continue; - } - - data = true; - continue; - } - - if(!strncmp(line, "-----END ", 9)) { - break; - } - - size_t linelen = strcspn(line, "\r\n"); - size_t len = b64decode(line, line, linelen); - - if(!len) { - logger(DEBUG_ALWAYS, LOG_ERR, "Invalid base64 data in PEM file\n"); - errno = EINVAL; - return false; - } - - if(len > size) { - logger(DEBUG_ALWAYS, LOG_ERR, "Too much base64 data in PEM file\n"); - errno = EINVAL; - return false; - } - - memcpy(buf, line, len); - buf += len; - size -= len; - } - - if(size) { - if(data) { - errno = EINVAL; - logger(DEBUG_ALWAYS, LOG_ERR, "Too little base64 data in PEM file\n"); - } else { - errno = ENOENT; - } - - return false; - } - - return true; -} - -ecdsa_t *ecdsa_read_pem_public_key(FILE *fp) { - ecdsa_t *ecdsa = xzalloc(sizeof(*ecdsa)); - - if(read_pem(fp, "ED25519 PUBLIC KEY", ecdsa->public, sizeof(ecdsa->public))) { - return ecdsa; - } - - free(ecdsa); - return 0; -} - -ecdsa_t *ecdsa_read_pem_private_key(FILE *fp) { - ecdsa_t *ecdsa = xmalloc(sizeof(*ecdsa)); - - if(read_pem(fp, "ED25519 PRIVATE KEY", ecdsa->private, sizeof(*ecdsa))) { - return ecdsa; - } - - free(ecdsa); - return 0; -} - -size_t ecdsa_size(ecdsa_t *ecdsa) { - (void)ecdsa; - return 64; -} - -// TODO: standardise output format? - -bool ecdsa_sign(ecdsa_t *ecdsa, const void *in, size_t len, void *sig) { - ed25519_sign(sig, in, len, ecdsa->public, ecdsa->private); - return true; -} - -bool ecdsa_verify(ecdsa_t *ecdsa, const void *in, size_t len, const void *sig) { - return ed25519_verify(sig, in, len, ecdsa->public); -} - -bool ecdsa_active(ecdsa_t *ecdsa) { - return ecdsa; -} - -void ecdsa_free(ecdsa_t *ecdsa) { - free(ecdsa); -} diff --git a/src/ed25519/ecdsagen.c b/src/ed25519/ecdsagen.c deleted file mode 100644 index ede5136..0000000 --- a/src/ed25519/ecdsagen.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - ecdsagen.c -- ECDSA key generation and export - Copyright (C) 2011-2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "../system.h" - -#include "ed25519.h" - -#define TINC_ECDSA_INTERNAL -typedef struct { - uint8_t private[64]; - uint8_t public[32]; -} ecdsa_t; - -#include "../crypto.h" -#include "../ecdsagen.h" -#include "../utils.h" -#include "../xalloc.h" - -// Generate ECDSA key - -ecdsa_t *ecdsa_generate(void) { - ecdsa_t *ecdsa = xzalloc(sizeof(*ecdsa)); - - uint8_t seed[32]; - randomize(seed, sizeof(seed)); - ed25519_create_keypair(ecdsa->public, ecdsa->private, seed); - - return ecdsa; -} - -// Write PEM ECDSA keys - -static bool write_pem(FILE *fp, const char *type, void *vbuf, size_t size) { - fprintf(fp, "-----BEGIN %s-----\n", type); - - char *buf = vbuf; - char base64[65]; - - while(size) { - size_t todo = size > 48 ? 48 : size; - b64encode(buf, base64, todo); - fprintf(fp, "%s\n", base64); - buf += todo; - size -= todo; - } - - fprintf(fp, "-----END %s-----\n", type); - return !ferror(fp); -} - -bool ecdsa_write_pem_public_key(ecdsa_t *ecdsa, FILE *fp) { - return write_pem(fp, "ED25519 PUBLIC KEY", ecdsa->public, sizeof(ecdsa->public)); -} - -bool ecdsa_write_pem_private_key(ecdsa_t *ecdsa, FILE *fp) { - return write_pem(fp, "ED25519 PRIVATE KEY", ecdsa->private, sizeof(*ecdsa)); -} diff --git a/src/ed25519/ed25519.h b/src/ed25519/ed25519.h deleted file mode 100644 index 65b191e..0000000 --- a/src/ed25519/ed25519.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef ED25519_H -#define ED25519_H - -#include - -#if defined(_WIN32) -#if defined(ED25519_BUILD_DLL) -#define ED25519_DECLSPEC __declspec(dllexport) -#elif defined(ED25519_DLL) -#define ED25519_DECLSPEC __declspec(dllimport) -#else -#define ED25519_DECLSPEC -#endif -#else -#define ED25519_DECLSPEC -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef ED25519_NO_SEED -int ED25519_DECLSPEC ed25519_create_seed(unsigned char *seed); -#endif - -void ED25519_DECLSPEC ed25519_create_keypair(unsigned char *public_key, unsigned char *private_key, const unsigned char *seed); -void ED25519_DECLSPEC ed25519_sign(unsigned char *signature, const unsigned char *message, size_t message_len, const unsigned char *public_key, const unsigned char *private_key); -int ED25519_DECLSPEC ed25519_verify(const unsigned char *signature, const unsigned char *message, size_t message_len, const unsigned char *private_key); -void ED25519_DECLSPEC ed25519_key_exchange(unsigned char *shared_secret, const unsigned char *public_key, const unsigned char *private_key); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/ed25519/fe.c b/src/ed25519/fe.c deleted file mode 100644 index df907a7..0000000 --- a/src/ed25519/fe.c +++ /dev/null @@ -1,1511 +0,0 @@ -#include "fixedint.h" -#include "fe.h" - - -/* - helper functions -*/ -static uint64_t load_3(const unsigned char *in) { - uint64_t result; - - result = in[0]; - result |= shlu64(in[1], 8); - result |= shlu64(in[2], 16); - - return result; -} - -static uint64_t load_4(const unsigned char *in) { - uint64_t result; - - result = in[0]; - result |= shlu64(in[1], 8); - result |= shlu64(in[2], 16); - result |= shlu64(in[3], 24); - - return result; -} - - - -/* - h = 0 -*/ - -void fe_0(fe h) { - h[0] = 0; - h[1] = 0; - h[2] = 0; - h[3] = 0; - h[4] = 0; - h[5] = 0; - h[6] = 0; - h[7] = 0; - h[8] = 0; - h[9] = 0; -} - - - -/* - h = 1 -*/ - -void fe_1(fe h) { - h[0] = 1; - h[1] = 0; - h[2] = 0; - h[3] = 0; - h[4] = 0; - h[5] = 0; - h[6] = 0; - h[7] = 0; - h[8] = 0; - h[9] = 0; -} - - - -/* - h = f + g - Can overlap h with f or g. - - Preconditions: - |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. - |g| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. - - Postconditions: - |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. -*/ - -void fe_add(fe h, const fe f, const fe g) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; - int32_t g0 = g[0]; - int32_t g1 = g[1]; - int32_t g2 = g[2]; - int32_t g3 = g[3]; - int32_t g4 = g[4]; - int32_t g5 = g[5]; - int32_t g6 = g[6]; - int32_t g7 = g[7]; - int32_t g8 = g[8]; - int32_t g9 = g[9]; - int32_t h0 = f0 + g0; - int32_t h1 = f1 + g1; - int32_t h2 = f2 + g2; - int32_t h3 = f3 + g3; - int32_t h4 = f4 + g4; - int32_t h5 = f5 + g5; - int32_t h6 = f6 + g6; - int32_t h7 = f7 + g7; - int32_t h8 = f8 + g8; - int32_t h9 = f9 + g9; - - h[0] = h0; - h[1] = h1; - h[2] = h2; - h[3] = h3; - h[4] = h4; - h[5] = h5; - h[6] = h6; - h[7] = h7; - h[8] = h8; - h[9] = h9; -} - - - -/* - Replace (f,g) with (g,g) if b == 1; - replace (f,g) with (f,g) if b == 0. - - Preconditions: b in {0,1}. -*/ - -void fe_cmov(fe f, const fe g, unsigned int b) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; - int32_t g0 = g[0]; - int32_t g1 = g[1]; - int32_t g2 = g[2]; - int32_t g3 = g[3]; - int32_t g4 = g[4]; - int32_t g5 = g[5]; - int32_t g6 = g[6]; - int32_t g7 = g[7]; - int32_t g8 = g[8]; - int32_t g9 = g[9]; - int32_t x0 = f0 ^ g0; - int32_t x1 = f1 ^ g1; - int32_t x2 = f2 ^ g2; - int32_t x3 = f3 ^ g3; - int32_t x4 = f4 ^ g4; - int32_t x5 = f5 ^ g5; - int32_t x6 = f6 ^ g6; - int32_t x7 = f7 ^ g7; - int32_t x8 = f8 ^ g8; - int32_t x9 = f9 ^ g9; - - b = (unsigned int)(- (int) b); /* silence warning */ - x0 &= b; - x1 &= b; - x2 &= b; - x3 &= b; - x4 &= b; - x5 &= b; - x6 &= b; - x7 &= b; - x8 &= b; - x9 &= b; - - f[0] = f0 ^ x0; - f[1] = f1 ^ x1; - f[2] = f2 ^ x2; - f[3] = f3 ^ x3; - f[4] = f4 ^ x4; - f[5] = f5 ^ x5; - f[6] = f6 ^ x6; - f[7] = f7 ^ x7; - f[8] = f8 ^ x8; - f[9] = f9 ^ x9; -} - -/* - Replace (f,g) with (g,f) if b == 1; - replace (f,g) with (f,g) if b == 0. - - Preconditions: b in {0,1}. -*/ - -void fe_cswap(fe f, fe g, unsigned int b) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; - int32_t g0 = g[0]; - int32_t g1 = g[1]; - int32_t g2 = g[2]; - int32_t g3 = g[3]; - int32_t g4 = g[4]; - int32_t g5 = g[5]; - int32_t g6 = g[6]; - int32_t g7 = g[7]; - int32_t g8 = g[8]; - int32_t g9 = g[9]; - int32_t x0 = f0 ^ g0; - int32_t x1 = f1 ^ g1; - int32_t x2 = f2 ^ g2; - int32_t x3 = f3 ^ g3; - int32_t x4 = f4 ^ g4; - int32_t x5 = f5 ^ g5; - int32_t x6 = f6 ^ g6; - int32_t x7 = f7 ^ g7; - int32_t x8 = f8 ^ g8; - int32_t x9 = f9 ^ g9; - b = -b; - x0 &= b; - x1 &= b; - x2 &= b; - x3 &= b; - x4 &= b; - x5 &= b; - x6 &= b; - x7 &= b; - x8 &= b; - x9 &= b; - f[0] = f0 ^ x0; - f[1] = f1 ^ x1; - f[2] = f2 ^ x2; - f[3] = f3 ^ x3; - f[4] = f4 ^ x4; - f[5] = f5 ^ x5; - f[6] = f6 ^ x6; - f[7] = f7 ^ x7; - f[8] = f8 ^ x8; - f[9] = f9 ^ x9; - g[0] = g0 ^ x0; - g[1] = g1 ^ x1; - g[2] = g2 ^ x2; - g[3] = g3 ^ x3; - g[4] = g4 ^ x4; - g[5] = g5 ^ x5; - g[6] = g6 ^ x6; - g[7] = g7 ^ x7; - g[8] = g8 ^ x8; - g[9] = g9 ^ x9; -} - - - -/* - h = f -*/ - -void fe_copy(fe h, const fe f) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; - - h[0] = f0; - h[1] = f1; - h[2] = f2; - h[3] = f3; - h[4] = f4; - h[5] = f5; - h[6] = f6; - h[7] = f7; - h[8] = f8; - h[9] = f9; -} - - - -/* - Ignores top bit of h. -*/ - -void fe_frombytes(fe h, const unsigned char *s) { - int64_t h0 = load_4(s); - int64_t h1 = load_3(s + 4) << 6; - int64_t h2 = load_3(s + 7) << 5; - int64_t h3 = load_3(s + 10) << 3; - int64_t h4 = load_3(s + 13) << 2; - int64_t h5 = load_4(s + 16); - int64_t h6 = load_3(s + 20) << 7; - int64_t h7 = load_3(s + 23) << 5; - int64_t h8 = load_3(s + 26) << 4; - int64_t h9 = (load_3(s + 29) & 8388607) << 2; - int64_t carry0; - int64_t carry1; - int64_t carry2; - int64_t carry3; - int64_t carry4; - int64_t carry5; - int64_t carry6; - int64_t carry7; - int64_t carry8; - int64_t carry9; - - carry9 = (h9 + (1L << 24)) >> 25; - h0 += carry9 * 19; - h9 -= shl64(carry9, 25); - carry1 = (h1 + (1L << 24)) >> 25; - h2 += carry1; - h1 -= shl64(carry1, 25); - carry3 = (h3 + (1L << 24)) >> 25; - h4 += carry3; - h3 -= shl64(carry3, 25); - carry5 = (h5 + (1L << 24)) >> 25; - h6 += carry5; - h5 -= shl64(carry5, 25); - carry7 = (h7 + (1L << 24)) >> 25; - h8 += carry7; - h7 -= shl64(carry7, 25); - carry0 = (h0 + (1L << 25)) >> 26; - h1 += carry0; - h0 -= shl64(carry0, 26); - carry2 = (h2 + (1L << 25)) >> 26; - h3 += carry2; - h2 -= shl64(carry2, 26); - carry4 = (h4 + (1L << 25)) >> 26; - h5 += carry4; - h4 -= shl64(carry4, 26); - carry6 = (h6 + (1L << 25)) >> 26; - h7 += carry6; - h6 -= shl64(carry6, 26); - carry8 = (h8 + (1L << 25)) >> 26; - h9 += carry8; - h8 -= shl64(carry8, 26); - - h[0] = h0; - h[1] = h1; - h[2] = h2; - h[3] = h3; - h[4] = h4; - h[5] = h5; - h[6] = h6; - h[7] = h7; - h[8] = h8; - h[9] = h9; -} - - - -void fe_invert(fe out, const fe z) { - fe t0; - fe t1; - fe t2; - fe t3; - int i; - - fe_sq(t0, z); - - for(i = 1; i < 1; ++i) { - fe_sq(t0, t0); - } - - fe_sq(t1, t0); - - for(i = 1; i < 2; ++i) { - fe_sq(t1, t1); - } - - fe_mul(t1, z, t1); - fe_mul(t0, t0, t1); - fe_sq(t2, t0); - - for(i = 1; i < 1; ++i) { - fe_sq(t2, t2); - } - - fe_mul(t1, t1, t2); - fe_sq(t2, t1); - - for(i = 1; i < 5; ++i) { - fe_sq(t2, t2); - } - - fe_mul(t1, t2, t1); - fe_sq(t2, t1); - - for(i = 1; i < 10; ++i) { - fe_sq(t2, t2); - } - - fe_mul(t2, t2, t1); - fe_sq(t3, t2); - - for(i = 1; i < 20; ++i) { - fe_sq(t3, t3); - } - - fe_mul(t2, t3, t2); - fe_sq(t2, t2); - - for(i = 1; i < 10; ++i) { - fe_sq(t2, t2); - } - - fe_mul(t1, t2, t1); - fe_sq(t2, t1); - - for(i = 1; i < 50; ++i) { - fe_sq(t2, t2); - } - - fe_mul(t2, t2, t1); - fe_sq(t3, t2); - - for(i = 1; i < 100; ++i) { - fe_sq(t3, t3); - } - - fe_mul(t2, t3, t2); - fe_sq(t2, t2); - - for(i = 1; i < 50; ++i) { - fe_sq(t2, t2); - } - - fe_mul(t1, t2, t1); - fe_sq(t1, t1); - - for(i = 1; i < 5; ++i) { - fe_sq(t1, t1); - } - - fe_mul(out, t1, t0); -} - - - -/* - return 1 if f is in {1,3,5,...,q-2} - return 0 if f is in {0,2,4,...,q-1} - - Preconditions: - |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. -*/ - -int fe_isnegative(const fe f) { - unsigned char s[32]; - - fe_tobytes(s, f); - - return s[0] & 1; -} - - - -/* - return 1 if f == 0 - return 0 if f != 0 - - Preconditions: - |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. -*/ - -int fe_isnonzero(const fe f) { - unsigned char s[32]; - unsigned char r; - - fe_tobytes(s, f); - - r = s[0]; -#define F(i) r |= s[i] - F(1); - F(2); - F(3); - F(4); - F(5); - F(6); - F(7); - F(8); - F(9); - F(10); - F(11); - F(12); - F(13); - F(14); - F(15); - F(16); - F(17); - F(18); - F(19); - F(20); - F(21); - F(22); - F(23); - F(24); - F(25); - F(26); - F(27); - F(28); - F(29); - F(30); - F(31); -#undef F - - return r != 0; -} - - - -/* - h = f * g - Can overlap h with f or g. - - Preconditions: - |f| bounded by 1.65*2^26,1.65*2^25,1.65*2^26,1.65*2^25,etc. - |g| bounded by 1.65*2^26,1.65*2^25,1.65*2^26,1.65*2^25,etc. - - Postconditions: - |h| bounded by 1.01*2^25,1.01*2^24,1.01*2^25,1.01*2^24,etc. - */ - -/* -Notes on implementation strategy: - -Using schoolbook multiplication. -Karatsuba would save a little in some cost models. - -Most multiplications by 2 and 19 are 32-bit precomputations; -cheaper than 64-bit postcomputations. - -There is one remaining multiplication by 19 in the carry chain; -one *19 precomputation can be merged into this, -but the resulting data flow is considerably less clean. - -There are 12 carries below. -10 of them are 2-way parallelizable and vectorizable. -Can get away with 11 carries, but then data flow is much deeper. - -With tighter constraints on inputs can squeeze carries into int32. -*/ - -void fe_mul(fe h, const fe f, const fe g) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; - int32_t g0 = g[0]; - int32_t g1 = g[1]; - int32_t g2 = g[2]; - int32_t g3 = g[3]; - int32_t g4 = g[4]; - int32_t g5 = g[5]; - int32_t g6 = g[6]; - int32_t g7 = g[7]; - int32_t g8 = g[8]; - int32_t g9 = g[9]; - int32_t g1_19 = 19 * g1; /* 1.959375*2^29 */ - int32_t g2_19 = 19 * g2; /* 1.959375*2^30; still ok */ - int32_t g3_19 = 19 * g3; - int32_t g4_19 = 19 * g4; - int32_t g5_19 = 19 * g5; - int32_t g6_19 = 19 * g6; - int32_t g7_19 = 19 * g7; - int32_t g8_19 = 19 * g8; - int32_t g9_19 = 19 * g9; - int32_t f1_2 = 2 * f1; - int32_t f3_2 = 2 * f3; - int32_t f5_2 = 2 * f5; - int32_t f7_2 = 2 * f7; - int32_t f9_2 = 2 * f9; - int64_t f0g0 = f0 * (int64_t) g0; - int64_t f0g1 = f0 * (int64_t) g1; - int64_t f0g2 = f0 * (int64_t) g2; - int64_t f0g3 = f0 * (int64_t) g3; - int64_t f0g4 = f0 * (int64_t) g4; - int64_t f0g5 = f0 * (int64_t) g5; - int64_t f0g6 = f0 * (int64_t) g6; - int64_t f0g7 = f0 * (int64_t) g7; - int64_t f0g8 = f0 * (int64_t) g8; - int64_t f0g9 = f0 * (int64_t) g9; - int64_t f1g0 = f1 * (int64_t) g0; - int64_t f1g1_2 = f1_2 * (int64_t) g1; - int64_t f1g2 = f1 * (int64_t) g2; - int64_t f1g3_2 = f1_2 * (int64_t) g3; - int64_t f1g4 = f1 * (int64_t) g4; - int64_t f1g5_2 = f1_2 * (int64_t) g5; - int64_t f1g6 = f1 * (int64_t) g6; - int64_t f1g7_2 = f1_2 * (int64_t) g7; - int64_t f1g8 = f1 * (int64_t) g8; - int64_t f1g9_38 = f1_2 * (int64_t) g9_19; - int64_t f2g0 = f2 * (int64_t) g0; - int64_t f2g1 = f2 * (int64_t) g1; - int64_t f2g2 = f2 * (int64_t) g2; - int64_t f2g3 = f2 * (int64_t) g3; - int64_t f2g4 = f2 * (int64_t) g4; - int64_t f2g5 = f2 * (int64_t) g5; - int64_t f2g6 = f2 * (int64_t) g6; - int64_t f2g7 = f2 * (int64_t) g7; - int64_t f2g8_19 = f2 * (int64_t) g8_19; - int64_t f2g9_19 = f2 * (int64_t) g9_19; - int64_t f3g0 = f3 * (int64_t) g0; - int64_t f3g1_2 = f3_2 * (int64_t) g1; - int64_t f3g2 = f3 * (int64_t) g2; - int64_t f3g3_2 = f3_2 * (int64_t) g3; - int64_t f3g4 = f3 * (int64_t) g4; - int64_t f3g5_2 = f3_2 * (int64_t) g5; - int64_t f3g6 = f3 * (int64_t) g6; - int64_t f3g7_38 = f3_2 * (int64_t) g7_19; - int64_t f3g8_19 = f3 * (int64_t) g8_19; - int64_t f3g9_38 = f3_2 * (int64_t) g9_19; - int64_t f4g0 = f4 * (int64_t) g0; - int64_t f4g1 = f4 * (int64_t) g1; - int64_t f4g2 = f4 * (int64_t) g2; - int64_t f4g3 = f4 * (int64_t) g3; - int64_t f4g4 = f4 * (int64_t) g4; - int64_t f4g5 = f4 * (int64_t) g5; - int64_t f4g6_19 = f4 * (int64_t) g6_19; - int64_t f4g7_19 = f4 * (int64_t) g7_19; - int64_t f4g8_19 = f4 * (int64_t) g8_19; - int64_t f4g9_19 = f4 * (int64_t) g9_19; - int64_t f5g0 = f5 * (int64_t) g0; - int64_t f5g1_2 = f5_2 * (int64_t) g1; - int64_t f5g2 = f5 * (int64_t) g2; - int64_t f5g3_2 = f5_2 * (int64_t) g3; - int64_t f5g4 = f5 * (int64_t) g4; - int64_t f5g5_38 = f5_2 * (int64_t) g5_19; - int64_t f5g6_19 = f5 * (int64_t) g6_19; - int64_t f5g7_38 = f5_2 * (int64_t) g7_19; - int64_t f5g8_19 = f5 * (int64_t) g8_19; - int64_t f5g9_38 = f5_2 * (int64_t) g9_19; - int64_t f6g0 = f6 * (int64_t) g0; - int64_t f6g1 = f6 * (int64_t) g1; - int64_t f6g2 = f6 * (int64_t) g2; - int64_t f6g3 = f6 * (int64_t) g3; - int64_t f6g4_19 = f6 * (int64_t) g4_19; - int64_t f6g5_19 = f6 * (int64_t) g5_19; - int64_t f6g6_19 = f6 * (int64_t) g6_19; - int64_t f6g7_19 = f6 * (int64_t) g7_19; - int64_t f6g8_19 = f6 * (int64_t) g8_19; - int64_t f6g9_19 = f6 * (int64_t) g9_19; - int64_t f7g0 = f7 * (int64_t) g0; - int64_t f7g1_2 = f7_2 * (int64_t) g1; - int64_t f7g2 = f7 * (int64_t) g2; - int64_t f7g3_38 = f7_2 * (int64_t) g3_19; - int64_t f7g4_19 = f7 * (int64_t) g4_19; - int64_t f7g5_38 = f7_2 * (int64_t) g5_19; - int64_t f7g6_19 = f7 * (int64_t) g6_19; - int64_t f7g7_38 = f7_2 * (int64_t) g7_19; - int64_t f7g8_19 = f7 * (int64_t) g8_19; - int64_t f7g9_38 = f7_2 * (int64_t) g9_19; - int64_t f8g0 = f8 * (int64_t) g0; - int64_t f8g1 = f8 * (int64_t) g1; - int64_t f8g2_19 = f8 * (int64_t) g2_19; - int64_t f8g3_19 = f8 * (int64_t) g3_19; - int64_t f8g4_19 = f8 * (int64_t) g4_19; - int64_t f8g5_19 = f8 * (int64_t) g5_19; - int64_t f8g6_19 = f8 * (int64_t) g6_19; - int64_t f8g7_19 = f8 * (int64_t) g7_19; - int64_t f8g8_19 = f8 * (int64_t) g8_19; - int64_t f8g9_19 = f8 * (int64_t) g9_19; - int64_t f9g0 = f9 * (int64_t) g0; - int64_t f9g1_38 = f9_2 * (int64_t) g1_19; - int64_t f9g2_19 = f9 * (int64_t) g2_19; - int64_t f9g3_38 = f9_2 * (int64_t) g3_19; - int64_t f9g4_19 = f9 * (int64_t) g4_19; - int64_t f9g5_38 = f9_2 * (int64_t) g5_19; - int64_t f9g6_19 = f9 * (int64_t) g6_19; - int64_t f9g7_38 = f9_2 * (int64_t) g7_19; - int64_t f9g8_19 = f9 * (int64_t) g8_19; - int64_t f9g9_38 = f9_2 * (int64_t) g9_19; - int64_t h0 = f0g0 + f1g9_38 + f2g8_19 + f3g7_38 + f4g6_19 + f5g5_38 + f6g4_19 + f7g3_38 + f8g2_19 + f9g1_38; - int64_t h1 = f0g1 + f1g0 + f2g9_19 + f3g8_19 + f4g7_19 + f5g6_19 + f6g5_19 + f7g4_19 + f8g3_19 + f9g2_19; - int64_t h2 = f0g2 + f1g1_2 + f2g0 + f3g9_38 + f4g8_19 + f5g7_38 + f6g6_19 + f7g5_38 + f8g4_19 + f9g3_38; - int64_t h3 = f0g3 + f1g2 + f2g1 + f3g0 + f4g9_19 + f5g8_19 + f6g7_19 + f7g6_19 + f8g5_19 + f9g4_19; - int64_t h4 = f0g4 + f1g3_2 + f2g2 + f3g1_2 + f4g0 + f5g9_38 + f6g8_19 + f7g7_38 + f8g6_19 + f9g5_38; - int64_t h5 = f0g5 + f1g4 + f2g3 + f3g2 + f4g1 + f5g0 + f6g9_19 + f7g8_19 + f8g7_19 + f9g6_19; - int64_t h6 = f0g6 + f1g5_2 + f2g4 + f3g3_2 + f4g2 + f5g1_2 + f6g0 + f7g9_38 + f8g8_19 + f9g7_38; - int64_t h7 = f0g7 + f1g6 + f2g5 + f3g4 + f4g3 + f5g2 + f6g1 + f7g0 + f8g9_19 + f9g8_19; - int64_t h8 = f0g8 + f1g7_2 + f2g6 + f3g5_2 + f4g4 + f5g3_2 + f6g2 + f7g1_2 + f8g0 + f9g9_38; - int64_t h9 = f0g9 + f1g8 + f2g7 + f3g6 + f4g5 + f5g4 + f6g3 + f7g2 + f8g1 + f9g0 ; - int64_t carry0; - int64_t carry1; - int64_t carry2; - int64_t carry3; - int64_t carry4; - int64_t carry5; - int64_t carry6; - int64_t carry7; - int64_t carry8; - int64_t carry9; - - carry0 = (h0 + (1L << 25)) >> 26; - h1 += carry0; - h0 -= shl64(carry0, 26); - carry4 = (h4 + (1L << 25)) >> 26; - h5 += carry4; - h4 -= shl64(carry4, 26); - - carry1 = (h1 + (1L << 24)) >> 25; - h2 += carry1; - h1 -= shl64(carry1, 25); - carry5 = (h5 + (1L << 24)) >> 25; - h6 += carry5; - h5 -= shl64(carry5, 25); - - carry2 = (h2 + (1L << 25)) >> 26; - h3 += carry2; - h2 -= shl64(carry2, 26); - carry6 = (h6 + (1L << 25)) >> 26; - h7 += carry6; - h6 -= shl64(carry6, 26); - - carry3 = (h3 + (1L << 24)) >> 25; - h4 += carry3; - h3 -= shl64(carry3, 25); - carry7 = (h7 + (1L << 24)) >> 25; - h8 += carry7; - h7 -= shl64(carry7, 25); - - carry4 = (h4 + (1L << 25)) >> 26; - h5 += carry4; - h4 -= shl64(carry4, 26); - carry8 = (h8 + (1L << 25)) >> 26; - h9 += carry8; - h8 -= shl64(carry8, 26); - - carry9 = (h9 + (1L << 24)) >> 25; - h0 += carry9 * 19; - h9 -= shl64(carry9, 25); - - carry0 = (h0 + (1L << 25)) >> 26; - h1 += carry0; - h0 -= shl64(carry0, 26); - - h[0] = (int32_t) h0; - h[1] = (int32_t) h1; - h[2] = (int32_t) h2; - h[3] = (int32_t) h3; - h[4] = (int32_t) h4; - h[5] = (int32_t) h5; - h[6] = (int32_t) h6; - h[7] = (int32_t) h7; - h[8] = (int32_t) h8; - h[9] = (int32_t) h9; -} - - -/* -h = f * 121666 -Can overlap h with f. - -Preconditions: - |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. - -Postconditions: - |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. -*/ - -void fe_mul121666(fe h, fe f) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; - int64_t h0 = f0 * (int64_t) 121666; - int64_t h1 = f1 * (int64_t) 121666; - int64_t h2 = f2 * (int64_t) 121666; - int64_t h3 = f3 * (int64_t) 121666; - int64_t h4 = f4 * (int64_t) 121666; - int64_t h5 = f5 * (int64_t) 121666; - int64_t h6 = f6 * (int64_t) 121666; - int64_t h7 = f7 * (int64_t) 121666; - int64_t h8 = f8 * (int64_t) 121666; - int64_t h9 = f9 * (int64_t) 121666; - int64_t carry0; - int64_t carry1; - int64_t carry2; - int64_t carry3; - int64_t carry4; - int64_t carry5; - int64_t carry6; - int64_t carry7; - int64_t carry8; - int64_t carry9; - - carry9 = (h9 + (int64_t)(1 << 24)) >> 25; - h0 += carry9 * 19; - h9 -= shl64(carry9, 25); - carry1 = (h1 + (int64_t)(1 << 24)) >> 25; - h2 += carry1; - h1 -= shl64(carry1, 25); - carry3 = (h3 + (int64_t)(1 << 24)) >> 25; - h4 += carry3; - h3 -= shl64(carry3, 25); - carry5 = (h5 + (int64_t)(1 << 24)) >> 25; - h6 += carry5; - h5 -= shl64(carry5, 25); - carry7 = (h7 + (int64_t)(1 << 24)) >> 25; - h8 += carry7; - h7 -= shl64(carry7, 25); - - carry0 = (h0 + (int64_t)(1 << 25)) >> 26; - h1 += carry0; - h0 -= shl64(carry0, 26); - carry2 = (h2 + (int64_t)(1 << 25)) >> 26; - h3 += carry2; - h2 -= shl64(carry2, 26); - carry4 = (h4 + (int64_t)(1 << 25)) >> 26; - h5 += carry4; - h4 -= shl64(carry4, 26); - carry6 = (h6 + (int64_t)(1 << 25)) >> 26; - h7 += carry6; - h6 -= shl64(carry6, 26); - carry8 = (h8 + (int64_t)(1 << 25)) >> 26; - h9 += carry8; - h8 -= shl64(carry8, 26); - - h[0] = h0; - h[1] = h1; - h[2] = h2; - h[3] = h3; - h[4] = h4; - h[5] = h5; - h[6] = h6; - h[7] = h7; - h[8] = h8; - h[9] = h9; -} - - -/* -h = -f - -Preconditions: - |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. - -Postconditions: - |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. -*/ - -void fe_neg(fe h, const fe f) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; - int32_t h0 = -f0; - int32_t h1 = -f1; - int32_t h2 = -f2; - int32_t h3 = -f3; - int32_t h4 = -f4; - int32_t h5 = -f5; - int32_t h6 = -f6; - int32_t h7 = -f7; - int32_t h8 = -f8; - int32_t h9 = -f9; - - h[0] = h0; - h[1] = h1; - h[2] = h2; - h[3] = h3; - h[4] = h4; - h[5] = h5; - h[6] = h6; - h[7] = h7; - h[8] = h8; - h[9] = h9; -} - - -void fe_pow22523(fe out, const fe z) { - fe t0; - fe t1; - fe t2; - int i; - fe_sq(t0, z); - - for(i = 1; i < 1; ++i) { - fe_sq(t0, t0); - } - - fe_sq(t1, t0); - - for(i = 1; i < 2; ++i) { - fe_sq(t1, t1); - } - - fe_mul(t1, z, t1); - fe_mul(t0, t0, t1); - fe_sq(t0, t0); - - for(i = 1; i < 1; ++i) { - fe_sq(t0, t0); - } - - fe_mul(t0, t1, t0); - fe_sq(t1, t0); - - for(i = 1; i < 5; ++i) { - fe_sq(t1, t1); - } - - fe_mul(t0, t1, t0); - fe_sq(t1, t0); - - for(i = 1; i < 10; ++i) { - fe_sq(t1, t1); - } - - fe_mul(t1, t1, t0); - fe_sq(t2, t1); - - for(i = 1; i < 20; ++i) { - fe_sq(t2, t2); - } - - fe_mul(t1, t2, t1); - fe_sq(t1, t1); - - for(i = 1; i < 10; ++i) { - fe_sq(t1, t1); - } - - fe_mul(t0, t1, t0); - fe_sq(t1, t0); - - for(i = 1; i < 50; ++i) { - fe_sq(t1, t1); - } - - fe_mul(t1, t1, t0); - fe_sq(t2, t1); - - for(i = 1; i < 100; ++i) { - fe_sq(t2, t2); - } - - fe_mul(t1, t2, t1); - fe_sq(t1, t1); - - for(i = 1; i < 50; ++i) { - fe_sq(t1, t1); - } - - fe_mul(t0, t1, t0); - fe_sq(t0, t0); - - for(i = 1; i < 2; ++i) { - fe_sq(t0, t0); - } - - fe_mul(out, t0, z); - return; -} - - -/* -h = f * f -Can overlap h with f. - -Preconditions: - |f| bounded by 1.65*2^26,1.65*2^25,1.65*2^26,1.65*2^25,etc. - -Postconditions: - |h| bounded by 1.01*2^25,1.01*2^24,1.01*2^25,1.01*2^24,etc. -*/ - -/* -See fe_mul.c for discussion of implementation strategy. -*/ - -void fe_sq(fe h, const fe f) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; - int32_t f0_2 = 2 * f0; - int32_t f1_2 = 2 * f1; - int32_t f2_2 = 2 * f2; - int32_t f3_2 = 2 * f3; - int32_t f4_2 = 2 * f4; - int32_t f5_2 = 2 * f5; - int32_t f6_2 = 2 * f6; - int32_t f7_2 = 2 * f7; - int32_t f5_38 = 38 * f5; /* 1.959375*2^30 */ - int32_t f6_19 = 19 * f6; /* 1.959375*2^30 */ - int32_t f7_38 = 38 * f7; /* 1.959375*2^30 */ - int32_t f8_19 = 19 * f8; /* 1.959375*2^30 */ - int32_t f9_38 = 38 * f9; /* 1.959375*2^30 */ - int64_t f0f0 = f0 * (int64_t) f0; - int64_t f0f1_2 = f0_2 * (int64_t) f1; - int64_t f0f2_2 = f0_2 * (int64_t) f2; - int64_t f0f3_2 = f0_2 * (int64_t) f3; - int64_t f0f4_2 = f0_2 * (int64_t) f4; - int64_t f0f5_2 = f0_2 * (int64_t) f5; - int64_t f0f6_2 = f0_2 * (int64_t) f6; - int64_t f0f7_2 = f0_2 * (int64_t) f7; - int64_t f0f8_2 = f0_2 * (int64_t) f8; - int64_t f0f9_2 = f0_2 * (int64_t) f9; - int64_t f1f1_2 = f1_2 * (int64_t) f1; - int64_t f1f2_2 = f1_2 * (int64_t) f2; - int64_t f1f3_4 = f1_2 * (int64_t) f3_2; - int64_t f1f4_2 = f1_2 * (int64_t) f4; - int64_t f1f5_4 = f1_2 * (int64_t) f5_2; - int64_t f1f6_2 = f1_2 * (int64_t) f6; - int64_t f1f7_4 = f1_2 * (int64_t) f7_2; - int64_t f1f8_2 = f1_2 * (int64_t) f8; - int64_t f1f9_76 = f1_2 * (int64_t) f9_38; - int64_t f2f2 = f2 * (int64_t) f2; - int64_t f2f3_2 = f2_2 * (int64_t) f3; - int64_t f2f4_2 = f2_2 * (int64_t) f4; - int64_t f2f5_2 = f2_2 * (int64_t) f5; - int64_t f2f6_2 = f2_2 * (int64_t) f6; - int64_t f2f7_2 = f2_2 * (int64_t) f7; - int64_t f2f8_38 = f2_2 * (int64_t) f8_19; - int64_t f2f9_38 = f2 * (int64_t) f9_38; - int64_t f3f3_2 = f3_2 * (int64_t) f3; - int64_t f3f4_2 = f3_2 * (int64_t) f4; - int64_t f3f5_4 = f3_2 * (int64_t) f5_2; - int64_t f3f6_2 = f3_2 * (int64_t) f6; - int64_t f3f7_76 = f3_2 * (int64_t) f7_38; - int64_t f3f8_38 = f3_2 * (int64_t) f8_19; - int64_t f3f9_76 = f3_2 * (int64_t) f9_38; - int64_t f4f4 = f4 * (int64_t) f4; - int64_t f4f5_2 = f4_2 * (int64_t) f5; - int64_t f4f6_38 = f4_2 * (int64_t) f6_19; - int64_t f4f7_38 = f4 * (int64_t) f7_38; - int64_t f4f8_38 = f4_2 * (int64_t) f8_19; - int64_t f4f9_38 = f4 * (int64_t) f9_38; - int64_t f5f5_38 = f5 * (int64_t) f5_38; - int64_t f5f6_38 = f5_2 * (int64_t) f6_19; - int64_t f5f7_76 = f5_2 * (int64_t) f7_38; - int64_t f5f8_38 = f5_2 * (int64_t) f8_19; - int64_t f5f9_76 = f5_2 * (int64_t) f9_38; - int64_t f6f6_19 = f6 * (int64_t) f6_19; - int64_t f6f7_38 = f6 * (int64_t) f7_38; - int64_t f6f8_38 = f6_2 * (int64_t) f8_19; - int64_t f6f9_38 = f6 * (int64_t) f9_38; - int64_t f7f7_38 = f7 * (int64_t) f7_38; - int64_t f7f8_38 = f7_2 * (int64_t) f8_19; - int64_t f7f9_76 = f7_2 * (int64_t) f9_38; - int64_t f8f8_19 = f8 * (int64_t) f8_19; - int64_t f8f9_38 = f8 * (int64_t) f9_38; - int64_t f9f9_38 = f9 * (int64_t) f9_38; - int64_t h0 = f0f0 + f1f9_76 + f2f8_38 + f3f7_76 + f4f6_38 + f5f5_38; - int64_t h1 = f0f1_2 + f2f9_38 + f3f8_38 + f4f7_38 + f5f6_38; - int64_t h2 = f0f2_2 + f1f1_2 + f3f9_76 + f4f8_38 + f5f7_76 + f6f6_19; - int64_t h3 = f0f3_2 + f1f2_2 + f4f9_38 + f5f8_38 + f6f7_38; - int64_t h4 = f0f4_2 + f1f3_4 + f2f2 + f5f9_76 + f6f8_38 + f7f7_38; - int64_t h5 = f0f5_2 + f1f4_2 + f2f3_2 + f6f9_38 + f7f8_38; - int64_t h6 = f0f6_2 + f1f5_4 + f2f4_2 + f3f3_2 + f7f9_76 + f8f8_19; - int64_t h7 = f0f7_2 + f1f6_2 + f2f5_2 + f3f4_2 + f8f9_38; - int64_t h8 = f0f8_2 + f1f7_4 + f2f6_2 + f3f5_4 + f4f4 + f9f9_38; - int64_t h9 = f0f9_2 + f1f8_2 + f2f7_2 + f3f6_2 + f4f5_2; - int64_t carry0; - int64_t carry1; - int64_t carry2; - int64_t carry3; - int64_t carry4; - int64_t carry5; - int64_t carry6; - int64_t carry7; - int64_t carry8; - int64_t carry9; - carry0 = (h0 + (1L << 25)) >> 26; - h1 += carry0; - h0 -= shl64(carry0, 26); - carry4 = (h4 + (1L << 25)) >> 26; - h5 += carry4; - h4 -= shl64(carry4, 26); - carry1 = (h1 + (1L << 24)) >> 25; - h2 += carry1; - h1 -= shl64(carry1, 25); - carry5 = (h5 + (1L << 24)) >> 25; - h6 += carry5; - h5 -= shl64(carry5, 25); - carry2 = (h2 + (1L << 25)) >> 26; - h3 += carry2; - h2 -= shl64(carry2, 26); - carry6 = (h6 + (1L << 25)) >> 26; - h7 += carry6; - h6 -= shl64(carry6, 26); - carry3 = (h3 + (1L << 24)) >> 25; - h4 += carry3; - h3 -= shl64(carry3, 25); - carry7 = (h7 + (1L << 24)) >> 25; - h8 += carry7; - h7 -= shl64(carry7, 25); - carry4 = (h4 + (1L << 25)) >> 26; - h5 += carry4; - h4 -= shl64(carry4, 26); - carry8 = (h8 + (1L << 25)) >> 26; - h9 += carry8; - h8 -= shl64(carry8, 26); - carry9 = (h9 + (1L << 24)) >> 25; - h0 += carry9 * 19; - h9 -= shl64(carry9, 25); - carry0 = (h0 + (1L << 25)) >> 26; - h1 += carry0; - h0 -= shl64(carry0, 26); - h[0] = (int32_t) h0; - h[1] = (int32_t) h1; - h[2] = (int32_t) h2; - h[3] = (int32_t) h3; - h[4] = (int32_t) h4; - h[5] = (int32_t) h5; - h[6] = (int32_t) h6; - h[7] = (int32_t) h7; - h[8] = (int32_t) h8; - h[9] = (int32_t) h9; -} - - -/* -h = 2 * f * f -Can overlap h with f. - -Preconditions: - |f| bounded by 1.65*2^26,1.65*2^25,1.65*2^26,1.65*2^25,etc. - -Postconditions: - |h| bounded by 1.01*2^25,1.01*2^24,1.01*2^25,1.01*2^24,etc. -*/ - -/* -See fe_mul.c for discussion of implementation strategy. -*/ - -void fe_sq2(fe h, const fe f) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; - int32_t f0_2 = 2 * f0; - int32_t f1_2 = 2 * f1; - int32_t f2_2 = 2 * f2; - int32_t f3_2 = 2 * f3; - int32_t f4_2 = 2 * f4; - int32_t f5_2 = 2 * f5; - int32_t f6_2 = 2 * f6; - int32_t f7_2 = 2 * f7; - int32_t f5_38 = 38 * f5; /* 1.959375*2^30 */ - int32_t f6_19 = 19 * f6; /* 1.959375*2^30 */ - int32_t f7_38 = 38 * f7; /* 1.959375*2^30 */ - int32_t f8_19 = 19 * f8; /* 1.959375*2^30 */ - int32_t f9_38 = 38 * f9; /* 1.959375*2^30 */ - int64_t f0f0 = f0 * (int64_t) f0; - int64_t f0f1_2 = f0_2 * (int64_t) f1; - int64_t f0f2_2 = f0_2 * (int64_t) f2; - int64_t f0f3_2 = f0_2 * (int64_t) f3; - int64_t f0f4_2 = f0_2 * (int64_t) f4; - int64_t f0f5_2 = f0_2 * (int64_t) f5; - int64_t f0f6_2 = f0_2 * (int64_t) f6; - int64_t f0f7_2 = f0_2 * (int64_t) f7; - int64_t f0f8_2 = f0_2 * (int64_t) f8; - int64_t f0f9_2 = f0_2 * (int64_t) f9; - int64_t f1f1_2 = f1_2 * (int64_t) f1; - int64_t f1f2_2 = f1_2 * (int64_t) f2; - int64_t f1f3_4 = f1_2 * (int64_t) f3_2; - int64_t f1f4_2 = f1_2 * (int64_t) f4; - int64_t f1f5_4 = f1_2 * (int64_t) f5_2; - int64_t f1f6_2 = f1_2 * (int64_t) f6; - int64_t f1f7_4 = f1_2 * (int64_t) f7_2; - int64_t f1f8_2 = f1_2 * (int64_t) f8; - int64_t f1f9_76 = f1_2 * (int64_t) f9_38; - int64_t f2f2 = f2 * (int64_t) f2; - int64_t f2f3_2 = f2_2 * (int64_t) f3; - int64_t f2f4_2 = f2_2 * (int64_t) f4; - int64_t f2f5_2 = f2_2 * (int64_t) f5; - int64_t f2f6_2 = f2_2 * (int64_t) f6; - int64_t f2f7_2 = f2_2 * (int64_t) f7; - int64_t f2f8_38 = f2_2 * (int64_t) f8_19; - int64_t f2f9_38 = f2 * (int64_t) f9_38; - int64_t f3f3_2 = f3_2 * (int64_t) f3; - int64_t f3f4_2 = f3_2 * (int64_t) f4; - int64_t f3f5_4 = f3_2 * (int64_t) f5_2; - int64_t f3f6_2 = f3_2 * (int64_t) f6; - int64_t f3f7_76 = f3_2 * (int64_t) f7_38; - int64_t f3f8_38 = f3_2 * (int64_t) f8_19; - int64_t f3f9_76 = f3_2 * (int64_t) f9_38; - int64_t f4f4 = f4 * (int64_t) f4; - int64_t f4f5_2 = f4_2 * (int64_t) f5; - int64_t f4f6_38 = f4_2 * (int64_t) f6_19; - int64_t f4f7_38 = f4 * (int64_t) f7_38; - int64_t f4f8_38 = f4_2 * (int64_t) f8_19; - int64_t f4f9_38 = f4 * (int64_t) f9_38; - int64_t f5f5_38 = f5 * (int64_t) f5_38; - int64_t f5f6_38 = f5_2 * (int64_t) f6_19; - int64_t f5f7_76 = f5_2 * (int64_t) f7_38; - int64_t f5f8_38 = f5_2 * (int64_t) f8_19; - int64_t f5f9_76 = f5_2 * (int64_t) f9_38; - int64_t f6f6_19 = f6 * (int64_t) f6_19; - int64_t f6f7_38 = f6 * (int64_t) f7_38; - int64_t f6f8_38 = f6_2 * (int64_t) f8_19; - int64_t f6f9_38 = f6 * (int64_t) f9_38; - int64_t f7f7_38 = f7 * (int64_t) f7_38; - int64_t f7f8_38 = f7_2 * (int64_t) f8_19; - int64_t f7f9_76 = f7_2 * (int64_t) f9_38; - int64_t f8f8_19 = f8 * (int64_t) f8_19; - int64_t f8f9_38 = f8 * (int64_t) f9_38; - int64_t f9f9_38 = f9 * (int64_t) f9_38; - int64_t h0 = f0f0 + f1f9_76 + f2f8_38 + f3f7_76 + f4f6_38 + f5f5_38; - int64_t h1 = f0f1_2 + f2f9_38 + f3f8_38 + f4f7_38 + f5f6_38; - int64_t h2 = f0f2_2 + f1f1_2 + f3f9_76 + f4f8_38 + f5f7_76 + f6f6_19; - int64_t h3 = f0f3_2 + f1f2_2 + f4f9_38 + f5f8_38 + f6f7_38; - int64_t h4 = f0f4_2 + f1f3_4 + f2f2 + f5f9_76 + f6f8_38 + f7f7_38; - int64_t h5 = f0f5_2 + f1f4_2 + f2f3_2 + f6f9_38 + f7f8_38; - int64_t h6 = f0f6_2 + f1f5_4 + f2f4_2 + f3f3_2 + f7f9_76 + f8f8_19; - int64_t h7 = f0f7_2 + f1f6_2 + f2f5_2 + f3f4_2 + f8f9_38; - int64_t h8 = f0f8_2 + f1f7_4 + f2f6_2 + f3f5_4 + f4f4 + f9f9_38; - int64_t h9 = f0f9_2 + f1f8_2 + f2f7_2 + f3f6_2 + f4f5_2; - int64_t carry0; - int64_t carry1; - int64_t carry2; - int64_t carry3; - int64_t carry4; - int64_t carry5; - int64_t carry6; - int64_t carry7; - int64_t carry8; - int64_t carry9; - h0 += h0; - h1 += h1; - h2 += h2; - h3 += h3; - h4 += h4; - h5 += h5; - h6 += h6; - h7 += h7; - h8 += h8; - h9 += h9; - carry0 = (h0 + (1L << 25)) >> 26; - h1 += carry0; - h0 -= shl64(carry0, 26); - carry4 = (h4 + (1L << 25)) >> 26; - h5 += carry4; - h4 -= shl64(carry4, 26); - carry1 = (h1 + (1L << 24)) >> 25; - h2 += carry1; - h1 -= shl64(carry1, 25); - carry5 = (h5 + (1L << 24)) >> 25; - h6 += carry5; - h5 -= shl64(carry5, 25); - carry2 = (h2 + (1L << 25)) >> 26; - h3 += carry2; - h2 -= shl64(carry2, 26); - carry6 = (h6 + (1L << 25)) >> 26; - h7 += carry6; - h6 -= shl64(carry6, 26); - carry3 = (h3 + (1L << 24)) >> 25; - h4 += carry3; - h3 -= shl64(carry3, 25); - carry7 = (h7 + (1L << 24)) >> 25; - h8 += carry7; - h7 -= shl64(carry7, 25); - carry4 = (h4 + (1L << 25)) >> 26; - h5 += carry4; - h4 -= shl64(carry4, 26); - carry8 = (h8 + (1L << 25)) >> 26; - h9 += carry8; - h8 -= shl64(carry8, 26); - carry9 = (h9 + (1L << 24)) >> 25; - h0 += carry9 * 19; - h9 -= shl64(carry9, 25); - carry0 = (h0 + (1L << 25)) >> 26; - h1 += carry0; - h0 -= shl64(carry0, 26); - h[0] = (int32_t) h0; - h[1] = (int32_t) h1; - h[2] = (int32_t) h2; - h[3] = (int32_t) h3; - h[4] = (int32_t) h4; - h[5] = (int32_t) h5; - h[6] = (int32_t) h6; - h[7] = (int32_t) h7; - h[8] = (int32_t) h8; - h[9] = (int32_t) h9; -} - - -/* -h = f - g -Can overlap h with f or g. - -Preconditions: - |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. - |g| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. - -Postconditions: - |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. -*/ - -void fe_sub(fe h, const fe f, const fe g) { - int32_t f0 = f[0]; - int32_t f1 = f[1]; - int32_t f2 = f[2]; - int32_t f3 = f[3]; - int32_t f4 = f[4]; - int32_t f5 = f[5]; - int32_t f6 = f[6]; - int32_t f7 = f[7]; - int32_t f8 = f[8]; - int32_t f9 = f[9]; - int32_t g0 = g[0]; - int32_t g1 = g[1]; - int32_t g2 = g[2]; - int32_t g3 = g[3]; - int32_t g4 = g[4]; - int32_t g5 = g[5]; - int32_t g6 = g[6]; - int32_t g7 = g[7]; - int32_t g8 = g[8]; - int32_t g9 = g[9]; - int32_t h0 = f0 - g0; - int32_t h1 = f1 - g1; - int32_t h2 = f2 - g2; - int32_t h3 = f3 - g3; - int32_t h4 = f4 - g4; - int32_t h5 = f5 - g5; - int32_t h6 = f6 - g6; - int32_t h7 = f7 - g7; - int32_t h8 = f8 - g8; - int32_t h9 = f9 - g9; - - h[0] = h0; - h[1] = h1; - h[2] = h2; - h[3] = h3; - h[4] = h4; - h[5] = h5; - h[6] = h6; - h[7] = h7; - h[8] = h8; - h[9] = h9; -} - - - -/* -Preconditions: - |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. - -Write p=2^255-19; q=floor(h/p). -Basic claim: q = floor(2^(-255)(h + 19 2^(-25)h9 + 2^(-1))). - -Proof: - Have |h|<=p so |q|<=1 so |19^2 2^(-255) q|<1/4. - Also have |h-2^230 h9|<2^231 so |19 2^(-255)(h-2^230 h9)|<1/4. - - Write y=2^(-1)-19^2 2^(-255)q-19 2^(-255)(h-2^230 h9). - Then 0> 25; - q = (h0 + q) >> 26; - q = (h1 + q) >> 25; - q = (h2 + q) >> 26; - q = (h3 + q) >> 25; - q = (h4 + q) >> 26; - q = (h5 + q) >> 25; - q = (h6 + q) >> 26; - q = (h7 + q) >> 25; - q = (h8 + q) >> 26; - q = (h9 + q) >> 25; - /* Goal: Output h-(2^255-19)q, which is between 0 and 2^255-20. */ - h0 += 19 * q; - /* Goal: Output h-2^255 q, which is between 0 and 2^255-20. */ - carry0 = h0 >> 26; - h1 += carry0; - h0 -= shl32(carry0, 26); - carry1 = h1 >> 25; - h2 += carry1; - h1 -= shl32(carry1, 25); - carry2 = h2 >> 26; - h3 += carry2; - h2 -= shl32(carry2, 26); - carry3 = h3 >> 25; - h4 += carry3; - h3 -= shl32(carry3, 25); - carry4 = h4 >> 26; - h5 += carry4; - h4 -= shl32(carry4, 26); - carry5 = h5 >> 25; - h6 += carry5; - h5 -= shl32(carry5, 25); - carry6 = h6 >> 26; - h7 += carry6; - h6 -= shl32(carry6, 26); - carry7 = h7 >> 25; - h8 += carry7; - h7 -= shl32(carry7, 25); - carry8 = h8 >> 26; - h9 += carry8; - h8 -= shl32(carry8, 26); - carry9 = h9 >> 25; - h9 -= shl32(carry9, 25); - - /* h10 = carry9 */ - /* - Goal: Output h0+...+2^255 h10-2^255 q, which is between 0 and 2^255-20. - Have h0+...+2^230 h9 between 0 and 2^255-1; - evidently 2^255 h10-2^255 q = 0. - Goal: Output h0+...+2^230 h9. - */ - s[0] = (unsigned char)(h0 >> 0); - s[1] = (unsigned char)(h0 >> 8); - s[2] = (unsigned char)(h0 >> 16); - s[3] = (unsigned char)((h0 >> 24) | shl32(h1, 2)); - s[4] = (unsigned char)(h1 >> 6); - s[5] = (unsigned char)(h1 >> 14); - s[6] = (unsigned char)((h1 >> 22) | shl32(h2, 3)); - s[7] = (unsigned char)(h2 >> 5); - s[8] = (unsigned char)(h2 >> 13); - s[9] = (unsigned char)((h2 >> 21) | shl32(h3, 5)); - s[10] = (unsigned char)(h3 >> 3); - s[11] = (unsigned char)(h3 >> 11); - s[12] = (unsigned char)((h3 >> 19) | shl32(h4, 6)); - s[13] = (unsigned char)(h4 >> 2); - s[14] = (unsigned char)(h4 >> 10); - s[15] = (unsigned char)(h4 >> 18); - s[16] = (unsigned char)(h5 >> 0); - s[17] = (unsigned char)(h5 >> 8); - s[18] = (unsigned char)(h5 >> 16); - s[19] = (unsigned char)((h5 >> 24) | shl32(h6, 1)); - s[20] = (unsigned char)(h6 >> 7); - s[21] = (unsigned char)(h6 >> 15); - s[22] = (unsigned char)((h6 >> 23) | shl32(h7, 3)); - s[23] = (unsigned char)(h7 >> 5); - s[24] = (unsigned char)(h7 >> 13); - s[25] = (unsigned char)((h7 >> 21) | shl32(h8, 4)); - s[26] = (unsigned char)(h8 >> 4); - s[27] = (unsigned char)(h8 >> 12); - s[28] = (unsigned char)((h8 >> 20) | shl32(h9, 6)); - s[29] = (unsigned char)(h9 >> 2); - s[30] = (unsigned char)(h9 >> 10); - s[31] = (unsigned char)(h9 >> 18); -} diff --git a/src/ed25519/fe.h b/src/ed25519/fe.h deleted file mode 100644 index b4b62d2..0000000 --- a/src/ed25519/fe.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef FE_H -#define FE_H - -#include "fixedint.h" - - -/* - fe means field element. - Here the field is \Z/(2^255-19). - An element t, entries t[0]...t[9], represents the integer - t[0]+2^26 t[1]+2^51 t[2]+2^77 t[3]+2^102 t[4]+...+2^230 t[9]. - Bounds on each t[i] vary depending on context. -*/ - - -typedef int32_t fe[10]; - - -void fe_0(fe h); -void fe_1(fe h); - -void fe_frombytes(fe h, const unsigned char *s); -void fe_tobytes(unsigned char *s, const fe h); - -void fe_copy(fe h, const fe f); -int fe_isnegative(const fe f); -int fe_isnonzero(const fe f); -void fe_cmov(fe f, const fe g, unsigned int b); -void fe_cswap(fe f, fe g, unsigned int b); - -void fe_neg(fe h, const fe f); -void fe_add(fe h, const fe f, const fe g); -void fe_invert(fe out, const fe z); -void fe_sq(fe h, const fe f); -void fe_sq2(fe h, const fe f); -void fe_mul(fe h, const fe f, const fe g); -void fe_mul121666(fe h, fe f); -void fe_pow22523(fe out, const fe z); -void fe_sub(fe h, const fe f, const fe g); - -#endif diff --git a/src/ed25519/fixedint.h b/src/ed25519/fixedint.h deleted file mode 100644 index af031e9..0000000 --- a/src/ed25519/fixedint.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef TINC_FIXEDINT_H -#define TINC_FIXEDINT_H - -/* - Portable header to provide the 32 and 64 bits type. - - Not a compatible replacement for , do not blindly use it as such. -*/ - -#if ((defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined(__WATCOMC__) && (defined(_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_) || defined(__UINT_FAST64_TYPE__)) )) && !defined(FIXEDINT_H_INCLUDED) -#include -#define FIXEDINT_H_INCLUDED - -#if defined(__WATCOMC__) && __WATCOMC__ >= 1250 && !defined(UINT64_C) -#include -#define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX)) -#endif -#endif - - -#ifndef FIXEDINT_H_INCLUDED -#define FIXEDINT_H_INCLUDED - -/* (u)int32_t */ -#ifndef uint32_t -#if (ULONG_MAX == 0xffffffffUL) -typedef unsigned long uint32_t; -#elif (UINT_MAX == 0xffffffffUL) -typedef unsigned int uint32_t; -#elif (USHRT_MAX == 0xffffffffUL) -typedef unsigned short uint32_t; -#endif -#endif - - -#ifndef int32_t -#if (LONG_MAX == 0x7fffffffL) -typedef signed long int32_t; -#elif (INT_MAX == 0x7fffffffL) -typedef signed int int32_t; -#elif (SHRT_MAX == 0x7fffffffL) -typedef signed short int32_t; -#endif -#endif - - -/* (u)int64_t */ -#if (defined(__STDC__) && defined(__STDC_VERSION__) && __STDC__ && __STDC_VERSION__ >= 199901L) -typedef long long int64_t; -typedef unsigned long long uint64_t; - -#define UINT64_C(v) v ##ULL -#define INT64_C(v) v ##LL -#elif defined(__GNUC__) -__extension__ typedef long long int64_t; -__extension__ typedef unsigned long long uint64_t; - -#define UINT64_C(v) v ##ULL -#define INT64_C(v) v ##LL -#elif defined(__MWERKS__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) || defined(__APPLE_CC__) || defined(_LONG_LONG) || defined(_CRAYC) -typedef long long int64_t; -typedef unsigned long long uint64_t; - -#define UINT64_C(v) v ##ULL -#define INT64_C(v) v ##LL -#elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined(__BORLANDC__) && __BORLANDC__ > 0x460) || defined(__alpha) || defined(__DECC) -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; - -#define UINT64_C(v) v ##UI64 -#define INT64_C(v) v ##I64 -#endif -#endif - -static inline unsigned char shlu8(unsigned char a, uint32_t b) { - return a << b; -} - -static inline int32_t shl32(uint32_t a, uint32_t b) { - return a << b; -} - -static inline int64_t shl64(uint64_t a, uint32_t b) { - return a << b; -} - -static inline uint64_t shlu64(uint64_t a, uint32_t b) { - return a << b; -} - -#endif diff --git a/src/ed25519/ge.c b/src/ed25519/ge.c deleted file mode 100644 index ca8c39b..0000000 --- a/src/ed25519/ge.c +++ /dev/null @@ -1,467 +0,0 @@ -#include "ge.h" -#include "precomp_data.h" - - -/* -r = p + q -*/ - -void ge_add(ge_p1p1 *r, const ge_p3 *p, const ge_cached *q) { - fe t0; - fe_add(r->X, p->Y, p->X); - fe_sub(r->Y, p->Y, p->X); - fe_mul(r->Z, r->X, q->YplusX); - fe_mul(r->Y, r->Y, q->YminusX); - fe_mul(r->T, q->T2d, p->T); - fe_mul(r->X, p->Z, q->Z); - fe_add(t0, r->X, r->X); - fe_sub(r->X, r->Z, r->Y); - fe_add(r->Y, r->Z, r->Y); - fe_add(r->Z, t0, r->T); - fe_sub(r->T, t0, r->T); -} - - -static void slide(signed char *r, const unsigned char *a) { - int i; - int b; - int k; - - for(i = 0; i < 256; ++i) { - r[i] = 1 & (a[i >> 3] >> (i & 7)); - } - - for(i = 0; i < 256; ++i) - if(r[i]) { - for(b = 1; b <= 6 && i + b < 256; ++b) { - if(r[i + b]) { - if(r[i] + (r[i + b] << b) <= 15) { - r[i] += r[i + b] << b; - r[i + b] = 0; - } else if(r[i] - (r[i + b] << b) >= -15) { - r[i] -= r[i + b] << b; - - for(k = i + b; k < 256; ++k) { - if(!r[k]) { - r[k] = 1; - break; - } - - r[k] = 0; - } - } else { - break; - } - } - } - } -} - -/* -r = a * A + b * B -where a = a[0]+256*a[1]+...+256^31 a[31]. -and b = b[0]+256*b[1]+...+256^31 b[31]. -B is the Ed25519 base point (x,4/5) with x positive. -*/ - -void ge_double_scalarmult_vartime(ge_p2 *r, const unsigned char *a, const ge_p3 *A, const unsigned char *b) { - signed char aslide[256]; - signed char bslide[256]; - ge_cached Ai[8]; /* A,3A,5A,7A,9A,11A,13A,15A */ - ge_p1p1 t; - ge_p3 u; - ge_p3 A2; - int i; - slide(aslide, a); - slide(bslide, b); - ge_p3_to_cached(&Ai[0], A); - ge_p3_dbl(&t, A); - ge_p1p1_to_p3(&A2, &t); - ge_add(&t, &A2, &Ai[0]); - ge_p1p1_to_p3(&u, &t); - ge_p3_to_cached(&Ai[1], &u); - ge_add(&t, &A2, &Ai[1]); - ge_p1p1_to_p3(&u, &t); - ge_p3_to_cached(&Ai[2], &u); - ge_add(&t, &A2, &Ai[2]); - ge_p1p1_to_p3(&u, &t); - ge_p3_to_cached(&Ai[3], &u); - ge_add(&t, &A2, &Ai[3]); - ge_p1p1_to_p3(&u, &t); - ge_p3_to_cached(&Ai[4], &u); - ge_add(&t, &A2, &Ai[4]); - ge_p1p1_to_p3(&u, &t); - ge_p3_to_cached(&Ai[5], &u); - ge_add(&t, &A2, &Ai[5]); - ge_p1p1_to_p3(&u, &t); - ge_p3_to_cached(&Ai[6], &u); - ge_add(&t, &A2, &Ai[6]); - ge_p1p1_to_p3(&u, &t); - ge_p3_to_cached(&Ai[7], &u); - ge_p2_0(r); - - for(i = 255; i >= 0; --i) { - if(aslide[i] || bslide[i]) { - break; - } - } - - for(; i >= 0; --i) { - ge_p2_dbl(&t, r); - - if(aslide[i] > 0) { - ge_p1p1_to_p3(&u, &t); - ge_add(&t, &u, &Ai[aslide[i] / 2]); - } else if(aslide[i] < 0) { - ge_p1p1_to_p3(&u, &t); - ge_sub(&t, &u, &Ai[(-aslide[i]) / 2]); - } - - if(bslide[i] > 0) { - ge_p1p1_to_p3(&u, &t); - ge_madd(&t, &u, &Bi[bslide[i] / 2]); - } else if(bslide[i] < 0) { - ge_p1p1_to_p3(&u, &t); - ge_msub(&t, &u, &Bi[(-bslide[i]) / 2]); - } - - ge_p1p1_to_p2(r, &t); - } -} - - -static const fe d = { - -10913610, 13857413, -15372611, 6949391, 114729, -8787816, -6275908, -3247719, -18696448, -12055116 - }; - -static const fe sqrtm1 = { - -32595792, -7943725, 9377950, 3500415, 12389472, -272473, -25146209, -2005654, 326686, 11406482 - }; - -int ge_frombytes_negate_vartime(ge_p3 *h, const unsigned char *s) { - fe u; - fe v; - fe v3; - fe vxx; - fe check; - fe_frombytes(h->Y, s); - fe_1(h->Z); - fe_sq(u, h->Y); - fe_mul(v, u, d); - fe_sub(u, u, h->Z); /* u = y^2-1 */ - fe_add(v, v, h->Z); /* v = dy^2+1 */ - fe_sq(v3, v); - fe_mul(v3, v3, v); /* v3 = v^3 */ - fe_sq(h->X, v3); - fe_mul(h->X, h->X, v); - fe_mul(h->X, h->X, u); /* x = uv^7 */ - fe_pow22523(h->X, h->X); /* x = (uv^7)^((q-5)/8) */ - fe_mul(h->X, h->X, v3); - fe_mul(h->X, h->X, u); /* x = uv^3(uv^7)^((q-5)/8) */ - fe_sq(vxx, h->X); - fe_mul(vxx, vxx, v); - fe_sub(check, vxx, u); /* vx^2-u */ - - if(fe_isnonzero(check)) { - fe_add(check, vxx, u); /* vx^2+u */ - - if(fe_isnonzero(check)) { - return -1; - } - - fe_mul(h->X, h->X, sqrtm1); - } - - if(fe_isnegative(h->X) == (s[31] >> 7)) { - fe_neg(h->X, h->X); - } - - fe_mul(h->T, h->X, h->Y); - return 0; -} - - -/* -r = p + q -*/ - -void ge_madd(ge_p1p1 *r, const ge_p3 *p, const ge_precomp *q) { - fe t0; - fe_add(r->X, p->Y, p->X); - fe_sub(r->Y, p->Y, p->X); - fe_mul(r->Z, r->X, q->yplusx); - fe_mul(r->Y, r->Y, q->yminusx); - fe_mul(r->T, q->xy2d, p->T); - fe_add(t0, p->Z, p->Z); - fe_sub(r->X, r->Z, r->Y); - fe_add(r->Y, r->Z, r->Y); - fe_add(r->Z, t0, r->T); - fe_sub(r->T, t0, r->T); -} - - -/* -r = p - q -*/ - -void ge_msub(ge_p1p1 *r, const ge_p3 *p, const ge_precomp *q) { - fe t0; - - fe_add(r->X, p->Y, p->X); - fe_sub(r->Y, p->Y, p->X); - fe_mul(r->Z, r->X, q->yminusx); - fe_mul(r->Y, r->Y, q->yplusx); - fe_mul(r->T, q->xy2d, p->T); - fe_add(t0, p->Z, p->Z); - fe_sub(r->X, r->Z, r->Y); - fe_add(r->Y, r->Z, r->Y); - fe_sub(r->Z, t0, r->T); - fe_add(r->T, t0, r->T); -} - - -/* -r = p -*/ - -void ge_p1p1_to_p2(ge_p2 *r, const ge_p1p1 *p) { - fe_mul(r->X, p->X, p->T); - fe_mul(r->Y, p->Y, p->Z); - fe_mul(r->Z, p->Z, p->T); -} - - - -/* -r = p -*/ - -void ge_p1p1_to_p3(ge_p3 *r, const ge_p1p1 *p) { - fe_mul(r->X, p->X, p->T); - fe_mul(r->Y, p->Y, p->Z); - fe_mul(r->Z, p->Z, p->T); - fe_mul(r->T, p->X, p->Y); -} - - -void ge_p2_0(ge_p2 *h) { - fe_0(h->X); - fe_1(h->Y); - fe_1(h->Z); -} - - - -/* -r = 2 * p -*/ - -void ge_p2_dbl(ge_p1p1 *r, const ge_p2 *p) { - fe t0; - - fe_sq(r->X, p->X); - fe_sq(r->Z, p->Y); - fe_sq2(r->T, p->Z); - fe_add(r->Y, p->X, p->Y); - fe_sq(t0, r->Y); - fe_add(r->Y, r->Z, r->X); - fe_sub(r->Z, r->Z, r->X); - fe_sub(r->X, t0, r->Y); - fe_sub(r->T, r->T, r->Z); -} - - -void ge_p3_0(ge_p3 *h) { - fe_0(h->X); - fe_1(h->Y); - fe_1(h->Z); - fe_0(h->T); -} - - -/* -r = 2 * p -*/ - -void ge_p3_dbl(ge_p1p1 *r, const ge_p3 *p) { - ge_p2 q; - ge_p3_to_p2(&q, p); - ge_p2_dbl(r, &q); -} - - - -/* -r = p -*/ - -static const fe d2 = { - -21827239, -5839606, -30745221, 13898782, 229458, 15978800, -12551817, -6495438, 29715968, 9444199 - }; - -void ge_p3_to_cached(ge_cached *r, const ge_p3 *p) { - fe_add(r->YplusX, p->Y, p->X); - fe_sub(r->YminusX, p->Y, p->X); - fe_copy(r->Z, p->Z); - fe_mul(r->T2d, p->T, d2); -} - - -/* -r = p -*/ - -void ge_p3_to_p2(ge_p2 *r, const ge_p3 *p) { - fe_copy(r->X, p->X); - fe_copy(r->Y, p->Y); - fe_copy(r->Z, p->Z); -} - - -void ge_p3_tobytes(unsigned char *s, const ge_p3 *h) { - fe recip; - fe x; - fe y; - fe_invert(recip, h->Z); - fe_mul(x, h->X, recip); - fe_mul(y, h->Y, recip); - fe_tobytes(s, y); - s[31] ^= fe_isnegative(x) << 7; -} - - -static unsigned char equal(signed char b, signed char c) { - unsigned char ub = b; - unsigned char uc = c; - unsigned char x = ub ^ uc; /* 0: yes; 1..255: no */ - uint64_t y = x; /* 0: yes; 1..255: no */ - y -= 1; /* large: yes; 0..254: no */ - y >>= 63; /* 1: yes; 0: no */ - return (unsigned char) y; -} - -static unsigned char negative(signed char b) { - uint64_t x = b; /* 18446744073709551361..18446744073709551615: yes; 0..255: no */ - x >>= 63; /* 1: yes; 0: no */ - return (unsigned char) x; -} - -static void cmov(ge_precomp *t, ge_precomp *u, unsigned char b) { - fe_cmov(t->yplusx, u->yplusx, b); - fe_cmov(t->yminusx, u->yminusx, b); - fe_cmov(t->xy2d, u->xy2d, b); -} - - -static void select(ge_precomp *t, int pos, signed char b) { - ge_precomp minust; - unsigned char bnegative = negative(b); - unsigned char babs = b - shlu8(((-bnegative) & b), 1); - fe_1(t->yplusx); - fe_1(t->yminusx); - fe_0(t->xy2d); - cmov(t, &base[pos][0], equal(babs, 1)); - cmov(t, &base[pos][1], equal(babs, 2)); - cmov(t, &base[pos][2], equal(babs, 3)); - cmov(t, &base[pos][3], equal(babs, 4)); - cmov(t, &base[pos][4], equal(babs, 5)); - cmov(t, &base[pos][5], equal(babs, 6)); - cmov(t, &base[pos][6], equal(babs, 7)); - cmov(t, &base[pos][7], equal(babs, 8)); - fe_copy(minust.yplusx, t->yminusx); - fe_copy(minust.yminusx, t->yplusx); - fe_neg(minust.xy2d, t->xy2d); - cmov(t, &minust, bnegative); -} - -/* -h = a * B -where a = a[0]+256*a[1]+...+256^31 a[31] -B is the Ed25519 base point (x,4/5) with x positive. - -Preconditions: - a[31] <= 127 -*/ - -void ge_scalarmult_base(ge_p3 *h, const unsigned char *a) { - signed char e[64]; - signed char carry; - ge_p1p1 r; - ge_p2 s; - ge_precomp t; - int i; - - for(i = 0; i < 32; ++i) { - e[2 * i + 0] = (a[i] >> 0) & 15; - e[2 * i + 1] = (a[i] >> 4) & 15; - } - - /* each e[i] is between 0 and 15 */ - /* e[63] is between 0 and 7 */ - carry = 0; - - for(i = 0; i < 63; ++i) { - e[i] += carry; - carry = e[i] + 8; - carry >>= 4; - e[i] -= shl32(carry, 4); - } - - e[63] += carry; - /* each e[i] is between -8 and 8 */ - ge_p3_0(h); - - for(i = 1; i < 64; i += 2) { - select(&t, i / 2, e[i]); - ge_madd(&r, h, &t); - ge_p1p1_to_p3(h, &r); - } - - ge_p3_dbl(&r, h); - ge_p1p1_to_p2(&s, &r); - ge_p2_dbl(&r, &s); - ge_p1p1_to_p2(&s, &r); - ge_p2_dbl(&r, &s); - ge_p1p1_to_p2(&s, &r); - ge_p2_dbl(&r, &s); - ge_p1p1_to_p3(h, &r); - - for(i = 0; i < 64; i += 2) { - select(&t, i / 2, e[i]); - ge_madd(&r, h, &t); - ge_p1p1_to_p3(h, &r); - } -} - - -/* -r = p - q -*/ - -void ge_sub(ge_p1p1 *r, const ge_p3 *p, const ge_cached *q) { - fe t0; - - fe_add(r->X, p->Y, p->X); - fe_sub(r->Y, p->Y, p->X); - fe_mul(r->Z, r->X, q->YminusX); - fe_mul(r->Y, r->Y, q->YplusX); - fe_mul(r->T, q->T2d, p->T); - fe_mul(r->X, p->Z, q->Z); - fe_add(t0, r->X, r->X); - fe_sub(r->X, r->Z, r->Y); - fe_add(r->Y, r->Z, r->Y); - fe_sub(r->Z, t0, r->T); - fe_add(r->T, t0, r->T); -} - - -void ge_tobytes(unsigned char *s, const ge_p2 *h) { - fe recip; - fe x; - fe y; - fe_invert(recip, h->Z); - fe_mul(x, h->X, recip); - fe_mul(y, h->Y, recip); - fe_tobytes(s, y); - s[31] ^= fe_isnegative(x) << 7; -} diff --git a/src/ed25519/ge.h b/src/ed25519/ge.h deleted file mode 100644 index 9cc3b98..0000000 --- a/src/ed25519/ge.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef GE_H -#define GE_H - -#include "fe.h" - - -/* -ge means group element. - -Here the group is the set of pairs (x,y) of field elements (see fe.h) -satisfying -x^2 + y^2 = 1 + d x^2y^2 -where d = -121665/121666. - -Representations: - ge_p2 (projective): (X:Y:Z) satisfying x=X/Z, y=Y/Z - ge_p3 (extended): (X:Y:Z:T) satisfying x=X/Z, y=Y/Z, XY=ZT - ge_p1p1 (completed): ((X:Z),(Y:T)) satisfying x=X/Z, y=Y/T - ge_precomp (Duif): (y+x,y-x,2dxy) -*/ - -typedef struct { - fe X; - fe Y; - fe Z; -} ge_p2; - -typedef struct { - fe X; - fe Y; - fe Z; - fe T; -} ge_p3; - -typedef struct { - fe X; - fe Y; - fe Z; - fe T; -} ge_p1p1; - -typedef struct { - fe yplusx; - fe yminusx; - fe xy2d; -} ge_precomp; - -typedef struct { - fe YplusX; - fe YminusX; - fe Z; - fe T2d; -} ge_cached; - -void ge_p3_tobytes(unsigned char *s, const ge_p3 *h); -void ge_tobytes(unsigned char *s, const ge_p2 *h); -int ge_frombytes_negate_vartime(ge_p3 *h, const unsigned char *s); - -void ge_add(ge_p1p1 *r, const ge_p3 *p, const ge_cached *q); -void ge_sub(ge_p1p1 *r, const ge_p3 *p, const ge_cached *q); -void ge_double_scalarmult_vartime(ge_p2 *r, const unsigned char *a, const ge_p3 *A, const unsigned char *b); -void ge_madd(ge_p1p1 *r, const ge_p3 *p, const ge_precomp *q); -void ge_msub(ge_p1p1 *r, const ge_p3 *p, const ge_precomp *q); -void ge_scalarmult_base(ge_p3 *h, const unsigned char *a); - -void ge_p1p1_to_p2(ge_p2 *r, const ge_p1p1 *p); -void ge_p1p1_to_p3(ge_p3 *r, const ge_p1p1 *p); -void ge_p2_0(ge_p2 *h); -void ge_p2_dbl(ge_p1p1 *r, const ge_p2 *p); -void ge_p3_0(ge_p3 *h); -void ge_p3_dbl(ge_p1p1 *r, const ge_p3 *p); -void ge_p3_to_cached(ge_cached *r, const ge_p3 *p); -void ge_p3_to_p2(ge_p2 *r, const ge_p3 *p); - -#endif diff --git a/src/ed25519/key_exchange.c b/src/ed25519/key_exchange.c deleted file mode 100644 index 9ace86b..0000000 --- a/src/ed25519/key_exchange.c +++ /dev/null @@ -1,80 +0,0 @@ -#include "ed25519.h" -#include "fe.h" - -void ed25519_key_exchange(unsigned char *shared_secret, const unsigned char *public_key, const unsigned char *private_key) { - unsigned char e[32]; - unsigned int i; - - fe x1; - fe x2; - fe z2; - fe x3; - fe z3; - fe tmp0; - fe tmp1; - - int pos; - unsigned int swap; - unsigned int b; - - /* copy the private key and make sure it's valid */ - for(i = 0; i < 32; ++i) { - e[i] = private_key[i]; - } - - e[0] &= 248; - e[31] &= 63; - e[31] |= 64; - - /* unpack the public key and convert edwards to montgomery */ - /* due to CodesInChaos: montgomeryX = (edwardsY + 1)*inverse(1 - edwardsY) mod p */ - fe_frombytes(x1, public_key); - fe_1(tmp1); - fe_add(tmp0, x1, tmp1); - fe_sub(tmp1, tmp1, x1); - fe_invert(tmp1, tmp1); - fe_mul(x1, tmp0, tmp1); - - fe_1(x2); - fe_0(z2); - fe_copy(x3, x1); - fe_1(z3); - - swap = 0; - - for(pos = 254; pos >= 0; --pos) { - b = e[pos / 8] >> (pos & 7); - b &= 1; - swap ^= b; - fe_cswap(x2, x3, swap); - fe_cswap(z2, z3, swap); - swap = b; - - /* from montgomery.h */ - fe_sub(tmp0, x3, z3); - fe_sub(tmp1, x2, z2); - fe_add(x2, x2, z2); - fe_add(z2, x3, z3); - fe_mul(z3, tmp0, x2); - fe_mul(z2, z2, tmp1); - fe_sq(tmp0, tmp1); - fe_sq(tmp1, x2); - fe_add(x3, z3, z2); - fe_sub(z2, z3, z2); - fe_mul(x2, tmp1, tmp0); - fe_sub(tmp1, tmp1, tmp0); - fe_sq(z2, z2); - fe_mul121666(z3, tmp1); - fe_sq(x3, x3); - fe_add(tmp0, tmp0, z3); - fe_mul(z3, x1, z2); - fe_mul(z2, tmp1, tmp0); - } - - fe_cswap(x2, x3, swap); - fe_cswap(z2, z3, swap); - - fe_invert(z2, z2); - fe_mul(x2, x2, z2); - fe_tobytes(shared_secret, x2); -} diff --git a/src/ed25519/keypair.c b/src/ed25519/keypair.c deleted file mode 100644 index 71ec4d7..0000000 --- a/src/ed25519/keypair.c +++ /dev/null @@ -1,16 +0,0 @@ -#include "ed25519.h" -#include "sha512.h" -#include "ge.h" - - -void ed25519_create_keypair(unsigned char *public_key, unsigned char *private_key, const unsigned char *seed) { - ge_p3 A; - - sha512(seed, 32, private_key); - private_key[0] &= 248; - private_key[31] &= 63; - private_key[31] |= 64; - - ge_scalarmult_base(&A, private_key); - ge_p3_tobytes(public_key, &A); -} diff --git a/src/ed25519/precomp_data.h b/src/ed25519/precomp_data.h deleted file mode 100644 index 7a29302..0000000 --- a/src/ed25519/precomp_data.h +++ /dev/null @@ -1,1391 +0,0 @@ -static ge_precomp Bi[8] = { - { - { 25967493, -14356035, 29566456, 3660896, -12694345, 4014787, 27544626, -11754271, -6079156, 2047605 }, - { -12545711, 934262, -2722910, 3049990, -727428, 9406986, 12720692, 5043384, 19500929, -15469378 }, - { -8738181, 4489570, 9688441, -14785194, 10184609, -12363380, 29287919, 11864899, -24514362, -4438546 }, - }, - { - { 15636291, -9688557, 24204773, -7912398, 616977, -16685262, 27787600, -14772189, 28944400, -1550024 }, - { 16568933, 4717097, -11556148, -1102322, 15682896, -11807043, 16354577, -11775962, 7689662, 11199574 }, - { 30464156, -5976125, -11779434, -15670865, 23220365, 15915852, 7512774, 10017326, -17749093, -9920357 }, - }, - { - { 10861363, 11473154, 27284546, 1981175, -30064349, 12577861, 32867885, 14515107, -15438304, 10819380 }, - { 4708026, 6336745, 20377586, 9066809, -11272109, 6594696, -25653668, 12483688, -12668491, 5581306 }, - { 19563160, 16186464, -29386857, 4097519, 10237984, -4348115, 28542350, 13850243, -23678021, -15815942 }, - }, - { - { 5153746, 9909285, 1723747, -2777874, 30523605, 5516873, 19480852, 5230134, -23952439, -15175766 }, - { -30269007, -3463509, 7665486, 10083793, 28475525, 1649722, 20654025, 16520125, 30598449, 7715701 }, - { 28881845, 14381568, 9657904, 3680757, -20181635, 7843316, -31400660, 1370708, 29794553, -1409300 }, - }, - { - { -22518993, -6692182, 14201702, -8745502, -23510406, 8844726, 18474211, -1361450, -13062696, 13821877 }, - { -6455177, -7839871, 3374702, -4740862, -27098617, -10571707, 31655028, -7212327, 18853322, -14220951 }, - { 4566830, -12963868, -28974889, -12240689, -7602672, -2830569, -8514358, -10431137, 2207753, -3209784 }, - }, - { - { -25154831, -4185821, 29681144, 7868801, -6854661, -9423865, -12437364, -663000, -31111463, -16132436 }, - { 25576264, -2703214, 7349804, -11814844, 16472782, 9300885, 3844789, 15725684, 171356, 6466918 }, - { 23103977, 13316479, 9739013, -16149481, 817875, -15038942, 8965339, -14088058, -30714912, 16193877 }, - }, - { - { -33521811, 3180713, -2394130, 14003687, -16903474, -16270840, 17238398, 4729455, -18074513, 9256800 }, - { -25182317, -4174131, 32336398, 5036987, -21236817, 11360617, 22616405, 9761698, -19827198, 630305 }, - { -13720693, 2639453, -24237460, -7406481, 9494427, -5774029, -6554551, -15960994, -2449256, -14291300 }, - }, - { - { -3151181, -5046075, 9282714, 6866145, -31907062, -863023, -18940575, 15033784, 25105118, -7894876 }, - { -24326370, 15950226, -31801215, -14592823, -11662737, -5090925, 1573892, -2625887, 2198790, -15804619 }, - { -3099351, 10324967, -2241613, 7453183, -5446979, -2735503, -13812022, -16236442, -32461234, -12290683 }, - }, -}; - - -/* base[i][j] = (j+1)*256^i*B */ -static ge_precomp base[32][8] = { - { - { - { 25967493, -14356035, 29566456, 3660896, -12694345, 4014787, 27544626, -11754271, -6079156, 2047605 }, - { -12545711, 934262, -2722910, 3049990, -727428, 9406986, 12720692, 5043384, 19500929, -15469378 }, - { -8738181, 4489570, 9688441, -14785194, 10184609, -12363380, 29287919, 11864899, -24514362, -4438546 }, - }, - { - { -12815894, -12976347, -21581243, 11784320, -25355658, -2750717, -11717903, -3814571, -358445, -10211303 }, - { -21703237, 6903825, 27185491, 6451973, -29577724, -9554005, -15616551, 11189268, -26829678, -5319081 }, - { 26966642, 11152617, 32442495, 15396054, 14353839, -12752335, -3128826, -9541118, -15472047, -4166697 }, - }, - { - { 15636291, -9688557, 24204773, -7912398, 616977, -16685262, 27787600, -14772189, 28944400, -1550024 }, - { 16568933, 4717097, -11556148, -1102322, 15682896, -11807043, 16354577, -11775962, 7689662, 11199574 }, - { 30464156, -5976125, -11779434, -15670865, 23220365, 15915852, 7512774, 10017326, -17749093, -9920357 }, - }, - { - { -17036878, 13921892, 10945806, -6033431, 27105052, -16084379, -28926210, 15006023, 3284568, -6276540 }, - { 23599295, -8306047, -11193664, -7687416, 13236774, 10506355, 7464579, 9656445, 13059162, 10374397 }, - { 7798556, 16710257, 3033922, 2874086, 28997861, 2835604, 32406664, -3839045, -641708, -101325 }, - }, - { - { 10861363, 11473154, 27284546, 1981175, -30064349, 12577861, 32867885, 14515107, -15438304, 10819380 }, - { 4708026, 6336745, 20377586, 9066809, -11272109, 6594696, -25653668, 12483688, -12668491, 5581306 }, - { 19563160, 16186464, -29386857, 4097519, 10237984, -4348115, 28542350, 13850243, -23678021, -15815942 }, - }, - { - { -15371964, -12862754, 32573250, 4720197, -26436522, 5875511, -19188627, -15224819, -9818940, -12085777 }, - { -8549212, 109983, 15149363, 2178705, 22900618, 4543417, 3044240, -15689887, 1762328, 14866737 }, - { -18199695, -15951423, -10473290, 1707278, -17185920, 3916101, -28236412, 3959421, 27914454, 4383652 }, - }, - { - { 5153746, 9909285, 1723747, -2777874, 30523605, 5516873, 19480852, 5230134, -23952439, -15175766 }, - { -30269007, -3463509, 7665486, 10083793, 28475525, 1649722, 20654025, 16520125, 30598449, 7715701 }, - { 28881845, 14381568, 9657904, 3680757, -20181635, 7843316, -31400660, 1370708, 29794553, -1409300 }, - }, - { - { 14499471, -2729599, -33191113, -4254652, 28494862, 14271267, 30290735, 10876454, -33154098, 2381726 }, - { -7195431, -2655363, -14730155, 462251, -27724326, 3941372, -6236617, 3696005, -32300832, 15351955 }, - { 27431194, 8222322, 16448760, -3907995, -18707002, 11938355, -32961401, -2970515, 29551813, 10109425 }, - }, - }, - { - { - { -13657040, -13155431, -31283750, 11777098, 21447386, 6519384, -2378284, -1627556, 10092783, -4764171 }, - { 27939166, 14210322, 4677035, 16277044, -22964462, -12398139, -32508754, 12005538, -17810127, 12803510 }, - { 17228999, -15661624, -1233527, 300140, -1224870, -11714777, 30364213, -9038194, 18016357, 4397660 }, - }, - { - { -10958843, -7690207, 4776341, -14954238, 27850028, -15602212, -26619106, 14544525, -17477504, 982639 }, - { 29253598, 15796703, -2863982, -9908884, 10057023, 3163536, 7332899, -4120128, -21047696, 9934963 }, - { 5793303, 16271923, -24131614, -10116404, 29188560, 1206517, -14747930, 4559895, -30123922, -10897950 }, - }, - { - { -27643952, -11493006, 16282657, -11036493, 28414021, -15012264, 24191034, 4541697, -13338309, 5500568 }, - { 12650548, -1497113, 9052871, 11355358, -17680037, -8400164, -17430592, 12264343, 10874051, 13524335 }, - { 25556948, -3045990, 714651, 2510400, 23394682, -10415330, 33119038, 5080568, -22528059, 5376628 }, - }, - { - { -26088264, -4011052, -17013699, -3537628, -6726793, 1920897, -22321305, -9447443, 4535768, 1569007 }, - { -2255422, 14606630, -21692440, -8039818, 28430649, 8775819, -30494562, 3044290, 31848280, 12543772 }, - { -22028579, 2943893, -31857513, 6777306, 13784462, -4292203, -27377195, -2062731, 7718482, 14474653 }, - }, - { - { 2385315, 2454213, -22631320, 46603, -4437935, -15680415, 656965, -7236665, 24316168, -5253567 }, - { 13741529, 10911568, -33233417, -8603737, -20177830, -1033297, 33040651, -13424532, -20729456, 8321686 }, - { 21060490, -2212744, 15712757, -4336099, 1639040, 10656336, 23845965, -11874838, -9984458, 608372 }, - }, - { - { -13672732, -15087586, -10889693, -7557059, -6036909, 11305547, 1123968, -6780577, 27229399, 23887 }, - { -23244140, -294205, -11744728, 14712571, -29465699, -2029617, 12797024, -6440308, -1633405, 16678954 }, - { -29500620, 4770662, -16054387, 14001338, 7830047, 9564805, -1508144, -4795045, -17169265, 4904953 }, - }, - { - { 24059557, 14617003, 19037157, -15039908, 19766093, -14906429, 5169211, 16191880, 2128236, -4326833 }, - { -16981152, 4124966, -8540610, -10653797, 30336522, -14105247, -29806336, 916033, -6882542, -2986532 }, - { -22630907, 12419372, -7134229, -7473371, -16478904, 16739175, 285431, 2763829, 15736322, 4143876 }, - }, - { - { 2379352, 11839345, -4110402, -5988665, 11274298, 794957, 212801, -14594663, 23527084, -16458268 }, - { 33431127, -11130478, -17838966, -15626900, 8909499, 8376530, -32625340, 4087881, -15188911, -14416214 }, - { 1767683, 7197987, -13205226, -2022635, -13091350, 448826, 5799055, 4357868, -4774191, -16323038 }, - }, - }, - { - { - { 6721966, 13833823, -23523388, -1551314, 26354293, -11863321, 23365147, -3949732, 7390890, 2759800 }, - { 4409041, 2052381, 23373853, 10530217, 7676779, -12885954, 21302353, -4264057, 1244380, -12919645 }, - { -4421239, 7169619, 4982368, -2957590, 30256825, -2777540, 14086413, 9208236, 15886429, 16489664 }, - }, - { - { 1996075, 10375649, 14346367, 13311202, -6874135, -16438411, -13693198, 398369, -30606455, -712933 }, - { -25307465, 9795880, -2777414, 14878809, -33531835, 14780363, 13348553, 12076947, -30836462, 5113182 }, - { -17770784, 11797796, 31950843, 13929123, -25888302, 12288344, -30341101, -7336386, 13847711, 5387222 }, - }, - { - { -18582163, -3416217, 17824843, -2340966, 22744343, -10442611, 8763061, 3617786, -19600662, 10370991 }, - { 20246567, -14369378, 22358229, -543712, 18507283, -10413996, 14554437, -8746092, 32232924, 16763880 }, - { 9648505, 10094563, 26416693, 14745928, -30374318, -6472621, 11094161, 15689506, 3140038, -16510092 }, - }, - { - { -16160072, 5472695, 31895588, 4744994, 8823515, 10365685, -27224800, 9448613, -28774454, 366295 }, - { 19153450, 11523972, -11096490, -6503142, -24647631, 5420647, 28344573, 8041113, 719605, 11671788 }, - { 8678025, 2694440, -6808014, 2517372, 4964326, 11152271, -15432916, -15266516, 27000813, -10195553 }, - }, - { - { -15157904, 7134312, 8639287, -2814877, -7235688, 10421742, 564065, 5336097, 6750977, -14521026 }, - { 11836410, -3979488, 26297894, 16080799, 23455045, 15735944, 1695823, -8819122, 8169720, 16220347 }, - { -18115838, 8653647, 17578566, -6092619, -8025777, -16012763, -11144307, -2627664, -5990708, -14166033 }, - }, - { - { -23308498, -10968312, 15213228, -10081214, -30853605, -11050004, 27884329, 2847284, 2655861, 1738395 }, - { -27537433, -14253021, -25336301, -8002780, -9370762, 8129821, 21651608, -3239336, -19087449, -11005278 }, - { 1533110, 3437855, 23735889, 459276, 29970501, 11335377, 26030092, 5821408, 10478196, 8544890 }, - }, - { - { 32173121, -16129311, 24896207, 3921497, 22579056, -3410854, 19270449, 12217473, 17789017, -3395995 }, - { -30552961, -2228401, -15578829, -10147201, 13243889, 517024, 15479401, -3853233, 30460520, 1052596 }, - { -11614875, 13323618, 32618793, 8175907, -15230173, 12596687, 27491595, -4612359, 3179268, -9478891 }, - }, - { - { 31947069, -14366651, -4640583, -15339921, -15125977, -6039709, -14756777, -16411740, 19072640, -9511060 }, - { 11685058, 11822410, 3158003, -13952594, 33402194, -4165066, 5977896, -5215017, 473099, 5040608 }, - { -20290863, 8198642, -27410132, 11602123, 1290375, -2799760, 28326862, 1721092, -19558642, -3131606 }, - }, - }, - { - { - { 7881532, 10687937, 7578723, 7738378, -18951012, -2553952, 21820786, 8076149, -27868496, 11538389 }, - { -19935666, 3899861, 18283497, -6801568, -15728660, -11249211, 8754525, 7446702, -5676054, 5797016 }, - { -11295600, -3793569, -15782110, -7964573, 12708869, -8456199, 2014099, -9050574, -2369172, -5877341 }, - }, - { - { -22472376, -11568741, -27682020, 1146375, 18956691, 16640559, 1192730, -3714199, 15123619, 10811505 }, - { 14352098, -3419715, -18942044, 10822655, 32750596, 4699007, -70363, 15776356, -28886779, -11974553 }, - { -28241164, -8072475, -4978962, -5315317, 29416931, 1847569, -20654173, -16484855, 4714547, -9600655 }, - }, - { - { 15200332, 8368572, 19679101, 15970074, -31872674, 1959451, 24611599, -4543832, -11745876, 12340220 }, - { 12876937, -10480056, 33134381, 6590940, -6307776, 14872440, 9613953, 8241152, 15370987, 9608631 }, - { -4143277, -12014408, 8446281, -391603, 4407738, 13629032, -7724868, 15866074, -28210621, -8814099 }, - }, - { - { 26660628, -15677655, 8393734, 358047, -7401291, 992988, -23904233, 858697, 20571223, 8420556 }, - { 14620715, 13067227, -15447274, 8264467, 14106269, 15080814, 33531827, 12516406, -21574435, -12476749 }, - { 236881, 10476226, 57258, -14677024, 6472998, 2466984, 17258519, 7256740, 8791136, 15069930 }, - }, - { - { 1276410, -9371918, 22949635, -16322807, -23493039, -5702186, 14711875, 4874229, -30663140, -2331391 }, - { 5855666, 4990204, -13711848, 7294284, -7804282, 1924647, -1423175, -7912378, -33069337, 9234253 }, - { 20590503, -9018988, 31529744, -7352666, -2706834, 10650548, 31559055, -11609587, 18979186, 13396066 }, - }, - { - { 24474287, 4968103, 22267082, 4407354, 24063882, -8325180, -18816887, 13594782, 33514650, 7021958 }, - { -11566906, -6565505, -21365085, 15928892, -26158305, 4315421, -25948728, -3916677, -21480480, 12868082 }, - { -28635013, 13504661, 19988037, -2132761, 21078225, 6443208, -21446107, 2244500, -12455797, -8089383 }, - }, - { - { -30595528, 13793479, -5852820, 319136, -25723172, -6263899, 33086546, 8957937, -15233648, 5540521 }, - { -11630176, -11503902, -8119500, -7643073, 2620056, 1022908, -23710744, -1568984, -16128528, -14962807 }, - { 23152971, 775386, 27395463, 14006635, -9701118, 4649512, 1689819, 892185, -11513277, -15205948 }, - }, - { - { 9770129, 9586738, 26496094, 4324120, 1556511, -3550024, 27453819, 4763127, -19179614, 5867134 }, - { -32765025, 1927590, 31726409, -4753295, 23962434, -16019500, 27846559, 5931263, -29749703, -16108455 }, - { 27461885, -2977536, 22380810, 1815854, -23033753, -3031938, 7283490, -15148073, -19526700, 7734629 }, - }, - }, - { - { - { -8010264, -9590817, -11120403, 6196038, 29344158, -13430885, 7585295, -3176626, 18549497, 15302069 }, - { -32658337, -6171222, -7672793, -11051681, 6258878, 13504381, 10458790, -6418461, -8872242, 8424746 }, - { 24687205, 8613276, -30667046, -3233545, 1863892, -1830544, 19206234, 7134917, -11284482, -828919 }, - }, - { - { 11334899, -9218022, 8025293, 12707519, 17523892, -10476071, 10243738, -14685461, -5066034, 16498837 }, - { 8911542, 6887158, -9584260, -6958590, 11145641, -9543680, 17303925, -14124238, 6536641, 10543906 }, - { -28946384, 15479763, -17466835, 568876, -1497683, 11223454, -2669190, -16625574, -27235709, 8876771 }, - }, - { - { -25742899, -12566864, -15649966, -846607, -33026686, -796288, -33481822, 15824474, -604426, -9039817 }, - { 10330056, 70051, 7957388, -9002667, 9764902, 15609756, 27698697, -4890037, 1657394, 3084098 }, - { 10477963, -7470260, 12119566, -13250805, 29016247, -5365589, 31280319, 14396151, -30233575, 15272409 }, - }, - { - { -12288309, 3169463, 28813183, 16658753, 25116432, -5630466, -25173957, -12636138, -25014757, 1950504 }, - { -26180358, 9489187, 11053416, -14746161, -31053720, 5825630, -8384306, -8767532, 15341279, 8373727 }, - { 28685821, 7759505, -14378516, -12002860, -31971820, 4079242, 298136, -10232602, -2878207, 15190420 }, - }, - { - { -32932876, 13806336, -14337485, -15794431, -24004620, 10940928, 8669718, 2742393, -26033313, -6875003 }, - { -1580388, -11729417, -25979658, -11445023, -17411874, -10912854, 9291594, -16247779, -12154742, 6048605 }, - { -30305315, 14843444, 1539301, 11864366, 20201677, 1900163, 13934231, 5128323, 11213262, 9168384 }, - }, - { - { -26280513, 11007847, 19408960, -940758, -18592965, -4328580, -5088060, -11105150, 20470157, -16398701 }, - { -23136053, 9282192, 14855179, -15390078, -7362815, -14408560, -22783952, 14461608, 14042978, 5230683 }, - { 29969567, -2741594, -16711867, -8552442, 9175486, -2468974, 21556951, 3506042, -5933891, -12449708 }, - }, - { - { -3144746, 8744661, 19704003, 4581278, -20430686, 6830683, -21284170, 8971513, -28539189, 15326563 }, - { -19464629, 10110288, -17262528, -3503892, -23500387, 1355669, -15523050, 15300988, -20514118, 9168260 }, - { -5353335, 4488613, -23803248, 16314347, 7780487, -15638939, -28948358, 9601605, 33087103, -9011387 }, - }, - { - { -19443170, -15512900, -20797467, -12445323, -29824447, 10229461, -27444329, -15000531, -5996870, 15664672 }, - { 23294591, -16632613, -22650781, -8470978, 27844204, 11461195, 13099750, -2460356, 18151676, 13417686 }, - { -24722913, -4176517, -31150679, 5988919, -26858785, 6685065, 1661597, -12551441, 15271676, -15452665 }, - }, - }, - { - { - { 11433042, -13228665, 8239631, -5279517, -1985436, -725718, -18698764, 2167544, -6921301, -13440182 }, - { -31436171, 15575146, 30436815, 12192228, -22463353, 9395379, -9917708, -8638997, 12215110, 12028277 }, - { 14098400, 6555944, 23007258, 5757252, -15427832, -12950502, 30123440, 4617780, -16900089, -655628 }, - }, - { - { -4026201, -15240835, 11893168, 13718664, -14809462, 1847385, -15819999, 10154009, 23973261, -12684474 }, - { -26531820, -3695990, -1908898, 2534301, -31870557, -16550355, 18341390, -11419951, 32013174, -10103539 }, - { -25479301, 10876443, -11771086, -14625140, -12369567, 1838104, 21911214, 6354752, 4425632, -837822 }, - }, - { - { -10433389, -14612966, 22229858, -3091047, -13191166, 776729, -17415375, -12020462, 4725005, 14044970 }, - { 19268650, -7304421, 1555349, 8692754, -21474059, -9910664, 6347390, -1411784, -19522291, -16109756 }, - { -24864089, 12986008, -10898878, -5558584, -11312371, -148526, 19541418, 8180106, 9282262, 10282508 }, - }, - { - { -26205082, 4428547, -8661196, -13194263, 4098402, -14165257, 15522535, 8372215, 5542595, -10702683 }, - { -10562541, 14895633, 26814552, -16673850, -17480754, -2489360, -2781891, 6993761, -18093885, 10114655 }, - { -20107055, -929418, 31422704, 10427861, -7110749, 6150669, -29091755, -11529146, 25953725, -106158 }, - }, - { - { -4234397, -8039292, -9119125, 3046000, 2101609, -12607294, 19390020, 6094296, -3315279, 12831125 }, - { -15998678, 7578152, 5310217, 14408357, -33548620, -224739, 31575954, 6326196, 7381791, -2421839 }, - { -20902779, 3296811, 24736065, -16328389, 18374254, 7318640, 6295303, 8082724, -15362489, 12339664 }, - }, - { - { 27724736, 2291157, 6088201, -14184798, 1792727, 5857634, 13848414, 15768922, 25091167, 14856294 }, - { -18866652, 8331043, 24373479, 8541013, -701998, -9269457, 12927300, -12695493, -22182473, -9012899 }, - { -11423429, -5421590, 11632845, 3405020, 30536730, -11674039, -27260765, 13866390, 30146206, 9142070 }, - }, - { - { 3924129, -15307516, -13817122, -10054960, 12291820, -668366, -27702774, 9326384, -8237858, 4171294 }, - { -15921940, 16037937, 6713787, 16606682, -21612135, 2790944, 26396185, 3731949, 345228, -5462949 }, - { -21327538, 13448259, 25284571, 1143661, 20614966, -8849387, 2031539, -12391231, -16253183, -13582083 }, - }, - { - { 31016211, -16722429, 26371392, -14451233, -5027349, 14854137, 17477601, 3842657, 28012650, -16405420 }, - { -5075835, 9368966, -8562079, -4600902, -15249953, 6970560, -9189873, 16292057, -8867157, 3507940 }, - { 29439664, 3537914, 23333589, 6997794, -17555561, -11018068, -15209202, -15051267, -9164929, 6580396 }, - }, - }, - { - { - { -12185861, -7679788, 16438269, 10826160, -8696817, -6235611, 17860444, -9273846, -2095802, 9304567 }, - { 20714564, -4336911, 29088195, 7406487, 11426967, -5095705, 14792667, -14608617, 5289421, -477127 }, - { -16665533, -10650790, -6160345, -13305760, 9192020, -1802462, 17271490, 12349094, 26939669, -3752294 }, - }, - { - { -12889898, 9373458, 31595848, 16374215, 21471720, 13221525, -27283495, -12348559, -3698806, 117887 }, - { 22263325, -6560050, 3984570, -11174646, -15114008, -566785, 28311253, 5358056, -23319780, 541964 }, - { 16259219, 3261970, 2309254, -15534474, -16885711, -4581916, 24134070, -16705829, -13337066, -13552195 }, - }, - { - { 9378160, -13140186, -22845982, -12745264, 28198281, -7244098, -2399684, -717351, 690426, 14876244 }, - { 24977353, -314384, -8223969, -13465086, 28432343, -1176353, -13068804, -12297348, -22380984, 6618999 }, - { -1538174, 11685646, 12944378, 13682314, -24389511, -14413193, 8044829, -13817328, 32239829, -5652762 }, - }, - { - { -18603066, 4762990, -926250, 8885304, -28412480, -3187315, 9781647, -10350059, 32779359, 5095274 }, - { -33008130, -5214506, -32264887, -3685216, 9460461, -9327423, -24601656, 14506724, 21639561, -2630236 }, - { -16400943, -13112215, 25239338, 15531969, 3987758, -4499318, -1289502, -6863535, 17874574, 558605 }, - }, - { - { -13600129, 10240081, 9171883, 16131053, -20869254, 9599700, 33499487, 5080151, 2085892, 5119761 }, - { -22205145, -2519528, -16381601, 414691, -25019550, 2170430, 30634760, -8363614, -31999993, -5759884 }, - { -6845704, 15791202, 8550074, -1312654, 29928809, -12092256, 27534430, -7192145, -22351378, 12961482 }, - }, - { - { -24492060, -9570771, 10368194, 11582341, -23397293, -2245287, 16533930, 8206996, -30194652, -5159638 }, - { -11121496, -3382234, 2307366, 6362031, -135455, 8868177, -16835630, 7031275, 7589640, 8945490 }, - { -32152748, 8917967, 6661220, -11677616, -1192060, -15793393, 7251489, -11182180, 24099109, -14456170 }, - }, - { - { 5019558, -7907470, 4244127, -14714356, -26933272, 6453165, -19118182, -13289025, -6231896, -10280736 }, - { 10853594, 10721687, 26480089, 5861829, -22995819, 1972175, -1866647, -10557898, -3363451, -6441124 }, - { -17002408, 5906790, 221599, -6563147, 7828208, -13248918, 24362661, -2008168, -13866408, 7421392 }, - }, - { - { 8139927, -6546497, 32257646, -5890546, 30375719, 1886181, -21175108, 15441252, 28826358, -4123029 }, - { 6267086, 9695052, 7709135, -16603597, -32869068, -1886135, 14795160, -7840124, 13746021, -1742048 }, - { 28584902, 7787108, -6732942, -15050729, 22846041, -7571236, -3181936, -363524, 4771362, -8419958 }, - }, - }, - { - { - { 24949256, 6376279, -27466481, -8174608, -18646154, -9930606, 33543569, -12141695, 3569627, 11342593 }, - { 26514989, 4740088, 27912651, 3697550, 19331575, -11472339, 6809886, 4608608, 7325975, -14801071 }, - { -11618399, -14554430, -24321212, 7655128, -1369274, 5214312, -27400540, 10258390, -17646694, -8186692 }, - }, - { - { 11431204, 15823007, 26570245, 14329124, 18029990, 4796082, -31446179, 15580664, 9280358, -3973687 }, - { -160783, -10326257, -22855316, -4304997, -20861367, -13621002, -32810901, -11181622, -15545091, 4387441 }, - { -20799378, 12194512, 3937617, -5805892, -27154820, 9340370, -24513992, 8548137, 20617071, -7482001 }, - }, - { - { -938825, -3930586, -8714311, 16124718, 24603125, -6225393, -13775352, -11875822, 24345683, 10325460 }, - { -19855277, -1568885, -22202708, 8714034, 14007766, 6928528, 16318175, -1010689, 4766743, 3552007 }, - { -21751364, -16730916, 1351763, -803421, -4009670, 3950935, 3217514, 14481909, 10988822, -3994762 }, - }, - { - { 15564307, -14311570, 3101243, 5684148, 30446780, -8051356, 12677127, -6505343, -8295852, 13296005 }, - { -9442290, 6624296, -30298964, -11913677, -4670981, -2057379, 31521204, 9614054, -30000824, 12074674 }, - { 4771191, -135239, 14290749, -13089852, 27992298, 14998318, -1413936, -1556716, 29832613, -16391035 }, - }, - { - { 7064884, -7541174, -19161962, -5067537, -18891269, -2912736, 25825242, 5293297, -27122660, 13101590 }, - { -2298563, 2439670, -7466610, 1719965, -27267541, -16328445, 32512469, -5317593, -30356070, -4190957 }, - { -30006540, 10162316, -33180176, 3981723, -16482138, -13070044, 14413974, 9515896, 19568978, 9628812 }, - }, - { - { 33053803, 199357, 15894591, 1583059, 27380243, -4580435, -17838894, -6106839, -6291786, 3437740 }, - { -18978877, 3884493, 19469877, 12726490, 15913552, 13614290, -22961733, 70104, 7463304, 4176122 }, - { -27124001, 10659917, 11482427, -16070381, 12771467, -6635117, -32719404, -5322751, 24216882, 5944158 }, - }, - { - { 8894125, 7450974, -2664149, -9765752, -28080517, -12389115, 19345746, 14680796, 11632993, 5847885 }, - { 26942781, -2315317, 9129564, -4906607, 26024105, 11769399, -11518837, 6367194, -9727230, 4782140 }, - { 19916461, -4828410, -22910704, -11414391, 25606324, -5972441, 33253853, 8220911, 6358847, -1873857 }, - }, - { - { 801428, -2081702, 16569428, 11065167, 29875704, 96627, 7908388, -4480480, -13538503, 1387155 }, - { 19646058, 5720633, -11416706, 12814209, 11607948, 12749789, 14147075, 15156355, -21866831, 11835260 }, - { 19299512, 1155910, 28703737, 14890794, 2925026, 7269399, 26121523, 15467869, -26560550, 5052483 }, - }, - }, - { - { - { -3017432, 10058206, 1980837, 3964243, 22160966, 12322533, -6431123, -12618185, 12228557, -7003677 }, - { 32944382, 14922211, -22844894, 5188528, 21913450, -8719943, 4001465, 13238564, -6114803, 8653815 }, - { 22865569, -4652735, 27603668, -12545395, 14348958, 8234005, 24808405, 5719875, 28483275, 2841751 }, - }, - { - { -16420968, -1113305, -327719, -12107856, 21886282, -15552774, -1887966, -315658, 19932058, -12739203 }, - { -11656086, 10087521, -8864888, -5536143, -19278573, -3055912, 3999228, 13239134, -4777469, -13910208 }, - { 1382174, -11694719, 17266790, 9194690, -13324356, 9720081, 20403944, 11284705, -14013818, 3093230 }, - }, - { - { 16650921, -11037932, -1064178, 1570629, -8329746, 7352753, -302424, 16271225, -24049421, -6691850 }, - { -21911077, -5927941, -4611316, -5560156, -31744103, -10785293, 24123614, 15193618, -21652117, -16739389 }, - { -9935934, -4289447, -25279823, 4372842, 2087473, 10399484, 31870908, 14690798, 17361620, 11864968 }, - }, - { - { -11307610, 6210372, 13206574, 5806320, -29017692, -13967200, -12331205, -7486601, -25578460, -16240689 }, - { 14668462, -12270235, 26039039, 15305210, 25515617, 4542480, 10453892, 6577524, 9145645, -6443880 }, - { 5974874, 3053895, -9433049, -10385191, -31865124, 3225009, -7972642, 3936128, -5652273, -3050304 }, - }, - { - { 30625386, -4729400, -25555961, -12792866, -20484575, 7695099, 17097188, -16303496, -27999779, 1803632 }, - { -3553091, 9865099, -5228566, 4272701, -5673832, -16689700, 14911344, 12196514, -21405489, 7047412 }, - { 20093277, 9920966, -11138194, -5343857, 13161587, 12044805, -32856851, 4124601, -32343828, -10257566 }, - }, - { - { -20788824, 14084654, -13531713, 7842147, 19119038, -13822605, 4752377, -8714640, -21679658, 2288038 }, - { -26819236, -3283715, 29965059, 3039786, -14473765, 2540457, 29457502, 14625692, -24819617, 12570232 }, - { -1063558, -11551823, 16920318, 12494842, 1278292, -5869109, -21159943, -3498680, -11974704, 4724943 }, - }, - { - { 17960970, -11775534, -4140968, -9702530, -8876562, -1410617, -12907383, -8659932, -29576300, 1903856 }, - { 23134274, -14279132, -10681997, -1611936, 20684485, 15770816, -12989750, 3190296, 26955097, 14109738 }, - { 15308788, 5320727, -30113809, -14318877, 22902008, 7767164, 29425325, -11277562, 31960942, 11934971 }, - }, - { - { -27395711, 8435796, 4109644, 12222639, -24627868, 14818669, 20638173, 4875028, 10491392, 1379718 }, - { -13159415, 9197841, 3875503, -8936108, -1383712, -5879801, 33518459, 16176658, 21432314, 12180697 }, - { -11787308, 11500838, 13787581, -13832590, -22430679, 10140205, 1465425, 12689540, -10301319, -13872883 }, - }, - }, - { - { - { 5414091, -15386041, -21007664, 9643570, 12834970, 1186149, -2622916, -1342231, 26128231, 6032912 }, - { -26337395, -13766162, 32496025, -13653919, 17847801, -12669156, 3604025, 8316894, -25875034, -10437358 }, - { 3296484, 6223048, 24680646, -12246460, -23052020, 5903205, -8862297, -4639164, 12376617, 3188849 }, - }, - { - { 29190488, -14659046, 27549113, -1183516, 3520066, -10697301, 32049515, -7309113, -16109234, -9852307 }, - { -14744486, -9309156, 735818, -598978, -20407687, -5057904, 25246078, -15795669, 18640741, -960977 }, - { -6928835, -16430795, 10361374, 5642961, 4910474, 12345252, -31638386, -494430, 10530747, 1053335 }, - }, - { - { -29265967, -14186805, -13538216, -12117373, -19457059, -10655384, -31462369, -2948985, 24018831, 15026644 }, - { -22592535, -3145277, -2289276, 5953843, -13440189, 9425631, 25310643, 13003497, -2314791, -15145616 }, - { -27419985, -603321, -8043984, -1669117, -26092265, 13987819, -27297622, 187899, -23166419, -2531735 }, - }, - { - { -21744398, -13810475, 1844840, 5021428, -10434399, -15911473, 9716667, 16266922, -5070217, 726099 }, - { 29370922, -6053998, 7334071, -15342259, 9385287, 2247707, -13661962, -4839461, 30007388, -15823341 }, - { -936379, 16086691, 23751945, -543318, -1167538, -5189036, 9137109, 730663, 9835848, 4555336 }, - }, - { - { -23376435, 1410446, -22253753, -12899614, 30867635, 15826977, 17693930, 544696, -11985298, 12422646 }, - { 31117226, -12215734, -13502838, 6561947, -9876867, -12757670, -5118685, -4096706, 29120153, 13924425 }, - { -17400879, -14233209, 19675799, -2734756, -11006962, -5858820, -9383939, -11317700, 7240931, -237388 }, - }, - { - { -31361739, -11346780, -15007447, -5856218, -22453340, -12152771, 1222336, 4389483, 3293637, -15551743 }, - { -16684801, -14444245, 11038544, 11054958, -13801175, -3338533, -24319580, 7733547, 12796905, -6335822 }, - { -8759414, -10817836, -25418864, 10783769, -30615557, -9746811, -28253339, 3647836, 3222231, -11160462 }, - }, - { - { 18606113, 1693100, -25448386, -15170272, 4112353, 10045021, 23603893, -2048234, -7550776, 2484985 }, - { 9255317, -3131197, -12156162, -1004256, 13098013, -9214866, 16377220, -2102812, -19802075, -3034702 }, - { -22729289, 7496160, -5742199, 11329249, 19991973, -3347502, -31718148, 9936966, -30097688, -10618797 }, - }, - { - { 21878590, -5001297, 4338336, 13643897, -3036865, 13160960, 19708896, 5415497, -7360503, -4109293 }, - { 27736861, 10103576, 12500508, 8502413, -3413016, -9633558, 10436918, -1550276, -23659143, -8132100 }, - { 19492550, -12104365, -29681976, -852630, -3208171, 12403437, 30066266, 8367329, 13243957, 8709688 }, - }, - }, - { - { - { 12015105, 2801261, 28198131, 10151021, 24818120, -4743133, -11194191, -5645734, 5150968, 7274186 }, - { 2831366, -12492146, 1478975, 6122054, 23825128, -12733586, 31097299, 6083058, 31021603, -9793610 }, - { -2529932, -2229646, 445613, 10720828, -13849527, -11505937, -23507731, 16354465, 15067285, -14147707 }, - }, - { - { 7840942, 14037873, -33364863, 15934016, -728213, -3642706, 21403988, 1057586, -19379462, -12403220 }, - { 915865, -16469274, 15608285, -8789130, -24357026, 6060030, -17371319, 8410997, -7220461, 16527025 }, - { 32922597, -556987, 20336074, -16184568, 10903705, -5384487, 16957574, 52992, 23834301, 6588044 }, - }, - { - { 32752030, 11232950, 3381995, -8714866, 22652988, -10744103, 17159699, 16689107, -20314580, -1305992 }, - { -4689649, 9166776, -25710296, -10847306, 11576752, 12733943, 7924251, -2752281, 1976123, -7249027 }, - { 21251222, 16309901, -2983015, -6783122, 30810597, 12967303, 156041, -3371252, 12331345, -8237197 }, - }, - { - { 8651614, -4477032, -16085636, -4996994, 13002507, 2950805, 29054427, -5106970, 10008136, -4667901 }, - { 31486080, 15114593, -14261250, 12951354, 14369431, -7387845, 16347321, -13662089, 8684155, -10532952 }, - { 19443825, 11385320, 24468943, -9659068, -23919258, 2187569, -26263207, -6086921, 31316348, 14219878 }, - }, - { - { -28594490, 1193785, 32245219, 11392485, 31092169, 15722801, 27146014, 6992409, 29126555, 9207390 }, - { 32382935, 1110093, 18477781, 11028262, -27411763, -7548111, -4980517, 10843782, -7957600, -14435730 }, - { 2814918, 7836403, 27519878, -7868156, -20894015, -11553689, -21494559, 8550130, 28346258, 1994730 }, - }, - { - { -19578299, 8085545, -14000519, -3948622, 2785838, -16231307, -19516951, 7174894, 22628102, 8115180 }, - { -30405132, 955511, -11133838, -15078069, -32447087, -13278079, -25651578, 3317160, -9943017, 930272 }, - { -15303681, -6833769, 28856490, 1357446, 23421993, 1057177, 24091212, -1388970, -22765376, -10650715 }, - }, - { - { -22751231, -5303997, -12907607, -12768866, -15811511, -7797053, -14839018, -16554220, -1867018, 8398970 }, - { -31969310, 2106403, -4736360, 1362501, 12813763, 16200670, 22981545, -6291273, 18009408, -15772772 }, - { -17220923, -9545221, -27784654, 14166835, 29815394, 7444469, 29551787, -3727419, 19288549, 1325865 }, - }, - { - { 15100157, -15835752, -23923978, -1005098, -26450192, 15509408, 12376730, -3479146, 33166107, -8042750 }, - { 20909231, 13023121, -9209752, 16251778, -5778415, -8094914, 12412151, 10018715, 2213263, -13878373 }, - { 32529814, -11074689, 30361439, -16689753, -9135940, 1513226, 22922121, 6382134, -5766928, 8371348 }, - }, - }, - { - { - { 9923462, 11271500, 12616794, 3544722, -29998368, -1721626, 12891687, -8193132, -26442943, 10486144 }, - { -22597207, -7012665, 8587003, -8257861, 4084309, -12970062, 361726, 2610596, -23921530, -11455195 }, - { 5408411, -1136691, -4969122, 10561668, 24145918, 14240566, 31319731, -4235541, 19985175, -3436086 }, - }, - { - { -13994457, 16616821, 14549246, 3341099, 32155958, 13648976, -17577068, 8849297, 65030, 8370684 }, - { -8320926, -12049626, 31204563, 5839400, -20627288, -1057277, -19442942, 6922164, 12743482, -9800518 }, - { -2361371, 12678785, 28815050, 4759974, -23893047, 4884717, 23783145, 11038569, 18800704, 255233 }, - }, - { - { -5269658, -1773886, 13957886, 7990715, 23132995, 728773, 13393847, 9066957, 19258688, -14753793 }, - { -2936654, -10827535, -10432089, 14516793, -3640786, 4372541, -31934921, 2209390, -1524053, 2055794 }, - { 580882, 16705327, 5468415, -2683018, -30926419, -14696000, -7203346, -8994389, -30021019, 7394435 }, - }, - { - { 23838809, 1822728, -15738443, 15242727, 8318092, -3733104, -21672180, -3492205, -4821741, 14799921 }, - { 13345610, 9759151, 3371034, -16137791, 16353039, 8577942, 31129804, 13496856, -9056018, 7402518 }, - { 2286874, -4435931, -20042458, -2008336, -13696227, 5038122, 11006906, -15760352, 8205061, 1607563 }, - }, - { - { 14414086, -8002132, 3331830, -3208217, 22249151, -5594188, 18364661, -2906958, 30019587, -9029278 }, - { -27688051, 1585953, -10775053, 931069, -29120221, -11002319, -14410829, 12029093, 9944378, 8024 }, - { 4368715, -3709630, 29874200, -15022983, -20230386, -11410704, -16114594, -999085, -8142388, 5640030 }, - }, - { - { 10299610, 13746483, 11661824, 16234854, 7630238, 5998374, 9809887, -16694564, 15219798, -14327783 }, - { 27425505, -5719081, 3055006, 10660664, 23458024, 595578, -15398605, -1173195, -18342183, 9742717 }, - { 6744077, 2427284, 26042789, 2720740, -847906, 1118974, 32324614, 7406442, 12420155, 1994844 }, - }, - { - { 14012521, -5024720, -18384453, -9578469, -26485342, -3936439, -13033478, -10909803, 24319929, -6446333 }, - { 16412690, -4507367, 10772641, 15929391, -17068788, -4658621, 10555945, -10484049, -30102368, -4739048 }, - { 22397382, -7767684, -9293161, -12792868, 17166287, -9755136, -27333065, 6199366, 21880021, -12250760 }, - }, - { - { -4283307, 5368523, -31117018, 8163389, -30323063, 3209128, 16557151, 8890729, 8840445, 4957760 }, - { -15447727, 709327, -6919446, -10870178, -29777922, 6522332, -21720181, 12130072, -14796503, 5005757 }, - { -2114751, -14308128, 23019042, 15765735, -25269683, 6002752, 10183197, -13239326, -16395286, -2176112 }, - }, - }, - { - { - { -19025756, 1632005, 13466291, -7995100, -23640451, 16573537, -32013908, -3057104, 22208662, 2000468 }, - { 3065073, -1412761, -25598674, -361432, -17683065, -5703415, -8164212, 11248527, -3691214, -7414184 }, - { 10379208, -6045554, 8877319, 1473647, -29291284, -12507580, 16690915, 2553332, -3132688, 16400289 }, - }, - { - { 15716668, 1254266, -18472690, 7446274, -8448918, 6344164, -22097271, -7285580, 26894937, 9132066 }, - { 24158887, 12938817, 11085297, -8177598, -28063478, -4457083, -30576463, 64452, -6817084, -2692882 }, - { 13488534, 7794716, 22236231, 5989356, 25426474, -12578208, 2350710, -3418511, -4688006, 2364226 }, - }, - { - { 16335052, 9132434, 25640582, 6678888, 1725628, 8517937, -11807024, -11697457, 15445875, -7798101 }, - { 29004207, -7867081, 28661402, -640412, -12794003, -7943086, 31863255, -4135540, -278050, -15759279 }, - { -6122061, -14866665, -28614905, 14569919, -10857999, -3591829, 10343412, -6976290, -29828287, -10815811 }, - }, - { - { 27081650, 3463984, 14099042, -4517604, 1616303, -6205604, 29542636, 15372179, 17293797, 960709 }, - { 20263915, 11434237, -5765435, 11236810, 13505955, -10857102, -16111345, 6493122, -19384511, 7639714 }, - { -2830798, -14839232, 25403038, -8215196, -8317012, -16173699, 18006287, -16043750, 29994677, -15808121 }, - }, - { - { 9769828, 5202651, -24157398, -13631392, -28051003, -11561624, -24613141, -13860782, -31184575, 709464 }, - { 12286395, 13076066, -21775189, -1176622, -25003198, 4057652, -32018128, -8890874, 16102007, 13205847 }, - { 13733362, 5599946, 10557076, 3195751, -5557991, 8536970, -25540170, 8525972, 10151379, 10394400 }, - }, - { - { 4024660, -16137551, 22436262, 12276534, -9099015, -2686099, 19698229, 11743039, -33302334, 8934414 }, - { -15879800, -4525240, -8580747, -2934061, 14634845, -698278, -9449077, 3137094, -11536886, 11721158 }, - { 17555939, -5013938, 8268606, 2331751, -22738815, 9761013, 9319229, 8835153, -9205489, -1280045 }, - }, - { - { -461409, -7830014, 20614118, 16688288, -7514766, -4807119, 22300304, 505429, 6108462, -6183415 }, - { -5070281, 12367917, -30663534, 3234473, 32617080, -8422642, 29880583, -13483331, -26898490, -7867459 }, - { -31975283, 5726539, 26934134, 10237677, -3173717, -605053, 24199304, 3795095, 7592688, -14992079 }, - }, - { - { 21594432, -14964228, 17466408, -4077222, 32537084, 2739898, 6407723, 12018833, -28256052, 4298412 }, - { -20650503, -11961496, -27236275, 570498, 3767144, -1717540, 13891942, -1569194, 13717174, 10805743 }, - { -14676630, -15644296, 15287174, 11927123, 24177847, -8175568, -796431, 14860609, -26938930, -5863836 }, - }, - }, - { - { - { 12962541, 5311799, -10060768, 11658280, 18855286, -7954201, 13286263, -12808704, -4381056, 9882022 }, - { 18512079, 11319350, -20123124, 15090309, 18818594, 5271736, -22727904, 3666879, -23967430, -3299429 }, - { -6789020, -3146043, 16192429, 13241070, 15898607, -14206114, -10084880, -6661110, -2403099, 5276065 }, - }, - { - { 30169808, -5317648, 26306206, -11750859, 27814964, 7069267, 7152851, 3684982, 1449224, 13082861 }, - { 10342826, 3098505, 2119311, 193222, 25702612, 12233820, 23697382, 15056736, -21016438, -8202000 }, - { -33150110, 3261608, 22745853, 7948688, 19370557, -15177665, -26171976, 6482814, -10300080, -11060101 }, - }, - { - { 32869458, -5408545, 25609743, 15678670, -10687769, -15471071, 26112421, 2521008, -22664288, 6904815 }, - { 29506923, 4457497, 3377935, -9796444, -30510046, 12935080, 1561737, 3841096, -29003639, -6657642 }, - { 10340844, -6630377, -18656632, -2278430, 12621151, -13339055, 30878497, -11824370, -25584551, 5181966 }, - }, - { - { 25940115, -12658025, 17324188, -10307374, -8671468, 15029094, 24396252, -16450922, -2322852, -12388574 }, - { -21765684, 9916823, -1300409, 4079498, -1028346, 11909559, 1782390, 12641087, 20603771, -6561742 }, - { -18882287, -11673380, 24849422, 11501709, 13161720, -4768874, 1925523, 11914390, 4662781, 7820689 }, - }, - { - { 12241050, -425982, 8132691, 9393934, 32846760, -1599620, 29749456, 12172924, 16136752, 15264020 }, - { -10349955, -14680563, -8211979, 2330220, -17662549, -14545780, 10658213, 6671822, 19012087, 3772772 }, - { 3753511, -3421066, 10617074, 2028709, 14841030, -6721664, 28718732, -15762884, 20527771, 12988982 }, - }, - { - { -14822485, -5797269, -3707987, 12689773, -898983, -10914866, -24183046, -10564943, 3299665, -12424953 }, - { -16777703, -15253301, -9642417, 4978983, 3308785, 8755439, 6943197, 6461331, -25583147, 8991218 }, - { -17226263, 1816362, -1673288, -6086439, 31783888, -8175991, -32948145, 7417950, -30242287, 1507265 }, - }, - { - { 29692663, 6829891, -10498800, 4334896, 20945975, -11906496, -28887608, 8209391, 14606362, -10647073 }, - { -3481570, 8707081, 32188102, 5672294, 22096700, 1711240, -33020695, 9761487, 4170404, -2085325 }, - { -11587470, 14855945, -4127778, -1531857, -26649089, 15084046, 22186522, 16002000, -14276837, -8400798 }, - }, - { - { -4811456, 13761029, -31703877, -2483919, -3312471, 7869047, -7113572, -9620092, 13240845, 10965870 }, - { -7742563, -8256762, -14768334, -13656260, -23232383, 12387166, 4498947, 14147411, 29514390, 4302863 }, - { -13413405, -12407859, 20757302, -13801832, 14785143, 8976368, -5061276, -2144373, 17846988, -13971927 }, - }, - }, - { - { - { -2244452, -754728, -4597030, -1066309, -6247172, 1455299, -21647728, -9214789, -5222701, 12650267 }, - { -9906797, -16070310, 21134160, 12198166, -27064575, 708126, 387813, 13770293, -19134326, 10958663 }, - { 22470984, 12369526, 23446014, -5441109, -21520802, -9698723, -11772496, -11574455, -25083830, 4271862 }, - }, - { - { -25169565, -10053642, -19909332, 15361595, -5984358, 2159192, 75375, -4278529, -32526221, 8469673 }, - { 15854970, 4148314, -8893890, 7259002, 11666551, 13824734, -30531198, 2697372, 24154791, -9460943 }, - { 15446137, -15806644, 29759747, 14019369, 30811221, -9610191, -31582008, 12840104, 24913809, 9815020 }, - }, - { - { -4709286, -5614269, -31841498, -12288893, -14443537, 10799414, -9103676, 13438769, 18735128, 9466238 }, - { 11933045, 9281483, 5081055, -5183824, -2628162, -4905629, -7727821, -10896103, -22728655, 16199064 }, - { 14576810, 379472, -26786533, -8317236, -29426508, -10812974, -102766, 1876699, 30801119, 2164795 }, - }, - { - { 15995086, 3199873, 13672555, 13712240, -19378835, -4647646, -13081610, -15496269, -13492807, 1268052 }, - { -10290614, -3659039, -3286592, 10948818, 23037027, 3794475, -3470338, -12600221, -17055369, 3565904 }, - { 29210088, -9419337, -5919792, -4952785, 10834811, -13327726, -16512102, -10820713, -27162222, -14030531 }, - }, - { - { -13161890, 15508588, 16663704, -8156150, -28349942, 9019123, -29183421, -3769423, 2244111, -14001979 }, - { -5152875, -3800936, -9306475, -6071583, 16243069, 14684434, -25673088, -16180800, 13491506, 4641841 }, - { 10813417, 643330, -19188515, -728916, 30292062, -16600078, 27548447, -7721242, 14476989, -12767431 }, - }, - { - { 10292079, 9984945, 6481436, 8279905, -7251514, 7032743, 27282937, -1644259, -27912810, 12651324 }, - { -31185513, -813383, 22271204, 11835308, 10201545, 15351028, 17099662, 3988035, 21721536, -3148940 }, - { 10202177, -6545839, -31373232, -9574638, -32150642, -8119683, -12906320, 3852694, 13216206, 14842320 }, - }, - { - { -15815640, -10601066, -6538952, -7258995, -6984659, -6581778, -31500847, 13765824, -27434397, 9900184 }, - { 14465505, -13833331, -32133984, -14738873, -27443187, 12990492, 33046193, 15796406, -7051866, -8040114 }, - { 30924417, -8279620, 6359016, -12816335, 16508377, 9071735, -25488601, 15413635, 9524356, -7018878 }, - }, - { - { 12274201, -13175547, 32627641, -1785326, 6736625, 13267305, 5237659, -5109483, 15663516, 4035784 }, - { -2951309, 8903985, 17349946, 601635, -16432815, -4612556, -13732739, -15889334, -22258478, 4659091 }, - { -16916263, -4952973, -30393711, -15158821, 20774812, 15897498, 5736189, 15026997, -2178256, -13455585 }, - }, - }, - { - { - { -8858980, -2219056, 28571666, -10155518, -474467, -10105698, -3801496, 278095, 23440562, -290208 }, - { 10226241, -5928702, 15139956, 120818, -14867693, 5218603, 32937275, 11551483, -16571960, -7442864 }, - { 17932739, -12437276, -24039557, 10749060, 11316803, 7535897, 22503767, 5561594, -3646624, 3898661 }, - }, - { - { 7749907, -969567, -16339731, -16464, -25018111, 15122143, -1573531, 7152530, 21831162, 1245233 }, - { 26958459, -14658026, 4314586, 8346991, -5677764, 11960072, -32589295, -620035, -30402091, -16716212 }, - { -12165896, 9166947, 33491384, 13673479, 29787085, 13096535, 6280834, 14587357, -22338025, 13987525 }, - }, - { - { -24349909, 7778775, 21116000, 15572597, -4833266, -5357778, -4300898, -5124639, -7469781, -2858068 }, - { 9681908, -6737123, -31951644, 13591838, -6883821, 386950, 31622781, 6439245, -14581012, 4091397 }, - { -8426427, 1470727, -28109679, -1596990, 3978627, -5123623, -19622683, 12092163, 29077877, -14741988 }, - }, - { - { 5269168, -6859726, -13230211, -8020715, 25932563, 1763552, -5606110, -5505881, -20017847, 2357889 }, - { 32264008, -15407652, -5387735, -1160093, -2091322, -3946900, 23104804, -12869908, 5727338, 189038 }, - { 14609123, -8954470, -6000566, -16622781, -14577387, -7743898, -26745169, 10942115, -25888931, -14884697 }, - }, - { - { 20513500, 5557931, -15604613, 7829531, 26413943, -2019404, -21378968, 7471781, 13913677, -5137875 }, - { -25574376, 11967826, 29233242, 12948236, -6754465, 4713227, -8940970, 14059180, 12878652, 8511905 }, - { -25656801, 3393631, -2955415, -7075526, -2250709, 9366908, -30223418, 6812974, 5568676, -3127656 }, - }, - { - { 11630004, 12144454, 2116339, 13606037, 27378885, 15676917, -17408753, -13504373, -14395196, 8070818 }, - { 27117696, -10007378, -31282771, -5570088, 1127282, 12772488, -29845906, 10483306, -11552749, -1028714 }, - { 10637467, -5688064, 5674781, 1072708, -26343588, -6982302, -1683975, 9177853, -27493162, 15431203 }, - }, - { - { 20525145, 10892566, -12742472, 12779443, -29493034, 16150075, -28240519, 14943142, -15056790, -7935931 }, - { -30024462, 5626926, -551567, -9981087, 753598, 11981191, 25244767, -3239766, -3356550, 9594024 }, - { -23752644, 2636870, -5163910, -10103818, 585134, 7877383, 11345683, -6492290, 13352335, -10977084 }, - }, - { - { -1931799, -5407458, 3304649, -12884869, 17015806, -4877091, -29783850, -7752482, -13215537, -319204 }, - { 20239939, 6607058, 6203985, 3483793, -18386976, -779229, -20723742, 15077870, -22750759, 14523817 }, - { 27406042, -6041657, 27423596, -4497394, 4996214, 10002360, -28842031, -4545494, -30172742, -4805667 }, - }, - }, - { - { - { 11374242, 12660715, 17861383, -12540833, 10935568, 1099227, -13886076, -9091740, -27727044, 11358504 }, - { -12730809, 10311867, 1510375, 10778093, -2119455, -9145702, 32676003, 11149336, -26123651, 4985768 }, - { -19096303, 341147, -6197485, -239033, 15756973, -8796662, -983043, 13794114, -19414307, -15621255 }, - }, - { - { 6490081, 11940286, 25495923, -7726360, 8668373, -8751316, 3367603, 6970005, -1691065, -9004790 }, - { 1656497, 13457317, 15370807, 6364910, 13605745, 8362338, -19174622, -5475723, -16796596, -5031438 }, - { -22273315, -13524424, -64685, -4334223, -18605636, -10921968, -20571065, -7007978, -99853, -10237333 }, - }, - { - { 17747465, 10039260, 19368299, -4050591, -20630635, -16041286, 31992683, -15857976, -29260363, -5511971 }, - { 31932027, -4986141, -19612382, 16366580, 22023614, 88450, 11371999, -3744247, 4882242, -10626905 }, - { 29796507, 37186, 19818052, 10115756, -11829032, 3352736, 18551198, 3272828, -5190932, -4162409 }, - }, - { - { 12501286, 4044383, -8612957, -13392385, -32430052, 5136599, -19230378, -3529697, 330070, -3659409 }, - { 6384877, 2899513, 17807477, 7663917, -2358888, 12363165, 25366522, -8573892, -271295, 12071499 }, - { -8365515, -4042521, 25133448, -4517355, -6211027, 2265927, -32769618, 1936675, -5159697, 3829363 }, - }, - { - { 28425966, -5835433, -577090, -4697198, -14217555, 6870930, 7921550, -6567787, 26333140, 14267664 }, - { -11067219, 11871231, 27385719, -10559544, -4585914, -11189312, 10004786, -8709488, -21761224, 8930324 }, - { -21197785, -16396035, 25654216, -1725397, 12282012, 11008919, 1541940, 4757911, -26491501, -16408940 }, - }, - { - { 13537262, -7759490, -20604840, 10961927, -5922820, -13218065, -13156584, 6217254, -15943699, 13814990 }, - { -17422573, 15157790, 18705543, 29619, 24409717, -260476, 27361681, 9257833, -1956526, -1776914 }, - { -25045300, -10191966, 15366585, 15166509, -13105086, 8423556, -29171540, 12361135, -18685978, 4578290 }, - }, - { - { 24579768, 3711570, 1342322, -11180126, -27005135, 14124956, -22544529, 14074919, 21964432, 8235257 }, - { -6528613, -2411497, 9442966, -5925588, 12025640, -1487420, -2981514, -1669206, 13006806, 2355433 }, - { -16304899, -13605259, -6632427, -5142349, 16974359, -10911083, 27202044, 1719366, 1141648, -12796236 }, - }, - { - { -12863944, -13219986, -8318266, -11018091, -6810145, -4843894, 13475066, -3133972, 32674895, 13715045 }, - { 11423335, -5468059, 32344216, 8962751, 24989809, 9241752, -13265253, 16086212, -28740881, -15642093 }, - { -1409668, 12530728, -6368726, 10847387, 19531186, -14132160, -11709148, 7791794, -27245943, 4383347 }, - }, - }, - { - { - { -28970898, 5271447, -1266009, -9736989, -12455236, 16732599, -4862407, -4906449, 27193557, 6245191 }, - { -15193956, 5362278, -1783893, 2695834, 4960227, 12840725, 23061898, 3260492, 22510453, 8577507 }, - { -12632451, 11257346, -32692994, 13548177, -721004, 10879011, 31168030, 13952092, -29571492, -3635906 }, - }, - { - { 3877321, -9572739, 32416692, 5405324, -11004407, -13656635, 3759769, 11935320, 5611860, 8164018 }, - { -16275802, 14667797, 15906460, 12155291, -22111149, -9039718, 32003002, -8832289, 5773085, -8422109 }, - { -23788118, -8254300, 1950875, 8937633, 18686727, 16459170, -905725, 12376320, 31632953, 190926 }, - }, - { - { -24593607, -16138885, -8423991, 13378746, 14162407, 6901328, -8288749, 4508564, -25341555, -3627528 }, - { 8884438, -5884009, 6023974, 10104341, -6881569, -4941533, 18722941, -14786005, -1672488, 827625 }, - { -32720583, -16289296, -32503547, 7101210, 13354605, 2659080, -1800575, -14108036, -24878478, 1541286 }, - }, - { - { 2901347, -1117687, 3880376, -10059388, -17620940, -3612781, -21802117, -3567481, 20456845, -1885033 }, - { 27019610, 12299467, -13658288, -1603234, -12861660, -4861471, -19540150, -5016058, 29439641, 15138866 }, - { 21536104, -6626420, -32447818, -10690208, -22408077, 5175814, -5420040, -16361163, 7779328, 109896 }, - }, - { - { 30279744, 14648750, -8044871, 6425558, 13639621, -743509, 28698390, 12180118, 23177719, -554075 }, - { 26572847, 3405927, -31701700, 12890905, -19265668, 5335866, -6493768, 2378492, 4439158, -13279347 }, - { -22716706, 3489070, -9225266, -332753, 18875722, -1140095, 14819434, -12731527, -17717757, -5461437 }, - }, - { - { -5056483, 16566551, 15953661, 3767752, -10436499, 15627060, -820954, 2177225, 8550082, -15114165 }, - { -18473302, 16596775, -381660, 15663611, 22860960, 15585581, -27844109, -3582739, -23260460, -8428588 }, - { -32480551, 15707275, -8205912, -5652081, 29464558, 2713815, -22725137, 15860482, -21902570, 1494193 }, - }, - { - { -19562091, -14087393, -25583872, -9299552, 13127842, 759709, 21923482, 16529112, 8742704, 12967017 }, - { -28464899, 1553205, 32536856, -10473729, -24691605, -406174, -8914625, -2933896, -29903758, 15553883 }, - { 21877909, 3230008, 9881174, 10539357, -4797115, 2841332, 11543572, 14513274, 19375923, -12647961 }, - }, - { - { 8832269, -14495485, 13253511, 5137575, 5037871, 4078777, 24880818, -6222716, 2862653, 9455043 }, - { 29306751, 5123106, 20245049, -14149889, 9592566, 8447059, -2077124, -2990080, 15511449, 4789663 }, - { -20679756, 7004547, 8824831, -9434977, -4045704, -3750736, -5754762, 108893, 23513200, 16652362 }, - }, - }, - { - { - { -33256173, 4144782, -4476029, -6579123, 10770039, -7155542, -6650416, -12936300, -18319198, 10212860 }, - { 2756081, 8598110, 7383731, -6859892, 22312759, -1105012, 21179801, 2600940, -9988298, -12506466 }, - { -24645692, 13317462, -30449259, -15653928, 21365574, -10869657, 11344424, 864440, -2499677, -16710063 }, - }, - { - { -26432803, 6148329, -17184412, -14474154, 18782929, -275997, -22561534, 211300, 2719757, 4940997 }, - { -1323882, 3911313, -6948744, 14759765, -30027150, 7851207, 21690126, 8518463, 26699843, 5276295 }, - { -13149873, -6429067, 9396249, 365013, 24703301, -10488939, 1321586, 149635, -15452774, 7159369 }, - }, - { - { 9987780, -3404759, 17507962, 9505530, 9731535, -2165514, 22356009, 8312176, 22477218, -8403385 }, - { 18155857, -16504990, 19744716, 9006923, 15154154, -10538976, 24256460, -4864995, -22548173, 9334109 }, - { 2986088, -4911893, 10776628, -3473844, 10620590, -7083203, -21413845, 14253545, -22587149, 536906 }, - }, - { - { 4377756, 8115836, 24567078, 15495314, 11625074, 13064599, 7390551, 10589625, 10838060, -15420424 }, - { -19342404, 867880, 9277171, -3218459, -14431572, -1986443, 19295826, -15796950, 6378260, 699185 }, - { 7895026, 4057113, -7081772, -13077756, -17886831, -323126, -716039, 15693155, -5045064, -13373962 }, - }, - { - { -7737563, -5869402, -14566319, -7406919, 11385654, 13201616, 31730678, -10962840, -3918636, -9669325 }, - { 10188286, -15770834, -7336361, 13427543, 22223443, 14896287, 30743455, 7116568, -21786507, 5427593 }, - { 696102, 13206899, 27047647, -10632082, 15285305, -9853179, 10798490, -4578720, 19236243, 12477404 }, - }, - { - { -11229439, 11243796, -17054270, -8040865, -788228, -8167967, -3897669, 11180504, -23169516, 7733644 }, - { 17800790, -14036179, -27000429, -11766671, 23887827, 3149671, 23466177, -10538171, 10322027, 15313801 }, - { 26246234, 11968874, 32263343, -5468728, 6830755, -13323031, -15794704, -101982, -24449242, 10890804 }, - }, - { - { -31365647, 10271363, -12660625, -6267268, 16690207, -13062544, -14982212, 16484931, 25180797, -5334884 }, - { -586574, 10376444, -32586414, -11286356, 19801893, 10997610, 2276632, 9482883, 316878, 13820577 }, - { -9882808, -4510367, -2115506, 16457136, -11100081, 11674996, 30756178, -7515054, 30696930, -3712849 }, - }, - { - { 32988917, -9603412, 12499366, 7910787, -10617257, -11931514, -7342816, -9985397, -32349517, 7392473 }, - { -8855661, 15927861, 9866406, -3649411, -2396914, -16655781, -30409476, -9134995, 25112947, -2926644 }, - { -2504044, -436966, 25621774, -5678772, 15085042, -5479877, -24884878, -13526194, 5537438, -13914319 }, - }, - }, - { - { - { -11225584, 2320285, -9584280, 10149187, -33444663, 5808648, -14876251, -1729667, 31234590, 6090599 }, - { -9633316, 116426, 26083934, 2897444, -6364437, -2688086, 609721, 15878753, -6970405, -9034768 }, - { -27757857, 247744, -15194774, -9002551, 23288161, -10011936, -23869595, 6503646, 20650474, 1804084 }, - }, - { - { -27589786, 15456424, 8972517, 8469608, 15640622, 4439847, 3121995, -10329713, 27842616, -202328 }, - { -15306973, 2839644, 22530074, 10026331, 4602058, 5048462, 28248656, 5031932, -11375082, 12714369 }, - { 20807691, -7270825, 29286141, 11421711, -27876523, -13868230, -21227475, 1035546, -19733229, 12796920 }, - }, - { - { 12076899, -14301286, -8785001, -11848922, -25012791, 16400684, -17591495, -12899438, 3480665, -15182815 }, - { -32361549, 5457597, 28548107, 7833186, 7303070, -11953545, -24363064, -15921875, -33374054, 2771025 }, - { -21389266, 421932, 26597266, 6860826, 22486084, -6737172, -17137485, -4210226, -24552282, 15673397 }, - }, - { - { -20184622, 2338216, 19788685, -9620956, -4001265, -8740893, -20271184, 4733254, 3727144, -12934448 }, - { 6120119, 814863, -11794402, -622716, 6812205, -15747771, 2019594, 7975683, 31123697, -10958981 }, - { 30069250, -11435332, 30434654, 2958439, 18399564, -976289, 12296869, 9204260, -16432438, 9648165 }, - }, - { - { 32705432, -1550977, 30705658, 7451065, -11805606, 9631813, 3305266, 5248604, -26008332, -11377501 }, - { 17219865, 2375039, -31570947, -5575615, -19459679, 9219903, 294711, 15298639, 2662509, -16297073 }, - { -1172927, -7558695, -4366770, -4287744, -21346413, -8434326, 32087529, -1222777, 32247248, -14389861 }, - }, - { - { 14312628, 1221556, 17395390, -8700143, -4945741, -8684635, -28197744, -9637817, -16027623, -13378845 }, - { -1428825, -9678990, -9235681, 6549687, -7383069, -468664, 23046502, 9803137, 17597934, 2346211 }, - { 18510800, 15337574, 26171504, 981392, -22241552, 7827556, -23491134, -11323352, 3059833, -11782870 }, - }, - { - { 10141598, 6082907, 17829293, -1947643, 9830092, 13613136, -25556636, -5544586, -33502212, 3592096 }, - { 33114168, -15889352, -26525686, -13343397, 33076705, 8716171, 1151462, 1521897, -982665, -6837803 }, - { -32939165, -4255815, 23947181, -324178, -33072974, -12305637, -16637686, 3891704, 26353178, 693168 }, - }, - { - { 30374239, 1595580, -16884039, 13186931, 4600344, 406904, 9585294, -400668, 31375464, 14369965 }, - { -14370654, -7772529, 1510301, 6434173, -18784789, -6262728, 32732230, -13108839, 17901441, 16011505 }, - { 18171223, -11934626, -12500402, 15197122, -11038147, -15230035, -19172240, -16046376, 8764035, 12309598 }, - }, - }, - { - { - { 5975908, -5243188, -19459362, -9681747, -11541277, 14015782, -23665757, 1228319, 17544096, -10593782 }, - { 5811932, -1715293, 3442887, -2269310, -18367348, -8359541, -18044043, -15410127, -5565381, 12348900 }, - { -31399660, 11407555, 25755363, 6891399, -3256938, 14872274, -24849353, 8141295, -10632534, -585479 }, - }, - { - { -12675304, 694026, -5076145, 13300344, 14015258, -14451394, -9698672, -11329050, 30944593, 1130208 }, - { 8247766, -6710942, -26562381, -7709309, -14401939, -14648910, 4652152, 2488540, 23550156, -271232 }, - { 17294316, -3788438, 7026748, 15626851, 22990044, 113481, 2267737, -5908146, -408818, -137719 }, - }, - { - { 16091085, -16253926, 18599252, 7340678, 2137637, -1221657, -3364161, 14550936, 3260525, -7166271 }, - { -4910104, -13332887, 18550887, 10864893, -16459325, -7291596, -23028869, -13204905, -12748722, 2701326 }, - { -8574695, 16099415, 4629974, -16340524, -20786213, -6005432, -10018363, 9276971, 11329923, 1862132 }, - }, - { - { 14763076, -15903608, -30918270, 3689867, 3511892, 10313526, -21951088, 12219231, -9037963, -940300 }, - { 8894987, -3446094, 6150753, 3013931, 301220, 15693451, -31981216, -2909717, -15438168, 11595570 }, - { 15214962, 3537601, -26238722, -14058872, 4418657, -15230761, 13947276, 10730794, -13489462, -4363670 }, - }, - { - { -2538306, 7682793, 32759013, 263109, -29984731, -7955452, -22332124, -10188635, 977108, 699994 }, - { -12466472, 4195084, -9211532, 550904, -15565337, 12917920, 19118110, -439841, -30534533, -14337913 }, - { 31788461, -14507657, 4799989, 7372237, 8808585, -14747943, 9408237, -10051775, 12493932, -5409317 }, - }, - { - { -25680606, 5260744, -19235809, -6284470, -3695942, 16566087, 27218280, 2607121, 29375955, 6024730 }, - { 842132, -2794693, -4763381, -8722815, 26332018, -12405641, 11831880, 6985184, -9940361, 2854096 }, - { -4847262, -7969331, 2516242, -5847713, 9695691, -7221186, 16512645, 960770, 12121869, 16648078 }, - }, - { - { -15218652, 14667096, -13336229, 2013717, 30598287, -464137, -31504922, -7882064, 20237806, 2838411 }, - { -19288047, 4453152, 15298546, -16178388, 22115043, -15972604, 12544294, -13470457, 1068881, -12499905 }, - { -9558883, -16518835, 33238498, 13506958, 30505848, -1114596, -8486907, -2630053, 12521378, 4845654 }, - }, - { - { -28198521, 10744108, -2958380, 10199664, 7759311, -13088600, 3409348, -873400, -6482306, -12885870 }, - { -23561822, 6230156, -20382013, 10655314, -24040585, -11621172, 10477734, -1240216, -3113227, 13974498 }, - { 12966261, 15550616, -32038948, -1615346, 21025980, -629444, 5642325, 7188737, 18895762, 12629579 }, - }, - }, - { - { - { 14741879, -14946887, 22177208, -11721237, 1279741, 8058600, 11758140, 789443, 32195181, 3895677 }, - { 10758205, 15755439, -4509950, 9243698, -4879422, 6879879, -2204575, -3566119, -8982069, 4429647 }, - { -2453894, 15725973, -20436342, -10410672, -5803908, -11040220, -7135870, -11642895, 18047436, -15281743 }, - }, - { - { -25173001, -11307165, 29759956, 11776784, -22262383, -15820455, 10993114, -12850837, -17620701, -9408468 }, - { 21987233, 700364, -24505048, 14972008, -7774265, -5718395, 32155026, 2581431, -29958985, 8773375 }, - { -25568350, 454463, -13211935, 16126715, 25240068, 8594567, 20656846, 12017935, -7874389, -13920155 }, - }, - { - { 6028182, 6263078, -31011806, -11301710, -818919, 2461772, -31841174, -5468042, -1721788, -2776725 }, - { -12278994, 16624277, 987579, -5922598, 32908203, 1248608, 7719845, -4166698, 28408820, 6816612 }, - { -10358094, -8237829, 19549651, -12169222, 22082623, 16147817, 20613181, 13982702, -10339570, 5067943 }, - }, - { - { -30505967, -3821767, 12074681, 13582412, -19877972, 2443951, -19719286, 12746132, 5331210, -10105944 }, - { 30528811, 3601899, -1957090, 4619785, -27361822, -15436388, 24180793, -12570394, 27679908, -1648928 }, - { 9402404, -13957065, 32834043, 10838634, -26580150, -13237195, 26653274, -8685565, 22611444, -12715406 }, - }, - { - { 22190590, 1118029, 22736441, 15130463, -30460692, -5991321, 19189625, -4648942, 4854859, 6622139 }, - { -8310738, -2953450, -8262579, -3388049, -10401731, -271929, 13424426, -3567227, 26404409, 13001963 }, - { -31241838, -15415700, -2994250, 8939346, 11562230, -12840670, -26064365, -11621720, -15405155, 11020693 }, - }, - { - { 1866042, -7949489, -7898649, -10301010, 12483315, 13477547, 3175636, -12424163, 28761762, 1406734 }, - { -448555, -1777666, 13018551, 3194501, -9580420, -11161737, 24760585, -4347088, 25577411, -13378680 }, - { -24290378, 4759345, -690653, -1852816, 2066747, 10693769, -29595790, 9884936, -9368926, 4745410 }, - }, - { - { -9141284, 6049714, -19531061, -4341411, -31260798, 9944276, -15462008, -11311852, 10931924, -11931931 }, - { -16561513, 14112680, -8012645, 4817318, -8040464, -11414606, -22853429, 10856641, -20470770, 13434654 }, - { 22759489, -10073434, -16766264, -1871422, 13637442, -10168091, 1765144, -12654326, 28445307, -5364710 }, - }, - { - { 29875063, 12493613, 2795536, -3786330, 1710620, 15181182, -10195717, -8788675, 9074234, 1167180 }, - { -26205683, 11014233, -9842651, -2635485, -26908120, 7532294, -18716888, -9535498, 3843903, 9367684 }, - { -10969595, -6403711, 9591134, 9582310, 11349256, 108879, 16235123, 8601684, -139197, 4242895 }, - }, - }, - { - { - { 22092954, -13191123, -2042793, -11968512, 32186753, -11517388, -6574341, 2470660, -27417366, 16625501 }, - { -11057722, 3042016, 13770083, -9257922, 584236, -544855, -7770857, 2602725, -27351616, 14247413 }, - { 6314175, -10264892, -32772502, 15957557, -10157730, 168750, -8618807, 14290061, 27108877, -1180880 }, - }, - { - { -8586597, -7170966, 13241782, 10960156, -32991015, -13794596, 33547976, -11058889, -27148451, 981874 }, - { 22833440, 9293594, -32649448, -13618667, -9136966, 14756819, -22928859, -13970780, -10479804, -16197962 }, - { -7768587, 3326786, -28111797, 10783824, 19178761, 14905060, 22680049, 13906969, -15933690, 3797899 }, - }, - { - { 21721356, -4212746, -12206123, 9310182, -3882239, -13653110, 23740224, -2709232, 20491983, -8042152 }, - { 9209270, -15135055, -13256557, -6167798, -731016, 15289673, 25947805, 15286587, 30997318, -6703063 }, - { 7392032, 16618386, 23946583, -8039892, -13265164, -1533858, -14197445, -2321576, 17649998, -250080 }, - }, - { - { -9301088, -14193827, 30609526, -3049543, -25175069, -1283752, -15241566, -9525724, -2233253, 7662146 }, - { -17558673, 1763594, -33114336, 15908610, -30040870, -12174295, 7335080, -8472199, -3174674, 3440183 }, - { -19889700, -5977008, -24111293, -9688870, 10799743, -16571957, 40450, -4431835, 4862400, 1133 }, - }, - { - { -32856209, -7873957, -5422389, 14860950, -16319031, 7956142, 7258061, 311861, -30594991, -7379421 }, - { -3773428, -1565936, 28985340, 7499440, 24445838, 9325937, 29727763, 16527196, 18278453, 15405622 }, - { -4381906, 8508652, -19898366, -3674424, -5984453, 15149970, -13313598, 843523, -21875062, 13626197 }, - }, - { - { 2281448, -13487055, -10915418, -2609910, 1879358, 16164207, -10783882, 3953792, 13340839, 15928663 }, - { 31727126, -7179855, -18437503, -8283652, 2875793, -16390330, -25269894, -7014826, -23452306, 5964753 }, - { 4100420, -5959452, -17179337, 6017714, -18705837, 12227141, -26684835, 11344144, 2538215, -7570755 }, - }, - { - { -9433605, 6123113, 11159803, -2156608, 30016280, 14966241, -20474983, 1485421, -629256, -15958862 }, - { -26804558, 4260919, 11851389, 9658551, -32017107, 16367492, -20205425, -13191288, 11659922, -11115118 }, - { 26180396, 10015009, -30844224, -8581293, 5418197, 9480663, 2231568, -10170080, 33100372, -1306171 }, - }, - { - { 15121113, -5201871, -10389905, 15427821, -27509937, -15992507, 21670947, 4486675, -5931810, -14466380 }, - { 16166486, -9483733, -11104130, 6023908, -31926798, -1364923, 2340060, -16254968, -10735770, -10039824 }, - { 28042865, -3557089, -12126526, 12259706, -3717498, -6945899, 6766453, -8689599, 18036436, 5803270 }, - }, - }, - { - { - { -817581, 6763912, 11803561, 1585585, 10958447, -2671165, 23855391, 4598332, -6159431, -14117438 }, - { -31031306, -14256194, 17332029, -2383520, 31312682, -5967183, 696309, 50292, -20095739, 11763584 }, - { -594563, -2514283, -32234153, 12643980, 12650761, 14811489, 665117, -12613632, -19773211, -10713562 }, - }, - { - { 30464590, -11262872, -4127476, -12734478, 19835327, -7105613, -24396175, 2075773, -17020157, 992471 }, - { 18357185, -6994433, 7766382, 16342475, -29324918, 411174, 14578841, 8080033, -11574335, -10601610 }, - { 19598397, 10334610, 12555054, 2555664, 18821899, -10339780, 21873263, 16014234, 26224780, 16452269 }, - }, - { - { -30223925, 5145196, 5944548, 16385966, 3976735, 2009897, -11377804, -7618186, -20533829, 3698650 }, - { 14187449, 3448569, -10636236, -10810935, -22663880, -3433596, 7268410, -10890444, 27394301, 12015369 }, - { 19695761, 16087646, 28032085, 12999827, 6817792, 11427614, 20244189, -1312777, -13259127, -3402461 }, - }, - { - { 30860103, 12735208, -1888245, -4699734, -16974906, 2256940, -8166013, 12298312, -8550524, -10393462 }, - { -5719826, -11245325, -1910649, 15569035, 26642876, -7587760, -5789354, -15118654, -4976164, 12651793 }, - { -2848395, 9953421, 11531313, -5282879, 26895123, -12697089, -13118820, -16517902, 9768698, -2533218 }, - }, - { - { -24719459, 1894651, -287698, -4704085, 15348719, -8156530, 32767513, 12765450, 4940095, 10678226 }, - { 18860224, 15980149, -18987240, -1562570, -26233012, -11071856, -7843882, 13944024, -24372348, 16582019 }, - { -15504260, 4970268, -29893044, 4175593, -20993212, -2199756, -11704054, 15444560, -11003761, 7989037 }, - }, - { - { 31490452, 5568061, -2412803, 2182383, -32336847, 4531686, -32078269, 6200206, -19686113, -14800171 }, - { -17308668, -15879940, -31522777, -2831, -32887382, 16375549, 8680158, -16371713, 28550068, -6857132 }, - { -28126887, -5688091, 16837845, -1820458, -6850681, 12700016, -30039981, 4364038, 1155602, 5988841 }, - }, - { - { 21890435, -13272907, -12624011, 12154349, -7831873, 15300496, 23148983, -4470481, 24618407, 8283181 }, - { -33136107, -10512751, 9975416, 6841041, -31559793, 16356536, 3070187, -7025928, 1466169, 10740210 }, - { -1509399, -15488185, -13503385, -10655916, 32799044, 909394, -13938903, -5779719, -32164649, -15327040 }, - }, - { - { 3960823, -14267803, -28026090, -15918051, -19404858, 13146868, 15567327, 951507, -3260321, -573935 }, - { 24740841, 5052253, -30094131, 8961361, 25877428, 6165135, -24368180, 14397372, -7380369, -6144105 }, - { -28888365, 3510803, -28103278, -1158478, -11238128, -10631454, -15441463, -14453128, -1625486, -6494814 }, - }, - }, - { - { - { 793299, -9230478, 8836302, -6235707, -27360908, -2369593, 33152843, -4885251, -9906200, -621852 }, - { 5666233, 525582, 20782575, -8038419, -24538499, 14657740, 16099374, 1468826, -6171428, -15186581 }, - { -4859255, -3779343, -2917758, -6748019, 7778750, 11688288, -30404353, -9871238, -1558923, -9863646 }, - }, - { - { 10896332, -7719704, 824275, 472601, -19460308, 3009587, 25248958, 14783338, -30581476, -15757844 }, - { 10566929, 12612572, -31944212, 11118703, -12633376, 12362879, 21752402, 8822496, 24003793, 14264025 }, - { 27713862, -7355973, -11008240, 9227530, 27050101, 2504721, 23886875, -13117525, 13958495, -5732453 }, - }, - { - { -23481610, 4867226, -27247128, 3900521, 29838369, -8212291, -31889399, -10041781, 7340521, -15410068 }, - { 4646514, -8011124, -22766023, -11532654, 23184553, 8566613, 31366726, -1381061, -15066784, -10375192 }, - { -17270517, 12723032, -16993061, 14878794, 21619651, -6197576, 27584817, 3093888, -8843694, 3849921 }, - }, - { - { -9064912, 2103172, 25561640, -15125738, -5239824, 9582958, 32477045, -9017955, 5002294, -15550259 }, - { -12057553, -11177906, 21115585, -13365155, 8808712, -12030708, 16489530, 13378448, -25845716, 12741426 }, - { -5946367, 10645103, -30911586, 15390284, -3286982, -7118677, 24306472, 15852464, 28834118, -7646072 }, - }, - { - { -17335748, -9107057, -24531279, 9434953, -8472084, -583362, -13090771, 455841, 20461858, 5491305 }, - { 13669248, -16095482, -12481974, -10203039, -14569770, -11893198, -24995986, 11293807, -28588204, -9421832 }, - { 28497928, 6272777, -33022994, 14470570, 8906179, -1225630, 18504674, -14165166, 29867745, -8795943 }, - }, - { - { -16207023, 13517196, -27799630, -13697798, 24009064, -6373891, -6367600, -13175392, 22853429, -4012011 }, - { 24191378, 16712145, -13931797, 15217831, 14542237, 1646131, 18603514, -11037887, 12876623, -2112447 }, - { 17902668, 4518229, -411702, -2829247, 26878217, 5258055, -12860753, 608397, 16031844, 3723494 }, - }, - { - { -28632773, 12763728, -20446446, 7577504, 33001348, -13017745, 17558842, -7872890, 23896954, -4314245 }, - { -20005381, -12011952, 31520464, 605201, 2543521, 5991821, -2945064, 7229064, -9919646, -8826859 }, - { 28816045, 298879, -28165016, -15920938, 19000928, -1665890, -12680833, -2949325, -18051778, -2082915 }, - }, - { - { 16000882, -344896, 3493092, -11447198, -29504595, -13159789, 12577740, 16041268, -19715240, 7847707 }, - { 10151868, 10572098, 27312476, 7922682, 14825339, 4723128, -32855931, -6519018, -10020567, 3852848 }, - { -11430470, 15697596, -21121557, -4420647, 5386314, 15063598, 16514493, -15932110, 29330899, -15076224 }, - }, - }, - { - { - { -25499735, -4378794, -15222908, -6901211, 16615731, 2051784, 3303702, 15490, -27548796, 12314391 }, - { 15683520, -6003043, 18109120, -9980648, 15337968, -5997823, -16717435, 15921866, 16103996, -3731215 }, - { -23169824, -10781249, 13588192, -1628807, -3798557, -1074929, -19273607, 5402699, -29815713, -9841101 }, - }, - { - { 23190676, 2384583, -32714340, 3462154, -29903655, -1529132, -11266856, 8911517, -25205859, 2739713 }, - { 21374101, -3554250, -33524649, 9874411, 15377179, 11831242, -33529904, 6134907, 4931255, 11987849 }, - { -7732, -2978858, -16223486, 7277597, 105524, -322051, -31480539, 13861388, -30076310, 10117930 }, - }, - { - { -29501170, -10744872, -26163768, 13051539, -25625564, 5089643, -6325503, 6704079, 12890019, 15728940 }, - { -21972360, -11771379, -951059, -4418840, 14704840, 2695116, 903376, -10428139, 12885167, 8311031 }, - { -17516482, 5352194, 10384213, -13811658, 7506451, 13453191, 26423267, 4384730, 1888765, -5435404 }, - }, - { - { -25817338, -3107312, -13494599, -3182506, 30896459, -13921729, -32251644, -12707869, -19464434, -3340243 }, - { -23607977, -2665774, -526091, 4651136, 5765089, 4618330, 6092245, 14845197, 17151279, -9854116 }, - { -24830458, -12733720, -15165978, 10367250, -29530908, -265356, 22825805, -7087279, -16866484, 16176525 }, - }, - { - { -23583256, 6564961, 20063689, 3798228, -4740178, 7359225, 2006182, -10363426, -28746253, -10197509 }, - { -10626600, -4486402, -13320562, -5125317, 3432136, -6393229, 23632037, -1940610, 32808310, 1099883 }, - { 15030977, 5768825, -27451236, -2887299, -6427378, -15361371, -15277896, -6809350, 2051441, -15225865 }, - }, - { - { -3362323, -7239372, 7517890, 9824992, 23555850, 295369, 5148398, -14154188, -22686354, 16633660 }, - { 4577086, -16752288, 13249841, -15304328, 19958763, -14537274, 18559670, -10759549, 8402478, -9864273 }, - { -28406330, -1051581, -26790155, -907698, -17212414, -11030789, 9453451, -14980072, 17983010, 9967138 }, - }, - { - { -25762494, 6524722, 26585488, 9969270, 24709298, 1220360, -1677990, 7806337, 17507396, 3651560 }, - { -10420457, -4118111, 14584639, 15971087, -15768321, 8861010, 26556809, -5574557, -18553322, -11357135 }, - { 2839101, 14284142, 4029895, 3472686, 14402957, 12689363, -26642121, 8459447, -5605463, -7621941 }, - }, - { - { -4839289, -3535444, 9744961, 2871048, 25113978, 3187018, -25110813, -849066, 17258084, -7977739 }, - { 18164541, -10595176, -17154882, -1542417, 19237078, -9745295, 23357533, -15217008, 26908270, 12150756 }, - { -30264870, -7647865, 5112249, -7036672, -1499807, -6974257, 43168, -5537701, -32302074, 16215819 }, - }, - }, - { - { - { -6898905, 9824394, -12304779, -4401089, -31397141, -6276835, 32574489, 12532905, -7503072, -8675347 }, - { -27343522, -16515468, -27151524, -10722951, 946346, 16291093, 254968, 7168080, 21676107, -1943028 }, - { 21260961, -8424752, -16831886, -11920822, -23677961, 3968121, -3651949, -6215466, -3556191, -7913075 }, - }, - { - { 16544754, 13250366, -16804428, 15546242, -4583003, 12757258, -2462308, -8680336, -18907032, -9662799 }, - { -2415239, -15577728, 18312303, 4964443, -15272530, -12653564, 26820651, 16690659, 25459437, -4564609 }, - { -25144690, 11425020, 28423002, -11020557, -6144921, -15826224, 9142795, -2391602, -6432418, -1644817 }, - }, - { - { -23104652, 6253476, 16964147, -3768872, -25113972, -12296437, -27457225, -16344658, 6335692, 7249989 }, - { -30333227, 13979675, 7503222, -12368314, -11956721, -4621693, -30272269, 2682242, 25993170, -12478523 }, - { 4364628, 5930691, 32304656, -10044554, -8054781, 15091131, 22857016, -10598955, 31820368, 15075278 }, - }, - { - { 31879134, -8918693, 17258761, 90626, -8041836, -4917709, 24162788, -9650886, -17970238, 12833045 }, - { 19073683, 14851414, -24403169, -11860168, 7625278, 11091125, -19619190, 2074449, -9413939, 14905377 }, - { 24483667, -11935567, -2518866, -11547418, -1553130, 15355506, -25282080, 9253129, 27628530, -7555480 }, - }, - { - { 17597607, 8340603, 19355617, 552187, 26198470, -3176583, 4593324, -9157582, -14110875, 15297016 }, - { 510886, 14337390, -31785257, 16638632, 6328095, 2713355, -20217417, -11864220, 8683221, 2921426 }, - { 18606791, 11874196, 27155355, -5281482, -24031742, 6265446, -25178240, -1278924, 4674690, 13890525 }, - }, - { - { 13609624, 13069022, -27372361, -13055908, 24360586, 9592974, 14977157, 9835105, 4389687, 288396 }, - { 9922506, -519394, 13613107, 5883594, -18758345, -434263, -12304062, 8317628, 23388070, 16052080 }, - { 12720016, 11937594, -31970060, -5028689, 26900120, 8561328, -20155687, -11632979, -14754271, -10812892 }, - }, - { - { 15961858, 14150409, 26716931, -665832, -22794328, 13603569, 11829573, 7467844, -28822128, 929275 }, - { 11038231, -11582396, -27310482, -7316562, -10498527, -16307831, -23479533, -9371869, -21393143, 2465074 }, - { 20017163, -4323226, 27915242, 1529148, 12396362, 15675764, 13817261, -9658066, 2463391, -4622140 }, - }, - { - { -16358878, -12663911, -12065183, 4996454, -1256422, 1073572, 9583558, 12851107, 4003896, 12673717 }, - { -1731589, -15155870, -3262930, 16143082, 19294135, 13385325, 14741514, -9103726, 7903886, 2348101 }, - { 24536016, -16515207, 12715592, -3862155, 1511293, 10047386, -3842346, -7129159, -28377538, 10048127 }, - }, - }, - { - { - { -12622226, -6204820, 30718825, 2591312, -10617028, 12192840, 18873298, -7297090, -32297756, 15221632 }, - { -26478122, -11103864, 11546244, -1852483, 9180880, 7656409, -21343950, 2095755, 29769758, 6593415 }, - { -31994208, -2907461, 4176912, 3264766, 12538965, -868111, 26312345, -6118678, 30958054, 8292160 }, - }, - { - { 31429822, -13959116, 29173532, 15632448, 12174511, -2760094, 32808831, 3977186, 26143136, -3148876 }, - { 22648901, 1402143, -22799984, 13746059, 7936347, 365344, -8668633, -1674433, -3758243, -2304625 }, - { -15491917, 8012313, -2514730, -12702462, -23965846, -10254029, -1612713, -1535569, -16664475, 8194478 }, - }, - { - { 27338066, -7507420, -7414224, 10140405, -19026427, -6589889, 27277191, 8855376, 28572286, 3005164 }, - { 26287124, 4821776, 25476601, -4145903, -3764513, -15788984, -18008582, 1182479, -26094821, -13079595 }, - { -7171154, 3178080, 23970071, 6201893, -17195577, -4489192, -21876275, -13982627, 32208683, -1198248 }, - }, - { - { -16657702, 2817643, -10286362, 14811298, 6024667, 13349505, -27315504, -10497842, -27672585, -11539858 }, - { 15941029, -9405932, -21367050, 8062055, 31876073, -238629, -15278393, -1444429, 15397331, -4130193 }, - { 8934485, -13485467, -23286397, -13423241, -32446090, 14047986, 31170398, -1441021, -27505566, 15087184 }, - }, - { - { -18357243, -2156491, 24524913, -16677868, 15520427, -6360776, -15502406, 11461896, 16788528, -5868942 }, - { -1947386, 16013773, 21750665, 3714552, -17401782, -16055433, -3770287, -10323320, 31322514, -11615635 }, - { 21426655, -5650218, -13648287, -5347537, -28812189, -4920970, -18275391, -14621414, 13040862, -12112948 }, - }, - { - { 11293895, 12478086, -27136401, 15083750, -29307421, 14748872, 14555558, -13417103, 1613711, 4896935 }, - { -25894883, 15323294, -8489791, -8057900, 25967126, -13425460, 2825960, -4897045, -23971776, -11267415 }, - { -15924766, -5229880, -17443532, 6410664, 3622847, 10243618, 20615400, 12405433, -23753030, -8436416 }, - }, - { - { -7091295, 12556208, -20191352, 9025187, -17072479, 4333801, 4378436, 2432030, 23097949, -566018 }, - { 4565804, -16025654, 20084412, -7842817, 1724999, 189254, 24767264, 10103221, -18512313, 2424778 }, - { 366633, -11976806, 8173090, -6890119, 30788634, 5745705, -7168678, 1344109, -3642553, 12412659 }, - }, - { - { -24001791, 7690286, 14929416, -168257, -32210835, -13412986, 24162697, -15326504, -3141501, 11179385 }, - { 18289522, -14724954, 8056945, 16430056, -21729724, 7842514, -6001441, -1486897, -18684645, -11443503 }, - { 476239, 6601091, -6152790, -9723375, 17503545, -4863900, 27672959, 13403813, 11052904, 5219329 }, - }, - }, - { - { - { 20678546, -8375738, -32671898, 8849123, -5009758, 14574752, 31186971, -3973730, 9014762, -8579056 }, - { -13644050, -10350239, -15962508, 5075808, -1514661, -11534600, -33102500, 9160280, 8473550, -3256838 }, - { 24900749, 14435722, 17209120, -15292541, -22592275, 9878983, -7689309, -16335821, -24568481, 11788948 }, - }, - { - { -3118155, -11395194, -13802089, 14797441, 9652448, -6845904, -20037437, 10410733, -24568470, -1458691 }, - { -15659161, 16736706, -22467150, 10215878, -9097177, 7563911, 11871841, -12505194, -18513325, 8464118 }, - { -23400612, 8348507, -14585951, -861714, -3950205, -6373419, 14325289, 8628612, 33313881, -8370517 }, - }, - { - { -20186973, -4967935, 22367356, 5271547, -1097117, -4788838, -24805667, -10236854, -8940735, -5818269 }, - { -6948785, -1795212, -32625683, -16021179, 32635414, -7374245, 15989197, -12838188, 28358192, -4253904 }, - { -23561781, -2799059, -32351682, -1661963, -9147719, 10429267, -16637684, 4072016, -5351664, 5596589 }, - }, - { - { -28236598, -3390048, 12312896, 6213178, 3117142, 16078565, 29266239, 2557221, 1768301, 15373193 }, - { -7243358, -3246960, -4593467, -7553353, -127927, -912245, -1090902, -4504991, -24660491, 3442910 }, - { -30210571, 5124043, 14181784, 8197961, 18964734, -11939093, 22597931, 7176455, -18585478, 13365930 }, - }, - { - { -7877390, -1499958, 8324673, 4690079, 6261860, 890446, 24538107, -8570186, -9689599, -3031667 }, - { 25008904, -10771599, -4305031, -9638010, 16265036, 15721635, 683793, -11823784, 15723479, -15163481 }, - { -9660625, 12374379, -27006999, -7026148, -7724114, -12314514, 11879682, 5400171, 519526, -1235876 }, - }, - { - { 22258397, -16332233, -7869817, 14613016, -22520255, -2950923, -20353881, 7315967, 16648397, 7605640 }, - { -8081308, -8464597, -8223311, 9719710, 19259459, -15348212, 23994942, -5281555, -9468848, 4763278 }, - { -21699244, 9220969, -15730624, 1084137, -25476107, -2852390, 31088447, -7764523, -11356529, 728112 }, - }, - { - { 26047220, -11751471, -6900323, -16521798, 24092068, 9158119, -4273545, -12555558, -29365436, -5498272 }, - { 17510331, -322857, 5854289, 8403524, 17133918, -3112612, -28111007, 12327945, 10750447, 10014012 }, - { -10312768, 3936952, 9156313, -8897683, 16498692, -994647, -27481051, -666732, 3424691, 7540221 }, - }, - { - { 30322361, -6964110, 11361005, -4143317, 7433304, 4989748, -7071422, -16317219, -9244265, 15258046 }, - { 13054562, -2779497, 19155474, 469045, -12482797, 4566042, 5631406, 2711395, 1062915, -5136345 }, - { -19240248, -11254599, -29509029, -7499965, -5835763, 13005411, -6066489, 12194497, 32960380, 1459310 }, - }, - }, - { - { - { 19852034, 7027924, 23669353, 10020366, 8586503, -6657907, 394197, -6101885, 18638003, -11174937 }, - { 31395534, 15098109, 26581030, 8030562, -16527914, -5007134, 9012486, -7584354, -6643087, -5442636 }, - { -9192165, -2347377, -1997099, 4529534, 25766844, 607986, -13222, 9677543, -32294889, -6456008 }, - }, - { - { -2444496, -149937, 29348902, 8186665, 1873760, 12489863, -30934579, -7839692, -7852844, -8138429 }, - { -15236356, -15433509, 7766470, 746860, 26346930, -10221762, -27333451, 10754588, -9431476, 5203576 }, - { 31834314, 14135496, -770007, 5159118, 20917671, -16768096, -7467973, -7337524, 31809243, 7347066 }, - }, - { - { -9606723, -11874240, 20414459, 13033986, 13716524, -11691881, 19797970, -12211255, 15192876, -2087490 }, - { -12663563, -2181719, 1168162, -3804809, 26747877, -14138091, 10609330, 12694420, 33473243, -13382104 }, - { 33184999, 11180355, 15832085, -11385430, -1633671, 225884, 15089336, -11023903, -6135662, 14480053 }, - }, - { - { 31308717, -5619998, 31030840, -1897099, 15674547, -6582883, 5496208, 13685227, 27595050, 8737275 }, - { -20318852, -15150239, 10933843, -16178022, 8335352, -7546022, -31008351, -12610604, 26498114, 66511 }, - { 22644454, -8761729, -16671776, 4884562, -3105614, -13559366, 30540766, -4286747, -13327787, -7515095 }, - }, - { - { -28017847, 9834845, 18617207, -2681312, -3401956, -13307506, 8205540, 13585437, -17127465, 15115439 }, - { 23711543, -672915, 31206561, -8362711, 6164647, -9709987, -33535882, -1426096, 8236921, 16492939 }, - { -23910559, -13515526, -26299483, -4503841, 25005590, -7687270, 19574902, 10071562, 6708380, -6222424 }, - }, - { - { 2101391, -4930054, 19702731, 2367575, -15427167, 1047675, 5301017, 9328700, 29955601, -11678310 }, - { 3096359, 9271816, -21620864, -15521844, -14847996, -7592937, -25892142, -12635595, -9917575, 6216608 }, - { -32615849, 338663, -25195611, 2510422, -29213566, -13820213, 24822830, -6146567, -26767480, 7525079 }, - }, - { - { -23066649, -13985623, 16133487, -7896178, -3389565, 778788, -910336, -2782495, -19386633, 11994101 }, - { 21691500, -13624626, -641331, -14367021, 3285881, -3483596, -25064666, 9718258, -7477437, 13381418 }, - { 18445390, -4202236, 14979846, 11622458, -1727110, -3582980, 23111648, -6375247, 28535282, 15779576 }, - }, - { - { 30098053, 3089662, -9234387, 16662135, -21306940, 11308411, -14068454, 12021730, 9955285, -16303356 }, - { 9734894, -14576830, -7473633, -9138735, 2060392, 11313496, -18426029, 9924399, 20194861, 13380996 }, - { -26378102, -7965207, -22167821, 15789297, -18055342, -6168792, -1984914, 15707771, 26342023, 10146099 }, - }, - }, - { - { - { -26016874, -219943, 21339191, -41388, 19745256, -2878700, -29637280, 2227040, 21612326, -545728 }, - { -13077387, 1184228, 23562814, -5970442, -20351244, -6348714, 25764461, 12243797, -20856566, 11649658 }, - { -10031494, 11262626, 27384172, 2271902, 26947504, -15997771, 39944, 6114064, 33514190, 2333242 }, - }, - { - { -21433588, -12421821, 8119782, 7219913, -21830522, -9016134, -6679750, -12670638, 24350578, -13450001 }, - { -4116307, -11271533, -23886186, 4843615, -30088339, 690623, -31536088, -10406836, 8317860, 12352766 }, - { 18200138, -14475911, -33087759, -2696619, -23702521, -9102511, -23552096, -2287550, 20712163, 6719373 }, - }, - { - { 26656208, 6075253, -7858556, 1886072, -28344043, 4262326, 11117530, -3763210, 26224235, -3297458 }, - { -17168938, -14854097, -3395676, -16369877, -19954045, 14050420, 21728352, 9493610, 18620611, -16428628 }, - { -13323321, 13325349, 11432106, 5964811, 18609221, 6062965, -5269471, -9725556, -30701573, -16479657 }, - }, - { - { -23860538, -11233159, 26961357, 1640861, -32413112, -16737940, 12248509, -5240639, 13735342, 1934062 }, - { 25089769, 6742589, 17081145, -13406266, 21909293, -16067981, -15136294, -3765346, -21277997, 5473616 }, - { 31883677, -7961101, 1083432, -11572403, 22828471, 13290673, -7125085, 12469656, 29111212, -5451014 }, - }, - { - { 24244947, -15050407, -26262976, 2791540, -14997599, 16666678, 24367466, 6388839, -10295587, 452383 }, - { -25640782, -3417841, 5217916, 16224624, 19987036, -4082269, -24236251, -5915248, 15766062, 8407814 }, - { -20406999, 13990231, 15495425, 16395525, 5377168, 15166495, -8917023, -4388953, -8067909, 2276718 }, - }, - { - { 30157918, 12924066, -17712050, 9245753, 19895028, 3368142, -23827587, 5096219, 22740376, -7303417 }, - { 2041139, -14256350, 7783687, 13876377, -25946985, -13352459, 24051124, 13742383, -15637599, 13295222 }, - { 33338237, -8505733, 12532113, 7977527, 9106186, -1715251, -17720195, -4612972, -4451357, -14669444 }, - }, - { - { -20045281, 5454097, -14346548, 6447146, 28862071, 1883651, -2469266, -4141880, 7770569, 9620597 }, - { 23208068, 7979712, 33071466, 8149229, 1758231, -10834995, 30945528, -1694323, -33502340, -14767970 }, - { 1439958, -16270480, -1079989, -793782, 4625402, 10647766, -5043801, 1220118, 30494170, -11440799 }, - }, - { - { -5037580, -13028295, -2970559, -3061767, 15640974, -6701666, -26739026, 926050, -1684339, -13333647 }, - { 13908495, -3549272, 30919928, -6273825, -21521863, 7989039, 9021034, 9078865, 3353509, 4033511 }, - { -29663431, -15113610, 32259991, -344482, 24295849, -12912123, 23161163, 8839127, 27485041, 7356032 }, - }, - }, - { - { - { 9661027, 705443, 11980065, -5370154, -1628543, 14661173, -6346142, 2625015, 28431036, -16771834 }, - { -23839233, -8311415, -25945511, 7480958, -17681669, -8354183, -22545972, 14150565, 15970762, 4099461 }, - { 29262576, 16756590, 26350592, -8793563, 8529671, -11208050, 13617293, -9937143, 11465739, 8317062 }, - }, - { - { -25493081, -6962928, 32500200, -9419051, -23038724, -2302222, 14898637, 3848455, 20969334, -5157516 }, - { -20384450, -14347713, -18336405, 13884722, -33039454, 2842114, -21610826, -3649888, 11177095, 14989547 }, - { -24496721, -11716016, 16959896, 2278463, 12066309, 10137771, 13515641, 2581286, -28487508, 9930240 }, - }, - { - { -17751622, -2097826, 16544300, -13009300, -15914807, -14949081, 18345767, -13403753, 16291481, -5314038 }, - { -33229194, 2553288, 32678213, 9875984, 8534129, 6889387, -9676774, 6957617, 4368891, 9788741 }, - { 16660756, 7281060, -10830758, 12911820, 20108584, -8101676, -21722536, -8613148, 16250552, -11111103 }, - }, - { - { -19765507, 2390526, -16551031, 14161980, 1905286, 6414907, 4689584, 10604807, -30190403, 4782747 }, - { -1354539, 14736941, -7367442, -13292886, 7710542, -14155590, -9981571, 4383045, 22546403, 437323 }, - { 31665577, -12180464, -16186830, 1491339, -18368625, 3294682, 27343084, 2786261, -30633590, -14097016 }, - }, - { - { -14467279, -683715, -33374107, 7448552, 19294360, 14334329, -19690631, 2355319, -19284671, -6114373 }, - { 15121312, -15796162, 6377020, -6031361, -10798111, -12957845, 18952177, 15496498, -29380133, 11754228 }, - { -2637277, -13483075, 8488727, -14303896, 12728761, -1622493, 7141596, 11724556, 22761615, -10134141 }, - }, - { - { 16918416, 11729663, -18083579, 3022987, -31015732, -13339659, -28741185, -12227393, 32851222, 11717399 }, - { 11166634, 7338049, -6722523, 4531520, -29468672, -7302055, 31474879, 3483633, -1193175, -4030831 }, - { -185635, 9921305, 31456609, -13536438, -12013818, 13348923, 33142652, 6546660, -19985279, -3948376 }, - }, - { - { -32460596, 11266712, -11197107, -7899103, 31703694, 3855903, -8537131, -12833048, -30772034, -15486313 }, - { -18006477, 12709068, 3991746, -6479188, -21491523, -10550425, -31135347, -16049879, 10928917, 3011958 }, - { -6957757, -15594337, 31696059, 334240, 29576716, 14796075, -30831056, -12805180, 18008031, 10258577 }, - }, - { - { -22448644, 15655569, 7018479, -4410003, -30314266, -1201591, -1853465, 1367120, 25127874, 6671743 }, - { 29701166, -14373934, -10878120, 9279288, -17568, 13127210, 21382910, 11042292, 25838796, 4642684 }, - { -20430234, 14955537, -24126347, 8124619, -5369288, -5990470, 30468147, -13900640, 18423289, 4177476 }, - }, - }, -}; diff --git a/src/ed25519/sc.c b/src/ed25519/sc.c deleted file mode 100644 index ee54d99..0000000 --- a/src/ed25519/sc.c +++ /dev/null @@ -1,785 +0,0 @@ -#include "fixedint.h" -#include "sc.h" - -static uint64_t load_3(const unsigned char *in) { - uint64_t result; - - result = in[0]; - result |= shlu64(in[1], 8); - result |= shlu64(in[2], 16); - - return result; -} - -static uint64_t load_4(const unsigned char *in) { - uint64_t result; - - result = in[0]; - result |= shlu64(in[1], 8); - result |= shlu64(in[2], 16); - result |= shlu64(in[3], 24); - - return result; -} - -/* -Input: - s[0]+256*s[1]+...+256^63*s[63] = s - -Output: - s[0]+256*s[1]+...+256^31*s[31] = s mod l - where l = 2^252 + 27742317777372353535851937790883648493. - Overwrites s in place. -*/ - -void sc_reduce(unsigned char *s) { - int64_t s0 = 2097151 & load_3(s); - int64_t s1 = 2097151 & (load_4(s + 2) >> 5); - int64_t s2 = 2097151 & (load_3(s + 5) >> 2); - int64_t s3 = 2097151 & (load_4(s + 7) >> 7); - int64_t s4 = 2097151 & (load_4(s + 10) >> 4); - int64_t s5 = 2097151 & (load_3(s + 13) >> 1); - int64_t s6 = 2097151 & (load_4(s + 15) >> 6); - int64_t s7 = 2097151 & (load_3(s + 18) >> 3); - int64_t s8 = 2097151 & load_3(s + 21); - int64_t s9 = 2097151 & (load_4(s + 23) >> 5); - int64_t s10 = 2097151 & (load_3(s + 26) >> 2); - int64_t s11 = 2097151 & (load_4(s + 28) >> 7); - int64_t s12 = 2097151 & (load_4(s + 31) >> 4); - int64_t s13 = 2097151 & (load_3(s + 34) >> 1); - int64_t s14 = 2097151 & (load_4(s + 36) >> 6); - int64_t s15 = 2097151 & (load_3(s + 39) >> 3); - int64_t s16 = 2097151 & load_3(s + 42); - int64_t s17 = 2097151 & (load_4(s + 44) >> 5); - int64_t s18 = 2097151 & (load_3(s + 47) >> 2); - int64_t s19 = 2097151 & (load_4(s + 49) >> 7); - int64_t s20 = 2097151 & (load_4(s + 52) >> 4); - int64_t s21 = 2097151 & (load_3(s + 55) >> 1); - int64_t s22 = 2097151 & (load_4(s + 57) >> 6); - int64_t s23 = (load_4(s + 60) >> 3); - int64_t carry0; - int64_t carry1; - int64_t carry2; - int64_t carry3; - int64_t carry4; - int64_t carry5; - int64_t carry6; - int64_t carry7; - int64_t carry8; - int64_t carry9; - int64_t carry10; - int64_t carry11; - int64_t carry12; - int64_t carry13; - int64_t carry14; - int64_t carry15; - int64_t carry16; - - s11 += s23 * 666643; - s12 += s23 * 470296; - s13 += s23 * 654183; - s14 -= s23 * 997805; - s15 += s23 * 136657; - s16 -= s23 * 683901; - s10 += s22 * 666643; - s11 += s22 * 470296; - s12 += s22 * 654183; - s13 -= s22 * 997805; - s14 += s22 * 136657; - s15 -= s22 * 683901; - s9 += s21 * 666643; - s10 += s21 * 470296; - s11 += s21 * 654183; - s12 -= s21 * 997805; - s13 += s21 * 136657; - s14 -= s21 * 683901; - s8 += s20 * 666643; - s9 += s20 * 470296; - s10 += s20 * 654183; - s11 -= s20 * 997805; - s12 += s20 * 136657; - s13 -= s20 * 683901; - s7 += s19 * 666643; - s8 += s19 * 470296; - s9 += s19 * 654183; - s10 -= s19 * 997805; - s11 += s19 * 136657; - s12 -= s19 * 683901; - s6 += s18 * 666643; - s7 += s18 * 470296; - s8 += s18 * 654183; - s9 -= s18 * 997805; - s10 += s18 * 136657; - s11 -= s18 * 683901; - carry6 = (s6 + (1 << 20)) >> 21; - s7 += carry6; - s6 -= shl64(carry6, 21); - carry8 = (s8 + (1 << 20)) >> 21; - s9 += carry8; - s8 -= shl64(carry8, 21); - carry10 = (s10 + (1 << 20)) >> 21; - s11 += carry10; - s10 -= shl64(carry10, 21); - carry12 = (s12 + (1 << 20)) >> 21; - s13 += carry12; - s12 -= shl64(carry12, 21); - carry14 = (s14 + (1 << 20)) >> 21; - s15 += carry14; - s14 -= shl64(carry14, 21); - carry16 = (s16 + (1 << 20)) >> 21; - s17 += carry16; - s16 -= shl64(carry16, 21); - carry7 = (s7 + (1 << 20)) >> 21; - s8 += carry7; - s7 -= shl64(carry7, 21); - carry9 = (s9 + (1 << 20)) >> 21; - s10 += carry9; - s9 -= shl64(carry9, 21); - carry11 = (s11 + (1 << 20)) >> 21; - s12 += carry11; - s11 -= shl64(carry11, 21); - carry13 = (s13 + (1 << 20)) >> 21; - s14 += carry13; - s13 -= shl64(carry13, 21); - carry15 = (s15 + (1 << 20)) >> 21; - s16 += carry15; - s15 -= shl64(carry15, 21); - s5 += s17 * 666643; - s6 += s17 * 470296; - s7 += s17 * 654183; - s8 -= s17 * 997805; - s9 += s17 * 136657; - s10 -= s17 * 683901; - s4 += s16 * 666643; - s5 += s16 * 470296; - s6 += s16 * 654183; - s7 -= s16 * 997805; - s8 += s16 * 136657; - s9 -= s16 * 683901; - s3 += s15 * 666643; - s4 += s15 * 470296; - s5 += s15 * 654183; - s6 -= s15 * 997805; - s7 += s15 * 136657; - s8 -= s15 * 683901; - s2 += s14 * 666643; - s3 += s14 * 470296; - s4 += s14 * 654183; - s5 -= s14 * 997805; - s6 += s14 * 136657; - s7 -= s14 * 683901; - s1 += s13 * 666643; - s2 += s13 * 470296; - s3 += s13 * 654183; - s4 -= s13 * 997805; - s5 += s13 * 136657; - s6 -= s13 * 683901; - s0 += s12 * 666643; - s1 += s12 * 470296; - s2 += s12 * 654183; - s3 -= s12 * 997805; - s4 += s12 * 136657; - s5 -= s12 * 683901; - s12 = 0; - carry0 = (s0 + (1 << 20)) >> 21; - s1 += carry0; - s0 -= shl64(carry0, 21); - carry2 = (s2 + (1 << 20)) >> 21; - s3 += carry2; - s2 -= shl64(carry2, 21); - carry4 = (s4 + (1 << 20)) >> 21; - s5 += carry4; - s4 -= shl64(carry4, 21); - carry6 = (s6 + (1 << 20)) >> 21; - s7 += carry6; - s6 -= shl64(carry6, 21); - carry8 = (s8 + (1 << 20)) >> 21; - s9 += carry8; - s8 -= shl64(carry8, 21); - carry10 = (s10 + (1 << 20)) >> 21; - s11 += carry10; - s10 -= shl64(carry10, 21); - carry1 = (s1 + (1 << 20)) >> 21; - s2 += carry1; - s1 -= shl64(carry1, 21); - carry3 = (s3 + (1 << 20)) >> 21; - s4 += carry3; - s3 -= shl64(carry3, 21); - carry5 = (s5 + (1 << 20)) >> 21; - s6 += carry5; - s5 -= shl64(carry5, 21); - carry7 = (s7 + (1 << 20)) >> 21; - s8 += carry7; - s7 -= shl64(carry7, 21); - carry9 = (s9 + (1 << 20)) >> 21; - s10 += carry9; - s9 -= shl64(carry9, 21); - carry11 = (s11 + (1 << 20)) >> 21; - s12 += carry11; - s11 -= shl64(carry11, 21); - s0 += s12 * 666643; - s1 += s12 * 470296; - s2 += s12 * 654183; - s3 -= s12 * 997805; - s4 += s12 * 136657; - s5 -= s12 * 683901; - s12 = 0; - carry0 = s0 >> 21; - s1 += carry0; - s0 -= shl64(carry0, 21); - carry1 = s1 >> 21; - s2 += carry1; - s1 -= shl64(carry1, 21); - carry2 = s2 >> 21; - s3 += carry2; - s2 -= shl64(carry2, 21); - carry3 = s3 >> 21; - s4 += carry3; - s3 -= shl64(carry3, 21); - carry4 = s4 >> 21; - s5 += carry4; - s4 -= shl64(carry4, 21); - carry5 = s5 >> 21; - s6 += carry5; - s5 -= shl64(carry5, 21); - carry6 = s6 >> 21; - s7 += carry6; - s6 -= shl64(carry6, 21); - carry7 = s7 >> 21; - s8 += carry7; - s7 -= shl64(carry7, 21); - carry8 = s8 >> 21; - s9 += carry8; - s8 -= shl64(carry8, 21); - carry9 = s9 >> 21; - s10 += carry9; - s9 -= shl64(carry9, 21); - carry10 = s10 >> 21; - s11 += carry10; - s10 -= shl64(carry10, 21); - carry11 = s11 >> 21; - s12 += carry11; - s11 -= shl64(carry11, 21); - s0 += s12 * 666643; - s1 += s12 * 470296; - s2 += s12 * 654183; - s3 -= s12 * 997805; - s4 += s12 * 136657; - s5 -= s12 * 683901; - carry0 = s0 >> 21; - s1 += carry0; - s0 -= shl64(carry0, 21); - carry1 = s1 >> 21; - s2 += carry1; - s1 -= shl64(carry1, 21); - carry2 = s2 >> 21; - s3 += carry2; - s2 -= shl64(carry2, 21); - carry3 = s3 >> 21; - s4 += carry3; - s3 -= shl64(carry3, 21); - carry4 = s4 >> 21; - s5 += carry4; - s4 -= shl64(carry4, 21); - carry5 = s5 >> 21; - s6 += carry5; - s5 -= shl64(carry5, 21); - carry6 = s6 >> 21; - s7 += carry6; - s6 -= shl64(carry6, 21); - carry7 = s7 >> 21; - s8 += carry7; - s7 -= shl64(carry7, 21); - carry8 = s8 >> 21; - s9 += carry8; - s8 -= shl64(carry8, 21); - carry9 = s9 >> 21; - s10 += carry9; - s9 -= shl64(carry9, 21); - carry10 = s10 >> 21; - s11 += carry10; - s10 -= shl64(carry10, 21); - - s[0] = (unsigned char)(s0 >> 0); - s[1] = (unsigned char)(s0 >> 8); - s[2] = (unsigned char)((s0 >> 16) | shl64(s1, 5)); - s[3] = (unsigned char)(s1 >> 3); - s[4] = (unsigned char)(s1 >> 11); - s[5] = (unsigned char)((s1 >> 19) | shl64(s2, 2)); - s[6] = (unsigned char)(s2 >> 6); - s[7] = (unsigned char)((s2 >> 14) | shl64(s3, 7)); - s[8] = (unsigned char)(s3 >> 1); - s[9] = (unsigned char)(s3 >> 9); - s[10] = (unsigned char)((s3 >> 17) | shl64(s4, 4)); - s[11] = (unsigned char)(s4 >> 4); - s[12] = (unsigned char)(s4 >> 12); - s[13] = (unsigned char)((s4 >> 20) | shl64(s5, 1)); - s[14] = (unsigned char)(s5 >> 7); - s[15] = (unsigned char)((s5 >> 15) | shl64(s6, 6)); - s[16] = (unsigned char)(s6 >> 2); - s[17] = (unsigned char)(s6 >> 10); - s[18] = (unsigned char)((s6 >> 18) | shl64(s7, 3)); - s[19] = (unsigned char)(s7 >> 5); - s[20] = (unsigned char)(s7 >> 13); - s[21] = (unsigned char)(s8 >> 0); - s[22] = (unsigned char)(s8 >> 8); - s[23] = (unsigned char)((s8 >> 16) | shl64(s9, 5)); - s[24] = (unsigned char)(s9 >> 3); - s[25] = (unsigned char)(s9 >> 11); - s[26] = (unsigned char)((s9 >> 19) | shl64(s10, 2)); - s[27] = (unsigned char)(s10 >> 6); - s[28] = (unsigned char)((s10 >> 14) | shl64(s11, 7)); - s[29] = (unsigned char)(s11 >> 1); - s[30] = (unsigned char)(s11 >> 9); - s[31] = (unsigned char)(s11 >> 17); -} - - - -/* -Input: - a[0]+256*a[1]+...+256^31*a[31] = a - b[0]+256*b[1]+...+256^31*b[31] = b - c[0]+256*c[1]+...+256^31*c[31] = c - -Output: - s[0]+256*s[1]+...+256^31*s[31] = (ab+c) mod l - where l = 2^252 + 27742317777372353535851937790883648493. -*/ - -void sc_muladd(unsigned char *s, const unsigned char *a, const unsigned char *b, const unsigned char *c) { - int64_t a0 = 2097151 & load_3(a); - int64_t a1 = 2097151 & (load_4(a + 2) >> 5); - int64_t a2 = 2097151 & (load_3(a + 5) >> 2); - int64_t a3 = 2097151 & (load_4(a + 7) >> 7); - int64_t a4 = 2097151 & (load_4(a + 10) >> 4); - int64_t a5 = 2097151 & (load_3(a + 13) >> 1); - int64_t a6 = 2097151 & (load_4(a + 15) >> 6); - int64_t a7 = 2097151 & (load_3(a + 18) >> 3); - int64_t a8 = 2097151 & load_3(a + 21); - int64_t a9 = 2097151 & (load_4(a + 23) >> 5); - int64_t a10 = 2097151 & (load_3(a + 26) >> 2); - int64_t a11 = (load_4(a + 28) >> 7); - int64_t b0 = 2097151 & load_3(b); - int64_t b1 = 2097151 & (load_4(b + 2) >> 5); - int64_t b2 = 2097151 & (load_3(b + 5) >> 2); - int64_t b3 = 2097151 & (load_4(b + 7) >> 7); - int64_t b4 = 2097151 & (load_4(b + 10) >> 4); - int64_t b5 = 2097151 & (load_3(b + 13) >> 1); - int64_t b6 = 2097151 & (load_4(b + 15) >> 6); - int64_t b7 = 2097151 & (load_3(b + 18) >> 3); - int64_t b8 = 2097151 & load_3(b + 21); - int64_t b9 = 2097151 & (load_4(b + 23) >> 5); - int64_t b10 = 2097151 & (load_3(b + 26) >> 2); - int64_t b11 = (load_4(b + 28) >> 7); - int64_t c0 = 2097151 & load_3(c); - int64_t c1 = 2097151 & (load_4(c + 2) >> 5); - int64_t c2 = 2097151 & (load_3(c + 5) >> 2); - int64_t c3 = 2097151 & (load_4(c + 7) >> 7); - int64_t c4 = 2097151 & (load_4(c + 10) >> 4); - int64_t c5 = 2097151 & (load_3(c + 13) >> 1); - int64_t c6 = 2097151 & (load_4(c + 15) >> 6); - int64_t c7 = 2097151 & (load_3(c + 18) >> 3); - int64_t c8 = 2097151 & load_3(c + 21); - int64_t c9 = 2097151 & (load_4(c + 23) >> 5); - int64_t c10 = 2097151 & (load_3(c + 26) >> 2); - int64_t c11 = (load_4(c + 28) >> 7); - int64_t s0; - int64_t s1; - int64_t s2; - int64_t s3; - int64_t s4; - int64_t s5; - int64_t s6; - int64_t s7; - int64_t s8; - int64_t s9; - int64_t s10; - int64_t s11; - int64_t s12; - int64_t s13; - int64_t s14; - int64_t s15; - int64_t s16; - int64_t s17; - int64_t s18; - int64_t s19; - int64_t s20; - int64_t s21; - int64_t s22; - int64_t s23; - int64_t carry0; - int64_t carry1; - int64_t carry2; - int64_t carry3; - int64_t carry4; - int64_t carry5; - int64_t carry6; - int64_t carry7; - int64_t carry8; - int64_t carry9; - int64_t carry10; - int64_t carry11; - int64_t carry12; - int64_t carry13; - int64_t carry14; - int64_t carry15; - int64_t carry16; - int64_t carry17; - int64_t carry18; - int64_t carry19; - int64_t carry20; - int64_t carry21; - int64_t carry22; - - s0 = c0 + a0 * b0; - s1 = c1 + a0 * b1 + a1 * b0; - s2 = c2 + a0 * b2 + a1 * b1 + a2 * b0; - s3 = c3 + a0 * b3 + a1 * b2 + a2 * b1 + a3 * b0; - s4 = c4 + a0 * b4 + a1 * b3 + a2 * b2 + a3 * b1 + a4 * b0; - s5 = c5 + a0 * b5 + a1 * b4 + a2 * b3 + a3 * b2 + a4 * b1 + a5 * b0; - s6 = c6 + a0 * b6 + a1 * b5 + a2 * b4 + a3 * b3 + a4 * b2 + a5 * b1 + a6 * b0; - s7 = c7 + a0 * b7 + a1 * b6 + a2 * b5 + a3 * b4 + a4 * b3 + a5 * b2 + a6 * b1 + a7 * b0; - s8 = c8 + a0 * b8 + a1 * b7 + a2 * b6 + a3 * b5 + a4 * b4 + a5 * b3 + a6 * b2 + a7 * b1 + a8 * b0; - s9 = c9 + a0 * b9 + a1 * b8 + a2 * b7 + a3 * b6 + a4 * b5 + a5 * b4 + a6 * b3 + a7 * b2 + a8 * b1 + a9 * b0; - s10 = c10 + a0 * b10 + a1 * b9 + a2 * b8 + a3 * b7 + a4 * b6 + a5 * b5 + a6 * b4 + a7 * b3 + a8 * b2 + a9 * b1 + a10 * b0; - s11 = c11 + a0 * b11 + a1 * b10 + a2 * b9 + a3 * b8 + a4 * b7 + a5 * b6 + a6 * b5 + a7 * b4 + a8 * b3 + a9 * b2 + a10 * b1 + a11 * b0; - s12 = a1 * b11 + a2 * b10 + a3 * b9 + a4 * b8 + a5 * b7 + a6 * b6 + a7 * b5 + a8 * b4 + a9 * b3 + a10 * b2 + a11 * b1; - s13 = a2 * b11 + a3 * b10 + a4 * b9 + a5 * b8 + a6 * b7 + a7 * b6 + a8 * b5 + a9 * b4 + a10 * b3 + a11 * b2; - s14 = a3 * b11 + a4 * b10 + a5 * b9 + a6 * b8 + a7 * b7 + a8 * b6 + a9 * b5 + a10 * b4 + a11 * b3; - s15 = a4 * b11 + a5 * b10 + a6 * b9 + a7 * b8 + a8 * b7 + a9 * b6 + a10 * b5 + a11 * b4; - s16 = a5 * b11 + a6 * b10 + a7 * b9 + a8 * b8 + a9 * b7 + a10 * b6 + a11 * b5; - s17 = a6 * b11 + a7 * b10 + a8 * b9 + a9 * b8 + a10 * b7 + a11 * b6; - s18 = a7 * b11 + a8 * b10 + a9 * b9 + a10 * b8 + a11 * b7; - s19 = a8 * b11 + a9 * b10 + a10 * b9 + a11 * b8; - s20 = a9 * b11 + a10 * b10 + a11 * b9; - s21 = a10 * b11 + a11 * b10; - s22 = a11 * b11; - s23 = 0; - carry0 = (s0 + (1 << 20)) >> 21; - s1 += carry0; - s0 -= shl64(carry0, 21); - carry2 = (s2 + (1 << 20)) >> 21; - s3 += carry2; - s2 -= shl64(carry2, 21); - carry4 = (s4 + (1 << 20)) >> 21; - s5 += carry4; - s4 -= shl64(carry4, 21); - carry6 = (s6 + (1 << 20)) >> 21; - s7 += carry6; - s6 -= shl64(carry6, 21); - carry8 = (s8 + (1 << 20)) >> 21; - s9 += carry8; - s8 -= shl64(carry8, 21); - carry10 = (s10 + (1 << 20)) >> 21; - s11 += carry10; - s10 -= shl64(carry10, 21); - carry12 = (s12 + (1 << 20)) >> 21; - s13 += carry12; - s12 -= shl64(carry12, 21); - carry14 = (s14 + (1 << 20)) >> 21; - s15 += carry14; - s14 -= shl64(carry14, 21); - carry16 = (s16 + (1 << 20)) >> 21; - s17 += carry16; - s16 -= shl64(carry16, 21); - carry18 = (s18 + (1 << 20)) >> 21; - s19 += carry18; - s18 -= shl64(carry18, 21); - carry20 = (s20 + (1 << 20)) >> 21; - s21 += carry20; - s20 -= shl64(carry20, 21); - carry22 = (s22 + (1 << 20)) >> 21; - s23 += carry22; - s22 -= shl64(carry22, 21); - carry1 = (s1 + (1 << 20)) >> 21; - s2 += carry1; - s1 -= shl64(carry1, 21); - carry3 = (s3 + (1 << 20)) >> 21; - s4 += carry3; - s3 -= shl64(carry3, 21); - carry5 = (s5 + (1 << 20)) >> 21; - s6 += carry5; - s5 -= shl64(carry5, 21); - carry7 = (s7 + (1 << 20)) >> 21; - s8 += carry7; - s7 -= shl64(carry7, 21); - carry9 = (s9 + (1 << 20)) >> 21; - s10 += carry9; - s9 -= shl64(carry9, 21); - carry11 = (s11 + (1 << 20)) >> 21; - s12 += carry11; - s11 -= shl64(carry11, 21); - carry13 = (s13 + (1 << 20)) >> 21; - s14 += carry13; - s13 -= shl64(carry13, 21); - carry15 = (s15 + (1 << 20)) >> 21; - s16 += carry15; - s15 -= shl64(carry15, 21); - carry17 = (s17 + (1 << 20)) >> 21; - s18 += carry17; - s17 -= shl64(carry17, 21); - carry19 = (s19 + (1 << 20)) >> 21; - s20 += carry19; - s19 -= shl64(carry19, 21); - carry21 = (s21 + (1 << 20)) >> 21; - s22 += carry21; - s21 -= shl64(carry21, 21); - s11 += s23 * 666643; - s12 += s23 * 470296; - s13 += s23 * 654183; - s14 -= s23 * 997805; - s15 += s23 * 136657; - s16 -= s23 * 683901; - s10 += s22 * 666643; - s11 += s22 * 470296; - s12 += s22 * 654183; - s13 -= s22 * 997805; - s14 += s22 * 136657; - s15 -= s22 * 683901; - s9 += s21 * 666643; - s10 += s21 * 470296; - s11 += s21 * 654183; - s12 -= s21 * 997805; - s13 += s21 * 136657; - s14 -= s21 * 683901; - s8 += s20 * 666643; - s9 += s20 * 470296; - s10 += s20 * 654183; - s11 -= s20 * 997805; - s12 += s20 * 136657; - s13 -= s20 * 683901; - s7 += s19 * 666643; - s8 += s19 * 470296; - s9 += s19 * 654183; - s10 -= s19 * 997805; - s11 += s19 * 136657; - s12 -= s19 * 683901; - s6 += s18 * 666643; - s7 += s18 * 470296; - s8 += s18 * 654183; - s9 -= s18 * 997805; - s10 += s18 * 136657; - s11 -= s18 * 683901; - carry6 = (s6 + (1 << 20)) >> 21; - s7 += carry6; - s6 -= shl64(carry6, 21); - carry8 = (s8 + (1 << 20)) >> 21; - s9 += carry8; - s8 -= shl64(carry8, 21); - carry10 = (s10 + (1 << 20)) >> 21; - s11 += carry10; - s10 -= shl64(carry10, 21); - carry12 = (s12 + (1 << 20)) >> 21; - s13 += carry12; - s12 -= shl64(carry12, 21); - carry14 = (s14 + (1 << 20)) >> 21; - s15 += carry14; - s14 -= shl64(carry14, 21); - carry16 = (s16 + (1 << 20)) >> 21; - s17 += carry16; - s16 -= shl64(carry16, 21); - carry7 = (s7 + (1 << 20)) >> 21; - s8 += carry7; - s7 -= shl64(carry7, 21); - carry9 = (s9 + (1 << 20)) >> 21; - s10 += carry9; - s9 -= shl64(carry9, 21); - carry11 = (s11 + (1 << 20)) >> 21; - s12 += carry11; - s11 -= shl64(carry11, 21); - carry13 = (s13 + (1 << 20)) >> 21; - s14 += carry13; - s13 -= shl64(carry13, 21); - carry15 = (s15 + (1 << 20)) >> 21; - s16 += carry15; - s15 -= shl64(carry15, 21); - s5 += s17 * 666643; - s6 += s17 * 470296; - s7 += s17 * 654183; - s8 -= s17 * 997805; - s9 += s17 * 136657; - s10 -= s17 * 683901; - s4 += s16 * 666643; - s5 += s16 * 470296; - s6 += s16 * 654183; - s7 -= s16 * 997805; - s8 += s16 * 136657; - s9 -= s16 * 683901; - s3 += s15 * 666643; - s4 += s15 * 470296; - s5 += s15 * 654183; - s6 -= s15 * 997805; - s7 += s15 * 136657; - s8 -= s15 * 683901; - s2 += s14 * 666643; - s3 += s14 * 470296; - s4 += s14 * 654183; - s5 -= s14 * 997805; - s6 += s14 * 136657; - s7 -= s14 * 683901; - s1 += s13 * 666643; - s2 += s13 * 470296; - s3 += s13 * 654183; - s4 -= s13 * 997805; - s5 += s13 * 136657; - s6 -= s13 * 683901; - s0 += s12 * 666643; - s1 += s12 * 470296; - s2 += s12 * 654183; - s3 -= s12 * 997805; - s4 += s12 * 136657; - s5 -= s12 * 683901; - s12 = 0; - carry0 = (s0 + (1 << 20)) >> 21; - s1 += carry0; - s0 -= shl64(carry0, 21); - carry2 = (s2 + (1 << 20)) >> 21; - s3 += carry2; - s2 -= shl64(carry2, 21); - carry4 = (s4 + (1 << 20)) >> 21; - s5 += carry4; - s4 -= shl64(carry4, 21); - carry6 = (s6 + (1 << 20)) >> 21; - s7 += carry6; - s6 -= shl64(carry6, 21); - carry8 = (s8 + (1 << 20)) >> 21; - s9 += carry8; - s8 -= shl64(carry8, 21); - carry10 = (s10 + (1 << 20)) >> 21; - s11 += carry10; - s10 -= shl64(carry10, 21); - carry1 = (s1 + (1 << 20)) >> 21; - s2 += carry1; - s1 -= shl64(carry1, 21); - carry3 = (s3 + (1 << 20)) >> 21; - s4 += carry3; - s3 -= shl64(carry3, 21); - carry5 = (s5 + (1 << 20)) >> 21; - s6 += carry5; - s5 -= shl64(carry5, 21); - carry7 = (s7 + (1 << 20)) >> 21; - s8 += carry7; - s7 -= shl64(carry7, 21); - carry9 = (s9 + (1 << 20)) >> 21; - s10 += carry9; - s9 -= shl64(carry9, 21); - carry11 = (s11 + (1 << 20)) >> 21; - s12 += carry11; - s11 -= shl64(carry11, 21); - s0 += s12 * 666643; - s1 += s12 * 470296; - s2 += s12 * 654183; - s3 -= s12 * 997805; - s4 += s12 * 136657; - s5 -= s12 * 683901; - s12 = 0; - carry0 = s0 >> 21; - s1 += carry0; - s0 -= shl64(carry0, 21); - carry1 = s1 >> 21; - s2 += carry1; - s1 -= shl64(carry1, 21); - carry2 = s2 >> 21; - s3 += carry2; - s2 -= shl64(carry2, 21); - carry3 = s3 >> 21; - s4 += carry3; - s3 -= shl64(carry3, 21); - carry4 = s4 >> 21; - s5 += carry4; - s4 -= shl64(carry4, 21); - carry5 = s5 >> 21; - s6 += carry5; - s5 -= shl64(carry5, 21); - carry6 = s6 >> 21; - s7 += carry6; - s6 -= shl64(carry6, 21); - carry7 = s7 >> 21; - s8 += carry7; - s7 -= shl64(carry7, 21); - carry8 = s8 >> 21; - s9 += carry8; - s8 -= shl64(carry8, 21); - carry9 = s9 >> 21; - s10 += carry9; - s9 -= shl64(carry9, 21); - carry10 = s10 >> 21; - s11 += carry10; - s10 -= shl64(carry10, 21); - carry11 = s11 >> 21; - s12 += carry11; - s11 -= shl64(carry11, 21); - s0 += s12 * 666643; - s1 += s12 * 470296; - s2 += s12 * 654183; - s3 -= s12 * 997805; - s4 += s12 * 136657; - s5 -= s12 * 683901; - carry0 = s0 >> 21; - s1 += carry0; - s0 -= shl64(carry0, 21); - carry1 = s1 >> 21; - s2 += carry1; - s1 -= shl64(carry1, 21); - carry2 = s2 >> 21; - s3 += carry2; - s2 -= shl64(carry2, 21); - carry3 = s3 >> 21; - s4 += carry3; - s3 -= shl64(carry3, 21); - carry4 = s4 >> 21; - s5 += carry4; - s4 -= shl64(carry4, 21); - carry5 = s5 >> 21; - s6 += carry5; - s5 -= shl64(carry5, 21); - carry6 = s6 >> 21; - s7 += carry6; - s6 -= shl64(carry6, 21); - carry7 = s7 >> 21; - s8 += carry7; - s7 -= shl64(carry7, 21); - carry8 = s8 >> 21; - s9 += carry8; - s8 -= shl64(carry8, 21); - carry9 = s9 >> 21; - s10 += carry9; - s9 -= shl64(carry9, 21); - carry10 = s10 >> 21; - s11 += carry10; - s10 -= shl64(carry10, 21); - - s[0] = (unsigned char)(s0 >> 0); - s[1] = (unsigned char)(s0 >> 8); - s[2] = (unsigned char)((s0 >> 16) | shl64(s1, 5)); - s[3] = (unsigned char)(s1 >> 3); - s[4] = (unsigned char)(s1 >> 11); - s[5] = (unsigned char)((s1 >> 19) | shl64(s2, 2)); - s[6] = (unsigned char)(s2 >> 6); - s[7] = (unsigned char)((s2 >> 14) | shl64(s3, 7)); - s[8] = (unsigned char)(s3 >> 1); - s[9] = (unsigned char)(s3 >> 9); - s[10] = (unsigned char)((s3 >> 17) | shl64(s4, 4)); - s[11] = (unsigned char)(s4 >> 4); - s[12] = (unsigned char)(s4 >> 12); - s[13] = (unsigned char)((s4 >> 20) | shl64(s5, 1)); - s[14] = (unsigned char)(s5 >> 7); - s[15] = (unsigned char)((s5 >> 15) | shl64(s6, 6)); - s[16] = (unsigned char)(s6 >> 2); - s[17] = (unsigned char)(s6 >> 10); - s[18] = (unsigned char)((s6 >> 18) | shl64(s7, 3)); - s[19] = (unsigned char)(s7 >> 5); - s[20] = (unsigned char)(s7 >> 13); - s[21] = (unsigned char)(s8 >> 0); - s[22] = (unsigned char)(s8 >> 8); - s[23] = (unsigned char)((s8 >> 16) | shl64(s9, 5)); - s[24] = (unsigned char)(s9 >> 3); - s[25] = (unsigned char)(s9 >> 11); - s[26] = (unsigned char)((s9 >> 19) | shl64(s10, 2)); - s[27] = (unsigned char)(s10 >> 6); - s[28] = (unsigned char)((s10 >> 14) | shl64(s11, 7)); - s[29] = (unsigned char)(s11 >> 1); - s[30] = (unsigned char)(s11 >> 9); - s[31] = (unsigned char)(s11 >> 17); -} diff --git a/src/ed25519/sc.h b/src/ed25519/sc.h deleted file mode 100644 index e29e7fa..0000000 --- a/src/ed25519/sc.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef SC_H -#define SC_H - -/* -The set of scalars is \Z/l -where l = 2^252 + 27742317777372353535851937790883648493. -*/ - -void sc_reduce(unsigned char *s); -void sc_muladd(unsigned char *s, const unsigned char *a, const unsigned char *b, const unsigned char *c); - -#endif diff --git a/src/ed25519/sha512.c b/src/ed25519/sha512.c deleted file mode 100644 index 9cdf94d..0000000 --- a/src/ed25519/sha512.c +++ /dev/null @@ -1,303 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - * - * Tom St Denis, tomstdenis@gmail.com, http://libtom.org - */ - -#include "fixedint.h" -#include "sha512.h" - -/* the K array */ -static const uint64_t K[80] = { - UINT64_C(0x428a2f98d728ae22), UINT64_C(0x7137449123ef65cd), - UINT64_C(0xb5c0fbcfec4d3b2f), UINT64_C(0xe9b5dba58189dbbc), - UINT64_C(0x3956c25bf348b538), UINT64_C(0x59f111f1b605d019), - UINT64_C(0x923f82a4af194f9b), UINT64_C(0xab1c5ed5da6d8118), - UINT64_C(0xd807aa98a3030242), UINT64_C(0x12835b0145706fbe), - UINT64_C(0x243185be4ee4b28c), UINT64_C(0x550c7dc3d5ffb4e2), - UINT64_C(0x72be5d74f27b896f), UINT64_C(0x80deb1fe3b1696b1), - UINT64_C(0x9bdc06a725c71235), UINT64_C(0xc19bf174cf692694), - UINT64_C(0xe49b69c19ef14ad2), UINT64_C(0xefbe4786384f25e3), - UINT64_C(0x0fc19dc68b8cd5b5), UINT64_C(0x240ca1cc77ac9c65), - UINT64_C(0x2de92c6f592b0275), UINT64_C(0x4a7484aa6ea6e483), - UINT64_C(0x5cb0a9dcbd41fbd4), UINT64_C(0x76f988da831153b5), - UINT64_C(0x983e5152ee66dfab), UINT64_C(0xa831c66d2db43210), - UINT64_C(0xb00327c898fb213f), UINT64_C(0xbf597fc7beef0ee4), - UINT64_C(0xc6e00bf33da88fc2), UINT64_C(0xd5a79147930aa725), - UINT64_C(0x06ca6351e003826f), UINT64_C(0x142929670a0e6e70), - UINT64_C(0x27b70a8546d22ffc), UINT64_C(0x2e1b21385c26c926), - UINT64_C(0x4d2c6dfc5ac42aed), UINT64_C(0x53380d139d95b3df), - UINT64_C(0x650a73548baf63de), UINT64_C(0x766a0abb3c77b2a8), - UINT64_C(0x81c2c92e47edaee6), UINT64_C(0x92722c851482353b), - UINT64_C(0xa2bfe8a14cf10364), UINT64_C(0xa81a664bbc423001), - UINT64_C(0xc24b8b70d0f89791), UINT64_C(0xc76c51a30654be30), - UINT64_C(0xd192e819d6ef5218), UINT64_C(0xd69906245565a910), - UINT64_C(0xf40e35855771202a), UINT64_C(0x106aa07032bbd1b8), - UINT64_C(0x19a4c116b8d2d0c8), UINT64_C(0x1e376c085141ab53), - UINT64_C(0x2748774cdf8eeb99), UINT64_C(0x34b0bcb5e19b48a8), - UINT64_C(0x391c0cb3c5c95a63), UINT64_C(0x4ed8aa4ae3418acb), - UINT64_C(0x5b9cca4f7763e373), UINT64_C(0x682e6ff3d6b2b8a3), - UINT64_C(0x748f82ee5defb2fc), UINT64_C(0x78a5636f43172f60), - UINT64_C(0x84c87814a1f0ab72), UINT64_C(0x8cc702081a6439ec), - UINT64_C(0x90befffa23631e28), UINT64_C(0xa4506cebde82bde9), - UINT64_C(0xbef9a3f7b2c67915), UINT64_C(0xc67178f2e372532b), - UINT64_C(0xca273eceea26619c), UINT64_C(0xd186b8c721c0c207), - UINT64_C(0xeada7dd6cde0eb1e), UINT64_C(0xf57d4f7fee6ed178), - UINT64_C(0x06f067aa72176fba), UINT64_C(0x0a637dc5a2c898a6), - UINT64_C(0x113f9804bef90dae), UINT64_C(0x1b710b35131c471b), - UINT64_C(0x28db77f523047d84), UINT64_C(0x32caab7b40c72493), - UINT64_C(0x3c9ebe0a15c9bebc), UINT64_C(0x431d67c49c100d4c), - UINT64_C(0x4cc5d4becb3e42b6), UINT64_C(0x597f299cfc657e2a), - UINT64_C(0x5fcb6fab3ad6faec), UINT64_C(0x6c44198c4a475817) -}; - -/* Various logical functions */ - -#define ROR64c(x, y) \ - ( ((((x)&UINT64_C(0xFFFFFFFFFFFFFFFF))>>((uint64_t)(y)&UINT64_C(63))) | \ - ((x)<<((uint64_t)(64-((y)&UINT64_C(63)))))) & UINT64_C(0xFFFFFFFFFFFFFFFF)) - -#define STORE64H(x, y) \ - { (y)[0] = (unsigned char)(((x)>>56)&255); (y)[1] = (unsigned char)(((x)>>48)&255); \ - (y)[2] = (unsigned char)(((x)>>40)&255); (y)[3] = (unsigned char)(((x)>>32)&255); \ - (y)[4] = (unsigned char)(((x)>>24)&255); (y)[5] = (unsigned char)(((x)>>16)&255); \ - (y)[6] = (unsigned char)(((x)>>8)&255); (y)[7] = (unsigned char)((x)&255); } - -#define LOAD64H(x, y) \ - { x = (((uint64_t)((y)[0] & 255))<<56)|(((uint64_t)((y)[1] & 255))<<48) | \ - (((uint64_t)((y)[2] & 255))<<40)|(((uint64_t)((y)[3] & 255))<<32) | \ - (((uint64_t)((y)[4] & 255))<<24)|(((uint64_t)((y)[5] & 255))<<16) | \ - (((uint64_t)((y)[6] & 255))<<8)|(((uint64_t)((y)[7] & 255))); } - - -#define Ch(x,y,z) (z ^ (x & (y ^ z))) -#define Maj(x,y,z) (((x | y) & z) | (x & y)) -#define S(x, n) ROR64c(x, n) -#define R(x, n) (((x) &UINT64_C(0xFFFFFFFFFFFFFFFF))>>((uint64_t)n)) -#define Sigma0(x) (S(x, 28) ^ S(x, 34) ^ S(x, 39)) -#define Sigma1(x) (S(x, 14) ^ S(x, 18) ^ S(x, 41)) -#define Gamma0(x) (S(x, 1) ^ S(x, 8) ^ R(x, 7)) -#define Gamma1(x) (S(x, 19) ^ S(x, 61) ^ R(x, 6)) -#ifndef MIN -#define MIN(x, y) ( ((x)<(y))?(x):(y) ) -#endif - -/* compress 1024-bits */ -static int sha512_compress(sha512_context *md, const unsigned char *buf) { - uint64_t S[8], W[80], t0, t1; - int i; - - /* copy state into S */ - for(i = 0; i < 8; i++) { - S[i] = md->state[i]; - } - - /* copy the state into 1024-bits into W[0..15] */ - for(i = 0; i < 16; i++) { - LOAD64H(W[i], buf + (8 * i)); - } - - /* fill W[16..79] */ - for(i = 16; i < 80; i++) { - W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16]; - } - - /* Compress */ -#define RND(a,b,c,d,e,f,g,h,i) \ - t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \ - t1 = Sigma0(a) + Maj(a, b, c);\ - d += t0; \ - h = t0 + t1; - - for(i = 0; i < 80; i += 8) { - RND(S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], i + 0); - RND(S[7], S[0], S[1], S[2], S[3], S[4], S[5], S[6], i + 1); - RND(S[6], S[7], S[0], S[1], S[2], S[3], S[4], S[5], i + 2); - RND(S[5], S[6], S[7], S[0], S[1], S[2], S[3], S[4], i + 3); - RND(S[4], S[5], S[6], S[7], S[0], S[1], S[2], S[3], i + 4); - RND(S[3], S[4], S[5], S[6], S[7], S[0], S[1], S[2], i + 5); - RND(S[2], S[3], S[4], S[5], S[6], S[7], S[0], S[1], i + 6); - RND(S[1], S[2], S[3], S[4], S[5], S[6], S[7], S[0], i + 7); - } - -#undef RND - - - - /* feedback */ - for(i = 0; i < 8; i++) { - md->state[i] = md->state[i] + S[i]; - } - - return 0; -} - - -/** - Initialize the hash state - @param md The hash state you wish to initialize - @return 0 if successful -*/ -int sha512_init(sha512_context *md) { - if(md == NULL) { - return 1; - } - - md->curlen = 0; - md->length = 0; - md->state[0] = UINT64_C(0x6a09e667f3bcc908); - md->state[1] = UINT64_C(0xbb67ae8584caa73b); - md->state[2] = UINT64_C(0x3c6ef372fe94f82b); - md->state[3] = UINT64_C(0xa54ff53a5f1d36f1); - md->state[4] = UINT64_C(0x510e527fade682d1); - md->state[5] = UINT64_C(0x9b05688c2b3e6c1f); - md->state[6] = UINT64_C(0x1f83d9abfb41bd6b); - md->state[7] = UINT64_C(0x5be0cd19137e2179); - - return 0; -} - -/** - Process a block of memory though the hash - @param md The hash state - @param in The data to hash - @param inlen The length of the data (octets) - @return 0 if successful -*/ -int sha512_update(sha512_context *md, const void *vin, size_t inlen) { - const unsigned char *in = vin; - size_t n; - size_t i; - int err; - - if(md == NULL) { - return 1; - } - - if(in == NULL) { - return 1; - } - - if(md->curlen > sizeof(md->buf)) { - return 1; - } - - while(inlen > 0) { - if(md->curlen == 0 && inlen >= 128) { - if((err = sha512_compress(md, in)) != 0) { - return err; - } - - md->length += 128 * 8; - in += 128; - inlen -= 128; - } else { - n = MIN(inlen, (128 - md->curlen)); - - for(i = 0; i < n; i++) { - md->buf[i + md->curlen] = in[i]; - } - - - md->curlen += n; - in += n; - inlen -= n; - - if(md->curlen == 128) { - if((err = sha512_compress(md, md->buf)) != 0) { - return err; - } - - md->length += 8 * 128; - md->curlen = 0; - } - } - } - - return 0; -} - -/** - Terminate the hash to get the digest - @param md The hash state - @param out [out] The destination of the hash (64 bytes) - @return 0 if successful -*/ -int sha512_final(sha512_context *md, void *vout) { - int i; - unsigned char *out = vout; - - if(md == NULL) { - return 1; - } - - if(out == NULL) { - return 1; - } - - if(md->curlen >= sizeof(md->buf)) { - return 1; - } - - /* increase the length of the message */ - md->length += md->curlen * UINT64_C(8); - - /* append the '1' bit */ - md->buf[md->curlen++] = (unsigned char)0x80; - - /* if the length is currently above 112 bytes we append zeros - * then compress. Then we can fall back to padding zeros and length - * encoding like normal. - */ - if(md->curlen > 112) { - while(md->curlen < 128) { - md->buf[md->curlen++] = (unsigned char)0; - } - - sha512_compress(md, md->buf); - md->curlen = 0; - } - - /* pad up to 120 bytes of zeroes - * note: that from 112 to 120 is the 64 MSB of the length. We assume that you won't hash - * > 2^64 bits of data... :-) - */ - while(md->curlen < 120) { - md->buf[md->curlen++] = (unsigned char)0; - } - - /* store length */ - STORE64H(md->length, md->buf + 120); - sha512_compress(md, md->buf); - - /* copy output */ - for(i = 0; i < 8; i++) { - STORE64H(md->state[i], out + (8 * i)); - } - - return 0; -} - -int sha512(const void *message, size_t message_len, void *out) { - sha512_context ctx; - int ret; - - if((ret = sha512_init(&ctx))) { - return ret; - } - - if((ret = sha512_update(&ctx, message, message_len))) { - return ret; - } - - if((ret = sha512_final(&ctx, out))) { - return ret; - } - - return 0; -} diff --git a/src/ed25519/sha512.h b/src/ed25519/sha512.h deleted file mode 100644 index 95461ce..0000000 --- a/src/ed25519/sha512.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef SHA512_H -#define SHA512_H - -#include - -#include "fixedint.h" - -/* state */ -typedef struct sha512_context_ { - uint64_t length, state[8]; - size_t curlen; - unsigned char buf[128]; -} sha512_context; - - -int sha512_init(sha512_context *md); -int sha512_final(sha512_context *md, void *out); -int sha512_update(sha512_context *md, const void *in, size_t inlen); -int sha512(const void *message, size_t message_len, void *out); - -#endif diff --git a/src/ed25519/sign.c b/src/ed25519/sign.c deleted file mode 100644 index 0c4eea9..0000000 --- a/src/ed25519/sign.c +++ /dev/null @@ -1,31 +0,0 @@ -#include "ed25519.h" -#include "sha512.h" -#include "ge.h" -#include "sc.h" - - -void ed25519_sign(unsigned char *signature, const unsigned char *message, size_t message_len, const unsigned char *public_key, const unsigned char *private_key) { - sha512_context hash; - unsigned char hram[64]; - unsigned char r[64]; - ge_p3 R; - - - sha512_init(&hash); - sha512_update(&hash, private_key + 32, 32); - sha512_update(&hash, message, message_len); - sha512_final(&hash, r); - - sc_reduce(r); - ge_scalarmult_base(&R, r); - ge_p3_tobytes(signature, &R); - - sha512_init(&hash); - sha512_update(&hash, signature, 32); - sha512_update(&hash, public_key, 32); - sha512_update(&hash, message, message_len); - sha512_final(&hash, hram); - - sc_reduce(hram); - sc_muladd(signature + 32, hram, private_key, r); -} diff --git a/src/ed25519/verify.c b/src/ed25519/verify.c deleted file mode 100644 index 415e94f..0000000 --- a/src/ed25519/verify.c +++ /dev/null @@ -1,77 +0,0 @@ -#include "ed25519.h" -#include "sha512.h" -#include "ge.h" -#include "sc.h" - -static int consttime_equal(const unsigned char *x, const unsigned char *y) { - unsigned char r = 0; - - r = x[0] ^ y[0]; -#define F(i) r |= x[i] ^ y[i] - F(1); - F(2); - F(3); - F(4); - F(5); - F(6); - F(7); - F(8); - F(9); - F(10); - F(11); - F(12); - F(13); - F(14); - F(15); - F(16); - F(17); - F(18); - F(19); - F(20); - F(21); - F(22); - F(23); - F(24); - F(25); - F(26); - F(27); - F(28); - F(29); - F(30); - F(31); -#undef F - - return !r; -} - -int ed25519_verify(const unsigned char *signature, const unsigned char *message, size_t message_len, const unsigned char *public_key) { - unsigned char h[64]; - unsigned char checker[32]; - sha512_context hash; - ge_p3 A; - ge_p2 R; - - if(signature[63] & 224) { - return 0; - } - - if(ge_frombytes_negate_vartime(&A, public_key) != 0) { - return 0; - } - - sha512_init(&hash); - sha512_update(&hash, signature, 32); - sha512_update(&hash, public_key, 32); - sha512_update(&hash, message, message_len); - sha512_final(&hash, h); - - sc_reduce(h); - ge_double_scalarmult_vartime(&R, h, &A, signature + 32); - ge_tobytes(checker, &R); - - if(!consttime_equal(checker, signature)) { - return 0; - } - - return 1; -} diff --git a/src/edge.c b/src/edge.c index 5491d8a..c30d6cc 100644 --- a/src/edge.c +++ b/src/edge.c @@ -1,6 +1,6 @@ /* edge.c -- edge tree management - Copyright (C) 2000-2013 Guus Sliepen , + Copyright (C) 2000-2006 Guus Sliepen , 2000-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -20,8 +20,7 @@ #include "system.h" -#include "splay_tree.h" -#include "control_common.h" +#include "avl_tree.h" #include "edge.h" #include "logger.h" #include "netutl.h" @@ -29,7 +28,7 @@ #include "utils.h" #include "xalloc.h" -splay_tree_t *edge_weight_tree; +avl_tree_t *edge_weight_tree; /* Tree with all edges, sorted on weight */ static int edge_compare(const edge_t *a, const edge_t *b) { return strcmp(a->to->name, b->to->name); @@ -54,37 +53,36 @@ static int edge_weight_compare(const edge_t *a, const edge_t *b) { } void init_edges(void) { - edge_weight_tree = splay_alloc_tree((splay_compare_t) edge_weight_compare, NULL); + edge_weight_tree = avl_alloc_tree((avl_compare_t) edge_weight_compare, NULL); } -splay_tree_t *new_edge_tree(void) { - return splay_alloc_tree((splay_compare_t) edge_compare, (splay_action_t) free_edge); +avl_tree_t *new_edge_tree(void) { + return avl_alloc_tree((avl_compare_t) edge_compare, (avl_action_t) free_edge); } -void free_edge_tree(splay_tree_t *edge_tree) { - splay_delete_tree(edge_tree); +void free_edge_tree(avl_tree_t *edge_tree) { + avl_delete_tree(edge_tree); } void exit_edges(void) { - splay_delete_tree(edge_weight_tree); + avl_delete_tree(edge_weight_tree); } /* Creation and deletion of connection elements */ edge_t *new_edge(void) { - return xzalloc(sizeof(edge_t)); + return xmalloc_and_zero(sizeof(edge_t)); } void free_edge(edge_t *e) { sockaddrfree(&e->address); - sockaddrfree(&e->local_address); free(e); } void edge_add(edge_t *e) { - splay_insert(edge_weight_tree, e); - splay_insert(e->from->edge_tree, e); + avl_insert(edge_weight_tree, e); + avl_insert(e->from->edge_tree, e); e->reverse = lookup_edge(e->to, e->from); @@ -98,8 +96,8 @@ void edge_del(edge_t *e) { e->reverse->reverse = NULL; } - splay_delete(edge_weight_tree, e); - splay_delete(e->from->edge_tree, e); + avl_delete(edge_weight_tree, e); + avl_delete(e->from->edge_tree, e); } edge_t *lookup_edge(node_t *from, node_t *to) { @@ -108,22 +106,28 @@ edge_t *lookup_edge(node_t *from, node_t *to) { v.from = from; v.to = to; - return splay_search(from->edge_tree, &v); + return avl_search(from->edge_tree, &v); } -bool dump_edges(connection_t *c) { - for splay_each(node_t, n, node_tree) { - for splay_each(edge_t, e, n->edge_tree) { - char *address = sockaddr2hostname(&e->address); - char *local_address = sockaddr2hostname(&e->local_address); - send_request(c, "%d %d %s %s %s %s %x %d", - CONTROL, REQ_DUMP_EDGES, - e->from->name, e->to->name, address, - local_address, e->options, e->weight); +void dump_edges(void) { + avl_node_t *node, *node2; + node_t *n; + edge_t *e; + char *address; + + logger(LOG_DEBUG, "Edges:"); + + for(node = node_tree->head; node; node = node->next) { + n = node->data; + + for(node2 = n->edge_tree->head; node2; node2 = node2->next) { + e = node2->data; + address = sockaddr2hostname(&e->address); + logger(LOG_DEBUG, " %s to %s at %s options %x weight %d", + e->from->name, e->to->name, address, e->options, e->weight); free(address); - free(local_address); } } - return send_request(c, "%d %d", CONTROL, REQ_DUMP_EDGES); + logger(LOG_DEBUG, "End of edges."); } diff --git a/src/edge.h b/src/edge.h index 032acbc..a7a6302 100644 --- a/src/edge.h +++ b/src/edge.h @@ -3,7 +3,7 @@ /* edge.h -- header for edge.c - Copyright (C) 2001-2012 Guus Sliepen , + Copyright (C) 2001-2006 Guus Sliepen , 2001-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -21,7 +21,7 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "splay_tree.h" +#include "avl_tree.h" #include "connection.h" #include "net.h" #include "node.h" @@ -30,26 +30,25 @@ typedef struct edge_t { struct node_t *from; struct node_t *to; sockaddr_t address; - sockaddr_t local_address; - uint32_t options; /* options turned on for this edge */ - int weight; /* weight of this edge */ + uint32_t options; /* options turned on for this edge */ + int weight; /* weight of this edge */ - struct connection_t *connection; /* connection associated with this edge, if available */ - struct edge_t *reverse; /* edge in the opposite direction, if available */ + struct connection_t *connection; /* connection associated with this edge, if available */ + struct edge_t *reverse; /* edge in the opposite direction, if available */ } edge_t; -extern splay_tree_t *edge_weight_tree; /* Tree with all known edges sorted on weight */ +extern avl_tree_t *edge_weight_tree; /* Tree with all known edges sorted on weight */ extern void init_edges(void); extern void exit_edges(void); extern edge_t *new_edge(void) __attribute__((__malloc__)); extern void free_edge(edge_t *e); -extern splay_tree_t *new_edge_tree(void) __attribute__((__malloc__)); -extern void free_edge_tree(splay_tree_t *edge_tree); +extern avl_tree_t *new_edge_tree(void) __attribute__((__malloc__)); +extern void free_edge_tree(avl_tree_t *edge_tree); extern void edge_add(edge_t *e); extern void edge_del(edge_t *e); extern edge_t *lookup_edge(struct node_t *from, struct node_t *to); -extern bool dump_edges(struct connection_t *c); +extern void dump_edges(void); #endif diff --git a/src/ethernet.h b/src/ethernet.h index 8bfbd71..32f5553 100644 --- a/src/ethernet.h +++ b/src/ethernet.h @@ -25,15 +25,6 @@ #define ETH_ALEN 6 #endif -#ifndef ETH_HLEN -#define ETH_HLEN 14 -#endif - -#ifndef ETHER_TYPE_LEN -#define ETHER_TYPE_LEN 2 -#endif - - #ifndef ARPHRD_ETHER #define ARPHRD_ETHER 1 #endif @@ -54,16 +45,12 @@ #define ETH_P_8021Q 0x8100 #endif -#ifndef ETH_P_MAX -#define ETH_P_MAX 0xFFFF -#endif - #ifndef HAVE_STRUCT_ETHER_HEADER struct ether_header { uint8_t ether_dhost[ETH_ALEN]; uint8_t ether_shost[ETH_ALEN]; uint16_t ether_type; -} __attribute__((__gcc_struct__, __packed__)); +} __attribute__((__packed__)); #endif #ifndef HAVE_STRUCT_ARPHDR @@ -73,7 +60,7 @@ struct arphdr { uint8_t ar_hln; uint8_t ar_pln; uint16_t ar_op; -} __attribute__((__gcc_struct__, __packed__)); +} __attribute__((__packed__)); #define ARPOP_REQUEST 1 #define ARPOP_REPLY 2 @@ -91,7 +78,7 @@ struct ether_arp { uint8_t arp_spa[4]; uint8_t arp_tha[ETH_ALEN]; uint8_t arp_tpa[4]; -} __attribute__((__gcc_struct__, __packed__)); +} __attribute__((__packed__)); #define arp_hrd ea_hdr.ar_hrd #define arp_pro ea_hdr.ar_pro #define arp_hln ea_hdr.ar_hln diff --git a/src/event.c b/src/event.c index 47adb18..1223222 100644 --- a/src/event.c +++ b/src/event.c @@ -1,6 +1,7 @@ /* - event.c -- I/O, timeout and signal event handling - Copyright (C) 2012-2013 Guus Sliepen + event.c -- event queue + Copyright (C) 2002-2009 Guus Sliepen , + 2002-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,471 +20,102 @@ #include "system.h" -#include "dropin.h" +#include "avl_tree.h" #include "event.h" -#include "net.h" #include "utils.h" #include "xalloc.h" -struct timeval now; +avl_tree_t *event_tree; +extern time_t now; -#ifndef HAVE_MINGW -static fd_set readfds; -static fd_set writefds; -#else -static const long READ_EVENTS = FD_READ | FD_ACCEPT | FD_CLOSE; -static const long WRITE_EVENTS = FD_WRITE | FD_CONNECT; -static DWORD event_count = 0; -#endif -static bool running; +static int id; -static int io_compare(const io_t *a, const io_t *b) { -#ifndef HAVE_MINGW - return a->fd - b->fd; -#else - - if(a->event < b->event) { - return -1; - } - - if(a->event > b->event) { +static int event_compare(const event_t *a, const event_t *b) { + if(a->time > b->time) { return 1; } - return 0; -#endif -} - -static int timeout_compare(const timeout_t *a, const timeout_t *b) { - struct timeval diff; - timersub(&a->tv, &b->tv, &diff); - - if(diff.tv_sec < 0) { + if(a->time < b->time) { return -1; } - if(diff.tv_sec > 0) { - return 1; - } - - if(diff.tv_usec < 0) { - return -1; - } - - if(diff.tv_usec > 0) { - return 1; - } - - if(a < b) { - return -1; - } - - if(a > b) { - return 1; - } - - return 0; + return a->id - b->id; } -static splay_tree_t io_tree = {.compare = (splay_compare_t)io_compare}; -static splay_tree_t timeout_tree = {.compare = (splay_compare_t)timeout_compare}; +void init_events(void) { + event_tree = avl_alloc_tree((avl_compare_t) event_compare, (avl_action_t) free_event); +} -void io_add(io_t *io, io_cb_t cb, void *data, int fd, int flags) { - if(io->cb) { +void exit_events(void) { + avl_delete_tree(event_tree); +} + +void expire_events(void) { + avl_node_t *node; + event_t *event; + time_t diff; + + /* + * Make all events appear expired by subtracting the difference between + * the expiration time of the last event and the current time. + */ + + if(!event_tree->tail) { return; } - io->fd = fd; -#ifdef HAVE_MINGW + event = event_tree->tail->data; - if(io->fd != -1) { - io->event = WSACreateEvent(); - - if(io->event == WSA_INVALID_EVENT) { - abort(); - } - } - - event_count++; -#endif - io->cb = cb; - io->data = data; - io->node.data = io; - - io_set(io, flags); - - if(!splay_insert_node(&io_tree, &io->node)) { - abort(); - } -} - -#ifdef HAVE_MINGW -void io_add_event(io_t *io, io_cb_t cb, void *data, WSAEVENT event) { - io->event = event; - io_add(io, cb, data, -1, 0); -} -#endif - -void io_set(io_t *io, int flags) { - if(flags == io->flags) { + if(event->time <= now) { return; } - io->flags = flags; + diff = event->time - now; - if(io->fd == -1) { - return; - } - -#ifndef HAVE_MINGW - - if(flags & IO_READ) { - FD_SET(io->fd, &readfds); - } else { - FD_CLR(io->fd, &readfds); - } - - if(flags & IO_WRITE) { - FD_SET(io->fd, &writefds); - } else { - FD_CLR(io->fd, &writefds); - } - -#else - long events = 0; - - if(flags & IO_WRITE) { - events |= WRITE_EVENTS; - } - - if(flags & IO_READ) { - events |= READ_EVENTS; - } - - if(WSAEventSelect(io->fd, io->event, events) != 0) { - abort(); - } - -#endif -} - -void io_del(io_t *io) { - if(!io->cb) { - return; - } - - io_set(io, 0); -#ifdef HAVE_MINGW - - if(io->fd != -1 && WSACloseEvent(io->event) == FALSE) { - abort(); - } - - event_count--; -#endif - - splay_unlink_node(&io_tree, &io->node); - io->cb = NULL; -} - -void timeout_add(timeout_t *timeout, timeout_cb_t cb, void *data, struct timeval *tv) { - timeout->cb = cb; - timeout->data = data; - timeout->node.data = timeout; - - timeout_set(timeout, tv); -} - -void timeout_set(timeout_t *timeout, struct timeval *tv) { - if(timerisset(&timeout->tv)) { - splay_unlink_node(&timeout_tree, &timeout->node); - } - - if(!now.tv_sec) { - gettimeofday(&now, NULL); - } - - timeradd(&now, tv, &timeout->tv); - - if(!splay_insert_node(&timeout_tree, &timeout->node)) { - abort(); + for(node = event_tree->head; node; node = node->next) { + event = node->data; + event->time -= diff; } } -void timeout_del(timeout_t *timeout) { - if(!timeout->cb) { - return; - } - - splay_unlink_node(&timeout_tree, &timeout->node); - timeout->cb = 0; - timeout->tv = (struct timeval) { - 0, 0 - }; +event_t *new_event(void) { + return xmalloc_and_zero(sizeof(event_t)); } -#ifndef HAVE_MINGW -static int signal_compare(const signal_t *a, const signal_t *b) { - return a->signum - b->signum; +void free_event(event_t *event) { + free(event); } -static io_t signalio; -static int pipefd[2] = {-1, -1}; -static splay_tree_t signal_tree = {.compare = (splay_compare_t)signal_compare}; - -static void signal_handler(int signum) { - unsigned char num = signum; - write(pipefd[1], &num, 1); +void event_add(event_t *event) { + event->id = ++id; + avl_insert(event_tree, event); } -static void signalio_handler(void *data, int flags) { - (void)data; - (void)flags; - unsigned char signum; - - if(read(pipefd[0], &signum, 1) != 1) { - return; - } - - signal_t *sig = splay_search(&signal_tree, &((signal_t) { - .signum = signum - })); - - if(sig) { - sig->cb(sig->data); - } +void event_del(event_t *event) { + avl_delete(event_tree, event); } -static void pipe_init(void) { - if(!pipe(pipefd)) { - io_add(&signalio, signalio_handler, NULL, pipefd[0], IO_READ); - } -} +event_t *get_expired_event(void) { + event_t *event; -void signal_add(signal_t *sig, signal_cb_t cb, void *data, int signum) { - if(sig->cb) { - return; - } + if(event_tree->head) { + event = event_tree->head->data; - sig->cb = cb; - sig->data = data; - sig->signum = signum; - sig->node.data = sig; - - if(pipefd[0] == -1) { - pipe_init(); - } - - signal(sig->signum, signal_handler); - - if(!splay_insert_node(&signal_tree, &sig->node)) { - abort(); - } -} - -void signal_del(signal_t *sig) { - if(!sig->cb) { - return; - } - - signal(sig->signum, SIG_DFL); - - splay_unlink_node(&signal_tree, &sig->node); - sig->cb = NULL; -} -#endif - -static struct timeval *get_time_remaining(struct timeval *diff) { - gettimeofday(&now, NULL); - struct timeval *tv = NULL; - - while(timeout_tree.head) { - timeout_t *timeout = timeout_tree.head->data; - timersub(&timeout->tv, &now, diff); - - if(diff->tv_sec < 0) { - timeout->cb(timeout->data); - - if(timercmp(&timeout->tv, &now, <)) { - timeout_del(timeout); - } - } else { - tv = diff; - break; + if(event->time <= now) { + avl_node_t *node = event_tree->head; + avl_unlink_node(event_tree, node); + free(node); + return event; } } - return tv; + return NULL; } -bool event_loop(void) { - running = true; - -#ifndef HAVE_MINGW - fd_set readable; - fd_set writable; - - while(running) { - struct timeval diff; - struct timeval *tv = get_time_remaining(&diff); - memcpy(&readable, &readfds, sizeof(readable)); - memcpy(&writable, &writefds, sizeof(writable)); - - int fds = 0; - - if(io_tree.tail) { - io_t *last = io_tree.tail->data; - fds = last->fd + 1; - } - - int n = select(fds, &readable, &writable, NULL, tv); - - if(n < 0) { - if(sockwouldblock(sockerrno)) { - continue; - } else { - return false; - } - } - - if(!n) { - continue; - } - - unsigned int curgen = io_tree.generation; - - for splay_each(io_t, io, &io_tree) { - if(FD_ISSET(io->fd, &writable)) { - io->cb(io->data, IO_WRITE); - } else if(FD_ISSET(io->fd, &readable)) { - io->cb(io->data, IO_READ); - } else { - continue; - } - - /* - There are scenarios in which the callback will remove another io_t from the tree - (e.g. closing a double connection). Since splay_each does not support that, we - need to exit the loop if that happens. That's okay, since any remaining events will - get picked up by the next select() call. - */ - if(curgen != io_tree.generation) { - break; - } - } +event_t *peek_next_event(void) { + if(event_tree->head) { + return event_tree->head->data; } -#else - - while(running) { - struct timeval diff; - struct timeval *tv = get_time_remaining(&diff); - DWORD timeout_ms = tv ? (tv->tv_sec * 1000 + tv->tv_usec / 1000 + 1) : WSA_INFINITE; - - if(!event_count) { - Sleep(timeout_ms); - continue; - } - - /* - For some reason, Microsoft decided to make the FD_WRITE event edge-triggered instead of level-triggered, - which is the opposite of what select() does. In practice, that means that if a FD_WRITE event triggers, - it will never trigger again until a send() returns EWOULDBLOCK. Since the semantics of this event loop - is that write events are level-triggered (i.e. they continue firing until the socket is full), we need - to emulate these semantics by making sure we fire each IO_WRITE that is still writeable. - - Note that technically FD_CLOSE has the same problem, but it's okay because user code does not rely on - this event being fired again if ignored. - */ - unsigned int curgen = io_tree.generation; - - for splay_each(io_t, io, &io_tree) { - if(io->flags & IO_WRITE && send(io->fd, NULL, 0, 0) == 0) { - io->cb(io->data, IO_WRITE); - - if(curgen != io_tree.generation) { - break; - } - } - } - - if(event_count > WSA_MAXIMUM_WAIT_EVENTS) { - WSASetLastError(WSA_INVALID_PARAMETER); - return(false); - } - - WSAEVENT events[WSA_MAXIMUM_WAIT_EVENTS]; - io_t *io_map[WSA_MAXIMUM_WAIT_EVENTS]; - DWORD event_index = 0; - - for splay_each(io_t, io, &io_tree) { - events[event_index] = io->event; - io_map[event_index] = io; - event_index++; - } - - /* - * If the generation number changes due to event addition - * or removal by a callback we restart the loop. - */ - curgen = io_tree.generation; - - for(DWORD event_offset = 0; event_offset < event_count;) { - DWORD result = WSAWaitForMultipleEvents(event_count - event_offset, &events[event_offset], FALSE, timeout_ms, FALSE); - - if(result == WSA_WAIT_TIMEOUT) { - break; - } - - if(result < WSA_WAIT_EVENT_0 || result >= WSA_WAIT_EVENT_0 + event_count - event_offset) { - return(false); - } - - /* Look up io in the map by index. */ - event_index = result - WSA_WAIT_EVENT_0 + event_offset; - io_t *io = io_map[event_index]; - - if(io->fd == -1) { - io->cb(io->data, 0); - - if(curgen != io_tree.generation) { - break; - } - } else { - WSANETWORKEVENTS network_events; - - if(WSAEnumNetworkEvents(io->fd, io->event, &network_events) != 0) { - return(false); - } - - if(network_events.lNetworkEvents & READ_EVENTS) { - io->cb(io->data, IO_READ); - - if(curgen != io_tree.generation) { - break; - } - } - - /* - The fd might be available for write too. However, if we already fired the read callback, that - callback might have deleted the io (e.g. through terminate_connection()), so we can't fire the - write callback here. Instead, we loop back and let the writable io loop above handle it. - */ - } - - /* Continue checking the rest of the events. */ - event_offset = event_index + 1; - - /* Just poll the next time through. */ - timeout_ms = 0; - } - } - -#endif - - return true; -} - -void event_exit(void) { - running = false; + return NULL; } diff --git a/src/event.h b/src/event.h index 7adaf85..6d521bb 100644 --- a/src/event.h +++ b/src/event.h @@ -2,8 +2,9 @@ #define TINC_EVENT_H /* - event.h -- I/O, timeout and signal event handling - Copyright (C) 2012-2013 Guus Sliepen + event.h -- header for event.c + Copyright (C) 2002-2009 Guus Sliepen , + 2002-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,57 +21,27 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "splay_tree.h" +#include "avl_tree.h" -#define IO_READ 1 -#define IO_WRITE 2 +extern avl_tree_t *event_tree; -typedef void (*io_cb_t)(void *data, int flags); -typedef void (*timeout_cb_t)(void *data); -typedef void (*signal_cb_t)(void *data); +typedef void (*event_handler_t)(void *); -typedef struct io_t { - int fd; - int flags; -#ifdef HAVE_MINGW - WSAEVENT event; -#endif - io_cb_t cb; +typedef struct event { + time_t time; + int id; + event_handler_t handler; void *data; - splay_node_t node; -} io_t; +} event_t; -typedef struct timeout_t { - struct timeval tv; - timeout_cb_t cb; - void *data; - splay_node_t node; -} timeout_t; - -typedef struct signal_t { - int signum; - signal_cb_t cb; - void *data; - splay_node_t node; -} signal_t; - -extern struct timeval now; - -extern void io_add(io_t *io, io_cb_t cb, void *data, int fd, int flags); -#ifdef HAVE_MINGW -extern void io_add_event(io_t *io, io_cb_t cb, void *data, WSAEVENT event); -#endif -extern void io_del(io_t *io); -extern void io_set(io_t *io, int flags); - -extern void timeout_add(timeout_t *timeout, timeout_cb_t cb, void *data, struct timeval *tv); -extern void timeout_del(timeout_t *timeout); -extern void timeout_set(timeout_t *timeout, struct timeval *tv); - -extern void signal_add(signal_t *sig, signal_cb_t cb, void *data, int signum); -extern void signal_del(signal_t *sig); - -extern bool event_loop(void); -extern void event_exit(void); +extern void init_events(void); +extern void exit_events(void); +extern void expire_events(void); +extern event_t *new_event(void) __attribute__((__malloc__)); +extern void free_event(event_t *event); +extern void event_add(event_t *event); +extern void event_del(event_t *event); +extern event_t *get_expired_event(void); +extern event_t *peek_next_event(void); #endif diff --git a/src/fake-getaddrinfo.c b/src/fake-getaddrinfo.c new file mode 100644 index 0000000..1ee11c5 --- /dev/null +++ b/src/fake-getaddrinfo.c @@ -0,0 +1,108 @@ +/* + * fake library for ssh + * + * This file includes getaddrinfo(), freeaddrinfo() and gai_strerror(). + * These functions are defined in rfc2133. + * + * But these functions are not implemented correctly. The minimum subset + * is implemented for ssh use only. For example, this routine assumes + * that ai_family is AF_INET. Don't use it for another purpose. + */ + +#include "system.h" + +#include "ipv4.h" +#include "ipv6.h" +#include "fake-getaddrinfo.h" +#include "xalloc.h" + +#if !HAVE_DECL_GAI_STRERROR +char *gai_strerror(int ecode) { + switch(ecode) { + case EAI_NODATA: + return "No address associated with hostname"; + + case EAI_MEMORY: + return "Memory allocation failure"; + + case EAI_FAMILY: + return "Address family not supported"; + + default: + return "Unknown error"; + } +} +#endif /* !HAVE_GAI_STRERROR */ + +#if !HAVE_DECL_FREEADDRINFO +void freeaddrinfo(struct addrinfo *ai) { + struct addrinfo *next; + + while(ai) { + next = ai->ai_next; + free(ai); + ai = next; + } +} +#endif /* !HAVE_FREEADDRINFO */ + +#if !HAVE_DECL_GETADDRINFO +static struct addrinfo *malloc_ai(uint16_t port, uint32_t addr) { + struct addrinfo *ai; + + ai = xmalloc_and_zero(sizeof(struct addrinfo) + sizeof(struct sockaddr_in)); + + ai->ai_addr = (struct sockaddr *)(ai + 1); + ai->ai_addrlen = sizeof(struct sockaddr_in); + ai->ai_addr->sa_family = ai->ai_family = AF_INET; + + ((struct sockaddr_in *)(ai)->ai_addr)->sin_port = port; + ((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr; + + return ai; +} + +int getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res) { + struct addrinfo *prev = NULL; + struct hostent *hp; + struct in_addr in = {0}; + int i; + uint16_t port = 0; + + if(hints && hints->ai_family != AF_INET && hints->ai_family != AF_UNSPEC) { + return EAI_FAMILY; + } + + if(servname) { + port = htons(atoi(servname)); + } + + if(hints && hints->ai_flags & AI_PASSIVE) { + *res = malloc_ai(port, htonl(0x00000000)); + return 0; + } + + if(!hostname) { + *res = malloc_ai(port, htonl(0x7f000001)); + return 0; + } + + hp = gethostbyname(hostname); + + if(!hp || !hp->h_addr_list || !hp->h_addr_list[0]) { + return EAI_NODATA; + } + + for(i = 0; hp->h_addr_list[i]; i++) { + *res = malloc_ai(port, ((struct in_addr *)hp->h_addr_list[i])->s_addr); + + if(prev) { + prev->ai_next = *res; + } + + prev = *res; + } + + return 0; +} +#endif /* !HAVE_GETADDRINFO */ diff --git a/src/fake-getaddrinfo.h b/src/fake-getaddrinfo.h new file mode 100644 index 0000000..f10cb83 --- /dev/null +++ b/src/fake-getaddrinfo.h @@ -0,0 +1,57 @@ +#ifndef TINC_FAKE_GETADDRINFO_H +#define TINC_FAKE_GETADDRINFO_H + +#ifndef EAI_NODATA +#define EAI_NODATA 1 +#endif + +#ifndef EAI_MEMORY +#define EAI_MEMORY 2 +#endif + +#ifndef EAI_FAMILY +#define EAI_FAMILY 3 +#endif + +#ifndef AI_PASSIVE +# define AI_PASSIVE 1 +# define AI_CANONNAME 2 +#endif + +#ifndef NI_NUMERICHOST +# define NI_NUMERICHOST 2 +# define NI_NAMEREQD 4 +# define NI_NUMERICSERV 8 +#endif + +#ifndef AI_NUMERICHOST +#define AI_NUMERICHOST 4 +#endif + +#ifndef HAVE_STRUCT_ADDRINFO +struct addrinfo { + int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ + int ai_family; /* PF_xxx */ + int ai_socktype; /* SOCK_xxx */ + int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ + size_t ai_addrlen; /* length of ai_addr */ + char *ai_canonname; /* canonical name for hostname */ + struct sockaddr *ai_addr; /* binary address */ + struct addrinfo *ai_next; /* next structure in linked list */ +}; +#endif /* !HAVE_STRUCT_ADDRINFO */ + +#if !HAVE_DECL_GETADDRINFO +int getaddrinfo(const char *hostname, const char *servname, + const struct addrinfo *hints, struct addrinfo **res); +#endif /* !HAVE_GETADDRINFO */ + +#if !HAVE_DECL_GAI_STRERROR +char *gai_strerror(int ecode); +#endif /* !HAVE_GAI_STRERROR */ + +#if !HAVE_DECL_FREEADDRINFO +void freeaddrinfo(struct addrinfo *ai); +#endif /* !HAVE_FREEADDRINFO */ + +#endif diff --git a/src/fake-getnameinfo.c b/src/fake-getnameinfo.c new file mode 100644 index 0000000..e51bce2 --- /dev/null +++ b/src/fake-getnameinfo.c @@ -0,0 +1,64 @@ +/* + * fake library for ssh + * + * This file includes getnameinfo(). + * These functions are defined in rfc2133. + * + * But these functions are not implemented correctly. The minimum subset + * is implemented for ssh use only. For example, this routine assumes + * that ai_family is AF_INET. Don't use it for another purpose. + */ + +#include "system.h" + +#include "fake-getnameinfo.h" +#include "fake-getaddrinfo.h" + +#if !HAVE_DECL_GETNAMEINFO + +int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags) { + struct sockaddr_in *sin = (struct sockaddr_in *)sa; + struct hostent *hp; + int len; + + if(sa->sa_family != AF_INET) { + return EAI_FAMILY; + } + + if(serv && servlen) { + len = snprintf(serv, servlen, "%d", ntohs(sin->sin_port)); + + if(len < 0 || len >= servlen) { + return EAI_MEMORY; + } + } + + if(!host || !hostlen) { + return 0; + } + + if(flags & NI_NUMERICHOST) { + len = snprintf(host, hostlen, "%s", inet_ntoa(sin->sin_addr)); + + if(len < 0 || len >= hostlen) { + return EAI_MEMORY; + } + + return 0; + } + + hp = gethostbyaddr((char *)&sin->sin_addr, sizeof(struct in_addr), AF_INET); + + if(!hp || !hp->h_name || !hp->h_name[0]) { + return EAI_NODATA; + } + + len = snprintf(host, hostlen, "%s", hp->h_name); + + if(len < 0 || len >= hostlen) { + return EAI_MEMORY; + } + + return 0; +} +#endif /* !HAVE_GETNAMEINFO */ diff --git a/src/fake-getnameinfo.h b/src/fake-getnameinfo.h new file mode 100644 index 0000000..4f24ad1 --- /dev/null +++ b/src/fake-getnameinfo.h @@ -0,0 +1,16 @@ +#ifndef TINC_FAKE_GETNAMEINFO_H +#define TINC_FAKE_GETNAMEINFO_H + +#if !HAVE_DECL_GETNAMEINFO +int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, + size_t hostlen, char *serv, size_t servlen, int flags); +#endif /* !HAVE_GETNAMEINFO */ + +#ifndef NI_MAXSERV +# define NI_MAXSERV 32 +#endif /* !NI_MAXSERV */ +#ifndef NI_MAXHOST +# define NI_MAXHOST 1025 +#endif /* !NI_MAXHOST */ + +#endif diff --git a/src/fd_device.c b/src/fd_device.c deleted file mode 100644 index afe59bc..0000000 --- a/src/fd_device.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - fd_device.c -- Interaction with Android tun fd - Copyright (C) 2001-2005 Ivo Timmermans, - 2001-2016 Guus Sliepen - 2009 Grzegorz Dymarek - 2016 Pacien TRAN-GIRARD - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" -#include "conf.h" -#include "device.h" -#include "ethernet.h" -#include "logger.h" -#include "net.h" -#include "route.h" -#include "utils.h" - -static inline bool check_config(void) { - if(routing_mode == RMODE_SWITCH) { - logger(DEBUG_ALWAYS, LOG_ERR, "Switch mode not supported (requires unsupported TAP device)!"); - return false; - } - - if(!get_config_int(lookup_config(config_tree, "Device"), &device_fd)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not read fd from configuration!"); - return false; - } - - return true; -} - -static bool setup_device(void) { - if(!check_config()) { - return false; - } - - if(device_fd < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not open %s: %s!", device, strerror(errno)); - return false; - } - - logger(DEBUG_ALWAYS, LOG_INFO, "fd/%d adapter set up.", device_fd); - - return true; -} - -static void close_device(void) { - close(device_fd); - device_fd = -1; -} - -static inline uint16_t get_ip_ethertype(vpn_packet_t *packet) { - switch(DATA(packet)[ETH_HLEN] >> 4) { - case 4: - return ETH_P_IP; - - case 6: - return ETH_P_IPV6; - - default: - return ETH_P_MAX; - } -} - -static inline void set_etherheader(vpn_packet_t *packet, uint16_t ethertype) { - memset(DATA(packet), 0, ETH_HLEN - ETHER_TYPE_LEN); - - DATA(packet)[ETH_HLEN - ETHER_TYPE_LEN] = (ethertype >> 8) & 0xFF; - DATA(packet)[ETH_HLEN - ETHER_TYPE_LEN + 1] = ethertype & 0xFF; -} - -static bool read_packet(vpn_packet_t *packet) { - int lenin = read(device_fd, DATA(packet) + ETH_HLEN, MTU - ETH_HLEN); - - if(lenin <= 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from fd/%d: %s!", device_fd, strerror(errno)); - return false; - } - - uint16_t ethertype = get_ip_ethertype(packet); - - if(ethertype == ETH_P_MAX) { - logger(DEBUG_TRAFFIC, LOG_ERR, "Unknown IP version while reading packet from fd/%d!", device_fd); - return false; - } - - set_etherheader(packet, ethertype); - packet->len = lenin + ETH_HLEN; - - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from fd/%d.", packet->len, device_fd); - - return true; -} - -static bool write_packet(vpn_packet_t *packet) { - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Writing packet of %d bytes to fd/%d.", packet->len, device_fd); - - if(write(device_fd, DATA(packet) + ETH_HLEN, packet->len - ETH_HLEN) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while writing to fd/%d: %s!", device_fd, strerror(errno)); - return false; - } - - return true; -} - -const devops_t fd_devops = { - .setup = setup_device, - .close = close_device, - .read = read_packet, - .write = write_packet, -}; diff --git a/src/fsck.c b/src/fsck.c deleted file mode 100644 index e19f03f..0000000 --- a/src/fsck.c +++ /dev/null @@ -1,603 +0,0 @@ -/* - fsck.c -- Check the configuration files for problems - Copyright (C) 2014 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include "crypto.h" -#include "ecdsa.h" -#include "ecdsagen.h" -#include "fsck.h" -#include "names.h" -#ifndef DISABLE_LEGACY -#include "rsa.h" -#include "rsagen.h" -#endif -#include "tincctl.h" -#include "utils.h" - -static bool ask_fix(void) { - if(force) { - return true; - } - - if(!tty) { - return false; - } - -again: - fprintf(stderr, "Fix y/n? "); - char buf[1024]; - - if(!fgets(buf, sizeof(buf), stdin)) { - tty = false; - return false; - } - - if(buf[0] == 'y' || buf[0] == 'Y') { - return true; - } - - if(buf[0] == 'n' || buf[0] == 'N') { - return false; - } - - goto again; -} - -static void print_tinc_cmd(const char *argv0, const char *format, ...) { - if(confbasegiven) { - fprintf(stderr, "%s -c %s ", argv0, confbase); - } else if(netname) { - fprintf(stderr, "%s -n %s ", argv0, netname); - } else { - fprintf(stderr, "%s ", argv0); - } - - va_list va; - va_start(va, format); - vfprintf(stderr, format, va); - va_end(va); - fputc('\n', stderr); -} - -static int strtailcmp(const char *str, const char *tail) { - size_t slen = strlen(str); - size_t tlen = strlen(tail); - - if(tlen > slen) { - return -1; - } - - return memcmp(str + slen - tlen, tail, tlen); -} - -static void check_conffile(const char *fname, bool server) { - (void)server; - - FILE *f = fopen(fname, "r"); - - if(!f) { - fprintf(stderr, "ERROR: cannot read %s: %s\n", fname, strerror(errno)); - return; - } - - char line[2048]; - int lineno = 0; - bool skip = false; - const int maxvariables = 50; - int count[maxvariables]; - memset(count, 0, sizeof(count)); - - while(fgets(line, sizeof(line), f)) { - if(skip) { - if(!strncmp(line, "-----END", 8)) { - skip = false; - } - - continue; - } else { - if(!strncmp(line, "-----BEGIN", 10)) { - skip = true; - continue; - } - } - - int len; - char *variable, *value, *eol; - variable = value = line; - - lineno++; - - eol = line + strlen(line); - - while(strchr("\t \r\n", *--eol)) { - *eol = '\0'; - } - - if(!line[0] || line[0] == '#') { - continue; - } - - len = strcspn(value, "\t ="); - value += len; - value += strspn(value, "\t "); - - if(*value == '=') { - value++; - value += strspn(value, "\t "); - } - - variable[len] = '\0'; - - bool found = false; - - for(int i = 0; variables[i].name; i++) { - if(strcasecmp(variables[i].name, variable)) { - continue; - } - - found = true; - - if(variables[i].type & VAR_OBSOLETE) { - fprintf(stderr, "WARNING: obsolete variable %s in %s line %d\n", variable, fname, lineno); - } - - if(i < maxvariables) { - count[i]++; - } - } - - if(!found) { - fprintf(stderr, "WARNING: unknown variable %s in %s line %d\n", variable, fname, lineno); - } - - if(!*value) { - fprintf(stderr, "ERROR: no value for variable %s in %s line %d\n", variable, fname, lineno); - } - } - - for(int i = 0; variables[i].name && i < maxvariables; i++) { - if(count[i] > 1 && !(variables[i].type & VAR_MULTIPLE)) { - fprintf(stderr, "WARNING: multiple instances of variable %s in %s\n", variables[i].name, fname); - } - } - - if(ferror(f)) { - fprintf(stderr, "ERROR: while reading %s: %s\n", fname, strerror(errno)); - } - - fclose(f); -} - -int fsck(const char *argv0) { -#ifdef HAVE_MINGW - int uid = 0; -#else - uid_t uid = getuid(); -#endif - - // Check that tinc.conf is readable. - - if(access(tinc_conf, R_OK)) { - fprintf(stderr, "ERROR: cannot read %s: %s\n", tinc_conf, strerror(errno)); - - if(errno == ENOENT) { - fprintf(stderr, "No tinc configuration found. Create a new one with:\n\n"); - print_tinc_cmd(argv0, "init"); - } else if(errno == EACCES) { - if(uid != 0) { - fprintf(stderr, "You are currently not running tinc as root. Use sudo?\n"); - } else { - fprintf(stderr, "Check the permissions of each component of the path %s.\n", tinc_conf); - } - } - - return 1; - } - - char *name = get_my_name(true); - - if(!name) { - fprintf(stderr, "ERROR: tinc cannot run without a valid Name.\n"); - return 1; - } - - // Check for private keys. - // TODO: use RSAPrivateKeyFile and Ed25519PrivateKeyFile variables if present. - - struct stat st; - char fname[PATH_MAX]; - char dname[PATH_MAX]; - -#ifndef DISABLE_LEGACY - rsa_t *rsa_priv = NULL; - snprintf(fname, sizeof(fname), "%s/rsa_key.priv", confbase); - - if(stat(fname, &st)) { - if(errno != ENOENT) { - // Something is seriously wrong here. If we can access the directory with tinc.conf in it, we should certainly be able to stat() an existing file. - fprintf(stderr, "ERROR: cannot read %s: %s\n", fname, strerror(errno)); - fprintf(stderr, "Please correct this error.\n"); - return 1; - } - } else { - FILE *f = fopen(fname, "r"); - - if(!f) { - fprintf(stderr, "ERROR: could not open %s: %s\n", fname, strerror(errno)); - return 1; - } - - rsa_priv = rsa_read_pem_private_key(f); - fclose(f); - - if(!rsa_priv) { - fprintf(stderr, "ERROR: No key or unusable key found in %s.\n", fname); - fprintf(stderr, "You can generate a new RSA key with:\n\n"); - print_tinc_cmd(argv0, "generate-rsa-keys"); - return 1; - } - -#if !defined(HAVE_MINGW) && !defined(HAVE_CYGWIN) - - if(st.st_mode & 077) { - fprintf(stderr, "WARNING: unsafe file permissions on %s.\n", fname); - - if(st.st_uid != uid) { - fprintf(stderr, "You are not running %s as the same uid as %s.\n", argv0, fname); - } else if(ask_fix()) { - if(chmod(fname, st.st_mode & ~077)) { - fprintf(stderr, "ERROR: could not change permissions of %s: %s\n", fname, strerror(errno)); - } else { - fprintf(stderr, "Fixed permissions of %s.\n", fname); - } - } - } - -#endif - } - -#endif - - ecdsa_t *ecdsa_priv = NULL; - snprintf(fname, sizeof(fname), "%s/ed25519_key.priv", confbase); - - if(stat(fname, &st)) { - if(errno != ENOENT) { - // Something is seriously wrong here. If we can access the directory with tinc.conf in it, we should certainly be able to stat() an existing file. - fprintf(stderr, "ERROR: cannot read %s: %s\n", fname, strerror(errno)); - fprintf(stderr, "Please correct this error.\n"); - return 1; - } - } else { - FILE *f = fopen(fname, "r"); - - if(!f) { - fprintf(stderr, "ERROR: could not open %s: %s\n", fname, strerror(errno)); - return 1; - } - - ecdsa_priv = ecdsa_read_pem_private_key(f); - fclose(f); - - if(!ecdsa_priv) { - fprintf(stderr, "ERROR: No key or unusable key found in %s.\n", fname); - fprintf(stderr, "You can generate a new Ed25519 key with:\n\n"); - print_tinc_cmd(argv0, "generate-ed25519-keys"); - return 1; - } - -#if !defined(HAVE_MINGW) && !defined(HAVE_CYGWIN) - - if(st.st_mode & 077) { - fprintf(stderr, "WARNING: unsafe file permissions on %s.\n", fname); - - if(st.st_uid != uid) { - fprintf(stderr, "You are not running %s as the same uid as %s.\n", argv0, fname); - } else if(ask_fix()) { - if(chmod(fname, st.st_mode & ~077)) { - fprintf(stderr, "ERROR: could not change permissions of %s: %s\n", fname, strerror(errno)); - } else { - fprintf(stderr, "Fixed permissions of %s.\n", fname); - } - } - } - -#endif - } - -#ifdef DISABLE_LEGACY - - if(!ecdsa_priv) { - fprintf(stderr, "ERROR: No Ed25519 private key found.\n"); -#else - - if(!rsa_priv && !ecdsa_priv) { - fprintf(stderr, "ERROR: Neither RSA or Ed25519 private key found.\n"); -#endif - fprintf(stderr, "You can generate new keys with:\n\n"); - print_tinc_cmd(argv0, "generate-keys"); - return 1; - } - - // Check for public keys. - // TODO: use RSAPublicKeyFile variable if present. - - snprintf(fname, sizeof(fname), "%s/hosts/%s", confbase, name); - - if(access(fname, R_OK)) { - fprintf(stderr, "WARNING: cannot read %s\n", fname); - } - - FILE *f; - -#ifndef DISABLE_LEGACY - rsa_t *rsa_pub = NULL; - - f = fopen(fname, "r"); - - if(f) { - rsa_pub = rsa_read_pem_public_key(f); - fclose(f); - } - - if(rsa_priv) { - if(!rsa_pub) { - fprintf(stderr, "WARNING: No (usable) public RSA key found.\n"); - - if(ask_fix()) { - FILE *f = fopen(fname, "a"); - - if(f) { - if(rsa_write_pem_public_key(rsa_priv, f)) { - fprintf(stderr, "Wrote RSA public key to %s.\n", fname); - } else { - fprintf(stderr, "ERROR: could not write RSA public key to %s.\n", fname); - } - - fclose(f); - } else { - fprintf(stderr, "ERROR: could not append to %s: %s\n", fname, strerror(errno)); - } - } - } else { - // TODO: suggest remedies - size_t len = rsa_size(rsa_priv); - - if(len != rsa_size(rsa_pub)) { - fprintf(stderr, "ERROR: public and private RSA keys do not match.\n"); - return 1; - } - - char buf1[len], buf2[len], buf3[len]; - randomize(buf1, sizeof(buf1)); - buf1[0] &= 0x7f; - memset(buf2, 0, sizeof(buf2)); - memset(buf3, 0, sizeof(buf2)); - - if(!rsa_public_encrypt(rsa_pub, buf1, sizeof(buf1), buf2)) { - fprintf(stderr, "ERROR: public RSA key does not work.\n"); - return 1; - } - - if(!rsa_private_decrypt(rsa_priv, buf2, sizeof(buf2), buf3)) { - fprintf(stderr, "ERROR: private RSA key does not work.\n"); - return 1; - } - - if(memcmp(buf1, buf3, sizeof(buf1))) { - fprintf(stderr, "ERROR: public and private RSA keys do not match.\n"); - return 1; - } - } - } else { - if(rsa_pub) { - fprintf(stderr, "WARNING: A public RSA key was found but no private key is known.\n"); - } - } - -#endif - - ecdsa_t *ecdsa_pub = NULL; - - f = fopen(fname, "r"); - - if(f) { - ecdsa_pub = get_pubkey(f); - - if(!ecdsa_pub) { - rewind(f); - ecdsa_pub = ecdsa_read_pem_public_key(f); - } - - fclose(f); - } - - if(ecdsa_priv) { - if(!ecdsa_pub) { - fprintf(stderr, "WARNING: No (usable) public Ed25519 key found.\n"); - - if(ask_fix()) { - FILE *f = fopen(fname, "a"); - - if(f) { - if(ecdsa_write_pem_public_key(ecdsa_priv, f)) { - fprintf(stderr, "Wrote Ed25519 public key to %s.\n", fname); - } else { - fprintf(stderr, "ERROR: could not write Ed25519 public key to %s.\n", fname); - } - - fclose(f); - } else { - fprintf(stderr, "ERROR: could not append to %s: %s\n", fname, strerror(errno)); - } - } - } else { - // TODO: suggest remedies - char *key1 = ecdsa_get_base64_public_key(ecdsa_pub); - - if(!key1) { - fprintf(stderr, "ERROR: public Ed25519 key does not work.\n"); - return 1; - } - - char *key2 = ecdsa_get_base64_public_key(ecdsa_priv); - - if(!key2) { - free(key1); - fprintf(stderr, "ERROR: private Ed25519 key does not work.\n"); - return 1; - } - - int result = strcmp(key1, key2); - free(key1); - free(key2); - - if(result) { - fprintf(stderr, "ERROR: public and private Ed25519 keys do not match.\n"); - return 1; - } - } - } else { - if(ecdsa_pub) { - fprintf(stderr, "WARNING: A public Ed25519 key was found but no private key is known.\n"); - } - } - - // Check whether scripts are executable - - struct dirent *ent; - DIR *dir = opendir(confbase); - - if(!dir) { - fprintf(stderr, "ERROR: cannot read directory %s: %s\n", confbase, strerror(errno)); - return 1; - } - - while((ent = readdir(dir))) { - if(strtailcmp(ent->d_name, "-up") && strtailcmp(ent->d_name, "-down")) { - continue; - } - - strncpy(fname, ent->d_name, sizeof(fname)); - char *dash = strrchr(fname, '-'); - - if(!dash) { - continue; - } - - *dash = 0; - - if(strcmp(fname, "tinc") && strcmp(fname, "host") && strcmp(fname, "subnet")) { - static bool explained = false; - fprintf(stderr, "WARNING: Unknown script %s" SLASH "%s found.\n", confbase, ent->d_name); - - if(!explained) { - fprintf(stderr, "The only scripts in %s executed by tinc are:\n", confbase); - fprintf(stderr, "tinc-up, tinc-down, host-up, host-down, subnet-up and subnet-down.\n"); - explained = true; - } - - continue; - } - - snprintf(fname, sizeof(fname), "%s" SLASH "%s", confbase, ent->d_name); - - if(access(fname, R_OK | X_OK)) { - if(errno != EACCES) { - fprintf(stderr, "ERROR: cannot access %s: %s\n", fname, strerror(errno)); - continue; - } - - fprintf(stderr, "WARNING: cannot read and execute %s: %s\n", fname, strerror(errno)); - - if(ask_fix()) { - if(chmod(fname, 0755)) { - fprintf(stderr, "ERROR: cannot change permissions on %s: %s\n", fname, strerror(errno)); - } - } - } - } - - closedir(dir); - - snprintf(dname, sizeof(dname), "%s" SLASH "hosts", confbase); - dir = opendir(dname); - - if(!dir) { - fprintf(stderr, "ERROR: cannot read directory %s: %s\n", dname, strerror(errno)); - return 1; - } - - while((ent = readdir(dir))) { - if(strtailcmp(ent->d_name, "-up") && strtailcmp(ent->d_name, "-down")) { - continue; - } - - strncpy(fname, ent->d_name, sizeof(fname)); - char *dash = strrchr(fname, '-'); - - if(!dash) { - continue; - } - - *dash = 0; - - snprintf(fname, sizeof(fname), "%s" SLASH "hosts" SLASH "%s", confbase, ent->d_name); - - if(access(fname, R_OK | X_OK)) { - if(errno != EACCES) { - fprintf(stderr, "ERROR: cannot access %s: %s\n", fname, strerror(errno)); - continue; - } - - fprintf(stderr, "WARNING: cannot read and execute %s: %s\n", fname, strerror(errno)); - - if(ask_fix()) { - if(chmod(fname, 0755)) { - fprintf(stderr, "ERROR: cannot change permissions on %s: %s\n", fname, strerror(errno)); - } - } - } - } - - closedir(dir); - - // Check for obsolete / unsafe / unknown configuration variables. - - check_conffile(tinc_conf, true); - - dir = opendir(dname); - - if(dir) { - while((ent = readdir(dir))) { - if(!check_id(ent->d_name)) { - continue; - } - - snprintf(fname, sizeof(fname), "%s" SLASH "hosts" SLASH "%s", confbase, ent->d_name); - check_conffile(fname, false); - } - - closedir(dir); - } - - return 0; -} - diff --git a/src/fsck.h b/src/fsck.h deleted file mode 100644 index 3e0b4ca..0000000 --- a/src/fsck.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef TINC_FSCK_H -#define TINC_FSCK_H - -/* - fsck.h -- header for fsck.c. - Copyright (C) 2012 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -extern int fsck(const char *argv0); - -#endif diff --git a/src/gcrypt/cipher.c b/src/gcrypt/cipher.c deleted file mode 100644 index 3eed8e9..0000000 --- a/src/gcrypt/cipher.c +++ /dev/null @@ -1,284 +0,0 @@ -/* - cipher.c -- Symmetric block cipher handling - Copyright (C) 2007-2012 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include "cipher.h" -#include "logger.h" -#include "xalloc.h" - -static struct { - const char *name; - int algo; - int mode; - int nid; -} ciphertable[] = { - {"none", GCRY_CIPHER_NONE, GCRY_CIPHER_MODE_NONE, 0}, - - {NULL, GCRY_CIPHER_BLOWFISH, GCRY_CIPHER_MODE_ECB, 92}, - {"blowfish", GCRY_CIPHER_BLOWFISH, GCRY_CIPHER_MODE_CBC, 91}, - {NULL, GCRY_CIPHER_BLOWFISH, GCRY_CIPHER_MODE_CFB, 93}, - {NULL, GCRY_CIPHER_BLOWFISH, GCRY_CIPHER_MODE_OFB, 94}, - - {NULL, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_ECB, 418}, - {"aes", GCRY_CIPHER_AES, GCRY_CIPHER_MODE_CBC, 419}, - {NULL, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_CFB, 421}, - {NULL, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_OFB, 420}, - - {NULL, GCRY_CIPHER_AES192, GCRY_CIPHER_MODE_ECB, 422}, - {"aes192", GCRY_CIPHER_AES192, GCRY_CIPHER_MODE_CBC, 423}, - {NULL, GCRY_CIPHER_AES192, GCRY_CIPHER_MODE_CFB, 425}, - {NULL, GCRY_CIPHER_AES192, GCRY_CIPHER_MODE_OFB, 424}, - - {NULL, GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_ECB, 426}, - {"aes256", GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CBC, 427}, - {NULL, GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CFB, 429}, - {NULL, GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_OFB, 428}, -}; - -static bool nametocipher(const char *name, int *algo, int *mode) { - size_t i; - - for(i = 0; i < sizeof(ciphertable) / sizeof(*ciphertable); i++) { - if(ciphertable[i].name && !strcasecmp(name, ciphertable[i].name)) { - *algo = ciphertable[i].algo; - *mode = ciphertable[i].mode; - return true; - } - } - - return false; -} - -static bool nidtocipher(int nid, int *algo, int *mode) { - size_t i; - - for(i = 0; i < sizeof(ciphertable) / sizeof(*ciphertable); i++) { - if(nid == ciphertable[i].nid) { - *algo = ciphertable[i].algo; - *mode = ciphertable[i].mode; - return true; - } - } - - return false; -} - -static bool ciphertonid(int algo, int mode, int *nid) { - size_t i; - - for(i = 0; i < sizeof(ciphertable) / sizeof(*ciphertable); i++) { - if(algo == ciphertable[i].algo && mode == ciphertable[i].mode) { - *nid = ciphertable[i].nid; - return true; - } - } - - return false; -} - -static bool cipher_open(cipher_t *cipher, int algo, int mode) { - gcry_error_t err; - - if(!ciphertonid(algo, mode, &cipher->nid)) { - logger(DEBUG_ALWAYS, LOG_DEBUG, "Cipher %d mode %d has no corresponding nid!", algo, mode); - return false; - } - - if((err = gcry_cipher_open(&cipher->handle, algo, mode, 0))) { - logger(DEBUG_ALWAYS, LOG_DEBUG, "Unable to initialise cipher %d mode %d: %s", algo, mode, gcry_strerror(err)); - return false; - } - - cipher->keylen = gcry_cipher_get_algo_keylen(algo); - cipher->blklen = gcry_cipher_get_algo_blklen(algo); - cipher->key = xmalloc(cipher->keylen + cipher->blklen); - cipher->padding = mode == GCRY_CIPHER_MODE_ECB || mode == GCRY_CIPHER_MODE_CBC; - - return true; -} - -bool cipher_open_by_name(cipher_t *cipher, const char *name) { - int algo, mode; - - if(!nametocipher(name, &algo, &mode)) { - logger(DEBUG_ALWAYS, LOG_DEBUG, "Unknown cipher name '%s'!", name); - return false; - } - - return cipher_open(cipher, algo, mode); -} - -bool cipher_open_by_nid(cipher_t *cipher, int nid) { - int algo, mode; - - if(!nidtocipher(nid, &algo, &mode)) { - logger(DEBUG_ALWAYS, LOG_DEBUG, "Unknown cipher ID %d!", nid); - return false; - } - - return cipher_open(cipher, algo, mode); -} - -bool cipher_open_blowfish_ofb(cipher_t *cipher) { - return cipher_open(cipher, GCRY_CIPHER_BLOWFISH, GCRY_CIPHER_MODE_OFB); -} - -void cipher_close(cipher_t *cipher) { - if(cipher->handle) { - gcry_cipher_close(cipher->handle); - cipher->handle = NULL; - } - - free(cipher->key); - cipher->key = NULL; -} - -size_t cipher_keylength(const cipher_t *cipher) { - return cipher->keylen + cipher->blklen; -} - -void cipher_get_key(const cipher_t *cipher, void *key) { - memcpy(key, cipher->key, cipher->keylen + cipher->blklen); -} - -bool cipher_set_key(cipher_t *cipher, void *key, bool encrypt) { - memcpy(cipher->key, key, cipher->keylen + cipher->blklen); - - gcry_cipher_setkey(cipher->handle, cipher->key, cipher->keylen); - gcry_cipher_setiv(cipher->handle, cipher->key + cipher->keylen, cipher->blklen); - - return true; -} - -bool cipher_set_key_from_rsa(cipher_t *cipher, void *key, size_t len, bool encrypt) { - memcpy(cipher->key, key + len - cipher->keylen, cipher->keylen + cipher->blklen); - memcpy(cipher->key + cipher->keylen, key + len - cipher->keylen - cipher->blklen, cipher->blklen); - - gcry_cipher_setkey(cipher->handle, cipher->key, cipher->keylen); - gcry_cipher_setiv(cipher->handle, cipher->key + cipher->keylen, cipher->blklen); - - return true; -} - -bool cipher_regenerate_key(cipher_t *cipher, bool encrypt) { - gcry_create_nonce(cipher->key, cipher->keylen + cipher->blklen); - - gcry_cipher_setkey(cipher->handle, cipher->key, cipher->keylen); - gcry_cipher_setiv(cipher->handle, cipher->key + cipher->keylen, cipher->blklen); - - return true; -} - -bool cipher_encrypt(cipher_t *cipher, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) { - gcry_error_t err; - uint8_t pad[cipher->blklen]; - - if(cipher->padding) { - if(!oneshot) { - return false; - } - - size_t reqlen = ((inlen + cipher->blklen) / cipher->blklen) * cipher->blklen; - - if(*outlen < reqlen) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while encrypting: not enough room for padding"); - return false; - } - - uint8_t padbyte = reqlen - inlen; - inlen = reqlen - cipher->blklen; - - for(int i = 0; i < cipher->blklen; i++) - if(i < cipher->blklen - padbyte) { - pad[i] = ((uint8_t *)indata)[inlen + i]; - } else { - pad[i] = padbyte; - } - } - - if(oneshot) { - gcry_cipher_setiv(cipher->handle, cipher->key + cipher->keylen, cipher->blklen); - } - - if((err = gcry_cipher_encrypt(cipher->handle, outdata, *outlen, indata, inlen))) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while encrypting: %s", gcry_strerror(err)); - return false; - } - - if(cipher->padding) { - if((err = gcry_cipher_encrypt(cipher->handle, outdata + inlen, cipher->blklen, pad, cipher->blklen))) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while encrypting: %s", gcry_strerror(err)); - return false; - } - - inlen += cipher->blklen; - } - - *outlen = inlen; - return true; -} - -bool cipher_decrypt(cipher_t *cipher, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) { - gcry_error_t err; - - if(oneshot) { - gcry_cipher_setiv(cipher->handle, cipher->key + cipher->keylen, cipher->blklen); - } - - if((err = gcry_cipher_decrypt(cipher->handle, outdata, *outlen, indata, inlen))) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while decrypting: %s", gcry_strerror(err)); - return false; - } - - if(cipher->padding) { - if(!oneshot) { - return false; - } - - uint8_t padbyte = ((uint8_t *)outdata)[inlen - 1]; - - if(padbyte == 0 || padbyte > cipher->blklen || padbyte > inlen) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while decrypting: invalid padding"); - return false; - } - - size_t origlen = inlen - padbyte; - - for(int i = inlen - 1; i >= origlen; i--) - if(((uint8_t *)outdata)[i] != padbyte) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while decrypting: invalid padding"); - return false; - } - - *outlen = origlen; - } else { - *outlen = inlen; - } - - return true; -} - -int cipher_get_nid(const cipher_t *cipher) { - return cipher->nid; -} - -bool cipher_active(const cipher_t *cipher) { - return cipher->nid != 0; -} diff --git a/src/gcrypt/crypto.c b/src/gcrypt/crypto.c deleted file mode 100644 index dc92b3e..0000000 --- a/src/gcrypt/crypto.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - crypto.c -- Cryptographic miscellaneous functions and initialisation - Copyright (C) 2007 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include - -#include "crypto.h" - -void crypto_init() { -} - -void crypto_exit() { -} - -void randomize(void *out, size_t outlen) { - gcry_create_nonce(out, outlen); -} diff --git a/src/gcrypt/digest.c b/src/gcrypt/digest.c deleted file mode 100644 index fce48ee..0000000 --- a/src/gcrypt/digest.c +++ /dev/null @@ -1,182 +0,0 @@ -/* - digest.c -- Digest handling - Copyright (C) 2007-2012 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include "digest.h" -#include "logger.h" - -static struct { - const char *name; - int algo; - int nid; -} digesttable[] = { - {"none", GCRY_MD_NONE, 0}, - {"sha1", GCRY_MD_SHA1, 64}, - {"sha256", GCRY_MD_SHA256, 672}, - {"sha384", GCRY_MD_SHA384, 673}, - {"sha512", GCRY_MD_SHA512, 674}, -}; - -static bool nametodigest(const char *name, int *algo) { - int i; - - for(i = 0; i < sizeof(digesttable) / sizeof(*digesttable); i++) { - if(digesttable[i].name && !strcasecmp(name, digesttable[i].name)) { - *algo = digesttable[i].algo; - return true; - } - } - - return false; -} - -static bool nidtodigest(int nid, int *algo) { - int i; - - for(i = 0; i < sizeof(digesttable) / sizeof(*digesttable); i++) { - if(nid == digesttable[i].nid) { - *algo = digesttable[i].algo; - return true; - } - } - - return false; -} - -static bool digesttonid(int algo, int *nid) { - int i; - - for(i = 0; i < sizeof(digesttable) / sizeof(*digesttable); i++) { - if(algo == digesttable[i].algo) { - *nid = digesttable[i].nid; - return true; - } - } - - return false; -} - -static bool digest_open(digest_t *digest, int algo, int maclength) { - if(!digesttonid(algo, &digest->nid)) { - logger(DEBUG_ALWAYS, LOG_DEBUG, "Digest %d has no corresponding nid!", algo); - return false; - } - - unsigned int len = gcry_md_get_algo_dlen(algo); - - if(maclength > len || maclength < 0) { - digest->maclength = len; - } else { - digest->maclength = maclength; - } - - digest->algo = algo; - digest->hmac = NULL; - - return true; -} - -bool digest_open_by_name(digest_t *digest, const char *name, int maclength) { - int algo; - - if(!nametodigest(name, &algo)) { - logger(DEBUG_ALWAYS, LOG_DEBUG, "Unknown digest name '%s'!", name); - return false; - } - - return digest_open(digest, algo, maclength); -} - -bool digest_open_by_nid(digest_t *digest, int nid, int maclength) { - int algo; - - if(!nidtodigest(nid, &algo)) { - logger(DEBUG_ALWAYS, LOG_DEBUG, "Unknown digest ID %d!", nid); - return false; - } - - return digest_open(digest, algo, maclength); -} - -bool digest_open_sha1(digest_t *digest, int maclength) { - return digest_open(digest, GCRY_MD_SHA1, maclength); -} - -void digest_close(digest_t *digest) { - if(digest->hmac) { - gcry_md_close(digest->hmac); - } - - digest->hmac = NULL; -} - -bool digest_set_key(digest_t *digest, const void *key, size_t len) { - if(!digest->hmac) { - gcry_md_open(&digest->hmac, digest->algo, GCRY_MD_FLAG_HMAC); - } - - if(!digest->hmac) { - return false; - } - - return !gcry_md_setkey(digest->hmac, key, len); -} - -bool digest_create(digest_t *digest, const void *indata, size_t inlen, void *outdata) { - unsigned int len = gcry_md_get_algo_dlen(digest->algo); - - if(digest->hmac) { - char *tmpdata; - gcry_md_reset(digest->hmac); - gcry_md_write(digest->hmac, indata, inlen); - tmpdata = gcry_md_read(digest->hmac, digest->algo); - - if(!tmpdata) { - return false; - } - - memcpy(outdata, tmpdata, digest->maclength); - } else { - char tmpdata[len]; - gcry_md_hash_buffer(digest->algo, tmpdata, indata, inlen); - memcpy(outdata, tmpdata, digest->maclength); - } - - return true; -} - -bool digest_verify(digest_t *digest, const void *indata, size_t inlen, const void *cmpdata) { - unsigned int len = digest->maclength; - char outdata[len]; - - return digest_create(digest, indata, inlen, outdata) && !memcmp(cmpdata, outdata, len); -} - -int digest_get_nid(const digest_t *digest) { - return digest->nid; -} - -size_t digest_length(const digest_t *digest) { - return digest->maclength; -} - -bool digest_active(const digest_t *digest) { - return digest->algo != GCRY_MD_NONE; -} diff --git a/src/gcrypt/digest.h b/src/gcrypt/digest.h deleted file mode 100644 index 42404fc..0000000 --- a/src/gcrypt/digest.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef TINC_GCRYPT_DIGEST_H -#define TINC_GCRYPT_DIGEST_H - -/* - digest.h -- header file digest.c - Copyright (C) 2007-2009 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include - -#define DIGEST_MAX_SIZE 64 - -typedef struct digest { - int algo; - int nid; - int maclength; - gcry_md_hd_t hmac; -} digest_t; - -extern bool digest_open_by_name(struct digest *, const char *name, int maclength); -extern bool digest_open_by_nid(struct digest *, int nid, int maclength); -extern bool digest_open_sha1(struct digest *, int maclength); -extern void digest_close(struct digest *); -extern bool digest_create(struct digest *, const void *indata, size_t inlen, void *outdata); -extern bool digest_verify(struct digest *, const void *indata, size_t inlen, const void *digestdata); -extern bool digest_set_key(struct digest *, const void *key, size_t len); -extern int digest_get_nid(const struct digest *); -extern size_t digest_length(const struct digest *); -extern bool digest_active(const struct digest *); - -#endif diff --git a/src/gcrypt/prf.c b/src/gcrypt/prf.c deleted file mode 100644 index ce80f8c..0000000 --- a/src/gcrypt/prf.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - prf.c -- Pseudo-Random Function for key material generation - Copyright (C) 2011-2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "../system.h" - -#include "../prf.h" -#include "../ed25519/sha512.h" - -static void memxor(char *buf, char c, size_t len) { - for(size_t i = 0; i < len; i++) { - buf[i] ^= c; - } -} - -static const size_t mdlen = 64; -static const size_t blklen = 128; - -static bool hmac_sha512(const char *key, size_t keylen, const char *msg, size_t msglen, char *out) { - char tmp[blklen + mdlen]; - sha512_context md; - - if(keylen <= blklen) { - memcpy(tmp, key, keylen); - memset(tmp + keylen, 0, blklen - keylen); - } else { - if(sha512(key, keylen, tmp) != 0) { - return false; - } - - memset(tmp + mdlen, 0, blklen - mdlen); - } - - if(sha512_init(&md) != 0) { - return false; - } - - // ipad - memxor(tmp, 0x36, blklen); - - if(sha512_update(&md, tmp, blklen) != 0) { - return false; - } - - // message - if(sha512_update(&md, msg, msglen) != 0) { - return false; - } - - if(sha512_final(&md, tmp + blklen) != 0) { - return false; - } - - // opad - memxor(tmp, 0x36 ^ 0x5c, blklen); - - if(sha512(tmp, sizeof(tmp), out) != 0) { - return false; - } - - return true; -} - - -/* Generate key material from a master secret and a seed, based on RFC 4346 section 5. - We use SHA512 instead of MD5 and SHA1. - */ - -bool prf(const char *secret, size_t secretlen, char *seed, size_t seedlen, char *out, size_t outlen) { - /* Data is what the "inner" HMAC function processes. - It consists of the previous HMAC result plus the seed. - */ - - char data[mdlen + seedlen]; - memset(data, 0, mdlen); - memcpy(data + mdlen, seed, seedlen); - - char hash[mdlen]; - - while(outlen > 0) { - /* Inner HMAC */ - if(!hmac_sha512(secret, secretlen, data, sizeof(data), data)) { - return false; - } - - /* Outer HMAC */ - if(outlen >= mdlen) { - if(!hmac_sha512(secret, secretlen, data, sizeof(data), out)) { - return false; - } - - out += mdlen; - outlen -= mdlen; - } else { - if(!hmac_sha512(secret, secretlen, data, sizeof(data), hash)) { - return false; - } - - memcpy(out, hash, outlen); - out += outlen; - outlen = 0; - } - } - - return true; -} diff --git a/src/gcrypt/rsa.c b/src/gcrypt/rsa.c deleted file mode 100644 index eb9f58d..0000000 --- a/src/gcrypt/rsa.c +++ /dev/null @@ -1,327 +0,0 @@ -/* - rsa.c -- RSA key handling - Copyright (C) 2007-2012 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include - -#include "logger.h" -#include "rsa.h" - -// Base64 decoding table - -static const uint8_t b64d[128] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f, - 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, - 0x3a, 0x3b, 0x3c, 0x3d, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, - 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, - 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, - 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, - 0x19, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, - 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, - 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, - 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, - 0x31, 0x32, 0x33, 0xff, 0xff, 0xff, - 0xff, 0xff -}; - -// PEM encoding/decoding functions - -static bool pem_decode(FILE *fp, const char *header, uint8_t *buf, size_t size, size_t *outsize) { - bool decode = false; - char line[1024]; - uint16_t word = 0; - int shift = 10; - size_t i, j = 0; - - while(!feof(fp)) { - if(!fgets(line, sizeof(line), fp)) { - return false; - } - - if(!decode && !strncmp(line, "-----BEGIN ", 11)) { - if(!strncmp(line + 11, header, strlen(header))) { - decode = true; - } - - continue; - } - - if(decode && !strncmp(line, "-----END", 8)) { - break; - } - - if(!decode) { - continue; - } - - for(i = 0; line[i] >= ' '; i++) { - if((signed char)line[i] < 0 || b64d[(int)line[i]] == 0xff) { - break; - } - - word |= b64d[(int)line[i]] << shift; - shift -= 6; - - if(shift <= 2) { - if(j > size) { - errno = ENOMEM; - return false; - } - - buf[j++] = word >> 8; - word <<= 8; - shift += 8; - } - } - } - - if(outsize) { - *outsize = j; - } - - return true; -} - - -// BER decoding functions - -static int ber_read_id(unsigned char **p, size_t *buflen) { - if(*buflen <= 0) { - return -1; - } - - if((**p & 0x1f) == 0x1f) { - int id = 0; - bool more; - - while(*buflen > 0) { - id <<= 7; - id |= **p & 0x7f; - more = *(*p)++ & 0x80; - (*buflen)--; - - if(!more) { - break; - } - } - - return id; - } else { - (*buflen)--; - return *(*p)++ & 0x1f; - } -} - -static size_t ber_read_len(unsigned char **p, size_t *buflen) { - if(*buflen <= 0) { - return -1; - } - - if(**p & 0x80) { - size_t result = 0; - int len = *(*p)++ & 0x7f; - (*buflen)--; - - if(len > *buflen) { - return 0; - } - - while(len--) { - result <<= 8; - result |= *(*p)++; - (*buflen)--; - } - - return result; - } else { - (*buflen)--; - return *(*p)++; - } -} - - -static bool ber_read_sequence(unsigned char **p, size_t *buflen, size_t *result) { - int tag = ber_read_id(p, buflen); - size_t len = ber_read_len(p, buflen); - - if(tag == 0x10) { - if(result) { - *result = len; - } - - return true; - } else { - return false; - } -} - -static bool ber_read_mpi(unsigned char **p, size_t *buflen, gcry_mpi_t *mpi) { - int tag = ber_read_id(p, buflen); - size_t len = ber_read_len(p, buflen); - gcry_error_t err = 0; - - if(tag != 0x02 || len > *buflen) { - return false; - } - - if(mpi) { - err = gcry_mpi_scan(mpi, GCRYMPI_FMT_USG, *p, len, NULL); - } - - *p += len; - *buflen -= len; - - return mpi ? !err : true; -} - -bool rsa_set_hex_public_key(rsa_t *rsa, char *n, char *e) { - gcry_error_t err = 0; - - err = gcry_mpi_scan(&rsa->n, GCRYMPI_FMT_HEX, n, 0, NULL) - ? : gcry_mpi_scan(&rsa->e, GCRYMPI_FMT_HEX, e, 0, NULL); - - if(err) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading RSA public key: %s", gcry_strerror(errno)); - return false; - } - - return true; -} - -bool rsa_set_hex_private_key(rsa_t *rsa, char *n, char *e, char *d) { - gcry_error_t err = 0; - - err = gcry_mpi_scan(&rsa->n, GCRYMPI_FMT_HEX, n, 0, NULL) - ? : gcry_mpi_scan(&rsa->e, GCRYMPI_FMT_HEX, e, 0, NULL) - ? : gcry_mpi_scan(&rsa->d, GCRYMPI_FMT_HEX, d, 0, NULL); - - if(err) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading RSA public key: %s", gcry_strerror(errno)); - return false; - } - - return true; -} - -// Read PEM RSA keys - -bool rsa_read_pem_public_key(rsa_t *rsa, FILE *fp) { - uint8_t derbuf[8096], *derp = derbuf; - size_t derlen; - - if(!pem_decode(fp, "RSA PUBLIC KEY", derbuf, sizeof(derbuf), &derlen)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unable to read RSA public key: %s", strerror(errno)); - return NULL; - } - - if(!ber_read_sequence(&derp, &derlen, NULL) - || !ber_read_mpi(&derp, &derlen, &rsa->n) - || !ber_read_mpi(&derp, &derlen, &rsa->e) - || derlen) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while decoding RSA public key"); - return NULL; - } - - return true; -} - -bool rsa_read_pem_private_key(rsa_t *rsa, FILE *fp) { - uint8_t derbuf[8096], *derp = derbuf; - size_t derlen; - - if(!pem_decode(fp, "RSA PRIVATE KEY", derbuf, sizeof(derbuf), &derlen)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unable to read RSA private key: %s", strerror(errno)); - return NULL; - } - - if(!ber_read_sequence(&derp, &derlen, NULL) - || !ber_read_mpi(&derp, &derlen, NULL) - || !ber_read_mpi(&derp, &derlen, &rsa->n) - || !ber_read_mpi(&derp, &derlen, &rsa->e) - || !ber_read_mpi(&derp, &derlen, &rsa->d) - || !ber_read_mpi(&derp, &derlen, NULL) // p - || !ber_read_mpi(&derp, &derlen, NULL) // q - || !ber_read_mpi(&derp, &derlen, NULL) - || !ber_read_mpi(&derp, &derlen, NULL) - || !ber_read_mpi(&derp, &derlen, NULL) // u - || derlen) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while decoding RSA private key"); - return NULL; - } - - return true; -} - -size_t rsa_size(rsa_t *rsa) { - return (gcry_mpi_get_nbits(rsa->n) + 7) / 8; -} - -/* Well, libgcrypt has functions to handle RSA keys, but they suck. - * So we just use libgcrypt's mpi functions, and do the math ourselves. - */ - -// TODO: get rid of this macro, properly clean up gcry_ structures after use -#define check(foo) { gcry_error_t err = (foo); if(err) {logger(DEBUG_ALWAYS, LOG_ERR, "gcrypt error %s/%s at %s:%d", gcry_strsource(err), gcry_strerror(err), __FILE__, __LINE__); return false; }} - -bool rsa_public_encrypt(rsa_t *rsa, void *in, size_t len, void *out) { - gcry_mpi_t inmpi; - check(gcry_mpi_scan(&inmpi, GCRYMPI_FMT_USG, in, len, NULL)); - - gcry_mpi_t outmpi = gcry_mpi_new(len * 8); - gcry_mpi_powm(outmpi, inmpi, rsa->e, rsa->n); - - int pad = len - (gcry_mpi_get_nbits(outmpi) + 7) / 8; - - while(pad--) { - *(char *)out++ = 0; - } - - check(gcry_mpi_print(GCRYMPI_FMT_USG, out, len, NULL, outmpi)); - - return true; -} - -bool rsa_private_decrypt(rsa_t *rsa, void *in, size_t len, void *out) { - gcry_mpi_t inmpi; - check(gcry_mpi_scan(&inmpi, GCRYMPI_FMT_USG, in, len, NULL)); - - gcry_mpi_t outmpi = gcry_mpi_new(len * 8); - gcry_mpi_powm(outmpi, inmpi, rsa->d, rsa->n); - - int pad = len - (gcry_mpi_get_nbits(outmpi) + 7) / 8; - - while(pad--) { - *(char *)out++ = 0; - } - - check(gcry_mpi_print(GCRYMPI_FMT_USG, out, len, NULL, outmpi)); - - return true; -} diff --git a/src/gcrypt/rsagen.c b/src/gcrypt/rsagen.c deleted file mode 100644 index 030f2bc..0000000 --- a/src/gcrypt/rsagen.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - rsagen.c -- RSA key generation and export - Copyright (C) 2008-2012 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include - -#include "rsagen.h" - -#if 0 -// Base64 encoding table - -static const char b64e[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -// PEM encoding - -static bool pem_encode(FILE *fp, const char *header, uint8_t *buf, size_t size) { - bool decode = false; - char line[1024]; - uint32_t word = 0; - int shift = 0; - size_t i, j = 0; - - fprintf(fp, "-----BEGIN %s-----\n", header); - - for(i = 0; i < size; i += 3) { - if(i <= size - 3) { - word = buf[i] << 16 | buf[i + 1] << 8 | buf[i + 2]; - } else { - word = buf[i] << 16; - - if(i == size - 2) { - word |= buf[i + 1] << 8; - } - } - - line[j++] = b64e[(word >> 18) ]; - line[j++] = b64e[(word >> 12) & 0x3f]; - line[j++] = b64e[(word >> 6) & 0x3f]; - line[j++] = b64e[(word) & 0x3f]; - - if(j >= 64) { - line[j++] = '\n'; - line[j] = 0; - fputs(line, fp); - j = 0; - } - } - - if(size % 3 > 0) { - if(size % 3 > 1) { - line[j++] = '='; - } - - line[j++] = '='; - } - - if(j) { - line[j++] = '\n'; - line[j] = 0; - fputs(line, fp); - } - - fprintf(fp, "-----END %s-----\n", header); - - return true; -} - - -// BER encoding functions - -static bool ber_write_id(uint8_t **p, size_t *buflen, int id) { - if(*buflen <= 0) { - return false; - } - - if(id >= 0x1f) { - while(id) { - if(*buflen <= 0) { - return false; - } - - (*buflen)--; - **p = id & 0x7f; - id >>= 7; - - if(id) { - **p |= 0x80; - } - - (*p)++; - } - } else { - (*buflen)--; - *(*p)++ = id; - } - - return true; -} - -static bool ber_write_len(uint8_t **p, size_t *buflen, size_t len) { - do { - if(*buflen <= 0) { - return false; - } - - (*buflen)--; - **p = len & 0x7f; - len >>= 7; - - if(len) { - **p |= 0x80; - } - - (*p)++; - } while(len); - - return true; -} - -static bool ber_write_sequence(uint8_t **p, size_t *buflen, uint8_t *seqbuf, size_t seqlen) { - if(!ber_write_id(p, buflen, 0x10) || !ber_write_len(p, buflen, seqlen) || *buflen < seqlen) { - return false; - } - - memcpy(*p, seqbuf, seqlen); - *p += seqlen; - *buflen -= seqlen; - - return true; -} - -static bool ber_write_mpi(uint8_t **p, size_t *buflen, gcry_mpi_t mpi) { - uint8_t tmpbuf[1024]; - size_t tmplen = sizeof(tmpbuf); - gcry_error_t err; - - err = gcry_mpi_aprint(GCRYMPI_FMT_USG, &tmpbuf, &tmplen, mpi); - - if(err) { - return false; - } - - if(!ber_write_id(p, buflen, 0x02) || !ber_write_len(p, buflen, tmplen) || *buflen < tmplen) { - return false; - } - - memcpy(*p, tmpbuf, tmplen); - *p += tmplen; - *buflen -= tmplen; - - return true; -} - -// Write PEM RSA keys - -bool rsa_write_pem_public_key(rsa_t *rsa, FILE *fp) { - uint8_t derbuf1[8096]; - uint8_t derbuf2[8096]; - uint8_t *derp1 = derbuf1; - uint8_t *derp2 = derbuf2; - size_t derlen1 = sizeof(derbuf1); - size_t derlen2 = sizeof(derbuf2); - - if(!ber_write_mpi(&derp1, &derlen1, &rsa->n) - || !ber_write_mpi(&derp1, &derlen1, &rsa->e) - || !ber_write_sequence(&derp2, &derlen2, derbuf1, derlen1)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while encoding RSA public key"); - return false; - } - - if(!pem_encode(fp, "RSA PUBLIC KEY", derbuf2, derlen2)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unable to write RSA public key: %s", strerror(errno)); - return false; - } - - return true; -} - -bool rsa_write_pem_private_key(rsa_t *rsa, FILE *fp) { - uint8_t derbuf1[8096]; - uint8_t derbuf2[8096]; - uint8_t *derp1 = derbuf1; - uint8_t *derp2 = derbuf2; - size_t derlen1 = sizeof(derbuf1); - size_t derlen2 = sizeof(derbuf2); - - if(!ber_write_mpi(&derp1, &derlen1, &bits) - || ber_write_mpi(&derp1, &derlen1, &rsa->n) // modulus - || ber_write_mpi(&derp1, &derlen1, &rsa->e) // public exponent - || ber_write_mpi(&derp1, &derlen1, &rsa->d) // private exponent - || ber_write_mpi(&derp1, &derlen1, &p) - || ber_write_mpi(&derp1, &derlen1, &q) - || ber_write_mpi(&derp1, &derlen1, &exp1) - || ber_write_mpi(&derp1, &derlen1, &exp2) - || ber_write_mpi(&derp1, &derlen1, &coeff)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while encoding RSA private key"); - } - - return false; -} - -if(!pem_encode(fp, "RSA PRIVATE KEY", derbuf2, derlen2)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unable to write RSA private key: %s", strerror(errno)); - return false; -} - -return true; -} -#endif - -bool rsa_write_pem_public_key(rsa_t *rsa, FILE *fp) { - return false; -} - -bool rsa_write_pem_private_key(rsa_t *rsa, FILE *fp) { - return false; -} - -bool rsa_generate(rsa_t *rsa, size_t bits, unsigned long exponent) { - fprintf(stderr, "Generating RSA keys with libgcrypt not implemented yet\n"); - return false; -} diff --git a/src/getopt.c b/src/getopt.c index 5d5fb59..741c7f2 100644 --- a/src/getopt.c +++ b/src/getopt.c @@ -132,7 +132,7 @@ int optind = 1; causes problems with re-calling getopt as programs generally don't know that. */ -int __getopt_initialized = 0; +int getopt_initialized = 0; /* The next char to be scanned in the option-element in which the last option character we returned was found. @@ -248,7 +248,7 @@ static int last_nonopt; indicating ARGV elements that should not be considered arguments. */ /* Defined in getopt_init.c */ -extern char *__getopt_nonoption_flags; +extern char *getopt_nonoption_flags; static int nonoption_flags_max_len; static int nonoption_flags_len; @@ -256,7 +256,7 @@ static int nonoption_flags_len; static int original_argc; static char *const *original_argv; -extern pid_t __libc_pid; +extern pid_t libc_pid; /* Make sure the environment variable bash 2.0 puts in the environment is valid for the getopt call we must make sure that the ARGV passed @@ -269,14 +269,14 @@ store_args_and_env(int argc, char *const *argv) { original_argc = argc; original_argv = argv; } -text_set_element(__libc_subinit, store_args_and_env); +text_set_element(libc_subinit, store_args_and_env); # define SWAP_FLAGS(ch1, ch2) \ if (nonoption_flags_len > 0) \ { \ - char __tmp = __getopt_nonoption_flags[ch1]; \ - __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ - __getopt_nonoption_flags[ch2] = __tmp; \ + char tmp = getopt_nonoption_flags[ch1]; \ + getopt_nonoption_flags[ch1] = getopt_nonoption_flags[ch2]; \ + getopt_nonoption_flags[ch2] = tmp; \ } #else /* !_LIBC */ # define SWAP_FLAGS(ch1, ch2) @@ -311,7 +311,7 @@ char **argv; #ifdef _LIBC - /* First make sure the handling of the `__getopt_nonoption_flags' + /* First make sure the handling of the `getopt_nonoption_flags' string can work normally. Our top argument must be in the range of the string. */ if(nonoption_flags_len > 0 && top >= nonoption_flags_max_len) { @@ -322,11 +322,11 @@ char **argv; if(new_str == NULL) { nonoption_flags_len = nonoption_flags_max_len = 0; } else { - memcpy(new_str, __getopt_nonoption_flags, nonoption_flags_max_len); + memcpy(new_str, getopt_nonoption_flags, nonoption_flags_max_len); memset(&new_str[nonoption_flags_max_len], '\0', top + 1 - nonoption_flags_max_len); nonoption_flags_max_len = top + 1; - __getopt_nonoption_flags = new_str; + getopt_nonoption_flags = new_str; } } @@ -412,25 +412,25 @@ const char *optstring; if(posixly_correct == NULL && argc == original_argc && argv == original_argv) { if(nonoption_flags_max_len == 0) { - if(__getopt_nonoption_flags == NULL - || __getopt_nonoption_flags[0] == '\0') { + if(getopt_nonoption_flags == NULL + || getopt_nonoption_flags[0] == '\0') { nonoption_flags_max_len = -1; } else { - const char *orig_str = __getopt_nonoption_flags; + const char *orig_str = getopt_nonoption_flags; int len = nonoption_flags_max_len = strlen(orig_str); if(nonoption_flags_max_len < argc) { nonoption_flags_max_len = argc; } - __getopt_nonoption_flags = + getopt_nonoption_flags = (char *) malloc(nonoption_flags_max_len); - if(__getopt_nonoption_flags == NULL) { + if(getopt_nonoption_flags == NULL) { nonoption_flags_max_len = -1; } else { - memcpy(__getopt_nonoption_flags, orig_str, len); - memset(&__getopt_nonoption_flags[len], '\0', + memcpy(getopt_nonoption_flags, orig_str, len); + memset(&getopt_nonoption_flags[len], '\0', nonoption_flags_max_len - len); } } @@ -513,13 +513,13 @@ int long_only; { optarg = NULL; - if(optind == 0 || !__getopt_initialized) { + if(optind == 0 || !getopt_initialized) { if(optind == 0) { optind = 1; /* Don't scan ARGV[0], the program name. */ } optstring = _getopt_initialize(argc, argv, optstring); - __getopt_initialized = 1; + getopt_initialized = 1; } /* Test whether ARGV[optind] points to a non-option argument. @@ -529,7 +529,7 @@ int long_only; #ifdef _LIBC #define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ || (optind < nonoption_flags_len \ - && __getopt_nonoption_flags[optind] == '1')) + && getopt_nonoption_flags[optind] == '1')) #else #define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') #endif diff --git a/src/getopt.h b/src/getopt.h index e9a7040..ab1d40b 100644 --- a/src/getopt.h +++ b/src/getopt.h @@ -22,79 +22,76 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef _GETOPT_H -#define _GETOPT_H 1 - -#ifdef __cplusplus +#ifdef cplusplus extern "C" { #endif -/* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ + /* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ -extern char *optarg; + extern char *optarg; -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `getopt'. + /* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. - On entry to `getopt', zero means this is the first call; initialize. + On entry to `getopt', zero means this is the first call; initialize. - When `getopt' returns -1, this is the index of the first of the - non-option elements that the caller should itself scan. + When `getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. - Otherwise, `optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ -extern int optind; + extern int optind; -/* Callers store zero here to inhibit the error message `getopt' prints - for unrecognized options. */ + /* Callers store zero here to inhibit the error message `getopt' prints + for unrecognized options. */ -extern int opterr; + extern int opterr; -/* Set to an option character which was unrecognized. */ + /* Set to an option character which was unrecognized. */ -extern int optopt; + extern int optopt; -/* Describe the long-named options requested by the application. - The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector - of `struct option' terminated by an element containing a name which is - zero. + /* Describe the long-named options requested by the application. + The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector + of `struct option' terminated by an element containing a name which is + zero. - The field `has_arg' is: - no_argument (or 0) if the option does not take an argument, - required_argument (or 1) if the option requires an argument, - optional_argument (or 2) if the option takes an optional argument. + The field `has_arg' is: + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. - If the field `flag' is not NULL, it points to a variable that is set - to the value given in the field `val' when the option is found, but - left unchanged if the option is not found. + If the field `flag' is not NULL, it points to a variable that is set + to the value given in the field `val' when the option is found, but + left unchanged if the option is not found. - To have a long-named option do something other than set an `int' to - a compiled-in constant, such as set a value from `optarg', set the - option's `flag' field to zero and its `val' field to a nonzero - value (the equivalent single-letter option character, if there is - one). For long options that have a zero `flag' field, `getopt' - returns the contents of the `val' field. */ + To have a long-named option do something other than set an `int' to + a compiled-in constant, such as set a value from `optarg', set the + option's `flag' field to zero and its `val' field to a nonzero + value (the equivalent single-letter option character, if there is + one). For long options that have a zero `flag' field, `getopt' + returns the contents of the `val' field. */ -struct option { + struct option { #if defined (__STDC__) && __STDC__ - const char *name; + const char *name; #else - char *name; + char *name; #endif - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; -}; + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; + }; -/* Names for the values of the `has_arg' field of `struct option'. */ + /* Names for the values of the `has_arg' field of `struct option'. */ #define no_argument 0 #define required_argument 1 @@ -102,33 +99,33 @@ struct option { #if defined (__STDC__) && __STDC__ #ifdef __GNU_LIBRARY__ -/* Many other libraries have conflicting prototypes for getopt, with - differences in the consts, in stdlib.h. To avoid compilation - errors, only prototype getopt for the GNU C library. */ -extern int getopt(int argc, char *const *argv, const char *shortopts); + /* Many other libraries have conflicting prototypes for getopt, with + differences in the consts, in stdlib.h. To avoid compilation + errors, only prototype getopt for the GNU C library. */ + extern int getopt(int argc, char *const *argv, const char *shortopts); #else /* not __GNU_LIBRARY__ */ -extern int getopt(); + extern int getopt(); #endif /* __GNU_LIBRARY__ */ -extern int getopt_long(int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind); -extern int getopt_long_only(int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind); + extern int getopt_long(int argc, char *const *argv, const char *shortopts, + const struct option *longopts, int *longind); + extern int getopt_long_only(int argc, char *const *argv, + const char *shortopts, + const struct option *longopts, int *longind); -/* Internal only. Users should not call this directly. */ -extern int _getopt_internal(int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind, - int long_only); + /* Internal only. Users should not call this directly. */ + extern int _getopt_internal(int argc, char *const *argv, + const char *shortopts, + const struct option *longopts, int *longind, + int long_only); #else /* not __STDC__ */ -extern int getopt(); -extern int getopt_long(); -extern int getopt_long_only(); + extern int getopt(); + extern int getopt_long(); + extern int getopt_long_only(); -extern int _getopt_internal(); + extern int _getopt_internal(); #endif /* __STDC__ */ -#ifdef __cplusplus +#ifdef cplusplus } #endif diff --git a/src/graph.c b/src/graph.c index a774eac..c63fdf9 100644 --- a/src/graph.c +++ b/src/graph.c @@ -1,6 +1,6 @@ /* graph.c -- graph algorithms - Copyright (C) 2001-2017 Guus Sliepen , + Copyright (C) 2001-2014 Guus Sliepen , 2001-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -44,21 +44,22 @@ #include "system.h" +#include "avl_tree.h" +#include "conf.h" #include "connection.h" #include "device.h" #include "edge.h" #include "graph.h" -#include "list.h" #include "logger.h" -#include "names.h" #include "netutl.h" #include "node.h" +#include "process.h" #include "protocol.h" -#include "script.h" #include "subnet.h" #include "utils.h" #include "xalloc.h" -#include "graph.h" + +static bool graph_changed = true; /* Implementation of Kruskal's algorithm. Running time: O(EN) @@ -66,23 +67,42 @@ */ static void mst_kruskal(void) { + avl_node_t *node, *next; + edge_t *e; + node_t *n; + connection_t *c; + int nodes = 0; + int safe_edges = 0; + bool skipped; + /* Clear MST status on connections */ - for list_each(connection_t, c, connection_list) { + for(node = connection_tree->head; node; node = node->next) { + c = node->data; c->status.mst = false; } - logger(DEBUG_SCARY_THINGS, LOG_DEBUG, "Running Kruskal's algorithm:"); + /* Do we have something to do at all? */ + + if(!edge_weight_tree->head) { + return; + } + + ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Running Kruskal's algorithm:"); /* Clear visited status on nodes */ - for splay_each(node_t, n, node_tree) { + for(node = node_tree->head; node; node = node->next) { + n = node->data; n->status.visited = false; + nodes++; } /* Starting point */ - for splay_each(edge_t, e, edge_weight_tree) { + for(node = edge_weight_tree->head; node; node = node->next) { + e = node->data; + if(e->from->status.reachable) { e->from->status.visited = true; break; @@ -91,10 +111,11 @@ static void mst_kruskal(void) { /* Add safe edges */ - bool skipped = false; + for(skipped = false, node = edge_weight_tree->head; node; node = next) { + next = node->next; + e = node->data; - for splay_each(edge_t, e, edge_weight_tree) { - if(!e->reverse || (e->from->status.visited == e->to->status.visited)) { + if(!e->reverse || e->from->status.visited == e->to->status.visited) { skipped = true; continue; } @@ -110,13 +131,20 @@ static void mst_kruskal(void) { e->reverse->connection->status.mst = true; } - logger(DEBUG_SCARY_THINGS, LOG_DEBUG, " Adding edge %s - %s weight %d", e->from->name, e->to->name, e->weight); + safe_edges++; + + ifdebug(SCARY_THINGS) logger(LOG_DEBUG, " Adding edge %s - %s weight %d", e->from->name, + e->to->name, e->weight); if(skipped) { skipped = false; next = edge_weight_tree->head; + continue; } } + + ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Done, counted %d nodes and %d safe edges.", nodes, + safe_edges); } /* Implementation of a simple breadth-first search algorithm. @@ -124,14 +152,25 @@ static void mst_kruskal(void) { */ static void sssp_bfs(void) { - list_t *todo_list = list_alloc(NULL); + avl_node_t *node, *next, *to; + edge_t *e; + node_t *n; + list_t *todo_list; + list_node_t *from, *todonext; + bool indirect; + char *name; + char *address, *port; + char *envp[8] = {NULL}; + int i; + + todo_list = list_alloc(NULL); /* Clear visited status on nodes */ - for splay_each(node_t, n, node_tree) { + for(node = node_tree->head; node; node = node->next) { + n = node->data; n->status.visited = false; n->status.indirect = true; - n->distance = -1; } /* Begin with myself */ @@ -141,20 +180,17 @@ static void sssp_bfs(void) { myself->nexthop = myself; myself->prevedge = NULL; myself->via = myself; - myself->distance = 0; list_insert_head(todo_list, myself); /* Loop while todo_list is filled */ - for list_each(node_t, n, todo_list) { /* "n" is the node from which we start */ - logger(DEBUG_SCARY_THINGS, LOG_DEBUG, " Examining edges from %s", n->name); + for(from = todo_list->head; from; from = todonext) { /* "from" is the node from which we start */ + n = from->data; - if(n->distance < 0) { - abort(); - } + for(to = n->edge_tree->head; to; to = to->next) { /* "to" is the edge connected to "from" */ + e = to->data; - for splay_each(edge_t, e, n->edge_tree) { /* "e" is the edge connected to "from" */ - if(!e->reverse || e->to == myself) { + if(!e->reverse) { continue; } @@ -175,17 +211,16 @@ static void sssp_bfs(void) { of nodes behind it. */ - bool indirect = n->status.indirect || e->options & OPTION_INDIRECT; + indirect = n->status.indirect || e->options & OPTION_INDIRECT; if(e->to->status.visited - && (!e->to->status.indirect || indirect) - && (e->to->distance != n->distance + 1 || e->weight >= e->to->prevedge->weight)) { + && (!e->to->status.indirect || indirect)) { continue; } - // Only update nexthop if it doesn't increase the path length + // Only update nexthop the first time we visit this node. - if(!e->to->status.visited || (e->to->distance == n->distance + 1 && e->weight >= e->to->prevedge->weight)) { + if(!e->to->status.visited) { e->to->nexthop = (n->nexthop == myself) ? e->to : n->nexthop; } @@ -194,93 +229,74 @@ static void sssp_bfs(void) { e->to->prevedge = e; e->to->via = indirect ? n->via : e->to; e->to->options = e->options; - e->to->distance = n->distance + 1; - if(!e->to->status.reachable || (e->to->address.sa.sa_family == AF_UNSPEC && e->address.sa.sa_family != AF_UNKNOWN)) { + if(e->to->address.sa.sa_family == AF_UNSPEC && e->address.sa.sa_family != AF_UNKNOWN) { update_node_udp(e->to, &e->address); } list_insert_tail(todo_list, e->to); } - next = node->next; /* Because the list_insert_tail() above could have added something extra for us! */ - list_delete_node(todo_list, node); + todonext = from->next; + list_delete_node(todo_list, from); } list_free(todo_list); -} -static void check_reachability(void) { /* Check reachability status. */ - int reachable_count = 0; - int became_reachable_count = 0; - int became_unreachable_count = 0; + for(node = node_tree->head; node; node = next) { + next = node->next; + n = node->data; - for splay_each(node_t, n, node_tree) { if(n->status.visited != n->status.reachable) { n->status.reachable = !n->status.reachable; - n->last_state_change = now.tv_sec; if(n->status.reachable) { - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Node %s (%s) became reachable", - n->name, n->hostname); - - if(n != myself) { - became_reachable_count++; - } + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Node %s (%s) became reachable", + n->name, n->hostname); } else { - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Node %s (%s) became unreachable", - n->name, n->hostname); - - if(n != myself) { - became_unreachable_count++; - } - } - - if(experimental && OPTION_VERSION(n->options) >= 2) { - n->status.sptps = true; + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Node %s (%s) became unreachable", + n->name, n->hostname); } /* TODO: only clear status.validkey if node is unreachable? */ n->status.validkey = false; - - if(n->status.sptps) { - sptps_stop(&n->sptps); - n->status.waitingforkey = false; - } - n->last_req_key = 0; - n->status.udp_confirmed = false; n->maxmtu = MTU; - n->maxrecentlen = 0; n->minmtu = 0; n->mtuprobes = 0; - timeout_del(&n->udp_ping_timeout); + if(n->mtuevent) { + event_del(n->mtuevent); + n->mtuevent = NULL; + } - char *name; - char *address; - char *port; - - environment_t env; - environment_init(&env); - environment_add(&env, "NODE=%s", n->name); + xasprintf(&envp[0], "NETNAME=%s", netname ? netname : ""); + xasprintf(&envp[1], "DEVICE=%s", device ? device : ""); + xasprintf(&envp[2], "INTERFACE=%s", iface ? iface : ""); + xasprintf(&envp[3], "NODE=%s", n->name); sockaddr2str(&n->address, &address, &port); - environment_add(&env, "REMOTEADDRESS=%s", address); - environment_add(&env, "REMOTEPORT=%s", port); + xasprintf(&envp[4], "REMOTEADDRESS=%s", address); + xasprintf(&envp[5], "REMOTEPORT=%s", port); + xasprintf(&envp[6], "NAME=%s", myself->name); - execute_script(n->status.reachable ? "host-up" : "host-down", &env); + execute_script(n->status.reachable ? "host-up" : "host-down", envp); - xasprintf(&name, n->status.reachable ? "hosts/%s-up" : "hosts/%s-down", n->name); - execute_script(name, &env); + xasprintf(&name, + n->status.reachable ? "hosts/%s-up" : "hosts/%s-down", + n->name); + execute_script(name, envp); free(name); free(address); free(port); - environment_exit(&env); + + for(i = 0; i < 7; i++) { + free(envp[i]); + } subnet_update(n, NULL, n->status.reachable); @@ -289,30 +305,86 @@ static void check_reachability(void) { memset(&n->status, 0, sizeof(n->status)); n->options = 0; } else if(n->connection) { - // Speed up UDP probing by sending our key. - if(!n->status.sptps) { - send_ans_key(n); - } + send_ans_key(n); } } - - if(n->status.reachable && n != myself) { - reachable_count++; - } - } - - if(device_standby) { - if(reachable_count == 0 && became_unreachable_count > 0) { - device_disable(); - } else if(reachable_count > 0 && reachable_count == became_reachable_count) { - device_enable(); - } } } void graph(void) { subnet_cache_flush(); sssp_bfs(); - check_reachability(); mst_kruskal(); + graph_changed = true; +} + + + +/* Dump nodes and edges to a graphviz file. + + The file can be converted to an image with + dot -Tpng graph_filename -o image_filename.png -Gconcentrate=true +*/ + +void dump_graph(void) { + avl_node_t *node; + node_t *n; + edge_t *e; + char *filename = NULL, *tmpname = NULL; + FILE *file, *pipe = NULL; + + if(!graph_changed || !get_config_string(lookup_config(config_tree, "GraphDumpFile"), &filename)) { + return; + } + + graph_changed = false; + + ifdebug(PROTOCOL) logger(LOG_NOTICE, "Dumping graph"); + + if(filename[0] == '|') { + file = pipe = popen(filename + 1, "w"); + } else { + xasprintf(&tmpname, "%s.new", filename); + file = fopen(tmpname, "w"); + } + + if(!file) { + logger(LOG_ERR, "Unable to open graph dump file %s: %s", filename, strerror(errno)); + free(filename); + free(tmpname); + return; + } + + fprintf(file, "digraph {\n"); + + /* dump all nodes first */ + for(node = node_tree->head; node; node = node->next) { + n = node->data; + fprintf(file, " \"%s\" [label = \"%s\"];\n", n->name, n->name); + } + + /* now dump all edges */ + for(node = edge_weight_tree->head; node; node = node->next) { + e = node->data; + fprintf(file, " \"%s\" -> \"%s\";\n", e->from->name, e->to->name); + } + + fprintf(file, "}\n"); + + if(pipe) { + pclose(pipe); + } else { + fclose(file); +#ifdef HAVE_MINGW + unlink(filename); +#endif + + if(rename(tmpname, filename)) { + logger(LOG_ERR, "Could not rename %s to %s: %s\n", tmpname, filename, strerror(errno)); + } + + free(tmpname); + } + + free(filename); } diff --git a/src/hash.c b/src/hash.c deleted file mode 100644 index 63b8f54..0000000 --- a/src/hash.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - hash.c -- hash table management - Copyright (C) 2012-2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include "hash.h" -#include "xalloc.h" - -/* Generic hash function */ - -static uint32_t hash_function(const void *p, size_t len) { - const uint8_t *q = p; - uint32_t hash = 0; - - while(true) { - for(int i = len > 4 ? 4 : len; --i;) { - hash += (uint32_t)q[len - i] << (8 * i); - } - - hash *= 0x9e370001UL; // Golden ratio prime. - - if(len <= 4) { - break; - } - - len -= 4; - } - - return hash; -} - -/* Map 32 bits int onto 0..n-1, without throwing away too many bits if n is 2^8 or 2^16 */ - -static uint32_t modulo(uint32_t hash, size_t n) { - if(n == 0x100) { - return (hash >> 24) ^ ((hash >> 16) & 0xff) ^ ((hash >> 8) & 0xff) ^ (hash & 0xff); - } else if(n == 0x10000) { - return (hash >> 16) ^ (hash & 0xffff); - } else { - return hash % n; - } -} - -/* (De)allocation */ - -hash_t *hash_alloc(size_t n, size_t size) { - hash_t *hash = xzalloc(sizeof(*hash)); - hash->n = n; - hash->size = size; - hash->keys = xzalloc(hash->n * hash->size); - hash->values = xzalloc(hash->n * sizeof(*hash->values)); - return hash; -} - -void hash_free(hash_t *hash) { - free(hash->keys); - free(hash->values); - free(hash); -} - -/* Searching and inserting */ - -void hash_insert(hash_t *hash, const void *key, const void *value) { - uint32_t i = modulo(hash_function(key, hash->size), hash->n); - memcpy(hash->keys + i * hash->size, key, hash->size); - hash->values[i] = value; -} - -void *hash_search(const hash_t *hash, const void *key) { - uint32_t i = modulo(hash_function(key, hash->size), hash->n); - - if(hash->values[i] && !memcmp(key, hash->keys + i * hash->size, hash->size)) { - return (void *)hash->values[i]; - } - - return NULL; -} - -void *hash_search_or_insert(hash_t *hash, const void *key, const void *value) { - uint32_t i = modulo(hash_function(key, hash->size), hash->n); - - if(hash->values[i] && !memcmp(key, hash->keys + i * hash->size, hash->size)) { - return (void *)hash->values[i]; - } - - memcpy(hash->keys + i * hash->size, key, hash->size); - hash->values[i] = value; - return NULL; -} - -/* Deleting */ - -void hash_delete(hash_t *hash, const void *key) { - uint32_t i = modulo(hash_function(key, hash->size), hash->n); - hash->values[i] = NULL; -} - -/* Utility functions */ - -void hash_clear(hash_t *hash) { - memset(hash->values, 0, hash->n * sizeof(*hash->values)); -} - -void hash_resize(hash_t *hash, size_t n) { - hash->keys = xrealloc(hash->keys, n * hash->size); - hash->values = xrealloc(hash->values, n * sizeof(*hash->values)); - - if(n > hash->n) { - memset(hash->keys + hash->n * hash->size, 0, (n - hash->n) * hash->size); - memset(hash->values + hash->n, 0, (n - hash->n) * sizeof(*hash->values)); - } -} diff --git a/src/hash.h b/src/hash.h deleted file mode 100644 index e4b1499..0000000 --- a/src/hash.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef TINC_HASH_H -#define TINC_HASH_H - -/* - hash.h -- header file for hash.c - Copyright (C) 2012 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -typedef struct hash_t { - size_t n; - size_t size; - char *keys; - const void **values; -} hash_t; - -extern hash_t *hash_alloc(size_t n, size_t size) __attribute__((__malloc__)); -extern void hash_free(hash_t *); - -extern void hash_insert(hash_t *, const void *key, const void *value); -extern void hash_delete(hash_t *, const void *key); - -extern void *hash_search(const hash_t *, const void *key); -extern void *hash_search_or_insert(hash_t *, const void *key, const void *value); - -extern void hash_clear(hash_t *); -extern void hash_resize(hash_t *, size_t n); - -#endif diff --git a/src/have.h b/src/have.h index 402f802..11fa56a 100644 --- a/src/have.h +++ b/src/have.h @@ -4,7 +4,7 @@ /* have.h -- include headers which are known to exist Copyright (C) 1998-2005 Ivo Timmermans - 2003-2016 Guus Sliepen + 2003-2015 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,23 +22,27 @@ */ #ifdef HAVE_MINGW +#ifdef WITH_WINDOWS2000 +#define WINVER Windows2000 +#else #define WINVER WindowsXP -#define WIN32_LEAN_AND_MEAN +#endif #endif #include +#include +#include +#include #include #include -#include #include #include -#include #include +#include + #include #include -#include -#include -#include +#include #ifdef HAVE_MINGW #include @@ -47,12 +51,16 @@ #include #endif +#ifdef HAVE_STDBOOL_H +#include +#endif + #ifdef HAVE_TERMIOS_H #include #endif -#ifdef HAVE_INTTYPES_H -#include +#ifdef HAVE_ALLOCA_H +#include #endif /* Include system specific headers */ @@ -65,6 +73,9 @@ #include #endif +#ifdef HAVE_TIME_H +#include +#endif #ifdef HAVE_SYS_TYPES_H #include @@ -94,8 +105,8 @@ #include #endif -#ifdef HAVE_SYS_UN_H -#include +#ifdef HAVE_SYS_UIO_H +#include #endif #ifdef HAVE_DIRENT_H @@ -187,6 +198,9 @@ #ifdef HAVE_ARPA_NAMESER_H #include +#ifdef STATUS +#undef STATUS +#endif #endif #ifdef HAVE_RESOLV_H @@ -197,20 +211,4 @@ #include #endif -#ifdef HAVE_GETOPT_H -#include -#else -#include "getopt.h" -#endif - -#ifdef STATUS -#undef STATUS -#endif - -#ifdef HAVE_MINGW -#define SLASH "\\" -#else -#define SLASH "/" -#endif - #endif diff --git a/src/ifconfig.c b/src/ifconfig.c deleted file mode 100644 index 4b47ad1..0000000 --- a/src/ifconfig.c +++ /dev/null @@ -1,304 +0,0 @@ -/* - ifconfig.c -- Generate platform specific interface configuration commands - Copyright (C) 2016-2017 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include "conf.h" -#include "ifconfig.h" -#include "subnet.h" - -static long start; - -#ifndef HAVE_MINGW -void ifconfig_header(FILE *out) { - fprintf(out, "#!/bin/sh\n"); - start = ftell(out); -} - -void ifconfig_dhcp(FILE *out) { - fprintf(out, "dhclient -nw \"$INTERFACE\"\n"); -} - -void ifconfig_dhcp6(FILE *out) { - fprintf(out, "dhclient -6 -nw \"$INTERFACE\"\n"); -} - -void ifconfig_slaac(FILE *out) { -#ifdef HAVE_LINUX - fprintf(out, "echo 1 >\"/proc/sys/net/ipv6/conf/$INTERFACE/accept_ra\"\n"); - fprintf(out, "echo 1 >\"/proc/sys/net/ipv6/conf/$INTERFACE/autoconf\"\n"); -#else - fprintf(out, "rtsol \"$INTERFACE\" &\n"); -#endif -} - -bool ifconfig_footer(FILE *out) { - if(ftell(out) == start) { - fprintf(out, "echo 'Unconfigured tinc-up script, please edit '$0'!'\n\n#ifconfig $INTERFACE netmask \n"); - return false; - } else { -#ifdef HAVE_LINUX - fprintf(out, "ip link set \"$INTERFACE\" up\n"); -#else - fprintf(out, "ifconfig \"$INTERFACE\" up\n"); -#endif - return true; - } -} -#else -void ifconfig_header(FILE *out) { - start = ftell(out); -} - -void ifconfig_dhcp(FILE *out) { - fprintf(out, "netsh interface ipv4 set address \"%%INTERFACE%%\" dhcp\n"); -} - -void ifconfig_dhcp6(FILE *out) { - fprintf(stderr, "DHCPv6 requested, but not supported by tinc on this platform\n"); -} - -void ifconfig_slaac(FILE *out) { - // It's the default? -} - -bool ifconfig_footer(FILE *out) { - return ftell(out) != start; -} -#endif - -static subnet_t ipv4, ipv6; - -void ifconfig_address(FILE *out, const char *value) { - subnet_t address = {0}; - char address_str[MAXNETSTR]; - - if(!str2net(&address, value) || !net2str(address_str, sizeof(address_str), &address)) { - fprintf(stderr, "Could not parse address in Ifconfig statement\n"); - return; - } - - switch(address.type) { - case SUBNET_IPV4: - ipv4 = address; - break; - - case SUBNET_IPV6: - ipv6 = address; - break; - - default: - return; - } - -#if defined(HAVE_LINUX) - - switch(address.type) { - case SUBNET_MAC: - fprintf(out, "ip link set \"$INTERFACE\" address %s\n", address_str); - break; - - case SUBNET_IPV4: - fprintf(out, "ip addr replace %s dev \"$INTERFACE\"\n", address_str); - break; - - case SUBNET_IPV6: - fprintf(out, "ip addr replace %s dev \"$INTERFACE\"\n", address_str); - break; - - default: - return; - } - -#elif defined(HAVE_MINGW) || defined(HAVE_CYGWIN) - - switch(address.type) { - case SUBNET_MAC: - fprintf(out, "ip link set \"$INTERFACE\" address %s\n", address_str); - break; - - case SUBNET_IPV4: - fprintf(out, "netsh inetface ipv4 set address \"$INTERFACE\" static %s\n", address_str); - break; - - case SUBNET_IPV6: - fprintf(out, "netsh inetface ipv6 set address \"$INTERFACE\" static %s\n", address_str); - break; - - default: - return; - } - -#else // assume BSD - - switch(address.type) { - case SUBNET_MAC: - fprintf(out, "ifconfig \"$INTERFACE\" link %s\n", address_str); - break; - - case SUBNET_IPV4: - fprintf(out, "ifconfig \"$INTERFACE\" %s\n", address_str); - break; - - case SUBNET_IPV6: - fprintf(out, "ifconfig \"$INTERFACE\" inet6 %s\n", address_str); - break; - - default: - return; - } - -#endif -} - -void ifconfig_route(FILE *out, const char *value) { - subnet_t subnet = {0}, gateway = {0}; - char subnet_str[MAXNETSTR] = "", gateway_str[MAXNETSTR] = ""; - char *sep = strchr(value, ' '); - - if(sep) { - *sep++ = 0; - } - - if(!str2net(&subnet, value) || !net2str(subnet_str, sizeof(subnet_str), &subnet) || subnet.type == SUBNET_MAC) { - fprintf(stderr, "Could not parse subnet in Route statement\n"); - return; - } - - if(sep) { - if(!str2net(&gateway, sep) || !net2str(gateway_str, sizeof(gateway_str), &gateway) || gateway.type != subnet.type) { - fprintf(stderr, "Could not parse gateway in Route statement\n"); - return; - } - - char *slash = strchr(gateway_str, '/'); - - if(slash) { - *slash = 0; - } - } - -#if defined(HAVE_LINUX) - - if(*gateway_str) { - switch(subnet.type) { - case SUBNET_IPV4: - fprintf(out, "ip route add %s via %s dev \"$INTERFACE\"\n", subnet_str, gateway_str); - break; - - case SUBNET_IPV6: - fprintf(out, "ip route add %s via %s dev \"$INTERFACE\"\n", subnet_str, gateway_str); - break; - - default: - return; - } - } else { - switch(subnet.type) { - case SUBNET_IPV4: - fprintf(out, "ip route add %s dev \"$INTERFACE\"\n", subnet_str); - break; - - case SUBNET_IPV6: - fprintf(out, "ip route add %s dev \"$INTERFACE\"\n", subnet_str); - break; - - default: - return; - } - } - -#elif defined(HAVE_MINGW) || defined(HAVE_CYGWIN) - - if(*gateway_str) { - switch(subnet.type) { - case SUBNET_IPV4: - fprintf(out, "netsh inetface ipv4 add route %s \"%%INTERFACE%%\" %s\n", subnet_str, gateway_str); - break; - - case SUBNET_IPV6: - fprintf(out, "netsh inetface ipv6 add route %s \"%%INTERFACE%%\" %s\n", subnet_str, gateway_str); - break; - - default: - return; - } - } else { - switch(subnet.type) { - case SUBNET_IPV4: - fprintf(out, "netsh inetface ipv4 add route %s \"%%INTERFACE%%\"\n", subnet_str); - break; - - case SUBNET_IPV6: - fprintf(out, "netsh inetface ipv6 add route %s \"%%INTERFACE%%\"\n", subnet_str); - break; - - default: - return; - } - } - -#else // assume BSD - - if(!*gateway_str) { - switch(subnet.type) { - case SUBNET_IPV4: - if(!ipv4.type) { - fprintf(stderr, "Route requested but no Ifconfig\n"); - return; - } - - net2str(gateway_str, sizeof(gateway_str), &ipv4); - break; - - case SUBNET_IPV6: - if(!ipv6.type) { - fprintf(stderr, "Route requested but no Ifconfig\n"); - return; - } - - net2str(gateway_str, sizeof(gateway_str), &ipv6); - break; - - default: - return; - } - - char *slash = strchr(gateway_str, '/'); - - if(slash) { - *slash = 0; - } - } - - switch(subnet.type) { - case SUBNET_IPV4: - fprintf(out, "route add %s %s\n", subnet_str, gateway_str); - break; - - case SUBNET_IPV6: - fprintf(out, "route add -inet6 %s %s\n", subnet_str, gateway_str); - break; - - default: - return; - } - -#endif -} diff --git a/src/ifconfig.h b/src/ifconfig.h deleted file mode 100644 index 854780b..0000000 --- a/src/ifconfig.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef TINC_IFCONFIG_H -#define TINC_IFCONFIG_H - -/* - ifconfig.h -- header for ifconfig.c. - Copyright (C) 2016 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -extern void ifconfig_dhcp(FILE *out); -extern void ifconfig_dhcp6(FILE *out); -extern void ifconfig_slaac(FILE *out); -extern void ifconfig_address(FILE *out, const char *value); -extern void ifconfig_route(FILE *out, const char *value); -extern void ifconfig_header(FILE *out); -extern bool ifconfig_footer(FILE *out); - -#endif diff --git a/src/info.c b/src/info.c deleted file mode 100644 index 758c0d1..0000000 --- a/src/info.c +++ /dev/null @@ -1,357 +0,0 @@ -/* - info.c -- Show information about a node, subnet or address - Copyright (C) 2012-2017 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include "control_common.h" -#include "list.h" -#include "subnet.h" -#include "tincctl.h" -#include "info.h" -#include "utils.h" -#include "xalloc.h" - -void logger(int level, int priority, const char *format, ...) { - (void)level; - (void)priority; - va_list ap; - - va_start(ap, format); - vfprintf(stderr, format, ap); - va_end(ap); - - fputc('\n', stderr); -} - -char *strip_weight(char *netstr) { - int len = strlen(netstr); - - if(len >= 3 && !strcmp(netstr + len - 3, "#10")) { - netstr[len - 3] = 0; - } - - return netstr; -} - -static int info_node(int fd, const char *item) { - // Check the list of nodes - sendline(fd, "%d %d %s", CONTROL, REQ_DUMP_NODES, item); - - bool found = false; - char line[4096]; - - char node[4096]; - char id[4096]; - char from[4096]; - char to[4096]; - char subnet[4096]; - char host[4096]; - char port[4096]; - char via[4096]; - char nexthop[4096]; - int code, req, cipher, digest, maclength, compression, distance; - short int pmtu, minmtu, maxmtu; - unsigned int options; - union { - node_status_t bits; - uint32_t raw; - } status_union; - node_status_t status; - long int last_state_change; - int udp_ping_rtt; - uint64_t in_packets, in_bytes, out_packets, out_bytes; - - while(recvline(fd, line, sizeof(line))) { - int n = sscanf(line, "%d %d %4095s %4095s %4095s port %4095s %d %d %d %d %x %"PRIx32" %4095s %4095s %d %hd %hd %hd %ld %d %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64, &code, &req, node, id, host, port, &cipher, &digest, &maclength, &compression, &options, &status_union.raw, nexthop, via, &distance, &pmtu, &minmtu, &maxmtu, &last_state_change, &udp_ping_rtt, &in_packets, &in_bytes, &out_packets, &out_bytes); - - if(n == 2) { - break; - } - - if(n != 24) { - fprintf(stderr, "Unable to parse node dump from tincd.\n"); - return 1; - } - - if(!strcmp(node, item)) { - found = true; - break; - } - } - - if(!found) { - fprintf(stderr, "Unknown node %s.\n", item); - return 1; - } - - while(recvline(fd, line, sizeof(line))) { - if(sscanf(line, "%d %d %4095s", &code, &req, node) == 2) { - break; - } - } - - printf("Node: %s\n", item); - printf("Node ID: %s\n", id); - printf("Address: %s port %s\n", host, port); - - char timestr[32] = "never"; - time_t lsc_time = last_state_change; - - if(last_state_change) { - strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S", localtime(&lsc_time)); - } - - status = status_union.bits; - - if(status.reachable) { - printf("Online since: %s\n", timestr); - } else { - printf("Last seen: %s\n", timestr); - } - - printf("Status: "); - - if(status.validkey) { - printf(" validkey"); - } - - if(status.visited) { - printf(" visited"); - } - - if(status.reachable) { - printf(" reachable"); - } - - if(status.indirect) { - printf(" indirect"); - } - - if(status.sptps) { - printf(" sptps"); - } - - if(status.udp_confirmed) { - printf(" udp_confirmed"); - } - - printf("\n"); - - printf("Options: "); - - if(options & OPTION_INDIRECT) { - printf(" indirect"); - } - - if(options & OPTION_TCPONLY) { - printf(" tcponly"); - } - - if(options & OPTION_PMTU_DISCOVERY) { - printf(" pmtu_discovery"); - } - - if(options & OPTION_CLAMP_MSS) { - printf(" clamp_mss"); - } - - printf("\n"); - printf("Protocol: %d.%d\n", PROT_MAJOR, OPTION_VERSION(options)); - printf("Reachability: "); - - if(!strcmp(host, "MYSELF")) { - printf("can reach itself\n"); - } else if(!status.reachable) { - printf("unreachable\n"); - } else if(strcmp(via, item)) { - printf("indirectly via %s\n", via); - } else if(!status.validkey) { - printf("unknown\n"); - } else if(minmtu > 0) { - printf("directly with UDP\nPMTU: %d\n", pmtu); - - if(udp_ping_rtt != -1) { - printf("RTT: %d.%03d\n", udp_ping_rtt / 1000, udp_ping_rtt % 1000); - } - } else if(!strcmp(nexthop, item)) { - printf("directly with TCP\n"); - } else { - printf("none, forwarded via %s\n", nexthop); - } - - printf("RX: %"PRIu64" packets %"PRIu64" bytes\n", in_packets, in_bytes); - printf("TX: %"PRIu64" packets %"PRIu64" bytes\n", out_packets, out_bytes); - - // List edges - printf("Edges: "); - sendline(fd, "%d %d %s", CONTROL, REQ_DUMP_EDGES, item); - - while(recvline(fd, line, sizeof(line))) { - int n = sscanf(line, "%d %d %4095s %4095s", &code, &req, from, to); - - if(n == 2) { - break; - } - - if(n != 4) { - fprintf(stderr, "Unable to parse edge dump from tincd.\n%s\n", line); - return 1; - } - - if(!strcmp(from, item)) { - printf(" %s", to); - } - } - - printf("\n"); - - // List subnets - printf("Subnets: "); - sendline(fd, "%d %d %s", CONTROL, REQ_DUMP_SUBNETS, item); - - while(recvline(fd, line, sizeof(line))) { - int n = sscanf(line, "%d %d %4095s %4095s", &code, &req, subnet, from); - - if(n == 2) { - break; - } - - if(n != 4) { - fprintf(stderr, "Unable to parse subnet dump from tincd.\n"); - return 1; - } - - if(!strcmp(from, item)) { - printf(" %s", strip_weight(subnet)); - } - } - - printf("\n"); - - return 0; -} - -static int info_subnet(int fd, const char *item) { - subnet_t subnet, find; - - if(!str2net(&find, item)) { - fprintf(stderr, "Could not parse subnet or address '%s'.\n", item); - return 1; - } - - bool address = !strchr(item, '/'); - bool weight = strchr(item, '#'); - bool found = false; - - char line[4096]; - char netstr[4096]; - char owner[4096]; - - int code, req; - - sendline(fd, "%d %d %s", CONTROL, REQ_DUMP_SUBNETS, item); - - while(recvline(fd, line, sizeof(line))) { - int n = sscanf(line, "%d %d %4095s %4095s", &code, &req, netstr, owner); - - if(n == 2) { - break; - } - - if(n != 4 || !str2net(&subnet, netstr)) { - fprintf(stderr, "Unable to parse subnet dump from tincd.\n"); - return 1; - } - - if(find.type != subnet.type) { - continue; - } - - if(weight) { - if(find.weight != subnet.weight) { - continue; - } - } - - if(find.type == SUBNET_IPV4) { - if(address) { - if(maskcmp(&find.net.ipv4.address, &subnet.net.ipv4.address, subnet.net.ipv4.prefixlength)) { - continue; - } - } else { - if(find.net.ipv4.prefixlength != subnet.net.ipv4.prefixlength) { - continue; - } - - if(memcmp(&find.net.ipv4.address, &subnet.net.ipv4.address, sizeof(subnet.net.ipv4))) { - continue; - } - } - } else if(find.type == SUBNET_IPV6) { - if(address) { - if(maskcmp(&find.net.ipv6.address, &subnet.net.ipv6.address, subnet.net.ipv6.prefixlength)) { - continue; - } - } else { - if(find.net.ipv6.prefixlength != subnet.net.ipv6.prefixlength) { - continue; - } - - if(memcmp(&find.net.ipv6.address, &subnet.net.ipv6.address, sizeof(subnet.net.ipv6))) { - continue; - } - } - } - - if(find.type == SUBNET_MAC) { - if(memcmp(&find.net.mac.address, &subnet.net.mac.address, sizeof(subnet.net.mac))) { - continue; - } - } - - found = true; - printf("Subnet: %s\n", strip_weight(netstr)); - printf("Owner: %s\n", owner); - } - - if(!found) { - if(address) { - fprintf(stderr, "Unknown address %s.\n", item); - } else { - fprintf(stderr, "Unknown subnet %s.\n", item); - } - - return 1; - } - - return 0; -} - -int info(int fd, const char *item) { - if(check_id(item)) { - return info_node(fd, item); - } - - if(strchr(item, '.') || strchr(item, ':')) { - return info_subnet(fd, item); - } - - fprintf(stderr, "Argument is not a node name, subnet or address.\n"); - return 1; -} diff --git a/src/info.h b/src/info.h deleted file mode 100644 index 1b323e0..0000000 --- a/src/info.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef TINC_INFO_H -#define TINC_INFO_H - -/* - info.h -- header for info.c. - Copyright (C) 2012 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -extern int info(int fd, const char *item); -extern char *strip_weight(char *); - -#endif diff --git a/src/invitation.c b/src/invitation.c deleted file mode 100644 index 500f243..0000000 --- a/src/invitation.c +++ /dev/null @@ -1,1351 +0,0 @@ -/* - invitation.c -- Create and accept invitations - Copyright (C) 2013-2017 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include "control_common.h" -#include "crypto.h" -#include "ecdsa.h" -#include "ecdsagen.h" -#include "ifconfig.h" -#include "invitation.h" -#include "names.h" -#include "netutl.h" -#include "rsagen.h" -#include "script.h" -#include "sptps.h" -#include "subnet.h" -#include "tincctl.h" -#include "utils.h" -#include "xalloc.h" - -#include "ed25519/sha512.h" - -int addressfamily = AF_UNSPEC; - -static void scan_for_hostname(const char *filename, char **hostname, char **port) { - if(!filename || (*hostname && *port)) { - return; - } - - FILE *f = fopen(filename, "r"); - - if(!f) { - return; - } - - while(fgets(line, sizeof(line), f)) { - if(!rstrip(line)) { - continue; - } - - char *p = line, *q; - p += strcspn(p, "\t ="); - - if(!*p) { - continue; - } - - q = p + strspn(p, "\t "); - - if(*q == '=') { - q += 1 + strspn(q + 1, "\t "); - } - - *p = 0; - p = q + strcspn(q, "\t "); - - if(*p) { - *p++ = 0; - } - - p += strspn(p, "\t "); - p[strcspn(p, "\t ")] = 0; - - if(!*port && !strcasecmp(line, "Port")) { - *port = xstrdup(q); - } else if(!*hostname && !strcasecmp(line, "Address")) { - *hostname = xstrdup(q); - - if(*p) { - free(*port); - *port = xstrdup(p); - } - } - - if(*hostname && *port) { - break; - } - } - - fclose(f); -} - -char *get_my_hostname() { - char *hostname = NULL; - char *port = NULL; - char *hostport = NULL; - char *name = get_my_name(false); - char filename[PATH_MAX] = {0}; - - // Use first Address statement in own host config file - if(check_id(name)) { - snprintf(filename, sizeof(filename), "%s" SLASH "hosts" SLASH "%s", confbase, name); - scan_for_hostname(filename, &hostname, &port); - scan_for_hostname(tinc_conf, &hostname, &port); - } - - if(hostname) { - goto done; - } - - // If that doesn't work, guess externally visible hostname - fprintf(stderr, "Trying to discover externally visible hostname...\n"); - struct addrinfo *ai = str2addrinfo("tinc-vpn.org", "80", SOCK_STREAM); - struct addrinfo *aip = ai; - static const char request[] = "GET http://tinc-vpn.org/host.cgi HTTP/1.0\r\n\r\n"; - - while(aip) { - int s = socket(aip->ai_family, aip->ai_socktype, aip->ai_protocol); - - if(s >= 0) { - if(connect(s, aip->ai_addr, aip->ai_addrlen)) { - closesocket(s); - s = -1; - } - } - - if(s >= 0) { - send(s, request, sizeof(request) - 1, 0); - int len = recv(s, line, sizeof(line) - 1, MSG_WAITALL); - - if(len > 0) { - line[len] = 0; - - if(line[len - 1] == '\n') { - line[--len] = 0; - } - - char *p = strrchr(line, '\n'); - - if(p && p[1]) { - hostname = xstrdup(p + 1); - } - } - - closesocket(s); - - if(hostname) { - break; - } - } - - aip = aip->ai_next; - continue; - } - - if(ai) { - freeaddrinfo(ai); - } - - // Check that the hostname is reasonable - if(hostname) { - for(char *p = hostname; *p; p++) { - if(isalnum(*p) || *p == '-' || *p == '.' || *p == ':') { - continue; - } - - // If not, forget it. - free(hostname); - hostname = NULL; - break; - } - } - - if(!tty) { - if(!hostname) { - fprintf(stderr, "Could not determine the external address or hostname. Please set Address manually.\n"); - free(port); - return NULL; - } - - goto save; - } - -again: - fprintf(stderr, "Please enter your host's external address or hostname"); - - if(hostname) { - fprintf(stderr, " [%s]", hostname); - } - - fprintf(stderr, ": "); - - if(!fgets(line, sizeof(line), stdin)) { - fprintf(stderr, "Error while reading stdin: %s\n", strerror(errno)); - free(hostname); - free(port); - return NULL; - } - - if(!rstrip(line)) { - if(hostname) { - goto save; - } else { - goto again; - } - } - - for(char *p = line; *p; p++) { - if(isalnum(*p) || *p == '-' || *p == '.') { - continue; - } - - fprintf(stderr, "Invalid address or hostname.\n"); - goto again; - } - - free(hostname); - hostname = xstrdup(line); - -save: - - if(*filename) { - FILE *f = fopen(filename, "a"); - - if(f) { - fprintf(f, "\nAddress = %s\n", hostname); - fclose(f); - } else { - fprintf(stderr, "Could not append Address to %s: %s\n", filename, strerror(errno)); - } - } - -done: - - if(port) { - if(strchr(hostname, ':')) { - xasprintf(&hostport, "[%s]:%s", hostname, port); - } else { - xasprintf(&hostport, "%s:%s", hostname, port); - } - } else { - if(strchr(hostname, ':')) { - xasprintf(&hostport, "[%s]", hostname); - } else { - hostport = xstrdup(hostname); - } - } - - free(hostname); - free(port); - return hostport; -} - -static bool fcopy(FILE *out, const char *filename) { - FILE *in = fopen(filename, "r"); - - if(!in) { - fprintf(stderr, "Could not open %s: %s\n", filename, strerror(errno)); - return false; - } - - char buf[1024]; - size_t len; - - while((len = fread(buf, 1, sizeof(buf), in))) { - fwrite(buf, len, 1, out); - } - - fclose(in); - return true; -} - -int cmd_invite(int argc, char *argv[]) { - if(argc < 2) { - fprintf(stderr, "Not enough arguments!\n"); - return 1; - } - - // Check validity of the new node's name - if(!check_id(argv[1])) { - fprintf(stderr, "Invalid name for node.\n"); - return 1; - } - - myname = get_my_name(true); - - if(!myname) { - return 1; - } - - // Ensure no host configuration file with that name exists - char filename[PATH_MAX]; - snprintf(filename, sizeof(filename), "%s" SLASH "hosts" SLASH "%s", confbase, argv[1]); - - if(!access(filename, F_OK)) { - fprintf(stderr, "A host config file for %s already exists!\n", argv[1]); - return 1; - } - - // If a daemon is running, ensure no other nodes know about this name - if(connect_tincd(false)) { - bool found = false; - sendline(fd, "%d %d", CONTROL, REQ_DUMP_NODES); - - while(recvline(fd, line, sizeof(line))) { - char node[4096]; - int code, req; - - if(sscanf(line, "%d %d %4095s", &code, &req, node) != 3) { - break; - } - - if(!strcmp(node, argv[1])) { - found = true; - } - } - - if(found) { - fprintf(stderr, "A node with name %s is already known!\n", argv[1]); - return 1; - } - } - - snprintf(filename, sizeof(filename), "%s" SLASH "invitations", confbase); - - if(mkdir(filename, 0700) && errno != EEXIST) { - fprintf(stderr, "Could not create directory %s: %s\n", filename, strerror(errno)); - return 1; - } - - // Count the number of valid invitations, clean up old ones - DIR *dir = opendir(filename); - - if(!dir) { - fprintf(stderr, "Could not read directory %s: %s\n", filename, strerror(errno)); - return 1; - } - - errno = 0; - int count = 0; - struct dirent *ent; - time_t deadline = time(NULL) - 604800; // 1 week in the past - - while((ent = readdir(dir))) { - if(strlen(ent->d_name) != 24) { - continue; - } - - char invname[PATH_MAX]; - struct stat st; - - if((size_t)snprintf(invname, sizeof(invname), "%s" SLASH "%s", filename, ent->d_name) >= sizeof(invname)) { - fprintf(stderr, "Filename too long: %s" SLASH "%s\n", filename, ent->d_name); - continue; - } - - if(!stat(invname, &st)) { - if(deadline < st.st_mtime) { - count++; - } else { - unlink(invname); - } - } else { - fprintf(stderr, "Could not stat %s: %s\n", invname, strerror(errno)); - errno = 0; - } - } - - closedir(dir); - - if(errno) { - fprintf(stderr, "Error while reading directory %s: %s\n", filename, strerror(errno)); - return 1; - } - - ecdsa_t *key; - snprintf(filename, sizeof(filename), "%s" SLASH "invitations" SLASH "ed25519_key.priv", confbase); - - // Remove the key if there are no outstanding invitations. - if(!count) { - unlink(filename); - } - - // Create a new key if necessary. - FILE *f = fopen(filename, "r"); - - if(!f) { - if(errno != ENOENT) { - fprintf(stderr, "Could not read %s: %s\n", filename, strerror(errno)); - return 1; - } - - key = ecdsa_generate(); - - if(!key) { - return 1; - } - - f = fopen(filename, "w"); - - if(!f) { - fprintf(stderr, "Could not write %s: %s\n", filename, strerror(errno)); - return 1; - } - - chmod(filename, 0600); - - if(!ecdsa_write_pem_private_key(key, f)) { - fprintf(stderr, "Could not write ECDSA private key\n"); - fclose(f); - return 1; - } - - fclose(f); - - if(connect_tincd(true)) { - sendline(fd, "%d %d", CONTROL, REQ_RELOAD); - } else { - fprintf(stderr, "Could not signal the tinc daemon. Please restart or reload it manually.\n"); - } - } else { - key = ecdsa_read_pem_private_key(f); - fclose(f); - - if(!key) { - fprintf(stderr, "Could not read private key from %s\n", filename); - } - } - - if(!key) { - return 1; - } - - // Create a hash of the key. - char hash[64]; - char *fingerprint = ecdsa_get_base64_public_key(key); - sha512(fingerprint, strlen(fingerprint), hash); - b64encode_urlsafe(hash, hash, 18); - - // Create a random cookie for this invitation. - char cookie[25]; - randomize(cookie, 18); - - // Create a filename that doesn't reveal the cookie itself - char buf[18 + strlen(fingerprint)]; - char cookiehash[64]; - memcpy(buf, cookie, 18); - memcpy(buf + 18, fingerprint, sizeof(buf) - 18); - sha512(buf, sizeof(buf), cookiehash); - b64encode_urlsafe(cookiehash, cookiehash, 18); - - b64encode_urlsafe(cookie, cookie, 18); - - // Create a file containing the details of the invitation. - snprintf(filename, sizeof(filename), "%s" SLASH "invitations" SLASH "%s", confbase, cookiehash); - int ifd = open(filename, O_RDWR | O_CREAT | O_EXCL, 0600); - - if(!ifd) { - fprintf(stderr, "Could not create invitation file %s: %s\n", filename, strerror(errno)); - return 1; - } - - f = fdopen(ifd, "w"); - - if(!f) { - abort(); - } - - // Get the local address - char *address = get_my_hostname(); - - // Fill in the details. - fprintf(f, "Name = %s\n", argv[1]); - - if(check_netname(netname, true)) { - fprintf(f, "NetName = %s\n", netname); - } - - fprintf(f, "ConnectTo = %s\n", myname); - - // Copy Broadcast and Mode - FILE *tc = fopen(tinc_conf, "r"); - - if(tc) { - char buf[1024]; - - while(fgets(buf, sizeof(buf), tc)) { - if((!strncasecmp(buf, "Mode", 4) && strchr(" \t=", buf[4])) - || (!strncasecmp(buf, "Broadcast", 9) && strchr(" \t=", buf[9]))) { - fputs(buf, f); - - // Make sure there is a newline character. - if(!strchr(buf, '\n')) { - fputc('\n', f); - } - } - } - - fclose(tc); - } - - fprintf(f, "#---------------------------------------------------------------#\n"); - fprintf(f, "Name = %s\n", myname); - - char filename2[PATH_MAX]; - snprintf(filename2, sizeof(filename2), "%s" SLASH "hosts" SLASH "%s", confbase, myname); - fcopy(f, filename2); - fclose(f); - - // Create an URL from the local address, key hash and cookie - char *url; - xasprintf(&url, "%s/%s%s", address, hash, cookie); - - // Call the inviation-created script - environment_t env; - environment_init(&env); - environment_add(&env, "NODE=%s", argv[1]); - environment_add(&env, "INVITATION_FILE=%s", filename); - environment_add(&env, "INVITATION_URL=%s", url); - execute_script("invitation-created", &env); - environment_exit(&env); - - puts(url); - free(url); - free(address); - - return 0; -} - -static int sock; -static char cookie[18]; -static sptps_t sptps; -static char *data; -static size_t datalen; -static bool success = false; - -static char cookie[18], hash[18]; - -static char *get_line(const char **data) { - if(!data || !*data) { - return NULL; - } - - if(! **data) { - *data = NULL; - return NULL; - } - - static char line[1024]; - const char *end = strchr(*data, '\n'); - size_t len = end ? (size_t)(end - *data) : strlen(*data); - - if(len >= sizeof(line)) { - fprintf(stderr, "Maximum line length exceeded!\n"); - return NULL; - } - - if(len && !isprint(**data)) { - abort(); - } - - memcpy(line, *data, len); - line[len] = 0; - - if(end) { - *data = end + 1; - } else { - *data = NULL; - } - - return line; -} - -static char *get_value(const char *data, const char *var) { - char *line = get_line(&data); - - if(!line) { - return NULL; - } - - char *sep = line + strcspn(line, " \t="); - char *val = sep + strspn(sep, " \t"); - - if(*val == '=') { - val += 1 + strspn(val + 1, " \t"); - } - - *sep = 0; - - if(strcasecmp(line, var)) { - return NULL; - } - - return val; -} - -static char *grep(const char *data, const char *var) { - static char value[1024]; - - const char *p = data; - int varlen = strlen(var); - - // Skip all lines not starting with var - while(strncasecmp(p, var, varlen) || !strchr(" \t=", p[varlen])) { - p = strchr(p, '\n'); - - if(!p) { - break; - } else { - p++; - } - } - - if(!p) { - return NULL; - } - - p += varlen; - p += strspn(p, " \t"); - - if(*p == '=') { - p += 1 + strspn(p + 1, " \t"); - } - - const char *e = strchr(p, '\n'); - - if(!e) { - return xstrdup(p); - } - - if((size_t)(e - p) >= sizeof(value)) { - fprintf(stderr, "Maximum line length exceeded!\n"); - return NULL; - } - - memcpy(value, p, e - p); - value[e - p] = 0; - return value; -} - -static bool finalize_join(void) { - const char *temp_name = get_value(data, "Name"); - - if(!temp_name) { - fprintf(stderr, "No Name found in invitation!\n"); - return false; - } - - size_t len = strlen(temp_name); - char name[len + 1]; - memcpy(name, temp_name, len); - name[len] = 0; - - if(!check_id(name)) { - fprintf(stderr, "Invalid Name found in invitation!\n"); - return false; - } - - if(!netname) { - netname = grep(data, "NetName"); - - if(netname && !check_netname(netname, true)) { - fprintf(stderr, "Unsafe NetName found in invitation!\n"); - return false; - } - } - - bool ask_netname = false; - char temp_netname[32]; - -make_names: - - if(!confbasegiven) { - free(confbase); - confbase = NULL; - } - - make_names(false); - - free(tinc_conf); - free(hosts_dir); - - xasprintf(&tinc_conf, "%s" SLASH "tinc.conf", confbase); - xasprintf(&hosts_dir, "%s" SLASH "hosts", confbase); - - if(!access(tinc_conf, F_OK)) { - fprintf(stderr, "Configuration file %s already exists!\n", tinc_conf); - - if(confbasegiven) { - return false; - } - - // Generate a random netname, ask for a better one later. - ask_netname = true; - snprintf(temp_netname, sizeof(temp_netname), "join_%x", rand()); - netname = temp_netname; - goto make_names; - } - - if(mkdir(confbase, 0777) && errno != EEXIST) { - fprintf(stderr, "Could not create directory %s: %s\n", confbase, strerror(errno)); - return false; - } - - if(mkdir(hosts_dir, 0777) && errno != EEXIST) { - fprintf(stderr, "Could not create directory %s: %s\n", hosts_dir, strerror(errno)); - return false; - } - - FILE *f = fopen(tinc_conf, "w"); - - if(!f) { - fprintf(stderr, "Could not create file %s: %s\n", tinc_conf, strerror(errno)); - return false; - } - - fprintf(f, "Name = %s\n", name); - - char filename[PATH_MAX]; - snprintf(filename, sizeof(filename), "%s" SLASH "%s", hosts_dir, name); - FILE *fh = fopen(filename, "w"); - - if(!fh) { - fprintf(stderr, "Could not create file %s: %s\n", filename, strerror(errno)); - fclose(f); - return false; - } - - snprintf(filename, sizeof(filename), "%s" SLASH "invitation-data", confbase); - FILE *finv = fopen(filename, "w"); - - if(!finv || fwrite(data, datalen, 1, finv) != 1) { - fprintf(stderr, "Could not create file %s: %s\n", filename, strerror(errno)); - fclose(fh); - fclose(f); - fclose(finv); - return false; - } - - fclose(finv); - - snprintf(filename, sizeof(filename), "%s" SLASH "tinc-up.invitation", confbase); - FILE *fup = fopen(filename, "w"); - - if(!fup) { - fprintf(stderr, "Could not create file %s: %s\n", filename, strerror(errno)); - fclose(f); - fclose(fh); - return false; - } - - ifconfig_header(fup); - - // Filter first chunk on approved keywords, split between tinc.conf and hosts/Name - // Generate a tinc-up script from Ifconfig and Route keywords. - // Other chunks go unfiltered to their respective host config files - const char *p = data; - char *l, *value; - - while((l = get_line(&p))) { - // Ignore comments - if(*l == '#') { - continue; - } - - // Split line into variable and value - int len = strcspn(l, "\t ="); - value = l + len; - value += strspn(value, "\t "); - - if(*value == '=') { - value++; - value += strspn(value, "\t "); - } - - l[len] = 0; - - // Ignore lines with empty variable names - if(!*l) { - continue; - } - - // Is it a Name? - if(!strcasecmp(l, "Name")) { - if(strcmp(value, name)) { - break; - } else { - continue; - } - } else if(!strcasecmp(l, "NetName")) { - continue; - } - - // Check the list of known variables - bool found = false; - int i; - - for(i = 0; variables[i].name; i++) { - if(strcasecmp(l, variables[i].name)) { - continue; - } - - found = true; - break; - } - - // Handle Ifconfig and Route statements - if(!found) { - if(!strcasecmp(l, "Ifconfig")) { - if(!strcasecmp(value, "dhcp")) { - ifconfig_dhcp(fup); - } else if(!strcasecmp(value, "dhcp6")) { - ifconfig_dhcp6(fup); - } else if(!strcasecmp(value, "slaac")) { - ifconfig_slaac(fup); - } else { - ifconfig_address(fup, value); - } - - continue; - } else if(!strcasecmp(l, "Route")) { - ifconfig_route(fup, value); - continue; - } - } - - // Ignore unknown and unsafe variables - if(!found) { - fprintf(stderr, "Ignoring unknown variable '%s' in invitation.\n", l); - continue; - } else if(!(variables[i].type & VAR_SAFE)) { - fprintf(stderr, "Ignoring unsafe variable '%s' in invitation.\n", l); - continue; - } - - // Copy the safe variable to the right config file - fprintf((variables[i].type & VAR_HOST) ? fh : f, "%s = %s\n", l, value); - } - - fclose(f); - bool valid_tinc_up = ifconfig_footer(fup); - fclose(fup); - - while(l && !strcasecmp(l, "Name")) { - if(!check_id(value)) { - fprintf(stderr, "Invalid Name found in invitation.\n"); - return false; - } - - if(!strcmp(value, name)) { - fprintf(stderr, "Secondary chunk would overwrite our own host config file.\n"); - return false; - } - - snprintf(filename, sizeof(filename), "%s" SLASH "%s", hosts_dir, value); - f = fopen(filename, "w"); - - if(!f) { - fprintf(stderr, "Could not create file %s: %s\n", filename, strerror(errno)); - return false; - } - - while((l = get_line(&p))) { - if(!strcmp(l, "#---------------------------------------------------------------#")) { - continue; - } - - int len = strcspn(l, "\t ="); - - if(len == 4 && !strncasecmp(l, "Name", 4)) { - value = l + len; - value += strspn(value, "\t "); - - if(*value == '=') { - value++; - value += strspn(value, "\t "); - } - - l[len] = 0; - break; - } - - fputs(l, f); - fputc('\n', f); - } - - fclose(f); - } - - // Generate our key and send a copy to the server - ecdsa_t *key = ecdsa_generate(); - - if(!key) { - return false; - } - - char *b64key = ecdsa_get_base64_public_key(key); - - if(!b64key) { - return false; - } - - snprintf(filename, sizeof(filename), "%s" SLASH "ed25519_key.priv", confbase); - f = fopenmask(filename, "w", 0600); - - if(!f) { - return false; - } - - if(!ecdsa_write_pem_private_key(key, f)) { - fprintf(stderr, "Error writing private key!\n"); - ecdsa_free(key); - fclose(f); - return false; - } - - fclose(f); - - fprintf(fh, "Ed25519PublicKey = %s\n", b64key); - - sptps_send_record(&sptps, 1, b64key, strlen(b64key)); - free(b64key); - ecdsa_free(key); - -#ifndef DISABLE_LEGACY - rsa_t *rsa = rsa_generate(2048, 0x1001); - snprintf(filename, sizeof(filename), "%s" SLASH "rsa_key.priv", confbase); - f = fopenmask(filename, "w", 0600); - - if(!f || !rsa_write_pem_private_key(rsa, f)) { - fprintf(stderr, "Could not write private RSA key\n"); - } else if(!rsa_write_pem_public_key(rsa, fh)) { - fprintf(stderr, "Could not write public RSA key\n"); - } - - fclose(f); - - fclose(fh); - - rsa_free(rsa); -#endif - - check_port(name); - -ask_netname: - - if(ask_netname && tty) { - fprintf(stderr, "Enter a new netname: "); - - if(!fgets(line, sizeof(line), stdin)) { - fprintf(stderr, "Error while reading stdin: %s\n", strerror(errno)); - return false; - } - - if(!*line || *line == '\n') { - goto ask_netname; - } - - line[strlen(line) - 1] = 0; - - char newbase[PATH_MAX]; - - if((size_t)snprintf(newbase, sizeof(newbase), CONFDIR SLASH "tinc" SLASH "%s", line) >= sizeof(newbase)) { - fprintf(stderr, "Filename too long: " CONFDIR SLASH "tinc" SLASH "%s\n", line); - goto ask_netname; - } - - if(rename(confbase, newbase)) { - fprintf(stderr, "Error trying to rename %s to %s: %s\n", confbase, newbase, strerror(errno)); - goto ask_netname; - } - - netname = line; - make_names(false); - } - - char filename2[PATH_MAX]; - snprintf(filename, sizeof(filename), "%s" SLASH "tinc-up.invitation", confbase); - snprintf(filename2, sizeof(filename2), "%s" SLASH "tinc-up", confbase); - - if(valid_tinc_up) { - if(tty) { - FILE *fup = fopen(filename, "r"); - - if(fup) { - fprintf(stderr, "\nPlease review the following tinc-up script:\n\n"); - - char buf[MAXSIZE]; - - while(fgets(buf, sizeof(buf), fup)) { - fputs(buf, stderr); - } - - fclose(fup); - - int response = 0; - - do { - fprintf(stderr, "\nDo you want to use this script [y]es/[n]o/[e]dit? "); - response = tolower(getchar()); - } while(!strchr("yne", response)); - - fprintf(stderr, "\n"); - - if(response == 'e') { - char *command; -#ifndef HAVE_MINGW - const char *editor = getenv("VISUAL"); - if (!editor) - editor = getenv("EDITOR"); - if (!editor) - editor = "vi"; - - xasprintf(&command, "\"%s\" \"%s\"", editor, filename); -#else - xasprintf(&command, "edit \"%s\"", filename); -#endif - - if(system(command)) { - response = 'n'; - } else { - response = 'y'; - } - - free(command); - } - - if(response == 'y') { - rename(filename, filename2); - chmod(filename2, 0755); - fprintf(stderr, "tinc-up enabled.\n"); - } else { - fprintf(stderr, "tinc-up has been left disabled.\n"); - } - } - } else { - fprintf(stderr, "A tinc-up script was generated, but has been left disabled.\n"); - } - } else { - // A placeholder was generated. - rename(filename, filename2); - chmod(filename2, 0755); - } - - fprintf(stderr, "Configuration stored in: %s\n", confbase); - - return true; -} - - -static bool invitation_send(void *handle, uint8_t type, const void *vdata, size_t len) { - (void)handle; - (void)type; - const char *data = vdata; - - while(len) { - int result = send(sock, data, len, 0); - - if(result == -1 && errno == EINTR) { - continue; - } else if(result <= 0) { - return false; - } - - data += result; - len -= result; - } - - return true; -} - -static bool invitation_receive(void *handle, uint8_t type, const void *msg, uint16_t len) { - (void)handle; - - switch(type) { - case SPTPS_HANDSHAKE: - return sptps_send_record(&sptps, 0, cookie, sizeof(cookie)); - - case 0: - data = xrealloc(data, datalen + len + 1); - memcpy(data + datalen, msg, len); - datalen += len; - data[datalen] = 0; - break; - - case 1: - return finalize_join(); - - case 2: - fprintf(stderr, "Invitation successfully accepted.\n"); - shutdown(sock, SHUT_RDWR); - success = true; - break; - - default: - return false; - } - - return true; -} - -int cmd_join(int argc, char *argv[]) { - free(data); - data = NULL; - datalen = 0; - - if(argc > 2) { - fprintf(stderr, "Too many arguments!\n"); - return 1; - } - - // Make sure confbase exists and is accessible. - if(!confbase_given && mkdir(confdir, 0755) && errno != EEXIST) { - fprintf(stderr, "Could not create directory %s: %s\n", confdir, strerror(errno)); - return 1; - } - - if(mkdir(confbase, 0777) && errno != EEXIST) { - fprintf(stderr, "Could not create directory %s: %s\n", confbase, strerror(errno)); - return 1; - } - - if(access(confbase, R_OK | W_OK | X_OK)) { - fprintf(stderr, "No permission to write in directory %s: %s\n", confbase, strerror(errno)); - return 1; - } - - // If a netname or explicit configuration directory is specified, check for an existing tinc.conf. - if((netname || confbasegiven) && !access(tinc_conf, F_OK)) { - fprintf(stderr, "Configuration file %s already exists!\n", tinc_conf); - return 1; - } - - // Either read the invitation from the command line or from stdin. - char *invitation; - - if(argc > 1) { - invitation = argv[1]; - } else { - if(tty) { - fprintf(stderr, "Enter invitation URL: "); - } - - errno = EPIPE; - - if(!fgets(line, sizeof(line), stdin)) { - fprintf(stderr, "Error while reading stdin: %s\n", strerror(errno)); - return false; - } - - invitation = line; - } - - // Parse the invitation URL. - rstrip(line); - - char *slash = strchr(invitation, '/'); - - if(!slash) { - goto invalid; - } - - *slash++ = 0; - - if(strlen(slash) != 48) { - goto invalid; - } - - char *address = invitation; - char *port = NULL; - - if(*address == '[') { - address++; - char *bracket = strchr(address, ']'); - - if(!bracket) { - goto invalid; - } - - *bracket = 0; - - if(bracket[1] == ':') { - port = bracket + 2; - } - } else { - port = strchr(address, ':'); - - if(port) { - *port++ = 0; - } - } - - if(!port || !*port) { - port = "655"; - } - - if(!b64decode(slash, hash, 24) || !b64decode(slash + 24, cookie, 24)) { - goto invalid; - } - - // Generate a throw-away key for the invitation. - ecdsa_t *key = ecdsa_generate(); - - if(!key) { - return 1; - } - - char *b64key = ecdsa_get_base64_public_key(key); - - // Connect to the tinc daemon mentioned in the URL. - struct addrinfo *ai = str2addrinfo(address, port, SOCK_STREAM); - - if(!ai) { - return 1; - } - - struct addrinfo *aip = NULL; - -next: - if(!aip) { - aip = ai; - } else { - aip = aip->ai_next; - - if(!aip) { - freeaddrinfo(ai); - return 1; - } - } - - sock = socket(aip->ai_family, aip->ai_socktype, aip->ai_protocol); - - if(sock <= 0) { - fprintf(stderr, "Could not open socket: %s\n", strerror(errno)); - goto next; - } - - if(connect(sock, aip->ai_addr, aip->ai_addrlen)) { - char *addrstr, *portstr; - sockaddr2str((sockaddr_t *)aip->ai_addr, &addrstr, &portstr); - fprintf(stderr, "Could not connect to %s port %s: %s\n", addrstr, portstr, strerror(errno)); - free(addrstr); - free(portstr); - closesocket(sock); - goto next; - } - - fprintf(stderr, "Connected to %s port %s...\n", address, port); - - // Tell him we have an invitation, and give him our throw-away key. - int len = snprintf(line, sizeof(line), "0 ?%s %d.%d\n", b64key, PROT_MAJOR, PROT_MINOR); - - if(len <= 0 || (size_t)len >= sizeof(line)) { - abort(); - } - - if(!sendline(sock, "0 ?%s %d.%d", b64key, PROT_MAJOR, 1)) { - fprintf(stderr, "Error sending request to %s port %s: %s\n", address, port, strerror(errno)); - closesocket(sock); - goto next; - } - - char hisname[4096] = ""; - int code, hismajor, hisminor = 0; - - if(!recvline(sock, line, sizeof(line)) || sscanf(line, "%d %4095s %d.%d", &code, hisname, &hismajor, &hisminor) < 3 || code != 0 || hismajor != PROT_MAJOR || !check_id(hisname) || !recvline(sock, line, sizeof(line)) || !rstrip(line) || sscanf(line, "%d ", &code) != 1 || code != ACK || strlen(line) < 3) { - fprintf(stderr, "Cannot read greeting from peer\n"); - closesocket(sock); - goto next; - } - - freeaddrinfo(ai); - - // Check if the hash of the key he gave us matches the hash in the URL. - char *fingerprint = line + 2; - char hishash[64]; - - if(sha512(fingerprint, strlen(fingerprint), hishash)) { - fprintf(stderr, "Could not create digest\n%s\n", line + 2); - return 1; - } - - if(memcmp(hishash, hash, 18)) { - fprintf(stderr, "Peer has an invalid key!\n%s\n", line + 2); - return 1; - - } - - ecdsa_t *hiskey = ecdsa_set_base64_public_key(fingerprint); - - if(!hiskey) { - return 1; - } - - // Start an SPTPS session - if(!sptps_start(&sptps, NULL, true, false, key, hiskey, "tinc invitation", 15, invitation_send, invitation_receive)) { - return 1; - } - - // Feed rest of input buffer to SPTPS - if(!sptps_receive_data(&sptps, buffer, blen)) { - return 1; - } - - while((len = recv(sock, line, sizeof(line), 0))) { - if(len < 0) { - if(errno == EINTR) { - continue; - } - - fprintf(stderr, "Error reading data from %s port %s: %s\n", address, port, strerror(errno)); - return 1; - } - - char *p = line; - - while(len) { - int done = sptps_receive_data(&sptps, p, len); - - if(!done) { - return 1; - } - - len -= done; - p += done; - } - } - - sptps_stop(&sptps); - ecdsa_free(hiskey); - ecdsa_free(key); - closesocket(sock); - - if(!success) { - fprintf(stderr, "Connection closed by peer, invitation cancelled.\n"); - return 1; - } - - return 0; - -invalid: - fprintf(stderr, "Invalid invitation URL.\n"); - return 1; -} diff --git a/src/invitation.h b/src/invitation.h deleted file mode 100644 index 6517fe8..0000000 --- a/src/invitation.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef TINC_INVITATION_H -#define TINC_INVITATION_H - -/* - invitation.h -- header for invitation.c. - Copyright (C) 2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -int cmd_invite(int argc, char *argv[]); -int cmd_join(int argc, char *argv[]); - -#endif diff --git a/src/ipv4.h b/src/ipv4.h index 1e34ccb..7979f7d 100644 --- a/src/ipv4.h +++ b/src/ipv4.h @@ -81,7 +81,7 @@ struct ip { uint8_t ip_p; uint16_t ip_sum; struct in_addr ip_src, ip_dst; -} __attribute__((__gcc_struct__, __packed__)); +} __attribute__((__packed__)); #endif #ifndef IP_OFFMASK @@ -143,7 +143,7 @@ struct icmp { #define icmp_radv icmp_dun.id_radv #define icmp_mask icmp_dun.id_mask #define icmp_data icmp_dun.id_data -} __attribute__((__gcc_struct__, __packed__)); +} __attribute__((__packed__)); #endif #endif diff --git a/src/ipv6.h b/src/ipv6.h index 4d5173f..1642278 100644 --- a/src/ipv6.h +++ b/src/ipv6.h @@ -4,7 +4,7 @@ /* ipv6.h -- missing IPv6 related definitions Copyright (C) 2005 Ivo Timmermans - 2006-2016 Guus Sliepen + 2006-2012 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,11 +29,34 @@ #define IPPROTO_ICMPV6 58 #endif +#ifndef HAVE_STRUCT_IN6_ADDR +struct in6_addr { + union { + uint8_t u6_addr8[16]; + uint16_t u6_addr16[8]; + uint32_t u6_addr32[4]; + } in6_u; +} __attribute__((__packed__)); +#define s6_addr in6_u.u6_addr8 +#define s6_addr16 in6_u.u6_addr16 +#define s6_addr32 in6_u.u6_addr32 +#endif + +#ifndef HAVE_STRUCT_SOCKADDR_IN6 +struct sockaddr_in6 { + uint16_t sin6_family; + uint16_t sin6_port; + uint32_t sin6_flowinfo; + struct in6_addr sin6_addr; + uint32_t sin6_scope_id; +} __attribute__((__packed__)); +#endif + #ifndef IN6_IS_ADDR_V4MAPPED #define IN6_IS_ADDR_V4MAPPED(a) \ - ((((__const uint32_t *) (a))[0] == 0) \ - && (((__const uint32_t *) (a))[1] == 0) \ - && (((__const uint32_t *) (a))[2] == htonl (0xffff))) + ((((const uint32_t *) (a))[0] == 0) \ + && (((const uint32_t *) (a))[1] == 0) \ + && (((const uint32_t *) (a))[2] == htonl (0xffff))) #endif #ifndef HAVE_STRUCT_IP6_HDR @@ -49,7 +72,7 @@ struct ip6_hdr { } ip6_ctlun; struct in6_addr ip6_src; struct in6_addr ip6_dst; -} __attribute__((__gcc_struct__, __packed__)); +} __attribute__((__packed__)); #define ip6_vfc ip6_ctlun.ip6_un2_vfc #define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow #define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen @@ -68,7 +91,7 @@ struct icmp6_hdr { uint16_t icmp6_un_data16[2]; uint8_t icmp6_un_data8[4]; } icmp6_dataun; -} __attribute__((__gcc_struct__, __packed__)); +} __attribute__((__packed__)); #define ICMP6_DST_UNREACH_NOROUTE 0 #define ICMP6_DST_UNREACH 1 #define ICMP6_PACKET_TOO_BIG 2 @@ -88,7 +111,7 @@ struct icmp6_hdr { struct nd_neighbor_solicit { struct icmp6_hdr nd_ns_hdr; struct in6_addr nd_ns_target; -} __attribute__((__gcc_struct__, __packed__)); +} __attribute__((__packed__)); #define ND_OPT_SOURCE_LINKADDR 1 #define ND_OPT_TARGET_LINKADDR 2 #define nd_ns_type nd_ns_hdr.icmp6_type @@ -101,7 +124,7 @@ struct nd_neighbor_solicit { struct nd_opt_hdr { uint8_t nd_opt_type; uint8_t nd_opt_len; -} __attribute__((__gcc_struct__, __packed__)); +} __attribute__((__packed__)); #endif #endif diff --git a/src/linux/device.c b/src/linux/device.c index 94e223f..38debe8 100644 --- a/src/linux/device.c +++ b/src/linux/device.c @@ -20,20 +20,23 @@ #include "../system.h" +#ifdef HAVE_LINUX_IF_TUN_H #include #define DEFAULT_DEVICE "/dev/net/tun" +#else +#define DEFAULT_DEVICE "/dev/tap0" +#endif #include "../conf.h" #include "../device.h" #include "../logger.h" -#include "../names.h" #include "../net.h" #include "../route.h" #include "../utils.h" #include "../xalloc.h" -#include "../device.h" typedef enum device_type_t { + DEVICE_TYPE_ETHERTAP, DEVICE_TYPE_TUN, DEVICE_TYPE_TAP, } device_type_t; @@ -46,20 +49,30 @@ static char *type = NULL; static char ifrname[IFNAMSIZ]; static const char *device_info; +static uint64_t device_total_in = 0; +static uint64_t device_total_out = 0; + static bool setup_device(void) { + struct ifreq ifr; + bool t1q = false; + if(!get_config_string(lookup_config(config_tree, "Device"), &device)) { device = xstrdup(DEFAULT_DEVICE); } if(!get_config_string(lookup_config(config_tree, "Interface"), &iface)) - if(netname) { +#ifdef HAVE_LINUX_IF_TUN_H + if(netname != NULL) { iface = xstrdup(netname); } +#else + iface = xstrdup(strrchr(device, '/') ? strrchr(device, '/') + 1 : device); +#endif device_fd = open(device, O_RDWR | O_NONBLOCK); if(device_fd < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not open %s: %s", device, strerror(errno)); + logger(LOG_ERR, "Could not open %s: %s", device, strerror(errno)); return false; } @@ -67,12 +80,15 @@ static bool setup_device(void) { fcntl(device_fd, F_SETFD, FD_CLOEXEC); #endif - struct ifreq ifr = {0}; +#ifdef HAVE_LINUX_IF_TUN_H + /* Ok now check if this is an old ethertap or a new tun/tap thingie */ + + memset(&ifr, 0, sizeof(ifr)); get_config_string(lookup_config(config_tree, "DeviceType"), &type); if(type && strcasecmp(type, "tun") && strcasecmp(type, "tap")) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unknown device type %s!", type); + logger(LOG_ERR, "Unknown device type %s!", type); return false; } @@ -91,10 +107,8 @@ static bool setup_device(void) { } #ifdef IFF_ONE_QUEUE + /* Set IFF_ONE_QUEUE flag... */ - - bool t1q = false; - if(get_config_bool(lookup_config(config_tree, "IffOneQueue"), &t1q) && t1q) { ifr.ifr_flags |= IFF_ONE_QUEUE; } @@ -111,93 +125,105 @@ static bool setup_device(void) { ifrname[IFNAMSIZ - 1] = 0; free(iface); iface = xstrdup(ifrname); - } else { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not create a tun/tap interface from %s: %s", device, strerror(errno)); + } else if(errno == EPERM || errno == EBUSY) { + logger(LOG_ERR, "Error while trying to configure %s: %s", device, strerror(errno)); return false; - } - - logger(DEBUG_ALWAYS, LOG_INFO, "%s is a %s", device, device_info); - - if(ifr.ifr_flags & IFF_TAP) { - struct ifreq ifr_mac = {0}; - - if(!ioctl(device_fd, SIOCGIFHWADDR, &ifr_mac)) { - memcpy(mymac.x, ifr_mac.ifr_hwaddr.sa_data, ETH_ALEN); - } else { - logger(DEBUG_ALWAYS, LOG_WARNING, "Could not get MAC address of %s: %s", device, strerror(errno)); + } else if(!ioctl(device_fd, (('T' << 8) | 202), &ifr)) { + logger(LOG_WARNING, "Old ioctl() request was needed for %s", device); + strncpy(ifrname, ifr.ifr_name, IFNAMSIZ); + ifrname[IFNAMSIZ - 1] = 0; + free(iface); + iface = xstrdup(ifrname); + } else +#endif + { + if(routing_mode == RMODE_ROUTER) { + overwrite_mac = true; } + + device_info = "Linux ethertap device"; + device_type = DEVICE_TYPE_ETHERTAP; + free(iface); + iface = xstrdup(strrchr(device, '/') ? strrchr(device, '/') + 1 : device); } + if(overwrite_mac && !ioctl(device_fd, SIOCGIFHWADDR, &ifr)) { + memcpy(mymac.x, ifr.ifr_hwaddr.sa_data, ETH_ALEN); + } + + logger(LOG_INFO, "%s is a %s", device, device_info); + return true; } static void close_device(void) { close(device_fd); - device_fd = -1; free(type); - type = NULL; free(device); - device = NULL; free(iface); - iface = NULL; - device_info = NULL; } static bool read_packet(vpn_packet_t *packet) { - int inlen; + int lenin; switch(device_type) { case DEVICE_TYPE_TUN: - inlen = read(device_fd, DATA(packet) + 10, MTU - 10); + lenin = read(device_fd, packet->data + 10, MTU - 10); - if(inlen <= 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from %s %s: %s", + if(lenin <= 0) { + logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); - - if(errno == EBADFD) { /* File descriptor in bad state */ - event_exit(); - } - return false; } - memset(DATA(packet), 0, 12); - packet->len = inlen + 10; + memset(packet->data, 0, 12); + packet->len = lenin + 10; break; case DEVICE_TYPE_TAP: - inlen = read(device_fd, DATA(packet), MTU); + lenin = read(device_fd, packet->data, MTU); - if(inlen <= 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from %s %s: %s", + if(lenin <= 0) { + logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); return false; } - packet->len = inlen; + packet->len = lenin; break; - default: - abort(); + case DEVICE_TYPE_ETHERTAP: + lenin = read(device_fd, packet->data - 2, MTU + 2); + + if(lenin <= 0) { + logger(LOG_ERR, "Error while reading from %s %s: %s", + device_info, device, strerror(errno)); + return false; + } + + packet->len = lenin - 2; + break; } - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, - device_info); + device_total_in += packet->len; + + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, + device_info); return true; } static bool write_packet(vpn_packet_t *packet) { - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Writing packet of %d bytes to %s", - packet->len, device_info); + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Writing packet of %d bytes to %s", + packet->len, device_info); switch(device_type) { case DEVICE_TYPE_TUN: - DATA(packet)[10] = DATA(packet)[11] = 0; + packet->data[10] = packet->data[11] = 0; - if(write(device_fd, DATA(packet) + 10, packet->len - 10) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Can't write to %s %s: %s", device_info, device, + if(write(device_fd, packet->data + 10, packet->len - 10) < 0) { + logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, strerror(errno)); return false; } @@ -205,24 +231,41 @@ static bool write_packet(vpn_packet_t *packet) { break; case DEVICE_TYPE_TAP: - if(write(device_fd, DATA(packet), packet->len) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Can't write to %s %s: %s", device_info, device, + if(write(device_fd, packet->data, packet->len) < 0) { + logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, strerror(errno)); return false; } break; - default: - abort(); + case DEVICE_TYPE_ETHERTAP: + memcpy(packet->data - 2, &packet->len, 2); + + if(write(device_fd, packet->data - 2, packet->len + 2) < 0) { + logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, + strerror(errno)); + return false; + } + + break; } + device_total_out += packet->len; + return true; } +static void dump_device_stats(void) { + logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); + logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); + logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); +} + const devops_t os_devops = { .setup = setup_device, .close = close_device, .read = read_packet, .write = write_packet, + .dump_stats = dump_device_stats, }; diff --git a/src/list.c b/src/list.c index 27494c8..a807c6d 100644 --- a/src/list.c +++ b/src/list.c @@ -1,7 +1,7 @@ /* list.c -- functions to deal with double linked lists Copyright (C) 2000-2005 Ivo Timmermans - 2000-2013 Guus Sliepen + 2000-2006 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,7 +26,9 @@ /* (De)constructors */ list_t *list_alloc(list_action_t delete) { - list_t *list = xzalloc(sizeof(list_t)); + list_t *list; + + list = xmalloc_and_zero(sizeof(list_t)); list->delete = delete; return list; @@ -37,7 +39,7 @@ void list_free(list_t *list) { } list_node_t *list_alloc_node(void) { - return xzalloc(sizeof(list_node_t)); + return xmalloc_and_zero(sizeof(list_node_t)); } void list_free_node(list_t *list, list_node_t *node) { @@ -51,7 +53,9 @@ void list_free_node(list_t *list, list_node_t *node) { /* Insertion and deletion */ list_node_t *list_insert_head(list_t *list, void *data) { - list_node_t *node = list_alloc_node(); + list_node_t *node; + + node = list_alloc_node(); node->data = data; node->prev = NULL; @@ -70,52 +74,14 @@ list_node_t *list_insert_head(list_t *list, void *data) { } list_node_t *list_insert_tail(list_t *list, void *data) { - list_node_t *node = list_alloc_node(); - - node->data = data; - node->next = NULL; - node->prev = list->tail; - list->tail = node; - - if(node->prev) { - node->prev->next = node; - } else { - list->head = node; - } - - list->count++; - - return node; -} - -list_node_t *list_insert_after(list_t *list, list_node_t *after, void *data) { - list_node_t *node = list_alloc_node(); - - node->data = data; - node->next = after->next; - node->prev = after; - after->next = node; - - if(node->next) { - node->next->prev = node; - } else { - list->tail = node; - } - - list->count++; - - return node; -} - -list_node_t *list_insert_before(list_t *list, list_node_t *before, void *data) { list_node_t *node; node = list_alloc_node(); node->data = data; - node->next = before; - node->prev = before->prev; - before->prev = node; + node->next = NULL; + node->prev = list->tail; + list->tail = node; if(node->prev) { node->prev->next = node; @@ -157,13 +123,6 @@ void list_delete_tail(list_t *list) { list_delete_node(list, list->tail); } -void list_delete(list_t *list, const void *data) { - for(list_node_t *node = list->head, *next; next = node ? node->next : NULL, node; node = next) - if(node->data == data) { - list_delete_node(list, node); - } -} - /* Head/tail lookup */ void *list_get_head(list_t *list) { @@ -185,7 +144,10 @@ void *list_get_tail(list_t *list) { /* Fast list deletion */ void list_delete_list(list_t *list) { - for(list_node_t *node = list->head, *next; next = node ? node->next : NULL, node; node = next) { + list_node_t *node, *next; + + for(node = list->head; node; node = next) { + next = node->next; list_free_node(list, node); } @@ -195,14 +157,22 @@ void list_delete_list(list_t *list) { /* Traversing */ void list_foreach_node(list_t *list, list_action_node_t action) { - for(list_node_t *node = list->head, *next; next = node ? node->next : NULL, node; node = next) { + list_node_t *node, *next; + + for(node = list->head; node; node = next) { + next = node->next; action(node); } } void list_foreach(list_t *list, list_action_t action) { - for(list_node_t *node = list->head, *next; next = node ? node->next : NULL, node; node = next) + list_node_t *node, *next; + + for(node = list->head; node; node = next) { + next = node->next; + if(node->data) { action(node->data); } + } } diff --git a/src/list.h b/src/list.h index 3806495..b2a9b3d 100644 --- a/src/list.h +++ b/src/list.h @@ -4,7 +4,7 @@ /* list.h -- header file for list.c Copyright (C) 2000-2005 Ivo Timmermans - 2000-2012 Guus Sliepen + 2000-2006 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,8 +30,8 @@ typedef struct list_node_t { void *data; } list_node_t; -typedef void (*list_action_t)(const void *data); -typedef void (*list_action_node_t)(const list_node_t *node); +typedef void (*list_action_t)(const void *); +typedef void (*list_action_node_t)(const list_node_t *); typedef struct list_t { list_node_t *head; @@ -45,7 +45,7 @@ typedef struct list_t { /* (De)constructors */ -extern list_t *list_alloc(list_action_t delete) __attribute__((__malloc__)); +extern list_t *list_alloc(list_action_t) __attribute__((__malloc__)); extern void list_free(list_t *list); extern list_node_t *list_alloc_node(void); extern void list_free_node(list_t *list, list_node_t *node); @@ -54,10 +54,6 @@ extern void list_free_node(list_t *list, list_node_t *node); extern list_node_t *list_insert_head(list_t *list, void *data); extern list_node_t *list_insert_tail(list_t *list, void *data); -extern list_node_t *list_insert_after(list_t *list, list_node_t *node, void *data); -extern list_node_t *list_insert_before(list_t *list, list_node_t *node, void *data); - -extern void list_delete(list_t *list, const void *data); extern void list_unlink_node(list_t *list, list_node_t *node); extern void list_delete_node(list_t *list, list_node_t *node); @@ -79,12 +75,4 @@ extern void list_delete_list(list_t *list); extern void list_foreach(list_t *list, list_action_t action); extern void list_foreach_node(list_t *list, list_action_node_t action); -/* - Iterates over a list. - - CAUTION: while this construct supports deleting the current item, - it does *not* support deleting *other* nodes while iterating on the list. - */ -#define list_each(type, item, list) (type *item = (type *)1; item; item = NULL) for(list_node_t *node = (list)->head, *next; item = node ? node->data : NULL, next = node ? node->next : NULL, node; node = next) - #endif diff --git a/src/logger.c b/src/logger.c index 062f759..8d4aea1 100644 --- a/src/logger.c +++ b/src/logger.c @@ -1,6 +1,6 @@ /* logger.c -- logging code - Copyright (C) 2004-2017 Guus Sliepen + Copyright (C) 2004-2016 Guus Sliepen 2004-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -21,146 +21,17 @@ #include "system.h" #include "conf.h" -#include "meta.h" -#include "names.h" #include "logger.h" -#include "connection.h" -#include "control_common.h" -#include "process.h" -#include "sptps.h" -int debug_level = DEBUG_NOTHING; +debug_t debug_level = DEBUG_NOTHING; static logmode_t logmode = LOGMODE_STDERR; static pid_t logpid; +extern char *logfilename; static FILE *logfile = NULL; #ifdef HAVE_MINGW static HANDLE loghandle = NULL; #endif static const char *logident = NULL; -bool logcontrol = false; -int umbilical = 0; - -static void real_logger(int level, int priority, const char *message) { - char timestr[32] = ""; - static bool suppress = false; - - // Bail out early if there is nothing to do. - if(suppress) { - return; - } - - if(!logcontrol && (level > debug_level || logmode == LOGMODE_NULL)) { - return; - } - - if(level <= debug_level) { - switch(logmode) { - case LOGMODE_STDERR: - fprintf(stderr, "%s\n", message); - fflush(stderr); - break; - - case LOGMODE_FILE: - if(!now.tv_sec) { - gettimeofday(&now, NULL); - } - - time_t now_sec = now.tv_sec; - strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S", localtime(&now_sec)); - fprintf(logfile, "%s %s[%ld]: %s\n", timestr, logident, (long)logpid, message); - fflush(logfile); - break; - - case LOGMODE_SYSLOG: -#ifdef HAVE_MINGW - { - const char *messages[] = {message}; - ReportEvent(loghandle, priority, 0, 0, NULL, 1, 0, messages, NULL); - } - -#else -#ifdef HAVE_SYSLOG_H - syslog(priority, "%s", message); -#endif -#endif - break; - - case LOGMODE_NULL: - break; - } - - if(umbilical && do_detach) { - write(umbilical, message, strlen(message)); - write(umbilical, "\n", 1); - } - } - - if(logcontrol) { - suppress = true; - logcontrol = false; - - for list_each(connection_t, c, connection_list) { - if(!c->status.log) { - continue; - } - - logcontrol = true; - - if(level > (c->outcompression >= 0 ? c->outcompression : debug_level)) { - continue; - } - - int len = strlen(message); - - if(send_request(c, "%d %d %d", CONTROL, REQ_LOG, len)) { - send_meta(c, message, len); - } - } - - suppress = false; - } -} - -void logger(int level, int priority, const char *format, ...) { - va_list ap; - char message[1024] = ""; - - va_start(ap, format); - int len = vsnprintf(message, sizeof(message), format, ap); - message[sizeof(message) - 1] = 0; - va_end(ap); - - if(len > 0 && (size_t)len < sizeof(message) - 1 && message[len - 1] == '\n') { - message[len - 1] = 0; - } - - real_logger(level, priority, message); -} - -static void sptps_logger(sptps_t *s, int s_errno, const char *format, va_list ap) { - (void)s_errno; - char message[1024]; - size_t msglen = sizeof(message); - - int len = vsnprintf(message, msglen, format, ap); - message[sizeof(message) - 1] = 0; - - if(len > 0 && (size_t)len < sizeof(message) - 1) { - if(message[len - 1] == '\n') { - message[--len] = 0; - } - - // WARNING: s->handle can point to a connection_t or a node_t, - // but both types have the name and hostname fields at the same offsets. - connection_t *c = s->handle; - - if(c) { - snprintf(message + len, sizeof(message) - len, " from %s (%s)", c->name, c->hostname); - } - } - - real_logger(DEBUG_ALWAYS, LOG_ERR, message); -} void openlogger(const char *ident, logmode_t mode) { logident = ident; @@ -187,7 +58,7 @@ void openlogger(const char *ident, logmode_t mode) { loghandle = RegisterEventSource(NULL, logident); if(!loghandle) { - fprintf(stderr, "Could not open log handle!\n"); + fprintf(stderr, "Could not open log handle!"); logmode = LOGMODE_NULL; } @@ -202,12 +73,6 @@ void openlogger(const char *ident, logmode_t mode) { case LOGMODE_NULL: break; } - - if(logmode != LOGMODE_NULL) { - sptps_log = sptps_logger; - } else { - sptps_log = sptps_log_quiet; - } } void reopenlogger() { @@ -219,7 +84,7 @@ void reopenlogger() { FILE *newfile = fopen(logfilename, "a"); if(!newfile) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unable to reopen log file %s: %s", logfilename, strerror(errno)); + logger(LOG_ERR, "Unable to reopen log file %s: %s", logfilename, strerror(errno)); return; } @@ -227,6 +92,60 @@ void reopenlogger() { logfile = newfile; } +void logger(int priority, const char *format, ...) { + va_list ap; + char timestr[32] = ""; + time_t now; + + va_start(ap, format); + + switch(logmode) { + case LOGMODE_STDERR: + vfprintf(stderr, format, ap); + fprintf(stderr, "\n"); + fflush(stderr); + break; + + case LOGMODE_FILE: + now = time(NULL); + strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S", localtime(&now)); + fprintf(logfile, "%s %s[%ld]: ", timestr, logident, (long)logpid); + vfprintf(logfile, format, ap); + fprintf(logfile, "\n"); + fflush(logfile); + break; + + case LOGMODE_SYSLOG: +#ifdef HAVE_MINGW + { + char message[4096]; + const char *messages[] = {message}; + vsnprintf(message, sizeof(message), format, ap); + message[sizeof(message) - 1] = 0; + ReportEvent(loghandle, priority, 0, 0, NULL, 1, 0, messages, NULL); + } + +#else +#ifdef HAVE_SYSLOG_H +#ifdef HAVE_VSYSLOG + vsyslog(priority, format, ap); +#else + { + char message[4096]; + vsnprintf(message, sizeof(message), format, ap); + syslog(priority, "%s", message); + } +#endif + break; +#endif +#endif + + case LOGMODE_NULL: + break; + } + + va_end(ap); +} void closelogger(void) { switch(logmode) { diff --git a/src/logger.h b/src/logger.h index 611fe38..5a17ffb 100644 --- a/src/logger.h +++ b/src/logger.h @@ -3,8 +3,7 @@ /* logger.h -- header file for logger.c - Copyright (C) 1998-2005 Ivo Timmermans - 2000-2017 Guus Sliepen + Copyright (C) 2003-2016 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,16 +21,16 @@ */ typedef enum debug_t { - DEBUG_NOTHING = 0, /* Quiet mode, only show starting/stopping of the daemon */ + DEBUG_NOTHING = 0, /* Quiet mode, only show starting/stopping of the daemon */ DEBUG_ALWAYS = 0, - DEBUG_CONNECTIONS = 1, /* Show (dis)connects of other tinc daemons via TCP */ - DEBUG_ERROR = 2, /* Show error messages received from other hosts */ - DEBUG_STATUS = 2, /* Show status messages received from other hosts */ - DEBUG_PROTOCOL = 3, /* Show the requests that are sent/received */ - DEBUG_META = 4, /* Show contents of every request that is sent/received */ - DEBUG_TRAFFIC = 5, /* Show network traffic information */ - DEBUG_PACKET = 6, /* Show contents of each packet that is being sent/received */ - DEBUG_SCARY_THINGS = 10 /* You have been warned */ + DEBUG_CONNECTIONS = 1, /* Show (dis)connects of other tinc daemons via TCP */ + DEBUG_ERROR = 2, /* Show error messages received from other hosts */ + DEBUG_STATUS = 2, /* Show status messages received from other hosts */ + DEBUG_PROTOCOL = 3, /* Show the requests that are sent/received */ + DEBUG_META = 4, /* Show contents of every request that is sent/received */ + DEBUG_TRAFFIC = 5, /* Show network traffic information */ + DEBUG_PACKET = 6, /* Show contents of each packet that is being sent/received */ + DEBUG_SCARY_THINGS = 10, /* You have been warned */ } debug_t; typedef enum logmode_t { @@ -65,14 +64,12 @@ enum { #endif #endif -#include - -extern int debug_level; -extern bool logcontrol; -extern int umbilical; +extern debug_t debug_level; extern void openlogger(const char *ident, logmode_t mode); extern void reopenlogger(void); -extern void logger(int level, int priority, const char *format, ...) __attribute__((__format__(printf, 3, 4))); +extern void logger(int priority, const char *format, ...) __attribute__((__format__(printf, 2, 3))); extern void closelogger(void); +#define ifdebug(l) if(debug_level >= DEBUG_##l) + #endif diff --git a/src/meta.c b/src/meta.c index 0089ac8..ee55ecd 100644 --- a/src/meta.c +++ b/src/meta.c @@ -1,6 +1,6 @@ /* meta.c -- handle the meta communication - Copyright (C) 2000-2014 Guus Sliepen , + Copyright (C) 2000-2017 Guus Sliepen , 2000-2005 Ivo Timmermans 2006 Scott Lamb @@ -21,147 +21,125 @@ #include "system.h" -#include "cipher.h" +#include +#include + +#include "avl_tree.h" #include "connection.h" #include "logger.h" #include "meta.h" #include "net.h" #include "protocol.h" +#include "proxy.h" #include "utils.h" #include "xalloc.h" -#ifndef MIN -#define MIN(x, y) (((x)<(y))?(x):(y)) -#endif +bool send_meta(connection_t *c, const char *buffer, int length) { + int outlen; + int result; -bool send_meta_sptps(void *handle, uint8_t type, const void *buffer, size_t length) { - (void)type; - connection_t *c = handle; + ifdebug(META) logger(LOG_DEBUG, "Sending %d bytes of metadata to %s (%s)", length, + c->name, c->hostname); - if(!c) { - logger(DEBUG_ALWAYS, LOG_ERR, "send_meta_sptps() called with NULL pointer!"); - abort(); + if(!c->outbuflen) { + c->last_flushed_time = now; } - buffer_add(&c->outbuf, buffer, length); - io_set(&c->io, IO_READ | IO_WRITE); - - return true; -} - -bool send_meta(connection_t *c, const char *buffer, size_t length) { - if(!c) { - logger(DEBUG_ALWAYS, LOG_ERR, "send_meta() called with NULL pointer!"); - abort(); + /* Find room in connection's buffer */ + if(length + c->outbuflen > c->outbufsize) { + c->outbufsize = length + c->outbuflen; + c->outbuf = xrealloc(c->outbuf, c->outbufsize); } - logger(DEBUG_META, LOG_DEBUG, "Sending %lu bytes of metadata to %s (%s)", (unsigned long)length, - c->name, c->hostname); - - if(c->protocol_minor >= 2) { - return sptps_send_record(&c->sptps, 0, buffer, length); + if(length + c->outbuflen + c->outbufstart > c->outbufsize) { + memmove(c->outbuf, c->outbuf + c->outbufstart, c->outbuflen); + c->outbufstart = 0; } /* Add our data to buffer */ if(c->status.encryptout) { -#ifdef DISABLE_LEGACY - return false; -#else - - if(length > c->outbudget) { - logger(DEBUG_META, LOG_ERR, "Byte limit exceeded for encryption to %s (%s)", c->name, c->hostname); + /* Check encryption limits */ + if((uint64_t)length > c->outbudget) { + ifdebug(META) logger(LOG_ERR, "Byte limit exceeded for encryption to %s (%s)", c->name, c->hostname); return false; } else { c->outbudget -= length; } - size_t outlen = length; + result = EVP_EncryptUpdate(c->outctx, (unsigned char *)c->outbuf + c->outbufstart + c->outbuflen, + &outlen, (unsigned char *)buffer, length); - if(!cipher_encrypt(c->outcipher, buffer, length, buffer_prepare(&c->outbuf, length), &outlen, false) || outlen != length) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while encrypting metadata to %s (%s)", - c->name, c->hostname); + if(!result || outlen < length) { + logger(LOG_ERR, "Error while encrypting metadata to %s (%s): %s", + c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL)); return false; + } else if(outlen > length) { + logger(LOG_EMERG, "Encrypted data too long! Heap corrupted!"); + abort(); } -#endif + c->outbuflen += outlen; } else { - buffer_add(&c->outbuf, buffer, length); + memcpy(c->outbuf + c->outbufstart + c->outbuflen, buffer, length); + c->outbuflen += length; } - io_set(&c->io, IO_READ | IO_WRITE); - return true; } -void send_meta_raw(connection_t *c, const char *buffer, size_t length) { - if(!c) { - logger(DEBUG_ALWAYS, LOG_ERR, "send_meta() called with NULL pointer!"); - abort(); - } +bool flush_meta(connection_t *c) { + int result; - logger(DEBUG_META, LOG_DEBUG, "Sending %lu bytes of raw metadata to %s (%s)", (unsigned long)length, - c->name, c->hostname); + ifdebug(META) logger(LOG_DEBUG, "Flushing %d bytes to %s (%s)", + c->outbuflen, c->name, c->hostname); - buffer_add(&c->outbuf, buffer, length); + while(c->outbuflen) { + result = send(c->socket, c->outbuf + c->outbufstart, c->outbuflen, 0); - io_set(&c->io, IO_READ | IO_WRITE); -} + if(result <= 0) { + if(!errno || errno == EPIPE) { + ifdebug(CONNECTIONS) logger(LOG_NOTICE, "Connection closed by %s (%s)", + c->name, c->hostname); + } else if(errno == EINTR) { + continue; + } else if(sockwouldblock(sockerrno)) { + ifdebug(META) logger(LOG_DEBUG, "Flushing %d bytes to %s (%s) would block", + c->outbuflen, c->name, c->hostname); + return true; + } else { + logger(LOG_ERR, "Flushing meta data to %s (%s) failed: %s", c->name, + c->hostname, sockstrerror(sockerrno)); + } -void broadcast_meta(connection_t *from, const char *buffer, size_t length) { - for list_each(connection_t, c, connection_list) - if(c != from && c->edge) { - send_meta(c, buffer, length); - } -} - -bool receive_meta_sptps(void *handle, uint8_t type, const void *vdata, uint16_t length) { - const char *data = vdata; - connection_t *c = handle; - - if(!c) { - logger(DEBUG_ALWAYS, LOG_ERR, "receive_meta_sptps() called with NULL pointer!"); - abort(); - } - - if(type == SPTPS_HANDSHAKE) { - if(c->allow_request == ACK) { - return send_ack(c); - } else { - return true; - } - } - - if(!data) { - return true; - } - - /* Are we receiving a TCPpacket? */ - - if(c->tcplen) { - if(length != c->tcplen) { return false; } - receive_tcppacket(c, data, length); - c->tcplen = 0; - return true; + c->outbufstart += result; + c->outbuflen -= result; } - /* Change newline to null byte, just like non-SPTPS requests */ + c->outbufstart = 0; /* avoid unnecessary memmoves */ + return true; +} - if(data[length - 1] == '\n') { - ((char *)data)[length - 1] = 0; +void broadcast_meta(connection_t *from, const char *buffer, int length) { + avl_node_t *node; + connection_t *c; + + for(node = connection_tree->head; node; node = node->next) { + c = node->data; + + if(c != from && c->status.active) { + send_meta(c, buffer, length); + } } - - /* Otherwise we are waiting for a request */ - - return receive_request(c, data); } bool receive_meta(connection_t *c) { - ssize_t inlen; + int oldlen, i, result; + int lenin, lenout, reqlen; + bool decrypted = false; char inbuf[MAXBUFSIZE]; - char *bufp = inbuf, *endp; /* Strategy: - Read as much as possible from the TCP socket in one go. @@ -172,174 +150,109 @@ bool receive_meta(connection_t *c) { - If not, keep stuff in buffer and exit. */ - buffer_compact(&c->inbuf, MAXBUFSIZE); + lenin = recv(c->socket, c->buffer + c->buflen, MAXBUFSIZE - c->buflen, 0); - if(sizeof(inbuf) <= c->inbuf.len) { - logger(DEBUG_ALWAYS, LOG_ERR, "Input buffer full for %s (%s)", c->name, c->hostname); - return false; - } - - inlen = recv(c->socket, inbuf, sizeof(inbuf) - c->inbuf.len, 0); - - if(inlen <= 0) { - if(!inlen || !sockerrno) { - logger(DEBUG_CONNECTIONS, LOG_NOTICE, "Connection closed by %s (%s)", - c->name, c->hostname); + if(lenin <= 0) { + if(!lenin || !errno) { + ifdebug(CONNECTIONS) logger(LOG_NOTICE, "Connection closed by %s (%s)", + c->name, c->hostname); } else if(sockwouldblock(sockerrno)) { return true; } else - logger(DEBUG_ALWAYS, LOG_ERR, "Metadata socket read error for %s (%s): %s", + logger(LOG_ERR, "Metadata socket read error for %s (%s): %s", c->name, c->hostname, sockstrerror(sockerrno)); return false; } - do { - /* Are we receiving a SPTPS packet? */ + oldlen = c->buflen; + c->buflen += lenin; - if(c->sptpslen) { - ssize_t len = MIN(inlen, c->sptpslen - c->inbuf.len); - buffer_add(&c->inbuf, bufp, len); + while(lenin > 0) { + reqlen = 0; - char *sptpspacket = buffer_read(&c->inbuf, c->sptpslen); + /* Is it proxy metadata? */ - if(!sptpspacket) { - return true; - } + if(c->allow_request == PROXY) { + reqlen = receive_proxy_meta(c); - if(!receive_tcppacket_sptps(c, sptpspacket, c->sptpslen)) { + if(reqlen < 0) { return false; } - c->sptpslen = 0; - - bufp += len; - inlen -= len; - continue; + goto consume; } - if(c->protocol_minor >= 2) { - size_t len = sptps_receive_data(&c->sptps, bufp, inlen); + /* Decrypt */ - if(!len) { - return false; - } - - bufp += len; - inlen -= len; - continue; - } - - if(!c->status.decryptin) { - endp = memchr(bufp, '\n', inlen); - - if(endp) { - endp++; - } else { - endp = bufp + inlen; - } - - buffer_add(&c->inbuf, bufp, endp - bufp); - - inlen -= endp - bufp; - bufp = endp; - } else { -#ifdef DISABLE_LEGACY - return false; -#else - - if((size_t)inlen > c->inbudget) { - logger(DEBUG_META, LOG_ERR, "Byte limit exceeded for decryption from %s (%s)", c->name, c->hostname); + if(c->status.decryptin && !decrypted) { + /* Check decryption limits */ + if((uint64_t)lenin > c->inbudget) { + ifdebug(META) logger(LOG_ERR, "Byte limit exceeded for decryption from %s (%s)", c->name, c->hostname); return false; } else { - c->inbudget -= inlen; + c->inbudget -= lenin; } - size_t outlen = inlen; + result = EVP_DecryptUpdate(c->inctx, (unsigned char *)inbuf, &lenout, (unsigned char *)c->buffer + oldlen, lenin); - if(!cipher_decrypt(c->incipher, bufp, inlen, buffer_prepare(&c->inbuf, inlen), &outlen, false) || (size_t)inlen != outlen) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while decrypting metadata from %s (%s)", - c->name, c->hostname); + if(!result || lenout != lenin) { + logger(LOG_ERR, "Error while decrypting metadata from %s (%s): %s", + c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL)); return false; } - inlen = 0; -#endif + memcpy(c->buffer + oldlen, inbuf, lenin); + decrypted = true; } - while(c->inbuf.len) { - /* Are we receiving a TCPpacket? */ + /* Are we receiving a TCPpacket? */ - if(c->tcplen) { - char *tcpbuffer = buffer_read(&c->inbuf, c->tcplen); - - if(!tcpbuffer) { - break; - } - - if(!c->node) { - if(c->outgoing && proxytype == PROXY_SOCKS4 && c->allow_request == ID) { - if(tcpbuffer[0] == 0 && tcpbuffer[1] == 0x5a) { - logger(DEBUG_CONNECTIONS, LOG_DEBUG, "Proxy request granted"); - } else { - logger(DEBUG_CONNECTIONS, LOG_ERR, "Proxy request rejected"); - return false; - } - } else if(c->outgoing && proxytype == PROXY_SOCKS5 && c->allow_request == ID) { - if(tcpbuffer[0] != 5) { - logger(DEBUG_CONNECTIONS, LOG_ERR, "Invalid response from proxy server"); - return false; - } - - if(tcpbuffer[1] == (char)0xff) { - logger(DEBUG_CONNECTIONS, LOG_ERR, "Proxy request rejected: unsuitable authentication method"); - return false; - } - - if(tcpbuffer[2] != 5) { - logger(DEBUG_CONNECTIONS, LOG_ERR, "Invalid response from proxy server"); - return false; - } - - if(tcpbuffer[3] == 0) { - logger(DEBUG_CONNECTIONS, LOG_DEBUG, "Proxy request granted"); - } else { - logger(DEBUG_CONNECTIONS, LOG_DEBUG, "Proxy request rejected"); - return false; - } - } else { - logger(DEBUG_CONNECTIONS, LOG_ERR, "c->tcplen set but c->node is NULL!"); - abort(); - } - } else { - if(c->allow_request == ALL) { - receive_tcppacket(c, tcpbuffer, c->tcplen); - } else { - logger(DEBUG_CONNECTIONS, LOG_ERR, "Got unauthorized TCP packet from %s (%s)", c->name, c->hostname); - return false; - } - } - - c->tcplen = 0; - } - - /* Otherwise we are waiting for a request */ - - char *request = buffer_readline(&c->inbuf); - - if(request) { - bool result = receive_request(c, request); - - if(!result) { + if(c->tcplen) { + if(c->tcplen <= c->buflen) { + if(c->allow_request != ALL) { + logger(LOG_ERR, "Got unauthorized TCP packet from %s (%s)", c->name, c->hostname); return false; } - continue; - } else { - break; + receive_tcppacket(c, c->buffer, c->tcplen); + reqlen = c->tcplen; + c->tcplen = 0; + } + } else { + /* Otherwise we are waiting for a request */ + + for(i = oldlen; i < c->buflen; i++) { + if(c->buffer[i] == '\n') { + c->buffer[i] = '\0'; /* replace end-of-line by end-of-string so we can use sscanf */ + c->reqlen = reqlen = i + 1; + break; + } + } + + if(reqlen && !receive_request(c)) { + return false; } } - } while(inlen); + +consume: + + if(reqlen) { + c->buflen -= reqlen; + lenin -= reqlen - oldlen; + memmove(c->buffer, c->buffer + reqlen, c->buflen); + oldlen = 0; + continue; + } else { + break; + } + } + + if(c->buflen >= MAXBUFSIZE) { + logger(LOG_ERR, "Metadata read buffer overflow for %s (%s)", + c->name, c->hostname); + return false; + } return true; } diff --git a/src/meta.h b/src/meta.h index dcf2419..36914f1 100644 --- a/src/meta.h +++ b/src/meta.h @@ -3,7 +3,7 @@ /* meta.h -- header for meta.c - Copyright (C) 2000-2014 Guus Sliepen , + Copyright (C) 2000-2006 Guus Sliepen , 2000-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -23,11 +23,9 @@ #include "connection.h" -extern bool send_meta(struct connection_t *c, const char *buffer, size_t length); -extern void send_meta_raw(struct connection_t *c, const char *buffer, size_t length); -extern bool send_meta_sptps(void *handle, uint8_t type, const void *data, size_t length); -extern bool receive_meta_sptps(void *handle, uint8_t type, const void *data, uint16_t length); -extern void broadcast_meta(struct connection_t *from, const char *buffer, size_t length); +extern bool send_meta(struct connection_t *c, const char *buffer, int length); +extern void broadcast_meta(struct connection_t *c, const char *buffer, int length); +extern bool flush_meta(struct connection_t *c); extern bool receive_meta(struct connection_t *c); #endif diff --git a/src/mingw/common.h b/src/mingw/common.h index ff052c9..41b9dc5 100644 --- a/src/mingw/common.h +++ b/src/mingw/common.h @@ -1,6 +1,3 @@ -#ifndef TINC_MINGW_COMMON_H -#define TINC_MINGW_COMMON_H - /* * TAP-Win32 -- A kernel driver to provide virtual tap device functionality * on Windows. Originally derived from the CIPE-Win32 @@ -76,5 +73,3 @@ //========================================================= #define TAP_COMPONENT_ID "tap0801" - -#endif diff --git a/src/mingw/device.c b/src/mingw/device.c index 183641b..321c515 100644 --- a/src/mingw/device.c +++ b/src/mingw/device.c @@ -1,7 +1,7 @@ /* device.c -- Interaction with Windows tap driver in a MinGW environment Copyright (C) 2002-2005 Ivo Timmermans, - 2002-2014 Guus Sliepen + 2002-2016 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,7 +26,6 @@ #include "../conf.h" #include "../device.h" #include "../logger.h" -#include "../names.h" #include "../net.h" #include "../route.h" #include "../utils.h" @@ -36,59 +35,67 @@ int device_fd = -1; static HANDLE device_handle = INVALID_HANDLE_VALUE; -static io_t device_read_io; -static OVERLAPPED device_read_overlapped; -static OVERLAPPED device_write_overlapped; -static vpn_packet_t device_read_packet; -static vpn_packet_t device_write_packet; char *device = NULL; char *iface = NULL; static const char *device_info = "Windows tap device"; -extern char *myport; +static uint64_t device_total_in = 0; +static uint64_t device_total_out = 0; -static void device_issue_read() { +extern char *myport; +OVERLAPPED r_overlapped; +OVERLAPPED w_overlapped; + +static DWORD WINAPI tapreader(void *bla) { int status; + DWORD len; + vpn_packet_t packet; + int errors = 0; + + logger(LOG_DEBUG, "Tap reader running"); + + /* Read from tap device and send to parent */ + + r_overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); for(;;) { - ResetEvent(device_read_overlapped.hEvent); + ResetEvent(r_overlapped.hEvent); - DWORD len; - status = ReadFile(device_handle, (void *)device_read_packet.data, MTU, &len, &device_read_overlapped); + status = ReadFile(device_handle, packet.data, MTU, &len, &r_overlapped); if(!status) { - if(GetLastError() != ERROR_IO_PENDING) - logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from %s %s: %s", device_info, + if(GetLastError() == ERROR_IO_PENDING) { + WaitForSingleObject(r_overlapped.hEvent, INFINITE); + + if(!GetOverlappedResult(device_handle, &r_overlapped, &len, FALSE)) { + continue; + } + } else { + logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); + errors++; - break; + if(errors >= 10) { + EnterCriticalSection(&mutex); + running = false; + LeaveCriticalSection(&mutex); + } + + usleep(1000000); + continue; + } } - device_read_packet.len = len; - device_read_packet.priority = 0; - route(myself, &device_read_packet); - } -} + errors = 0; + packet.len = len; + packet.priority = 0; -static void device_handle_read(void *data, int flags) { - DWORD len; - - if(!GetOverlappedResult(device_handle, &device_read_overlapped, &len, FALSE)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error getting read result from %s %s: %s", device_info, - device, strerror(errno)); - - if(GetLastError() != ERROR_IO_INCOMPLETE) { - /* Must reset event or it will keep firing. */ - ResetEvent(device_read_overlapped.hEvent); - } - - return; + EnterCriticalSection(&mutex); + route(myself, &packet); + LeaveCriticalSection(&mutex); } - device_read_packet.len = len; - device_read_packet.priority = 0; - route(myself, &device_read_packet); - device_issue_read(); + return 0; } static bool setup_device(void) { @@ -100,22 +107,24 @@ static bool setup_device(void) { char adaptername[1024]; char tapname[1024]; DWORD len; + unsigned long status; bool found = false; int err; + HANDLE thread; get_config_string(lookup_config(config_tree, "Device"), &device); get_config_string(lookup_config(config_tree, "Interface"), &iface); if(device && iface) { - logger(DEBUG_ALWAYS, LOG_WARNING, "Warning: both Device and Interface specified, results may not be as expected"); + logger(LOG_WARNING, "Warning: both Device and Interface specified, results may not be as expected"); } /* Open registry and look for network adapters */ if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, NETWORK_CONNECTIONS_KEY, 0, KEY_READ, &key)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unable to read registry: %s", winerror(GetLastError())); + logger(LOG_ERR, "Unable to read registry: %s", winerror(GetLastError())); return false; } @@ -173,7 +182,7 @@ static bool setup_device(void) { RegCloseKey(key); if(!found) { - logger(DEBUG_ALWAYS, LOG_ERR, "No Windows tap device found!"); + logger(LOG_ERR, "No Windows tap device found!"); return false; } @@ -193,34 +202,14 @@ static bool setup_device(void) { } if(device_handle == INVALID_HANDLE_VALUE) { - logger(DEBUG_ALWAYS, LOG_ERR, "%s (%s) is not a usable Windows tap device: %s", device, iface, winerror(GetLastError())); + logger(LOG_ERR, "%s (%s) is not a usable Windows tap device: %s", device, iface, winerror(GetLastError())); return false; } - /* Get version information from tap device */ - - { - ULONG info[3] = {0}; - DWORD len; - - if(!DeviceIoControl(device_handle, TAP_IOCTL_GET_VERSION, &info, sizeof(info), &info, sizeof(info), &len, NULL)) { - logger(DEBUG_ALWAYS, LOG_WARNING, "Could not get version information from Windows tap device %s (%s): %s", device, iface, winerror(GetLastError())); - } else { - logger(DEBUG_ALWAYS, LOG_INFO, "TAP-Windows driver version: %lu.%lu%s", info[0], info[1], info[2] ? " (DEBUG)" : ""); - - /* Warn if using >=9.21. This is because starting from 9.21, TAP-Win32 seems to use a different, less efficient write path. */ - if(info[0] == 9 && info[1] >= 21) - logger(DEBUG_ALWAYS, LOG_WARNING, - "You are using the newer (>= 9.0.0.21, NDIS6) series of TAP-Win32 drivers. " - "Using these drivers with tinc is not recommended as it can result in poor performance. " - "You might want to revert back to 9.0.0.9 instead."); - } - } - /* Get MAC address from tap device */ if(!DeviceIoControl(device_handle, TAP_IOCTL_GET_MAC, mymac.x, sizeof(mymac.x), mymac.x, sizeof(mymac.x), &len, 0)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not get MAC address from Windows tap device %s (%s): %s", device, iface, winerror(GetLastError())); + logger(LOG_ERR, "Could not get MAC address from Windows tap device %s (%s): %s", device, iface, winerror(GetLastError())); return false; } @@ -228,75 +217,35 @@ static bool setup_device(void) { overwrite_mac = 1; } - device_info = "Windows tap device"; + /* Create overlapped events for tap I/O */ - logger(DEBUG_ALWAYS, LOG_INFO, "%s (%s) is a %s", device, iface, device_info); + r_overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + w_overlapped.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL); - device_read_overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - device_write_overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + /* Start the tap reader */ + + thread = CreateThread(NULL, 0, tapreader, NULL, 0, NULL); + + if(!thread) { + logger(LOG_ERR, "System call `%s' failed: %s", "CreateThread", winerror(GetLastError())); + return false; + } + + /* Set media status for newer TAP-Win32 devices */ + + status = true; + DeviceIoControl(device_handle, TAP_IOCTL_SET_MEDIA_STATUS, &status, sizeof(status), &status, sizeof(status), &len, NULL); + + logger(LOG_INFO, "%s (%s) is a %s", device, iface, device_info); return true; } -static void enable_device(void) { - logger(DEBUG_ALWAYS, LOG_INFO, "Enabling %s", device_info); - - ULONG status = 1; - DWORD len; - DeviceIoControl(device_handle, TAP_IOCTL_SET_MEDIA_STATUS, &status, sizeof(status), &status, sizeof(status), &len, NULL); - - /* We don't use the write event directly, but GetOverlappedResult() does, internally. */ - - io_add_event(&device_read_io, device_handle_read, NULL, device_read_overlapped.hEvent); - device_issue_read(); -} - -static void disable_device(void) { - logger(DEBUG_ALWAYS, LOG_INFO, "Disabling %s", device_info); - - io_del(&device_read_io); - - ULONG status = 0; - DWORD len; - DeviceIoControl(device_handle, TAP_IOCTL_SET_MEDIA_STATUS, &status, sizeof(status), &status, sizeof(status), &len, NULL); - - /* Note that we don't try to cancel ongoing I/O here - we just stop listening. - This is because some TAP-Win32 drivers don't seem to handle cancellation very well, - especially when combined with other events such as the computer going to sleep - cases - were observed where the GetOverlappedResult() would just block indefinitely and never - return in that case. */ -} - static void close_device(void) { - CancelIo(device_handle); - - /* According to MSDN, CancelIo() does not necessarily wait for the operation to complete. - To prevent race conditions, make sure the operation is complete - before we close the event it's referencing. */ - - DWORD len; - - if(!GetOverlappedResult(device_handle, &device_read_overlapped, &len, TRUE) && GetLastError() != ERROR_OPERATION_ABORTED) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not wait for %s %s read to cancel: %s", device_info, device, winerror(GetLastError())); - } - - if(device_write_packet.len > 0 && !GetOverlappedResult(device_handle, &device_write_overlapped, &len, TRUE) && GetLastError() != ERROR_OPERATION_ABORTED) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not wait for %s %s write to cancel: %s", device_info, device, winerror(GetLastError())); - } - - device_write_packet.len = 0; - - CloseHandle(device_read_overlapped.hEvent); - CloseHandle(device_write_overlapped.hEvent); - CloseHandle(device_handle); - device_handle = INVALID_HANDLE_VALUE; free(device); - device = NULL; free(iface); - iface = NULL; - device_info = NULL; } static bool read_packet(vpn_packet_t *packet) { @@ -304,50 +253,70 @@ static bool read_packet(vpn_packet_t *packet) { } static bool write_packet(vpn_packet_t *packet) { - DWORD outlen; + DWORD lenout; + static vpn_packet_t queue; - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Writing packet of %d bytes to %s", - packet->len, device_info); + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Writing packet of %d bytes to %s", + packet->len, device_info); - if(device_write_packet.len > 0) { - /* Make sure the previous write operation is finished before we start the next one; - otherwise we end up with multiple write ops referencing the same OVERLAPPED structure, - which according to MSDN is a no-no. */ + /* Check if there is something in progress */ - if(!GetOverlappedResult(device_handle, &device_write_overlapped, &outlen, FALSE)) { - if(GetLastError() != ERROR_IO_INCOMPLETE) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error completing previously queued write to %s %s: %s", device_info, device, winerror(GetLastError())); + if(queue.len) { + DWORD size; + BOOL success = GetOverlappedResult(device_handle, &w_overlapped, &size, FALSE); + + if(success) { + ResetEvent(&w_overlapped); + queue.len = 0; + } else { + int err = GetLastError(); + + if(err != ERROR_IO_INCOMPLETE) { + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Error completing previously queued write: %s", winerror(err)); + ResetEvent(&w_overlapped); + queue.len = 0; } else { - logger(DEBUG_TRAFFIC, LOG_ERR, "Previous overlapped write to %s %s still in progress", device_info, device); + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Previous overlapped write still in progress"); // drop this packet return true; } } } - /* Copy the packet, since the write operation might still be ongoing after we return. */ + /* Otherwise, try to write. */ - memcpy(&device_write_packet, packet, sizeof(*packet)); + memcpy(queue.data, packet->data, packet->len); - ResetEvent(device_write_overlapped.hEvent); + if(!WriteFile(device_handle, queue.data, packet->len, &lenout, &w_overlapped)) { + int err = GetLastError(); - if(WriteFile(device_handle, DATA(&device_write_packet), device_write_packet.len, &outlen, &device_write_overlapped)) { + if(err != ERROR_IO_PENDING) { + logger(LOG_ERR, "Error while writing to %s %s: %s", device_info, device, winerror(err)); + return false; + } + + // Write is being done asynchronously. + queue.len = packet->len; + } else { // Write was completed immediately. - device_write_packet.len = 0; - } else if(GetLastError() != ERROR_IO_PENDING) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while writing to %s %s: %s", device_info, device, winerror(GetLastError())); - device_write_packet.len = 0; - return false; + ResetEvent(&w_overlapped); } + device_total_out += packet->len; + return true; } +static void dump_device_stats(void) { + logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); + logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); + logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); +} + const devops_t os_devops = { .setup = setup_device, .close = close_device, .read = read_packet, .write = write_packet, - .enable = enable_device, - .disable = disable_device, + .dump_stats = dump_device_stats, }; diff --git a/src/multicast_device.c b/src/multicast_device.c index e9607f0..93a40c4 100644 --- a/src/multicast_device.c +++ b/src/multicast_device.c @@ -1,7 +1,7 @@ /* device.c -- multicast socket Copyright (C) 2002-2005 Ivo Timmermans, - 2002-2013 Guus Sliepen + 2002-2014 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,11 +31,14 @@ static const char *device_info = "multicast socket"; +static uint64_t device_total_in = 0; +static uint64_t device_total_out = 0; + static struct addrinfo *ai = NULL; -static mac_t ignore_src = {0}; +static mac_t ignore_src = {{0}}; static bool setup_device(void) { - char *host = NULL; + char *host; char *port; char *space; int ttl = 1; @@ -43,16 +46,17 @@ static bool setup_device(void) { get_config_string(lookup_config(config_tree, "Interface"), &iface); if(!get_config_string(lookup_config(config_tree, "Device"), &device)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Device variable required for %s", device_info); - goto error; + logger(LOG_ERR, "Device variable required for %s", device_info); + return false; } host = xstrdup(device); space = strchr(host, ' '); if(!space) { - logger(DEBUG_ALWAYS, LOG_ERR, "Port number required for %s", device_info); - goto error; + logger(LOG_ERR, "Port number required for %s", device_info); + free(host); + return false; } *space++ = 0; @@ -67,14 +71,16 @@ static bool setup_device(void) { ai = str2addrinfo(host, port, SOCK_DGRAM); if(!ai) { - goto error; + free(host); + return false; } device_fd = socket(ai->ai_family, SOCK_DGRAM, IPPROTO_UDP); if(device_fd < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Creating socket failed: %s", sockstrerror(sockerrno)); - goto error; + logger(LOG_ERR, "Creating socket failed: %s", sockstrerror(sockerrno)); + free(host); + return false; } #ifdef FD_CLOEXEC @@ -85,8 +91,10 @@ static bool setup_device(void) { setsockopt(device_fd, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof(one)); if(bind(device_fd, ai->ai_addr, ai->ai_addrlen)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Can't bind to %s %s: %s", host, port, sockstrerror(sockerrno)); - goto error; + closesocket(device_fd); + logger(LOG_ERR, "Can't bind to %s %s: %s", host, port, sockstrerror(sockerrno)); + free(host); + return false; } switch(ai->ai_family) { @@ -100,8 +108,10 @@ static bool setup_device(void) { mreq.imr_interface.s_addr = htonl(INADDR_ANY); if(setsockopt(device_fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (void *)&mreq, sizeof(mreq))) { - logger(DEBUG_ALWAYS, LOG_ERR, "Cannot join multicast group %s %s: %s", host, port, sockstrerror(sockerrno)); - goto error; + logger(LOG_ERR, "Cannot join multicast group %s %s: %s", host, port, sockstrerror(sockerrno)); + closesocket(device_fd); + free(host); + return false; } #ifdef IP_MULTICAST_LOOP @@ -124,8 +134,10 @@ static bool setup_device(void) { mreq.ipv6mr_interface = in6.sin6_scope_id; if(setsockopt(device_fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, (void *)&mreq, sizeof(mreq))) { - logger(DEBUG_ALWAYS, LOG_ERR, "Cannot join multicast group %s %s: %s", host, port, sockstrerror(sockerrno)); - goto error; + logger(LOG_ERR, "Cannot join multicast group %s %s: %s", host, port, sockstrerror(sockerrno)); + closesocket(device_fd); + free(host); + return false; } #ifdef IPV6_MULTICAST_LOOP @@ -139,86 +151,97 @@ static bool setup_device(void) { #endif default: - logger(DEBUG_ALWAYS, LOG_ERR, "Multicast for address family %x unsupported", ai->ai_family); - goto error; - } - - logger(DEBUG_ALWAYS, LOG_INFO, "%s is a %s", device, device_info); - - return true; - -error: - - if(device_fd >= 0) { + logger(LOG_ERR, "Multicast for address family %x unsupported", ai->ai_family); closesocket(device_fd); - } - - if(ai) { - freeaddrinfo(ai); + free(host); + return false; } free(host); + logger(LOG_INFO, "%s is a %s", device, device_info); - return false; + return true; } static void close_device(void) { close(device_fd); - device_fd = -1; free(device); - device = NULL; free(iface); - iface = NULL; if(ai) { freeaddrinfo(ai); - ai = NULL; } - - device_info = NULL; } static bool read_packet(vpn_packet_t *packet) { int lenin; - if((lenin = recv(device_fd, (void *)DATA(packet), MTU, 0)) <= 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from %s %s: %s", device_info, - device, sockstrerror(sockerrno)); + if((lenin = recv(device_fd, (void *)packet->data, MTU, 0)) <= 0) { + logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, + device, strerror(errno)); return false; } - if(!memcmp(&ignore_src, DATA(packet) + 6, sizeof(ignore_src))) { - logger(DEBUG_SCARY_THINGS, LOG_DEBUG, "Ignoring loopback packet of %d bytes from %s", lenin, device_info); - return false; + if(!memcmp(&ignore_src, packet->data + 6, sizeof(ignore_src))) { + ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Ignoring loopback packet of %d bytes from %s", lenin, device_info); + packet->len = 0; + return true; } packet->len = lenin; - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, - device_info); + device_total_in += packet->len; + + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, + device_info); return true; } static bool write_packet(vpn_packet_t *packet) { - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Writing packet of %d bytes to %s", - packet->len, device_info); + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Writing packet of %d bytes to %s", + packet->len, device_info); - if(sendto(device_fd, (void *)DATA(packet), packet->len, 0, ai->ai_addr, ai->ai_addrlen) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Can't write to %s %s: %s", device_info, device, - sockstrerror(sockerrno)); + if(sendto(device_fd, (void *)packet->data, packet->len, 0, ai->ai_addr, ai->ai_addrlen) < 0) { + logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, + strerror(errno)); return false; } - memcpy(&ignore_src, DATA(packet) + 6, sizeof(ignore_src)); + device_total_out += packet->len; + + memcpy(&ignore_src, packet->data + 6, sizeof(ignore_src)); return true; } +static void dump_device_stats(void) { + logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); + logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); + logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); +} + const devops_t multicast_devops = { .setup = setup_device, .close = close_device, .read = read_packet, .write = write_packet, + .dump_stats = dump_device_stats, }; + +#if 0 + +static bool not_supported(void) { + logger(LOG_ERR, "Raw socket device not supported on this platform"); + return false; +} + +const devops_t multicast_devops = { + .setup = not_supported, + .close = NULL, + .read = NULL, + .write = NULL, + .dump_stats = NULL, +}; +#endif diff --git a/src/names.c b/src/names.c deleted file mode 100644 index 6db364e..0000000 --- a/src/names.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - names.c -- generate commonly used (file)names - Copyright (C) 1998-2005 Ivo Timmermans - 2000-2017 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include "logger.h" -#include "names.h" -#include "xalloc.h" - -char *netname = NULL; -char *myname = NULL; -char *confdir = NULL; /* base configuration directory */ -char *confbase = NULL; /* base configuration directory for this instance of tinc */ -bool confbase_given; -char *identname = NULL; /* program name for syslog */ -char *unixsocketname = NULL; /* UNIX socket location */ -char *logfilename = NULL; /* log file location */ -char *pidfilename = NULL; -char *program_name = NULL; - -/* - Set all files and paths according to netname -*/ -void make_names(bool daemon) { -#ifdef HAVE_MINGW - HKEY key; - char installdir[1024] = ""; - DWORD len = sizeof(installdir); -#endif - confbase_given = confbase; - - if(netname && confbase) { - logger(DEBUG_ALWAYS, LOG_INFO, "Both netname and configuration directory given, using the latter..."); - } - - if(netname) { - xasprintf(&identname, "tinc.%s", netname); - } else { - identname = xstrdup("tinc"); - } - -#ifdef HAVE_MINGW - - if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\tinc", 0, KEY_READ, &key)) { - if(!RegQueryValueEx(key, NULL, 0, 0, (LPBYTE)installdir, &len)) { - confdir = xstrdup(installdir); - - if(!confbase) { - if(netname) { - xasprintf(&confbase, "%s" SLASH "%s", installdir, netname); - } else { - xasprintf(&confbase, "%s", installdir); - } - } - - if(!logfilename) { - xasprintf(&logfilename, "%s" SLASH "tinc.log", confbase); - } - } - - RegCloseKey(key); - } - -#endif - - if(!confdir) { - confdir = xstrdup(CONFDIR SLASH "tinc"); - } - - if(!confbase) { - if(netname) { - xasprintf(&confbase, CONFDIR SLASH "tinc" SLASH "%s", netname); - } else { - xasprintf(&confbase, CONFDIR SLASH "tinc"); - } - } - -#ifdef HAVE_MINGW - - if(!logfilename) { - xasprintf(&logfilename, "%s" SLASH "log", confbase); - } - - if(!pidfilename) { - xasprintf(&pidfilename, "%s" SLASH "pid", confbase); - } - -#else - bool fallback = false; - - if(daemon) { - if(access(LOCALSTATEDIR, R_OK | W_OK | X_OK)) { - fallback = true; - } - } else { - char fname[PATH_MAX]; - snprintf(fname, sizeof(fname), LOCALSTATEDIR SLASH "run" SLASH "%s.pid", identname); - - if(access(fname, R_OK)) { - snprintf(fname, sizeof(fname), "%s" SLASH "pid", confbase); - - if(!access(fname, R_OK)) { - fallback = true; - } - } - } - - if(!fallback) { - if(!logfilename) { - xasprintf(&logfilename, LOCALSTATEDIR SLASH "log" SLASH "%s.log", identname); - } - - if(!pidfilename) { - xasprintf(&pidfilename, LOCALSTATEDIR SLASH "run" SLASH "%s.pid", identname); - } - } else { - if(!logfilename) { - xasprintf(&logfilename, "%s" SLASH "log", confbase); - } - - if(!pidfilename) { - if(daemon) { - logger(DEBUG_ALWAYS, LOG_WARNING, "Could not access " LOCALSTATEDIR SLASH " (%s), storing pid and socket files in %s" SLASH, strerror(errno), confbase); - } - - xasprintf(&pidfilename, "%s" SLASH "pid", confbase); - } - } - -#endif - - if(!unixsocketname) { - int len = strlen(pidfilename); - unixsocketname = xmalloc(len + 8); - memcpy(unixsocketname, pidfilename, len); - - if(len > 4 && !strcmp(pidfilename + len - 4, ".pid")) { - strncpy(unixsocketname + len - 4, ".socket", 8); - } else { - strncpy(unixsocketname + len, ".socket", 8); - } - } -} - -void free_names(void) { - free(identname); - free(netname); - free(unixsocketname); - free(pidfilename); - free(logfilename); - free(confbase); - free(confdir); - free(myname); - - identname = NULL; - netname = NULL; - unixsocketname = NULL; - pidfilename = NULL; - logfilename = NULL; - confbase = NULL; - confdir = NULL; - myname = NULL; -} diff --git a/src/names.h b/src/names.h deleted file mode 100644 index f109686..0000000 --- a/src/names.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef TINC_NAMES_H -#define TINC_NAMES_H - -/* - names.h -- header for names.c - Copyright (C) 1998-2005 Ivo Timmermans - 2000-2017 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -extern char *confdir; -extern char *confbase; -extern bool confbase_given; -extern char *netname; -extern char *myname; -extern char *identname; -extern char *unixsocketname; -extern char *logfilename; -extern char *pidfilename; -extern char *program_name; - -extern void make_names(bool daemon); -extern void free_names(void); - -#endif diff --git a/src/net.c b/src/net.c index 75838e0..37ae116 100644 --- a/src/net.c +++ b/src/net.c @@ -1,7 +1,7 @@ /* net.c -- most of the network code Copyright (C) 1998-2005 Ivo Timmermans, - 2000-2017 Guus Sliepen + 2000-2015 Guus Sliepen 2006 Scott Lamb 2011 Loïc Grenié @@ -22,41 +22,59 @@ #include "system.h" -#include "autoconnect.h" +#include + +#include "utils.h" +#include "avl_tree.h" #include "conf.h" #include "connection.h" #include "device.h" +#include "event.h" #include "graph.h" #include "logger.h" #include "meta.h" -#include "names.h" #include "net.h" #include "netutl.h" +#include "process.h" #include "protocol.h" +#include "route.h" #include "subnet.h" -#include "utils.h" #include "xalloc.h" +bool do_purge = false; +volatile bool running = false; +#ifdef HAVE_PSELECT +bool graph_dump = false; +#endif + +time_t now = 0; int contradicting_add_edge = 0; int contradicting_del_edge = 0; static int sleeptime = 10; -time_t last_config_check = 0; -static timeout_t pingtimer; -static timeout_t periodictimer; -static struct timeval last_periodic_run_time; /* Purge edges and subnets of unreachable nodes. Use carefully. */ -void purge(void) { - logger(DEBUG_PROTOCOL, LOG_DEBUG, "Purging unreachable nodes"); +static void purge(void) { + avl_node_t *nnode, *nnext, *enode, *enext, *snode, *snext; + node_t *n; + edge_t *e; + subnet_t *s; + + ifdebug(PROTOCOL) logger(LOG_DEBUG, "Purging unreachable nodes"); /* Remove all edges and subnets owned by unreachable nodes. */ - for splay_each(node_t, n, node_tree) { - if(!n->status.reachable) { - logger(DEBUG_SCARY_THINGS, LOG_DEBUG, "Purging node %s (%s)", n->name, n->hostname); + for(nnode = node_tree->head; nnode; nnode = nnext) { + nnext = nnode->next; + n = nnode->data; - for splay_each(subnet_t, s, n->subnet_tree) { + if(!n->status.reachable) { + ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Purging node %s (%s)", n->name, + n->hostname); + + for(snode = n->subnet_tree->head; snode; snode = snext) { + snext = snode->next; + s = snode->data; send_del_subnet(everyone, s); if(!strictsubnets) { @@ -64,7 +82,10 @@ void purge(void) { } } - for splay_each(edge_t, e, n->edge_tree) { + for(enode = n->edge_tree->head; enode; enode = enext) { + enext = enode->next; + e = enode->data; + if(!tunnelserver) { send_del_edge(everyone, e); } @@ -76,14 +97,21 @@ void purge(void) { /* Check if anyone else claims to have an edge to an unreachable node. If not, delete node. */ - for splay_each(node_t, n, node_tree) { - if(!n->status.reachable) { - for splay_each(edge_t, e, edge_weight_tree) - if(e->to == n) { - return; - } + for(nnode = node_tree->head; nnode; nnode = nnext) { + nnext = nnode->next; + n = nnode->data; - if(!autoconnect && (!strictsubnets || !n->subnet_tree->head)) + if(!n->status.reachable) { + for(enode = edge_weight_tree->head; enode; enode = enext) { + enext = enode->next; + e = enode->data; + + if(e->to == n) { + break; + } + } + + if(!enode && (!strictsubnets || !n->subnet_tree->head)) /* in strictsubnets mode do not delete nodes with subnets */ { node_del(n); @@ -92,10 +120,70 @@ void purge(void) { } } +/* + put all file descriptors in an fd_set array + While we're at it, purge stuff that needs to be removed. +*/ +static int build_fdset(fd_set *readset, fd_set *writeset) { + avl_node_t *node, *next; + connection_t *c; + int i, max = 0; + + FD_ZERO(readset); + FD_ZERO(writeset); + + for(node = connection_tree->head; node; node = next) { + next = node->next; + c = node->data; + + if(c->status.remove) { + connection_del(c); + + if(!connection_tree->head) { + purge(); + } + } else { + FD_SET(c->socket, readset); + + if(c->outbuflen > 0 || c->status.connecting) { + FD_SET(c->socket, writeset); + } + + if(c->socket > max) { + max = c->socket; + } + } + } + + for(i = 0; i < listen_sockets; i++) { + FD_SET(listen_socket[i].tcp, readset); + + if(listen_socket[i].tcp > max) { + max = listen_socket[i].tcp; + } + + FD_SET(listen_socket[i].udp, readset); + + if(listen_socket[i].udp > max) { + max = listen_socket[i].udp; + } + } + + if(device_fd >= 0) { + FD_SET(device_fd, readset); + } + + if(device_fd > max) { + max = device_fd; + } + + return max; +} + /* Put a misbehaving connection in the tarpit */ void tarpit(int fd) { static int pits[10] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; - static unsigned int next_pit = 0; + static int next_pit = 0; if(pits[next_pit] != -1) { closesocket(pits[next_pit]); @@ -103,62 +191,82 @@ void tarpit(int fd) { pits[next_pit++] = fd; - if(next_pit >= sizeof pits / sizeof pits[0]) { + if(next_pit >= (int)(sizeof pits / sizeof pits[0])) { next_pit = 0; } } /* Terminate a connection: - - Mark it as inactive - - Remove the edge representing this connection - - Kill it with fire + - Close the socket + - Remove associated edge and tell other connections about it if report = true - Check if we need to retry making an outgoing connection + - Deactivate the host */ void terminate_connection(connection_t *c, bool report) { - logger(DEBUG_CONNECTIONS, LOG_NOTICE, "Closing connection with %s (%s)", c->name, c->hostname); + if(c->status.remove) { + return; + } + + ifdebug(CONNECTIONS) logger(LOG_NOTICE, "Closing connection with %s (%s)", + c->name, c->hostname); + + c->status.remove = true; + c->status.active = false; if(c->node) { - if(c->node->connection == c) { - c->node->connection = NULL; + c->node->connection = NULL; + } + + if(c->socket) { + if(c->status.tarpit) { + tarpit(c->socket); + } else { + closesocket(c->socket); + } + } + + if(c->edge) { + if(!c->node) { + logger(LOG_ERR, "Connection to %s (%s) has an edge but node is NULL!", c->name, c->hostname); + // And that should never happen. + abort(); } - if(c->edge) { - if(report && !tunnelserver) { - send_del_edge(everyone, c->edge); - } + if(report && !tunnelserver) { + send_del_edge(everyone, c->edge); + } - edge_del(c->edge); - c->edge = NULL; + edge_del(c->edge); + c->edge = NULL; - /* Run MST and SSSP algorithms */ + /* Run MST and SSSP algorithms */ - graph(); + graph(); - /* If the node is not reachable anymore but we remember it had an edge to us, clean it up */ + /* If the node is not reachable anymore but we remember it had an edge to us, clean it up */ - if(report && !c->node->status.reachable) { - edge_t *e; - e = lookup_edge(c->node, myself); + if(report && !c->node->status.reachable) { + edge_t *e; + e = lookup_edge(c->node, myself); - if(e) { - if(!tunnelserver) { - send_del_edge(everyone, e); - } - - edge_del(e); + if(e) { + if(!tunnelserver) { + send_del_edge(everyone, e); } + + edge_del(e); } } } - outgoing_t *outgoing = c->outgoing; - connection_del(c); + free_connection_partially(c); /* Check if this was our outgoing connection */ - if(outgoing) { - do_outgoing_connection(outgoing); + if(c->outgoing) { + c->status.remove = false; + do_outgoing_connection(c); } #ifndef HAVE_MINGW @@ -177,351 +285,427 @@ void terminate_connection(connection_t *c, bool report) { end does not reply in time, we consider them dead and close the connection. */ -static void timeout_handler(void *data) { +static void check_dead_connections(void) { + avl_node_t *node, *next; + connection_t *c; - bool close_all_connections = false; + for(node = connection_tree->head; node; node = next) { + next = node->next; + c = node->data; - /* - timeout_handler will start after 30 seconds from start of tincd - hold information about the elapsed time since last time the handler - has been run - */ - long sleep_time = now.tv_sec - last_periodic_run_time.tv_sec; + if(c->last_ping_time + pingtimeout <= now) { + if(c->status.active) { + if(c->status.pinged) { + ifdebug(CONNECTIONS) logger(LOG_INFO, "%s (%s) didn't respond to PING in %ld seconds", + c->name, c->hostname, (long)(now - c->last_ping_time)); + c->status.timeout = true; + terminate_connection(c, true); + } else if(c->last_ping_time + pinginterval <= now) { + send_ping(c); + } + } else { + if(c->status.remove) { + logger(LOG_WARNING, "Old connection_t for %s (%s) status %04x still lingering, deleting...", + c->name, c->hostname, bitfield_to_int(&c->status, sizeof(c->status))); + connection_del(c); + continue; + } - /* - It seems that finding sane default value is harder than expected - Since we send every second a UDP packet to make holepunching work - And default UDP state expire on firewalls is between 15-30 seconds - we drop all connections after 60 Seconds - UDPDiscoveryTimeout=30 - by default - */ - if(sleep_time > 2 * udp_discovery_timeout) { - logger(DEBUG_ALWAYS, LOG_ERR, "Awaking from dead after %ld seconds of sleep", sleep_time); - /* - Do not send any packets to tinc after we wake up. - The other node probably closed our connection but we still - are holding context information to them. This may happen on - laptops or any other hardware which can be suspended for some time. - Sending any data to node that wasn't expecting it will produce - annoying and misleading errors on the other side about failed signature - verification and or about missing sptps context - */ - close_all_connections = true; + ifdebug(CONNECTIONS) logger(LOG_WARNING, "Timeout from %s (%s) during authentication", + c->name, c->hostname); + + if(c->status.connecting) { + c->status.connecting = false; + closesocket(c->socket); + do_outgoing_connection(c); + } else { + c->status.tarpit = true; + terminate_connection(c, false); + } + } + } + + if(c->outbuflen > 0 && c->last_flushed_time + pingtimeout <= now) { + if(c->status.active) { + ifdebug(CONNECTIONS) logger(LOG_INFO, + "%s (%s) could not flush for %ld seconds (%d bytes remaining)", + c->name, c->hostname, (long)(now - c->last_flushed_time), c->outbuflen); + c->status.timeout = true; + terminate_connection(c, true); + } + } + } +} + +/* + check all connections to see if anything + happened on their sockets +*/ +static void check_network_activity(fd_set *readset, fd_set *writeset) { + connection_t *c; + avl_node_t *node; + int result, i; + socklen_t len = sizeof(result); + vpn_packet_t packet; + static int errors = 0; + + /* check input from kernel */ + if(device_fd >= 0 && FD_ISSET(device_fd, readset)) { + if(devops.read(&packet)) { + if(packet.len) { + errors = 0; + packet.priority = 0; + route(myself, &packet); + } + } else { + usleep(errors * 50000); + errors++; + + if(errors > 10) { + logger(LOG_ERR, "Too many errors from %s, exiting!", device); + running = false; + } + } } - last_periodic_run_time = now; + /* check meta connections */ + for(node = connection_tree->head; node; node = node->next) { + c = node->data; - for list_each(connection_t, c, connection_list) { - // control connections (eg. tinc ctl) do not have any timeout - if(c->status.control) { + if(c->status.remove) { continue; } - if(close_all_connections) { - logger(DEBUG_ALWAYS, LOG_ERR, "Forcing connection close after sleep time %s (%s)", c->name, c->hostname); - terminate_connection(c, c->edge); - continue; - } - - // Bail out early if we haven't reached the ping timeout for this node yet - if(c->last_ping_time + pingtimeout > now.tv_sec) { - continue; - } - - // timeout during connection establishing - if(!c->edge) { + if(FD_ISSET(c->socket, writeset)) { if(c->status.connecting) { - logger(DEBUG_CONNECTIONS, LOG_WARNING, "Timeout while connecting to %s (%s)", c->name, c->hostname); - } else { - logger(DEBUG_CONNECTIONS, LOG_WARNING, "Timeout from %s (%s) during authentication", c->name, c->hostname); + c->status.connecting = false; + getsockopt(c->socket, SOL_SOCKET, SO_ERROR, (void *)&result, &len); + + if(!result) { + finish_connecting(c); + } else { + ifdebug(CONNECTIONS) logger(LOG_DEBUG, + "Error while connecting to %s (%s): %s", + c->name, c->hostname, sockstrerror(result)); + closesocket(c->socket); + do_outgoing_connection(c); + continue; + } + } + + if(!flush_meta(c)) { + terminate_connection(c, c->status.active); + continue; + } + } + + if(FD_ISSET(c->socket, readset)) { + if(!receive_meta(c)) { c->status.tarpit = true; - } - - terminate_connection(c, c->edge); - continue; - } - - // helps in UDP holepunching - try_tx(c->node, false); - - // timeout during ping - if(c->status.pinged) { - logger(DEBUG_CONNECTIONS, LOG_INFO, "%s (%s) didn't respond to PING in %ld seconds", c->name, c->hostname, (long)(now.tv_sec - c->last_ping_time)); - terminate_connection(c, c->edge); - continue; - } - - // check whether we need to send a new ping - if(c->last_ping_time + pinginterval <= now.tv_sec) { - send_ping(c); - } - } - - timeout_set(data, &(struct timeval) { - 1, rand() % 100000 - }); -} - -static void periodic_handler(void *data) { - /* Check if there are too many contradicting ADD_EDGE and DEL_EDGE messages. - This usually only happens when another node has the same Name as this node. - If so, sleep for a short while to prevent a storm of contradicting messages. - */ - - if(contradicting_del_edge > 100 && contradicting_add_edge > 100) { - logger(DEBUG_ALWAYS, LOG_WARNING, "Possible node with same Name as us! Sleeping %d seconds.", sleeptime); - nanosleep(&(struct timespec) { - sleeptime, 0 - }, NULL); - sleeptime *= 2; - - if(sleeptime < 0) { - sleeptime = 3600; - } - } else { - sleeptime /= 2; - - if(sleeptime < 10) { - sleeptime = 10; - } - } - - contradicting_add_edge = 0; - contradicting_del_edge = 0; - - /* If AutoConnect is set, check if we need to make or break connections. */ - - if(autoconnect && node_tree->count > 1) { - do_autoconnect(); - } - - timeout_set(data, &(struct timeval) { - 5, rand() % 100000 - }); -} - -void handle_meta_connection_data(connection_t *c) { - if(!receive_meta(c)) { - if(!c->status.control) { - c->status.tarpit = true; - } - - terminate_connection(c, c->edge); - return; - } -} - -#ifndef HAVE_MINGW -static void sigterm_handler(void *data) { - logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum)); - event_exit(); -} - -static void sighup_handler(void *data) { - logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum)); - reopenlogger(); - - if(reload_configuration()) { - exit(1); - } -} - -static void sigalrm_handler(void *data) { - logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum)); - retry(); -} -#endif - -int reload_configuration(void) { - char fname[PATH_MAX]; - - /* Reread our own configuration file */ - - exit_configuration(&config_tree); - init_configuration(&config_tree); - - if(!read_server_config()) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unable to reread configuration file."); - return EINVAL; - } - - read_config_options(config_tree, NULL); - - snprintf(fname, sizeof(fname), "%s" SLASH "hosts" SLASH "%s", confbase, myself->name); - read_config_file(config_tree, fname, true); - - /* Parse some options that are allowed to be changed while tinc is running */ - - setup_myself_reloadable(); - - /* If StrictSubnet is set, expire deleted Subnets and read new ones in */ - - if(strictsubnets) { - for splay_each(subnet_t, subnet, subnet_tree) - if(subnet->owner) { - subnet->expires = 1; - } - } - - for splay_each(node_t, n, node_tree) { - n->status.has_address = false; - } - - load_all_nodes(); - - if(strictsubnets) { - for splay_each(subnet_t, subnet, subnet_tree) { - if(!subnet->owner) { + terminate_connection(c, c->status.active); continue; } - - if(subnet->expires == 1) { - send_del_subnet(everyone, subnet); - - if(subnet->owner->status.reachable) { - subnet_update(subnet->owner, subnet, false); - } - - subnet_del(subnet->owner, subnet); - } else if(subnet->expires == -1) { - subnet->expires = 0; - } else { - send_add_subnet(everyone, subnet); - - if(subnet->owner->status.reachable) { - subnet_update(subnet->owner, subnet, true); - } - } - } - } else { /* Only read our own subnets back in */ - for splay_each(subnet_t, subnet, myself->subnet_tree) - if(!subnet->expires) { - subnet->expires = 1; - } - - config_t *cfg = lookup_config(config_tree, "Subnet"); - - while(cfg) { - subnet_t *subnet, *s2; - - if(!get_config_subnet(cfg, &subnet)) { - continue; - } - - if((s2 = lookup_subnet(myself, subnet))) { - if(s2->expires == 1) { - s2->expires = 0; - } - - free_subnet(subnet); - } else { - subnet_add(myself, subnet); - send_add_subnet(everyone, subnet); - subnet_update(myself, subnet, true); - } - - cfg = lookup_config_next(config_tree, cfg); - } - - for splay_each(subnet_t, subnet, myself->subnet_tree) { - if(subnet->expires == 1) { - send_del_subnet(everyone, subnet); - subnet_update(myself, subnet, false); - subnet_del(myself, subnet); - } } } - /* Try to make outgoing connections */ - - try_outgoing_connections(); - - /* Close connections to hosts that have a changed or deleted host config file */ - - for list_each(connection_t, c, connection_list) { - if(c->status.control) { - continue; + for(i = 0; i < listen_sockets; i++) { + if(FD_ISSET(listen_socket[i].udp, readset)) { + handle_incoming_vpn_data(i); } - snprintf(fname, sizeof(fname), "%s" SLASH "hosts" SLASH "%s", confbase, c->name); - struct stat s; - - if(stat(fname, &s) || s.st_mtime > last_config_check) { - logger(DEBUG_CONNECTIONS, LOG_INFO, "Host config file of %s has been changed", c->name); - terminate_connection(c, c->edge); + if(FD_ISSET(listen_socket[i].tcp, readset)) { + handle_new_meta_connection(listen_socket[i].tcp); } } - - last_config_check = now.tv_sec; - - return 0; -} - -void retry(void) { - /* Reset the reconnection timers for all outgoing connections */ - for list_each(outgoing_t, outgoing, outgoing_list) { - outgoing->timeout = 0; - - if(outgoing->ev.cb) - timeout_set(&outgoing->ev, &(struct timeval) { - 0, 0 - }); - } - - /* Check for outgoing connections that are in progress, and reset their ping timers */ - for list_each(connection_t, c, connection_list) { - if(c->outgoing && !c->node) { - c->last_ping_time = 0; - } - } - - /* Kick the ping timeout handler */ - timeout_set(&pingtimer, &(struct timeval) { - 0, 0 - }); } /* this is where it all happens... */ int main_loop(void) { - last_periodic_run_time = now; - timeout_add(&pingtimer, timeout_handler, &pingtimer, &(struct timeval) { - pingtimeout, rand() % 100000 - }); - timeout_add(&periodictimer, periodic_handler, &periodictimer, &(struct timeval) { - 0, 0 - }); - -#ifndef HAVE_MINGW - signal_t sighup = {0}; - signal_t sigterm = {0}; - signal_t sigquit = {0}; - signal_t sigint = {0}; - signal_t sigalrm = {0}; - - signal_add(&sighup, sighup_handler, &sighup, SIGHUP); - signal_add(&sigterm, sigterm_handler, &sigterm, SIGTERM); - signal_add(&sigquit, sigterm_handler, &sigquit, SIGQUIT); - signal_add(&sigint, sigterm_handler, &sigint, SIGINT); - signal_add(&sigalrm, sigalrm_handler, &sigalrm, SIGALRM); + fd_set readset, writeset; +#ifdef HAVE_PSELECT + struct timespec tv; + sigset_t omask, block_mask; + time_t next_event; +#else + struct timeval tv; #endif + int r, maxfd; + time_t last_ping_check, last_config_check, last_graph_dump; + event_t *event; - if(!event_loop()) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while waiting for input: %s", sockstrerror(sockerrno)); - return 1; + last_ping_check = now; + last_config_check = now; + last_graph_dump = now; + + srand(now); + +#ifdef HAVE_PSELECT + + if(lookup_config(config_tree, "GraphDumpFile")) { + graph_dump = true; } -#ifndef HAVE_MINGW - signal_del(&sighup); - signal_del(&sigterm); - signal_del(&sigquit); - signal_del(&sigint); - signal_del(&sigalrm); + /* Block SIGHUP & SIGALRM */ + sigemptyset(&block_mask); + sigaddset(&block_mask, SIGHUP); + sigaddset(&block_mask, SIGALRM); + sigprocmask(SIG_BLOCK, &block_mask, &omask); #endif - timeout_del(&periodictimer); - timeout_del(&pingtimer); + running = true; + + while(running) { +#ifdef HAVE_PSELECT + next_event = last_ping_check + pingtimeout; + + if(graph_dump && next_event > last_graph_dump + 60) { + next_event = last_graph_dump + 60; + } + + if((event = peek_next_event()) && next_event > event->time) { + next_event = event->time; + } + + if(next_event <= now) { + tv.tv_sec = 0; + } else { + tv.tv_sec = next_event - now; + } + + tv.tv_nsec = 0; +#else + tv.tv_sec = 1; + tv.tv_usec = 0; +#endif + + maxfd = build_fdset(&readset, &writeset); + +#ifdef HAVE_MINGW + LeaveCriticalSection(&mutex); +#endif +#ifdef HAVE_PSELECT + r = pselect(maxfd + 1, &readset, &writeset, NULL, &tv, &omask); +#else + r = select(maxfd + 1, &readset, &writeset, NULL, &tv); +#endif + now = time(NULL); +#ifdef HAVE_MINGW + EnterCriticalSection(&mutex); +#endif + + if(r < 0) { + if(!sockwouldblock(sockerrno)) { + logger(LOG_ERR, "Error while waiting for input: %s", sockstrerror(sockerrno)); + dump_connections(); + return 1; + } + } + + if(r > 0) { + check_network_activity(&readset, &writeset); + } + + if(do_purge) { + purge(); + do_purge = false; + } + + /* Let's check if everybody is still alive */ + + if(last_ping_check + pingtimeout <= now) { + check_dead_connections(); + last_ping_check = now; + + if(routing_mode == RMODE_SWITCH) { + age_subnets(); + } + + age_past_requests(); + + /* Should we regenerate our key? */ + + if(keyexpires <= now) { + avl_node_t *node; + node_t *n; + + ifdebug(STATUS) logger(LOG_INFO, "Expiring symmetric keys"); + + for(node = node_tree->head; node; node = node->next) { + n = node->data; + + if(n->inkey) { + free(n->inkey); + n->inkey = NULL; + } + } + + send_key_changed(); + keyexpires = now + keylifetime; + } + + /* Detect ADD_EDGE/DEL_EDGE storms that are caused when + * two tinc daemons with the same name are on the VPN. + * If so, sleep a while. If this happens multiple times + * in a row, sleep longer. */ + + if(contradicting_del_edge > 100 && contradicting_add_edge > 100) { + logger(LOG_WARNING, "Possible node with same Name as us! Sleeping %d seconds.", sleeptime); + usleep(sleeptime * 1000000LL); + sleeptime *= 2; + + if(sleeptime < 0) { + sleeptime = 3600; + } + } else { + sleeptime /= 2; + + if(sleeptime < 10) { + sleeptime = 10; + } + } + + contradicting_add_edge = 0; + contradicting_del_edge = 0; + } + + if(sigalrm) { + avl_node_t *node; + logger(LOG_INFO, "Flushing event queue"); + expire_events(); + + for(node = connection_tree->head; node; node = node->next) { + connection_t *c = node->data; + + if(c->status.active) { + send_ping(c); + } + } + + sigalrm = false; + } + + while((event = get_expired_event())) { + event->handler(event->data); + free_event(event); + } + + if(sighup) { + connection_t *c; + avl_node_t *node, *next; + char *fname; + struct stat s; + + sighup = false; + + reopenlogger(); + + /* Reread our own configuration file */ + + exit_configuration(&config_tree); + init_configuration(&config_tree); + + if(!read_server_config()) { + logger(LOG_ERR, "Unable to reread configuration file, exitting."); + return 1; + } + + /* Cancel non-active outgoing connections */ + + for(node = connection_tree->head; node; node = next) { + next = node->next; + c = node->data; + + c->outgoing = NULL; + + if(c->status.connecting) { + terminate_connection(c, false); + connection_del(c); + } + } + + /* Wipe list of outgoing connections */ + + for(list_node_t *node = outgoing_list->head; node; node = node->next) { + outgoing_t *outgoing = node->data; + + if(outgoing->event) { + event_del(outgoing->event); + } + } + + list_delete_list(outgoing_list); + + /* Close connections to hosts that have a changed or deleted host config file */ + + for(node = connection_tree->head; node; node = node->next) { + c = node->data; + + xasprintf(&fname, "%s/hosts/%s", confbase, c->name); + + if(stat(fname, &s) || s.st_mtime > last_config_check) { + terminate_connection(c, c->status.active); + } + + free(fname); + } + + last_config_check = now; + + /* If StrictSubnet is set, expire deleted Subnets and read new ones in */ + + if(strictsubnets) { + subnet_t *subnet; + + for(node = subnet_tree->head; node; node = node->next) { + subnet = node->data; + subnet->expires = 1; + } + + load_all_subnets(); + + for(node = subnet_tree->head; node; node = next) { + next = node->next; + subnet = node->data; + + if(subnet->expires == 1) { + send_del_subnet(everyone, subnet); + + if(subnet->owner->status.reachable) { + subnet_update(subnet->owner, subnet, false); + } + + subnet_del(subnet->owner, subnet); + } else if(subnet->expires == -1) { + subnet->expires = 0; + } else { + send_add_subnet(everyone, subnet); + + if(subnet->owner->status.reachable) { + subnet_update(subnet->owner, subnet, true); + } + } + } + } + + /* Try to make outgoing connections */ + + try_outgoing_connections(); + } + + /* Dump graph if wanted every 60 seconds*/ + + if(last_graph_dump + 60 <= now) { + dump_graph(); + last_graph_dump = now; + } + } + +#ifdef HAVE_PSELECT + /* Restore SIGHUP & SIGALARM mask */ + sigprocmask(SIG_SETMASK, &omask, NULL); +#endif return 0; } diff --git a/src/net.h b/src/net.h index 8a74d85..a9becb6 100644 --- a/src/net.h +++ b/src/net.h @@ -4,7 +4,7 @@ /* net.h -- header for net.c Copyright (C) 1998-2005 Ivo Timmermans - 2000-2016 Guus Sliepen + 2000-2015 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,10 +21,9 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include + #include "ipv6.h" -#include "cipher.h" -#include "digest.h" -#include "event.h" #ifdef ENABLE_JUMBOGRAMS #define MTU 9018 /* 9000 bytes payload + 14 bytes ethernet header + 4 bytes VLAN tag */ @@ -32,13 +31,10 @@ #define MTU 1518 /* 1500 bytes payload + 14 bytes ethernet header + 4 bytes VLAN tag */ #endif -/* MAXSIZE is the maximum size of an encapsulated packet: MTU + seqno + srcid + dstid + padding + HMAC + compressor overhead */ -#define MAXSIZE (MTU + 4 + sizeof(node_id_t) + sizeof(node_id_t) + CIPHER_MAX_BLOCK_SIZE + DIGEST_MAX_SIZE + MTU/64 + 20) +#define MAXSIZE (MTU + 4 + EVP_MAX_BLOCK_LENGTH + EVP_MAX_MD_SIZE + MTU/64 + 20) /* MTU + seqno + padding + HMAC + compressor overhead */ +#define MAXBUFSIZE ((MAXSIZE > 2048 ? MAXSIZE : 2048) + 128) /* Enough room for a request with a MAXSIZEd packet or a 8192 bits RSA key */ -/* MAXBUFSIZE is the maximum size of a request: enough for a MAXSIZEd packet or a 8192 bits RSA key */ -#define MAXBUFSIZE ((MAXSIZE > 2048 ? MAXSIZE : 2048) + 128) - -#define MAXSOCKETS 8 /* Probably overkill... */ +#define MAXSOCKETS 128 /* Overkill... */ typedef struct mac_t { uint8_t x[6]; @@ -52,12 +48,7 @@ typedef struct ipv6_t { uint16_t x[8]; } ipv6_t; -typedef struct node_id_t { - uint8_t x[6]; -} node_id_t; - typedef uint16_t length_t; -typedef uint32_t seqno_t; #define AF_UNKNOWN 255 @@ -74,6 +65,9 @@ typedef union sockaddr_t { struct sockaddr_in in; struct sockaddr_in6 in6; struct sockaddr_unknown unknown; +#ifdef HAVE_STRUCT_SOCKADDR_STORAGE + struct sockaddr_storage storage; +#endif } sockaddr_t; #ifdef SA_LEN @@ -82,36 +76,17 @@ typedef union sockaddr_t { #define SALEN(s) (s.sa_family==AF_INET?sizeof(struct sockaddr_in):sizeof(struct sockaddr_in6)) #endif -#define SEQNO(x) ((x)->data + (x)->offset - 4) -#define SRCID(x) ((node_id_t *)((x)->data + (x)->offset - 6)) -#define DSTID(x) ((node_id_t *)((x)->data + (x)->offset - 12)) -#define DATA(x) ((x)->data + (x)->offset) -#define DEFAULT_PACKET_OFFSET 12 - typedef struct vpn_packet_t { - length_t len; /* The actual number of valid bytes in the `data' field (including seqno or dstid/srcid) */ - length_t offset; /* Offset in the buffer where the packet data starts (righter after seqno or dstid/srcid) */ + length_t len; /* the actual number of bytes in the `data' field */ int priority; /* priority or TOS */ + uint32_t seqno; /* 32 bits sequence number (network byte order of course) */ uint8_t data[MAXSIZE]; } vpn_packet_t; -/* Packet types when using SPTPS */ - -#define PKT_COMPRESSED 1 -#define PKT_MAC 2 -#define PKT_PROBE 4 - -typedef enum packet_type_t { - PACKET_NORMAL, - PACKET_COMPRESSED, - PACKET_PROBE -} packet_type_t; - typedef struct listen_socket_t { - io_t tcp; - io_t udp; + int tcp; + int udp; sockaddr_t sa; - bool bindto; int priority; } listen_socket_t; @@ -119,10 +94,12 @@ typedef struct listen_socket_t { #include "list.h" typedef struct outgoing_t { - struct node_t *node; + char *name; int timeout; - struct address_cache_t *address_cache; - timeout_t ev; + struct config_t *cfg; + struct addrinfo *ai; + struct addrinfo *aip; + struct event *event; } outgoing_t; extern list_t *outgoing_list; @@ -133,91 +110,52 @@ extern int addressfamily; extern unsigned replaywin; extern bool localdiscovery; -extern bool udp_discovery; -extern int udp_discovery_keepalive_interval; -extern int udp_discovery_interval; -extern int udp_discovery_timeout; - -extern int mtu_info_interval; -extern int udp_info_interval; - extern listen_socket_t listen_socket[MAXSOCKETS]; extern int listen_sockets; -extern io_t unix_socket; +extern int keyexpires; extern int keylifetime; extern int udp_rcvbuf; extern int udp_sndbuf; -extern int max_connection_burst; -extern int fwmark; extern bool do_prune; +extern bool do_purge; extern char *myport; -extern bool device_standby; -extern bool autoconnect; -extern bool disablebuggypeers; +extern time_t now; extern int contradicting_add_edge; extern int contradicting_del_edge; -extern time_t last_config_check; -extern char *proxyhost; -extern char *proxyport; -extern char *proxyuser; -extern char *proxypass; -typedef enum proxytype_t { - PROXY_NONE = 0, - PROXY_SOCKS4, - PROXY_SOCKS4A, - PROXY_SOCKS5, - PROXY_HTTP, - PROXY_EXEC, -} proxytype_t; -extern proxytype_t proxytype; - -extern char *scriptinterpreter; -extern char *scriptextension; +extern volatile bool running; /* Yes, very strange placement indeed, but otherwise the typedefs get all tangled up */ #include "connection.h" #include "node.h" extern void retry_outgoing(outgoing_t *outgoing); -extern void handle_incoming_vpn_data(void *data, int flags); +extern void handle_incoming_vpn_data(int sock); extern void finish_connecting(struct connection_t *c); -extern bool do_outgoing_connection(struct outgoing_t *outgoing); -extern void handle_new_meta_connection(void *data, int flags); -extern void handle_new_unix_connection(void *data, int flags); +extern void do_outgoing_connection(struct connection_t *c); +extern bool handle_new_meta_connection(int sock); extern int setup_listen_socket(const sockaddr_t *sa); extern int setup_vpn_in_socket(const sockaddr_t *sa); -extern bool send_sptps_data(node_t *to, node_t *from, int type, const void *data, size_t len); -extern bool receive_sptps_record(void *handle, uint8_t type, const void *data, uint16_t len); -extern void send_packet(struct node_t *n, vpn_packet_t *packet); -extern void receive_tcppacket(struct connection_t *c, const char *buffer, size_t length); -extern bool receive_tcppacket_sptps(struct connection_t *c, const char *buffer, size_t length); -extern void broadcast_packet(const struct node_t *n, vpn_packet_t *packet); +extern void send_packet(const struct node_t *n, vpn_packet_t *packet); +extern void receive_tcppacket(struct connection_t *c, const char *buffer, length_t len); +extern void broadcast_packet(const struct node_t *, vpn_packet_t *packet); extern char *get_name(void); -extern void device_enable(void); -extern void device_disable(void); -extern bool setup_myself_reloadable(void); extern bool setup_network(void); -extern void setup_outgoing_connection(struct outgoing_t *outgoing, bool verbose); +extern void setup_outgoing_connection(struct outgoing_t *outgoing); extern void try_outgoing_connections(void); extern void close_network_connections(void); extern int main_loop(void); extern void terminate_connection(struct connection_t *c, bool report); -extern bool node_read_ecdsa_public_key(struct node_t *n); -extern bool read_ecdsa_public_key(struct connection_t *c); +extern void flush_queue(struct node_t *n); extern bool read_rsa_public_key(struct connection_t *c); -extern void handle_device_data(void *data, int flags); -extern void handle_meta_connection_data(struct connection_t *c); -extern void regenerate_key(void); -extern void purge(void); -extern void retry(void); -extern int reload_configuration(void); -extern void load_all_nodes(void); -extern void try_tx(struct node_t *n, bool mtu); +extern void send_mtu_probe(struct node_t *n); +extern void load_all_subnets(void); extern void tarpit(int fd); #ifndef HAVE_MINGW #define closesocket(s) close(s) +#else +extern CRITICAL_SECTION mutex; #endif #endif diff --git a/src/net_packet.c b/src/net_packet.c index 6b40f2a..938b3b6 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -1,7 +1,7 @@ /* net_packet.c -- Handles in- and outgoing VPN packets Copyright (C) 1998-2005 Ivo Timmermans, - 2000-2017 Guus Sliepen + 2000-2016 Guus Sliepen 2010 Timothy Redaelli 2010 Brandon Black @@ -22,8 +22,13 @@ #include "system.h" +#include +#include +#include +#include +#include + #ifdef HAVE_ZLIB -#define ZLIB_CONST #include #endif @@ -31,56 +36,84 @@ #include LZO1X_H #endif -#include "address_cache.h" -#include "cipher.h" +#include "avl_tree.h" #include "conf.h" #include "connection.h" -#include "crypto.h" -#include "digest.h" #include "device.h" #include "ethernet.h" -#include "ipv4.h" -#include "ipv6.h" +#include "event.h" #include "graph.h" #include "logger.h" #include "net.h" #include "netutl.h" #include "protocol.h" +#include "process.h" #include "route.h" #include "utils.h" #include "xalloc.h" -#ifndef MAX -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#endif - -/* The minimum size of a probe is 14 bytes, but since we normally use CBC mode - encryption, we can add a few extra random bytes without increasing the - resulting packet size. */ -#define MIN_PROBE_SIZE 18 - int keylifetime = 0; +int keyexpires = 0; #ifdef HAVE_LZO static char lzo_wrkmem[LZO1X_999_MEM_COMPRESS > LZO1X_1_MEM_COMPRESS ? LZO1X_999_MEM_COMPRESS : LZO1X_1_MEM_COMPRESS]; #endif static void send_udppacket(node_t *, vpn_packet_t *); -unsigned replaywin = 32; -bool localdiscovery = true; -bool udp_discovery = true; -int udp_discovery_keepalive_interval = 10; -int udp_discovery_interval = 2; -int udp_discovery_timeout = 30; +unsigned replaywin = 16; +bool localdiscovery = false; #define MAX_SEQNO 1073741824 -static void try_fix_mtu(node_t *n) { - if(n->mtuprobes < 0) { +/* mtuprobes == 1..30: initial discovery, send bursts with 1 second interval + mtuprobes == 31: sleep pinginterval seconds + mtuprobes == 32: send 1 burst, sleep pingtimeout second + mtuprobes == 33: no response from other side, restart PMTU discovery process + + Probes are sent in batches of at least three, with random sizes between the + lower and upper boundaries for the MTU thus far discovered. + + After the initial discovery, a fourth packet is added to each batch with a + size larger than the currently known PMTU, to test if the PMTU has increased. + + In case local discovery is enabled, another packet is added to each batch, + which will be broadcast to the local network. + +*/ + +void send_mtu_probe(node_t *n) { + vpn_packet_t packet; + int len, i; + int timeout = 1; + + n->mtuprobes++; + n->mtuevent = NULL; + + if(!n->status.reachable || !n->status.validkey) { + ifdebug(TRAFFIC) logger(LOG_INFO, "Trying to send MTU probe to unreachable or rekeying node %s (%s)", n->name, n->hostname); + n->mtuprobes = 0; return; } - if(n->mtuprobes == 20 || n->minmtu >= n->maxmtu) { + if(n->mtuprobes > 32) { + if(!n->minmtu) { + n->mtuprobes = 31; + timeout = pinginterval; + goto end; + } + + ifdebug(TRAFFIC) logger(LOG_INFO, "%s (%s) did not respond to UDP ping, restarting PMTU discovery", n->name, n->hostname); + n->mtuprobes = 1; + n->minmtu = 0; + n->maxmtu = MTU; + } + + if(n->mtuprobes >= 10 && n->mtuprobes < 32 && !n->minmtu) { + ifdebug(TRAFFIC) logger(LOG_INFO, "No response to MTU probes from %s (%s)", n->name, n->hostname); + n->mtuprobes = 31; + } + + if(n->mtuprobes == 30 || (n->mtuprobes < 30 && n->minmtu >= n->maxmtu)) { if(n->minmtu > n->maxmtu) { n->minmtu = n->maxmtu; } else { @@ -88,121 +121,86 @@ static void try_fix_mtu(node_t *n) { } n->mtu = n->minmtu; - logger(DEBUG_TRAFFIC, LOG_INFO, "Fixing MTU of %s (%s) to %d after %d probes", n->name, n->hostname, n->mtu, n->mtuprobes); - n->mtuprobes = -1; - } -} - -static void udp_probe_timeout_handler(void *data) { - node_t *n = data; - - if(!n->status.udp_confirmed) { - return; + ifdebug(TRAFFIC) logger(LOG_INFO, "Fixing MTU of %s (%s) to %d after %d probes", n->name, n->hostname, n->mtu, n->mtuprobes); + n->mtuprobes = 31; } - logger(DEBUG_TRAFFIC, LOG_INFO, "Too much time has elapsed since last UDP ping response from %s (%s), stopping UDP communication", n->name, n->hostname); - n->status.udp_confirmed = false; - n->udp_ping_rtt = -1; - n->maxrecentlen = 0; - n->mtuprobes = 0; - n->minmtu = 0; - n->maxmtu = MTU; -} - -static void send_udp_probe_reply(node_t *n, vpn_packet_t *packet, length_t len) { - if(!n->status.sptps && !n->status.validkey) { - logger(DEBUG_TRAFFIC, LOG_INFO, "Trying to send UDP probe reply to %s (%s) but we don't have his key yet", n->name, n->hostname); - return; + if(n->mtuprobes == 31) { + timeout = pinginterval; + goto end; + } else if(n->mtuprobes == 32) { + timeout = pingtimeout; } - /* Type 2 probe replies were introduced in protocol 17.3 */ - if((n->options >> 24) >= 3) { - DATA(packet)[0] = 2; - uint16_t len16 = htons(len); - memcpy(DATA(packet) + 1, &len16, 2); - packet->len = MIN_PROBE_SIZE; - logger(DEBUG_TRAFFIC, LOG_INFO, "Sending type 2 probe reply length %u to %s (%s)", len, n->name, n->hostname); + for(i = 0; i < 4 + localdiscovery; i++) { + if(i == 0) { + if(n->mtuprobes < 30 || n->maxmtu + 8 >= MTU) { + continue; + } - } else { - /* Legacy protocol: n won't understand type 2 probe replies. */ - DATA(packet)[0] = 1; - logger(DEBUG_TRAFFIC, LOG_INFO, "Sending type 1 probe reply length %u to %s (%s)", len, n->name, n->hostname); - } - - /* Temporarily set udp_confirmed, so that the reply is sent - back exactly the way it came in. */ - - bool udp_confirmed = n->status.udp_confirmed; - n->status.udp_confirmed = true; - send_udppacket(n, packet); - n->status.udp_confirmed = udp_confirmed; -} - -static void udp_probe_h(node_t *n, vpn_packet_t *packet, length_t len) { - if(!DATA(packet)[0]) { - logger(DEBUG_TRAFFIC, LOG_INFO, "Got UDP probe request %d from %s (%s)", packet->len, n->name, n->hostname); - send_udp_probe_reply(n, packet, len); - return; - } - - if(DATA(packet)[0] == 2) { - // It's a type 2 probe reply, use the length field inside the packet - uint16_t len16; - memcpy(&len16, DATA(packet) + 1, 2); - len = ntohs(len16); - } - - if(n->udp_ping_sent.tv_sec != 0) { // a probe in flight - gettimeofday(&now, NULL); - struct timeval rtt; - timersub(&now, &n->udp_ping_sent, &rtt); - n->udp_ping_rtt = rtt.tv_sec * 1000000 + rtt.tv_usec; - logger(DEBUG_TRAFFIC, LOG_INFO, "Got type %d UDP probe reply %d from %s (%s) rtt=%d.%03d", DATA(packet)[0], len, n->name, n->hostname, n->udp_ping_rtt / 1000, n->udp_ping_rtt % 1000); - } else { - logger(DEBUG_TRAFFIC, LOG_INFO, "Got type %d UDP probe reply %d from %s (%s)", DATA(packet)[0], len, n->name, n->hostname); - } - - /* It's a valid reply: now we know bidirectional communication - is possible using the address and socket that the reply - packet used. */ - if(!n->status.udp_confirmed) { - n->status.udp_confirmed = true; - - if(!n->address_cache) { - n->address_cache = open_address_cache(n); + len = n->maxmtu + 8; + } else if(n->maxmtu <= n->minmtu) { + len = n->maxmtu; + } else { + len = n->minmtu + 1 + rand() % (n->maxmtu - n->minmtu); } - reset_address_cache(n->address_cache, &n->address); + if(len < 64) { + len = 64; + } + + memset(packet.data, 0, 14); + RAND_bytes(packet.data + 14, len - 14); + packet.len = len; + + if(i >= 4 && n->mtuprobes <= 10) { + packet.priority = -1; + } else { + packet.priority = 0; + } + + ifdebug(TRAFFIC) logger(LOG_INFO, "Sending MTU probe length %d to %s (%s)", len, n->name, n->hostname); + + send_udppacket(n, &packet); } - // Reset the UDP ping timer. (no probe in flight) - n->udp_ping_sent.tv_sec = 0; +end: + n->mtuevent = new_event(); + n->mtuevent->handler = (event_handler_t)send_mtu_probe; + n->mtuevent->data = n; + n->mtuevent->time = now + timeout; + event_add(n->mtuevent); +} - if(udp_discovery) { - timeout_del(&n->udp_ping_timeout); - timeout_add(&n->udp_ping_timeout, &udp_probe_timeout_handler, n, &(struct timeval) { - udp_discovery_timeout, 0 - }); - } +void mtu_probe_h(node_t *n, vpn_packet_t *packet, length_t len) { + ifdebug(TRAFFIC) logger(LOG_INFO, "Got MTU probe length %d from %s (%s)", packet->len, n->name, n->hostname); - if(len > n->maxmtu) { - logger(DEBUG_TRAFFIC, LOG_INFO, "Increase in PMTU to %s (%s) detected, restarting PMTU discovery", n->name, n->hostname); - n->minmtu = len; - n->maxmtu = MTU; - /* Set mtuprobes to 1 so that try_mtu() doesn't reset maxmtu */ - n->mtuprobes = 1; - return; - } else if(n->mtuprobes < 0 && len == n->maxmtu) { - /* We got a maxmtu sized packet, confirming the PMTU is still valid. */ - n->mtuprobes = -1; - n->mtu_ping_sent = now; - } + if(!packet->data[0]) { + packet->data[0] = 1; + send_udppacket(n, packet); + } else { + if(n->mtuprobes > 30) { + if(len == n->maxmtu + 8) { + ifdebug(TRAFFIC) logger(LOG_INFO, "Increase in PMTU to %s (%s) detected, restarting PMTU discovery", n->name, n->hostname); + n->maxmtu = MTU; + n->mtuprobes = 10; + return; + } - /* If applicable, raise the minimum supported MTU */ + if(n->minmtu) { + n->mtuprobes = 30; + } else { + n->mtuprobes = 1; + } + } - if(n->minmtu < len) { - n->minmtu = len; - try_fix_mtu(n); + if(len > n->maxmtu) { + len = n->maxmtu; + } + + if(n->minmtu < len) { + n->minmtu = len; + } } } @@ -258,22 +256,9 @@ static length_t uncompress_packet(uint8_t *dest, const uint8_t *source, length_t #ifdef HAVE_ZLIB else { unsigned long destlen = MAXSIZE; - static z_stream stream; - if(stream.next_in) { - inflateReset(&stream); - } else { - inflateInit(&stream); - } - - stream.next_in = source; - stream.avail_in = len; - stream.next_out = dest; - stream.avail_out = destlen; - stream.total_out = 0; - - if(inflate(&stream, Z_FINISH) == Z_STREAM_END) { - return stream.total_out; + if(uncompress(dest, &destlen, source, len) == Z_OK) { + return destlen; } else { return 0; } @@ -281,169 +266,124 @@ static length_t uncompress_packet(uint8_t *dest, const uint8_t *source, length_t #endif - return 0; + return -1; } /* VPN packet I/O */ static void receive_packet(node_t *n, vpn_packet_t *packet) { - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Received packet of %d bytes from %s (%s)", - packet->len, n->name, n->hostname); - - n->in_packets++; - n->in_bytes += packet->len; + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Received packet of %d bytes from %s (%s)", + packet->len, n->name, n->hostname); route(n, packet); } -static bool try_mac(node_t *n, const vpn_packet_t *inpkt) { - if(n->status.sptps) { - return sptps_verify_datagram(&n->sptps, DATA(inpkt), inpkt->len); - } +static bool try_mac(const node_t *n, const vpn_packet_t *inpkt) { + unsigned char hmac[EVP_MAX_MD_SIZE]; -#ifdef DISABLE_LEGACY - return false; -#else - - if(!n->status.validkey_in || !digest_active(n->indigest) || (size_t)inpkt->len < sizeof(seqno_t) + digest_length(n->indigest)) { + if(!n->indigest || !n->inmaclength || !n->inkey || inpkt->len < sizeof(inpkt->seqno) + n->inmaclength) { return false; } - return digest_verify(n->indigest, inpkt->data, inpkt->len - digest_length(n->indigest), inpkt->data + inpkt->len - digest_length(n->indigest)); -#endif + HMAC(n->indigest, n->inkey, n->inkeylength, (unsigned char *) &inpkt->seqno, inpkt->len - n->inmaclength, (unsigned char *)hmac, NULL); + + return !memcmp_constant_time(hmac, (char *) &inpkt->seqno + inpkt->len - n->inmaclength, n->inmaclength); } -static bool receive_udppacket(node_t *n, vpn_packet_t *inpkt) { +static void receive_udppacket(node_t *n, vpn_packet_t *inpkt) { vpn_packet_t pkt1, pkt2; vpn_packet_t *pkt[] = { &pkt1, &pkt2, &pkt1, &pkt2 }; int nextpkt = 0; - size_t outlen; - pkt1.offset = DEFAULT_PACKET_OFFSET; - pkt2.offset = DEFAULT_PACKET_OFFSET; + vpn_packet_t *outpkt; + int outlen, outpad; + unsigned char hmac[EVP_MAX_MD_SIZE]; - if(n->status.sptps) { - if(!n->sptps.state) { - if(!n->status.waitingforkey) { - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Got packet from %s (%s) but we haven't exchanged keys yet", n->name, n->hostname); - send_req_key(n); - } else { - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Got packet from %s (%s) but he hasn't got our key yet", n->name, n->hostname); - } - - return false; - } - - n->status.udppacket = true; - bool result = sptps_receive_data(&n->sptps, DATA(inpkt), inpkt->len); - n->status.udppacket = false; - - if(!result) { - /* Uh-oh. It might be that the tunnel is stuck in some corrupted state, - so let's restart SPTPS in case that helps. But don't do that too often - to prevent storms, and because that would make life a little too easy - for external attackers trying to DoS us. */ - if(n->last_req_key < now.tv_sec - 10) { - logger(DEBUG_PROTOCOL, LOG_ERR, "Failed to decode raw TCP packet from %s (%s), restarting SPTPS", n->name, n->hostname); - send_req_key(n); - } - - return false; - } - - return true; - } - -#ifdef DISABLE_LEGACY - return false; -#else - - if(!n->status.validkey_in) { - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Got packet from %s (%s) but he hasn't got our key yet", n->name, n->hostname); - return false; + if(!n->inkey) { + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Got packet from %s (%s) but he hasn't got our key yet", + n->name, n->hostname); + return; } /* Check packet length */ - if((size_t)inpkt->len < sizeof(seqno_t) + digest_length(n->indigest)) { - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Got too short packet from %s (%s)", - n->name, n->hostname); - return false; + if(inpkt->len < sizeof(inpkt->seqno) + n->inmaclength) { + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Got too short packet from %s (%s)", + n->name, n->hostname); + return; } - /* It's a legacy UDP packet, the data starts after the seqno */ - - inpkt->offset += sizeof(seqno_t); - /* Check the message authentication code */ - if(digest_active(n->indigest)) { - inpkt->len -= digest_length(n->indigest); + if(n->indigest && n->inmaclength) { + inpkt->len -= n->inmaclength; + HMAC(n->indigest, n->inkey, n->inkeylength, + (unsigned char *) &inpkt->seqno, inpkt->len, (unsigned char *)hmac, NULL); - if(!digest_verify(n->indigest, SEQNO(inpkt), inpkt->len, SEQNO(inpkt) + inpkt->len)) { - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Got unauthenticated packet from %s (%s)", n->name, n->hostname); - return false; + if(memcmp_constant_time(hmac, (char *) &inpkt->seqno + inpkt->len, n->inmaclength)) { + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Got unauthenticated packet from %s (%s)", + n->name, n->hostname); + return; } } /* Decrypt the packet */ - if(cipher_active(n->incipher)) { - vpn_packet_t *outpkt = pkt[nextpkt++]; - outlen = MAXSIZE; + if(n->incipher) { + outpkt = pkt[nextpkt++]; - if(!cipher_decrypt(n->incipher, SEQNO(inpkt), inpkt->len, SEQNO(outpkt), &outlen, true)) { - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Error decrypting packet from %s (%s)", n->name, n->hostname); - return false; + if(!EVP_DecryptInit_ex(n->inctx, NULL, NULL, NULL, NULL) + || !EVP_DecryptUpdate(n->inctx, (unsigned char *) &outpkt->seqno, &outlen, + (unsigned char *) &inpkt->seqno, inpkt->len) + || !EVP_DecryptFinal_ex(n->inctx, (unsigned char *) &outpkt->seqno + outlen, &outpad)) { + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Error decrypting packet from %s (%s): %s", + n->name, n->hostname, ERR_error_string(ERR_get_error(), NULL)); + return; } - outpkt->len = outlen; + outpkt->len = outlen + outpad; inpkt = outpkt; } /* Check the sequence number */ - seqno_t seqno; - memcpy(&seqno, SEQNO(inpkt), sizeof(seqno)); - seqno = ntohl(seqno); - inpkt->len -= sizeof(seqno); + inpkt->len -= sizeof(inpkt->seqno); + inpkt->seqno = ntohl(inpkt->seqno); if(replaywin) { - if(seqno != n->received_seqno + 1) { - if(seqno >= n->received_seqno + replaywin * 8) { + if(inpkt->seqno != n->received_seqno + 1) { + if(inpkt->seqno >= n->received_seqno + replaywin * 8) { if(n->farfuture++ < replaywin >> 2) { - logger(DEBUG_TRAFFIC, LOG_WARNING, "Packet from %s (%s) is %d seqs in the future, dropped (%u)", - n->name, n->hostname, seqno - n->received_seqno - 1, n->farfuture); - return false; + ifdebug(TRAFFIC) logger(LOG_WARNING, "Packet from %s (%s) is %d seqs in the future, dropped (%u)", + n->name, n->hostname, inpkt->seqno - n->received_seqno - 1, n->farfuture); + return; } - logger(DEBUG_TRAFFIC, LOG_WARNING, "Lost %d packets from %s (%s)", - seqno - n->received_seqno - 1, n->name, n->hostname); + ifdebug(TRAFFIC) logger(LOG_WARNING, "Lost %d packets from %s (%s)", + inpkt->seqno - n->received_seqno - 1, n->name, n->hostname); memset(n->late, 0, replaywin); - } else if(seqno <= n->received_seqno) { - if((n->received_seqno >= replaywin * 8 && seqno <= n->received_seqno - replaywin * 8) || !(n->late[(seqno / 8) % replaywin] & (1 << seqno % 8))) { - logger(DEBUG_TRAFFIC, LOG_WARNING, "Got late or replayed packet from %s (%s), seqno %d, last received %d", - n->name, n->hostname, seqno, n->received_seqno); - return false; + } else if(inpkt->seqno <= n->received_seqno) { + if((n->received_seqno >= replaywin * 8 && inpkt->seqno <= n->received_seqno - replaywin * 8) || !(n->late[(inpkt->seqno / 8) % replaywin] & (1 << inpkt->seqno % 8))) { + ifdebug(TRAFFIC) logger(LOG_WARNING, "Got late or replayed packet from %s (%s), seqno %d, last received %d", + n->name, n->hostname, inpkt->seqno, n->received_seqno); + return; } } else { - for(seqno_t i = n->received_seqno + 1; i < seqno; i++) { + for(uint32_t i = n->received_seqno + 1; i < inpkt->seqno; i++) { n->late[(i / 8) % replaywin] |= 1 << i % 8; } } } n->farfuture = 0; - n->late[(seqno / 8) % replaywin] &= ~(1 << seqno % 8); + n->late[(inpkt->seqno / 8) % replaywin] &= ~(1 << inpkt->seqno % 8); } - if(seqno > n->received_seqno) { - n->received_seqno = seqno; + if(inpkt->seqno > n->received_seqno) { + n->received_seqno = inpkt->seqno; } - n->received++; - if(n->received_seqno > MAX_SEQNO) { - regenerate_key(); + keyexpires = 0; } /* Decompress the packet */ @@ -451,44 +391,32 @@ static bool receive_udppacket(node_t *n, vpn_packet_t *inpkt) { length_t origlen = inpkt->len; if(n->incompression) { - vpn_packet_t *outpkt = pkt[nextpkt++]; + outpkt = pkt[nextpkt++]; - if(!(outpkt->len = uncompress_packet(DATA(outpkt), DATA(inpkt), inpkt->len, n->incompression))) { - logger(DEBUG_TRAFFIC, LOG_ERR, "Error while uncompressing packet from %s (%s)", - n->name, n->hostname); - return false; + if(!(outpkt->len = uncompress_packet(outpkt->data, inpkt->data, inpkt->len, n->incompression))) { + ifdebug(TRAFFIC) logger(LOG_ERR, "Error while uncompressing packet from %s (%s)", + n->name, n->hostname); + return; } inpkt = outpkt; - if(origlen > MTU / 64 + 20) { - origlen -= MTU / 64 + 20; - } else { - origlen = 0; - } - } - - if(inpkt->len > n->maxrecentlen) { - n->maxrecentlen = inpkt->len; + origlen -= MTU / 64 + 20; } inpkt->priority = 0; - if(!DATA(inpkt)[12] && !DATA(inpkt)[13]) { - udp_probe_h(n, inpkt, origlen); + if(!inpkt->data[12] && !inpkt->data[13]) { + mtu_probe_h(n, inpkt, origlen); } else { receive_packet(n, inpkt); } - - return true; -#endif } -void receive_tcppacket(connection_t *c, const char *buffer, size_t len) { +void receive_tcppacket(connection_t *c, const char *buffer, length_t len) { vpn_packet_t outpkt; - outpkt.offset = DEFAULT_PACKET_OFFSET; - if(len > sizeof(outpkt.data) - outpkt.offset) { + if(len > sizeof(outpkt.data)) { return; } @@ -500,244 +428,47 @@ void receive_tcppacket(connection_t *c, const char *buffer, size_t len) { outpkt.priority = -1; } - memcpy(DATA(&outpkt), buffer, len); + memcpy(outpkt.data, buffer, len); receive_packet(c->node, &outpkt); } -bool receive_tcppacket_sptps(connection_t *c, const char *data, size_t len) { - if(len < sizeof(node_id_t) + sizeof(node_id_t)) { - logger(DEBUG_PROTOCOL, LOG_ERR, "Got too short TCP SPTPS packet from %s (%s)", c->name, c->hostname); - return false; - } - - node_t *to = lookup_node_id((node_id_t *)data); - data += sizeof(node_id_t); - len -= sizeof(node_id_t); - - if(!to) { - logger(DEBUG_PROTOCOL, LOG_ERR, "Got TCP SPTPS packet from %s (%s) with unknown destination ID", c->name, c->hostname); - return true; - } - - node_t *from = lookup_node_id((node_id_t *)data); - data += sizeof(node_id_t); - len -= sizeof(node_id_t); - - if(!from) { - logger(DEBUG_PROTOCOL, LOG_ERR, "Got TCP SPTPS packet from %s (%s) with unknown source ID", c->name, c->hostname); - return true; - } - - if(!to->status.reachable) { - /* This can happen in the form of a race condition - if the node just became unreachable. */ - logger(DEBUG_TRAFFIC, LOG_WARNING, "Cannot relay TCP packet from %s (%s) because the destination, %s (%s), is unreachable", from->name, from->hostname, to->name, to->hostname); - return true; - } - - /* Help the sender reach us over UDP. - Note that we only do this if we're the destination or the static relay; - otherwise every hop would initiate its own UDP info message, resulting in elevated chatter. */ - if(to->via == myself) { - send_udp_info(myself, from); - } - - /* If we're not the final recipient, relay the packet. */ - - if(to != myself) { - send_sptps_data(to, from, 0, data, len); - try_tx(to, true); - return true; - } - - /* The packet is for us */ - - if(!sptps_receive_data(&from->sptps, data, len)) { - /* Uh-oh. It might be that the tunnel is stuck in some corrupted state, - so let's restart SPTPS in case that helps. But don't do that too often - to prevent storms. */ - if(from->last_req_key < now.tv_sec - 10) { - logger(DEBUG_PROTOCOL, LOG_ERR, "Failed to decode raw TCP packet from %s (%s), restarting SPTPS", from->name, from->hostname); - send_req_key(from); - } - - return true; - } - - send_mtu_info(myself, from, MTU); - return true; -} - -static void send_sptps_packet(node_t *n, vpn_packet_t *origpkt) { - if(!n->status.validkey && !n->connection) { - return; - } - - uint8_t type = 0; - int offset = 0; - - if((!(DATA(origpkt)[12] | DATA(origpkt)[13])) && (n->sptps.outstate)) { - sptps_send_record(&n->sptps, PKT_PROBE, (char *)DATA(origpkt), origpkt->len); - return; - } - - if(routing_mode == RMODE_ROUTER) { - offset = 14; - } else { - type = PKT_MAC; - } - - if(origpkt->len < offset) { - return; - } - - vpn_packet_t outpkt; - - if(n->outcompression) { - outpkt.offset = 0; - length_t len = compress_packet(DATA(&outpkt) + offset, DATA(origpkt) + offset, origpkt->len - offset, n->outcompression); - - if(!len) { - logger(DEBUG_TRAFFIC, LOG_ERR, "Error while compressing packet to %s (%s)", n->name, n->hostname); - } else if(len < origpkt->len - offset) { - outpkt.len = len + offset; - origpkt = &outpkt; - type |= PKT_COMPRESSED; - } - } - - /* If we have a direct metaconnection to n, and we can't use UDP, then - don't bother with SPTPS and just use a "plaintext" PACKET message. - We don't really care about end-to-end security since we're not - sending the message through any intermediate nodes. */ - if(n->connection && origpkt->len > n->minmtu) { - send_tcppacket(n->connection, origpkt); - } else { - sptps_send_record(&n->sptps, type, DATA(origpkt) + offset, origpkt->len - offset); - } - - return; -} - -static void adapt_socket(const sockaddr_t *sa, int *sock) { - /* Make sure we have a suitable socket for the chosen address */ - if(listen_socket[*sock].sa.sa.sa_family != sa->sa.sa_family) { - for(int i = 0; i < listen_sockets; i++) { - if(listen_socket[i].sa.sa.sa_family == sa->sa.sa_family) { - *sock = i; - break; - } - } - } -} - -static void choose_udp_address(const node_t *n, const sockaddr_t **sa, int *sock) { - /* Latest guess */ - *sa = &n->address; - *sock = n->sock; - - /* If the UDP address is confirmed, use it. */ - if(n->status.udp_confirmed) { - return; - } - - /* Send every third packet to n->address; that could be set - to the node's reflexive UDP address discovered during key - exchange. */ - - static int x = 0; - - if(++x >= 3) { - x = 0; - return; - } - - /* Otherwise, address are found in edges to this node. - So we pick a random edge and a random socket. */ - - int i = 0; - int j = rand() % n->edge_tree->count; - edge_t *candidate = NULL; - - for splay_each(edge_t, e, n->edge_tree) { - if(i++ == j) { - candidate = e->reverse; - break; - } - } - - if(candidate) { - *sa = &candidate->address; - *sock = rand() % listen_sockets; - } - - adapt_socket(*sa, sock); -} - -static void choose_local_address(const node_t *n, const sockaddr_t **sa, int *sock) { - *sa = NULL; - - /* Pick one of the edges from this node at random, then use its local address. */ - - int i = 0; - int j = rand() % n->edge_tree->count; - edge_t *candidate = NULL; - - for splay_each(edge_t, e, n->edge_tree) { - if(i++ == j) { - candidate = e; - break; - } - } - - if(candidate && candidate->local_address.sa.sa_family) { - *sa = &candidate->local_address; - *sock = rand() % listen_sockets; - adapt_socket(*sa, sock); - } -} - static void send_udppacket(node_t *n, vpn_packet_t *origpkt) { vpn_packet_t pkt1, pkt2; vpn_packet_t *pkt[] = { &pkt1, &pkt2, &pkt1, &pkt2 }; vpn_packet_t *inpkt = origpkt; int nextpkt = 0; vpn_packet_t *outpkt; - int origlen = origpkt->len; - size_t outlen; - int origpriority = origpkt->priority; - - pkt1.offset = DEFAULT_PACKET_OFFSET; - pkt2.offset = DEFAULT_PACKET_OFFSET; + int origlen; + int outlen, outpad; + int origpriority; if(!n->status.reachable) { - logger(DEBUG_TRAFFIC, LOG_INFO, "Trying to send UDP packet to unreachable node %s (%s)", n->name, n->hostname); + ifdebug(TRAFFIC) logger(LOG_INFO, "Trying to send UDP packet to unreachable node %s (%s)", n->name, n->hostname); return; } - if(n->status.sptps) { - send_sptps_packet(n, origpkt); - return; - } - -#ifdef DISABLE_LEGACY - return; -#else /* Make sure we have a valid key */ if(!n->status.validkey) { - logger(DEBUG_TRAFFIC, LOG_INFO, - "No valid key known yet for %s (%s), forwarding via TCP", - n->name, n->hostname); + ifdebug(TRAFFIC) logger(LOG_INFO, + "No valid key known yet for %s (%s), forwarding via TCP", + n->name, n->hostname); + + if(n->last_req_key + 10 <= now) { + send_req_key(n); + n->last_req_key = now; + } + send_tcppacket(n->nexthop->connection, origpkt); + return; } - if(n->options & OPTION_PMTU_DISCOVERY && inpkt->len > n->minmtu && (DATA(inpkt)[12] | DATA(inpkt)[13])) { - logger(DEBUG_TRAFFIC, LOG_INFO, - "Packet for %s (%s) larger than minimum MTU, forwarding via %s", - n->name, n->hostname, n != n->nexthop ? n->nexthop->name : "TCP"); + if(n->options & OPTION_PMTU_DISCOVERY && inpkt->len > n->minmtu && (inpkt->data[12] | inpkt->data[13])) { + ifdebug(TRAFFIC) logger(LOG_INFO, + "Packet for %s (%s) larger than minimum MTU, forwarding via %s", + n->name, n->hostname, n != n->nexthop ? n->nexthop->name : "TCP"); if(n != n->nexthop) { send_packet(n->nexthop, origpkt); @@ -748,14 +479,17 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) { return; } + origlen = inpkt->len; + origpriority = inpkt->priority; + /* Compress the packet */ if(n->outcompression) { outpkt = pkt[nextpkt++]; - if(!(outpkt->len = compress_packet(DATA(outpkt), DATA(inpkt), inpkt->len, n->outcompression))) { - logger(DEBUG_TRAFFIC, LOG_ERR, "Error while compressing packet to %s (%s)", - n->name, n->hostname); + if(!(outpkt->len = compress_packet(outpkt->data, inpkt->data, inpkt->len, n->outcompression))) { + ifdebug(TRAFFIC) logger(LOG_ERR, "Error while compressing packet to %s (%s)", + n->name, n->hostname); return; } @@ -764,60 +498,95 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) { /* Add sequence number */ - seqno_t seqno = htonl(++(n->sent_seqno)); - memcpy(SEQNO(inpkt), &seqno, sizeof(seqno)); - inpkt->len += sizeof(seqno); + inpkt->seqno = htonl(++(n->sent_seqno)); + inpkt->len += sizeof(inpkt->seqno); /* Encrypt the packet */ - if(cipher_active(n->outcipher)) { + if(n->outcipher) { outpkt = pkt[nextpkt++]; - outlen = MAXSIZE; - if(!cipher_encrypt(n->outcipher, SEQNO(inpkt), inpkt->len, SEQNO(outpkt), &outlen, true)) { - logger(DEBUG_TRAFFIC, LOG_ERR, "Error while encrypting packet to %s (%s)", n->name, n->hostname); + if(!EVP_EncryptInit_ex(n->outctx, NULL, NULL, NULL, NULL) + || !EVP_EncryptUpdate(n->outctx, (unsigned char *) &outpkt->seqno, &outlen, + (unsigned char *) &inpkt->seqno, inpkt->len) + || !EVP_EncryptFinal_ex(n->outctx, (unsigned char *) &outpkt->seqno + outlen, &outpad)) { + ifdebug(TRAFFIC) logger(LOG_ERR, "Error while encrypting packet to %s (%s): %s", + n->name, n->hostname, ERR_error_string(ERR_get_error(), NULL)); goto end; } - outpkt->len = outlen; + outpkt->len = outlen + outpad; inpkt = outpkt; } /* Add the message authentication code */ - if(digest_active(n->outdigest)) { - if(!digest_create(n->outdigest, SEQNO(inpkt), inpkt->len, SEQNO(inpkt) + inpkt->len)) { - logger(DEBUG_TRAFFIC, LOG_ERR, "Error while encrypting packet to %s (%s)", n->name, n->hostname); - goto end; - } + if(n->outdigest && n->outmaclength) { + HMAC(n->outdigest, n->outkey, n->outkeylength, (unsigned char *) &inpkt->seqno, + inpkt->len, (unsigned char *) &inpkt->seqno + inpkt->len, NULL); + inpkt->len += n->outmaclength; + } - inpkt->len += digest_length(n->outdigest); + /* Determine which socket we have to use */ + + if(n->address.sa.sa_family != listen_socket[n->sock].sa.sa.sa_family) { + for(int sock = 0; sock < listen_sockets; sock++) { + if(n->address.sa.sa_family == listen_socket[sock].sa.sa.sa_family) { + n->sock = sock; + break; + } + } } /* Send the packet */ - const sockaddr_t *sa = NULL; + struct sockaddr *sa; + socklen_t sl; int sock; + sockaddr_t broadcast; - if(n->status.send_locally) { - choose_local_address(n, &sa, &sock); + /* Overloaded use of priority field: -1 means local broadcast */ + + if(origpriority == -1 && n->prevedge) { + sock = rand() % listen_sockets; + memset(&broadcast, 0, sizeof(broadcast)); + + if(listen_socket[sock].sa.sa.sa_family == AF_INET6) { + broadcast.in6.sin6_family = AF_INET6; + broadcast.in6.sin6_addr.s6_addr[0x0] = 0xff; + broadcast.in6.sin6_addr.s6_addr[0x1] = 0x02; + broadcast.in6.sin6_addr.s6_addr[0xf] = 0x01; + broadcast.in6.sin6_port = n->prevedge->address.in.sin_port; + broadcast.in6.sin6_scope_id = listen_socket[sock].sa.in6.sin6_scope_id; + } else { + broadcast.in.sin_family = AF_INET; + broadcast.in.sin_addr.s_addr = -1; + broadcast.in.sin_port = n->prevedge->address.in.sin_port; + } + + sa = &broadcast.sa; + sl = SALEN(broadcast.sa); + } else { + if(origpriority == -1) { + origpriority = 0; + } + + sa = &(n->address.sa); + sl = SALEN(n->address.sa); + sock = n->sock; } - if(!sa) { - choose_udp_address(n, &sa, &sock); - } + if(priorityinheritance && origpriority != listen_socket[n->sock].priority) { + listen_socket[n->sock].priority = origpriority; - if(priorityinheritance && origpriority != listen_socket[sock].priority) { - listen_socket[sock].priority = origpriority; - - switch(sa->sa.sa_family) { + switch(listen_socket[n->sock].sa.sa.sa_family) { #if defined(IP_TOS) case AF_INET: - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Setting IPv4 outgoing packet priority to %d", origpriority); + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Setting IPv4 outgoing packet priority to %d", origpriority); - if(setsockopt(listen_socket[sock].udp.fd, IPPROTO_IP, IP_TOS, (void *)&origpriority, sizeof(origpriority))) { /* SO_PRIORITY doesn't seem to work */ - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "setsockopt", sockstrerror(sockerrno)); + if(setsockopt(listen_socket[n->sock].udp, IPPROTO_IP, IP_TOS, (void *)&origpriority, sizeof(origpriority))) { /* SO_PRIORITY doesn't seem to work */ + logger(LOG_ERR, "System call `%s' failed: %s", "setsockopt", strerror(errno)); } break; @@ -825,10 +594,10 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) { #if defined(IPV6_TCLASS) case AF_INET6: - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Setting IPv6 outgoing packet priority to %d", origpriority); + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Setting IPv6 outgoing packet priority to %d", origpriority); - if(setsockopt(listen_socket[sock].udp.fd, IPPROTO_IPV6, IPV6_TCLASS, (void *)&origpriority, sizeof(origpriority))) { /* SO_PRIORITY doesn't seem to work */ - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "setsockopt", sockstrerror(sockerrno)); + if(setsockopt(listen_socket[n->sock].udp, IPPROTO_IPV6, IPV6_TCLASS, (void *)&origpriority, sizeof(origpriority))) { + logger(LOG_ERR, "System call `%s' failed: %s", "setsockopt", strerror(errno)); } break; @@ -839,7 +608,7 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) { } } - if(sendto(listen_socket[sock].udp.fd, (void *)SEQNO(inpkt), inpkt->len, 0, &sa->sa, SALEN(sa->sa)) < 0 && !sockwouldblock(sockerrno)) { + if(sendto(listen_socket[sock].udp, (char *) &inpkt->seqno, inpkt->len, 0, sa, sl) < 0 && !sockwouldblock(sockerrno)) { if(sockmsgsize(sockerrno)) { if(n->maxmtu >= origlen) { n->maxmtu = origlen - 1; @@ -848,663 +617,61 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) { if(n->mtu >= origlen) { n->mtu = origlen - 1; } - - try_fix_mtu(n); } else { - logger(DEBUG_TRAFFIC, LOG_WARNING, "Error sending packet to %s (%s): %s", n->name, n->hostname, sockstrerror(sockerrno)); + ifdebug(TRAFFIC) logger(LOG_WARNING, "Error sending packet to %s (%s): %s", n->name, n->hostname, sockstrerror(sockerrno)); } } end: origpkt->len = origlen; -#endif } -bool send_sptps_data(node_t *to, node_t *from, int type, const void *data, size_t len) { - node_t *relay = (to->via != myself && (type == PKT_PROBE || (len - SPTPS_DATAGRAM_OVERHEAD) <= to->via->minmtu)) ? to->via : to->nexthop; - bool direct = from == myself && to == relay; - bool relay_supported = (relay->options >> 24) >= 4; - bool tcponly = (myself->options | relay->options) & OPTION_TCPONLY; - - /* Send it via TCP if it is a handshake packet, TCPOnly is in use, this is a relay packet that the other node cannot understand, or this packet is larger than the MTU. */ - - if(type == SPTPS_HANDSHAKE || tcponly || (!direct && !relay_supported) || (type != PKT_PROBE && (len - SPTPS_DATAGRAM_OVERHEAD) > relay->minmtu)) { - if(type != SPTPS_HANDSHAKE && (to->nexthop->connection->options >> 24) >= 7) { - char buf[len + sizeof(to->id) + sizeof(from->id)]; - char *buf_ptr = buf; - memcpy(buf_ptr, &to->id, sizeof(to->id)); - buf_ptr += sizeof(to->id); - memcpy(buf_ptr, &from->id, sizeof(from->id)); - buf_ptr += sizeof(from->id); - memcpy(buf_ptr, data, len); - logger(DEBUG_TRAFFIC, LOG_INFO, "Sending packet from %s (%s) to %s (%s) via %s (%s) (TCP)", from->name, from->hostname, to->name, to->hostname, to->nexthop->name, to->nexthop->hostname); - return send_sptps_tcppacket(to->nexthop->connection, buf, sizeof(buf)); - } - - char buf[len * 4 / 3 + 5]; - b64encode(data, buf, len); - - /* If this is a handshake packet, use ANS_KEY instead of REQ_KEY, for two reasons: - - We don't want intermediate nodes to switch to UDP to relay these packets; - - ANS_KEY allows us to learn the reflexive UDP address. */ - if(type == SPTPS_HANDSHAKE) { - to->incompression = myself->incompression; - return send_request(to->nexthop->connection, "%d %s %s %s -1 -1 -1 %d", ANS_KEY, from->name, to->name, buf, to->incompression); - } else { - return send_request(to->nexthop->connection, "%d %s %s %d %s", REQ_KEY, from->name, to->name, SPTPS_PACKET, buf); - } - } - - size_t overhead = 0; - - if(relay_supported) { - overhead += sizeof(to->id) + sizeof(from->id); - } - - char buf[len + overhead]; - char *buf_ptr = buf; - - if(relay_supported) { - if(direct) { - /* Inform the recipient that this packet was sent directly. */ - node_id_t nullid = {0}; - memcpy(buf_ptr, &nullid, sizeof(nullid)); - buf_ptr += sizeof(nullid); - } else { - memcpy(buf_ptr, &to->id, sizeof(to->id)); - buf_ptr += sizeof(to->id); - } - - memcpy(buf_ptr, &from->id, sizeof(from->id)); - buf_ptr += sizeof(from->id); - - } - - /* TODO: if this copy turns out to be a performance concern, change sptps_send_record() to add some "pre-padding" to the buffer and use that instead */ - memcpy(buf_ptr, data, len); - buf_ptr += len; - - const sockaddr_t *sa = NULL; - int sock; - - if(relay->status.send_locally) { - choose_local_address(relay, &sa, &sock); - } - - if(!sa) { - choose_udp_address(relay, &sa, &sock); - } - - logger(DEBUG_TRAFFIC, LOG_INFO, "Sending packet from %s (%s) to %s (%s) via %s (%s) (UDP)", from->name, from->hostname, to->name, to->hostname, relay->name, relay->hostname); - - if(sendto(listen_socket[sock].udp.fd, buf, buf_ptr - buf, 0, &sa->sa, SALEN(sa->sa)) < 0 && !sockwouldblock(sockerrno)) { - if(sockmsgsize(sockerrno)) { - // Compensate for SPTPS overhead - len -= SPTPS_DATAGRAM_OVERHEAD; - - if(relay->maxmtu >= len) { - relay->maxmtu = len - 1; - } - - if(relay->mtu >= len) { - relay->mtu = len - 1; - } - - try_fix_mtu(relay); - } else { - logger(DEBUG_TRAFFIC, LOG_WARNING, "Error sending UDP SPTPS packet to %s (%s): %s", relay->name, relay->hostname, sockstrerror(sockerrno)); - return false; - } - } - - return true; -} - -bool receive_sptps_record(void *handle, uint8_t type, const void *data, uint16_t len) { - node_t *from = handle; - - if(type == SPTPS_HANDSHAKE) { - if(!from->status.validkey) { - from->status.validkey = true; - from->status.waitingforkey = false; - logger(DEBUG_META, LOG_INFO, "SPTPS key exchange with %s (%s) successful", from->name, from->hostname); - } - - return true; - } - - if(len > MTU) { - logger(DEBUG_ALWAYS, LOG_ERR, "Packet from %s (%s) larger than maximum supported size (%d > %d)", from->name, from->hostname, len, MTU); - return false; - } - - vpn_packet_t inpkt; - inpkt.offset = DEFAULT_PACKET_OFFSET; - inpkt.priority = 0; - - if(type == PKT_PROBE) { - if(!from->status.udppacket) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got SPTPS PROBE packet from %s (%s) via TCP", from->name, from->hostname); - return false; - } - - inpkt.len = len; - memcpy(DATA(&inpkt), data, len); - - if(inpkt.len > from->maxrecentlen) { - from->maxrecentlen = inpkt.len; - } - - udp_probe_h(from, &inpkt, len); - return true; - } - - if(type & ~(PKT_COMPRESSED | PKT_MAC)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unexpected SPTPS record type %d len %d from %s (%s)", type, len, from->name, from->hostname); - return false; - } - - /* Check if we have the headers we need */ - if(routing_mode != RMODE_ROUTER && !(type & PKT_MAC)) { - logger(DEBUG_TRAFFIC, LOG_ERR, "Received packet from %s (%s) without MAC header (maybe Mode is not set correctly)", from->name, from->hostname); - return false; - } else if(routing_mode == RMODE_ROUTER && (type & PKT_MAC)) { - logger(DEBUG_TRAFFIC, LOG_WARNING, "Received packet from %s (%s) with MAC header (maybe Mode is not set correctly)", from->name, from->hostname); - } - - int offset = (type & PKT_MAC) ? 0 : 14; - - if(type & PKT_COMPRESSED) { - length_t ulen = uncompress_packet(DATA(&inpkt) + offset, (const uint8_t *)data, len, from->incompression); - - if(!ulen) { - return false; - } else { - inpkt.len = ulen + offset; - } - - if(inpkt.len > MAXSIZE) { - abort(); - } - } else { - memcpy(DATA(&inpkt) + offset, data, len); - inpkt.len = len + offset; - } - - /* Generate the Ethernet packet type if necessary */ - if(offset) { - switch(DATA(&inpkt)[14] >> 4) { - case 4: - DATA(&inpkt)[12] = 0x08; - DATA(&inpkt)[13] = 0x00; - break; - - case 6: - DATA(&inpkt)[12] = 0x86; - DATA(&inpkt)[13] = 0xDD; - break; - - default: - logger(DEBUG_TRAFFIC, LOG_ERR, - "Unknown IP version %d while reading packet from %s (%s)", - DATA(&inpkt)[14] >> 4, from->name, from->hostname); - return false; - } - } - - if(from->status.udppacket && inpkt.len > from->maxrecentlen) { - from->maxrecentlen = inpkt.len; - } - - receive_packet(from, &inpkt); - return true; -} - -// This function tries to get SPTPS keys, if they aren't already known. -// This function makes no guarantees - it is up to the caller to check the node's state to figure out if the keys are available. -static void try_sptps(node_t *n) { - if(n->status.validkey) { - return; - } - - logger(DEBUG_TRAFFIC, LOG_INFO, "No valid key known yet for %s (%s)", n->name, n->hostname); - - if(!n->status.waitingforkey) { - send_req_key(n); - } else if(n->last_req_key + 10 < now.tv_sec) { - logger(DEBUG_ALWAYS, LOG_DEBUG, "No key from %s after 10 seconds, restarting SPTPS", n->name); - sptps_stop(&n->sptps); - n->status.waitingforkey = false; - send_req_key(n); - } - - return; -} - -static void send_udp_probe_packet(node_t *n, int len) { - vpn_packet_t packet; - packet.offset = DEFAULT_PACKET_OFFSET; - memset(DATA(&packet), 0, 14); - randomize(DATA(&packet) + 14, len - 14); - packet.len = len; - packet.priority = 0; - - logger(DEBUG_TRAFFIC, LOG_INFO, "Sending UDP probe length %d to %s (%s)", len, n->name, n->hostname); - - send_udppacket(n, &packet); -} - -// This function tries to establish a UDP tunnel to a node so that packets can be sent. -// If a tunnel is already established, it makes sure it stays up. -// This function makes no guarantees - it is up to the caller to check the node's state to figure out if UDP is usable. -static void try_udp(node_t *n) { - if(!udp_discovery) { - return; - } - - /* Send gratuitous probe replies to 1.1 nodes. */ - - if((n->options >> 24) >= 3 && n->status.udp_confirmed) { - struct timeval ping_tx_elapsed; - timersub(&now, &n->udp_reply_sent, &ping_tx_elapsed); - - if(ping_tx_elapsed.tv_sec >= udp_discovery_keepalive_interval - 1) { - n->udp_reply_sent = now; - - if(n->maxrecentlen) { - vpn_packet_t pkt; - pkt.len = n->maxrecentlen; - pkt.offset = DEFAULT_PACKET_OFFSET; - memset(DATA(&pkt), 0, 14); - randomize(DATA(&pkt) + 14, MIN_PROBE_SIZE - 14); - send_udp_probe_reply(n, &pkt, pkt.len); - n->maxrecentlen = 0; - } - } - } - - /* Probe request */ - - struct timeval ping_tx_elapsed; - timersub(&now, &n->udp_ping_sent, &ping_tx_elapsed); - - int interval = n->status.udp_confirmed ? udp_discovery_keepalive_interval : udp_discovery_interval; - - if(ping_tx_elapsed.tv_sec >= interval) { - gettimeofday(&now, NULL); - n->udp_ping_sent = now; // a probe in flight - send_udp_probe_packet(n, MIN_PROBE_SIZE); - - if(localdiscovery && !n->status.udp_confirmed && n->prevedge) { - n->status.send_locally = true; - send_udp_probe_packet(n, MIN_PROBE_SIZE); - n->status.send_locally = false; - } - } -} - -static length_t choose_initial_maxmtu(node_t *n) { -#ifdef IP_MTU - - int sock = -1; - - const sockaddr_t *sa = NULL; - int sockindex; - choose_udp_address(n, &sa, &sockindex); - - if(!sa) { - return MTU; - } - - sock = socket(sa->sa.sa_family, SOCK_DGRAM, IPPROTO_UDP); - - if(sock < 0) { - logger(DEBUG_TRAFFIC, LOG_ERR, "Creating MTU assessment socket for %s (%s) failed: %s", n->name, n->hostname, sockstrerror(sockerrno)); - return MTU; - } - - if(connect(sock, &sa->sa, SALEN(sa->sa))) { - logger(DEBUG_TRAFFIC, LOG_ERR, "Connecting MTU assessment socket for %s (%s) failed: %s", n->name, n->hostname, sockstrerror(sockerrno)); - close(sock); - return MTU; - } - - int ip_mtu; - socklen_t ip_mtu_len = sizeof(ip_mtu); - - if(getsockopt(sock, IPPROTO_IP, IP_MTU, &ip_mtu, &ip_mtu_len)) { - logger(DEBUG_TRAFFIC, LOG_ERR, "getsockopt(IP_MTU) on %s (%s) failed: %s", n->name, n->hostname, sockstrerror(sockerrno)); - close(sock); - return MTU; - } - - close(sock); - - /* getsockopt(IP_MTU) returns the MTU of the physical interface. - We need to remove various overheads to get to the tinc MTU. */ - length_t mtu = ip_mtu; - mtu -= (sa->sa.sa_family == AF_INET6) ? sizeof(struct ip6_hdr) : sizeof(struct ip); - mtu -= 8; /* UDP */ - - if(n->status.sptps) { - mtu -= SPTPS_DATAGRAM_OVERHEAD; - - if((n->options >> 24) >= 4) { - mtu -= sizeof(node_id_t) + sizeof(node_id_t); - } - -#ifndef DISABLE_LEGACY - } else { - mtu -= digest_length(n->outdigest); - - /* Now it's tricky. We use CBC mode, so the length of the - encrypted payload must be a multiple of the blocksize. The - sequence number is also part of the encrypted payload, so we - must account for it after correcting for the blocksize. - Furthermore, the padding in the last block must be at least - 1 byte. */ - - length_t blocksize = cipher_blocksize(n->outcipher); - - if(blocksize > 1) { - mtu /= blocksize; - mtu *= blocksize; - mtu--; - } - - mtu -= 4; // seqno -#endif - } - - if(mtu < 512) { - logger(DEBUG_TRAFFIC, LOG_ERR, "getsockopt(IP_MTU) on %s (%s) returned absurdly small value: %d", n->name, n->hostname, ip_mtu); - return MTU; - } - - if(mtu > MTU) { - return MTU; - } - - logger(DEBUG_TRAFFIC, LOG_INFO, "Using system-provided maximum tinc MTU for %s (%s): %hd", n->name, n->hostname, mtu); - return mtu; - -#else - - return MTU; - -#endif -} - -/* This function tries to determines the MTU of a node. - By calling this function repeatedly, n->minmtu will be progressively - increased, and at some point, n->mtu will be fixed to n->minmtu. If the MTU - is already fixed, this function checks if it can be increased. +/* + send a packet to the given vpn ip. */ - -static void try_mtu(node_t *n) { - if(!(n->options & OPTION_PMTU_DISCOVERY)) { - return; - } - - if(udp_discovery && !n->status.udp_confirmed) { - n->maxrecentlen = 0; - n->mtuprobes = 0; - n->minmtu = 0; - n->maxmtu = MTU; - return; - } - - /* mtuprobes == 0..19: initial discovery, send bursts with 1 second interval, mtuprobes++ - mtuprobes == 20: fix MTU, and go to -1 - mtuprobes == -1: send one maxmtu and one maxmtu+1 probe every pinginterval - mtuprobes ==-2..-3: send one maxmtu probe every second - mtuprobes == -4: maxmtu no longer valid, reset minmtu and maxmtu and go to 0 */ - - struct timeval elapsed; - timersub(&now, &n->mtu_ping_sent, &elapsed); - - if(n->mtuprobes >= 0) { - if(n->mtuprobes != 0 && elapsed.tv_sec == 0 && elapsed.tv_usec < 333333) { - return; - } - } else { - if(n->mtuprobes < -1) { - if(elapsed.tv_sec < 1) { - return; - } - } else { - if(elapsed.tv_sec < pinginterval) { - return; - } - } - } - - n->mtu_ping_sent = now; - - try_fix_mtu(n); - - if(n->mtuprobes < -3) { - /* We lost three MTU probes, restart discovery */ - logger(DEBUG_TRAFFIC, LOG_INFO, "Decrease in PMTU to %s (%s) detected, restarting PMTU discovery", n->name, n->hostname); - n->mtuprobes = 0; - n->minmtu = 0; - } - - if(n->mtuprobes < 0) { - /* After the initial discovery, we only send one maxmtu and one - maxmtu+1 probe to detect PMTU increases. */ - send_udp_probe_packet(n, n->maxmtu); - - if(n->mtuprobes == -1 && n->maxmtu + 1 < MTU) { - send_udp_probe_packet(n, n->maxmtu + 1); - } - - n->mtuprobes--; - } else { - /* Before initial discovery begins, set maxmtu to the most likely value. - If it's underestimated, we will correct it after initial discovery. */ - if(n->mtuprobes == 0) { - n->maxmtu = choose_initial_maxmtu(n); - } - - for(;;) { - /* Decreasing the number of probes per cycle might make the algorithm react faster to lost packets, - but it will typically increase convergence time in the no-loss case. */ - const length_t probes_per_cycle = 8; - - /* This magic value was determined using math simulations. - It will result in a 1329-byte first probe, followed (if there was a reply) by a 1407-byte probe. - Since 1407 is just below the range of tinc MTUs over typical networks, - this fine-tuning allows tinc to cover a lot of ground very quickly. - This fine-tuning is only valid for maxmtu = MTU; if maxmtu is smaller, - then it's better to use a multiplier of 1. Indeed, this leads to an interesting scenario - if choose_initial_maxmtu() returns the actual MTU value - it will get confirmed with one single probe. */ - const float multiplier = (n->maxmtu == MTU) ? 0.97 : 1; - - const float cycle_position = probes_per_cycle - (n->mtuprobes % probes_per_cycle) - 1; - const length_t minmtu = MAX(n->minmtu, 512); - const float interval = n->maxmtu - minmtu; - - /* The core of the discovery algorithm is this exponential. - It produces very large probes early in the cycle, and then it very quickly decreases the probe size. - This reflects the fact that in the most difficult cases, we don't get any feedback for probes that - are too large, and therefore we need to concentrate on small offsets so that we can quickly converge - on the precise MTU as we are approaching it. - The last probe of the cycle is always 1 byte in size - this is to make sure we'll get at least one - reply per cycle so that we can make progress. */ - const length_t offset = powf(interval, multiplier * cycle_position / (probes_per_cycle - 1)); - - length_t maxmtu = n->maxmtu; - send_udp_probe_packet(n, minmtu + offset); - - /* If maxmtu changed, it means the probe was rejected by the system because it was too large. - In that case, we recalculate with the new maxmtu and try again. */ - if(n->mtuprobes < 0 || maxmtu == n->maxmtu) { - break; - } - } - - if(n->mtuprobes >= 0) { - n->mtuprobes++; - } - } -} - -/* These functions try to establish a tunnel to a node (or its relay) so that - packets can be sent (e.g. exchange keys). - If a tunnel is already established, it tries to improve it (e.g. by trying - to establish a UDP tunnel instead of TCP). This function makes no - guarantees - it is up to the caller to check the node's state to figure out - if TCP and/or UDP is usable. By calling this function repeatedly, the - tunnel is gradually improved until we hit the wall imposed by the underlying - network environment. It is recommended to call this function every time a - packet is sent (or intended to be sent) to a node, so that the tunnel keeps - improving as packets flow, and then gracefully downgrades itself as it goes - idle. -*/ - -static void try_tx_sptps(node_t *n, bool mtu) { - /* If n is a TCP-only neighbor, we'll only use "cleartext" PACKET - messages anyway, so there's no need for SPTPS at all. */ - - if(n->connection && ((myself->options | n->options) & OPTION_TCPONLY)) { - return; - } - - /* Otherwise, try to do SPTPS authentication with n if necessary. */ - - try_sptps(n); - - /* Do we need to statically relay packets? */ - - node_t *via = (n->via == myself) ? n->nexthop : n->via; - - /* If we do have a static relay, try everything with that one instead, if it supports relaying. */ - - if(via != n) { - if((via->options >> 24) < 4) { - return; - } - - try_tx(via, mtu); - return; - } - - /* Otherwise, try to establish UDP connectivity. */ - - try_udp(n); - - if(mtu) { - try_mtu(n); - } - - /* If we don't have UDP connectivity (yet), we need to use a dynamic relay (nexthop) - while we try to establish direct connectivity. */ - - if(!n->status.udp_confirmed && n != n->nexthop && (n->nexthop->options >> 24) >= 4) { - try_tx(n->nexthop, mtu); - } -} - -static void try_tx_legacy(node_t *n, bool mtu) { - /* Does he have our key? If not, send one. */ - - if(!n->status.validkey_in) { - send_ans_key(n); - } - - /* Check if we already have a key, or request one. */ - - if(!n->status.validkey) { - if(n->last_req_key + 10 <= now.tv_sec) { - send_req_key(n); - n->last_req_key = now.tv_sec; - } - - return; - } - - try_udp(n); - - if(mtu) { - try_mtu(n); - } -} - -void try_tx(node_t *n, bool mtu) { - if(!n->status.reachable) { - return; - } - - if(n->status.sptps) { - try_tx_sptps(n, mtu); - } else { - try_tx_legacy(n, mtu); - } -} - -void send_packet(node_t *n, vpn_packet_t *packet) { - // If it's for myself, write it to the tun/tap device. +void send_packet(const node_t *n, vpn_packet_t *packet) { + node_t *via; if(n == myself) { if(overwrite_mac) { - memcpy(DATA(packet), mymac.x, ETH_ALEN); - // Use an arbitrary fake source address. - memcpy(DATA(packet) + ETH_ALEN, DATA(packet), ETH_ALEN); - DATA(packet)[ETH_ALEN * 2 - 1] ^= 0xFF; + memcpy(packet->data, mymac.x, ETH_ALEN); } - n->out_packets++; - n->out_bytes += packet->len; devops.write(packet); return; } - logger(DEBUG_TRAFFIC, LOG_ERR, "Sending packet of %d bytes to %s (%s)", packet->len, n->name, n->hostname); - - // If the node is not reachable, drop it. + ifdebug(TRAFFIC) logger(LOG_ERR, "Sending packet of %d bytes to %s (%s)", + packet->len, n->name, n->hostname); if(!n->status.reachable) { - logger(DEBUG_TRAFFIC, LOG_INFO, "Node %s (%s) is not reachable", n->name, n->hostname); + ifdebug(TRAFFIC) logger(LOG_INFO, "Node %s (%s) is not reachable", + n->name, n->hostname); return; } - // Keep track of packet statistics. + via = (packet->priority == -1 || n->via == myself) ? n->nexthop : n->via; - n->out_packets++; - n->out_bytes += packet->len; - - // Check if it should be sent as an SPTPS packet. - - if(n->status.sptps) { - send_sptps_packet(n, packet); - try_tx(n, true); - return; - } - - // Determine which node to actually send it to. - - node_t *via = (packet->priority == -1 || n->via == myself) ? n->nexthop : n->via; - - if(via != n) { - logger(DEBUG_TRAFFIC, LOG_INFO, "Sending packet to %s via %s (%s)", n->name, via->name, n->via->hostname); - } - - // Try to send via UDP, unless TCP is forced. + if(via != n) + ifdebug(TRAFFIC) logger(LOG_INFO, "Sending packet to %s via %s (%s)", + n->name, via->name, n->via->hostname); if(packet->priority == -1 || ((myself->options | via->options) & OPTION_TCPONLY)) { if(!send_tcppacket(via->connection, packet)) { terminate_connection(via->connection, true); } - - return; + } else { + send_udppacket(via, packet); } - - send_udppacket(via, packet); - try_tx(via, true); } +/* Broadcast a packet using the minimum spanning tree */ + void broadcast_packet(const node_t *from, vpn_packet_t *packet) { + avl_node_t *node; + connection_t *c; + node_t *n; + // Always give ourself a copy of the packet. if(from != myself) { send_packet(myself, packet); @@ -1516,18 +683,21 @@ void broadcast_packet(const node_t *from, vpn_packet_t *packet) { return; } - logger(DEBUG_TRAFFIC, LOG_INFO, "Broadcasting packet of %d bytes from %s (%s)", - packet->len, from->name, from->hostname); + ifdebug(TRAFFIC) logger(LOG_INFO, "Broadcasting packet of %d bytes from %s (%s)", + packet->len, from->name, from->hostname); switch(broadcast_mode) { // In MST mode, broadcast packets travel via the Minimum Spanning Tree. // This guarantees all nodes receive the broadcast packet, and // usually distributes the sending of broadcast packets over all nodes. case BMODE_MST: - for list_each(connection_t, c, connection_list) - if(c->edge && c->status.mst && c != from->nexthop->connection) { + for(node = connection_tree->head; node; node = node->next) { + c = node->data; + + if(c->status.active && c->status.mst && c != from->nexthop->connection) { send_packet(c->node, packet); } + } break; @@ -1539,10 +709,13 @@ void broadcast_packet(const node_t *from, vpn_packet_t *packet) { break; } - for splay_each(node_t, n, node_tree) + for(node = node_udp_tree->head; node; node = node->next) { + n = node->data; + if(n->status.reachable && n != myself && ((n->via == myself && n->nexthop == n) || n->via == n)) { send_packet(n, packet); } + } break; @@ -1551,271 +724,75 @@ void broadcast_packet(const node_t *from, vpn_packet_t *packet) { } } -/* We got a packet from some IP address, but we don't know who sent it. Try to - verify the message authentication code against all active session keys. - Since this is actually an expensive operation, we only do a full check once - a minute, the rest of the time we only check against nodes for which we know - an IP address that matches the one from the packet. */ - static node_t *try_harder(const sockaddr_t *from, const vpn_packet_t *pkt) { - node_t *match = NULL; - bool hard = false; + avl_node_t *node; + edge_t *e; + node_t *n = NULL; static time_t last_hard_try = 0; - for splay_each(node_t, n, node_tree) { - if(!n->status.reachable || n == myself) { + for(node = edge_weight_tree->head; node; node = node->next) { + e = node->data; + + if(e->to == myself) { continue; } - if(!n->status.validkey_in && !(n->status.sptps && n->sptps.instate)) { + if(last_hard_try == now && sockaddrcmp_noport(from, &e->address)) { continue; } - bool soft = false; - - for splay_each(edge_t, e, n->edge_tree) { - if(!e->reverse) { - continue; - } - - if(!sockaddrcmp_noport(from, &e->reverse->address)) { - soft = true; - break; - } - } - - if(!soft) { - if(last_hard_try == now.tv_sec) { - continue; - } - - hard = true; - } - - if(!try_mac(n, pkt)) { + if(!try_mac(e->to, pkt)) { continue; } - match = n; + n = e->to; break; } - if(hard) { - last_hard_try = now.tv_sec; - } - - return match; + last_hard_try = now; + return n; } -static void handle_incoming_vpn_packet(listen_socket_t *ls, vpn_packet_t *pkt, sockaddr_t *addr) { - char *hostname; - node_id_t nullid = {0}; - node_t *from, *to; - bool direct = false; - - sockaddrunmap(addr); /* Some braindead IPv6 implementations do stupid things. */ - - // Try to figure out who sent this packet. - - node_t *n = lookup_node_udp(addr); - - if(n && !n->status.udp_confirmed) { - n = NULL; // Don't believe it if we don't have confirmation yet. - } - - if(!n) { - // It might be from a 1.1 node, which might have a source ID in the packet. - pkt->offset = 2 * sizeof(node_id_t); - from = lookup_node_id(SRCID(pkt)); - - if(from && !memcmp(DSTID(pkt), &nullid, sizeof(nullid)) && from->status.sptps) { - if(sptps_verify_datagram(&from->sptps, DATA(pkt), pkt->len - 2 * sizeof(node_id_t))) { - n = from; - } else { - goto skip_harder; - } - } - } - - if(!n) { - pkt->offset = 0; - n = try_harder(addr, pkt); - } - -skip_harder: - - if(!n) { - if(debug_level >= DEBUG_PROTOCOL) { - hostname = sockaddr2hostname(addr); - logger(DEBUG_PROTOCOL, LOG_WARNING, "Received UDP packet from unknown source %s", hostname); - free(hostname); - } - - return; - } - - pkt->offset = 0; - - if(n->status.sptps) { - bool relay_enabled = (n->options >> 24) >= 4; - - if(relay_enabled) { - pkt->offset = 2 * sizeof(node_id_t); - pkt->len -= pkt->offset; - } - - if(!memcmp(DSTID(pkt), &nullid, sizeof(nullid)) || !relay_enabled) { - direct = true; - from = n; - to = myself; - } else { - from = lookup_node_id(SRCID(pkt)); - to = lookup_node_id(DSTID(pkt)); - } - - if(!from || !to) { - logger(DEBUG_PROTOCOL, LOG_WARNING, "Received UDP packet from %s (%s) with unknown source and/or destination ID", n->name, n->hostname); - return; - } - - if(!to->status.reachable) { - /* This can happen in the form of a race condition - if the node just became unreachable. */ - logger(DEBUG_TRAFFIC, LOG_WARNING, "Cannot relay packet from %s (%s) because the destination, %s (%s), is unreachable", from->name, from->hostname, to->name, to->hostname); - return; - } - - /* The packet is supposed to come from the originator or its static relay - (i.e. with no dynamic relays in between). - If it did not, "help" the static relay by sending it UDP info. - Note that we only do this if we're the destination or the static relay; - otherwise every hop would initiate its own UDP info message, resulting in elevated chatter. */ - - if(n != from->via && to->via == myself) { - send_udp_info(myself, from); - } - - /* If we're not the final recipient, relay the packet. */ - - if(to != myself) { - send_sptps_data(to, from, 0, DATA(pkt), pkt->len); - try_tx(to, true); - return; - } - } else { - direct = true; - from = n; - } - - if(!receive_udppacket(from, pkt)) { - return; - } - - n->sock = ls - listen_socket; - - if(direct && sockaddrcmp(addr, &n->address)) { - update_node_udp(n, addr); - } - - /* If the packet went through a relay, help the sender find the appropriate MTU - through the relay path. */ - - if(!direct) { - send_mtu_info(myself, n, MTU); - } -} - -void handle_incoming_vpn_data(void *data, int flags) { - (void)data; - (void)flags; - listen_socket_t *ls = data; - -#ifdef HAVE_RECVMMSG -#define MAX_MSG 64 - static int num = MAX_MSG; - static vpn_packet_t pkt[MAX_MSG]; - static sockaddr_t addr[MAX_MSG]; - static struct mmsghdr msg[MAX_MSG]; - static struct iovec iov[MAX_MSG]; - - for(int i = 0; i < num; i++) { - pkt[i].offset = 0; - - iov[i] = (struct iovec) { - .iov_base = DATA(&pkt[i]), - .iov_len = MAXSIZE, - }; - - msg[i].msg_hdr = (struct msghdr) { - .msg_name = &addr[i].sa, - .msg_namelen = sizeof(addr)[i], - .msg_iov = &iov[i], - .msg_iovlen = 1, - }; - } - - num = recvmmsg(ls->udp.fd, msg, MAX_MSG, MSG_DONTWAIT, NULL); - - if(num < 0) { - if(!sockwouldblock(sockerrno)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Receiving packet failed: %s", sockstrerror(sockerrno)); - } - - return; - } - - for(int i = 0; i < num; i++) { - pkt[i].len = msg[i].msg_len; - - if(pkt[i].len <= 0 || pkt[i].len > MAXSIZE) { - continue; - } - - handle_incoming_vpn_packet(ls, &pkt[i], &addr[i]); - } - -#else +void handle_incoming_vpn_data(int sock) { vpn_packet_t pkt; - sockaddr_t addr = {}; - socklen_t addrlen = sizeof(addr); + char *hostname; + sockaddr_t from; + socklen_t fromlen = sizeof(from); + node_t *n; - pkt.offset = 0; - int len = recvfrom(ls->udp.fd, (void *)DATA(&pkt), MAXSIZE, 0, &addr.sa, &addrlen); + ssize_t len = recvfrom(listen_socket[sock].udp, (char *) &pkt.seqno, MAXSIZE, 0, &from.sa, &fromlen); - if(len <= 0 || len > MAXSIZE) { - if(!sockwouldblock(sockerrno)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Receiving packet failed: %s", sockstrerror(sockerrno)); + if(len <= 0 || len > UINT16_MAX) { + if(len >= 0) { + logger(LOG_ERR, "Receiving packet with invalid size"); + } else if(!sockwouldblock(sockerrno)) { + logger(LOG_ERR, "Receiving packet failed: %s", sockstrerror(sockerrno)); } return; } pkt.len = len; + sockaddrunmap(&from); /* Some braindead IPv6 implementations do stupid things. */ - handle_incoming_vpn_packet(ls, &pkt, &addr); -#endif -} + n = lookup_node_udp(&from); -void handle_device_data(void *data, int flags) { - (void)data; - (void)flags; - vpn_packet_t packet; - packet.offset = DEFAULT_PACKET_OFFSET; - packet.priority = 0; - static int errors = 0; + if(!n) { + n = try_harder(&from, &pkt); - if(devops.read(&packet)) { - errors = 0; - myself->in_packets++; - myself->in_bytes += packet.len; - route(myself, &packet); - } else { - usleep(errors * 50000); - errors++; - - if(errors > 10) { - logger(DEBUG_ALWAYS, LOG_ERR, "Too many errors from %s, exiting!", device); - event_exit(); + if(n) { + update_node_udp(n, &from); + } else ifdebug(PROTOCOL) { + hostname = sockaddr2hostname(&from); + logger(LOG_WARNING, "Received UDP packet from unknown source %s", hostname); + free(hostname); + return; + } else { + return; } } + + n->sock = sock; + + receive_udppacket(n, &pkt); } diff --git a/src/net_setup.c b/src/net_setup.c index ed69808..f26007b 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -22,294 +22,220 @@ #include "system.h" -#include "cipher.h" +#include +#include +#include +#include +#include +#include + +#include "avl_tree.h" #include "conf.h" #include "connection.h" -#include "control.h" #include "device.h" -#include "digest.h" -#include "ecdsa.h" +#include "event.h" #include "graph.h" #include "logger.h" -#include "names.h" #include "net.h" #include "netutl.h" #include "process.h" #include "protocol.h" +#include "proxy.h" #include "route.h" -#include "rsa.h" -#include "script.h" #include "subnet.h" #include "utils.h" #include "xalloc.h" -#ifdef HAVE_MINIUPNPC -#include "upnp.h" +char *myport; +devops_t devops; + +#ifndef HAVE_RSA_SET0_KEY +int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) { + BN_free(r->n); + r->n = n; + BN_free(r->e); + r->e = e; + BN_free(r->d); + r->d = d; + return 1; +} #endif -char *myport; -static io_t device_io; -devops_t devops; -bool device_standby = false; - -char *proxyhost; -char *proxyport; -char *proxyuser; -char *proxypass; -proxytype_t proxytype; -bool autoconnect; -bool disablebuggypeers; - -char *scriptinterpreter; -char *scriptextension; - -bool node_read_ecdsa_public_key(node_t *n) { - if(ecdsa_active(n->ecdsa)) { - return true; - } - - splay_tree_t *config_tree; - FILE *fp; - char *pubname = NULL; - char *p; - - init_configuration(&config_tree); - - if(!read_host_config(config_tree, n->name, true)) { - goto exit; - } - - /* First, check for simple Ed25519PublicKey statement */ - - if(get_config_string(lookup_config(config_tree, "Ed25519PublicKey"), &p)) { - n->ecdsa = ecdsa_set_base64_public_key(p); - free(p); - goto exit; - } - - /* Else, check for Ed25519PublicKeyFile statement and read it */ - - if(!get_config_string(lookup_config(config_tree, "Ed25519PublicKeyFile"), &pubname)) { - xasprintf(&pubname, "%s" SLASH "hosts" SLASH "%s", confbase, n->name); - } - - fp = fopen(pubname, "r"); - - if(!fp) { - goto exit; - } - - n->ecdsa = ecdsa_read_pem_public_key(fp); - fclose(fp); - -exit: - exit_configuration(&config_tree); - free(pubname); - return n->ecdsa; -} - -bool read_ecdsa_public_key(connection_t *c) { - if(ecdsa_active(c->ecdsa)) { - return true; - } - - FILE *fp; - char *fname; - char *p; - - if(!c->config_tree) { - init_configuration(&c->config_tree); - - if(!read_host_config(c->config_tree, c->name, true)) { - return false; - } - } - - /* First, check for simple Ed25519PublicKey statement */ - - if(get_config_string(lookup_config(c->config_tree, "Ed25519PublicKey"), &p)) { - c->ecdsa = ecdsa_set_base64_public_key(p); - free(p); - return c->ecdsa; - } - - /* Else, check for Ed25519PublicKeyFile statement and read it */ - - if(!get_config_string(lookup_config(c->config_tree, "Ed25519PublicKeyFile"), &fname)) { - xasprintf(&fname, "%s" SLASH "hosts" SLASH "%s", confbase, c->name); - } - - fp = fopen(fname, "r"); - - if(!fp) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error reading Ed25519 public key file `%s': %s", - fname, strerror(errno)); - free(fname); - return false; - } - - c->ecdsa = ecdsa_read_pem_public_key(fp); - - if(!c->ecdsa && errno != ENOENT) { - logger(DEBUG_ALWAYS, LOG_ERR, "Parsing Ed25519 public key file `%s' failed.", fname); - } - - fclose(fp); - free(fname); - return c->ecdsa; -} - -#ifndef DISABLE_LEGACY bool read_rsa_public_key(connection_t *c) { FILE *fp; - char *fname; - char *n; + char *pubname; + char *hcfname; + char *key; + BIGNUM *n = NULL; + BIGNUM *e = NULL; + + if(!c->rsa_key) { + c->rsa_key = RSA_new(); +// RSA_blinding_on(c->rsa_key, NULL); + } /* First, check for simple PublicKey statement */ - if(get_config_string(lookup_config(c->config_tree, "PublicKey"), &n)) { - c->rsa = rsa_set_hex_public_key(n, "FFFF"); - free(n); - return c->rsa; + if(get_config_string(lookup_config(c->config_tree, "PublicKey"), &key)) { + if((size_t)BN_hex2bn(&n, key) != strlen(key)) { + free(key); + logger(LOG_ERR, "Invalid PublicKey for %s!", c->name); + return false; + } + + free(key); + BN_hex2bn(&e, "FFFF"); + + if(!n || !e || RSA_set0_key(c->rsa_key, n, e, NULL) != 1) { + BN_free(e); + BN_free(n); + logger(LOG_ERR, "RSA_set0_key() failed with PublicKey for %s!", c->name); + return false; + } + + return true; } /* Else, check for PublicKeyFile statement and read it */ - if(!get_config_string(lookup_config(c->config_tree, "PublicKeyFile"), &fname)) { - xasprintf(&fname, "%s" SLASH "hosts" SLASH "%s", confbase, c->name); - } + if(get_config_string(lookup_config(c->config_tree, "PublicKeyFile"), &pubname)) { + fp = fopen(pubname, "r"); - fp = fopen(fname, "r"); - - if(!fp) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error reading RSA public key file `%s': %s", fname, strerror(errno)); - free(fname); - return false; - } - - c->rsa = rsa_read_pem_public_key(fp); - fclose(fp); - - if(!c->rsa) { - logger(DEBUG_ALWAYS, LOG_ERR, "Reading RSA public key file `%s' failed: %s", fname, strerror(errno)); - } - - free(fname); - return c->rsa; -} -#endif - -static bool read_ecdsa_private_key(void) { - FILE *fp; - char *fname; - - /* Check for PrivateKeyFile statement and read it */ - - if(!get_config_string(lookup_config(config_tree, "Ed25519PrivateKeyFile"), &fname)) { - xasprintf(&fname, "%s" SLASH "ed25519_key.priv", confbase); - } - - fp = fopen(fname, "r"); - - if(!fp) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error reading Ed25519 private key file `%s': %s", fname, strerror(errno)); - - if(errno == ENOENT) { - logger(DEBUG_ALWAYS, LOG_INFO, "Create an Ed25519 keypair with `tinc -n %s generate-ed25519-keys'.", netname ? netname : "."); - } - - free(fname); - return false; - } - -#if !defined(HAVE_MINGW) && !defined(HAVE_CYGWIN) - struct stat s; - - if(fstat(fileno(fp), &s)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not stat Ed25519 private key file `%s': %s'", fname, strerror(errno)); - free(fname); - return false; - } - - if(s.st_mode & ~0100700) { - logger(DEBUG_ALWAYS, LOG_WARNING, "Warning: insecure file permissions for Ed25519 private key file `%s'!", fname); - } - -#endif - - myself->connection->ecdsa = ecdsa_read_pem_private_key(fp); - fclose(fp); - - if(!myself->connection->ecdsa) { - logger(DEBUG_ALWAYS, LOG_ERR, "Reading Ed25519 private key file `%s' failed", fname); - } - - free(fname); - return myself->connection->ecdsa; -} - -static bool read_invitation_key(void) { - FILE *fp; - char fname[PATH_MAX]; - - if(invitation_key) { - ecdsa_free(invitation_key); - invitation_key = NULL; - } - - snprintf(fname, sizeof(fname), "%s" SLASH "invitations" SLASH "ed25519_key.priv", confbase); - - fp = fopen(fname, "r"); - - if(fp) { - invitation_key = ecdsa_read_pem_private_key(fp); - fclose(fp); - - if(!invitation_key) { - logger(DEBUG_ALWAYS, LOG_ERR, "Reading Ed25519 private key file `%s' failed", fname); - } - } - - return invitation_key; -} - -#ifndef DISABLE_LEGACY -static bool read_rsa_private_key(void) { - FILE *fp; - char *fname; - char *n, *d; - - /* First, check for simple PrivateKey statement */ - - if(get_config_string(lookup_config(config_tree, "PrivateKey"), &d)) { - if(!get_config_string(lookup_config(config_tree, "PublicKey"), &n)) { - logger(DEBUG_ALWAYS, LOG_ERR, "PrivateKey used but no PublicKey found!"); - free(d); + if(!fp) { + logger(LOG_ERR, "Error reading RSA public key file `%s': %s", pubname, strerror(errno)); + free(pubname); return false; } - myself->connection->rsa = rsa_set_hex_private_key(n, "FFFF", d); - free(n); - free(d); - return myself->connection->rsa; + c->rsa_key = PEM_read_RSAPublicKey(fp, &c->rsa_key, NULL, NULL); + fclose(fp); + + if(c->rsa_key) { + free(pubname); + return true; /* Woohoo. */ + } + + /* If it fails, try PEM_read_RSA_PUBKEY. */ + fp = fopen(pubname, "r"); + + if(!fp) { + logger(LOG_ERR, "Error reading RSA public key file `%s': %s", pubname, strerror(errno)); + free(pubname); + return false; + } + + c->rsa_key = PEM_read_RSA_PUBKEY(fp, &c->rsa_key, NULL, NULL); + fclose(fp); + + if(c->rsa_key) { +// RSA_blinding_on(c->rsa_key, NULL); + free(pubname); + return true; + } + + logger(LOG_ERR, "Reading RSA public key file `%s' failed: %s", pubname, strerror(errno)); + free(pubname); + return false; } - /* Else, check for PrivateKeyFile statement and read it */ + /* Else, check if a harnessed public key is in the config file */ + + xasprintf(&hcfname, "%s/hosts/%s", confbase, c->name); + fp = fopen(hcfname, "r"); + + if(!fp) { + logger(LOG_ERR, "Error reading RSA public key file `%s': %s", hcfname, strerror(errno)); + free(hcfname); + return false; + } + + c->rsa_key = PEM_read_RSAPublicKey(fp, &c->rsa_key, NULL, NULL); + fclose(fp); + + if(c->rsa_key) { + free(hcfname); + return true; + } + + /* Try again with PEM_read_RSA_PUBKEY. */ + + fp = fopen(hcfname, "r"); + + if(!fp) { + logger(LOG_ERR, "Error reading RSA public key file `%s': %s", hcfname, strerror(errno)); + free(hcfname); + return false; + } + + free(hcfname); + c->rsa_key = PEM_read_RSA_PUBKEY(fp, &c->rsa_key, NULL, NULL); +// RSA_blinding_on(c->rsa_key, NULL); + fclose(fp); + + if(c->rsa_key) { + return true; + } + + logger(LOG_ERR, "No public key for %s specified!", c->name); + + return false; +} + +static bool read_rsa_private_key(void) { + FILE *fp; + char *fname, *key, *pubkey; + BIGNUM *n = NULL; + BIGNUM *e = NULL; + BIGNUM *d = NULL; + + if(get_config_string(lookup_config(config_tree, "PrivateKey"), &key)) { + myself->connection->rsa_key = RSA_new(); + +// RSA_blinding_on(myself->connection->rsa_key, NULL); + if((size_t)BN_hex2bn(&d, key) != strlen(key)) { + logger(LOG_ERR, "Invalid PrivateKey for myself!"); + free(key); + return false; + } + + free(key); + + if(!get_config_string(lookup_config(config_tree, "PublicKey"), &pubkey)) { + BN_free(d); + logger(LOG_ERR, "PrivateKey used but no PublicKey found!"); + return false; + } + + if((size_t)BN_hex2bn(&n, pubkey) != strlen(pubkey)) { + free(pubkey); + BN_free(d); + logger(LOG_ERR, "Invalid PublicKey for myself!"); + return false; + } + + free(pubkey); + BN_hex2bn(&e, "FFFF"); + + if(!n || !e || !d || RSA_set0_key(myself->connection->rsa_key, n, e, d) != 1) { + BN_free(d); + BN_free(e); + BN_free(n); + logger(LOG_ERR, "RSA_set0_key() failed with PrivateKey for myself!"); + return false; + } + + return true; + } if(!get_config_string(lookup_config(config_tree, "PrivateKeyFile"), &fname)) { - xasprintf(&fname, "%s" SLASH "rsa_key.priv", confbase); + xasprintf(&fname, "%s/rsa_key.priv", confbase); } fp = fopen(fname, "r"); if(!fp) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error reading RSA private key file `%s': %s", + logger(LOG_ERR, "Error reading RSA private key file `%s': %s", fname, strerror(errno)); - - if(errno == ENOENT) { - logger(DEBUG_ALWAYS, LOG_INFO, "Create an RSA keypair with `tinc -n %s generate-rsa-keys'.", netname ? netname : "."); - } - free(fname); return false; } @@ -317,58 +243,49 @@ static bool read_rsa_private_key(void) { #if !defined(HAVE_MINGW) && !defined(HAVE_CYGWIN) struct stat s; - if(fstat(fileno(fp), &s)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not stat RSA private key file `%s': %s'", fname, strerror(errno)); + if(!fstat(fileno(fp), &s)) { + if(s.st_mode & ~0100700) { + logger(LOG_WARNING, "Warning: insecure file permissions for RSA private key file `%s'!", fname); + } + } else { + logger(LOG_WARNING, "Could not stat RSA private key file `%s': %s'", fname, strerror(errno)); + } + +#endif + + myself->connection->rsa_key = PEM_read_RSAPrivateKey(fp, NULL, NULL, NULL); + fclose(fp); + + if(!myself->connection->rsa_key) { + logger(LOG_ERR, "Reading RSA private key file `%s' failed: %s", + fname, strerror(errno)); free(fname); return false; } - if(s.st_mode & ~0100700) { - logger(DEBUG_ALWAYS, LOG_WARNING, "Warning: insecure file permissions for RSA private key file `%s'!", fname); - } - -#endif - - myself->connection->rsa = rsa_read_pem_private_key(fp); - fclose(fp); - - if(!myself->connection->rsa) { - logger(DEBUG_ALWAYS, LOG_ERR, "Reading RSA private key file `%s' failed: %s", fname, strerror(errno)); - } - free(fname); - return myself->connection->rsa; -} -#endif - -static timeout_t keyexpire_timeout; - -static void keyexpire_handler(void *data) { - regenerate_key(); - timeout_set(data, &(struct timeval) { - keylifetime, rand() % 100000 - }); + return true; } -void regenerate_key(void) { - logger(DEBUG_STATUS, LOG_INFO, "Expiring symmetric keys"); - send_key_changed(); - - for splay_each(node_t, n, node_tree) { - n->status.validkey_in = false; - } -} - -void load_all_nodes(void) { +/* + Read Subnets from all host config files +*/ +void load_all_subnets(void) { DIR *dir; struct dirent *ent; - char dname[PATH_MAX]; + char *dname; + char *fname; + avl_tree_t *config_tree; + config_t *cfg; + subnet_t *s, *s2; + node_t *n; - snprintf(dname, sizeof(dname), "%s" SLASH "hosts", confbase); + xasprintf(&dname, "%s/hosts", confbase); dir = opendir(dname); if(!dir) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not open %s: %s", dname, strerror(errno)); + logger(LOG_ERR, "Could not open %s: %s", dname, strerror(errno)); + free(dname); return; } @@ -377,12 +294,17 @@ void load_all_nodes(void) { continue; } - node_t *n = lookup_node(ent->d_name); + n = lookup_node(ent->d_name); +#ifdef _DIRENT_HAVE_D_TYPE + //if(ent->d_type != DT_REG) + // continue; +#endif - splay_tree_t *config_tree; + xasprintf(&fname, "%s/hosts/%s", confbase, ent->d_name); init_configuration(&config_tree); read_config_options(config_tree, ent->d_name); - read_host_config(config_tree, ent->d_name, true); + read_config_file(config_tree, fname); + free(fname); if(!n) { n = new_node(); @@ -390,25 +312,16 @@ void load_all_nodes(void) { node_add(n); } - if(strictsubnets) { - for(config_t *cfg = lookup_config(config_tree, "Subnet"); cfg; cfg = lookup_config_next(config_tree, cfg)) { - subnet_t *s, *s2; - - if(!get_config_subnet(cfg, &s)) { - continue; - } - - if((s2 = lookup_subnet(n, s))) { - s2->expires = -1; - free(s); - } else { - subnet_add(n, s); - } + for(cfg = lookup_config(config_tree, "Subnet"); cfg; cfg = lookup_config_next(config_tree, cfg)) { + if(!get_config_subnet(cfg, &s)) { + continue; } - } - if(lookup_config(config_tree, "Address")) { - n->status.has_address = true; + if((s2 = lookup_subnet(n, s))) { + s2->expires = -1; + } else { + subnet_add(n, s); + } } exit_configuration(&config_tree); @@ -419,7 +332,6 @@ void load_all_nodes(void) { char *get_name(void) { char *name = NULL; - char *returned_name; get_config_string(lookup_config(config_tree, "Name"), &name); @@ -427,34 +339,112 @@ char *get_name(void) { return NULL; } - returned_name = replace_name(name); - free(name); - return returned_name; -} + if(*name == '$') { + char *envname = getenv(name + 1); + char hostname[32] = ""; -bool setup_myself_reloadable(void) { - char *proxy = NULL; - char *rmode = NULL; - char *fmode = NULL; - char *bmode = NULL; - char *afname = NULL; - char *space; - bool choice; + if(!envname) { + if(strcmp(name + 1, "HOST")) { + fprintf(stderr, "Invalid Name: environment variable %s does not exist\n", name + 1); + free(name); + return false; + } - free(scriptinterpreter); - scriptinterpreter = NULL; - get_config_string(lookup_config(config_tree, "ScriptsInterpreter"), &scriptinterpreter); + if(gethostname(hostname, sizeof(hostname)) || !*hostname) { + fprintf(stderr, "Could not get hostname: %s\n", strerror(errno)); + free(name); + return false; + } + hostname[31] = 0; + envname = hostname; + } - free(scriptextension); + free(name); + name = xstrdup(envname); - if(!get_config_string(lookup_config(config_tree, "ScriptsExtension"), &scriptextension)) { - scriptextension = xstrdup(""); + for(char *c = name; *c; c++) + if(!isalnum(*c)) { + *c = '_'; + } } - get_config_string(lookup_config(config_tree, "Proxy"), &proxy); + if(!check_id(name)) { + logger(LOG_ERR, "Invalid name for myself!"); + free(name); + return false; + } - if(proxy) { + return name; +} + +/* + Configure node_t myself and set up the local sockets (listen only) +*/ +static bool setup_myself(void) { + config_t *cfg; + subnet_t *subnet; + char *name, *hostname, *mode, *afname, *cipher, *digest, *type; + char *fname = NULL; + char *address = NULL; + char *proxy = NULL; + char *space; + char *envp[5] = {0}; + struct addrinfo *ai, *aip, hint = {0}; + bool choice; + int i, err; + int replaywin_int; + bool port_specified = false; + + myself = new_node(); + myself->connection = new_connection(); + + myself->hostname = xstrdup("MYSELF"); + myself->connection->hostname = xstrdup("MYSELF"); + + myself->connection->options = 0; + myself->connection->protocol_version = PROT_CURRENT; + + if(!(name = get_name())) { + logger(LOG_ERR, "Name for tinc daemon required!"); + return false; + } + + /* Read tinc.conf and our own host config file */ + + myself->name = name; + myself->connection->name = xstrdup(name); + xasprintf(&fname, "%s/hosts/%s", confbase, name); + read_config_options(config_tree, name); + read_config_file(config_tree, fname); + free(fname); + + if(!read_rsa_private_key()) { + return false; + } + + if(!get_config_string(lookup_config(config_tree, "Port"), &myport)) { + myport = xstrdup("655"); + } else { + port_specified = true; + } + + /* Ensure myport is numeric */ + + if(!atoi(myport)) { + struct addrinfo *ai = str2addrinfo("localhost", myport, SOCK_DGRAM); + sockaddr_t sa; + + if(!ai || !ai->ai_addr) { + return false; + } + + free(myport); + memcpy(&sa, ai->ai_addr, ai->ai_addrlen); + sockaddr2str(&sa, NULL, &myport); + } + + if(get_config_string(lookup_config(config_tree, "Proxy"), &proxy)) { if((space = strchr(proxy, ' '))) { *space++ = 0; } @@ -472,7 +462,8 @@ bool setup_myself_reloadable(void) { } else if(!strcasecmp(proxy, "exec")) { proxytype = PROXY_EXEC; } else { - logger(DEBUG_ALWAYS, LOG_ERR, "Unknown proxy type %s!", proxy); + logger(LOG_ERR, "Unknown proxy type %s!", proxy); + free(proxy); return false; } @@ -483,7 +474,8 @@ bool setup_myself_reloadable(void) { case PROXY_EXEC: if(!space || !*space) { - logger(DEBUG_ALWAYS, LOG_ERR, "Argument expected for proxy type exec!"); + logger(LOG_ERR, "Argument expected for proxy type exec!"); + free(proxy); return false; } @@ -509,7 +501,8 @@ bool setup_myself_reloadable(void) { } if(!proxyhost || !*proxyhost || !proxyport || !*proxyport) { - logger(DEBUG_ALWAYS, LOG_ERR, "Host and port argument expected for proxy!"); + logger(LOG_ERR, "Host and port argument expected for proxy!"); + free(proxy); return false; } @@ -530,6 +523,22 @@ bool setup_myself_reloadable(void) { free(proxy); } + /* Read in all the subnets specified in the host configuration file */ + + cfg = lookup_config(config_tree, "Subnet"); + + while(cfg) { + if(!get_config_subnet(cfg, &subnet)) { + return false; + } + + subnet_add(myself, subnet); + + cfg = lookup_config_next(config_tree, cfg); + } + + /* Check some options */ + if(get_config_bool(lookup_config(config_tree, "IndirectData"), &choice) && choice) { myself->options |= OPTION_INDIRECT; } @@ -542,45 +551,42 @@ bool setup_myself_reloadable(void) { myself->options |= OPTION_INDIRECT; } - get_config_bool(lookup_config(config_tree, "UDPDiscovery"), &udp_discovery); - get_config_int(lookup_config(config_tree, "UDPDiscoveryKeepaliveInterval"), &udp_discovery_keepalive_interval); - get_config_int(lookup_config(config_tree, "UDPDiscoveryInterval"), &udp_discovery_interval); - get_config_int(lookup_config(config_tree, "UDPDiscoveryTimeout"), &udp_discovery_timeout); - - get_config_int(lookup_config(config_tree, "MTUInfoInterval"), &mtu_info_interval); - get_config_int(lookup_config(config_tree, "UDPInfoInterval"), &udp_info_interval); - get_config_bool(lookup_config(config_tree, "DirectOnly"), &directonly); + get_config_bool(lookup_config(config_tree, "StrictSubnets"), &strictsubnets); + get_config_bool(lookup_config(config_tree, "TunnelServer"), &tunnelserver); get_config_bool(lookup_config(config_tree, "LocalDiscovery"), &localdiscovery); + strictsubnets |= tunnelserver; - if(get_config_string(lookup_config(config_tree, "Mode"), &rmode)) { - if(!strcasecmp(rmode, "router")) { + if(get_config_string(lookup_config(config_tree, "Mode"), &mode)) { + if(!strcasecmp(mode, "router")) { routing_mode = RMODE_ROUTER; - } else if(!strcasecmp(rmode, "switch")) { + } else if(!strcasecmp(mode, "switch")) { routing_mode = RMODE_SWITCH; - } else if(!strcasecmp(rmode, "hub")) { + } else if(!strcasecmp(mode, "hub")) { routing_mode = RMODE_HUB; } else { - logger(DEBUG_ALWAYS, LOG_ERR, "Invalid routing mode!"); + logger(LOG_ERR, "Invalid routing mode!"); + free(mode); return false; } - free(rmode); + free(mode); } - if(get_config_string(lookup_config(config_tree, "Forwarding"), &fmode)) { - if(!strcasecmp(fmode, "off")) { + if(get_config_string(lookup_config(config_tree, "Forwarding"), &mode)) { + if(!strcasecmp(mode, "off")) { forwarding_mode = FMODE_OFF; - } else if(!strcasecmp(fmode, "internal")) { + } else if(!strcasecmp(mode, "internal")) { forwarding_mode = FMODE_INTERNAL; - } else if(!strcasecmp(fmode, "kernel")) { + } else if(!strcasecmp(mode, "kernel")) { forwarding_mode = FMODE_KERNEL; } else { - logger(DEBUG_ALWAYS, LOG_ERR, "Invalid forwarding mode!"); + logger(LOG_ERR, "Invalid forwarding mode!"); + free(mode); return false; } - free(fmode); + free(mode); } choice = !(myself->options & OPTION_TCPONLY); @@ -600,55 +606,34 @@ bool setup_myself_reloadable(void) { get_config_bool(lookup_config(config_tree, "PriorityInheritance"), &priorityinheritance); get_config_bool(lookup_config(config_tree, "DecrementTTL"), &decrement_ttl); - if(get_config_string(lookup_config(config_tree, "Broadcast"), &bmode)) { - if(!strcasecmp(bmode, "no")) { + if(get_config_string(lookup_config(config_tree, "Broadcast"), &mode)) { + if(!strcasecmp(mode, "no")) { broadcast_mode = BMODE_NONE; - } else if(!strcasecmp(bmode, "yes") || !strcasecmp(bmode, "mst")) { + } else if(!strcasecmp(mode, "yes") || !strcasecmp(mode, "mst")) { broadcast_mode = BMODE_MST; - } else if(!strcasecmp(bmode, "direct")) { + } else if(!strcasecmp(mode, "direct")) { broadcast_mode = BMODE_DIRECT; } else { - logger(DEBUG_ALWAYS, LOG_ERR, "Invalid broadcast mode!"); + logger(LOG_ERR, "Invalid broadcast mode!"); + free(mode); return false; } - free(bmode); + free(mode); } - const char *const DEFAULT_BROADCAST_SUBNETS[] = { "ff:ff:ff:ff:ff:ff", "255.255.255.255", "224.0.0.0/4", "ff00::/8" }; - - for(size_t i = 0; i < sizeof(DEFAULT_BROADCAST_SUBNETS) / sizeof(*DEFAULT_BROADCAST_SUBNETS); i++) { - subnet_t *s = new_subnet(); - - if(!str2net(s, DEFAULT_BROADCAST_SUBNETS[i])) { - abort(); - } - - subnet_add(NULL, s); - } - - for(config_t *cfg = lookup_config(config_tree, "BroadcastSubnet"); cfg; cfg = lookup_config_next(config_tree, cfg)) { - subnet_t *s; - - if(!get_config_subnet(cfg, &s)) { - continue; - } - - subnet_add(NULL, s); - } - -#if !defined(IP_TOS) +#if !defined(SOL_IP) || !defined(IP_TOS) if(priorityinheritance) { - logger(DEBUG_ALWAYS, LOG_WARNING, "%s not supported on this platform for IPv4 connections", "PriorityInheritance"); + logger(LOG_WARNING, "%s not supported on this platform for IPv4 connection", "PriorityInheritance"); } #endif -#if !defined(IPV6_TCLASS) +#if !defined(IPPROTO_IPV6) || !defined(IPV6_TCLASS) if(priorityinheritance) { - logger(DEBUG_ALWAYS, LOG_WARNING, "%s not supported on this platform for IPv6 connections", "PriorityInheritance"); + logger(LOG_WARNING, "%s not supported on this platform for IPv6 connection", "PriorityInheritance"); } #endif @@ -659,13 +644,50 @@ bool setup_myself_reloadable(void) { if(get_config_int(lookup_config(config_tree, "MaxTimeout"), &maxtimeout)) { if(maxtimeout <= 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Bogus maximum timeout!"); + logger(LOG_ERR, "Bogus maximum timeout!"); return false; } } else { maxtimeout = 900; } + if(get_config_int(lookup_config(config_tree, "MinTimeout"), &mintimeout)) { + if(mintimeout < 0) { + logger(LOG_ERR, "Bogus minimum timeout!"); + return false; + } + + if(mintimeout > maxtimeout) { + logger(LOG_WARNING, "Minimum timeout (%d s) cannot be larger than maximum timeout (%d s). Correcting !", mintimeout, maxtimeout); + mintimeout = maxtimeout; + } + } else { + mintimeout = 0; + } + + if(get_config_int(lookup_config(config_tree, "UDPRcvBuf"), &udp_rcvbuf)) { + if(udp_rcvbuf <= 0) { + logger(LOG_ERR, "UDPRcvBuf cannot be negative!"); + return false; + } + } + + if(get_config_int(lookup_config(config_tree, "UDPSndBuf"), &udp_sndbuf)) { + if(udp_sndbuf <= 0) { + logger(LOG_ERR, "UDPSndBuf cannot be negative!"); + return false; + } + } + + if(get_config_int(lookup_config(config_tree, "ReplayWindow"), &replaywin_int)) { + if(replaywin_int < 0) { + logger(LOG_ERR, "ReplayWindow cannot be negative!"); + return false; + } + + replaywin = (unsigned)replaywin_int; + } + if(get_config_string(lookup_config(config_tree, "AddressFamily"), &afname)) { if(!strcasecmp(afname, "IPv4")) { addressfamily = AF_INET; @@ -674,7 +696,8 @@ bool setup_myself_reloadable(void) { } else if(!strcasecmp(afname, "any")) { addressfamily = AF_UNSPEC; } else { - logger(DEBUG_ALWAYS, LOG_ERR, "Invalid address family!"); + logger(LOG_ERR, "Invalid address family!"); + free(afname); return false; } @@ -683,338 +706,99 @@ bool setup_myself_reloadable(void) { get_config_bool(lookup_config(config_tree, "Hostnames"), &hostnames); + /* Generate packet encryption key */ + + if(get_config_string(lookup_config(config_tree, "Cipher"), &cipher)) { + if(!strcasecmp(cipher, "none")) { + myself->incipher = NULL; + } else { + myself->incipher = EVP_get_cipherbyname(cipher); + + if(!myself->incipher) { + logger(LOG_ERR, "Unrecognized cipher type!"); + free(cipher); + return false; + } + } + + free(cipher); + } else { + myself->incipher = EVP_aes_256_cbc(); + } + + if(myself->incipher) { + myself->inkeylength = EVP_CIPHER_key_length(myself->incipher) + EVP_CIPHER_iv_length(myself->incipher); + } else { + myself->inkeylength = 1; + } + + /* We need to use a stream mode for the meta protocol. Use AES for this, + but try to match the key size with the one from the cipher selected + by Cipher. + + If Cipher is set to none, still use a low level of encryption for the + meta protocol. + */ + + int keylen = myself->incipher ? EVP_CIPHER_key_length(myself->incipher) : 0; + + if(keylen <= 16) { + myself->connection->outcipher = EVP_aes_128_cfb(); + } else if(keylen <= 24) { + myself->connection->outcipher = EVP_aes_192_cfb(); + } else { + myself->connection->outcipher = EVP_aes_256_cfb(); + } + if(!get_config_int(lookup_config(config_tree, "KeyExpire"), &keylifetime)) { keylifetime = 3600; } - if(!get_config_bool(lookup_config(config_tree, "AutoConnect"), &autoconnect)) { - autoconnect = true; - } - - get_config_bool(lookup_config(config_tree, "DisableBuggyPeers"), &disablebuggypeers); - - if(!get_config_int(lookup_config(config_tree, "InvitationExpire"), &invitation_lifetime)) { - invitation_lifetime = 604800; // 1 week - } - - read_invitation_key(); - - return true; -} - -/* - Add listening sockets. -*/ -static bool add_listen_address(char *address, bool bindto) { - char *port = myport; - - if(address) { - char *space = strchr(address, ' '); - - if(space) { - *space++ = 0; - port = space; - } - - if(!strcmp(address, "*")) { - *address = 0; - } - } - - struct addrinfo *ai, hint = {0}; - - hint.ai_family = addressfamily; - - hint.ai_socktype = SOCK_STREAM; - - hint.ai_protocol = IPPROTO_TCP; - - hint.ai_flags = AI_PASSIVE; - -#if HAVE_DECL_RES_INIT - res_init(); - -#endif - int err = getaddrinfo(address && *address ? address : NULL, port, &hint, &ai); - - free(address); - - if(err || !ai) { - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "getaddrinfo", err == EAI_SYSTEM ? strerror(err) : gai_strerror(err)); - return false; - } - - for(struct addrinfo *aip = ai; aip; aip = aip->ai_next) { - // Ignore duplicate addresses - bool found = false; - - for(int i = 0; i < listen_sockets; i++) - if(!memcmp(&listen_socket[i].sa, aip->ai_addr, aip->ai_addrlen)) { - found = true; - break; - } - - if(found) { - continue; - } - - if(listen_sockets >= MAXSOCKETS) { - logger(DEBUG_ALWAYS, LOG_ERR, "Too many listening sockets"); - return false; - } - - int tcp_fd = setup_listen_socket((sockaddr_t *) aip->ai_addr); - - if(tcp_fd < 0) { - continue; - } - - int udp_fd = setup_vpn_in_socket((sockaddr_t *) aip->ai_addr); - - if(udp_fd < 0) { - close(tcp_fd); - continue; - } - - io_add(&listen_socket[listen_sockets].tcp, handle_new_meta_connection, &listen_socket[listen_sockets], tcp_fd, IO_READ); - io_add(&listen_socket[listen_sockets].udp, handle_incoming_vpn_data, &listen_socket[listen_sockets], udp_fd, IO_READ); - - if(debug_level >= DEBUG_CONNECTIONS) { - char *hostname = sockaddr2hostname((sockaddr_t *) aip->ai_addr); - logger(DEBUG_CONNECTIONS, LOG_NOTICE, "Listening on %s", hostname); - free(hostname); - } - - listen_socket[listen_sockets].bindto = bindto; - memcpy(&listen_socket[listen_sockets].sa, aip->ai_addr, aip->ai_addrlen); - listen_sockets++; - } - - freeaddrinfo(ai); - return true; -} - -void device_enable(void) { - if(devops.enable) { - devops.enable(); - } - - /* Run tinc-up script to further initialize the tap interface */ - - environment_t env; - environment_init(&env); - execute_script("tinc-up", &env); - environment_exit(&env); -} - -void device_disable(void) { - environment_t env; - environment_init(&env); - execute_script("tinc-down", &env); - environment_exit(&env); - - if(devops.disable) { - devops.disable(); - } -} - -/* - Configure node_t myself and set up the local sockets (listen only) -*/ -static bool setup_myself(void) { - char *name, *hostname, *cipher, *digest, *type; - char *address = NULL; - bool port_specified = false; - - if(!(name = get_name())) { - logger(DEBUG_ALWAYS, LOG_ERR, "Name for tinc daemon required!"); - return false; - } - - myname = xstrdup(name); - myself = new_node(); - myself->connection = new_connection(); - myself->name = name; - myself->connection->name = xstrdup(name); - read_host_config(config_tree, name, true); - - if(!get_config_string(lookup_config(config_tree, "Port"), &myport)) { - myport = xstrdup("655"); - } else { - port_specified = true; - } - - myself->connection->options = 0; - myself->connection->protocol_major = PROT_MAJOR; - myself->connection->protocol_minor = PROT_MINOR; - - myself->options |= PROT_MINOR << 24; - -#ifdef DISABLE_LEGACY - experimental = read_ecdsa_private_key(); - - if(!experimental) { - logger(DEBUG_ALWAYS, LOG_ERR, "No private key available, cannot start tinc!"); - return false; - } - -#else - - if(!get_config_bool(lookup_config(config_tree, "ExperimentalProtocol"), &experimental)) { - experimental = read_ecdsa_private_key(); - - if(!experimental) { - logger(DEBUG_ALWAYS, LOG_WARNING, "Support for SPTPS disabled."); - } - } else { - if(experimental && !read_ecdsa_private_key()) { - return false; - } - } - - if(!read_rsa_private_key()) { - if(experimental) { - logger(DEBUG_ALWAYS, LOG_WARNING, "Support for legacy protocol disabled."); - } else { - logger(DEBUG_ALWAYS, LOG_ERR, "No private keys available, cannot start tinc!"); - return false; - } - } - -#endif - - /* Ensure myport is numeric */ - - if(!atoi(myport)) { - struct addrinfo *ai = str2addrinfo("localhost", myport, SOCK_DGRAM); - sockaddr_t sa; - - if(!ai || !ai->ai_addr) { - return false; - } - - free(myport); - memcpy(&sa, ai->ai_addr, ai->ai_addrlen); - freeaddrinfo(ai); - sockaddr2str(&sa, NULL, &myport); - } - - /* Read in all the subnets specified in the host configuration file */ - - for(config_t *cfg = lookup_config(config_tree, "Subnet"); cfg; cfg = lookup_config_next(config_tree, cfg)) { - subnet_t *subnet; - - if(!get_config_subnet(cfg, &subnet)) { - return false; - } - - subnet_add(myself, subnet); - } - - /* Check some options */ - - if(!setup_myself_reloadable()) { - return false; - } - - get_config_bool(lookup_config(config_tree, "StrictSubnets"), &strictsubnets); - get_config_bool(lookup_config(config_tree, "TunnelServer"), &tunnelserver); - strictsubnets |= tunnelserver; - - if(get_config_int(lookup_config(config_tree, "MaxConnectionBurst"), &max_connection_burst)) { - if(max_connection_burst <= 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "MaxConnectionBurst cannot be negative!"); - return false; - } - } - - if(get_config_int(lookup_config(config_tree, "UDPRcvBuf"), &udp_rcvbuf)) { - if(udp_rcvbuf < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "UDPRcvBuf cannot be negative!"); - return false; - } - } - - if(get_config_int(lookup_config(config_tree, "UDPSndBuf"), &udp_sndbuf)) { - if(udp_sndbuf < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "UDPSndBuf cannot be negative!"); - return false; - } - } - - get_config_int(lookup_config(config_tree, "FWMark"), &fwmark); -#ifndef SO_MARK - - if(fwmark) { - logger(DEBUG_ALWAYS, LOG_ERR, "FWMark not supported on this platform!"); - return false; - } - -#endif - - int replaywin_int; - - if(get_config_int(lookup_config(config_tree, "ReplayWindow"), &replaywin_int)) { - if(replaywin_int < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "ReplayWindow cannot be negative!"); - return false; - } - - replaywin = (unsigned)replaywin_int; - sptps_replaywin = replaywin; - } - -#ifndef DISABLE_LEGACY - /* Generate packet encryption key */ - - if(!get_config_string(lookup_config(config_tree, "Cipher"), &cipher)) { - cipher = xstrdup("aes-256-cbc"); - } - - if(!strcasecmp(cipher, "none")) { - myself->incipher = NULL; - } else if(!(myself->incipher = cipher_open_by_name(cipher))) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unrecognized cipher type!"); - free(cipher); - return false; - } - - free(cipher); - - timeout_add(&keyexpire_timeout, keyexpire_handler, &keyexpire_timeout, &(struct timeval) { - keylifetime, rand() % 100000 - }); + keyexpires = now + keylifetime; /* Check if we want to use message authentication codes... */ - int maclength = 4; - get_config_int(lookup_config(config_tree, "MACLength"), &maclength); + if(get_config_string(lookup_config(config_tree, "Digest"), &digest)) { + if(!strcasecmp(digest, "none")) { + myself->indigest = NULL; + } else { + myself->indigest = EVP_get_digestbyname(digest); - if(maclength < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Bogus MAC length!"); - return false; - } + if(!myself->indigest) { + logger(LOG_ERR, "Unrecognized digest type!"); + free(digest); + return false; + } + } - if(!get_config_string(lookup_config(config_tree, "Digest"), &digest)) { - digest = xstrdup("sha256"); - } - - if(!strcasecmp(digest, "none")) { - myself->indigest = NULL; - } else if(!(myself->indigest = digest_open_by_name(digest, maclength))) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unrecognized digest type!"); free(digest); - return false; + } else { + myself->indigest = EVP_sha256(); } - free(digest); -#endif + myself->connection->outdigest = EVP_sha256(); + + if(get_config_int(lookup_config(config_tree, "MACLength"), &myself->inmaclength)) { + if(myself->indigest) { + if(myself->inmaclength > EVP_MD_size(myself->indigest)) { + logger(LOG_ERR, "MAC length exceeds size of digest!"); + return false; + } else if(myself->inmaclength < 0) { + logger(LOG_ERR, "Bogus MAC length!"); + return false; + } + } + } else { + myself->inmaclength = 4; + } + + myself->connection->outmaclength = 0; /* Compression */ if(get_config_int(lookup_config(config_tree, "Compression"), &myself->incompression)) { if(myself->incompression < 0 || myself->incompression > 11) { - logger(DEBUG_ALWAYS, LOG_ERR, "Bogus compression level!"); + logger(LOG_ERR, "Bogus compression level!"); return false; } } else { @@ -1028,13 +812,13 @@ static bool setup_myself(void) { myself->nexthop = myself; myself->via = myself; myself->status.reachable = true; - myself->last_state_change = now.tv_sec; - myself->status.sptps = experimental; node_add(myself); graph(); - load_all_nodes(); + if(strictsubnets) { + load_all_subnets(); + } /* Open device */ @@ -1047,8 +831,6 @@ static bool setup_myself(void) { devops = raw_socket_devops; } else if(!strcasecmp(type, "multicast")) { devops = multicast_devops; - } else if(!strcasecmp(type, "fd")) { - devops = fd_devops; } #ifdef ENABLE_UML @@ -1066,16 +848,32 @@ static bool setup_myself(void) { free(type); } - get_config_bool(lookup_config(config_tree, "DeviceStandby"), &device_standby); - if(!devops.setup()) { return false; } - if(device_fd >= 0) { - io_add(&device_io, handle_device_data, NULL, device_fd, IO_READ); + /* Run tinc-up script to further initialize the tap interface */ + xasprintf(&envp[0], "NETNAME=%s", netname ? netname : ""); + xasprintf(&envp[1], "DEVICE=%s", device ? device : ""); + xasprintf(&envp[2], "INTERFACE=%s", iface ? iface : ""); + xasprintf(&envp[3], "NAME=%s", myself->name); + +#ifdef HAVE_MINGW + Sleep(1000); +#endif +#ifdef HAVE_CYGWIN + sleep(1); +#endif + execute_script("tinc-up", envp); + + for(i = 0; i < 4; i++) { + free(envp[i]); } + /* Run subnet-up scripts for our own subnets */ + + subnet_update(myself, NULL, true); + /* Open sockets */ if(!do_detach && getenv("LISTEN_FDS")) { @@ -1088,34 +886,33 @@ static bool setup_myself(void) { #endif if(listen_sockets > MAXSOCKETS) { - logger(DEBUG_ALWAYS, LOG_ERR, "Too many listening sockets"); + logger(LOG_ERR, "Too many listening sockets"); return false; } - for(int i = 0; i < listen_sockets; i++) { + for(i = 0; i < listen_sockets; i++) { salen = sizeof(sa); if(getsockname(i + 3, &sa.sa, &salen) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not get address of listen fd %d: %s", i + 3, sockstrerror(sockerrno)); + logger(LOG_ERR, "Could not get address of listen fd %d: %s", i + 3, sockstrerror(errno)); return false; } + listen_socket[i].tcp = i + 3; + #ifdef FD_CLOEXEC fcntl(i + 3, F_SETFD, FD_CLOEXEC); #endif - int udp_fd = setup_vpn_in_socket(&sa); + listen_socket[i].udp = setup_vpn_in_socket(&sa); - if(udp_fd < 0) { + if(listen_socket[i].udp < 0) { return false; } - io_add(&listen_socket[i].tcp, (io_cb_t)handle_new_meta_connection, &listen_socket[i], i + 3, IO_READ); - io_add(&listen_socket[i].udp, (io_cb_t)handle_incoming_vpn_data, &listen_socket[i], udp_fd, IO_READ); - - if(debug_level >= DEBUG_CONNECTIONS) { + ifdebug(CONNECTIONS) { hostname = sockaddr2hostname(&sa); - logger(DEBUG_CONNECTIONS, LOG_NOTICE, "Listening on %s", hostname); + logger(LOG_NOTICE, "Listening on %s", hostname); free(hostname); } @@ -1123,44 +920,94 @@ static bool setup_myself(void) { } } else { listen_sockets = 0; - int cfgs = 0; + cfg = lookup_config(config_tree, "BindToAddress"); - for(config_t *cfg = lookup_config(config_tree, "BindToAddress"); cfg; cfg = lookup_config_next(config_tree, cfg)) { - cfgs++; + do { get_config_string(cfg, &address); - if(!add_listen_address(address, true)) { + if(cfg) { + cfg = lookup_config_next(config_tree, cfg); + } + + char *port = myport; + + if(address) { + char *space = strchr(address, ' '); + + if(space) { + *space++ = 0; + port = space; + } + + if(!strcmp(address, "*")) { + *address = 0; + } + } + + hint.ai_family = addressfamily; + hint.ai_socktype = SOCK_STREAM; + hint.ai_protocol = IPPROTO_TCP; + hint.ai_flags = AI_PASSIVE; + +#if HAVE_DECL_RES_INIT + // ensure glibc reloads /etc/resolv.conf. + res_init(); +#endif + err = getaddrinfo(address && *address ? address : NULL, port, &hint, &ai); + free(address); + + if(err || !ai) { + logger(LOG_ERR, "System call `%s' failed: %s", "getaddrinfo", + gai_strerror(err)); return false; } - } - for(config_t *cfg = lookup_config(config_tree, "ListenAddress"); cfg; cfg = lookup_config_next(config_tree, cfg)) { - cfgs++; - get_config_string(cfg, &address); + for(aip = ai; aip; aip = aip->ai_next) { + if(listen_sockets >= MAXSOCKETS) { + logger(LOG_ERR, "Too many listening sockets"); + return false; + } - if(!add_listen_address(address, false)) { - return false; + listen_socket[listen_sockets].tcp = + setup_listen_socket((sockaddr_t *) aip->ai_addr); + + if(listen_socket[listen_sockets].tcp < 0) { + continue; + } + + listen_socket[listen_sockets].udp = + setup_vpn_in_socket((sockaddr_t *) aip->ai_addr); + + if(listen_socket[listen_sockets].udp < 0) { + continue; + } + + ifdebug(CONNECTIONS) { + hostname = sockaddr2hostname((sockaddr_t *) aip->ai_addr); + logger(LOG_NOTICE, "Listening on %s", hostname); + free(hostname); + } + + memcpy(&listen_socket[listen_sockets].sa, aip->ai_addr, aip->ai_addrlen); + listen_sockets++; } - } - if(!cfgs) - if(!add_listen_address(address, NULL)) { - return false; - } + freeaddrinfo(ai); + } while(cfg); } if(!listen_sockets) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unable to create any listening socket!"); + logger(LOG_ERR, "Unable to create any listening socket!"); return false; } /* If no Port option was specified, set myport to the port used by the first listening socket. */ - if(!port_specified || atoi(myport) == 0) { + if(!port_specified) { sockaddr_t sa; socklen_t salen = sizeof(sa); - if(!getsockname(listen_socket[0].udp.fd, &sa.sa, &salen)) { + if(!getsockname(listen_socket[0].udp, &sa.sa, &salen)) { free(myport); sockaddr2str(&sa, NULL, &myport); @@ -1170,36 +1017,9 @@ static bool setup_myself(void) { } } - xasprintf(&myself->hostname, "MYSELF port %s", myport); - myself->connection->hostname = xstrdup(myself->hostname); - - char *upnp = NULL; - get_config_string(lookup_config(config_tree, "UPnP"), &upnp); - bool upnp_tcp = false; - bool upnp_udp = false; - - if(upnp) { - if(!strcasecmp(upnp, "yes")) { - upnp_tcp = upnp_udp = true; - } else if(!strcasecmp(upnp, "udponly")) { - upnp_udp = true; - } - - free(upnp); - } - - if(upnp_tcp || upnp_udp) { -#ifdef HAVE_MINIUPNPC - upnp_init(upnp_tcp, upnp_udp); -#else - logger(DEBUG_ALWAYS, LOG_WARNING, "UPnP was requested, but tinc isn't built with miniupnpc support!"); -#endif - } - /* Done. */ - last_config_check = now.tv_sec; - + logger(LOG_NOTICE, "Ready"); return true; } @@ -1207,6 +1027,9 @@ static bool setup_myself(void) { initialize network */ bool setup_network(void) { + now = time(NULL); + + init_events(); init_connections(); init_subnets(); init_nodes(); @@ -1237,18 +1060,6 @@ bool setup_network(void) { return false; } - if(!init_control()) { - return false; - } - - if(!device_standby) { - device_enable(); - } - - /* Run subnet-up scripts for our own subnets */ - - subnet_update(myself, NULL, true); - return true; } @@ -1256,59 +1067,62 @@ bool setup_network(void) { close all open network connections */ void close_network_connections(void) { - for(list_node_t *node = connection_list->head, *next; node; node = next) { + avl_node_t *node, *next; + connection_t *c; + char *envp[5] = {0}; + int i; + + for(node = connection_tree->head; node; node = next) { next = node->next; - connection_t *c = node->data; - - /* Keep control connections open until the end, so they know when we really terminated */ - if(c->status.control) { - c->socket = -1; - } - + c = node->data; c->outgoing = NULL; terminate_connection(c, false); } - if(outgoing_list) { - list_delete_list(outgoing_list); + for(list_node_t *node = outgoing_list->head; node; node = node->next) { + outgoing_t *outgoing = node->data; + + if(outgoing->event) { + event_del(outgoing->event); + } } + list_delete_list(outgoing_list); + if(myself && myself->connection) { subnet_update(myself, NULL, false); - connection_del(myself->connection); + terminate_connection(myself->connection, false); + free_connection(myself->connection); } - for(int i = 0; i < listen_sockets; i++) { - io_del(&listen_socket[i].tcp); - io_del(&listen_socket[i].udp); - close(listen_socket[i].tcp.fd); - close(listen_socket[i].udp.fd); + for(i = 0; i < listen_sockets; i++) { + close(listen_socket[i].tcp); + close(listen_socket[i].udp); } + xasprintf(&envp[0], "NETNAME=%s", netname ? netname : ""); + xasprintf(&envp[1], "DEVICE=%s", device ? device : ""); + xasprintf(&envp[2], "INTERFACE=%s", iface ? iface : ""); + xasprintf(&envp[3], "NAME=%s", myself->name); + exit_requests(); exit_edges(); exit_subnets(); exit_nodes(); exit_connections(); + exit_events(); - if(!device_standby) { - device_disable(); + execute_script("tinc-down", envp); + + if(myport) { + free(myport); } - free(myport); - - if(device_fd >= 0) { - io_del(&device_io); + for(i = 0; i < 4; i++) { + free(envp[i]); } - if(devops.close) { - devops.close(); - } - - exit_control(); - - free(scriptextension); - free(scriptinterpreter); + devops.close(); return; } diff --git a/src/net_socket.c b/src/net_socket.c index dcf8372..6195c16 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -22,33 +22,33 @@ #include "system.h" -#include "address_cache.h" +#include "avl_tree.h" #include "conf.h" #include "connection.h" -#include "control_common.h" -#include "list.h" +#include "event.h" #include "logger.h" #include "meta.h" -#include "names.h" #include "net.h" #include "netutl.h" #include "protocol.h" +#include "proxy.h" #include "utils.h" #include "xalloc.h" +/* Needed on Mac OS/X */ +#ifndef SOL_TCP +#define SOL_TCP IPPROTO_TCP +#endif + int addressfamily = AF_UNSPEC; +int mintimeout = 0; int maxtimeout = 900; int seconds_till_retry = 5; -int udp_rcvbuf = 1024 * 1024; -int udp_sndbuf = 1024 * 1024; -int max_connection_burst = 10; -int fwmark; +int udp_rcvbuf = 0; +int udp_sndbuf = 0; listen_socket_t listen_socket[MAXSOCKETS]; int listen_sockets; -#ifndef HAVE_MINGW -io_t unix_socket; -#endif list_t *outgoing_list = NULL; /* Setup sockets */ @@ -60,21 +60,21 @@ static void configure_tcp(connection_t *c) { int flags = fcntl(c->socket, F_GETFL); if(fcntl(c->socket, F_SETFL, flags | O_NONBLOCK) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "fcntl for %s fd %d: %s", c->hostname, c->socket, strerror(errno)); + logger(LOG_ERR, "fcntl for %s: %s", c->hostname, strerror(errno)); } #elif defined(WIN32) unsigned long arg = 1; if(ioctlsocket(c->socket, FIONBIO, &arg) != 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "ioctlsocket for %s fd %d: %s", c->hostname, c->socket, sockstrerror(sockerrno)); + logger(LOG_ERR, "ioctlsocket for %s: %s", c->hostname, sockstrerror(sockerrno)); } #endif -#if defined(TCP_NODELAY) +#if defined(SOL_TCP) && defined(TCP_NODELAY) option = 1; - setsockopt(c->socket, IPPROTO_TCP, TCP_NODELAY, (void *)&option, sizeof(option)); + setsockopt(c->socket, SOL_TCP, TCP_NODELAY, (void *)&option, sizeof(option)); #endif #if defined(IP_TOS) && defined(IPTOS_LOWDELAY) @@ -86,14 +86,6 @@ static void configure_tcp(connection_t *c) { option = IPTOS_LOWDELAY; setsockopt(c->socket, IPPROTO_IPV6, IPV6_TCLASS, (void *)&option, sizeof(option)); #endif - -#if defined(SO_MARK) - - if(fwmark) { - setsockopt(c->socket, SOL_SOCKET, SO_MARK, (void *)&fwmark, sizeof(fwmark)); - } - -#endif } static bool bind_to_interface(int sd) { @@ -112,57 +104,22 @@ static bool bind_to_interface(int sd) { memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_ifrn.ifrn_name, iface, IFNAMSIZ); ifr.ifr_ifrn.ifrn_name[IFNAMSIZ - 1] = 0; + free(iface); status = setsockopt(sd, SOL_SOCKET, SO_BINDTODEVICE, (void *)&ifr, sizeof(ifr)); if(status) { - logger(DEBUG_ALWAYS, LOG_ERR, "Can't bind to interface %s: %s", iface, - sockstrerror(sockerrno)); + logger(LOG_ERR, "Can't bind to interface %s: %s", ifr.ifr_ifrn.ifrn_name, strerror(errno)); return false; } #else /* if !defined(SOL_SOCKET) || !defined(SO_BINDTODEVICE) */ - logger(DEBUG_ALWAYS, LOG_WARNING, "%s not supported on this platform", "BindToInterface"); + logger(LOG_WARNING, "%s not supported on this platform", "BindToInterface"); #endif return true; } -static bool bind_to_address(connection_t *c) { - int s = -1; - - for(int i = 0; i < listen_sockets && listen_socket[i].bindto; i++) { - if(listen_socket[i].sa.sa.sa_family != c->address.sa.sa_family) { - continue; - } - - if(s >= 0) { - return false; - } - - s = i; - } - - if(s < 0) { - return false; - } - - sockaddr_t sa = listen_socket[s].sa; - - if(sa.sa.sa_family == AF_INET) { - sa.in.sin_port = 0; - } else if(sa.sa.sa_family == AF_INET6) { - sa.in6.sin6_port = 0; - } - - if(bind(c->socket, &sa.sa, SALEN(sa.sa))) { - logger(DEBUG_CONNECTIONS, LOG_WARNING, "Can't bind outgoing socket: %s", sockstrerror(sockerrno)); - return false; - } - - return true; -} - int setup_listen_socket(const sockaddr_t *sa) { int nfd; char *addrstr; @@ -172,7 +129,7 @@ int setup_listen_socket(const sockaddr_t *sa) { nfd = socket(sa->sa.sa_family, SOCK_STREAM, IPPROTO_TCP); if(nfd < 0) { - logger(DEBUG_STATUS, LOG_ERR, "Creating metasocket failed: %s", sockstrerror(sockerrno)); + ifdebug(STATUS) logger(LOG_ERR, "Creating metasocket failed: %s", sockstrerror(sockerrno)); return -1; } @@ -195,46 +152,37 @@ int setup_listen_socket(const sockaddr_t *sa) { #warning IPV6_V6ONLY not defined #endif -#if defined(SO_MARK) - - if(fwmark) { - setsockopt(nfd, SOL_SOCKET, SO_MARK, (void *)&fwmark, sizeof(fwmark)); - } - -#endif - - if(get_config_string - (lookup_config(config_tree, "BindToInterface"), &iface)) { + if(get_config_string(lookup_config(config_tree, "BindToInterface"), &iface)) { #if defined(SOL_SOCKET) && defined(SO_BINDTODEVICE) struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_ifrn.ifrn_name, iface, IFNAMSIZ); ifr.ifr_ifrn.ifrn_name[IFNAMSIZ - 1] = 0; + free(iface); if(setsockopt(nfd, SOL_SOCKET, SO_BINDTODEVICE, (void *)&ifr, sizeof(ifr))) { closesocket(nfd); - logger(DEBUG_ALWAYS, LOG_ERR, "Can't bind to interface %s: %s", iface, - sockstrerror(sockerrno)); + logger(LOG_ERR, "Can't bind to interface %s: %s", ifr.ifr_ifrn.ifrn_name, strerror(sockerrno)); return -1; } #else - logger(DEBUG_ALWAYS, LOG_WARNING, "%s not supported on this platform", "BindToInterface"); + logger(LOG_WARNING, "%s not supported on this platform", "BindToInterface"); #endif } if(bind(nfd, &sa->sa, SALEN(sa->sa))) { closesocket(nfd); addrstr = sockaddr2hostname(sa); - logger(DEBUG_ALWAYS, LOG_ERR, "Can't bind to %s/tcp: %s", addrstr, sockstrerror(sockerrno)); + logger(LOG_ERR, "Can't bind to %s/tcp: %s", addrstr, sockstrerror(sockerrno)); free(addrstr); return -1; } if(listen(nfd, 3)) { closesocket(nfd); - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "listen", sockstrerror(sockerrno)); + logger(LOG_ERR, "System call `%s' failed: %s", "listen", sockstrerror(sockerrno)); return -1; } @@ -249,7 +197,7 @@ int setup_vpn_in_socket(const sockaddr_t *sa) { nfd = socket(sa->sa.sa_family, SOCK_DGRAM, IPPROTO_UDP); if(nfd < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Creating UDP socket failed: %s", sockstrerror(sockerrno)); + logger(LOG_ERR, "Creating UDP socket failed: %s", sockstrerror(sockerrno)); return -1; } @@ -263,7 +211,7 @@ int setup_vpn_in_socket(const sockaddr_t *sa) { if(fcntl(nfd, F_SETFL, flags | O_NONBLOCK) < 0) { closesocket(nfd); - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "fcntl", + logger(LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno)); return -1; } @@ -274,7 +222,7 @@ int setup_vpn_in_socket(const sockaddr_t *sa) { if(ioctlsocket(nfd, FIONBIO, &arg) != 0) { closesocket(nfd); - logger(DEBUG_ALWAYS, LOG_ERR, "Call to `%s' failed: %s", "ioctlsocket", sockstrerror(sockerrno)); + logger(LOG_ERR, "Call to `%s' failed: %s", "ioctlsocket", sockstrerror(sockerrno)); return -1; } } @@ -285,11 +233,11 @@ int setup_vpn_in_socket(const sockaddr_t *sa) { setsockopt(nfd, SOL_SOCKET, SO_BROADCAST, (void *)&option, sizeof(option)); if(udp_rcvbuf && setsockopt(nfd, SOL_SOCKET, SO_RCVBUF, (void *)&udp_rcvbuf, sizeof(udp_rcvbuf))) { - logger(DEBUG_ALWAYS, LOG_WARNING, "Can't set UDP SO_RCVBUF to %i: %s", udp_rcvbuf, sockstrerror(sockerrno)); + logger(LOG_WARNING, "Can't set UDP SO_RCVBUF to %i: %s", udp_rcvbuf, strerror(errno)); } if(udp_sndbuf && setsockopt(nfd, SOL_SOCKET, SO_SNDBUF, (void *)&udp_sndbuf, sizeof(udp_sndbuf))) { - logger(DEBUG_ALWAYS, LOG_WARNING, "Can't set UDP SO_SNDBUF to %i: %s", udp_sndbuf, sockstrerror(sockerrno)); + logger(LOG_WARNING, "Can't set UDP SO_SNDBUF to %i: %s", udp_sndbuf, strerror(errno)); } #if defined(IPV6_V6ONLY) @@ -334,14 +282,6 @@ int setup_vpn_in_socket(const sockaddr_t *sa) { setsockopt(nfd, IPPROTO_IPV6, IPV6_DONTFRAG, (void *)&option, sizeof(option)); } -#endif - -#if defined(SO_MARK) - - if(fwmark) { - setsockopt(nfd, SOL_SOCKET, SO_MARK, (void *)&fwmark, sizeof(fwmark)); - } - #endif if(!bind_to_interface(nfd)) { @@ -352,7 +292,7 @@ int setup_vpn_in_socket(const sockaddr_t *sa) { if(bind(nfd, &sa->sa, SALEN(sa->sa))) { closesocket(nfd); addrstr = sockaddr2hostname(sa); - logger(DEBUG_ALWAYS, LOG_ERR, "Can't bind to %s/udp: %s", addrstr, sockstrerror(sockerrno)); + logger(LOG_ERR, "Can't bind to %s/udp: %s", addrstr, sockstrerror(sockerrno)); free(addrstr); return -1; } @@ -360,29 +300,36 @@ int setup_vpn_in_socket(const sockaddr_t *sa) { return nfd; } /* int setup_vpn_in_socket */ -static void retry_outgoing_handler(void *data) { - setup_outgoing_connection(data, true); -} - void retry_outgoing(outgoing_t *outgoing) { outgoing->timeout += 5; + if(outgoing->timeout < mintimeout) { + outgoing->timeout = mintimeout; + } + if(outgoing->timeout > maxtimeout) { outgoing->timeout = maxtimeout; } - timeout_add(&outgoing->ev, retry_outgoing_handler, outgoing, &(struct timeval) { - outgoing->timeout, rand() % 100000 - }); + if(outgoing->event) { + event_del(outgoing->event); + } - logger(DEBUG_CONNECTIONS, LOG_NOTICE, "Trying to re-establish outgoing connection in %d seconds", outgoing->timeout); + outgoing->event = new_event(); + outgoing->event->handler = (event_handler_t) setup_outgoing_connection; + outgoing->event->time = now + outgoing->timeout; + outgoing->event->data = outgoing; + event_add(outgoing->event); + + ifdebug(CONNECTIONS) logger(LOG_NOTICE, + "Trying to re-establish outgoing connection in %d seconds", + outgoing->timeout); } void finish_connecting(connection_t *c) { - logger(DEBUG_CONNECTIONS, LOG_INFO, "Connected to %s (%s)", c->name, c->hostname); + ifdebug(CONNECTIONS) logger(LOG_INFO, "Connected to %s (%s)", c->name, c->hostname); - c->last_ping_time = now.tv_sec; - c->status.connecting = false; + c->last_ping_time = now; send_id(c); } @@ -392,14 +339,14 @@ static void do_outgoing_pipe(connection_t *c, char *command) { int fd[2]; if(socketpair(AF_UNIX, SOCK_STREAM, 0, fd)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not create socketpair: %s", sockstrerror(sockerrno)); + logger(LOG_ERR, "Could not create socketpair: %s\n", strerror(errno)); return; } if(fork()) { c->socket = fd[0]; close(fd[1]); - logger(DEBUG_CONNECTIONS, LOG_DEBUG, "Using proxy %s", command); + ifdebug(CONNECTIONS) logger(LOG_DEBUG, "Using proxy %s", command); return; } @@ -428,141 +375,137 @@ static void do_outgoing_pipe(connection_t *c, char *command) { int result = system(command); if(result < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not execute %s: %s", command, strerror(errno)); + logger(LOG_ERR, "Could not execute %s: %s\n", command, strerror(errno)); } else if(result) { - logger(DEBUG_ALWAYS, LOG_ERR, "%s exited with non-zero status %d", command, result); + logger(LOG_ERR, "%s exited with non-zero status %d", command, result); } exit(result); #else - logger(DEBUG_ALWAYS, LOG_ERR, "Proxy type exec not supported on this platform!"); + logger(LOG_ERR, "Proxy type exec not supported on this platform!"); return; #endif } -static void handle_meta_write(connection_t *c) { - if(c->outbuf.len <= c->outbuf.offset) { - return; - } - - ssize_t outlen = send(c->socket, c->outbuf.data + c->outbuf.offset, c->outbuf.len - c->outbuf.offset, 0); - - if(outlen <= 0) { - if(!sockerrno || sockerrno == EPIPE) { - logger(DEBUG_CONNECTIONS, LOG_NOTICE, "Connection closed by %s (%s)", c->name, c->hostname); - } else if(sockwouldblock(sockerrno)) { - logger(DEBUG_META, LOG_DEBUG, "Sending %d bytes to %s (%s) would block", c->outbuf.len - c->outbuf.offset, c->name, c->hostname); - return; - } else { - logger(DEBUG_CONNECTIONS, LOG_ERR, "Could not send %d bytes of data to %s (%s): %s", c->outbuf.len - c->outbuf.offset, c->name, c->hostname, sockstrerror(sockerrno)); +static bool is_valid_host_port(const char *host, const char *port) { + for(const char *p = host; *p; p++) + if(!isalnum(*p) && *p != '-' && *p != '.') { + return false; } - terminate_connection(c, c->edge); - return; - } - - buffer_read(&c->outbuf, outlen); - - if(!c->outbuf.len) { - io_set(&c->io, IO_READ); - } -} - -static void handle_meta_io(void *data, int flags) { - connection_t *c = data; - - if(c->status.connecting) { - /* - The event loop does not protect against spurious events. Verify that we are actually connected - by issuing an empty send() call. - - Note that the behavior of send() on potentially unconnected sockets differ between platforms: - +------------+-----------+-------------+-----------+ - | Event | POSIX | Linux | Windows | - +------------+-----------+-------------+-----------+ - | Spurious | ENOTCONN | EWOULDBLOCK | ENOTCONN | - | Failed | ENOTCONN | (cause) | ENOTCONN | - | Successful | (success) | (success) | (success) | - +------------+-----------+-------------+-----------+ - */ - if(send(c->socket, NULL, 0, 0) != 0) { - if(sockwouldblock(sockerrno)) { - return; - } - - int socket_error; - - if(!socknotconn(sockerrno)) { - socket_error = sockerrno; - } else { - socklen_t len = sizeof(socket_error); - getsockopt(c->socket, SOL_SOCKET, SO_ERROR, (void *)&socket_error, &len); - } - - if(socket_error) { - logger(DEBUG_CONNECTIONS, LOG_DEBUG, "Error while connecting to %s (%s): %s", c->name, c->hostname, sockstrerror(socket_error)); - terminate_connection(c, false); - } - - return; + for(const char *p = port; *p; p++) + if(!isalnum(*p)) { + return false; } - c->status.connecting = false; - finish_connecting(c); - } - - if(flags & IO_WRITE) { - handle_meta_write(c); - } else { - handle_meta_connection_data(c); - } + return true; } -bool do_outgoing_connection(outgoing_t *outgoing) { - const sockaddr_t *sa; +void do_outgoing_connection(connection_t *c) { struct addrinfo *proxyai = NULL; int result; -begin: - sa = get_recent_address(outgoing->address_cache); - - if(!sa) { - logger(DEBUG_CONNECTIONS, LOG_ERR, "Could not set up a meta connection to %s", outgoing->node->name); - retry_outgoing(outgoing); - return false; + if(!c->outgoing) { + logger(LOG_ERR, "do_outgoing_connection() for %s called without c->outgoing", c->name); + abort(); + } + +begin: + + if(!c->outgoing->ai) { + if(!c->outgoing->cfg) { + ifdebug(CONNECTIONS) logger(LOG_ERR, "Could not set up a meta connection to %s", + c->name); + c->status.remove = true; + retry_outgoing(c->outgoing); + c->outgoing = NULL; + return; + } + + char *address, *port, *space; + + get_config_string(c->outgoing->cfg, &address); + + space = strchr(address, ' '); + + if(space) { + port = xstrdup(space + 1); + *space = 0; + } else { + if(!get_config_string(lookup_config(c->config_tree, "Port"), &port)) { + port = xstrdup("655"); + } + } + + c->outgoing->ai = str2addrinfo(address, port, SOCK_STREAM); + + // If we cannot resolve the address, maybe we are using a proxy that can? + if(!c->outgoing->ai && proxytype != PROXY_NONE && is_valid_host_port(address, port)) { + memset(&c->address, 0, sizeof(c->address)); + c->address.sa.sa_family = AF_UNKNOWN; + c->address.unknown.address = address; + c->address.unknown.port = port; + } else { + free(address); + free(port); + } + + c->outgoing->aip = c->outgoing->ai; + c->outgoing->cfg = lookup_config_next(c->config_tree, c->outgoing->cfg); + + if(!c->outgoing->ai && proxytype != PROXY_NONE) { + goto connect; + } + } + + if(!c->outgoing->aip) { + if(c->outgoing->ai) { + freeaddrinfo(c->outgoing->ai); + } + + c->outgoing->ai = NULL; + goto begin; + } + + memcpy(&c->address, c->outgoing->aip->ai_addr, c->outgoing->aip->ai_addrlen); + c->outgoing->aip = c->outgoing->aip->ai_next; + +connect: + + if(c->hostname) { + free(c->hostname); } - connection_t *c = new_connection(); - c->outgoing = outgoing; - memcpy(&c->address, sa, SALEN(sa->sa)); c->hostname = sockaddr2hostname(&c->address); - logger(DEBUG_CONNECTIONS, LOG_INFO, "Trying to connect to %s (%s)", outgoing->node->name, c->hostname); + ifdebug(CONNECTIONS) logger(LOG_INFO, "Trying to connect to %s (%s)", c->name, + c->hostname); if(!proxytype) { c->socket = socket(c->address.sa.sa_family, SOCK_STREAM, IPPROTO_TCP); - configure_tcp(c); } else if(proxytype == PROXY_EXEC) { + c->status.proxy_passed = true; do_outgoing_pipe(c, proxyhost); } else { proxyai = str2addrinfo(proxyhost, proxyport, SOCK_STREAM); if(!proxyai) { - free_connection(c); goto begin; } - logger(DEBUG_CONNECTIONS, LOG_INFO, "Using proxy at %s port %s", proxyhost, proxyport); + ifdebug(CONNECTIONS) logger(LOG_INFO, "Using proxy at %s port %s", proxyhost, proxyport); c->socket = socket(proxyai->ai_family, SOCK_STREAM, IPPROTO_TCP); - configure_tcp(c); } if(c->socket == -1) { - logger(DEBUG_CONNECTIONS, LOG_ERR, "Creating socket for %s failed: %s", c->hostname, sockstrerror(sockerrno)); - free_connection(c); + ifdebug(CONNECTIONS) logger(LOG_ERR, "Creating socket for %s failed: %s", c->hostname, sockstrerror(sockerrno)); goto begin; } + if(proxytype != PROXY_EXEC) { + configure_tcp(c); + } + #ifdef FD_CLOEXEC fcntl(c->socket, F_SETFD, FD_CLOEXEC); #endif @@ -578,7 +521,35 @@ begin: #endif bind_to_interface(c->socket); - bind_to_address(c); + + int b = -1; + + for(int i = 0; i < listen_sockets; i++) { + if(listen_socket[i].sa.sa.sa_family == c->address.sa.sa_family) { + if(b == -1) { + b = i; + } else { + b = -1; + break; + } + } + } + + if(b != -1) { + sockaddr_t sa = listen_socket[b].sa; + + if(sa.sa.sa_family == AF_INET) { + sa.in.sin_port = 0; + } else if(sa.sa.sa_family == AF_INET6) { + sa.in6.sin6_port = 0; + } + + if(bind(c->socket, &sa.sa, SALEN(sa.sa))) { + char *addrstr = sockaddr2hostname(&sa); + logger(LOG_ERR, "Can't bind to %s/tcp: %s", addrstr, sockstrerror(sockerrno)); + free(addrstr); + } + } } /* Connect */ @@ -588,280 +559,175 @@ begin: } else if(proxytype == PROXY_EXEC) { result = 0; } else { - if(!proxyai) { - abort(); - } - result = connect(c->socket, proxyai->ai_addr, proxyai->ai_addrlen); freeaddrinfo(proxyai); } - if(result == -1 && !sockinprogress(sockerrno)) { - logger(DEBUG_CONNECTIONS, LOG_ERR, "Could not connect to %s (%s): %s", outgoing->node->name, c->hostname, sockstrerror(sockerrno)); - free_connection(c); + now = time(NULL); + + if(result == -1) { + if(sockinprogress(sockerrno)) { + c->last_ping_time = now; + c->status.connecting = true; + return; + } + + closesocket(c->socket); + + ifdebug(CONNECTIONS) logger(LOG_ERR, "%s: %s", c->hostname, sockstrerror(sockerrno)); goto begin; } - /* Now that there is a working socket, fill in the rest and register this connection. */ + finish_connecting(c); - c->last_ping_time = time(NULL); - c->status.connecting = true; - c->name = xstrdup(outgoing->node->name); -#ifndef DISABLE_LEGACY + return; +} + +void setup_outgoing_connection(outgoing_t *outgoing) { + connection_t *c; + node_t *n; + + outgoing->event = NULL; + + n = lookup_node(outgoing->name); + + if(n) + if(n->connection) { + ifdebug(CONNECTIONS) logger(LOG_INFO, "Already connected to %s", outgoing->name); + + n->connection->outgoing = outgoing; + return; + } + + c = new_connection(); + c->name = xstrdup(outgoing->name); c->outcipher = myself->connection->outcipher; c->outdigest = myself->connection->outdigest; -#endif c->outmaclength = myself->connection->outmaclength; c->outcompression = myself->connection->outcompression; - c->last_ping_time = now.tv_sec; + + init_configuration(&c->config_tree); + + if(!read_connection_config(c)) { + free_connection(c); + outgoing->timeout = maxtimeout; + retry_outgoing(outgoing); + return; + } + + outgoing->cfg = lookup_config(c->config_tree, "Address"); + + if(!outgoing->cfg) { + logger(LOG_ERR, "No address specified for %s", c->name); + free_connection(c); + outgoing->timeout = maxtimeout; + retry_outgoing(outgoing); + return; + } + + c->outgoing = outgoing; + c->last_ping_time = now; connection_add(c); - io_add(&c->io, handle_meta_io, c, c->socket, IO_READ | IO_WRITE); - - return true; -} - -void setup_outgoing_connection(outgoing_t *outgoing, bool verbose) { - (void)verbose; - timeout_del(&outgoing->ev); - - node_t *n = outgoing->node; - - if(n->connection) { - logger(DEBUG_CONNECTIONS, LOG_INFO, "Already connected to %s", n->name); - - if(!n->connection->outgoing) { - n->connection->outgoing = outgoing; - return; - } else { - goto remove; - } - } - - if(!outgoing->address_cache) { - outgoing->address_cache = open_address_cache(n); - } - - do_outgoing_connection(outgoing); - return; - -remove: - list_delete(outgoing_list, outgoing); + do_outgoing_connection(c); } /* accept a new tcp connect and create a new connection */ -void handle_new_meta_connection(void *data, int flags) { - (void)flags; - listen_socket_t *l = data; +bool handle_new_meta_connection(int sock) { + static const int max_accept_burst = 10; + static int last_accept_burst; + static int last_accept_time; connection_t *c; sockaddr_t sa; int fd; socklen_t len = sizeof(sa); - fd = accept(l->tcp.fd, &sa.sa, &len); + fd = accept(sock, &sa.sa, &len); if(fd < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Accepting a new connection failed: %s", sockstrerror(sockerrno)); - return; + logger(LOG_ERR, "Accepting a new connection failed: %s", sockstrerror(sockerrno)); + return false; + } + + if(last_accept_time == now) { + last_accept_burst++; + + if(last_accept_burst >= max_accept_burst) { + if(last_accept_burst == max_accept_burst) { + ifdebug(CONNECTIONS) logger(LOG_WARNING, "Throttling incoming connections"); + } + + tarpit(fd); + return false; + } + } else { + last_accept_burst = 0; + last_accept_time = now; } sockaddrunmap(&sa); - // Check if we get many connections from the same host - - static sockaddr_t prev_sa; - - if(!sockaddrcmp_noport(&sa, &prev_sa)) { - static int samehost_burst; - static int samehost_burst_time; - - if(now.tv_sec - samehost_burst_time > samehost_burst) { - samehost_burst = 0; - } else { - samehost_burst -= now.tv_sec - samehost_burst_time; - } - - samehost_burst_time = now.tv_sec; - samehost_burst++; - - if(samehost_burst > max_connection_burst) { - tarpit(fd); - return; - } - } - - memcpy(&prev_sa, &sa, sizeof(sa)); - - // Check if we get many connections from different hosts - - static int connection_burst; - static int connection_burst_time; - - if(now.tv_sec - connection_burst_time > connection_burst) { - connection_burst = 0; - } else { - connection_burst -= now.tv_sec - connection_burst_time; - } - - connection_burst_time = now.tv_sec; - connection_burst++; - - if(connection_burst >= max_connection_burst) { - connection_burst = max_connection_burst; - tarpit(fd); - return; - } - - // Accept the new connection - c = new_connection(); c->name = xstrdup(""); -#ifndef DISABLE_LEGACY c->outcipher = myself->connection->outcipher; c->outdigest = myself->connection->outdigest; -#endif c->outmaclength = myself->connection->outmaclength; c->outcompression = myself->connection->outcompression; c->address = sa; c->hostname = sockaddr2hostname(&sa); c->socket = fd; - c->last_ping_time = now.tv_sec; + c->last_ping_time = now; - logger(DEBUG_CONNECTIONS, LOG_NOTICE, "Connection from %s", c->hostname); - - io_add(&c->io, handle_meta_io, c, c->socket, IO_READ); + ifdebug(CONNECTIONS) logger(LOG_NOTICE, "Connection from %s", c->hostname); configure_tcp(c); connection_add(c); c->allow_request = ID; + + return true; } -#ifndef HAVE_MINGW -/* - accept a new UNIX socket connection -*/ -void handle_new_unix_connection(void *data, int flags) { - (void)flags; - io_t *io = data; - connection_t *c; - sockaddr_t sa; - int fd; - socklen_t len = sizeof(sa); - - fd = accept(io->fd, &sa.sa, &len); - - if(fd < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Accepting a new connection failed: %s", sockstrerror(sockerrno)); - return; - } - - sockaddrunmap(&sa); - - c = new_connection(); - c->name = xstrdup(""); - c->address = sa; - c->hostname = xstrdup("localhost port unix"); - c->socket = fd; - c->last_ping_time = now.tv_sec; - - logger(DEBUG_CONNECTIONS, LOG_NOTICE, "Connection from %s", c->hostname); - - io_add(&c->io, handle_meta_io, c, c->socket, IO_READ); - - connection_add(c); - - c->allow_request = ID; -} -#endif - static void free_outgoing(outgoing_t *outgoing) { - timeout_del(&outgoing->ev); + if(outgoing->ai) { + freeaddrinfo(outgoing->ai); + } - if(outgoing->address_cache) { - close_address_cache(outgoing->address_cache); + if(outgoing->name) { + free(outgoing->name); } free(outgoing); } void try_outgoing_connections(void) { - /* If there is no outgoing list yet, create one. Otherwise, mark all outgoings as deleted. */ + static config_t *cfg = NULL; + char *name; + outgoing_t *outgoing; - if(!outgoing_list) { - outgoing_list = list_alloc((list_action_t)free_outgoing); - } else { - for list_each(outgoing_t, outgoing, outgoing_list) { - outgoing->timeout = -1; - } - } + outgoing_list = list_alloc((list_action_t)free_outgoing); - /* Make sure there is one outgoing_t in the list for each ConnectTo. */ - - for(config_t *cfg = lookup_config(config_tree, "ConnectTo"); cfg; cfg = lookup_config_next(config_tree, cfg)) { - char *name; + for(cfg = lookup_config(config_tree, "ConnectTo"); cfg; cfg = lookup_config_next(config_tree, cfg)) { get_config_string(cfg, &name); if(!check_id(name)) { - logger(DEBUG_ALWAYS, LOG_ERR, + logger(LOG_ERR, "Invalid name for outgoing connection in %s line %d", cfg->file, cfg->line); free(name); continue; } - if(!strcmp(name, myself->name)) { - free(name); - continue; - } - - bool found = false; - - for list_each(outgoing_t, outgoing, outgoing_list) { - if(!strcmp(outgoing->node->name, name)) { - found = true; - outgoing->timeout = 0; - break; - } - } - - if(!found) { - outgoing_t *outgoing = xzalloc(sizeof(*outgoing)); - node_t *n = lookup_node(name); - - if(!n) { - n = new_node(); - n->name = xstrdup(name); - node_add(n); - } - - outgoing->node = n; - list_insert_tail(outgoing_list, outgoing); - setup_outgoing_connection(outgoing, true); - } + outgoing = xmalloc_and_zero(sizeof(*outgoing)); + outgoing->name = name; + list_insert_tail(outgoing_list, outgoing); + setup_outgoing_connection(outgoing); } - - /* Terminate any connections whose outgoing_t is to be deleted. */ - - for list_each(connection_t, c, connection_list) { - if(c->outgoing && c->outgoing->timeout == -1) { - c->outgoing = NULL; - logger(DEBUG_CONNECTIONS, LOG_INFO, "No more outgoing connection to %s", c->name); - terminate_connection(c, c->edge); - } - } - - /* Delete outgoing_ts for which there is no ConnectTo. */ - - for list_each(outgoing_t, outgoing, outgoing_list) - if(outgoing->timeout == -1) { - list_delete_node(outgoing_list, node); - } } diff --git a/src/netutl.c b/src/netutl.c index 2916e9a..abe3d87 100644 --- a/src/netutl.c +++ b/src/netutl.c @@ -1,7 +1,7 @@ /* netutl.c -- some supporting network utility code Copyright (C) 1998-2005 Ivo Timmermans - 2000-2013 Guus Sliepen + 2000-2016 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,19 +33,21 @@ bool hostnames = false; Return NULL on failure. */ struct addrinfo *str2addrinfo(const char *address, const char *service, int socktype) { - struct addrinfo *ai, hint = {0}; + struct addrinfo *ai = NULL, hint = {0}; int err; hint.ai_family = addressfamily; hint.ai_socktype = socktype; #if HAVE_DECL_RES_INIT + // ensure glibc reloads /etc/resolv.conf. res_init(); #endif err = getaddrinfo(address, service, &hint, &ai); if(err) { - logger(DEBUG_ALWAYS, LOG_WARNING, "Error looking up %s port %s: %s", address, service, err == EAI_SYSTEM ? strerror(errno) : gai_strerror(err)); + logger(LOG_WARNING, "Error looking up %s port %s: %s", address, + service, gai_strerror(err)); return NULL; } @@ -53,8 +55,8 @@ struct addrinfo *str2addrinfo(const char *address, const char *service, int sock } sockaddr_t str2sockaddr(const char *address, const char *port) { - struct addrinfo *ai, hint = {0}; - sockaddr_t result = {0}; + struct addrinfo *ai = NULL, hint = {0}; + sockaddr_t result; int err; hint.ai_family = AF_UNSPEC; @@ -64,7 +66,8 @@ sockaddr_t str2sockaddr(const char *address, const char *port) { err = getaddrinfo(address, port, &hint, &ai); if(err || !ai) { - logger(DEBUG_SCARY_THINGS, LOG_DEBUG, "Unknown type address %s port %s", address, port); + ifdebug(SCARY_THINGS) + logger(LOG_DEBUG, "Unknown type address %s port %s", address, port); result.sa.sa_family = AF_UNKNOWN; result.unknown.address = xstrdup(address); result.unknown.port = xstrdup(port); @@ -83,17 +86,7 @@ void sockaddr2str(const sockaddr_t *sa, char **addrstr, char **portstr) { char *scopeid; int err; - if(sa->sa.sa_family == AF_UNSPEC) { - if(addrstr) { - *addrstr = xstrdup("unspec"); - } - - if(portstr) { - *portstr = xstrdup("unspec"); - } - - return; - } else if(sa->sa.sa_family == AF_UNKNOWN) { + if(sa->sa.sa_family == AF_UNKNOWN) { if(addrstr) { *addrstr = xstrdup(sa->unknown.address); } @@ -108,7 +101,8 @@ void sockaddr2str(const sockaddr_t *sa, char **addrstr, char **portstr) { err = getnameinfo(&sa->sa, SALEN(sa->sa), address, sizeof(address), port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV); if(err) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while translating addresses: %s", err == EAI_SYSTEM ? strerror(errno) : gai_strerror(err)); + logger(LOG_ERR, "Error while translating addresses: %s", + gai_strerror(err)); abort(); } @@ -133,10 +127,7 @@ char *sockaddr2hostname(const sockaddr_t *sa) { char port[NI_MAXSERV] = "unknown"; int err; - if(sa->sa.sa_family == AF_UNSPEC) { - xasprintf(&str, "unspec port unspec"); - return str; - } else if(sa->sa.sa_family == AF_UNKNOWN) { + if(sa->sa.sa_family == AF_UNKNOWN) { xasprintf(&str, "%s port %s", sa->unknown.address, sa->unknown.port); return str; } @@ -145,7 +136,8 @@ char *sockaddr2hostname(const sockaddr_t *sa) { hostnames ? 0 : (NI_NUMERICHOST | NI_NUMERICSERV)); if(err) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while looking up hostname: %s", err == EAI_SYSTEM ? strerror(errno) : gai_strerror(err)); + logger(LOG_ERR, "Error while looking up hostname: %s", + gai_strerror(err)); } xasprintf(&str, "%s port %s", address, port); @@ -176,7 +168,7 @@ int sockaddrcmp_noport(const sockaddr_t *a, const sockaddr_t *b) { return memcmp(&a->in6.sin6_addr, &b->in6.sin6_addr, sizeof(a->in6.sin6_addr)); default: - logger(DEBUG_ALWAYS, LOG_ERR, "sockaddrcmp() was called with unknown address family %d, exitting!", + logger(LOG_ERR, "sockaddrcmp() was called with unknown address family %d, exitting!", a->sa.sa_family); abort(); } @@ -223,7 +215,7 @@ int sockaddrcmp(const sockaddr_t *a, const sockaddr_t *b) { return memcmp(&a->in6.sin6_port, &b->in6.sin6_port, sizeof(a->in6.sin6_port)); default: - logger(DEBUG_ALWAYS, LOG_ERR, "sockaddrcmp() was called with unknown address family %d, exitting!", + logger(LOG_ERR, "sockaddrcmp() was called with unknown address family %d, exitting!", a->sa.sa_family); abort(); } @@ -277,3 +269,79 @@ void sockaddr_setport(sockaddr_t *sa, const char *port) { return; } } + +/* Subnet mask handling */ + +int maskcmp(const void *va, const void *vb, int masklen) { + int i, m, result; + const char *a = va; + const char *b = vb; + + for(m = masklen, i = 0; m >= 8; m -= 8, i++) { + result = a[i] - b[i]; + + if(result) { + return result; + } + } + + if(m) + return (a[i] & (0x100 - (1 << (8 - m)))) - + (b[i] & (0x100 - (1 << (8 - m)))); + + return 0; +} + +void mask(void *va, int masklen, int len) { + int i; + char *a = va; + + i = masklen / 8; + masklen %= 8; + + if(masklen) { + a[i++] &= (0x100 - (1 << (8 - masklen))); + } + + for(; i < len; i++) { + a[i] = 0; + } +} + +void maskcpy(void *va, const void *vb, int masklen, int len) { + int i, m; + char *a = va; + const char *b = vb; + + for(m = masklen, i = 0; m >= 8; m -= 8, i++) { + a[i] = b[i]; + } + + if(m) { + a[i] = b[i] & (0x100 - (1 << (8 - m))); + i++; + } + + for(; i < len; i++) { + a[i] = 0; + } +} + +bool maskcheck(const void *va, int masklen, int len) { + int i; + const char *a = va; + + i = masklen / 8; + masklen %= 8; + + if(masklen && a[i++] & (0xff >> masklen)) { + return false; + } + + for(; i < len; i++) + if(a[i] != 0) { + return false; + } + + return true; +} diff --git a/src/netutl.h b/src/netutl.h index 4aa1542..cc3ccab 100644 --- a/src/netutl.h +++ b/src/netutl.h @@ -4,7 +4,7 @@ /* netutl.h -- header file for netutl.c Copyright (C) 1998-2005 Ivo Timmermans - 2000-2013 Guus Sliepen + 2000-2016 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,15 +25,19 @@ extern bool hostnames; -extern struct addrinfo *str2addrinfo(const char *address, const char *service, int socktype) __attribute__((__malloc__)); +extern struct addrinfo *str2addrinfo(const char *address, const char *service, int socktype); extern sockaddr_t str2sockaddr(const char *address, const char *port); -extern void sockaddr2str(const sockaddr_t *sa, char **address, char **port); -extern char *sockaddr2hostname(const sockaddr_t *sa) __attribute__((__malloc__)); +extern void sockaddr2str(const sockaddr_t *sa, char **addrstr, char **portstr); +extern char *sockaddr2hostname(const sockaddr_t *sa); extern int sockaddrcmp(const sockaddr_t *a, const sockaddr_t *b); extern int sockaddrcmp_noport(const sockaddr_t *a, const sockaddr_t *b); extern void sockaddrunmap(sockaddr_t *sa); extern void sockaddrfree(sockaddr_t *sa); extern void sockaddrcpy(sockaddr_t *dest, const sockaddr_t *src); extern void sockaddr_setport(sockaddr_t *sa, const char *port); +extern int maskcmp(const void *a, const void *b, int masklen); +extern void maskcpy(void *dest, const void *src, int masklen, int len); +extern void mask(void *mask, int masklen, int len); +extern bool maskcheck(const void *mask, int masklen, int len); #endif diff --git a/src/node.c b/src/node.c index 8f4b6ee..03be21c 100644 --- a/src/node.c +++ b/src/node.c @@ -1,6 +1,6 @@ /* node.c -- node tree management - Copyright (C) 2001-2013 Guus Sliepen , + Copyright (C) 2001-2016 Guus Sliepen , 2001-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -20,22 +20,16 @@ #include "system.h" -#include "address_cache.h" -#include "control_common.h" -#include "hash.h" +#include "avl_tree.h" #include "logger.h" #include "net.h" #include "netutl.h" #include "node.h" -#include "splay_tree.h" #include "utils.h" #include "xalloc.h" -#include "ed25519/sha512.h" - -splay_tree_t *node_tree; -static splay_tree_t *node_id_tree; -static splay_tree_t *node_udp_tree; +avl_tree_t *node_tree; /* Known nodes, sorted by name */ +avl_tree_t *node_udp_tree; /* Known nodes, sorted by address and port */ node_t *myself; @@ -43,49 +37,51 @@ static int node_compare(const node_t *a, const node_t *b) { return strcmp(a->name, b->name); } -static int node_id_compare(const node_t *a, const node_t *b) { - return memcmp(&a->id, &b->id, sizeof(node_id_t)); -} - static int node_udp_compare(const node_t *a, const node_t *b) { - int result = sockaddrcmp(&a->address, &b->address); - - if(result) { - return result; - } - - return (a->name && b->name) ? strcmp(a->name, b->name) : 0; + return sockaddrcmp(&a->address, &b->address); } void init_nodes(void) { - node_tree = splay_alloc_tree((splay_compare_t) node_compare, (splay_action_t) free_node); - node_id_tree = splay_alloc_tree((splay_compare_t) node_id_compare, NULL); - node_udp_tree = splay_alloc_tree((splay_compare_t) node_udp_compare, NULL); + node_tree = avl_alloc_tree((avl_compare_t) node_compare, (avl_action_t) free_node); + node_udp_tree = avl_alloc_tree((avl_compare_t) node_udp_compare, NULL); } void exit_nodes(void) { - splay_delete_tree(node_udp_tree); - splay_delete_tree(node_id_tree); - splay_delete_tree(node_tree); + avl_delete_tree(node_udp_tree); + avl_delete_tree(node_tree); } node_t *new_node(void) { - node_t *n = xzalloc(sizeof(*n)); + node_t *n = xmalloc_and_zero(sizeof(*n)); if(replaywin) { - n->late = xzalloc(replaywin); + n->late = xmalloc_and_zero(replaywin); } n->subnet_tree = new_subnet_tree(); n->edge_tree = new_edge_tree(); + n->inctx = EVP_CIPHER_CTX_new(); + n->outctx = EVP_CIPHER_CTX_new(); + + if(!n->inctx || !n->outctx) { + abort(); + } + n->mtu = MTU; n->maxmtu = MTU; - n->udp_ping_rtt = -1; return n; } void free_node(node_t *n) { + if(n->inkey) { + free(n->inkey); + } + + if(n->outkey) { + free(n->outkey); + } + if(n->subnet_tree) { free_subnet_tree(n->subnet_tree); } @@ -96,51 +92,51 @@ void free_node(node_t *n) { sockaddrfree(&n->address); -#ifndef DISABLE_LEGACY - cipher_close(n->incipher); - digest_close(n->indigest); - cipher_close(n->outcipher); - digest_close(n->outdigest); -#endif + EVP_CIPHER_CTX_free(n->outctx); + EVP_CIPHER_CTX_free(n->inctx); - ecdsa_free(n->ecdsa); - sptps_stop(&n->sptps); + if(n->mtuevent) { + event_del(n->mtuevent); + } - timeout_del(&n->udp_ping_timeout); + if(n->hostname) { + free(n->hostname); + } - free(n->hostname); - free(n->name); - free(n->late); + if(n->name) { + free(n->name); + } - if(n->address_cache) { - close_address_cache(n->address_cache); + if(n->late) { + free(n->late); } free(n); } void node_add(node_t *n) { - unsigned char buf[64]; - sha512(n->name, strlen(n->name), buf); - memcpy(&n->id, buf, sizeof(n->id)); - - splay_insert(node_tree, n); - splay_insert(node_id_tree, n); + avl_insert(node_tree, n); } void node_del(node_t *n) { - splay_delete(node_udp_tree, n); + avl_node_t *node, *next; + edge_t *e; + subnet_t *s; - for splay_each(subnet_t, s, n->subnet_tree) { + for(node = n->subnet_tree->head; node; node = next) { + next = node->next; + s = node->data; subnet_del(n, s); } - for splay_each(edge_t, e, n->edge_tree) { + for(node = n->edge_tree->head; node; node = next) { + next = node->next; + e = node->data; edge_del(e); } - splay_delete(node_id_tree, n); - splay_delete(node_tree, n); + avl_delete(node_udp_tree, n); + avl_delete(node_tree, n); } node_t *lookup_node(char *name) { @@ -148,82 +144,56 @@ node_t *lookup_node(char *name) { n.name = name; - return splay_search(node_tree, &n); -} - -node_t *lookup_node_id(const node_id_t *id) { - node_t n = {.id = *id}; - return splay_search(node_id_tree, &n); + return avl_search(node_tree, &n); } node_t *lookup_node_udp(const sockaddr_t *sa) { - node_t tmp = {.address = *sa}; - return splay_search(node_udp_tree, &tmp); + node_t n = {0}; + + n.address = *sa; + n.name = NULL; + + return avl_search(node_udp_tree, &n); } void update_node_udp(node_t *n, const sockaddr_t *sa) { if(n == myself) { - logger(DEBUG_ALWAYS, LOG_WARNING, "Trying to update UDP address of myself!"); + logger(LOG_WARNING, "Trying to update UDP address of myself!"); return; } - splay_delete(node_udp_tree, n); + avl_delete(node_udp_tree, n); + + if(n->hostname) { + free(n->hostname); + } if(sa) { n->address = *sa; - n->sock = 0; - - for(int i = 0; i < listen_sockets; i++) { - if(listen_socket[i].sa.sa.sa_family == sa->sa.sa_family) { - n->sock = i; - break; - } - } - - splay_insert(node_udp_tree, n); - free(n->hostname); n->hostname = sockaddr2hostname(&n->address); - logger(DEBUG_PROTOCOL, LOG_DEBUG, "UDP address of %s set to %s", n->name, n->hostname); + avl_insert(node_udp_tree, n); + ifdebug(PROTOCOL) logger(LOG_DEBUG, "UDP address of %s set to %s", n->name, n->hostname); + } else { + memset(&n->address, 0, sizeof(n->address)); + n->hostname = NULL; + ifdebug(PROTOCOL) logger(LOG_DEBUG, "UDP address of %s cleared", n->name); + } +} + +void dump_nodes(void) { + avl_node_t *node; + node_t *n; + + logger(LOG_DEBUG, "Nodes:"); + + for(node = node_tree->head; node; node = node->next) { + n = node->data; + logger(LOG_DEBUG, " %s at %s cipher %d digest %d maclength %d compression %d options %x status %04x nexthop %s via %s pmtu %d (min %d max %d)", + n->name, n->hostname, n->outcipher ? EVP_CIPHER_nid(n->outcipher) : 0, + n->outdigest ? EVP_MD_type(n->outdigest) : 0, n->outmaclength, n->outcompression, + n->options, bitfield_to_int(&n->status, sizeof(n->status)), n->nexthop ? n->nexthop->name : "-", + n->via ? n->via->name : "-", n->mtu, n->minmtu, n->maxmtu); } - /* invalidate UDP information - note that this is a security feature as well to make sure - we can't be tricked into flooding any random address with UDP packets */ - n->status.udp_confirmed = false; - n->maxrecentlen = 0; - n->mtuprobes = 0; - n->minmtu = 0; - n->maxmtu = MTU; -} - -bool dump_nodes(connection_t *c) { - for splay_each(node_t, n, node_tree) { - char id[2 * sizeof(n->id) + 1]; - - for(size_t c = 0; c < sizeof(n->id); ++c) { - snprintf(id + 2 * c, 3, "%02x", n->id.x[c]); - } - - id[sizeof(id) - 1] = 0; - send_request(c, "%d %d %s %s %s %d %d %d %d %x %x %s %s %d %d %d %d %ld %d %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64, CONTROL, REQ_DUMP_NODES, - n->name, id, n->hostname ? n->hostname : "unknown port unknown", -#ifdef DISABLE_LEGACY - 0, 0, 0, -#else - cipher_get_nid(n->outcipher), digest_get_nid(n->outdigest), (int)digest_length(n->outdigest), -#endif - n->outcompression, n->options, bitfield_to_int(&n->status, sizeof(n->status)), - n->nexthop ? n->nexthop->name : "-", n->via && n->via->name ? n->via->name : "-", n->distance, - n->mtu, n->minmtu, n->maxmtu, (long)n->last_state_change, n->udp_ping_rtt, - n->in_packets, n->in_bytes, n->out_packets, n->out_bytes); - } - - return send_request(c, "%d %d", CONTROL, REQ_DUMP_NODES); -} - -bool dump_traffic(connection_t *c) { - for splay_each(node_t, n, node_tree) - send_request(c, "%d %d %s %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64, CONTROL, REQ_DUMP_TRAFFIC, - n->name, n->in_packets, n->in_bytes, n->out_packets, n->out_bytes); - - return send_request(c, "%d %d", CONTROL, REQ_DUMP_TRAFFIC); + logger(LOG_DEBUG, "End of nodes."); } diff --git a/src/node.h b/src/node.h index 3daffd4..b360fe5 100644 --- a/src/node.h +++ b/src/node.h @@ -3,7 +3,7 @@ /* node.h -- header for node.c - Copyright (C) 2001-2013 Guus Sliepen , + Copyright (C) 2001-2016 Guus Sliepen , 2001-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -21,102 +21,76 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "splay_tree.h" -#include "cipher.h" +#include "avl_tree.h" #include "connection.h" -#include "digest.h" #include "event.h" #include "subnet.h" typedef struct node_status_t { unsigned int unused_active: 1; /* 1 if active (not used for nodes) */ unsigned int validkey: 1; /* 1 if we currently have a valid key for him */ - unsigned int waitingforkey: 1; /* 1 if we already sent out a request */ + unsigned int unused_waitingforkey: 1; /* 1 if we already sent out a request */ unsigned int visited: 1; /* 1 if this node has been visited by one of the graph algorithms */ unsigned int reachable: 1; /* 1 if this node is reachable in the graph */ unsigned int indirect: 1; /* 1 if this node is not directly reachable by us */ - unsigned int sptps: 1; /* 1 if this node supports SPTPS */ - unsigned int udp_confirmed: 1; /* 1 if the address is one that we received UDP traffic on */ - unsigned int send_locally: 1; /* 1 if the next UDP packet should be sent on the local network */ - unsigned int udppacket: 1; /* 1 if the most recently received packet was UDP */ - unsigned int validkey_in: 1; /* 1 if we have sent a valid key to him */ - unsigned int has_address: 1; /* 1 if we know an external address for this node */ - unsigned int unused: 20; + unsigned int unused: 26; } node_status_t; typedef struct node_t { char *name; /* name of this node */ - char *hostname; /* the hostname of its real ip */ - node_id_t id; /* unique node ID (name hash) */ uint32_t options; /* options turned on for this node */ int sock; /* Socket to use for outgoing UDP packets */ sockaddr_t address; /* his real (internet) ip to send UDP packets to */ + char *hostname; /* the hostname of its real ip */ node_status_t status; - time_t last_state_change; time_t last_req_key; - ecdsa_t *ecdsa; /* His public ECDSA key */ - sptps_t sptps; + const EVP_CIPHER *incipher; /* Cipher type for UDP packets received from him */ + char *inkey; /* Cipher key and iv */ + int inkeylength; /* Cipher key and iv length */ + EVP_CIPHER_CTX *inctx; /* Cipher context */ -#ifndef DISABLE_LEGACY - cipher_t *incipher; /* Cipher for UDP packets */ - digest_t *indigest; /* Digest for UDP packets */ + const EVP_CIPHER *outcipher; /* Cipher type for UDP packets sent to him*/ + char *outkey; /* Cipher key and iv */ + int outkeylength; /* Cipher key and iv length */ + EVP_CIPHER_CTX *outctx; /* Cipher context */ - cipher_t *outcipher; /* Cipher for UDP packets */ - digest_t *outdigest; /* Digest for UDP packets */ -#endif + const EVP_MD *indigest; /* Digest type for MAC of packets received from him */ + int inmaclength; /* Length of MAC */ + + const EVP_MD *outdigest; /* Digest type for MAC of packets sent to him*/ + int outmaclength; /* Length of MAC */ int incompression; /* Compressionlevel, 0 = no compression */ int outcompression; /* Compressionlevel, 0 = no compression */ - int distance; struct node_t *nexthop; /* nearest node from us to him */ struct edge_t *prevedge; /* nearest node from him to us */ struct node_t *via; /* next hop for UDP packets */ - splay_tree_t *subnet_tree; /* Pointer to a tree of subnets belonging to this node */ + avl_tree_t *subnet_tree; /* Pointer to a tree of subnets belonging to this node */ - splay_tree_t *edge_tree; /* Edges with this node as one of the endpoints */ + avl_tree_t *edge_tree; /* Edges with this node as one of the endpoints */ struct connection_t *connection; /* Connection associated with this node (if a direct connection exists) */ uint32_t sent_seqno; /* Sequence number last sent to this node */ uint32_t received_seqno; /* Sequence number last received from this node */ - uint32_t received; /* Total valid packets received from this node */ - uint32_t prev_received_seqno; - uint32_t prev_received; uint32_t farfuture; /* Packets in a row that have arrived from the far future */ unsigned char *late; /* Bitfield marking late packets */ - struct timeval udp_reply_sent; /* Last time a (gratuitous) UDP probe reply was sent */ - struct timeval udp_ping_sent; /* Last time a UDP probe was sent */ - int udp_ping_rtt; /* Round trip time of UDP ping (in microseconds; or -1 if !status.udp_confirmed) */ - timeout_t udp_ping_timeout; /* Ping timeout event */ - - struct timeval mtu_ping_sent; /* Last time a MTU probe was sent */ - - struct timeval mtu_info_sent; /* Last time a MTU_INFO message was sent */ - struct timeval udp_info_sent; /* Last time a UDP_INFO message was sent */ - - length_t maxrecentlen; /* Maximum size of recently received packets */ - length_t mtu; /* Maximum size of packets to send to this node */ length_t minmtu; /* Probed minimum MTU */ length_t maxmtu; /* Probed maximum MTU */ int mtuprobes; /* Number of probes */ - - uint64_t in_packets; - uint64_t in_bytes; - uint64_t out_packets; - uint64_t out_bytes; - - struct address_cache_t *address_cache; + event_t *mtuevent; /* Probe event */ } node_t; extern struct node_t *myself; -extern splay_tree_t *node_tree; +extern avl_tree_t *node_tree; +extern avl_tree_t *node_udp_tree; extern void init_nodes(void); extern void exit_nodes(void); @@ -125,10 +99,8 @@ extern void free_node(node_t *n); extern void node_add(node_t *n); extern void node_del(node_t *n); extern node_t *lookup_node(char *name); -extern node_t *lookup_node_id(const node_id_t *id); extern node_t *lookup_node_udp(const sockaddr_t *sa); -extern bool dump_nodes(struct connection_t *c); -extern bool dump_traffic(struct connection_t *c); extern void update_node_udp(node_t *n, const sockaddr_t *sa); +extern void dump_nodes(void); #endif diff --git a/src/nolegacy/crypto.c b/src/nolegacy/crypto.c deleted file mode 100644 index 44692fd..0000000 --- a/src/nolegacy/crypto.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - crypto.c -- Cryptographic miscellaneous functions and initialisation - Copyright (C) 2007-2014 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "../system.h" - -#include "../crypto.h" - -#ifndef HAVE_MINGW - -static int random_fd = -1; - -static void random_init(void) { - random_fd = open("/dev/urandom", O_RDONLY); - - if(random_fd < 0) { - random_fd = open("/dev/random", O_RDONLY); - } - - if(random_fd < 0) { - fprintf(stderr, "Could not open source of random numbers: %s\n", strerror(errno)); - abort(); - } -} - -static void random_exit(void) { - close(random_fd); -} - -void randomize(void *out, size_t outlen) { - while(outlen) { - size_t len = read(random_fd, out, outlen); - - if(len <= 0) { - if(errno == EAGAIN || errno == EINTR) { - continue; - } - - fprintf(stderr, "Could not read random numbers: %s\n", strerror(errno)); - abort(); - } - - out += len; - outlen -= len; - } -} - -#else - -#include -HCRYPTPROV prov; - -void random_init(void) { - if(!CryptAcquireContext(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) { - fprintf(stderr, "CryptAcquireContext() failed!\n"); - abort(); - } -} - -void random_exit(void) { - CryptReleaseContext(prov, 0); -} - -void randomize(void *out, size_t outlen) { - if(!CryptGenRandom(prov, outlen, out)) { - fprintf(stderr, "CryptGenRandom() failed\n"); - abort(); - } -} - -#endif - -void crypto_init(void) { - random_init(); -} - -void crypto_exit(void) { - random_exit(); -} diff --git a/src/nolegacy/prf.c b/src/nolegacy/prf.c deleted file mode 100644 index ce80f8c..0000000 --- a/src/nolegacy/prf.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - prf.c -- Pseudo-Random Function for key material generation - Copyright (C) 2011-2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "../system.h" - -#include "../prf.h" -#include "../ed25519/sha512.h" - -static void memxor(char *buf, char c, size_t len) { - for(size_t i = 0; i < len; i++) { - buf[i] ^= c; - } -} - -static const size_t mdlen = 64; -static const size_t blklen = 128; - -static bool hmac_sha512(const char *key, size_t keylen, const char *msg, size_t msglen, char *out) { - char tmp[blklen + mdlen]; - sha512_context md; - - if(keylen <= blklen) { - memcpy(tmp, key, keylen); - memset(tmp + keylen, 0, blklen - keylen); - } else { - if(sha512(key, keylen, tmp) != 0) { - return false; - } - - memset(tmp + mdlen, 0, blklen - mdlen); - } - - if(sha512_init(&md) != 0) { - return false; - } - - // ipad - memxor(tmp, 0x36, blklen); - - if(sha512_update(&md, tmp, blklen) != 0) { - return false; - } - - // message - if(sha512_update(&md, msg, msglen) != 0) { - return false; - } - - if(sha512_final(&md, tmp + blklen) != 0) { - return false; - } - - // opad - memxor(tmp, 0x36 ^ 0x5c, blklen); - - if(sha512(tmp, sizeof(tmp), out) != 0) { - return false; - } - - return true; -} - - -/* Generate key material from a master secret and a seed, based on RFC 4346 section 5. - We use SHA512 instead of MD5 and SHA1. - */ - -bool prf(const char *secret, size_t secretlen, char *seed, size_t seedlen, char *out, size_t outlen) { - /* Data is what the "inner" HMAC function processes. - It consists of the previous HMAC result plus the seed. - */ - - char data[mdlen + seedlen]; - memset(data, 0, mdlen); - memcpy(data + mdlen, seed, seedlen); - - char hash[mdlen]; - - while(outlen > 0) { - /* Inner HMAC */ - if(!hmac_sha512(secret, secretlen, data, sizeof(data), data)) { - return false; - } - - /* Outer HMAC */ - if(outlen >= mdlen) { - if(!hmac_sha512(secret, secretlen, data, sizeof(data), out)) { - return false; - } - - out += mdlen; - outlen -= mdlen; - } else { - if(!hmac_sha512(secret, secretlen, data, sizeof(data), hash)) { - return false; - } - - memcpy(out, hash, outlen); - out += outlen; - outlen = 0; - } - } - - return true; -} diff --git a/src/openssl/cipher.c b/src/openssl/cipher.c deleted file mode 100644 index d51ec0d..0000000 --- a/src/openssl/cipher.c +++ /dev/null @@ -1,215 +0,0 @@ -/* - cipher.c -- Symmetric block cipher handling - Copyright (C) 2007-2017 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "../system.h" - -#include -#include -#include - -#include "../cipher.h" -#include "../logger.h" -#include "../xalloc.h" - -struct cipher { - EVP_CIPHER_CTX *ctx; - const EVP_CIPHER *cipher; -}; - -static cipher_t *cipher_open(const EVP_CIPHER *evp_cipher) { - cipher_t *cipher = xzalloc(sizeof(*cipher)); - cipher->cipher = evp_cipher; - cipher->ctx = EVP_CIPHER_CTX_new(); - - if(!cipher->ctx) { - abort(); - } - - return cipher; -} - -cipher_t *cipher_open_by_name(const char *name) { - const EVP_CIPHER *evp_cipher = EVP_get_cipherbyname(name); - - if(!evp_cipher) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unknown cipher name '%s'!", name); - return NULL; - } - - return cipher_open(evp_cipher); -} - -cipher_t *cipher_open_by_nid(int nid) { - const EVP_CIPHER *evp_cipher = EVP_get_cipherbynid(nid); - - if(!evp_cipher) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unknown cipher nid %d!", nid); - return NULL; - } - - return cipher_open(evp_cipher); -} - -void cipher_close(cipher_t *cipher) { - if(!cipher) { - return; - } - - EVP_CIPHER_CTX_free(cipher->ctx); - free(cipher); -} - -size_t cipher_keylength(const cipher_t *cipher) { - if(!cipher || !cipher->cipher) { - return 0; - } - - return EVP_CIPHER_key_length(cipher->cipher) + EVP_CIPHER_iv_length(cipher->cipher); -} - -uint64_t cipher_budget(const cipher_t *cipher) { - /* Hopefully some failsafe way to calculate the maximum amount of bytes to - send/receive with a given cipher before we might run into birthday paradox - attacks. Because we might use different modes, the block size of the mode - might be 1 byte. In that case, use the IV length. Ensure the whole thing - is limited to what can be represented with a 64 bits integer. - */ - - if(!cipher || !cipher->cipher) { - return UINT64_MAX; // NULL cipher - } - - int ivlen = EVP_CIPHER_iv_length(cipher->cipher); - int blklen = EVP_CIPHER_block_size(cipher->cipher); - int len = blklen > 1 ? blklen : ivlen > 1 ? ivlen : 8; - int bits = len * 4 - 1; - return bits < 64 ? UINT64_C(1) << bits : UINT64_MAX; -} - -size_t cipher_blocksize(const cipher_t *cipher) { - if(!cipher || !cipher->cipher) { - return 1; - } - - return EVP_CIPHER_block_size(cipher->cipher); -} - -bool cipher_set_key(cipher_t *cipher, void *key, bool encrypt) { - bool result; - - if(encrypt) { - result = EVP_EncryptInit_ex(cipher->ctx, cipher->cipher, NULL, (unsigned char *)key, (unsigned char *)key + EVP_CIPHER_key_length(cipher->cipher)); - } else { - result = EVP_DecryptInit_ex(cipher->ctx, cipher->cipher, NULL, (unsigned char *)key, (unsigned char *)key + EVP_CIPHER_key_length(cipher->cipher)); - } - - if(result) { - return true; - } - - logger(DEBUG_ALWAYS, LOG_ERR, "Error while setting key: %s", ERR_error_string(ERR_get_error(), NULL)); - return false; -} - -bool cipher_set_key_from_rsa(cipher_t *cipher, void *key, size_t len, bool encrypt) { - bool result; - - if(encrypt) { - result = EVP_EncryptInit_ex(cipher->ctx, cipher->cipher, NULL, (unsigned char *)key + len - EVP_CIPHER_key_length(cipher->cipher), (unsigned char *)key + len - EVP_CIPHER_iv_length(cipher->cipher) - EVP_CIPHER_key_length(cipher->cipher)); - } else { - result = EVP_DecryptInit_ex(cipher->ctx, cipher->cipher, NULL, (unsigned char *)key + len - EVP_CIPHER_key_length(cipher->cipher), (unsigned char *)key + len - EVP_CIPHER_iv_length(cipher->cipher) - EVP_CIPHER_key_length(cipher->cipher)); - } - - if(result) { - return true; - } - - logger(DEBUG_ALWAYS, LOG_ERR, "Error while setting key: %s", ERR_error_string(ERR_get_error(), NULL)); - return false; -} - -bool cipher_encrypt(cipher_t *cipher, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) { - if(oneshot) { - int len, pad; - - if(EVP_EncryptInit_ex(cipher->ctx, NULL, NULL, NULL, NULL) - && EVP_EncryptUpdate(cipher->ctx, (unsigned char *)outdata, &len, indata, inlen) - && EVP_EncryptFinal_ex(cipher->ctx, (unsigned char *)outdata + len, &pad)) { - if(outlen) { - *outlen = len + pad; - } - - return true; - } - } else { - int len; - - if(EVP_EncryptUpdate(cipher->ctx, outdata, &len, indata, inlen)) { - if(outlen) { - *outlen = len; - } - - return true; - } - } - - logger(DEBUG_ALWAYS, LOG_ERR, "Error while encrypting: %s", ERR_error_string(ERR_get_error(), NULL)); - return false; -} - -bool cipher_decrypt(cipher_t *cipher, const void *indata, size_t inlen, void *outdata, size_t *outlen, bool oneshot) { - if(oneshot) { - int len, pad; - - if(EVP_DecryptInit_ex(cipher->ctx, NULL, NULL, NULL, NULL) - && EVP_DecryptUpdate(cipher->ctx, (unsigned char *)outdata, &len, indata, inlen) - && EVP_DecryptFinal_ex(cipher->ctx, (unsigned char *)outdata + len, &pad)) { - if(outlen) { - *outlen = len + pad; - } - - return true; - } - } else { - int len; - - if(EVP_EncryptUpdate(cipher->ctx, outdata, &len, indata, inlen)) { - if(outlen) { - *outlen = len; - } - - return true; - } - } - - logger(DEBUG_ALWAYS, LOG_ERR, "Error while decrypting: %s", ERR_error_string(ERR_get_error(), NULL)); - return false; -} - -int cipher_get_nid(const cipher_t *cipher) { - if(!cipher || !cipher->cipher) { - return 0; - } - - return EVP_CIPHER_nid(cipher->cipher); -} - -bool cipher_active(const cipher_t *cipher) { - return cipher && cipher->cipher && EVP_CIPHER_nid(cipher->cipher) != 0; -} diff --git a/src/openssl/crypto.c b/src/openssl/crypto.c deleted file mode 100644 index e594e73..0000000 --- a/src/openssl/crypto.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - crypto.c -- Cryptographic miscellaneous functions and initialisation - Copyright (C) 2007-2014 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "../system.h" - -#include -#include -#include - -#include "../crypto.h" - -#ifndef HAVE_MINGW - -static int random_fd = -1; - -static void random_init(void) { - random_fd = open("/dev/urandom", O_RDONLY); - - if(random_fd < 0) { - random_fd = open("/dev/random", O_RDONLY); - } - - if(random_fd < 0) { - fprintf(stderr, "Could not open source of random numbers: %s\n", strerror(errno)); - abort(); - } -} - -static void random_exit(void) { - close(random_fd); -} - -void randomize(void *vout, size_t outlen) { - char *out = vout; - - while(outlen) { - size_t len = read(random_fd, out, outlen); - - if(len <= 0) { - if(errno == EAGAIN || errno == EINTR) { - continue; - } - - fprintf(stderr, "Could not read random numbers: %s\n", strerror(errno)); - abort(); - } - - out += len; - outlen -= len; - } -} - -#else - -#include -HCRYPTPROV prov; - -void random_init(void) { - if(!CryptAcquireContext(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) { - fprintf(stderr, "CryptAcquireContext() failed!\n"); - abort(); - } -} - -void random_exit(void) { - CryptReleaseContext(prov, 0); -} - -void randomize(void *out, size_t outlen) { - if(!CryptGenRandom(prov, outlen, out)) { - fprintf(stderr, "CryptGenRandom() failed\n"); - abort(); - } -} - -#endif - -void crypto_init(void) { - random_init(); - - ENGINE_load_builtin_engines(); - ENGINE_register_all_complete(); - - ERR_load_crypto_strings(); - OpenSSL_add_all_algorithms(); - - if(!RAND_status()) { - fprintf(stderr, "Not enough entropy for the PRNG!\n"); - abort(); - } -} - -void crypto_exit(void) { - EVP_cleanup(); - ERR_free_strings(); - ENGINE_cleanup(); - random_exit(); -} diff --git a/src/openssl/digest.c b/src/openssl/digest.c deleted file mode 100644 index 9569f3c..0000000 --- a/src/openssl/digest.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - digest.c -- Digest handling - Copyright (C) 2007-2016 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "../system.h" -#include "../utils.h" -#include "../xalloc.h" - -#include -#include - -#include "digest.h" -#include "../digest.h" -#include "../logger.h" - -static digest_t *digest_open(const EVP_MD *evp_md, int maclength) { - digest_t *digest = xzalloc(sizeof(*digest)); - digest->digest = evp_md; - - int digestlen = EVP_MD_size(digest->digest); - - if(maclength > digestlen || maclength < 0) { - digest->maclength = digestlen; - } else { - digest->maclength = maclength; - } - - return digest; -} - -digest_t *digest_open_by_name(const char *name, int maclength) { - const EVP_MD *evp_md = EVP_get_digestbyname(name); - - if(!evp_md) { - logger(DEBUG_ALWAYS, LOG_DEBUG, "Unknown digest name '%s'!", name); - return false; - } - - return digest_open(evp_md, maclength); -} - -digest_t *digest_open_by_nid(int nid, int maclength) { - const EVP_MD *evp_md = EVP_get_digestbynid(nid); - - if(!evp_md) { - logger(DEBUG_ALWAYS, LOG_DEBUG, "Unknown digest nid %d!", nid); - return false; - } - - return digest_open(evp_md, maclength); -} - -bool digest_set_key(digest_t *digest, const void *key, size_t len) { -#ifdef HAVE_HMAC_CTX_NEW - digest->hmac_ctx = HMAC_CTX_new(); - HMAC_Init_ex(digest->hmac_ctx, key, len, digest->digest, NULL); -#else - digest->hmac_ctx = xzalloc(sizeof(*digest->hmac_ctx)); - HMAC_Init(digest->hmac_ctx, key, len, digest->digest); -#endif - - if(!digest->hmac_ctx) { - abort(); - } - - return true; -} - -void digest_close(digest_t *digest) { - if(!digest) { - return; - } - - if(digest->md_ctx) { - EVP_MD_CTX_destroy(digest->md_ctx); - } - -#ifdef HAVE_HMAC_CTX_NEW - - if(digest->hmac_ctx) { - HMAC_CTX_free(digest->hmac_ctx); - } - -#else - free(digest->hmac_ctx); -#endif - - free(digest); -} - -bool digest_create(digest_t *digest, const void *indata, size_t inlen, void *outdata) { - size_t len = EVP_MD_size(digest->digest); - unsigned char tmpdata[len]; - - if(digest->hmac_ctx) { - if(!HMAC_Init_ex(digest->hmac_ctx, NULL, 0, NULL, NULL) - || !HMAC_Update(digest->hmac_ctx, indata, inlen) - || !HMAC_Final(digest->hmac_ctx, tmpdata, NULL)) { - logger(DEBUG_ALWAYS, LOG_DEBUG, "Error creating digest: %s", ERR_error_string(ERR_get_error(), NULL)); - return false; - } - } else { - if(!digest->md_ctx) { - digest->md_ctx = EVP_MD_CTX_create(); - } - - if(!digest->md_ctx) { - abort(); - } - - if(!EVP_DigestInit(digest->md_ctx, digest->digest) - || !EVP_DigestUpdate(digest->md_ctx, indata, inlen) - || !EVP_DigestFinal(digest->md_ctx, tmpdata, NULL)) { - logger(DEBUG_ALWAYS, LOG_DEBUG, "Error creating digest: %s", ERR_error_string(ERR_get_error(), NULL)); - return false; - } - } - - memcpy(outdata, tmpdata, digest->maclength); - return true; -} - -bool digest_verify(digest_t *digest, const void *indata, size_t inlen, const void *cmpdata) { - size_t len = digest->maclength; - unsigned char outdata[len]; - - return digest_create(digest, indata, inlen, outdata) && !memcmp(cmpdata, outdata, digest->maclength); -} - -int digest_get_nid(const digest_t *digest) { - if(!digest || !digest->digest) { - return 0; - } - - return EVP_MD_type(digest->digest); -} - -size_t digest_keylength(const digest_t *digest) { - if(!digest || !digest->digest) { - return 0; - } - - return EVP_MD_size(digest->digest); -} - -size_t digest_length(const digest_t *digest) { - if(!digest) { - return 0; - } - - return digest->maclength; -} - -bool digest_active(const digest_t *digest) { - return digest && digest->digest && EVP_MD_type(digest->digest) != 0; -} diff --git a/src/openssl/digest.h b/src/openssl/digest.h deleted file mode 100644 index 420b11e..0000000 --- a/src/openssl/digest.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef TINC_OPENSSL_DIGEST_H -#define TINC_OPENSSL_DIGEST_H - -/* - digest.h -- header file digest.c - Copyright (C) 2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include -#include - -struct digest { - const EVP_MD *digest; - HMAC_CTX *hmac_ctx; - EVP_MD_CTX *md_ctx; - int maclength; -}; - -#endif diff --git a/src/openssl/prf.c b/src/openssl/prf.c deleted file mode 100644 index 37af2ef..0000000 --- a/src/openssl/prf.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - prf.c -- Pseudo-Random Function for key material generation - Copyright (C) 2011-2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "../system.h" - -#include - -#include "digest.h" -#include "../digest.h" -#include "../prf.h" - -/* Generate key material from a master secret and a seed, based on RFC 4346 section 5. - We use SHA512 instead of MD5 and SHA1. - */ - -static bool prf_xor(int nid, const char *secret, size_t secretlen, char *seed, size_t seedlen, char *out, size_t outlen) { - digest_t *digest = digest_open_by_nid(nid, -1); - - if(!digest) { - return false; - } - - if(!digest_set_key(digest, secret, secretlen)) { - digest_close(digest); - return false; - } - - size_t len = digest_length(digest); - - /* Data is what the "inner" HMAC function processes. - It consists of the previous HMAC result plus the seed. - */ - - char data[len + seedlen]; - memset(data, 0, len); - memcpy(data + len, seed, seedlen); - - char hash[len]; - - while(outlen > 0) { - /* Inner HMAC */ - if(!digest_create(digest, data, len + seedlen, data)) { - digest_close(digest); - return false; - } - - /* Outer HMAC */ - if(!digest_create(digest, data, len + seedlen, hash)) { - digest_close(digest); - return false; - } - - /* XOR the results of the outer HMAC into the out buffer */ - for(size_t i = 0; i < len && i < outlen; i++) { - *out++ ^= hash[i]; - } - - outlen -= len; - } - - digest_close(digest); - return true; -} - -bool prf(const char *secret, size_t secretlen, char *seed, size_t seedlen, char *out, size_t outlen) { - /* This construction allows us to easily switch back to a scheme where the PRF is calculated using two different digest algorithms. */ - memset(out, 0, outlen); - - return prf_xor(NID_sha512, secret, secretlen, seed, seedlen, out, outlen); -} diff --git a/src/openssl/rsa.c b/src/openssl/rsa.c deleted file mode 100644 index 0e81172..0000000 --- a/src/openssl/rsa.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - rsa.c -- RSA key handling - Copyright (C) 2007-2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "../system.h" - -#include -#include - -#define TINC_RSA_INTERNAL -typedef RSA rsa_t; - -#include "../logger.h" -#include "../rsa.h" - -// Set RSA keys - -#ifndef HAVE_RSA_SET0_KEY -int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) { - BN_free(r->n); - r->n = n; - BN_free(r->e); - r->e = e; - BN_free(r->d); - r->d = d; - return 1; -} -#endif - -rsa_t *rsa_set_hex_public_key(char *n, char *e) { - BIGNUM *bn_n = NULL; - BIGNUM *bn_e = NULL; - - if((size_t)BN_hex2bn(&bn_n, n) != strlen(n) || (size_t)BN_hex2bn(&bn_e, e) != strlen(e)) { - BN_free(bn_e); - BN_free(bn_n); - return false; - } - - rsa_t *rsa = RSA_new(); - - if(!rsa) { - return NULL; - } - - RSA_set0_key(rsa, bn_n, bn_e, NULL); - - return rsa; -} - -rsa_t *rsa_set_hex_private_key(char *n, char *e, char *d) { - BIGNUM *bn_n = NULL; - BIGNUM *bn_e = NULL; - BIGNUM *bn_d = NULL; - - if((size_t)BN_hex2bn(&bn_n, n) != strlen(n) || (size_t)BN_hex2bn(&bn_e, e) != strlen(e) || (size_t)BN_hex2bn(&bn_d, d) != strlen(d)) { - BN_free(bn_d); - BN_free(bn_e); - BN_free(bn_n); - return false; - } - - rsa_t *rsa = RSA_new(); - - if(!rsa) { - return NULL; - } - - RSA_set0_key(rsa, bn_n, bn_e, bn_d); - - return rsa; -} - -// Read PEM RSA keys - -rsa_t *rsa_read_pem_public_key(FILE *fp) { - rsa_t *rsa = PEM_read_RSAPublicKey(fp, NULL, NULL, NULL); - - if(!rsa) { - rewind(fp); - rsa = PEM_read_RSA_PUBKEY(fp, NULL, NULL, NULL); - } - - if(!rsa) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unable to read RSA public key: %s", ERR_error_string(ERR_get_error(), NULL)); - } - - return rsa; -} - -rsa_t *rsa_read_pem_private_key(FILE *fp) { - rsa_t *rsa = PEM_read_RSAPrivateKey(fp, NULL, NULL, NULL); - - if(!rsa) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unable to read RSA private key: %s", ERR_error_string(ERR_get_error(), NULL)); - } - - return rsa; -} - -size_t rsa_size(rsa_t *rsa) { - return RSA_size(rsa); -} - -bool rsa_public_encrypt(rsa_t *rsa, void *in, size_t len, void *out) { - if((size_t)RSA_public_encrypt(len, in, out, rsa, RSA_NO_PADDING) == len) { - return true; - } - - logger(DEBUG_ALWAYS, LOG_ERR, "Unable to perform RSA encryption: %s", ERR_error_string(ERR_get_error(), NULL)); - return false; -} - -bool rsa_private_decrypt(rsa_t *rsa, void *in, size_t len, void *out) { - if((size_t)RSA_private_decrypt(len, in, out, rsa, RSA_NO_PADDING) == len) { - return true; - } - - logger(DEBUG_ALWAYS, LOG_ERR, "Unable to perform RSA decryption: %s", ERR_error_string(ERR_get_error(), NULL)); - return false; -} - -bool rsa_active(rsa_t *rsa) { - return rsa; -} - -void rsa_free(rsa_t *rsa) { - if(rsa) { - RSA_free(rsa); - } -} diff --git a/src/openssl/rsagen.c b/src/openssl/rsagen.c deleted file mode 100644 index 79127f6..0000000 --- a/src/openssl/rsagen.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - rsagen.c -- RSA key generation and export - Copyright (C) 2008-2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "../system.h" - -#include -#include - -#define TINC_RSA_INTERNAL -typedef RSA rsa_t; - -#include "../logger.h" -#include "../rsagen.h" -#include "../xalloc.h" - -/* This function prettyprints the key generation process */ - -static int indicator(int a, int b, BN_GENCB *cb) { - (void)cb; - - switch(a) { - case 0: - fprintf(stderr, "."); - break; - - case 1: - fprintf(stderr, "+"); - break; - - case 2: - fprintf(stderr, "-"); - break; - - case 3: - switch(b) { - case 0: - fprintf(stderr, " p\n"); - break; - - case 1: - fprintf(stderr, " q\n"); - break; - - default: - fprintf(stderr, "?"); - } - - break; - - default: - fprintf(stderr, "?"); - } - - return 1; -} - -// Generate RSA key - -#ifndef HAVE_BN_GENCB_NEW -BN_GENCB *BN_GENCB_new(void) { - return xzalloc(sizeof(BN_GENCB)); -} - -void BN_GENCB_free(BN_GENCB *cb) { - free(cb); -} -#endif - -rsa_t *rsa_generate(size_t bits, unsigned long exponent) { - BIGNUM *bn_e = BN_new(); - rsa_t *rsa = RSA_new(); - BN_GENCB *cb = BN_GENCB_new(); - - if(!bn_e || !rsa || !cb) { - abort(); - } - - BN_set_word(bn_e, exponent); - BN_GENCB_set(cb, indicator, NULL); - - int result = RSA_generate_key_ex(rsa, bits, bn_e, cb); - - BN_GENCB_free(cb); - BN_free(bn_e); - - if(!result) { - fprintf(stderr, "Error during key generation!\n"); - RSA_free(rsa); - return NULL; - } - - return rsa; -} - -// Write PEM RSA keys - -bool rsa_write_pem_public_key(rsa_t *rsa, FILE *fp) { - return PEM_write_RSAPublicKey(fp, rsa); -} - -bool rsa_write_pem_private_key(rsa_t *rsa, FILE *fp) { - return PEM_write_RSAPrivateKey(fp, rsa, NULL, NULL, 0, NULL, NULL); -} diff --git a/src/pidfile.c b/src/pidfile.c new file mode 100644 index 0000000..dd17267 --- /dev/null +++ b/src/pidfile.c @@ -0,0 +1,142 @@ +/* + pidfile.c - interact with pidfiles + Copyright (c) 1995 Martin Schulze + + This file is part of the sysklogd package, a kernel and system log daemon. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +/* left unaltered for tinc -- Ivo Timmermans */ +/* + * Sat Aug 19 13:24:33 MET DST 1995: Martin Schulze + * First version (v0.2) released + */ + +#include "system.h" + +#include "pidfile.h" + +#ifndef HAVE_MINGW +/* read_pid + * + * Reads the specified pidfile and returns the read pid. + * 0 is returned if either there's no pidfile, it's empty + * or no pid can be read. + */ +pid_t read_pid(const char *pidfile) { + FILE *f; + long pid; + + if(!(f = fopen(pidfile, "r"))) { + return 0; + } + + if(fscanf(f, "%20ld", &pid) != 1) { + pid = 0; + } + + fclose(f); + return (pid_t)pid; +} + +/* check_pid + * + * Reads the pid using read_pid and looks up the pid in the process + * table (using /proc) to determine if the process already exists. If + * so the pid is returned, otherwise 0. + */ +pid_t check_pid(const char *pidfile) { + pid_t pid = read_pid(pidfile); + + /* Amazing ! _I_ am already holding the pid file... */ + if((!pid) || (pid == getpid())) { + return 0; + } + + /* + * The 'standard' method of doing this is to try and do a 'fake' kill + * of the process. If an ESRCH error is returned the process cannot + * be found -- GW + */ + /* But... errno is usually changed only on error.. */ + errno = 0; + + if(kill(pid, 0) && errno == ESRCH) { + return 0; + } + + return pid; +} + +/* write_pid + * + * Writes the pid to the specified file. If that fails 0 is + * returned, otherwise the pid. + */ +pid_t write_pid(const char *pidfile) { + FILE *f; + int fd; + pid_t pid; + + if((fd = open(pidfile, O_RDWR | O_CREAT, 0644)) == -1) { + return 0; + } + + if((f = fdopen(fd, "r+")) == NULL) { + close(fd); + return 0; + } + +#ifdef HAVE_FLOCK + + if(flock(fd, LOCK_EX | LOCK_NB) == -1) { + fclose(f); + return 0; + } + +#endif + + pid = getpid(); + + if(!fprintf(f, "%ld\n", (long)pid)) { + fclose(f); + return 0; + } + + fflush(f); + +#ifdef HAVE_FLOCK + + if(flock(fd, LOCK_UN) == -1) { + fclose(f); + return 0; + } + +#endif + fclose(f); + + return pid; +} + +/* remove_pid + * + * Remove the the specified file. The result from unlink(2) + * is returned + */ +int remove_pid(const char *pidfile) { + return unlink(pidfile); +} +#endif diff --git a/src/pidfile.h b/src/pidfile.h new file mode 100644 index 0000000..7d71cc2 --- /dev/null +++ b/src/pidfile.h @@ -0,0 +1,57 @@ +#ifndef TINC_PIDFILE_H +#define TINC_PIDFILE_H + +/* + pidfile.h - interact with pidfiles + Copyright (c) 1995 Martin Schulze + + This file is part of the sysklogd package, a kernel and system log daemon. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef HAVE_MINGW +/* read_pid + * + * Reads the specified pidfile and returns the read pid. + * 0 is returned if either there's no pidfile, it's empty + * or no pid can be read. + */ +extern pid_t read_pid(const char *pidfile); + +/* check_pid + * + * Reads the pid using read_pid and looks up the pid in the process + * table (using /proc) to determine if the process already exists. If + * so 1 is returned, otherwise 0. + */ +extern pid_t check_pid(const char *pidfile); + +/* write_pid + * + * Writes the pid to the specified file. If that fails 0 is + * returned, otherwise the pid. + */ +extern pid_t write_pid(const char *pidfile); + +/* remove_pid + * + * Remove the the specified file. The result from unlink(2) + * is returned + */ +extern int remove_pid(const char *pidfile); +#endif + +#endif diff --git a/src/prf.h b/src/prf.h deleted file mode 100644 index 9e64989..0000000 --- a/src/prf.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef TINC_PRF_H -#define TINC_PRF_H - -/* - prf.h -- header file for prf.c - Copyright (C) 2011-2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -extern bool prf(const char *secret, size_t secretlen, char *seed, size_t seedlen, char *out, size_t outlen) __attribute__((__warn_unused_result__)); - -#endif diff --git a/src/process.c b/src/process.c index c6cb536..13d1007 100644 --- a/src/process.c +++ b/src/process.c @@ -1,7 +1,7 @@ /* process.c -- process management functions Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2013 Guus Sliepen + 2000-2015 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,55 +22,67 @@ #include "conf.h" #include "connection.h" -#include "control.h" #include "device.h" #include "edge.h" -#include "event.h" #include "logger.h" -#include "names.h" #include "net.h" #include "node.h" +#include "pidfile.h" #include "process.h" #include "subnet.h" #include "utils.h" #include "xalloc.h" -#include "version.h" /* If zero, don't detach from the terminal. */ bool do_detach = true; +bool sighup = false; bool sigalrm = false; +extern char *identname; +extern char *pidfilename; extern char **g_argv; extern bool use_logfile; -extern bool use_syslog; + +#ifndef HAVE_MINGW +static sigset_t emptysigset; +#endif /* Some functions the less gifted operating systems might lack... */ #ifdef HAVE_MINGW +extern char *identname; +extern char *program_name; +extern char **g_argv; + static SC_HANDLE manager = NULL; static SC_HANDLE service = NULL; static SERVICE_STATUS status = {0}; static SERVICE_STATUS_HANDLE statushandle = 0; -static bool install_service(void) { +bool install_service(void) { char command[4096] = "\""; + char **argp; + bool space; SERVICE_DESCRIPTION description = {"Virtual Private Network daemon"}; manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); if(!manager) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not open service manager: %s", winerror(GetLastError())); + logger(LOG_ERR, "Could not open service manager: %s", winerror(GetLastError())); return false; } - HMODULE module = GetModuleHandle(NULL); - GetModuleFileName(module, command + 1, sizeof(command) - 1); - command[sizeof(command) - 1] = 0; + if(!strchr(program_name, '\\')) { + GetCurrentDirectory(sizeof(command) - 1, command + 1); + strncat(command, "\\", sizeof(command) - strlen(command)); + } + + strncat(command, program_name, sizeof(command) - strlen(command)); strncat(command, "\"", sizeof(command) - strlen(command)); - for(char **argp = g_argv + 1; *argp; argp++) { - char *space = strchr(*argp, ' '); + for(argp = g_argv + 1; *argp; argp++) { + space = strchr(*argp, ' '); strncat(command, " ", sizeof(command) - strlen(command)); if(space) { @@ -90,7 +102,7 @@ static bool install_service(void) { if(!service) { DWORD lasterror = GetLastError(); - logger(DEBUG_ALWAYS, LOG_ERR, "Could not create %s service: %s", identname, winerror(lasterror)); + logger(LOG_ERR, "Could not create %s service: %s", identname, winerror(lasterror)); if(lasterror != ERROR_SERVICE_EXISTS) { return false; @@ -99,21 +111,50 @@ static bool install_service(void) { if(service) { ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &description); - logger(DEBUG_ALWAYS, LOG_INFO, "%s service installed", identname); + logger(LOG_INFO, "%s service installed", identname); } else { service = OpenService(manager, identname, SERVICE_ALL_ACCESS); } if(!StartService(service, 0, NULL)) { - logger(DEBUG_ALWAYS, LOG_WARNING, "Could not start %s service: %s", identname, winerror(GetLastError())); + logger(LOG_WARNING, "Could not start %s service: %s", identname, winerror(GetLastError())); } else { - logger(DEBUG_ALWAYS, LOG_INFO, "%s service started", identname); + logger(LOG_INFO, "%s service started", identname); } return true; } -io_t stop_io; +bool remove_service(void) { + manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); + + if(!manager) { + logger(LOG_ERR, "Could not open service manager: %s", winerror(GetLastError())); + return false; + } + + service = OpenService(manager, identname, SERVICE_ALL_ACCESS); + + if(!service) { + logger(LOG_ERR, "Could not open %s service: %s", identname, winerror(GetLastError())); + return false; + } + + if(!ControlService(service, SERVICE_CONTROL_STOP, &status)) { + logger(LOG_ERR, "Could not stop %s service: %s", identname, winerror(GetLastError())); + } else { + logger(LOG_INFO, "%s service stopped", identname); + } + + if(!DeleteService(service)) { + logger(LOG_ERR, "Could not remove %s service: %s", identname, winerror(GetLastError())); + return false; + } + + logger(LOG_INFO, "%s service removed", identname); + + return true; +} DWORD WINAPI controlhandler(DWORD request, DWORD type, LPVOID boe, LPVOID bah) { switch(request) { @@ -122,27 +163,31 @@ DWORD WINAPI controlhandler(DWORD request, DWORD type, LPVOID boe, LPVOID bah) { return NO_ERROR; case SERVICE_CONTROL_STOP: - logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s request", "SERVICE_CONTROL_STOP"); + logger(LOG_NOTICE, "Got %s request", "SERVICE_CONTROL_STOP"); break; case SERVICE_CONTROL_SHUTDOWN: - logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s request", "SERVICE_CONTROL_SHUTDOWN"); + logger(LOG_NOTICE, "Got %s request", "SERVICE_CONTROL_SHUTDOWN"); break; default: - logger(DEBUG_ALWAYS, LOG_WARNING, "Got unexpected request %d", (int)request); + logger(LOG_WARNING, "Got unexpected request %d", (int)request); return ERROR_CALL_NOT_IMPLEMENTED; } - status.dwWaitHint = 1000; - status.dwCurrentState = SERVICE_STOP_PENDING; - SetServiceStatus(statushandle, &status); - - if(WSASetEvent(stop_io.event) == FALSE) { - abort(); + if(running) { + running = false; + status.dwWaitHint = 30000; + status.dwCurrentState = SERVICE_STOP_PENDING; + SetServiceStatus(statushandle, &status); + return NO_ERROR; + } else { + status.dwWaitHint = 0; + status.dwCurrentState = SERVICE_STOPPED; + SetServiceStatus(statushandle, &status); + exit(1); } - return NO_ERROR; } VOID WINAPI run_service(DWORD argc, LPTSTR *argv) { @@ -157,7 +202,7 @@ VOID WINAPI run_service(DWORD argc, LPTSTR *argv) { statushandle = RegisterServiceCtrlHandlerEx(identname, controlhandler, NULL); if(!statushandle) { - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "RegisterServiceCtrlHandlerEx", winerror(GetLastError())); + logger(LOG_ERR, "System call `%s' failed: %s", "RegisterServiceCtrlHandlerEx", winerror(GetLastError())); } else { status.dwWaitHint = 30000; status.dwCurrentState = SERVICE_START_PENDING; @@ -187,7 +232,7 @@ bool init_service(void) { if(GetLastError() == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) { return false; } else { - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "StartServiceCtrlDispatcher", winerror(GetLastError())); + logger(LOG_ERR, "System call `%s' failed: %s", "StartServiceCtrlDispatcher", winerror(GetLastError())); } } @@ -195,17 +240,92 @@ bool init_service(void) { } #endif +#ifndef HAVE_MINGW +/* + check for an existing tinc for this net, and write pid to pidfile +*/ +static bool write_pidfile(void) { + pid_t pid; + + pid = check_pid(pidfilename); + + if(pid) { + if(netname) + fprintf(stderr, "A tincd is already running for net `%s' with pid %ld.\n", + netname, (long)pid); + else { + fprintf(stderr, "A tincd is already running with pid %ld.\n", (long)pid); + } + + return false; + } + + /* if it's locked, write-protected, or whatever */ + if(!write_pid(pidfilename)) { + fprintf(stderr, "Couldn't write pid file %s: %s\n", pidfilename, strerror(errno)); + return false; + } + + return true; +} +#endif + /* - Detach from current terminal + kill older tincd for this net +*/ +bool kill_other(int signal) { +#ifndef HAVE_MINGW + pid_t pid; + + pid = read_pid(pidfilename); + + if(!pid) { + if(netname) + fprintf(stderr, "No other tincd is running for net `%s'.\n", + netname); + else { + fprintf(stderr, "No other tincd is running.\n"); + } + + return false; + } + + errno = 0; /* No error, sometimes errno is only changed on error */ + + /* ESRCH is returned when no process with that pid is found */ + if(kill(pid, signal) && errno == ESRCH) { + if(netname) + fprintf(stderr, "The tincd for net `%s' is no longer running. ", + netname); + else { + fprintf(stderr, "The tincd is no longer running. "); + } + + fprintf(stderr, "Removing stale lock file.\n"); + remove_pid(pidfilename); + } + + return true; +#else + return remove_service(); +#endif +} + +/* + Detach from current terminal, write pidfile, kill parent */ bool detach(void) { - logmode_t logmode; + setup_signals(); + + /* First check if we can open a fresh new pidfile */ #ifndef HAVE_MINGW - signal(SIGPIPE, SIG_IGN); - signal(SIGUSR1, SIG_IGN); - signal(SIGUSR2, SIG_IGN); - signal(SIGWINCH, SIG_IGN); + + if(!write_pidfile()) { + return false; + } + + /* If we succeeded in doing that, detach */ closelogger(); #endif @@ -213,32 +333,346 @@ bool detach(void) { if(do_detach) { #ifndef HAVE_MINGW - if(daemon(1, 0)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Couldn't detach from terminal: %s", strerror(errno)); + if(daemon(0, 0)) { + fprintf(stderr, "Couldn't detach from terminal: %s", + strerror(errno)); + return false; + } + + /* Now UPDATE the pid in the pidfile, because we changed it... */ + + if(!write_pid(pidfilename)) { + fprintf(stderr, "Could not write pid file %s: %s\n", pidfilename, strerror(errno)); return false; } #else if(!statushandle) { - exit(!install_service()); + exit(install_service()); } #endif } - if(use_logfile) { - logmode = LOGMODE_FILE; - } else if(use_syslog || do_detach) { - logmode = LOGMODE_SYSLOG; - } else { - logmode = LOGMODE_STDERR; - } + openlogger(identname, use_logfile ? LOGMODE_FILE : (do_detach ? LOGMODE_SYSLOG : LOGMODE_STDERR)); - openlogger(identname, logmode); - - logger(DEBUG_ALWAYS, LOG_NOTICE, "tincd %s (%s %s) starting, debug level %d", - BUILD_VERSION, BUILD_DATE, BUILD_TIME, debug_level); + logger(LOG_NOTICE, "tincd %s starting, debug level %d", + VERSION, debug_level); return true; } + +#ifdef HAVE_PUTENV +void unputenv(char *p) { + char *e = strchr(p, '='); + + if(!e) { + return; + } + + int len = e - p; +#ifndef HAVE_UNSETENV +#ifdef HAVE_MINGW + // Windows requires putenv("FOO=") to unset %FOO% + len++; +#endif +#endif + char var[len + 1]; + memcpy(var, p, len); + var[len] = 0; +#ifdef HAVE_UNSETENV + unsetenv(var); +#else + // We must keep what we putenv() around in memory. + // To do this without memory leaks, keep things in a list and reuse if possible. + static list_t list = {}; + + for(list_node_t *node = list.head; node; node = node->next) { + char *data = node->data; + + if(!strcmp(data, var)) { + putenv(data); + return; + } + } + + char *data = xstrdup(var); + list_insert_tail(&list, data); + putenv(data); +#endif +} +#else +void putenv(const char *p) {} +void unputenv(const char *p) {} +#endif + +bool execute_script(const char *name, char **envp) { +#ifdef HAVE_SYSTEM + char *scriptname; + char *interpreter = NULL; + config_t *cfg_interpreter; + int status, len, i; + + cfg_interpreter = lookup_config(config_tree, "ScriptsInterpreter"); +#ifndef HAVE_MINGW + len = xasprintf(&scriptname, "\"%s/%s\"", confbase, name); +#else + + if(cfg_interpreter) { + len = xasprintf(&scriptname, "\"%s/%s\"", confbase, name); + } else { + len = xasprintf(&scriptname, "\"%s/%s.bat\"", confbase, name); + } + +#endif + + if(len < 0) { + return false; + } + + scriptname[len - 1] = '\0'; + + /* First check if there is a script */ + if(access(scriptname + 1, F_OK)) { + free(scriptname); + return true; + } + + // Custom scripts interpreter + if(get_config_string(cfg_interpreter, &interpreter)) { + // Force custom scripts interpreter allowing execution of scripts on android without execution flag (such as on /sdcard) + free(scriptname); + len = xasprintf(&scriptname, "%s \"%s/%s\"", interpreter, confbase, name); + free(interpreter); + + if(len < 0) { + return false; + } + } + + ifdebug(STATUS) logger(LOG_INFO, "Executing script %s", name); + + /* Set environment */ + + for(i = 0; envp[i]; i++) { + putenv(envp[i]); + } + + scriptname[len - 1] = '\"'; + status = system(scriptname); + + free(scriptname); + + /* Unset environment */ + + for(i = 0; envp[i]; i++) { + unputenv(envp[i]); + } + + if(status != -1) { +#ifdef WEXITSTATUS + + if(WIFEXITED(status)) { /* Child exited by itself */ + if(WEXITSTATUS(status)) { + logger(LOG_ERR, "Script %s exited with non-zero status %d", + name, WEXITSTATUS(status)); + return false; + } + } else if(WIFSIGNALED(status)) { /* Child was killed by a signal */ + logger(LOG_ERR, "Script %s was killed by signal %d (%s)", + name, WTERMSIG(status), strsignal(WTERMSIG(status))); + return false; + } else { /* Something strange happened */ + logger(LOG_ERR, "Script %s terminated abnormally", name); + return false; + } + +#endif + } else { + logger(LOG_ERR, "System call `%s' failed: %s", "system", strerror(errno)); + return false; + } + +#endif + return true; +} + + +/* + Signal handlers. +*/ + +#ifndef HAVE_MINGW +static RETSIGTYPE sigterm_handler(int a) { + (void)a; + logger(LOG_NOTICE, "Got %s signal", "TERM"); + + if(running) { + running = false; + } else { + exit(1); + } +} + +static RETSIGTYPE sigquit_handler(int a) { + (void)a; + logger(LOG_NOTICE, "Got %s signal", "QUIT"); + + if(running) { + running = false; + } else { + exit(1); + } +} + +static RETSIGTYPE fatal_signal_square(int a) { + logger(LOG_ERR, "Got another fatal signal %d (%s): not restarting.", a, + strsignal(a)); + exit(1); +} + +static RETSIGTYPE fatal_signal_handler(int a) { + struct sigaction act; + logger(LOG_ERR, "Got fatal signal %d (%s)", a, strsignal(a)); + + if(do_detach) { + logger(LOG_NOTICE, "Trying to re-execute in 5 seconds..."); + + act.sa_handler = fatal_signal_square; + act.sa_mask = emptysigset; + act.sa_flags = 0; + sigaction(SIGSEGV, &act, NULL); + + close_network_connections(); + sleep(5); + remove_pid(pidfilename); + execvp(g_argv[0], g_argv); + } else { + logger(LOG_NOTICE, "Not restarting."); + exit(1); + } +} + +static RETSIGTYPE sighup_handler(int a) { + (void)a; + logger(LOG_NOTICE, "Got %s signal", "HUP"); + sighup = true; +} + +static RETSIGTYPE sigint_handler(int a) { + (void)a; + static int saved_debug_level = -1; + + logger(LOG_NOTICE, "Got %s signal", "INT"); + + if(saved_debug_level != -1) { + logger(LOG_NOTICE, "Reverting to old debug level (%d)", + saved_debug_level); + debug_level = saved_debug_level; + saved_debug_level = -1; + } else { + logger(LOG_NOTICE, + "Temporarily setting debug level to 5. Kill me with SIGINT again to go back to level %d.", + debug_level); + saved_debug_level = debug_level; + debug_level = 5; + } +} + +static RETSIGTYPE sigalrm_handler(int a) { + (void)a; + logger(LOG_NOTICE, "Got %s signal", "ALRM"); + sigalrm = true; +} + +static RETSIGTYPE sigusr1_handler(int a) { + (void)a; + dump_connections(); +} + +static RETSIGTYPE sigusr2_handler(int a) { + (void)a; + devops.dump_stats(); + dump_nodes(); + dump_edges(); + dump_subnets(); +} + +static RETSIGTYPE sigwinch_handler(int a) { + (void)a; + do_purge = true; +} + +static RETSIGTYPE unexpected_signal_handler(int a) { + (void)a; + logger(LOG_WARNING, "Got unexpected signal %d (%s)", a, strsignal(a)); +} + +static RETSIGTYPE ignore_signal_handler(int a) { + (void)a; + ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Ignored signal %d (%s)", a, strsignal(a)); +} + +static struct { + int signal; + void (*handler)(int); +} sighandlers[] = { + {SIGHUP, sighup_handler}, + {SIGTERM, sigterm_handler}, + {SIGQUIT, sigquit_handler}, + {SIGSEGV, fatal_signal_handler}, + {SIGBUS, fatal_signal_handler}, + {SIGILL, fatal_signal_handler}, + {SIGPIPE, ignore_signal_handler}, + {SIGINT, sigint_handler}, + {SIGUSR1, sigusr1_handler}, + {SIGUSR2, sigusr2_handler}, + {SIGCHLD, ignore_signal_handler}, + {SIGALRM, sigalrm_handler}, + {SIGWINCH, sigwinch_handler}, + {SIGABRT, SIG_DFL}, + {0, NULL} +}; +#endif + +void setup_signals(void) { +#ifndef HAVE_MINGW + int i; + struct sigaction act; + + sigemptyset(&emptysigset); + act.sa_handler = NULL; + act.sa_mask = emptysigset; + act.sa_flags = 0; + + /* Set a default signal handler for every signal, errors will be + ignored. */ + for(i = 1; i < NSIG; i++) { + if(!do_detach) { + act.sa_handler = SIG_DFL; + } else { + act.sa_handler = unexpected_signal_handler; + } + + sigaction(i, &act, NULL); + } + + /* If we didn't detach, allow coredumps */ + if(!do_detach) { + sighandlers[3].handler = SIG_DFL; + } + + /* Then, for each known signal that we want to catch, assign a + handler to the signal, with error checking this time. */ + for(i = 0; sighandlers[i].signal; i++) { + act.sa_handler = sighandlers[i].handler; + + if(sigaction(sighandlers[i].signal, &act, NULL) < 0) + fprintf(stderr, "Installing signal handler for signal %d (%s) failed: %s\n", + sighandlers[i].signal, strsignal(sighandlers[i].signal), + strerror(errno)); + } + +#endif +} diff --git a/src/process.h b/src/process.h index 93ef5e9..e775ac3 100644 --- a/src/process.h +++ b/src/process.h @@ -4,7 +4,7 @@ /* process.h -- header file for process.c Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2013 Guus Sliepen + 2000-2006 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,14 +22,15 @@ */ extern bool do_detach; +extern bool sighup; extern bool sigalrm; extern void setup_signals(void); +extern bool execute_script(const char *name, char **envp); extern bool detach(void); -extern bool kill_other(int); +extern bool kill_other(int signal); #ifdef HAVE_MINGW -extern io_t stop_io; extern bool init_service(void); #endif diff --git a/src/protocol.c b/src/protocol.c index d8b8867..4f74d3b 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -1,7 +1,7 @@ /* protocol.c -- handle the meta-protocol, basic functions Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2013 Guus Sliepen + 2000-2016 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,20 +30,16 @@ bool tunnelserver = false; bool strictsubnets = false; -bool experimental = true; /* Jumptable for the request handlers */ -static bool (*request_handlers[])(connection_t *, const char *) = { +static bool (*request_handlers[])(connection_t *) = { id_h, metakey_h, challenge_h, chal_reply_h, ack_h, - NULL, NULL, termreq_h, + NULL, NULL, NULL, ping_h, pong_h, add_subnet_h, del_subnet_h, add_edge_h, del_edge_h, - key_changed_h, req_key_h, ans_key_h, tcppacket_h, control_h, - NULL, NULL, /* Not "real" requests (yet) */ - sptps_tcppacket_h, - udp_info_h, mtu_info_h, + key_changed_h, req_key_h, ans_key_h, tcppacket_h, }; /* Request names */ @@ -53,107 +49,123 @@ static char (*request_name[]) = { "STATUS", "ERROR", "TERMREQ", "PING", "PONG", "ADD_SUBNET", "DEL_SUBNET", - "ADD_EDGE", "DEL_EDGE", "KEY_CHANGED", "REQ_KEY", "ANS_KEY", "PACKET", "CONTROL", - "REQ_PUBKEY", "ANS_PUBKEY", "SPTPS_PACKET", "UDP_INFO", "MTU_INFO", + "ADD_EDGE", "DEL_EDGE", "KEY_CHANGED", "REQ_KEY", "ANS_KEY", "PACKET", }; -static splay_tree_t *past_request_tree; +static avl_tree_t *past_request_tree; + +bool check_id(const char *id) { + for(; *id; id++) + if(!isalnum(*id) && *id != '_') { + return false; + } + + return true; +} /* Generic request routines - takes care of logging and error detection as well */ bool send_request(connection_t *c, const char *format, ...) { va_list args; - char request[MAXBUFSIZE]; - int len; + char buffer[MAXBUFSIZE]; + int len, request = 0; /* Use vsnprintf instead of vxasprintf: faster, no memory fragmentation, cleanup is automatic, and there is a limit on the input buffer anyway */ va_start(args, format); - len = vsnprintf(request, sizeof(request), format, args); - request[sizeof(request) - 1] = 0; + len = vsnprintf(buffer, sizeof(buffer), format, args); + buffer[sizeof(buffer) - 1] = 0; va_end(args); - if(len < 0 || (size_t)len > sizeof(request) - 1) { - logger(DEBUG_ALWAYS, LOG_ERR, "Output buffer overflow while sending request to %s (%s)", + if(len < 0 || (size_t)len > sizeof(buffer) - 1) { + logger(LOG_ERR, "Output buffer overflow while sending request to %s (%s)", c->name, c->hostname); return false; } - int id = atoi(request); - logger(DEBUG_META, LOG_DEBUG, "Sending %s to %s (%s): %s", request_name[id], c->name, c->hostname, request); + ifdebug(PROTOCOL) { + sscanf(buffer, "%d", &request); + ifdebug(META) + logger(LOG_DEBUG, "Sending %s to %s (%s): %s", + request_name[request], c->name, c->hostname, buffer); + else + logger(LOG_DEBUG, "Sending %s to %s (%s)", request_name[request], + c->name, c->hostname); + } - request[len++] = '\n'; + buffer[len++] = '\n'; if(c == everyone) { - broadcast_meta(NULL, request, len); + broadcast_meta(NULL, buffer, len); return true; } else { - if(id) { - return send_meta(c, request, len); - } else { - send_meta_raw(c, request, len); - return true; - } + return send_meta(c, buffer, len); } } -void forward_request(connection_t *from, const char *request) { - logger(DEBUG_META, LOG_DEBUG, "Forwarding %s from %s (%s): %s", request_name[atoi(request)], from->name, from->hostname, request); +void forward_request(connection_t *from) { + int request; - // Create a temporary newline-terminated copy of the request - int len = strlen(request); - char tmp[len + 1]; - memcpy(tmp, request, len); - tmp[len] = '\n'; - broadcast_meta(from, tmp, sizeof(tmp)); + ifdebug(PROTOCOL) { + sscanf(from->buffer, "%d", &request); + ifdebug(META) + logger(LOG_DEBUG, "Forwarding %s from %s (%s): %s", + request_name[request], from->name, from->hostname, + from->buffer); + else + logger(LOG_DEBUG, "Forwarding %s from %s (%s)", + request_name[request], from->name, from->hostname); + } + + from->buffer[from->reqlen - 1] = '\n'; + + broadcast_meta(from, from->buffer, from->reqlen); } -bool receive_request(connection_t *c, const char *request) { - if(c->outgoing && proxytype == PROXY_HTTP && c->allow_request == ID) { - if(!request[0] || request[0] == '\r') { - return true; - } +bool receive_request(connection_t *c) { + int request; - if(!strncasecmp(request, "HTTP/1.1 ", 9)) { - if(!strncmp(request + 9, "200", 3)) { - logger(DEBUG_CONNECTIONS, LOG_DEBUG, "Proxy request granted"); - return true; - } else { - logger(DEBUG_ALWAYS, LOG_DEBUG, "Proxy request rejected: %s", request + 9); - return false; + if(sscanf(c->buffer, "%d", &request) == 1) { + if((request < 0) || (request >= LAST) || !request_handlers[request]) { + ifdebug(META) + logger(LOG_DEBUG, "Unknown request from %s (%s): %s", + c->name, c->hostname, c->buffer); + else + logger(LOG_ERR, "Unknown request from %s (%s)", + c->name, c->hostname); + + return false; + } else { + ifdebug(PROTOCOL) { + ifdebug(META) + logger(LOG_DEBUG, "Got %s from %s (%s): %s", + request_name[request], c->name, c->hostname, + c->buffer); + else + logger(LOG_DEBUG, "Got %s from %s (%s)", + request_name[request], c->name, c->hostname); } } - } - int reqno = atoi(request); - - if(reqno || *request == '0') { - if((reqno < 0) || (reqno >= LAST) || !request_handlers[reqno]) { - logger(DEBUG_META, LOG_DEBUG, "Unknown request from %s (%s): %s", c->name, c->hostname, request); - return false; - } else { - logger(DEBUG_META, LOG_DEBUG, "Got %s from %s (%s): %s", request_name[reqno], c->name, c->hostname, request); - } - - if((c->allow_request != ALL) && (c->allow_request != reqno)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unauthorized request from %s (%s)", c->name, c->hostname); + if((c->allow_request != ALL) && (c->allow_request != request)) { + logger(LOG_ERR, "Unauthorized request from %s (%s)", c->name, + c->hostname); return false; } - if(!request_handlers[reqno](c, request)) { + if(!request_handlers[request](c)) { /* Something went wrong. Probably scriptkiddies. Terminate. */ - if(reqno != TERMREQ) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while processing %s from %s (%s)", request_name[reqno], c->name, c->hostname); - } - + logger(LOG_ERR, "Error while processing %s from %s (%s)", + request_name[request], c->name, c->hostname); return false; } } else { - logger(DEBUG_ALWAYS, LOG_ERR, "Bogus data received from %s (%s)", c->name, c->hostname); + logger(LOG_ERR, "Bogus data received from %s (%s)", + c->name, c->hostname); return false; } @@ -165,60 +177,55 @@ static int past_request_compare(const past_request_t *a, const past_request_t *b } static void free_past_request(past_request_t *r) { - free((char *)r->request); + if(r->request) { + free(r->request); + } + free(r); } -static timeout_t past_request_timeout; +void init_requests(void) { + past_request_tree = avl_alloc_tree((avl_compare_t) past_request_compare, (avl_action_t) free_past_request); +} -static void age_past_requests(void *data) { - (void)data; +void exit_requests(void) { + avl_delete_tree(past_request_tree); +} + +bool seen_request(char *request) { + past_request_t *new, p = {0}; + + p.request = request; + + if(avl_search(past_request_tree, &p)) { + ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Already seen request"); + return true; + } else { + new = xmalloc(sizeof(*new)); + new->request = xstrdup(request); + new->firstseen = now; + avl_insert(past_request_tree, new); + return false; + } +} + +void age_past_requests(void) { + avl_node_t *node, *next; + past_request_t *p; int left = 0, deleted = 0; - for splay_each(past_request_t, p, past_request_tree) { - if(p->firstseen + pinginterval <= now.tv_sec) { - splay_delete_node(past_request_tree, node), deleted++; + for(node = past_request_tree->head; node; node = next) { + next = node->next; + p = node->data; + + if(p->firstseen + pinginterval <= now) { + avl_delete_node(past_request_tree, node), deleted++; } else { left++; } } - if(left || deleted) { - logger(DEBUG_SCARY_THINGS, LOG_DEBUG, "Aging past requests: deleted %d, left %d", deleted, left); - } - - if(left) - timeout_set(&past_request_timeout, &(struct timeval) { - 10, rand() % 100000 - }); -} - -bool seen_request(const char *request) { - past_request_t *new, p = {0}; - - p.request = request; - - if(splay_search(past_request_tree, &p)) { - logger(DEBUG_SCARY_THINGS, LOG_DEBUG, "Already seen request"); - return true; - } else { - new = xmalloc(sizeof(*new)); - new->request = xstrdup(request); - new->firstseen = now.tv_sec; - splay_insert(past_request_tree, new); - timeout_add(&past_request_timeout, age_past_requests, NULL, &(struct timeval) { - 10, rand() % 100000 - }); - return false; - } -} - -void init_requests(void) { - past_request_tree = splay_alloc_tree((splay_compare_t) past_request_compare, (splay_action_t) free_past_request); -} - -void exit_requests(void) { - splay_delete_tree(past_request_tree); - - timeout_del(&past_request_timeout); + if(left || deleted) + ifdebug(SCARY_THINGS) logger(LOG_DEBUG, "Aging past requests: deleted %d, left %d", + deleted, left); } diff --git a/src/protocol.h b/src/protocol.h index 42981cc..a055f28 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -4,7 +4,7 @@ /* protocol.h -- header for protocol.c Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2017 Guus Sliepen + 2000-2015 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,12 +21,11 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "ecdsa.h" +/* Protocol version. Different versions are incompatible, + incompatible version have different protocols. + */ -/* Protocol version. Different major versions are incompatible. */ - -#define PROT_MAJOR 17 -#define PROT_MINOR 7 /* Should not exceed 255! */ +#define PROT_CURRENT 17 /* Silly Windows */ @@ -37,6 +36,7 @@ /* Request numbers */ typedef enum request_t { + PROXY = -2, ALL = -1, /* Guardian for allow_request */ ID = 0, METAKEY, CHALLENGE, CHAL_REPLY, ACK, STATUS, ERROR, TERMREQ, @@ -45,25 +45,16 @@ typedef enum request_t { ADD_EDGE, DEL_EDGE, KEY_CHANGED, REQ_KEY, ANS_KEY, PACKET, - /* Tinc 1.1 requests */ - CONTROL, - REQ_PUBKEY, ANS_PUBKEY, - SPTPS_PACKET, - UDP_INFO, MTU_INFO, LAST /* Guardian for the highest request number */ } request_t; typedef struct past_request_t { - const char *request; + char *request; time_t firstseen; } past_request_t; extern bool tunnelserver; extern bool strictsubnets; -extern bool experimental; - -extern int invitation_lifetime; -extern ecdsa_t *invitation_key; /* Maximum size of strings in a request. * scanf terminates %2048s with a NUL character, @@ -81,22 +72,22 @@ extern ecdsa_t *invitation_key; /* Basic functions */ extern bool send_request(struct connection_t *c, const char *format, ...) __attribute__((__format__(printf, 2, 3))); -extern void forward_request(struct connection_t *c, const char *request); -extern bool receive_request(struct connection_t *c, const char *request); +extern void forward_request(struct connection_t *c); +extern bool receive_request(struct connection_t *c); +extern bool check_id(const char *name); extern void init_requests(void); extern void exit_requests(void); -extern bool seen_request(const char *request); +extern bool seen_request(char *request); +extern void age_past_requests(void); /* Requests */ extern bool send_id(struct connection_t *c); extern bool send_metakey(struct connection_t *c); -extern bool send_metakey_ec(struct connection_t *c); extern bool send_challenge(struct connection_t *c); extern bool send_chal_reply(struct connection_t *c); extern bool send_ack(struct connection_t *c); -extern bool send_termreq(struct connection_t *c); extern bool send_ping(struct connection_t *c); extern bool send_pong(struct connection_t *c); extern bool send_add_subnet(struct connection_t *c, const struct subnet_t *subnet); @@ -104,36 +95,26 @@ extern bool send_del_subnet(struct connection_t *c, const struct subnet_t *subne extern bool send_add_edge(struct connection_t *c, const struct edge_t *e); extern bool send_del_edge(struct connection_t *c, const struct edge_t *e); extern void send_key_changed(void); -extern bool send_req_key(struct node_t *to); -extern bool send_ans_key(struct node_t *to); +extern bool send_req_key(struct node_t *n); +extern bool send_ans_key(struct node_t *n); extern bool send_tcppacket(struct connection_t *c, const struct vpn_packet_t *packet); -extern bool send_sptps_tcppacket(struct connection_t *c, const char *packet, int len); -extern bool send_udp_info(struct node_t *from, struct node_t *to); -extern bool send_mtu_info(struct node_t *from, struct node_t *to, int mtu); /* Request handlers */ -extern bool id_h(struct connection_t *c, const char *request); -extern bool metakey_h(struct connection_t *c, const char *request); -extern bool challenge_h(struct connection_t *c, const char *request); -extern bool chal_reply_h(struct connection_t *c, const char *request); -extern bool ack_h(struct connection_t *c, const char *request); -extern bool status_h(struct connection_t *c, const char *request); -extern bool error_h(struct connection_t *c, const char *request); -extern bool termreq_h(struct connection_t *c, const char *request); -extern bool ping_h(struct connection_t *c, const char *request); -extern bool pong_h(struct connection_t *c, const char *request); -extern bool add_subnet_h(struct connection_t *c, const char *request); -extern bool del_subnet_h(struct connection_t *c, const char *request); -extern bool add_edge_h(struct connection_t *c, const char *request); -extern bool del_edge_h(struct connection_t *c, const char *request); -extern bool key_changed_h(struct connection_t *c, const char *request); -extern bool req_key_h(struct connection_t *c, const char *request); -extern bool ans_key_h(struct connection_t *c, const char *request); -extern bool tcppacket_h(struct connection_t *c, const char *request); -extern bool sptps_tcppacket_h(struct connection_t *c, const char *request); -extern bool control_h(struct connection_t *c, const char *request); -extern bool udp_info_h(struct connection_t *c, const char *request); -extern bool mtu_info_h(struct connection_t *c, const char *request); +extern bool id_h(struct connection_t *c); +extern bool metakey_h(struct connection_t *c); +extern bool challenge_h(struct connection_t *c); +extern bool chal_reply_h(struct connection_t *c); +extern bool ack_h(struct connection_t *c); +extern bool ping_h(struct connection_t *c); +extern bool pong_h(struct connection_t *c); +extern bool add_subnet_h(struct connection_t *c); +extern bool del_subnet_h(struct connection_t *c); +extern bool add_edge_h(struct connection_t *c); +extern bool del_edge_h(struct connection_t *c); +extern bool key_changed_h(struct connection_t *c); +extern bool req_key_h(struct connection_t *c); +extern bool ans_key_h(struct connection_t *c); +extern bool tcppacket_h(struct connection_t *c); #endif diff --git a/src/protocol_auth.c b/src/protocol_auth.c index 3a84c22..15807c3 100644 --- a/src/protocol_auth.c +++ b/src/protocol_auth.c @@ -1,7 +1,7 @@ /* protocol_auth.c -- handle the meta-protocol, authentication Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2017 Guus Sliepen + 2000-2016 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,380 +20,48 @@ #include "system.h" +#include +#include +#include +#include + +#include "avl_tree.h" #include "conf.h" #include "connection.h" -#include "control.h" -#include "control_common.h" -#include "cipher.h" -#include "crypto.h" -#include "device.h" -#include "digest.h" -#include "ecdsa.h" #include "edge.h" #include "graph.h" #include "logger.h" #include "meta.h" -#include "names.h" #include "net.h" #include "netutl.h" #include "node.h" -#include "prf.h" #include "protocol.h" -#include "rsa.h" -#include "script.h" -#include "sptps.h" +#include "proxy.h" #include "utils.h" #include "xalloc.h" -#include "ed25519/sha512.h" - -int invitation_lifetime; -ecdsa_t *invitation_key = NULL; - -static bool send_proxyrequest(connection_t *c) { - switch(proxytype) { - case PROXY_HTTP: { - char *host; - char *port; - - sockaddr2str(&c->address, &host, &port); - send_request(c, "CONNECT %s:%s HTTP/1.1\r\n\r", host, port); - free(host); - free(port); - return true; - } - - case PROXY_SOCKS4: { - if(c->address.sa.sa_family != AF_INET) { - logger(DEBUG_ALWAYS, LOG_ERR, "Cannot connect to an IPv6 host through a SOCKS 4 proxy!"); - return false; - } - - char s4req[9 + (proxyuser ? strlen(proxyuser) : 0)]; - s4req[0] = 4; - s4req[1] = 1; - memcpy(s4req + 2, &c->address.in.sin_port, 2); - memcpy(s4req + 4, &c->address.in.sin_addr, 4); - - if(proxyuser) { - memcpy(s4req + 8, proxyuser, strlen(proxyuser)); - } - - s4req[sizeof(s4req) - 1] = 0; - c->tcplen = 8; - return send_meta(c, s4req, sizeof(s4req)); - } - - case PROXY_SOCKS5: { - int len = 3 + 6 + (c->address.sa.sa_family == AF_INET ? 4 : 16); - c->tcplen = 2; - - if(proxypass) { - len += 3 + strlen(proxyuser) + strlen(proxypass); - } - - char s5req[len]; - int i = 0; - s5req[i++] = 5; - s5req[i++] = 1; - - if(proxypass) { - s5req[i++] = 2; - s5req[i++] = 1; - s5req[i++] = strlen(proxyuser); - memcpy(s5req + i, proxyuser, strlen(proxyuser)); - i += strlen(proxyuser); - s5req[i++] = strlen(proxypass); - memcpy(s5req + i, proxypass, strlen(proxypass)); - i += strlen(proxypass); - c->tcplen += 2; - } else { - s5req[i++] = 0; - } - - s5req[i++] = 5; - s5req[i++] = 1; - s5req[i++] = 0; - - if(c->address.sa.sa_family == AF_INET) { - s5req[i++] = 1; - memcpy(s5req + i, &c->address.in.sin_addr, 4); - i += 4; - memcpy(s5req + i, &c->address.in.sin_port, 2); - i += 2; - c->tcplen += 10; - } else if(c->address.sa.sa_family == AF_INET6) { - s5req[i++] = 3; - memcpy(s5req + i, &c->address.in6.sin6_addr, 16); - i += 16; - memcpy(s5req + i, &c->address.in6.sin6_port, 2); - i += 2; - c->tcplen += 22; - } else { - logger(DEBUG_ALWAYS, LOG_ERR, "Address family %x not supported for SOCKS 5 proxies!", c->address.sa.sa_family); - return false; - } - - if(i > len) { - abort(); - } - - return send_meta(c, s5req, sizeof(s5req)); - } - - case PROXY_SOCKS4A: - logger(DEBUG_ALWAYS, LOG_ERR, "Proxy type not implemented yet"); - return false; - - case PROXY_EXEC: - return true; - - default: - logger(DEBUG_ALWAYS, LOG_ERR, "Unknown proxy type"); - return false; - } -} - bool send_id(connection_t *c) { - gettimeofday(&c->start, NULL); - - int minor = 0; - - if(experimental) { - if(c->outgoing && !read_ecdsa_public_key(c)) { - minor = 1; - } else { - minor = myself->connection->protocol_minor; - } + if(proxytype && c->outgoing && !c->status.proxy_passed) { + return send_proxyrequest(c); } - if(proxytype && c->outgoing) - if(!send_proxyrequest(c)) { - return false; - } - - return send_request(c, "%d %s %d.%d", ID, myself->connection->name, myself->connection->protocol_major, minor); + return send_request(c, "%d %s %d", ID, myself->connection->name, + myself->connection->protocol_version); } -static bool finalize_invitation(connection_t *c, const char *data, uint16_t len) { - (void)len; - - if(strchr(data, '\n')) { - logger(DEBUG_ALWAYS, LOG_ERR, "Received invalid key from invited node %s (%s)!\n", c->name, c->hostname); - return false; - } - - // Create a new host config file - char filename[PATH_MAX]; - snprintf(filename, sizeof(filename), "%s" SLASH "hosts" SLASH "%s", confbase, c->name); - - if(!access(filename, F_OK)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Host config file for %s (%s) already exists!\n", c->name, c->hostname); - return false; - } - - FILE *f = fopen(filename, "w"); - - if(!f) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error trying to create %s: %s\n", filename, strerror(errno)); - return false; - } - - fprintf(f, "Ed25519PublicKey = %s\n", data); - fclose(f); - - logger(DEBUG_CONNECTIONS, LOG_INFO, "Key successfully received from %s (%s)", c->name, c->hostname); - - // Call invitation-accepted script - environment_t env; - char *address, *port; - - environment_init(&env); - environment_add(&env, "NODE=%s", c->name); - sockaddr2str(&c->address, &address, &port); - environment_add(&env, "REMOTEADDRESS=%s", address); - environment_add(&env, "NAME=%s", myself->name); - - execute_script("invitation-accepted", &env); - - environment_exit(&env); - - sptps_send_record(&c->sptps, 2, data, 0); - return true; -} - -static bool receive_invitation_sptps(void *handle, uint8_t type, const void *data, uint16_t len) { - connection_t *c = handle; - - if(type == 128) { - return true; - } - - if(type == 1 && c->status.invitation_used) { - return finalize_invitation(c, data, len); - } - - if(type != 0 || len != 18 || c->status.invitation_used) { - return false; - } - - // Recover the filename from the cookie and the key - char *fingerprint = ecdsa_get_base64_public_key(invitation_key); - char hashbuf[18 + strlen(fingerprint)]; - char cookie[64]; - memcpy(hashbuf, data, 18); - memcpy(hashbuf + 18, fingerprint, sizeof(hashbuf) - 18); - sha512(hashbuf, sizeof(hashbuf), cookie); - b64encode_urlsafe(cookie, cookie, 18); - free(fingerprint); - - char filename[PATH_MAX], usedname[PATH_MAX]; - snprintf(filename, sizeof(filename), "%s" SLASH "invitations" SLASH "%s", confbase, cookie); - snprintf(usedname, sizeof(usedname), "%s" SLASH "invitations" SLASH "%s.used", confbase, cookie); - - // Atomically rename the invitation file - if(rename(filename, usedname)) { - if(errno == ENOENT) { - logger(DEBUG_ALWAYS, LOG_ERR, "Peer %s tried to use non-existing invitation %s\n", c->hostname, cookie); - } else { - logger(DEBUG_ALWAYS, LOG_ERR, "Error trying to rename invitation %s\n", cookie); - } - - return false; - } - - // Check the timestamp of the invitation - struct stat st; - - if(stat(usedname, &st)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not stat %s", usedname); - return false; - } - - if(st.st_mtime + invitation_lifetime < now.tv_sec) { - logger(DEBUG_ALWAYS, LOG_ERR, "Peer %s tried to use expired invitation %s", c->hostname, cookie); - return false; - } - - // Open the renamed file - FILE *f = fopen(usedname, "r"); - - if(!f) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error trying to open invitation %s\n", cookie); - return false; - } - - // Read the new node's Name from the file - char buf[1024]; - fgets(buf, sizeof(buf), f); - - if(*buf) { - buf[strlen(buf) - 1] = 0; - } - - len = strcspn(buf, " \t="); - char *name = buf + len; - name += strspn(name, " \t"); - - if(*name == '=') { - name++; - name += strspn(name, " \t"); - } - - buf[len] = 0; - - if(!*buf || !*name || strcasecmp(buf, "Name") || !check_id(name) || !strcmp(name, myself->name)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Invalid invitation file %s\n", cookie); - fclose(f); - return false; - } - - free(c->name); - c->name = xstrdup(name); - - // Send the node the contents of the invitation file - rewind(f); - size_t result; - - while((result = fread(buf, 1, sizeof(buf), f))) { - sptps_send_record(&c->sptps, 0, buf, result); - } - - sptps_send_record(&c->sptps, 1, buf, 0); - fclose(f); - unlink(usedname); - - c->status.invitation_used = true; - - logger(DEBUG_CONNECTIONS, LOG_INFO, "Invitation %s successfully sent to %s (%s)", cookie, c->name, c->hostname); - return true; -} - -bool id_h(connection_t *c, const char *request) { +bool id_h(connection_t *c) { char name[MAX_STRING_SIZE]; - if(sscanf(request, "%*d " MAX_STRING " %2d.%3d", name, &c->protocol_major, &c->protocol_minor) < 2) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "ID", c->name, + if(sscanf(c->buffer, "%*d " MAX_STRING " %d", name, &c->protocol_version) != 2) { + logger(LOG_ERR, "Got bad %s from %s (%s)", "ID", c->name, c->hostname); return false; } - /* Check if this is a control connection */ - - if(name[0] == '^' && !strcmp(name + 1, controlcookie)) { - c->status.control = true; - c->allow_request = CONTROL; - c->last_ping_time = now.tv_sec + 3600; - - free(c->name); - c->name = xstrdup(""); - - if(!c->outgoing) { - send_id(c); - } - - return send_request(c, "%d %d %d", ACK, TINC_CTL_VERSION_CURRENT, getpid()); - } - - if(name[0] == '?') { - if(!invitation_key) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got invitation from %s but we don't have an invitation key", c->hostname); - return false; - } - - c->ecdsa = ecdsa_set_base64_public_key(name + 1); - - if(!c->ecdsa) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad invitation from %s", c->hostname); - return false; - } - - c->status.invitation = true; - char *mykey = ecdsa_get_base64_public_key(invitation_key); - - if(!mykey) { - return false; - } - - if(!c->outgoing) { - send_id(c); - } - - if(!send_request(c, "%d %s", ACK, mykey)) { - return false; - } - - free(mykey); - - c->protocol_minor = 2; - - return sptps_start(&c->sptps, c, false, false, invitation_key, c->ecdsa, "tinc invitation", 15, send_meta_sptps, receive_invitation_sptps); - } - /* Check if identity is a valid name */ if(!check_id(name) || !strcmp(name, myself->name)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "ID", c->name, + logger(LOG_ERR, "Got bad %s from %s (%s): %s", "ID", c->name, c->hostname, "invalid name"); return false; } @@ -402,20 +70,23 @@ bool id_h(connection_t *c, const char *request) { if(c->outgoing) { if(strcmp(c->name, name)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Peer %s is %s instead of %s", c->hostname, name, + logger(LOG_ERR, "Peer %s is %s instead of %s", c->hostname, name, c->name); return false; } } else { - free(c->name); + if(c->name) { + free(c->name); + } + c->name = xstrdup(name); } /* Check if version matches */ - if(c->protocol_major != myself->connection->protocol_major) { - logger(DEBUG_ALWAYS, LOG_ERR, "Peer %s (%s) uses incompatible version %d.%d", - c->name, c->hostname, c->protocol_major, c->protocol_minor); + if(c->protocol_version != myself->connection->protocol_version) { + logger(LOG_ERR, "Peer %s (%s) uses incompatible version %d", + c->name, c->hostname, c->protocol_version); return false; } @@ -433,34 +104,17 @@ bool id_h(connection_t *c, const char *request) { return send_ack(c); } - if(!experimental) { - c->protocol_minor = 0; - } - if(!c->config_tree) { init_configuration(&c->config_tree); - if(!read_host_config(c->config_tree, c->name, false)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Peer %s had unknown identity (%s)", c->hostname, c->name); + if(!read_connection_config(c)) { + logger(LOG_ERR, "Peer %s had unknown identity (%s)", c->hostname, + c->name); return false; } - - if(experimental) { - read_ecdsa_public_key(c); - } - - /* Ignore failures if no key known yet */ } - if(c->protocol_minor && !ecdsa_active(c->ecdsa)) { - c->protocol_minor = 1; - } - - /* Forbid version rollback for nodes whose Ed25519 key we know */ - - if(ecdsa_active(c->ecdsa) && c->protocol_minor < 1) { - logger(DEBUG_ALWAYS, LOG_ERR, "Peer %s (%s) tries to roll back protocol version to %d.%d", - c->name, c->hostname, c->protocol_major, c->protocol_minor); + if(!read_rsa_public_key(c)) { return false; } @@ -470,69 +124,51 @@ bool id_h(connection_t *c, const char *request) { send_id(c); } - if(c->protocol_minor >= 2) { - c->allow_request = ACK; - char label[25 + strlen(myself->name) + strlen(c->name)]; + return send_metakey(c); +} - if(c->outgoing) { - snprintf(label, sizeof(label), "tinc TCP key expansion %s %s", myself->name, c->name); - } else { - snprintf(label, sizeof(label), "tinc TCP key expansion %s %s", c->name, myself->name); - } +static uint64_t byte_budget(const EVP_CIPHER *cipher) { + /* Hopefully some failsafe way to calculate the maximum amount of bytes to + send/receive with a given cipher before we might run into birthday paradox + attacks. Because we might use different modes, the block size of the mode + might be 1 byte. In that case, use the IV length. Ensure the whole thing + is limited to what can be represented with a 64 bits integer. + */ - return sptps_start(&c->sptps, c, c->outgoing, false, myself->connection->ecdsa, c->ecdsa, label, sizeof(label), send_meta_sptps, receive_meta_sptps); - } else { - return send_metakey(c); - } + int ivlen = EVP_CIPHER_iv_length(cipher); + int blklen = EVP_CIPHER_block_size(cipher); + int len = blklen > 1 ? blklen : ivlen > 1 ? ivlen : 8; + int bits = len * 4 - 1; + return bits < 64 ? UINT64_C(1) << bits : UINT64_MAX; } bool send_metakey(connection_t *c) { -#ifdef DISABLE_LEGACY - return false; -#else + bool x; - if(!myself->connection->rsa) { - logger(DEBUG_CONNECTIONS, LOG_ERR, "Peer %s (%s) uses legacy protocol which we don't support", c->name, c->hostname); + int len = RSA_size(c->rsa_key); + + /* Allocate buffers for the meta key */ + + char buffer[2 * len + 1]; + + c->outkey = xrealloc(c->outkey, len); + + if(!c->outctx) { + c->outctx = EVP_CIPHER_CTX_new(); + + if(!c->outctx) { + abort(); + } + } + + /* Copy random data to the buffer */ + + if(1 != RAND_bytes((unsigned char *)c->outkey, len)) { + int err = ERR_get_error(); + logger(LOG_ERR, "Failed to generate meta key (%s)", ERR_error_string(err, NULL)); return false; } - if(!read_rsa_public_key(c)) { - return false; - } - - /* We need to use a stream mode for the meta protocol. Use AES for this, - but try to match the key size with the one from the cipher selected - by Cipher. - */ - - int keylen = cipher_keylength(myself->incipher); - - if(keylen <= 16) { - c->outcipher = cipher_open_by_name("aes-128-cfb"); - } else if(keylen <= 24) { - c->outcipher = cipher_open_by_name("aes-192-cfb"); - } else { - c->outcipher = cipher_open_by_name("aes-256-cfb"); - } - - if(!c) { - return false; - } - - c->outbudget = cipher_budget(c->outcipher); - - if(!(c->outdigest = digest_open_by_name("sha256", -1))) { - return false; - } - - const size_t len = rsa_size(c->rsa); - char key[len]; - char enckey[len]; - char hexkey[2 * len + 1]; - - /* Create a random key */ - - randomize(key, len); /* The message we send must be smaller than the modulus of the RSA key. By definition, for a key of k bits, the following formula holds: @@ -544,15 +180,13 @@ bool send_metakey(connection_t *c) { This can be done by setting the most significant bit to zero. */ - key[0] &= 0x7F; + c->outkey[0] &= 0x7F; - if(!cipher_set_key_from_rsa(c->outcipher, key, len, true)) { - return false; - } - - if(debug_level >= DEBUG_SCARY_THINGS) { - bin2hex(key, hexkey, len); - logger(DEBUG_SCARY_THINGS, LOG_DEBUG, "Generated random meta key (unencrypted): %s", hexkey); + ifdebug(SCARY_THINGS) { + bin2hex(c->outkey, buffer, len); + buffer[len * 2] = '\0'; + logger(LOG_DEBUG, "Generated random meta key (unencrypted): %s", + buffer); } /* Encrypt the random data @@ -562,219 +196,311 @@ bool send_metakey(connection_t *c) { with a length equal to that of the modulus of the RSA key. */ - if(!rsa_public_encrypt(c->rsa, key, len, enckey)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error during encryption of meta key for %s (%s)", c->name, c->hostname); + if(RSA_public_encrypt(len, (unsigned char *)c->outkey, (unsigned char *)buffer, c->rsa_key, RSA_NO_PADDING) != len) { + logger(LOG_ERR, "Error during encryption of meta key for %s (%s): %s", + c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL)); return false; } /* Convert the encrypted random data to a hexadecimal formatted string */ - bin2hex(enckey, hexkey, len); + bin2hex(buffer, buffer, len); + buffer[len * 2] = '\0'; /* Send the meta key */ - bool result = send_request(c, "%d %d %d %d %d %s", METAKEY, - cipher_get_nid(c->outcipher), - digest_get_nid(c->outdigest), c->outmaclength, - c->outcompression, hexkey); + x = send_request(c, "%d %d %d %d %d %s", METAKEY, + c->outcipher ? EVP_CIPHER_nid(c->outcipher) : 0, + c->outdigest ? EVP_MD_type(c->outdigest) : 0, c->outmaclength, + c->outcompression, buffer); - c->status.encryptout = true; - return result; -#endif + /* Further outgoing requests are encrypted with the key we just generated */ + + if(c->outcipher) { + if(!EVP_EncryptInit(c->outctx, c->outcipher, + (unsigned char *)c->outkey + len - EVP_CIPHER_key_length(c->outcipher), + (unsigned char *)c->outkey + len - EVP_CIPHER_key_length(c->outcipher) - + EVP_CIPHER_iv_length(c->outcipher))) { + logger(LOG_ERR, "Error during initialisation of cipher for %s (%s): %s", + c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL)); + return false; + } + + c->outbudget = byte_budget(c->outcipher); + c->status.encryptout = true; + } + + return x; } -bool metakey_h(connection_t *c, const char *request) { -#ifdef DISABLE_LEGACY - return false; -#else +bool metakey_h(connection_t *c) { + char buffer[MAX_STRING_SIZE]; + int cipher, digest, maclength, compression; + int len; - if(!myself->connection->rsa) { + if(sscanf(c->buffer, "%*d %d %d %d %d " MAX_STRING, &cipher, &digest, &maclength, &compression, buffer) != 5) { + logger(LOG_ERR, "Got bad %s from %s (%s)", "METAKEY", c->name, + c->hostname); return false; } - char hexkey[MAX_STRING_SIZE]; - int cipher, digest, maclength, compression; - const size_t len = rsa_size(myself->connection->rsa); - char enckey[len]; - char key[len]; + len = RSA_size(myself->connection->rsa_key); - if(sscanf(request, "%*d %d %d %d %d " MAX_STRING, &cipher, &digest, &maclength, &compression, hexkey) != 5) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "METAKEY", c->name, c->hostname); + /* Check if the length of the meta key is all right */ + + if(strlen(buffer) != (size_t)len * 2) { + logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, "wrong keylength"); return false; } + /* Allocate buffers for the meta key */ + + c->inkey = xrealloc(c->inkey, len); + + if(!c->inctx) { + c->inctx = EVP_CIPHER_CTX_new(); + + if(!c->inctx) { + abort(); + } + } + /* Convert the challenge from hexadecimal back to binary */ - size_t inlen = hex2bin(hexkey, enckey, sizeof(enckey)); - - /* Check if the length of the meta key is all right */ - - if(inlen != len) { - logger(DEBUG_ALWAYS, LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, "wrong keylength"); + if(!hex2bin(buffer, buffer, len)) { + logger(LOG_ERR, "Got bad %s from %s(%s): %s", "METAKEY", c->name, c->hostname, "invalid key"); return false; } /* Decrypt the meta key */ - if(!rsa_private_decrypt(myself->connection->rsa, enckey, len, key)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error during decryption of meta key for %s (%s)", c->name, c->hostname); + if(RSA_private_decrypt(len, (unsigned char *)buffer, (unsigned char *)c->inkey, myself->connection->rsa_key, RSA_NO_PADDING) != len) { /* See challenge() */ + logger(LOG_ERR, "Error during decryption of meta key for %s (%s): %s", + c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL)); return false; } - if(debug_level >= DEBUG_SCARY_THINGS) { - bin2hex(key, hexkey, len); - logger(DEBUG_SCARY_THINGS, LOG_DEBUG, "Received random meta key (unencrypted): %s", hexkey); + ifdebug(SCARY_THINGS) { + bin2hex(c->inkey, buffer, len); + buffer[len * 2] = '\0'; + logger(LOG_DEBUG, "Received random meta key (unencrypted): %s", buffer); } + /* All incoming requests will now be encrypted. */ + /* Check and lookup cipher and digest algorithms */ if(cipher) { - if(!(c->incipher = cipher_open_by_nid(cipher)) || !cipher_set_key_from_rsa(c->incipher, key, len, false)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error during initialisation of cipher from %s (%s)", c->name, c->hostname); + c->incipher = EVP_get_cipherbynid(cipher); + + if(!c->incipher) { + logger(LOG_ERR, "%s (%s) uses unknown cipher!", c->name, c->hostname); return false; } + + if(!EVP_DecryptInit(c->inctx, c->incipher, + (unsigned char *)c->inkey + len - EVP_CIPHER_key_length(c->incipher), + (unsigned char *)c->inkey + len - EVP_CIPHER_key_length(c->incipher) - + EVP_CIPHER_iv_length(c->incipher))) { + logger(LOG_ERR, "Error during initialisation of cipher from %s (%s): %s", + c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL)); + return false; + } + + c->inbudget = byte_budget(c->incipher); + c->status.decryptin = true; } else { - logger(DEBUG_ALWAYS, LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, "null cipher"); + logger(LOG_ERR, "%s (%s) uses null cipher!", c->name, c->hostname); return false; } - c->inbudget = cipher_budget(c->incipher); + c->inmaclength = maclength; if(digest) { - if(!(c->indigest = digest_open_by_nid(digest, -1))) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error during initialisation of digest from %s (%s)", c->name, c->hostname); + c->indigest = EVP_get_digestbynid(digest); + + if(!c->indigest) { + logger(LOG_ERR, "Node %s (%s) uses unknown digest!", c->name, c->hostname); + return false; + } + + if(c->inmaclength > EVP_MD_size(c->indigest) || c->inmaclength < 0) { + logger(LOG_ERR, "%s (%s) uses bogus MAC length!", c->name, c->hostname); return false; } } else { - logger(DEBUG_ALWAYS, LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, "null digest"); + logger(LOG_ERR, "%s (%s) uses null digest!", c->name, c->hostname); return false; } - c->status.decryptin = true; + c->incompression = compression; c->allow_request = CHALLENGE; return send_challenge(c); -#endif } bool send_challenge(connection_t *c) { -#ifdef DISABLE_LEGACY - return false; -#else - const size_t len = rsa_size(c->rsa); - char buffer[len * 2 + 1]; + /* CHECKME: what is most reasonable value for len? */ + + int len = RSA_size(c->rsa_key); + + /* Allocate buffers for the challenge */ + + char buffer[2 * len + 1]; c->hischallenge = xrealloc(c->hischallenge, len); /* Copy random data to the buffer */ - randomize(c->hischallenge, len); + if(1 != RAND_bytes((unsigned char *)c->hischallenge, len)) { + int err = ERR_get_error(); + logger(LOG_ERR, "Failed to generate challenge (%s)", ERR_error_string(err, NULL)); + return false; // Do not send predictable challenges, let connection attempt fail. + } /* Convert to hex */ bin2hex(c->hischallenge, buffer, len); + buffer[len * 2] = '\0'; /* Send the challenge */ return send_request(c, "%d %s", CHALLENGE, buffer); -#endif } -bool challenge_h(connection_t *c, const char *request) { -#ifdef DISABLE_LEGACY - return false; -#else - - if(!myself->connection->rsa) { - return false; - } - +bool challenge_h(connection_t *c) { char buffer[MAX_STRING_SIZE]; - const size_t len = rsa_size(myself->connection->rsa); + int len; - if(sscanf(request, "%*d " MAX_STRING, buffer) != 1) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "CHALLENGE", c->name, c->hostname); + if(sscanf(c->buffer, "%*d " MAX_STRING, buffer) != 1) { + logger(LOG_ERR, "Got bad %s from %s (%s)", "CHALLENGE", c->name, + c->hostname); return false; } + len = RSA_size(myself->connection->rsa_key); + /* Check if the length of the challenge is all right */ if(strlen(buffer) != (size_t)len * 2) { - logger(DEBUG_ALWAYS, LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, "wrong challenge length"); + logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name, + c->hostname, "wrong challenge length"); return false; } + /* Allocate buffers for the challenge */ + c->mychallenge = xrealloc(c->mychallenge, len); /* Convert the challenge from hexadecimal back to binary */ - hex2bin(buffer, c->mychallenge, len); - - /* The rest is done by send_chal_reply() */ + if(!hex2bin(buffer, c->mychallenge, len)) { + logger(LOG_ERR, "Got bad %s from %s(%s): %s", "CHALLENGE", c->name, c->hostname, "invalid challenge"); + return false; + } c->allow_request = CHAL_REPLY; + /* Rest is done by send_chal_reply() */ + if(c->outgoing) { return send_chal_reply(c); } else { return true; } - -#endif } bool send_chal_reply(connection_t *c) { - const size_t len = rsa_size(myself->connection->rsa); - size_t digestlen = digest_length(c->indigest); - char digest[digestlen * 2 + 1]; + char hash[EVP_MAX_MD_SIZE * 2 + 1]; + EVP_MD_CTX *ctx; /* Calculate the hash from the challenge we received */ - if(!digest_create(c->indigest, c->mychallenge, len, digest)) { + ctx = EVP_MD_CTX_create(); + + if(!ctx) { + abort(); + } + + if(!EVP_DigestInit(ctx, c->indigest) + || !EVP_DigestUpdate(ctx, c->mychallenge, RSA_size(myself->connection->rsa_key)) + || !EVP_DigestFinal(ctx, (unsigned char *)hash, NULL)) { + EVP_MD_CTX_destroy(ctx); + logger(LOG_ERR, "Error during calculation of response for %s (%s): %s", + c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL)); return false; } - free(c->mychallenge); - c->mychallenge = NULL; + EVP_MD_CTX_destroy(ctx); /* Convert the hash to a hexadecimal formatted string */ - bin2hex(digest, digest, digestlen); + bin2hex(hash, hash, EVP_MD_size(c->indigest)); + hash[EVP_MD_size(c->indigest) * 2] = '\0'; /* Send the reply */ - return send_request(c, "%d %s", CHAL_REPLY, digest); + return send_request(c, "%d %s", CHAL_REPLY, hash); } -bool chal_reply_h(connection_t *c, const char *request) { -#ifdef DISABLE_LEGACY - return false; -#else +bool chal_reply_h(connection_t *c) { char hishash[MAX_STRING_SIZE]; + char myhash[EVP_MAX_MD_SIZE]; + EVP_MD_CTX *ctx; - if(sscanf(request, "%*d " MAX_STRING, hishash) != 1) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "CHAL_REPLY", c->name, + if(sscanf(c->buffer, "%*d " MAX_STRING, hishash) != 1) { + logger(LOG_ERR, "Got bad %s from %s (%s)", "CHAL_REPLY", c->name, c->hostname); return false; } + /* Check if the length of the hash is all right */ + + if(strlen(hishash) != (size_t)EVP_MD_size(c->outdigest) * 2) { + logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name, + c->hostname, "wrong challenge reply length"); + return false; + } + /* Convert the hash to binary format */ - size_t inlen = hex2bin(hishash, hishash, sizeof(hishash)); - - /* Check if the length of the hash is all right */ - - if(inlen != digest_length(c->outdigest)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, "wrong challenge reply length"); + if(!hex2bin(hishash, hishash, EVP_MD_size(c->outdigest))) { + logger(LOG_ERR, "Got bad %s from %s(%s): %s", "CHAL_REPLY", c->name, c->hostname, "invalid hash"); return false; } + /* Calculate the hash from the challenge we sent */ - /* Verify the hash */ + ctx = EVP_MD_CTX_create(); + + if(!ctx) { + abort(); + } + + if(!EVP_DigestInit(ctx, c->outdigest) + || !EVP_DigestUpdate(ctx, c->hischallenge, RSA_size(c->rsa_key)) + || !EVP_DigestFinal(ctx, (unsigned char *)myhash, NULL)) { + EVP_MD_CTX_destroy(ctx); + logger(LOG_ERR, "Error during calculation of response from %s (%s): %s", + c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL)); + return false; + } + + EVP_MD_CTX_destroy(ctx); + + /* Verify the incoming hash with the calculated hash */ + + if(memcmp(hishash, myhash, EVP_MD_size(c->outdigest))) { + logger(LOG_ERR, "Possible intruder %s (%s): %s", c->name, + c->hostname, "wrong challenge reply"); + + ifdebug(SCARY_THINGS) { + bin2hex(myhash, hishash, SHA_DIGEST_LENGTH); + hishash[SHA_DIGEST_LENGTH * 2] = '\0'; + logger(LOG_DEBUG, "Expected challenge reply: %s", hishash); + } - if(!digest_verify(c->outdigest, c->hischallenge, rsa_size(c->rsa), hishash)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Possible intruder %s (%s): %s", c->name, c->hostname, "wrong challenge reply"); return false; } @@ -782,8 +508,6 @@ bool chal_reply_h(connection_t *c, const char *request) { Send an acknowledgement with the rest of the information needed. */ - free(c->hischallenge); - c->hischallenge = NULL; c->allow_request = ACK; if(!c->outgoing) { @@ -791,33 +515,9 @@ bool chal_reply_h(connection_t *c, const char *request) { } return send_ack(c); -#endif -} - -static bool send_upgrade(connection_t *c) { -#ifdef DISABLE_LEGACY - return false; -#else - /* Special case when protocol_minor is 1: the other end is Ed25519 capable, - * but doesn't know our key yet. So send it now. */ - - char *pubkey = ecdsa_get_base64_public_key(myself->connection->ecdsa); - - if(!pubkey) { - return false; - } - - bool result = send_request(c, "%d %s", ACK, pubkey); - free(pubkey); - return result; -#endif } bool send_ack(connection_t *c) { - if(c->protocol_minor == 1) { - return send_upgrade(c); - } - /* ACK message contains rest of the information the other end needs to create node_t and edge_t structures. */ @@ -850,100 +550,52 @@ bool send_ack(connection_t *c) { c->options |= OPTION_CLAMP_MSS; } - if(!get_config_int(lookup_config(c->config_tree, "Weight"), &c->estimated_weight)) { - get_config_int(lookup_config(config_tree, "Weight"), &c->estimated_weight); - } + get_config_int(lookup_config(c->config_tree, "Weight"), &c->estimated_weight); - return send_request(c, "%d %s %d %x", ACK, myport, c->estimated_weight, (c->options & 0xffffff) | (experimental ? (PROT_MINOR << 24) : 0)); + return send_request(c, "%d %s %d %x", ACK, myport, c->estimated_weight, c->options); } static void send_everything(connection_t *c) { + avl_node_t *node, *node2; + node_t *n; + subnet_t *s; + edge_t *e; + /* Send all known subnets and edges */ - if(disablebuggypeers) { - static struct { - vpn_packet_t pkt; - char pad[MAXBUFSIZE - MAXSIZE]; - } zeropkt; - - memset(&zeropkt, 0, sizeof(zeropkt)); - zeropkt.pkt.len = MAXBUFSIZE; - send_tcppacket(c, &zeropkt.pkt); - } - if(tunnelserver) { - for splay_each(subnet_t, s, myself->subnet_tree) { + for(node = myself->subnet_tree->head; node; node = node->next) { + s = node->data; send_add_subnet(c, s); } return; } - for splay_each(node_t, n, node_tree) { - for splay_each(subnet_t, s, n->subnet_tree) { + for(node = node_tree->head; node; node = node->next) { + n = node->data; + + for(node2 = n->subnet_tree->head; node2; node2 = node2->next) { + s = node2->data; send_add_subnet(c, s); } - for splay_each(edge_t, e, n->edge_tree) { + for(node2 = n->edge_tree->head; node2; node2 = node2->next) { + e = node2->data; send_add_edge(c, e); } } } -static bool upgrade_h(connection_t *c, const char *request) { - char pubkey[MAX_STRING_SIZE]; - - if(sscanf(request, "%*d " MAX_STRING, pubkey) != 1) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "ACK", c->name, c->hostname); - return false; - } - - if(ecdsa_active(c->ecdsa) || read_ecdsa_public_key(c)) { - char *knownkey = ecdsa_get_base64_public_key(c->ecdsa); - bool different = strcmp(knownkey, pubkey); - free(knownkey); - - if(different) { - logger(DEBUG_ALWAYS, LOG_ERR, "Already have an Ed25519 public key from %s (%s) which is different from the one presented now!", c->name, c->hostname); - return false; - } - - logger(DEBUG_ALWAYS, LOG_INFO, "Already have Ed25519 public key from %s (%s), ignoring.", c->name, c->hostname); - c->allow_request = TERMREQ; - return send_termreq(c); - } - - c->ecdsa = ecdsa_set_base64_public_key(pubkey); - - if(!c->ecdsa) { - logger(DEBUG_ALWAYS, LOG_INFO, "Got bad Ed25519 public key from %s (%s), not upgrading.", c->name, c->hostname); - return false; - } - - logger(DEBUG_ALWAYS, LOG_INFO, "Got Ed25519 public key from %s (%s), upgrading!", c->name, c->hostname); - append_config_file(c->name, "Ed25519PublicKey", pubkey); - c->allow_request = TERMREQ; - - if(c->outgoing) { - c->outgoing->timeout = 0; - } - - return send_termreq(c); -} - -bool ack_h(connection_t *c, const char *request) { - if(c->protocol_minor == 1) { - return upgrade_h(c, request); - } - +bool ack_h(connection_t *c) { char hisport[MAX_STRING_SIZE]; int weight, mtu; uint32_t options; node_t *n; bool choice; - if(sscanf(request, "%*d " MAX_STRING " %d %x", hisport, &weight, &options) != 3) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "ACK", c->name, + if(sscanf(c->buffer, "%*d " MAX_STRING " %d %x", hisport, &weight, &options) != 3) { + logger(LOG_ERR, "Got bad %s from %s (%s)", "ACK", c->name, c->hostname); return false; } @@ -959,18 +611,8 @@ bool ack_h(connection_t *c, const char *request) { } else { if(n->connection) { /* Oh dear, we already have a connection to this node. */ - logger(DEBUG_CONNECTIONS, LOG_DEBUG, "Established a second connection with %s (%s), closing old connection", n->connection->name, n->connection->hostname); - - if(n->connection->outgoing) { - if(c->outgoing) { - logger(DEBUG_ALWAYS, LOG_WARNING, "Two outgoing connections to the same node!"); - } else { - c->outgoing = n->connection->outgoing; - } - - n->connection->outgoing = NULL; - } - + ifdebug(CONNECTIONS) logger(LOG_DEBUG, "Established a second connection with %s (%s), closing old connection", + n->name, n->hostname); terminate_connection(n->connection, false); /* Run graph algorithm to purge key and make sure up/down scripts are rerun with new IP addresses and stuff */ graph(); @@ -1006,9 +648,10 @@ bool ack_h(connection_t *c, const char *request) { /* Activate this connection */ c->allow_request = ALL; + c->status.active = true; - logger(DEBUG_CONNECTIONS, LOG_NOTICE, "Connection with %s (%s) activated", c->name, - c->hostname); + ifdebug(CONNECTIONS) logger(LOG_NOTICE, "Connection with %s (%s) activated", c->name, + c->hostname); /* Send him everything we know */ @@ -1021,16 +664,6 @@ bool ack_h(connection_t *c, const char *request) { c->edge->to = n; sockaddrcpy(&c->edge->address, &c->address); sockaddr_setport(&c->edge->address, hisport); - sockaddr_t local_sa; - socklen_t local_salen = sizeof(local_sa); - - if(getsockname(c->socket, &local_sa.sa, &local_salen) < 0) { - logger(DEBUG_ALWAYS, LOG_WARNING, "Could not get local socket address for connection with %s", c->name); - } else { - sockaddr_setport(&local_sa, myport); - c->edge->local_address = local_sa; - } - c->edge->weight = (weight + c->estimated_weight) / 2; c->edge->connection = c; c->edge->options = c->options; diff --git a/src/protocol_edge.c b/src/protocol_edge.c index d650c36..a1cf640 100644 --- a/src/protocol_edge.c +++ b/src/protocol_edge.c @@ -1,7 +1,7 @@ /* protocol_edge.c -- handle the meta-protocol, edges Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2012 Guus Sliepen + 2000-2016 Guus Sliepen 2009 Michael Tokarev This program is free software; you can redistribute it and/or modify @@ -21,6 +21,7 @@ #include "system.h" +#include "avl_tree.h" #include "conf.h" #include "connection.h" #include "edge.h" @@ -40,45 +41,29 @@ bool send_add_edge(connection_t *c, const edge_t *e) { sockaddr2str(&e->address, &address, &port); - if(e->local_address.sa.sa_family) { - char *local_address, *local_port; - sockaddr2str(&e->local_address, &local_address, &local_port); - - x = send_request(c, "%d %x %s %s %s %s %x %d %s %s", ADD_EDGE, rand(), - e->from->name, e->to->name, address, port, - e->options, e->weight, local_address, local_port); - free(local_address); - free(local_port); - } else { - x = send_request(c, "%d %x %s %s %s %s %x %d", ADD_EDGE, rand(), - e->from->name, e->to->name, address, port, - e->options, e->weight); - } - + x = send_request(c, "%d %x %s %s %s %s %x %d", ADD_EDGE, rand(), + e->from->name, e->to->name, address, port, + e->options, e->weight); free(address); free(port); return x; } -bool add_edge_h(connection_t *c, const char *request) { +bool add_edge_h(connection_t *c) { edge_t *e; node_t *from, *to; char from_name[MAX_STRING_SIZE]; char to_name[MAX_STRING_SIZE]; char to_address[MAX_STRING_SIZE]; char to_port[MAX_STRING_SIZE]; - char address_local[MAX_STRING_SIZE]; - char port_local[MAX_STRING_SIZE]; - sockaddr_t address, local_address = {0}; + sockaddr_t address; uint32_t options; int weight; - int parameter_count = sscanf(request, "%*d %*x "MAX_STRING" "MAX_STRING" "MAX_STRING" "MAX_STRING" %x %d "MAX_STRING" "MAX_STRING, - from_name, to_name, to_address, to_port, &options, &weight, address_local, port_local); - - if(parameter_count != 6 && parameter_count != 8) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "ADD_EDGE", c->name, + if(sscanf(c->buffer, "%*d %*x "MAX_STRING" "MAX_STRING" "MAX_STRING" "MAX_STRING" %x %d", + from_name, to_name, to_address, to_port, &options, &weight) != 6) { + logger(LOG_ERR, "Got bad %s from %s (%s)", "ADD_EDGE", c->name, c->hostname); return false; } @@ -86,12 +71,12 @@ bool add_edge_h(connection_t *c, const char *request) { /* Check if names are valid */ if(!check_id(from_name) || !check_id(to_name) || !strcmp(from_name, to_name)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "ADD_EDGE", c->name, + logger(LOG_ERR, "Got bad %s from %s (%s): %s", "ADD_EDGE", c->name, c->hostname, "invalid name"); return false; } - if(seen_request(request)) { + if(seen_request(c->buffer)) { return true; } @@ -104,9 +89,9 @@ bool add_edge_h(connection_t *c, const char *request) { from != myself && from != c->node && to != myself && to != c->node) { /* ignore indirect edge registrations for tunnelserver */ - logger(DEBUG_PROTOCOL, LOG_WARNING, - "Ignoring indirect %s from %s (%s)", - "ADD_EDGE", c->name, c->hostname); + ifdebug(PROTOCOL) logger(LOG_WARNING, + "Ignoring indirect %s from %s (%s)", + "ADD_EDGE", c->name, c->hostname); return true; } @@ -127,88 +112,63 @@ bool add_edge_h(connection_t *c, const char *request) { address = str2sockaddr(to_address, to_port); - if(parameter_count >= 8) { - local_address = str2sockaddr(address_local, port_local); - } - /* Check if edge already exists */ e = lookup_edge(from, to); if(e) { - bool new_address = sockaddrcmp(&e->address, &address); - // local_address.sa.sa_family will be 0 if we got it from older tinc versions - // local_address.sa.sa_family will be 255 (AF_UNKNOWN) if we got it from newer versions - // but for edge which does not have local_address - bool new_local_address = local_address.sa.sa_family && local_address.sa.sa_family != AF_UNKNOWN && - sockaddrcmp(&e->local_address, &local_address); + if(e->weight != weight || e->options != options || sockaddrcmp(&e->address, &address)) { + if(from == myself) { + ifdebug(PROTOCOL) logger(LOG_WARNING, "Got %s from %s (%s) for ourself which does not match existing entry", + "ADD_EDGE", c->name, c->hostname); + send_add_edge(c, e); + return true; + } else { + ifdebug(PROTOCOL) logger(LOG_WARNING, "Got %s from %s (%s) which does not match existing entry", + "ADD_EDGE", c->name, c->hostname); + e->options = options; - if(e->weight == weight && e->options == options && !new_address && !new_local_address) { - sockaddrfree(&address); - sockaddrfree(&local_address); - return true; - } + if(sockaddrcmp(&e->address, &address)) { + sockaddrfree(&e->address); + e->address = address; + } - if(from == myself) { - logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) for ourself which does not match existing entry", - "ADD_EDGE", c->name, c->hostname); - send_add_edge(c, e); - sockaddrfree(&address); - sockaddrfree(&local_address); - return true; - } + if(e->weight != weight) { + avl_node_t *node = avl_unlink(edge_weight_tree, e); + e->weight = weight; + avl_insert_node(edge_weight_tree, node); + } - logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) which does not match existing entry", - "ADD_EDGE", c->name, c->hostname); - - e->options = options; - - if(new_address) { - sockaddrfree(&e->address); - e->address = address; + goto done; + } } else { - sockaddrfree(&address); - } - - if(new_local_address) { - sockaddrfree(&e->local_address); - e->local_address = local_address; - } else { - sockaddrfree(&local_address); - } - - if(e->weight != weight) { - splay_node_t *node = splay_unlink(edge_weight_tree, e); - e->weight = weight; - splay_insert_node(edge_weight_tree, node); + return true; } } else if(from == myself) { - logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) for ourself which does not exist", - "ADD_EDGE", c->name, c->hostname); + ifdebug(PROTOCOL) logger(LOG_WARNING, "Got %s from %s (%s) for ourself which does not exist", + "ADD_EDGE", c->name, c->hostname); contradicting_add_edge++; e = new_edge(); e->from = from; e->to = to; send_del_edge(c, e); free_edge(e); - sockaddrfree(&address); - sockaddrfree(&local_address); return true; - } else { - e = new_edge(); - e->from = from; - e->to = to; - e->address = address; - e->local_address = local_address; - e->options = options; - e->weight = weight; - edge_add(e); } + e = new_edge(); + e->from = from; + e->to = to; + e->address = address; + e->options = options; + e->weight = weight; + edge_add(e); + +done: /* Tell the rest about the new edge */ if(!tunnelserver) { - forward_request(c, request); + forward_request(c); } /* Run MST before or after we tell the rest? */ @@ -223,14 +183,14 @@ bool send_del_edge(connection_t *c, const edge_t *e) { e->from->name, e->to->name); } -bool del_edge_h(connection_t *c, const char *request) { +bool del_edge_h(connection_t *c) { edge_t *e; char from_name[MAX_STRING_SIZE]; char to_name[MAX_STRING_SIZE]; node_t *from, *to; - if(sscanf(request, "%*d %*x "MAX_STRING" "MAX_STRING, from_name, to_name) != 2) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "DEL_EDGE", c->name, + if(sscanf(c->buffer, "%*d %*x "MAX_STRING" "MAX_STRING, from_name, to_name) != 2) { + logger(LOG_ERR, "Got bad %s from %s (%s)", "DEL_EDGE", c->name, c->hostname); return false; } @@ -238,12 +198,12 @@ bool del_edge_h(connection_t *c, const char *request) { /* Check if names are valid */ if(!check_id(from_name) || !check_id(to_name) || !strcmp(from_name, to_name)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "DEL_EDGE", c->name, + logger(LOG_ERR, "Got bad %s from %s (%s): %s", "DEL_EDGE", c->name, c->hostname, "invalid name"); return false; } - if(seen_request(request)) { + if(seen_request(c->buffer)) { return true; } @@ -256,21 +216,21 @@ bool del_edge_h(connection_t *c, const char *request) { from != myself && from != c->node && to != myself && to != c->node) { /* ignore indirect edge registrations for tunnelserver */ - logger(DEBUG_PROTOCOL, LOG_WARNING, - "Ignoring indirect %s from %s (%s)", - "DEL_EDGE", c->name, c->hostname); + ifdebug(PROTOCOL) logger(LOG_WARNING, + "Ignoring indirect %s from %s (%s)", + "DEL_EDGE", c->name, c->hostname); return true; } if(!from) { - logger(DEBUG_PROTOCOL, LOG_ERR, "Got %s from %s (%s) which does not appear in the edge tree", - "DEL_EDGE", c->name, c->hostname); + ifdebug(PROTOCOL) logger(LOG_ERR, "Got %s from %s (%s) which does not appear in the edge tree", + "DEL_EDGE", c->name, c->hostname); return true; } if(!to) { - logger(DEBUG_PROTOCOL, LOG_ERR, "Got %s from %s (%s) which does not appear in the edge tree", - "DEL_EDGE", c->name, c->hostname); + ifdebug(PROTOCOL) logger(LOG_ERR, "Got %s from %s (%s) which does not appear in the edge tree", + "DEL_EDGE", c->name, c->hostname); return true; } @@ -279,14 +239,14 @@ bool del_edge_h(connection_t *c, const char *request) { e = lookup_edge(from, to); if(!e) { - logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) which does not appear in the edge tree", - "DEL_EDGE", c->name, c->hostname); + ifdebug(PROTOCOL) logger(LOG_WARNING, "Got %s from %s (%s) which does not appear in the edge tree", + "DEL_EDGE", c->name, c->hostname); return true; } if(e->from == myself) { - logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) for ourself", - "DEL_EDGE", c->name, c->hostname); + ifdebug(PROTOCOL) logger(LOG_WARNING, "Got %s from %s (%s) for ourself", + "DEL_EDGE", c->name, c->hostname); contradicting_del_edge++; send_add_edge(c, e); /* Send back a correction */ return true; @@ -295,7 +255,7 @@ bool del_edge_h(connection_t *c, const char *request) { /* Tell the rest about the deleted edge */ if(!tunnelserver) { - forward_request(c, request); + forward_request(c); } /* Delete the edge */ diff --git a/src/protocol_key.c b/src/protocol_key.c index 58a3bd2..6140a53 100644 --- a/src/protocol_key.c +++ b/src/protocol_key.c @@ -1,7 +1,7 @@ /* protocol_key.c -- handle the meta-protocol, key exchange Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2017 Guus Sliepen + 2000-2016 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,264 +20,102 @@ #include "system.h" -#include "cipher.h" +#include +#include +#include + +#include "avl_tree.h" #include "connection.h" -#include "crypto.h" #include "logger.h" #include "net.h" #include "netutl.h" #include "node.h" -#include "prf.h" #include "protocol.h" -#include "route.h" -#include "sptps.h" #include "utils.h" #include "xalloc.h" static bool mykeyused = false; void send_key_changed(void) { -#ifndef DISABLE_LEGACY + avl_node_t *node; + connection_t *c; + send_request(everyone, "%d %x %s", KEY_CHANGED, rand(), myself->name); /* Immediately send new keys to directly connected nodes to keep UDP mappings alive */ - for list_each(connection_t, c, connection_list) - if(c->edge && c->node && c->node->status.reachable && !c->node->status.sptps) { + for(node = connection_tree->head; node; node = node->next) { + c = node->data; + + if(c->status.active && c->node && c->node->status.reachable) { send_ans_key(c->node); } - -#endif - - /* Force key exchange for connections using SPTPS */ - - if(experimental) { - for splay_each(node_t, n, node_tree) - if(n->status.reachable && n->status.validkey && n->status.sptps) { - sptps_force_kex(&n->sptps); - } } } -bool key_changed_h(connection_t *c, const char *request) { +bool key_changed_h(connection_t *c) { char name[MAX_STRING_SIZE]; node_t *n; - if(sscanf(request, "%*d %*x " MAX_STRING, name) != 1) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "KEY_CHANGED", + if(sscanf(c->buffer, "%*d %*x " MAX_STRING, name) != 1) { + logger(LOG_ERR, "Got bad %s from %s (%s)", "KEY_CHANGED", c->name, c->hostname); return false; } - if(seen_request(request)) { + if(!check_id(name)) { + logger(LOG_ERR, "Got bad %s from %s (%s): %s", "KEY_CHANGED", c->name, c->hostname, "invalid name"); + return false; + } + + if(seen_request(c->buffer)) { return true; } n = lookup_node(name); if(!n) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got %s from %s (%s) origin %s which does not exist", + logger(LOG_ERR, "Got %s from %s (%s) origin %s which does not exist", "KEY_CHANGED", c->name, c->hostname, name); return true; } - if(!n->status.sptps) { - n->status.validkey = false; - n->last_req_key = 0; - } + n->status.validkey = false; + n->last_req_key = 0; /* Tell the others */ if(!tunnelserver) { - forward_request(c, request); + forward_request(c); } return true; } -static bool send_sptps_data_myself(void *handle, uint8_t type, const void *data, size_t len) { - return send_sptps_data(handle, myself, type, data, len); -} - -static bool send_initial_sptps_data(void *handle, uint8_t type, const void *data, size_t len) { - (void)type; - node_t *to = handle; - to->sptps.send_data = send_sptps_data_myself; - char buf[len * 4 / 3 + 5]; - - b64encode(data, buf, len); - - return send_request(to->nexthop->connection, "%d %s %s %d %s", REQ_KEY, myself->name, to->name, REQ_KEY, buf); -} - bool send_req_key(node_t *to) { - if(to->status.sptps) { - if(!node_read_ecdsa_public_key(to)) { - logger(DEBUG_PROTOCOL, LOG_DEBUG, "No Ed25519 key known for %s (%s)", to->name, to->hostname); - send_request(to->nexthop->connection, "%d %s %s %d", REQ_KEY, myself->name, to->name, REQ_PUBKEY); - return true; - } - - char label[25 + strlen(myself->name) + strlen(to->name)]; - snprintf(label, sizeof(label), "tinc UDP key expansion %s %s", myself->name, to->name); - sptps_stop(&to->sptps); - to->status.validkey = false; - to->status.waitingforkey = true; - to->last_req_key = now.tv_sec; - to->incompression = myself->incompression; - return sptps_start(&to->sptps, to, true, true, myself->connection->ecdsa, to->ecdsa, label, sizeof(label), send_initial_sptps_data, receive_sptps_record); - } - return send_request(to->nexthop->connection, "%d %s %s", REQ_KEY, myself->name, to->name); } -/* REQ_KEY is overloaded to allow arbitrary requests to be routed between two nodes. */ - -static bool req_key_ext_h(connection_t *c, const char *request, node_t *from, node_t *to, int reqno) { - (void)c; - - /* If this is a SPTPS packet, see if sending UDP info helps. - Note that we only do this if we're the destination or the static relay; - otherwise every hop would initiate its own UDP info message, resulting in elevated chatter. */ - if((reqno == REQ_KEY || reqno == SPTPS_PACKET) && to->via == myself) { - send_udp_info(myself, from); - } - - if(reqno == SPTPS_PACKET) { - /* This is a SPTPS data packet. */ - - char buf[MAX_STRING_SIZE]; - int len; - - if(sscanf(request, "%*d %*s %*s %*d " MAX_STRING, buf) != 1 || !(len = b64decode(buf, buf, strlen(buf)))) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s) to %s (%s): %s", "SPTPS_PACKET", from->name, from->hostname, to->name, to->hostname, "invalid SPTPS data"); - return true; - } - - if(to != myself) { - /* We don't just forward the request, because we want to use UDP if it's available. */ - if(forwarding_mode == FMODE_INTERNAL) { - send_sptps_data(to, from, 0, buf, len); - try_tx(to, true); - } - } else { - /* The packet is for us */ - if(!sptps_receive_data(&from->sptps, buf, len)) { - /* Uh-oh. It might be that the tunnel is stuck in some corrupted state, - so let's restart SPTPS in case that helps. But don't do that too often - to prevent storms. */ - if(from->last_req_key < now.tv_sec - 10) { - logger(DEBUG_PROTOCOL, LOG_ERR, "Failed to decode TCP packet from %s (%s), restarting SPTPS", from->name, from->hostname); - send_req_key(from); - } - - return true; - } - - send_mtu_info(myself, from, MTU); - } - - return true; - } - - /* Requests that are not SPTPS data packets are forwarded as-is. */ - - if(to != myself) { - return send_request(to->nexthop->connection, "%s", request); - } - - /* The request is for us */ - - switch(reqno) { - case REQ_PUBKEY: { - if(!node_read_ecdsa_public_key(from)) { - /* Request their key *before* we send our key back. Otherwise the first SPTPS packet from them will get dropped. */ - logger(DEBUG_PROTOCOL, LOG_DEBUG, "Preemptively requesting Ed25519 key for %s (%s)", from->name, from->hostname); - send_request(from->nexthop->connection, "%d %s %s %d", REQ_KEY, myself->name, from->name, REQ_PUBKEY); - } - - char *pubkey = ecdsa_get_base64_public_key(myself->connection->ecdsa); - send_request(from->nexthop->connection, "%d %s %s %d %s", REQ_KEY, myself->name, from->name, ANS_PUBKEY, pubkey); - free(pubkey); - return true; - } - - case ANS_PUBKEY: { - if(node_read_ecdsa_public_key(from)) { - logger(DEBUG_PROTOCOL, LOG_WARNING, "Got ANS_PUBKEY from %s (%s) even though we already have his pubkey", from->name, from->hostname); - return true; - } - - char pubkey[MAX_STRING_SIZE]; - - if(sscanf(request, "%*d %*s %*s %*d " MAX_STRING, pubkey) != 1 || !(from->ecdsa = ecdsa_set_base64_public_key(pubkey))) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "ANS_PUBKEY", from->name, from->hostname, "invalid pubkey"); - return true; - } - - logger(DEBUG_PROTOCOL, LOG_INFO, "Learned Ed25519 public key from %s (%s)", from->name, from->hostname); - append_config_file(from->name, "Ed25519PublicKey", pubkey); - return true; - } - - case REQ_KEY: { - if(!node_read_ecdsa_public_key(from)) { - logger(DEBUG_PROTOCOL, LOG_DEBUG, "No Ed25519 key known for %s (%s)", from->name, from->hostname); - send_request(from->nexthop->connection, "%d %s %s %d", REQ_KEY, myself->name, from->name, REQ_PUBKEY); - return true; - } - - if(from->sptps.label) { - logger(DEBUG_ALWAYS, LOG_DEBUG, "Got REQ_KEY from %s while we already started a SPTPS session!", from->name); - } - - char buf[MAX_STRING_SIZE]; - size_t len; - - if(sscanf(request, "%*d %*s %*s %*d " MAX_STRING, buf) != 1 || !(len = b64decode(buf, buf, strlen(buf)))) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "REQ_SPTPS_START", from->name, from->hostname, "invalid SPTPS data"); - return true; - } - - char label[25 + strlen(from->name) + strlen(myself->name)]; - snprintf(label, sizeof(label), "tinc UDP key expansion %s %s", from->name, myself->name); - sptps_stop(&from->sptps); - from->status.validkey = false; - from->status.waitingforkey = true; - from->last_req_key = now.tv_sec; - sptps_start(&from->sptps, from, false, true, myself->connection->ecdsa, from->ecdsa, label, sizeof(label), send_sptps_data_myself, receive_sptps_record); - sptps_receive_data(&from->sptps, buf, len); - send_mtu_info(myself, from, MTU); - return true; - } - - default: - logger(DEBUG_ALWAYS, LOG_ERR, "Unknown extended REQ_KEY request from %s (%s): %s", from->name, from->hostname, request); - return true; - } -} - -bool req_key_h(connection_t *c, const char *request) { +bool req_key_h(connection_t *c) { char from_name[MAX_STRING_SIZE]; char to_name[MAX_STRING_SIZE]; node_t *from, *to; - int reqno = 0; - if(sscanf(request, "%*d " MAX_STRING " " MAX_STRING " %d", from_name, to_name, &reqno) < 2) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "REQ_KEY", c->name, + if(sscanf(c->buffer, "%*d " MAX_STRING " " MAX_STRING, from_name, to_name) != 2) { + logger(LOG_ERR, "Got bad %s from %s (%s)", "REQ_KEY", c->name, c->hostname); return false; } if(!check_id(from_name) || !check_id(to_name)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "REQ_KEY", c->name, c->hostname, "invalid name"); + logger(LOG_ERR, "Got bad %s from %s (%s): %s", "REQ_KEY", c->name, c->hostname, "invalid name"); return false; } from = lookup_node(from_name); if(!from) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got %s from %s (%s) origin %s which does not exist in our connection list", + logger(LOG_ERR, "Got %s from %s (%s) origin %s which does not exist in our connection list", "REQ_KEY", c->name, c->hostname, from_name); return true; } @@ -285,108 +123,77 @@ bool req_key_h(connection_t *c, const char *request) { to = lookup_node(to_name); if(!to) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got %s from %s (%s) destination %s which does not exist in our connection list", + logger(LOG_ERR, "Got %s from %s (%s) destination %s which does not exist in our connection list", "REQ_KEY", c->name, c->hostname, to_name); return true; } /* Check if this key request is for us */ - if(to == myself) { /* Yes */ - /* Is this an extended REQ_KEY message? */ - if(experimental && reqno) { - return req_key_ext_h(c, request, from, to, reqno); + if(to == myself) { /* Yes, send our own key back */ + if(!send_ans_key(from)) { + return false; } - - /* No, just send our key back */ - send_ans_key(from); } else { if(tunnelserver) { return true; } if(!to->status.reachable) { - logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) destination %s which is not reachable", + logger(LOG_WARNING, "Got %s from %s (%s) destination %s which is not reachable", "REQ_KEY", c->name, c->hostname, to_name); return true; } - /* Is this an extended REQ_KEY message? */ - if(experimental && reqno) { - return req_key_ext_h(c, request, from, to, reqno); - } - - send_request(to->nexthop->connection, "%s", request); + send_request(to->nexthop->connection, "%s", c->buffer); } return true; } bool send_ans_key(node_t *to) { - if(to->status.sptps) { - abort(); - } - -#ifdef DISABLE_LEGACY - return false; -#else - size_t keylen = myself->incipher ? cipher_keylength(myself->incipher) : 1; - char key[keylen * 2 + 1]; - - randomize(key, keylen); - - cipher_close(to->incipher); - digest_close(to->indigest); - - if(myself->incipher) { - to->incipher = cipher_open_by_nid(cipher_get_nid(myself->incipher)); - - if(!to->incipher) { - abort(); - } - - if(!cipher_set_key(to->incipher, key, false)) { - abort(); - } - } - - if(myself->indigest) { - to->indigest = digest_open_by_nid(digest_get_nid(myself->indigest), digest_length(myself->indigest)); - - if(!to->indigest) { - abort(); - } - - if(!digest_set_key(to->indigest, key, keylen)) { - abort(); - } - } - + // Set key parameters + to->incipher = myself->incipher; + to->inkeylength = myself->inkeylength; + to->indigest = myself->indigest; + to->inmaclength = myself->inmaclength; to->incompression = myself->incompression; - bin2hex(key, key, keylen); + // Allocate memory for key + to->inkey = xrealloc(to->inkey, to->inkeylength); + + // Create a new key + if(1 != RAND_bytes((unsigned char *)to->inkey, to->inkeylength)) { + int err = ERR_get_error(); + logger(LOG_ERR, "Failed to generate random for key (%s)", ERR_error_string(err, NULL)); + return false; // Do not send insecure keys, let connection attempt fail. + } + + if(to->incipher) { + EVP_DecryptInit_ex(to->inctx, to->incipher, NULL, (unsigned char *)to->inkey, (unsigned char *)to->inkey + EVP_CIPHER_key_length(to->incipher)); + } // Reset sequence number and late packet window mykeyused = true; to->received_seqno = 0; - to->received = 0; if(replaywin) { memset(to->late, 0, replaywin); } - to->status.validkey_in = true; + // Convert to hexadecimal and send + char key[2 * to->inkeylength + 1]; + bin2hex(to->inkey, key, to->inkeylength); + key[to->inkeylength * 2] = '\0'; return send_request(to->nexthop->connection, "%d %s %s %s %d %d %d %d", ANS_KEY, myself->name, to->name, key, - cipher_get_nid(to->incipher), - digest_get_nid(to->indigest), - (int)digest_length(to->indigest), + to->incipher ? EVP_CIPHER_nid(to->incipher) : 0, + to->indigest ? EVP_MD_type(to->indigest) : 0, to->inmaclength, to->incompression); -#endif } -bool ans_key_h(connection_t *c, const char *request) { +bool ans_key_h(connection_t *c) { char from_name[MAX_STRING_SIZE]; char to_name[MAX_STRING_SIZE]; char key[MAX_STRING_SIZE]; @@ -395,23 +202,23 @@ bool ans_key_h(connection_t *c, const char *request) { int cipher, digest, maclength, compression; node_t *from, *to; - if(sscanf(request, "%*d "MAX_STRING" "MAX_STRING" "MAX_STRING" %d %d %d %d "MAX_STRING" "MAX_STRING, + if(sscanf(c->buffer, "%*d "MAX_STRING" "MAX_STRING" "MAX_STRING" %d %d %d %d "MAX_STRING" "MAX_STRING, from_name, to_name, key, &cipher, &digest, &maclength, &compression, address, port) < 7) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "ANS_KEY", c->name, + logger(LOG_ERR, "Got bad %s from %s (%s)", "ANS_KEY", c->name, c->hostname); return false; } if(!check_id(from_name) || !check_id(to_name)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "ANS_KEY", c->name, c->hostname, "invalid name"); + logger(LOG_ERR, "Got bad %s from %s (%s): %s", "ANS_KEY", c->name, c->hostname, "invalid name"); return false; } from = lookup_node(from_name); if(!from) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got %s from %s (%s) origin %s which does not exist in our connection list", + logger(LOG_ERR, "Got %s from %s (%s) origin %s which does not exist in our connection list", "ANS_KEY", c->name, c->hostname, from_name); return true; } @@ -419,7 +226,7 @@ bool ans_key_h(connection_t *c, const char *request) { to = lookup_node(to_name); if(!to) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got %s from %s (%s) destination %s which does not exist in our connection list", + logger(LOG_ERR, "Got %s from %s (%s) destination %s which does not exist in our connection list", "ANS_KEY", c->name, c->hostname, to_name); return true; } @@ -432,131 +239,107 @@ bool ans_key_h(connection_t *c, const char *request) { } if(!to->status.reachable) { - logger(DEBUG_ALWAYS, LOG_WARNING, "Got %s from %s (%s) destination %s which is not reachable", + logger(LOG_WARNING, "Got %s from %s (%s) destination %s which is not reachable", "ANS_KEY", c->name, c->hostname, to_name); return true; } if(!*address && from->address.sa.sa_family != AF_UNSPEC && to->minmtu) { char *address, *port; - logger(DEBUG_PROTOCOL, LOG_DEBUG, "Appending reflexive UDP address to ANS_KEY from %s to %s", from->name, to->name); + ifdebug(PROTOCOL) logger(LOG_DEBUG, "Appending reflexive UDP address to ANS_KEY from %s to %s", from->name, to->name); sockaddr2str(&from->address, &address, &port); - send_request(to->nexthop->connection, "%s %s %s", request, address, port); + send_request(to->nexthop->connection, "%s %s %s", c->buffer, address, port); free(address); free(port); return true; } - return send_request(to->nexthop->connection, "%s", request); + return send_request(to->nexthop->connection, "%s", c->buffer); } -#ifndef DISABLE_LEGACY /* Don't use key material until every check has passed. */ - cipher_close(from->outcipher); - digest_close(from->outdigest); -#endif + from->status.validkey = false; - if(!from->status.sptps) { - from->status.validkey = false; - } + /* Update our copy of the origin's packet key */ + from->outkey = xrealloc(from->outkey, strlen(key) / 2); + from->outkeylength = strlen(key) / 2; - if(compression < 0 || compression > 11) { - logger(DEBUG_ALWAYS, LOG_ERR, "Node %s (%s) uses bogus compression level!", from->name, from->hostname); + if(!hex2bin(key, from->outkey, from->outkeylength)) { + logger(LOG_ERR, "Got bad %s from %s(%s): %s", "ANS_KEY", from->name, from->hostname, "invalid key"); return true; } - from->outcompression = compression; - - /* SPTPS or old-style key exchange? */ - - if(from->status.sptps) { - char buf[strlen(key)]; - size_t len = b64decode(key, buf, strlen(key)); - - if(!len || !sptps_receive_data(&from->sptps, buf, len)) { - /* Uh-oh. It might be that the tunnel is stuck in some corrupted state, - so let's restart SPTPS in case that helps. But don't do that too often - to prevent storms. - Note that simply relying on handshake timeout is not enough, because - that doesn't apply to key regeneration. */ - if(from->last_req_key < now.tv_sec - 10) { - logger(DEBUG_PROTOCOL, LOG_ERR, "Failed to decode handshake TCP packet from %s (%s), restarting SPTPS", from->name, from->hostname); - send_req_key(from); - } - - return true; - } - - if(from->status.validkey) { - if(*address && *port) { - logger(DEBUG_PROTOCOL, LOG_DEBUG, "Using reflexive UDP address from %s: %s port %s", from->name, address, port); - sockaddr_t sa = str2sockaddr(address, port); - update_node_udp(from, &sa); - } - } - - send_mtu_info(myself, from, MTU); - - return true; - } - -#ifdef DISABLE_LEGACY - logger(DEBUG_ALWAYS, LOG_ERR, "Node %s (%s) uses legacy protocol!", from->name, from->hostname); - return false; -#else /* Check and lookup cipher and digest algorithms */ if(cipher) { - if(!(from->outcipher = cipher_open_by_nid(cipher))) { - logger(DEBUG_ALWAYS, LOG_ERR, "Node %s (%s) uses unknown cipher!", from->name, from->hostname); - return false; + from->outcipher = EVP_get_cipherbynid(cipher); + + if(!from->outcipher) { + logger(LOG_ERR, "Node %s (%s) uses unknown cipher!", from->name, + from->hostname); + return true; + } + + if(from->outkeylength != EVP_CIPHER_key_length(from->outcipher) + EVP_CIPHER_iv_length(from->outcipher)) { + logger(LOG_ERR, "Node %s (%s) uses wrong keylength!", from->name, + from->hostname); + return true; } } else { + if(from->outkeylength != 1) { + logger(LOG_ERR, "Node %s (%s) uses wrong keylength!", from->name, from->hostname); + return true; + } + from->outcipher = NULL; } + from->outmaclength = maclength; + if(digest) { - if(!(from->outdigest = digest_open_by_nid(digest, maclength))) { - logger(DEBUG_ALWAYS, LOG_ERR, "Node %s (%s) uses unknown digest!", from->name, from->hostname); - return false; + from->outdigest = EVP_get_digestbynid(digest); + + if(!from->outdigest) { + logger(LOG_ERR, "Node %s (%s) uses unknown digest!", from->name, + from->hostname); + return true; + } + + if(from->outmaclength > EVP_MD_size(from->outdigest) || from->outmaclength < 0) { + logger(LOG_ERR, "Node %s (%s) uses bogus MAC length!", + from->name, from->hostname); + return true; } } else { from->outdigest = NULL; } - if((size_t)maclength != digest_length(from->outdigest)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Node %s (%s) uses bogus MAC length!", from->name, from->hostname); - return false; - } - - /* Process key */ - - size_t keylen = hex2bin(key, key, sizeof(key)); - - if(keylen != (from->outcipher ? cipher_keylength(from->outcipher) : 1)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Node %s (%s) uses wrong keylength!", from->name, from->hostname); + if(compression < 0 || compression > 11) { + logger(LOG_ERR, "Node %s (%s) uses bogus compression level!", from->name, from->hostname); return true; } - /* Update our copy of the origin's packet key */ + from->outcompression = compression; - if(from->outcipher && !cipher_set_key(from->outcipher, key, true)) { - return false; - } - - if(from->outdigest && !digest_set_key(from->outdigest, key, keylen)) { - return false; - } + if(from->outcipher) + if(!EVP_EncryptInit_ex(from->outctx, from->outcipher, NULL, (unsigned char *)from->outkey, (unsigned char *)from->outkey + EVP_CIPHER_key_length(from->outcipher))) { + logger(LOG_ERR, "Error during initialisation of key from %s (%s): %s", + from->name, from->hostname, ERR_error_string(ERR_get_error(), NULL)); + return true; + } from->status.validkey = true; from->sent_seqno = 0; if(*address && *port) { - logger(DEBUG_PROTOCOL, LOG_DEBUG, "Using reflexive UDP address from %s: %s port %s", from->name, address, port); + ifdebug(PROTOCOL) logger(LOG_DEBUG, "Using reflexive UDP address from %s: %s port %s", from->name, address, port); sockaddr_t sa = str2sockaddr(address, port); update_node_udp(from, &sa); } + if(from->options & OPTION_PMTU_DISCOVERY && !from->mtuevent) { + send_mtu_probe(from); + } + return true; -#endif } diff --git a/src/protocol_misc.c b/src/protocol_misc.c index a4fcd6f..904ac3f 100644 --- a/src/protocol_misc.c +++ b/src/protocol_misc.c @@ -1,7 +1,7 @@ /* protocol_misc.c -- handle the meta-protocol, miscellaneous functions Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2013 Guus Sliepen + 2000-2012 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,7 +20,6 @@ #include "system.h" -#include "address_cache.h" #include "conf.h" #include "connection.h" #include "logger.h" @@ -29,35 +28,17 @@ #include "netutl.h" #include "protocol.h" #include "utils.h" -#include "xalloc.h" - -#ifndef MIN -#define MIN(x, y) (((x)<(y))?(x):(y)) -#endif int maxoutbufsize = 0; -int mtu_info_interval = 5; -int udp_info_interval = 5; - -bool send_termreq(connection_t *c) { - return send_request(c, "%d", TERMREQ); -} - -bool termreq_h(connection_t *c, const char *request) { - (void)c; - (void)request; - return false; -} bool send_ping(connection_t *c) { c->status.pinged = true; - c->last_ping_time = now.tv_sec; + c->last_ping_time = now; return send_request(c, "%d", PING); } -bool ping_h(connection_t *c, const char *request) { - (void)request; +bool ping_h(connection_t *c) { return send_pong(c); } @@ -65,15 +46,21 @@ bool send_pong(connection_t *c) { return send_request(c, "%d", PONG); } -bool pong_h(connection_t *c, const char *request) { - (void)request; +bool pong_h(connection_t *c) { c->status.pinged = false; /* Successful connection, reset timeout if this is an outgoing connection. */ if(c->outgoing) { c->outgoing->timeout = 0; - reset_address_cache(c->outgoing->address_cache, &c->address); + c->outgoing->cfg = NULL; + + if(c->outgoing->ai) { + freeaddrinfo(c->outgoing->ai); + } + + c->outgoing->ai = NULL; + c->outgoing->aip = NULL; } return true; @@ -85,22 +72,22 @@ bool send_tcppacket(connection_t *c, const vpn_packet_t *packet) { /* If there already is a lot of data in the outbuf buffer, discard this packet. We use a very simple Random Early Drop algorithm. */ - if(2.0 * c->outbuf.len / (float)maxoutbufsize - 1 > (float)rand() / (float)RAND_MAX) { + if(2.0 * c->outbuflen / (float)maxoutbufsize - 1 > (float)rand() / (float)RAND_MAX) { return true; } - if(!send_request(c, "%d %d", PACKET, packet->len)) { + if(!send_request(c, "%d %hd", PACKET, packet->len)) { return false; } - return send_meta(c, (char *)DATA(packet), packet->len); + return send_meta(c, (char *)packet->data, packet->len) && flush_meta(c); } -bool tcppacket_h(connection_t *c, const char *request) { - short int len; +bool tcppacket_h(connection_t *c) { + length_t len; - if(sscanf(request, "%*d %hd", &len) != 1) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "PACKET", c->name, + if(sscanf(c->buffer, "%*d %hu", &len) != 1) { + logger(LOG_ERR, "Got bad %s from %s (%s)", "PACKET", c->name, c->hostname); return false; } @@ -111,260 +98,3 @@ bool tcppacket_h(connection_t *c, const char *request) { return true; } - -bool send_sptps_tcppacket(connection_t *c, const char *packet, int len) { - /* If there already is a lot of data in the outbuf buffer, discard this packet. - We use a very simple Random Early Drop algorithm. */ - - if(2.0 * c->outbuf.len / (float)maxoutbufsize - 1 > (float)rand() / (float)RAND_MAX) { - return true; - } - - if(!send_request(c, "%d %d", SPTPS_PACKET, len)) { - return false; - } - - send_meta_raw(c, packet, len); - return true; -} - -bool sptps_tcppacket_h(connection_t *c, const char *request) { - short int len; - - if(sscanf(request, "%*d %hd", &len) != 1) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "SPTPS_PACKET", c->name, - c->hostname); - return false; - } - - /* Set sptpslen to len, this will tell receive_meta() that a SPTPS packet is coming. */ - - c->sptpslen = len; - - return true; -} - -/* Transmitting UDP information */ - -bool send_udp_info(node_t *from, node_t *to) { - /* If there's a static relay in the path, there's no point in sending the message - farther than the static relay. */ - to = (to->via == myself) ? to->nexthop : to->via; - - if(to == NULL) { - logger(DEBUG_ALWAYS, LOG_ERR, "Something went wrong when selecting relay - possible fake UDP_INFO"); - return false; - } - - /* Skip cases where sending UDP info messages doesn't make sense. - This is done here in order to avoid repeating the same logic in multiple callsites. */ - - if(to == myself) { - return true; - } - - if(!to->status.reachable) { - return true; - } - - if(from == myself) { - if(to->connection) { - return true; - } - - struct timeval elapsed; - - timersub(&now, &to->udp_info_sent, &elapsed); - - if(elapsed.tv_sec < udp_info_interval) { - return true; - } - } - - if((myself->options | from->options | to->options) & OPTION_TCPONLY) { - return true; - } - - if((to->nexthop->options >> 24) < 5) { - return true; - } - - char *from_address, *from_port; - /* If we're the originator, the address we use is irrelevant - because the first intermediate node will ignore it. - We use our local address as it somewhat makes sense - and it's simpler than introducing an encoding for "null" addresses anyway. */ - sockaddr2str((from != myself) ? &from->address : &to->nexthop->connection->edge->local_address, &from_address, &from_port); - - bool x = send_request(to->nexthop->connection, "%d %s %s %s %s", UDP_INFO, from->name, to->name, from_address, from_port); - - free(from_address); - free(from_port); - - if(from == myself) { - to->udp_info_sent = now; - } - - return x; -} - -bool udp_info_h(connection_t *c, const char *request) { - char from_name[MAX_STRING_SIZE]; - char to_name[MAX_STRING_SIZE]; - char from_address[MAX_STRING_SIZE]; - char from_port[MAX_STRING_SIZE]; - - if(sscanf(request, "%*d "MAX_STRING" "MAX_STRING" "MAX_STRING" "MAX_STRING, from_name, to_name, from_address, from_port) != 4) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "UDP_INFO", c->name, c->hostname); - return false; - } - - if(!check_id(from_name) || !check_id(to_name)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "UDP_INFO", c->name, c->hostname, "invalid name"); - return false; - } - - node_t *from = lookup_node(from_name); - - if(!from) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got %s from %s (%s) origin %s which does not exist in our connection list", "UDP_INFO", c->name, c->hostname, from_name); - return true; - } - - if(from != from->via) { - /* Not supposed to happen, as it means the message wandered past a static relay */ - logger(DEBUG_PROTOCOL, LOG_WARNING, "Got UDP info message from %s (%s) which we can't reach directly", from->name, from->hostname); - return true; - } - - /* If we have a direct edge to "from", we are in a better position - to guess its address than it is itself. */ - if(!from->connection && !from->status.udp_confirmed) { - sockaddr_t from_addr = str2sockaddr(from_address, from_port); - - if(sockaddrcmp(&from_addr, &from->address)) { - update_node_udp(from, &from_addr); - } - } - - node_t *to = lookup_node(to_name); - - if(!to) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got %s from %s (%s) destination %s which does not exist in our connection list", "UDP_INFO", c->name, c->hostname, to_name); - return true; - } - - /* Send our own data (which could be what we just received) up the chain. */ - - return send_udp_info(from, to); -} - -/* Transmitting MTU information */ - -bool send_mtu_info(node_t *from, node_t *to, int mtu) { - /* Skip cases where sending MTU info messages doesn't make sense. - This is done here in order to avoid repeating the same logic in multiple callsites. */ - - if(to == myself) { - return true; - } - - if(!to->status.reachable) { - return true; - } - - if(from == myself) { - if(to->connection) { - return true; - } - - struct timeval elapsed; - - timersub(&now, &to->mtu_info_sent, &elapsed); - - if(elapsed.tv_sec < mtu_info_interval) { - return true; - } - } - - if((to->nexthop->options >> 24) < 6) { - return true; - } - - /* We will send the passed-in MTU value, unless we believe ours is better. */ - - node_t *via = (from->via == myself) ? from->nexthop : from->via; - - if(from->minmtu == from->maxmtu && from->via == myself) { - /* We have a direct measurement. Override the value entirely. - Note that we only do that if we are sitting as a static relay in the path; - otherwise, we can't guarantee packets will flow through us, and increasing - MTU could therefore end up being too optimistic. */ - mtu = from->minmtu; - } else if(via->minmtu == via->maxmtu) { - /* Static relay. Ensure packets will make it through the entire relay path. */ - mtu = MIN(mtu, via->minmtu); - } else if(via->nexthop->minmtu == via->nexthop->maxmtu) { - /* Dynamic relay. Ensure packets will make it through the entire relay path. */ - mtu = MIN(mtu, via->nexthop->minmtu); - } - - if(from == myself) { - to->mtu_info_sent = now; - } - - /* If none of the conditions above match in the steady state, it means we're using TCP, - so the MTU is irrelevant. That said, it is still important to honor the MTU that was passed in, - because other parts of the relay path might be able to use UDP, which means they care about the MTU. */ - - return send_request(to->nexthop->connection, "%d %s %s %d", MTU_INFO, from->name, to->name, mtu); -} - -bool mtu_info_h(connection_t *c, const char *request) { - char from_name[MAX_STRING_SIZE]; - char to_name[MAX_STRING_SIZE]; - int mtu; - - if(sscanf(request, "%*d "MAX_STRING" "MAX_STRING" %d", from_name, to_name, &mtu) != 3) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "MTU_INFO", c->name, c->hostname); - return false; - } - - if(mtu < 512) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "MTU_INFO", c->name, c->hostname, "invalid MTU"); - return false; - } - - mtu = MIN(mtu, MTU); - - if(!check_id(from_name) || !check_id(to_name)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "MTU_INFO", c->name, c->hostname, "invalid name"); - return false; - } - - node_t *from = lookup_node(from_name); - - if(!from) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got %s from %s (%s) origin %s which does not exist in our connection list", "MTU_INFO", c->name, c->hostname, from_name); - return true; - } - - /* If we don't know the current MTU for that node, use the one we received. - Even if we're about to make our own measurements, the value we got from downstream nodes should be pretty close - so it's a good idea to use it in the mean time. */ - if(from->mtu != mtu && from->minmtu != from->maxmtu) { - logger(DEBUG_TRAFFIC, LOG_INFO, "Using provisional MTU %d for node %s (%s)", mtu, from->name, from->hostname); - from->mtu = mtu; - } - - node_t *to = lookup_node(to_name); - - if(!to) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got %s from %s (%s) destination %s which does not exist in our connection list", "MTU_INFO", c->name, c->hostname, to_name); - return true; - } - - /* Continue passing the MTU value (or a better one if we have it) up the chain. */ - - return send_mtu_info(from, to, mtu); -} diff --git a/src/protocol_subnet.c b/src/protocol_subnet.c index 53afb8a..2c4d08f 100644 --- a/src/protocol_subnet.c +++ b/src/protocol_subnet.c @@ -1,7 +1,7 @@ /* protocol_subnet.c -- handle the meta-protocol, subnets Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2012 Guus Sliepen + 2000-2009 Guus Sliepen 2009 Michael Tokarev This program is free software; you can redistribute it and/or modify @@ -42,14 +42,14 @@ bool send_add_subnet(connection_t *c, const subnet_t *subnet) { return send_request(c, "%d %x %s %s", ADD_SUBNET, rand(), subnet->owner->name, netstr); } -bool add_subnet_h(connection_t *c, const char *request) { +bool add_subnet_h(connection_t *c) { char subnetstr[MAX_STRING_SIZE]; char name[MAX_STRING_SIZE]; node_t *owner; subnet_t s = {0}, *new, *old; - if(sscanf(request, "%*d %*x " MAX_STRING " " MAX_STRING, name, subnetstr) != 2) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "ADD_SUBNET", c->name, + if(sscanf(c->buffer, "%*d %*x " MAX_STRING " " MAX_STRING, name, subnetstr) != 2) { + logger(LOG_ERR, "Got bad %s from %s (%s)", "ADD_SUBNET", c->name, c->hostname); return false; } @@ -57,7 +57,7 @@ bool add_subnet_h(connection_t *c, const char *request) { /* Check if owner name is valid */ if(!check_id(name)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "ADD_SUBNET", c->name, + logger(LOG_ERR, "Got bad %s from %s (%s): %s", "ADD_SUBNET", c->name, c->hostname, "invalid name"); return false; } @@ -65,12 +65,12 @@ bool add_subnet_h(connection_t *c, const char *request) { /* Check if subnet string is valid */ if(!str2net(&s, subnetstr)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "ADD_SUBNET", c->name, + logger(LOG_ERR, "Got bad %s from %s (%s): %s", "ADD_SUBNET", c->name, c->hostname, "invalid subnet string"); return false; } - if(seen_request(request)) { + if(seen_request(c->buffer)) { return true; } @@ -80,8 +80,8 @@ bool add_subnet_h(connection_t *c, const char *request) { if(tunnelserver && owner != myself && owner != c->node) { /* in case of tunnelserver, ignore indirect subnet registrations */ - logger(DEBUG_PROTOCOL, LOG_WARNING, "Ignoring indirect %s from %s (%s) for %s", - "ADD_SUBNET", c->name, c->hostname, subnetstr); + ifdebug(PROTOCOL) logger(LOG_WARNING, "Ignoring indirect %s from %s (%s) for %s", + "ADD_SUBNET", c->name, c->hostname, subnetstr); return true; } @@ -100,8 +100,8 @@ bool add_subnet_h(connection_t *c, const char *request) { /* If we don't know this subnet, but we are the owner, retaliate with a DEL_SUBNET */ if(owner == myself) { - logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) for ourself", - "ADD_SUBNET", c->name, c->hostname); + ifdebug(PROTOCOL) logger(LOG_WARNING, "Got %s from %s (%s) for ourself", + "ADD_SUBNET", c->name, c->hostname); s.owner = myself; send_del_subnet(c, &s); return true; @@ -110,7 +110,7 @@ bool add_subnet_h(connection_t *c, const char *request) { /* In tunnel server mode, we should already know all allowed subnets */ if(tunnelserver) { - logger(DEBUG_ALWAYS, LOG_WARNING, "Ignoring unauthorized %s from %s (%s): %s", + logger(LOG_WARNING, "Ignoring unauthorized %s from %s (%s): %s", "ADD_SUBNET", c->name, c->hostname, subnetstr); return true; } @@ -118,9 +118,9 @@ bool add_subnet_h(connection_t *c, const char *request) { /* Ignore if strictsubnets is true, but forward it to others */ if(strictsubnets) { - logger(DEBUG_ALWAYS, LOG_WARNING, "Ignoring unauthorized %s from %s (%s): %s", + logger(LOG_WARNING, "Ignoring unauthorized %s from %s (%s): %s", "ADD_SUBNET", c->name, c->hostname, subnetstr); - forward_request(c, request); + forward_request(c); return true; } @@ -135,14 +135,12 @@ bool add_subnet_h(connection_t *c, const char *request) { /* Tell the rest */ - if(!tunnelserver) { - forward_request(c, request); - } + forward_request(c); /* Fast handoff of roaming MAC addresses */ if(s.type == SUBNET_MAC && owner != myself && (old = lookup_subnet(myself, &s)) && old->expires) { - old->expires = 1; + old->expires = now; } return true; @@ -158,14 +156,14 @@ bool send_del_subnet(connection_t *c, const subnet_t *s) { return send_request(c, "%d %x %s %s", DEL_SUBNET, rand(), s->owner->name, netstr); } -bool del_subnet_h(connection_t *c, const char *request) { +bool del_subnet_h(connection_t *c) { char subnetstr[MAX_STRING_SIZE]; char name[MAX_STRING_SIZE]; node_t *owner; subnet_t s = {0}, *find; - if(sscanf(request, "%*d %*x " MAX_STRING " " MAX_STRING, name, subnetstr) != 2) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "DEL_SUBNET", c->name, + if(sscanf(c->buffer, "%*d %*x " MAX_STRING " " MAX_STRING, name, subnetstr) != 2) { + logger(LOG_ERR, "Got bad %s from %s (%s)", "DEL_SUBNET", c->name, c->hostname); return false; } @@ -173,7 +171,7 @@ bool del_subnet_h(connection_t *c, const char *request) { /* Check if owner name is valid */ if(!check_id(name)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "DEL_SUBNET", c->name, + logger(LOG_ERR, "Got bad %s from %s (%s): %s", "DEL_SUBNET", c->name, c->hostname, "invalid name"); return false; } @@ -181,12 +179,12 @@ bool del_subnet_h(connection_t *c, const char *request) { /* Check if subnet string is valid */ if(!str2net(&s, subnetstr)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "DEL_SUBNET", c->name, + logger(LOG_ERR, "Got bad %s from %s (%s): %s", "DEL_SUBNET", c->name, c->hostname, "invalid subnet string"); return false; } - if(seen_request(request)) { + if(seen_request(c->buffer)) { return true; } @@ -196,14 +194,14 @@ bool del_subnet_h(connection_t *c, const char *request) { if(tunnelserver && owner != myself && owner != c->node) { /* in case of tunnelserver, ignore indirect subnet deletion */ - logger(DEBUG_PROTOCOL, LOG_WARNING, "Ignoring indirect %s from %s (%s) for %s", - "DEL_SUBNET", c->name, c->hostname, subnetstr); + ifdebug(PROTOCOL) logger(LOG_WARNING, "Ignoring indirect %s from %s (%s) for %s", + "DEL_SUBNET", c->name, c->hostname, subnetstr); return true; } if(!owner) { - logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) for %s which is not in our node tree", - "DEL_SUBNET", c->name, c->hostname, name); + ifdebug(PROTOCOL) logger(LOG_WARNING, "Got %s from %s (%s) for %s which is not in our node tree", + "DEL_SUBNET", c->name, c->hostname, name); return true; } @@ -214,11 +212,11 @@ bool del_subnet_h(connection_t *c, const char *request) { find = lookup_subnet(owner, &s); if(!find) { - logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) for %s which does not appear in his subnet tree", - "DEL_SUBNET", c->name, c->hostname, name); + ifdebug(PROTOCOL) logger(LOG_WARNING, "Got %s from %s (%s) for %s which does not appear in his subnet tree", + "DEL_SUBNET", c->name, c->hostname, name); if(strictsubnets) { - forward_request(c, request); + forward_request(c); } return true; @@ -227,8 +225,8 @@ bool del_subnet_h(connection_t *c, const char *request) { /* If we are the owner of this subnet, retaliate with an ADD_SUBNET */ if(owner == myself) { - logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) for ourself", - "DEL_SUBNET", c->name, c->hostname); + ifdebug(PROTOCOL) logger(LOG_WARNING, "Got %s from %s (%s) for ourself", + "DEL_SUBNET", c->name, c->hostname); send_add_subnet(c, find); return true; } @@ -239,9 +237,7 @@ bool del_subnet_h(connection_t *c, const char *request) { /* Tell the rest */ - if(!tunnelserver) { - forward_request(c, request); - } + forward_request(c); if(strictsubnets) { return true; diff --git a/src/proxy.c b/src/proxy.c new file mode 100644 index 0000000..979626c --- /dev/null +++ b/src/proxy.c @@ -0,0 +1,366 @@ +/* + proxy.c -- Proxy handling functions. + Copyright (C) 2015-2017 Guus Sliepen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "system.h" + +#include "connection.h" +#include "logger.h" +#include "meta.h" +#include "netutl.h" +#include "protocol.h" +#include "proxy.h" +#include "utils.h" // + +proxytype_t proxytype; +char *proxyhost; +char *proxyport; +char *proxyuser; +char *proxypass; + +static void update_address_ipv4(connection_t *c, void *address, void *port) { + sockaddrfree(&c->address); + memset(&c->address, 0, sizeof(c->address)); + c->address.sa.sa_family = AF_INET; + + if(address) { + memcpy(&c->address.in.sin_addr, address, sizeof(ipv4_t)); + } + + if(port) { + memcpy(&c->address.in.sin_port, port, sizeof(uint16_t)); + } + + // OpenSSH -D returns all zero address, set it to 0.0.0.1 to prevent spamming ourselves. + if(!memcmp(&c->address.in.sin_addr, "\0\0\0\0", 4)) { + memcpy(&c->address.in.sin_addr, "\0\0\0\01", 4); + } +} + +static void update_address_ipv6(connection_t *c, void *address, void *port) { + sockaddrfree(&c->address); + memset(&c->address, 0, sizeof(c->address)); + c->address.sa.sa_family = AF_INET6; + + if(address) { + memcpy(&c->address.in6.sin6_addr, address, sizeof(ipv6_t)); + } + + if(port) { + memcpy(&c->address.in6.sin6_port, port, sizeof(uint16_t)); + } + + // OpenSSH -D returns all zero address, set it to 0100:: to prevent spamming ourselves. + if(!memcmp(&c->address.in6.sin6_addr, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16)) { + memcpy(&c->address.in6.sin6_addr, "\01\0\0\0\0\0\0\0", 8); + } +} + +bool send_proxyrequest(connection_t *c) { + switch(proxytype) { + case PROXY_SOCKS4: + if(c->address.sa.sa_family != AF_INET) { + logger(LOG_ERR, "Can only connect to numeric IPv4 addresses through a SOCKS 4 proxy!"); + return false; + } + + // fallthrough + case PROXY_SOCKS4A: { + if(c->address.sa.sa_family != AF_INET && c->address.sa.sa_family != AF_UNKNOWN) { + logger(LOG_ERR, "Can only connect to IPv4 addresses or hostnames through a SOCKS 4a proxy!"); + return false; + } + + int len = 9; + + if(proxyuser) { + len += strlen(proxyuser); + } + + if(c->address.sa.sa_family == AF_UNKNOWN) { + len += 1 + strlen(c->address.unknown.address); + } + + char s4req[len]; + s4req[0] = 4; + s4req[1] = 1; + + if(c->address.sa.sa_family == AF_INET) { + memcpy(s4req + 2, &c->address.in.sin_port, 2); + memcpy(s4req + 4, &c->address.in.sin_addr, 4); + } else { + uint16_t port = htons(atoi(c->address.unknown.port)); + memcpy(s4req + 2, &port, 2); + memcpy(s4req + 4, "\0\0\0\1", 4); + strcpy(s4req + (9 + (proxyuser ? strlen(proxyuser) : 0)), c->address.unknown.address); + } + + if(proxyuser) { + strcpy(s4req + 8, proxyuser); + } else { + s4req[8] = 0; + } + + s4req[sizeof(s4req) - 1] = 0; + c->allow_request = PROXY; + return send_meta(c, s4req, sizeof(s4req)); + } + + case PROXY_SOCKS5: { + int len = 3 + 6; + + if(c->address.sa.sa_family == AF_INET) { + len += 4; + } else if(c->address.sa.sa_family == AF_INET6) { + len += 16; + } else if(c->address.sa.sa_family == AF_UNKNOWN) { + len += 1 + strlen(c->address.unknown.address); + } else { + logger(LOG_ERR, "Address family %x not supported for SOCKS 5 proxies!", c->address.sa.sa_family); + return false; + } + + if(proxypass) { + len += 3 + strlen(proxyuser) + strlen(proxypass); + } + + char s5req[len]; + int i = 0; + s5req[i++] = 5; + s5req[i++] = 1; + + if(proxypass) { + s5req[i++] = 2; + s5req[i++] = 1; + s5req[i++] = strlen(proxyuser); + strcpy(s5req + i, proxyuser); + i += strlen(proxyuser); + s5req[i++] = strlen(proxypass); + strcpy(s5req + i, proxypass); + i += strlen(proxypass); + } else { + s5req[i++] = 0; + } + + s5req[i++] = 5; + s5req[i++] = 1; + s5req[i++] = 0; + + if(c->address.sa.sa_family == AF_INET) { + s5req[i++] = 1; + memcpy(s5req + i, &c->address.in.sin_addr, 4); + i += 4; + memcpy(s5req + i, &c->address.in.sin_port, 2); + i += 2; + } else if(c->address.sa.sa_family == AF_INET6) { + s5req[i++] = 4; + memcpy(s5req + i, &c->address.in6.sin6_addr, 16); + i += 16; + memcpy(s5req + i, &c->address.in6.sin6_port, 2); + i += 2; + } else if(c->address.sa.sa_family == AF_UNKNOWN) { + s5req[i++] = 3; + int len = strlen(c->address.unknown.address); + s5req[i++] = len; + memcpy(s5req + i, c->address.unknown.address, len); + i += len; + uint16_t port = htons(atoi(c->address.unknown.port)); + memcpy(s5req + i, &port, 2); + i += 2; + } else { + logger(LOG_ERR, "Unknown address family while trying to connect to SOCKS5 proxy"); + return false; + } + + if(i > len) { + abort(); + } + + c->allow_request = PROXY; + return send_meta(c, s5req, sizeof(s5req)); + } + + case PROXY_HTTP: { + char *host; + char *port; + + sockaddr2str(&c->address, &host, &port); + send_request(c, "CONNECT %s:%s HTTP/1.1\r\n\r", host, port); + free(host); + free(port); + c->allow_request = PROXY; + return true; + } + + case PROXY_EXEC: + abort(); + + default: + logger(LOG_ERR, "Unknown proxy type"); + return false; + } +} + +int receive_proxy_meta(connection_t *c) { + switch(proxytype) { + case PROXY_SOCKS4: + case PROXY_SOCKS4A: + if(c->buflen < 8) { + return 0; + } + + if(c->buffer[0] == 0 && c->buffer[1] == 0x5a) { + if(c->address.sa.sa_family == AF_UNKNOWN) { + update_address_ipv4(c, c->buffer + 4, c->buffer + 2); + } + + ifdebug(CONNECTIONS) logger(LOG_DEBUG, "Proxy request granted"); + c->allow_request = ID; + c->status.proxy_passed = true; + send_id(c); + return 8; + } else { + logger(LOG_ERR, "Proxy request rejected"); + return -1; + } + + case PROXY_SOCKS5: + if(c->buflen < 2) { + return 0; + } + + if(c->buffer[0] != 0x05 || c->buffer[1] == (char)0xff) { + logger(LOG_ERR, "Proxy authentication method rejected"); + return -1; + } + + int offset = 2; + + if(c->buffer[1] == 0x02) { + if(c->buflen < 4) { + return 0; + } + + if(c->buffer[2] != 0x05 || c->buffer[3] != 0x00) { + logger(LOG_ERR, "Proxy username/password rejected"); + return -1; + } + + offset += 2; + } + + if(c->buflen - offset < 7) { + return 0; + } + + if(c->buffer[offset] != 0x05 || c->buffer[offset + 1] != 0x00) { + logger(LOG_ERR, "Proxy request rejected"); + return -1; + } + + int replen = offset + 6; + + switch(c->buffer[offset + 3]) { + case 0x01: // IPv4 + if(c->address.sa.sa_family == AF_UNKNOWN) { + update_address_ipv4(c, c->buffer + offset + 4, c->buffer + offset + 8); + } + + replen += 4; + break; + + case 0x03: // Hostname + if(c->address.sa.sa_family == AF_UNKNOWN) { + update_address_ipv4(c, "\0\0\0\1", "\0\0"); + } + + replen += ((uint8_t *)c->buffer)[offset + 4]; + break; + + case 0x04: // IPv6 + if(c->address.sa.sa_family == AF_UNKNOWN) { + update_address_ipv6(c, c->buffer + offset + 4, c->buffer + offset + 20); + } + + replen += 16; + break; + + default: + logger(LOG_ERR, "Proxy reply malformed"); + return -1; + } + + if(c->buflen < replen) { + return 0; + } else { + ifdebug(CONNECTIONS) logger(LOG_DEBUG, "Proxy request granted"); + c->allow_request = ID; + c->status.proxy_passed = true; + send_id(c); + return replen; + } + + case PROXY_HTTP: { + char *p = memchr(c->buffer, '\n', c->buflen); + + if(!p || p - c->buffer >= c->buflen) { + return 0; + } + + while((p = memchr(p + 1, '\n', c->buflen - (p + 1 - c->buffer)))) { + if(p > c->buffer + 3 && !memcmp(p - 3, "\r\n\r\n", 4)) { + break; + } + } + + if(!p) { + return 0; + } + + if(c->buflen < 9) { + return 0; + } + + if(!strncasecmp(c->buffer, "HTTP/1.1 ", 9)) { + if(!strncmp(c->buffer + 9, "200", 3)) { + if(c->address.sa.sa_family == AF_UNKNOWN) { + update_address_ipv4(c, "\0\0\0\1", "\0\0"); + } + + logger(LOG_DEBUG, "Proxy request granted"); + replen = p + 1 - c->buffer; + c->allow_request = ID; + c->status.proxy_passed = true; + send_id(c); + return replen; + } else { + p = memchr(c->buffer, '\n', c->buflen); + p[-1] = 0; + logger(LOG_ERR, "Proxy request rejected: %s", c->buffer + 9); + return false; + } + } else { + logger(LOG_ERR, "Proxy reply malformed"); + return -1; + } + } + + default: + abort(); + } +} diff --git a/src/upnp.h b/src/proxy.h similarity index 62% rename from src/upnp.h rename to src/proxy.h index b611bc1..a96fc3d 100644 --- a/src/upnp.h +++ b/src/proxy.h @@ -1,8 +1,8 @@ -#ifndef TINC_UPNP_H -#define TINC_UPNP_H +#ifndef TINC_PROXY_H +#define TINC_PROXY_H /* - upnp.h -- UPnP-IGD client + proxy.h -- header for proxy.c Copyright (C) 2015 Guus Sliepen This program is free software; you can redistribute it and/or modify @@ -20,8 +20,24 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "system.h" +#include "connection.h" -extern void upnp_init(bool tcp, bool udp); +typedef enum proxytype_t { + PROXY_NONE = 0, + PROXY_SOCKS4, + PROXY_SOCKS4A, + PROXY_SOCKS5, + PROXY_HTTP, + PROXY_EXEC, +} proxytype_t; + +extern proxytype_t proxytype; +extern char *proxyhost; +extern char *proxyport; +extern char *proxyuser; +extern char *proxypass; + +extern bool send_proxyrequest(struct connection_t *c); +extern int receive_proxy_meta(struct connection_t *c); #endif diff --git a/src/raw_socket_device.c b/src/raw_socket_device.c index 02f6afa..f4ed694 100644 --- a/src/raw_socket_device.c +++ b/src/raw_socket_device.c @@ -1,7 +1,7 @@ /* device.c -- raw socket Copyright (C) 2002-2005 Ivo Timmermans, - 2002-2012 Guus Sliepen + 2002-2014 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -35,6 +35,9 @@ #if defined(PF_PACKET) && defined(ETH_P_ALL) && defined(AF_PACKET) && defined(SIOCGIFINDEX) static const char *device_info = "raw_socket"; +static uint64_t device_total_in = 0; +static uint64_t device_total_out = 0; + static bool setup_device(void) { struct ifreq ifr; struct sockaddr_ll sa; @@ -48,94 +51,99 @@ static bool setup_device(void) { } if((device_fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not open %s: %s", device_info, + logger(LOG_ERR, "Could not open %s: %s", device_info, strerror(errno)); return false; } - memset(&ifr, 0, sizeof(ifr)); - #ifdef FD_CLOEXEC fcntl(device_fd, F_SETFD, FD_CLOEXEC); #endif + memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_ifrn.ifrn_name, iface, IFNAMSIZ); ifr.ifr_ifrn.ifrn_name[IFNAMSIZ - 1] = 0; if(ioctl(device_fd, SIOCGIFINDEX, &ifr)) { close(device_fd); - logger(DEBUG_ALWAYS, LOG_ERR, "Can't find interface %s: %s", iface, - strerror(errno)); + logger(LOG_ERR, "Can't find interface %s: %s", ifr.ifr_ifrn.ifrn_name, strerror(errno)); return false; } - memset(&sa, '0', sizeof(sa)); + memset(&sa, 0, sizeof(sa)); sa.sll_family = AF_PACKET; sa.sll_protocol = htons(ETH_P_ALL); sa.sll_ifindex = ifr.ifr_ifindex; if(bind(device_fd, (struct sockaddr *) &sa, (socklen_t) sizeof(sa))) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not bind %s to %s: %s", device, iface, strerror(errno)); + logger(LOG_ERR, "Could not bind %s to %s: %s", device, ifr.ifr_ifrn.ifrn_name, strerror(errno)); return false; } - logger(DEBUG_ALWAYS, LOG_INFO, "%s is a %s", device, device_info); + logger(LOG_INFO, "%s is a %s", device, device_info); return true; } static void close_device(void) { close(device_fd); - device_fd = -1; free(device); - device = NULL; free(iface); - iface = NULL; - device_info = NULL; } static bool read_packet(vpn_packet_t *packet) { - int inlen; + int lenin; - if((inlen = read(device_fd, DATA(packet), MTU)) <= 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from %s %s: %s", device_info, + if((lenin = read(device_fd, packet->data, MTU)) <= 0) { + logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); return false; } - packet->len = inlen; + packet->len = lenin; - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, - device_info); + device_total_in += packet->len; + + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, + device_info); return true; } static bool write_packet(vpn_packet_t *packet) { - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Writing packet of %d bytes to %s", - packet->len, device_info); + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Writing packet of %d bytes to %s", + packet->len, device_info); - if(write(device_fd, DATA(packet), packet->len) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Can't write to %s %s: %s", device_info, device, + if(write(device_fd, packet->data, packet->len) < 0) { + logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, strerror(errno)); return false; } + device_total_out += packet->len; + return true; } +static void dump_device_stats(void) { + logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); + logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); + logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); +} + const devops_t raw_socket_devops = { .setup = setup_device, .close = close_device, .read = read_packet, .write = write_packet, + .dump_stats = dump_device_stats, }; #else static bool not_supported(void) { - logger(DEBUG_ALWAYS, LOG_ERR, "Raw socket device not supported on this platform"); + logger(LOG_ERR, "Raw socket device not supported on this platform"); return false; } @@ -144,5 +152,6 @@ const devops_t raw_socket_devops = { .close = NULL, .read = NULL, .write = NULL, + .dump_stats = NULL, }; #endif diff --git a/src/route.c b/src/route.c index dcc6f3c..f8b11bb 100644 --- a/src/route.c +++ b/src/route.c @@ -1,7 +1,8 @@ /* route.c -- routing Copyright (C) 2000-2005 Ivo Timmermans, - 2000-2013 Guus Sliepen + 2000-2017 Guus Sliepen + 2015-2016 Vittorio Gambaletta This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,13 +21,12 @@ #include "system.h" +#include "avl_tree.h" #include "connection.h" -#include "control_common.h" #include "ethernet.h" #include "ipv4.h" #include "ipv6.h" #include "logger.h" -#include "meta.h" #include "net.h" #include "protocol.h" #include "route.h" @@ -42,7 +42,6 @@ bool priorityinheritance = false; int macexpire = 600; bool overwrite_mac = false; mac_t mymac = {{0xFE, 0xFD, 0, 0, 0, 0}}; -bool pcap = false; /* Sizes of various headers */ @@ -59,9 +58,6 @@ static const size_t opt_size = sizeof(struct nd_opt_hdr); #define MAX(a, b) ((a) > (b) ? (a) : (b)) #endif -volatile int dummy; -static timeout_t age_subnets_timeout; - /* RFC 1071 */ static uint16_t inet_checksum(void *data, int len, uint16_t prevsum) { @@ -81,11 +77,6 @@ static uint16_t inet_checksum(void *data, int len, uint16_t prevsum) { checksum = (checksum & 0xFFFF) + (checksum >> 16); } - // Work around a compiler optimization bug. - if(checksum) { - dummy = 1; - } - return ~checksum; } @@ -93,12 +84,12 @@ static bool ratelimit(int frequency) { static time_t lasttime = 0; static int count = 0; - if(lasttime == now.tv_sec) { + if(lasttime == now) { if(count >= frequency) { return true; } } else { - lasttime = now.tv_sec; + lasttime = now; count = 0; } @@ -108,7 +99,7 @@ static bool ratelimit(int frequency) { static bool checklength(node_t *source, vpn_packet_t *packet, length_t length) { if(packet->len < length) { - logger(DEBUG_TRAFFIC, LOG_WARNING, "Got too short packet from %s (%s)", source->name, source->hostname); + ifdebug(TRAFFIC) logger(LOG_WARNING, "Got too short packet from %s (%s)", source->name, source->hostname); return false; } else { return true; @@ -117,9 +108,9 @@ static bool checklength(node_t *source, vpn_packet_t *packet, length_t length) { static void swap_mac_addresses(vpn_packet_t *packet) { mac_t tmp; - memcpy(&tmp, &DATA(packet)[0], sizeof(tmp)); - memcpy(&DATA(packet)[0], &DATA(packet)[6], sizeof(tmp)); - memcpy(&DATA(packet)[6], &tmp, sizeof(tmp)); + memcpy(&tmp, &packet->data[0], sizeof(tmp)); + memcpy(&packet->data[0], &packet->data[6], sizeof(tmp)); + memcpy(&packet->data[6], &tmp, sizeof(tmp)); } /* RFC 792 */ @@ -142,7 +133,7 @@ static void route_ipv4_unreachable(node_t *source, vpn_packet_t *packet, length_ /* Copy headers from packet into properly aligned structs on the stack */ - memcpy(&ip, DATA(packet) + ether_size, ip_size); + memcpy(&ip, packet->data + ether_size, ip_size); /* Remember original source and destination */ @@ -186,7 +177,7 @@ static void route_ipv4_unreachable(node_t *source, vpn_packet_t *packet, length_ /* Copy first part of original contents to ICMP message */ - memmove(DATA(packet) + ether_size + ip_size + icmp_size, DATA(packet) + ether_size, oldlen); + memmove(packet->data + ether_size + ip_size + icmp_size, packet->data + ether_size, oldlen); /* Fill in IPv4 header */ @@ -211,12 +202,12 @@ static void route_ipv4_unreachable(node_t *source, vpn_packet_t *packet, length_ icmp.icmp_cksum = 0; icmp.icmp_cksum = inet_checksum(&icmp, icmp_size, ~0); - icmp.icmp_cksum = inet_checksum(DATA(packet) + ether_size + ip_size + icmp_size, oldlen, icmp.icmp_cksum); + icmp.icmp_cksum = inet_checksum(packet->data + ether_size + ip_size + icmp_size, oldlen, icmp.icmp_cksum); /* Copy structs on stack back to packet */ - memcpy(DATA(packet) + ether_size, &ip, ip_size); - memcpy(DATA(packet) + ether_size + ip_size, &icmp, icmp_size); + memcpy(packet->data + ether_size, &ip, ip_size); + memcpy(packet->data + ether_size + ip_size, &icmp, icmp_size); packet->len = ether_size + ip_size + icmp_size + oldlen; @@ -247,7 +238,7 @@ static void route_ipv6_unreachable(node_t *source, vpn_packet_t *packet, length_ /* Copy headers from packet to structs on the stack */ - memcpy(&ip6, DATA(packet) + ether_size, ip6_size); + memcpy(&ip6, packet->data + ether_size, ip6_size); /* Remember original source and destination */ @@ -291,7 +282,7 @@ static void route_ipv6_unreachable(node_t *source, vpn_packet_t *packet, length_ /* Copy first part of original contents to ICMP message */ - memmove(DATA(packet) + ether_size + ip6_size + icmp6_size, DATA(packet) + ether_size, pseudo.length); + memmove(packet->data + ether_size + ip6_size + icmp6_size, packet->data + ether_size, pseudo.length); /* Fill in IPv6 header */ @@ -317,14 +308,14 @@ static void route_ipv6_unreachable(node_t *source, vpn_packet_t *packet, length_ checksum = inet_checksum(&pseudo, sizeof(pseudo), ~0); checksum = inet_checksum(&icmp6, icmp6_size, checksum); - checksum = inet_checksum(DATA(packet) + ether_size + ip6_size + icmp6_size, ntohl(pseudo.length) - icmp6_size, checksum); + checksum = inet_checksum(packet->data + ether_size + ip6_size + icmp6_size, ntohl(pseudo.length) - icmp6_size, checksum); icmp6.icmp6_cksum = checksum; /* Copy structs on stack back to packet */ - memcpy(DATA(packet) + ether_size, &ip6, ip6_size); - memcpy(DATA(packet) + ether_size + ip6_size, &icmp6, icmp6_size); + memcpy(packet->data + ether_size, &ip6, ip6_size); + memcpy(packet->data + ether_size + ip6_size, &icmp6, icmp6_size); packet->len = ether_size + ip6_size + ntohl(pseudo.length); @@ -332,11 +323,11 @@ static void route_ipv6_unreachable(node_t *source, vpn_packet_t *packet, length_ } static bool do_decrement_ttl(node_t *source, vpn_packet_t *packet) { - uint16_t type = DATA(packet)[12] << 8 | DATA(packet)[13]; + uint16_t type = packet->data[12] << 8 | packet->data[13]; length_t ethlen = ether_size; if(type == ETH_P_8021Q) { - type = DATA(packet)[16] << 8 | DATA(packet)[17]; + type = packet->data[16] << 8 | packet->data[17]; ethlen += 4; } @@ -346,27 +337,27 @@ static bool do_decrement_ttl(node_t *source, vpn_packet_t *packet) { return false; } - if(DATA(packet)[ethlen + 8] <= 1) { - if(DATA(packet)[ethlen + 11] != IPPROTO_ICMP || DATA(packet)[ethlen + 32] != ICMP_TIME_EXCEEDED) { + if(packet->data[ethlen + 8] <= 1) { + if(packet->data[ethlen + 11] != IPPROTO_ICMP || packet->data[ethlen + 32] != ICMP_TIME_EXCEEDED) { route_ipv4_unreachable(source, packet, ethlen, ICMP_TIME_EXCEEDED, ICMP_EXC_TTL); } return false; } - uint16_t old = DATA(packet)[ethlen + 8] << 8 | DATA(packet)[ethlen + 9]; - DATA(packet)[ethlen + 8]--; - uint16_t new = DATA(packet)[ethlen + 8] << 8 | DATA(packet)[ethlen + 9]; + uint16_t old = packet->data[ethlen + 8] << 8 | packet->data[ethlen + 9]; + packet->data[ethlen + 8]--; + uint16_t new = packet->data[ethlen + 8] << 8 | packet->data[ethlen + 9]; - uint32_t checksum = DATA(packet)[ethlen + 10] << 8 | DATA(packet)[ethlen + 11]; + uint32_t checksum = packet->data[ethlen + 10] << 8 | packet->data[ethlen + 11]; checksum += old + (~new & 0xFFFF); while(checksum >> 16) { checksum = (checksum & 0xFFFF) + (checksum >> 16); } - DATA(packet)[ethlen + 10] = checksum >> 8; - DATA(packet)[ethlen + 11] = checksum & 0xff; + packet->data[ethlen + 10] = checksum >> 8; + packet->data[ethlen + 11] = checksum & 0xff; return true; @@ -375,15 +366,15 @@ static bool do_decrement_ttl(node_t *source, vpn_packet_t *packet) { return false; } - if(DATA(packet)[ethlen + 7] <= 1) { - if(DATA(packet)[ethlen + 6] != IPPROTO_ICMPV6 || DATA(packet)[ethlen + 40] != ICMP6_TIME_EXCEEDED) { + if(packet->data[ethlen + 7] <= 1) { + if(packet->data[ethlen + 6] != IPPROTO_ICMPV6 || packet->data[ethlen + 40] != ICMP6_TIME_EXCEEDED) { route_ipv6_unreachable(source, packet, ethlen, ICMP6_TIME_EXCEEDED, ICMP6_TIME_EXCEED_TRANSIT); } return false; } - DATA(packet)[ethlen + 7]--; + packet->data[ethlen + 7]--; return true; @@ -405,25 +396,16 @@ static void clamp_mss(const node_t *source, const node_t *via, vpn_packet_t *pac /* Find TCP header */ int start = ether_size; - uint16_t type = DATA(packet)[12] << 8 | DATA(packet)[13]; + uint16_t type = packet->data[12] << 8 | packet->data[13]; if(type == ETH_P_8021Q) { start += 4; - type = DATA(packet)[16] << 8 | DATA(packet)[17]; + type = packet->data[16] << 8 | packet->data[17]; } - /* IP in IP (RFC 2003) packet */ - if(type == ETH_P_IP && DATA(packet)[start + 9] == 4) { - start += 20; - } - - if(packet->len <= start + 20) { - return; - } - - if(type == ETH_P_IP && DATA(packet)[start + 9] == 6) { - start += (DATA(packet)[start] & 0xf) * 4; - } else if(type == ETH_P_IPV6 && DATA(packet)[start + 6] == 6) { + if(type == ETH_P_IP && packet->data[start + 9] == 6) { + start += (packet->data[start] & 0xf) * 4; + } else if(type == ETH_P_IPV6 && packet->data[start + 6] == 6) { start += 40; } else { return; @@ -434,7 +416,7 @@ static void clamp_mss(const node_t *source, const node_t *via, vpn_packet_t *pac } /* Use data offset field to calculate length of options field */ - int len = ((DATA(packet)[start + 12] >> 4) - 5) * 4; + int len = ((packet->data[start + 12] >> 4) - 5) * 4; if(packet->len < start + 20 + len) { return; @@ -442,104 +424,75 @@ static void clamp_mss(const node_t *source, const node_t *via, vpn_packet_t *pac /* Search for MSS option header */ for(int i = 0; i < len;) { - if(DATA(packet)[start + 20 + i] == 0) { + if(packet->data[start + 20 + i] == 0) { break; } - if(DATA(packet)[start + 20 + i] == 1) { + if(packet->data[start + 20 + i] == 1) { i++; continue; } - if(i > len - 2 || i > len - DATA(packet)[start + 21 + i]) { + if(i > len - 2 || i > len - packet->data[start + 21 + i]) { break; } - if(DATA(packet)[start + 20 + i] != 2) { - if(DATA(packet)[start + 21 + i] < 2) { + if(packet->data[start + 20 + i] != 2) { + if(packet->data[start + 21 + i] < 2) { break; } - i += DATA(packet)[start + 21 + i]; + i += packet->data[start + 21 + i]; continue; } - if(DATA(packet)[start + 21] != 4) { + if(packet->data[start + 21] != 4) { break; } /* Found it */ - uint16_t oldmss = DATA(packet)[start + 22 + i] << 8 | DATA(packet)[start + 23 + i]; + uint16_t oldmss = packet->data[start + 22 + i] << 8 | packet->data[start + 23 + i]; uint16_t newmss = mtu - start - 20; - uint32_t csum = DATA(packet)[start + 16] << 8 | DATA(packet)[start + 17]; + uint32_t csum = packet->data[start + 16] << 8 | packet->data[start + 17]; if(oldmss <= newmss) { break; } - logger(DEBUG_TRAFFIC, LOG_INFO, "Clamping MSS of packet from %s to %s to %d", source->name, via->name, newmss); + ifdebug(TRAFFIC) logger(LOG_INFO, "Clamping MSS of packet from %s to %s to %d", source->name, via->name, newmss); /* Update the MSS value and the checksum */ - DATA(packet)[start + 22 + i] = newmss >> 8; - DATA(packet)[start + 23 + i] = newmss & 0xff; + packet->data[start + 22 + i] = newmss >> 8; + packet->data[start + 23 + i] = newmss & 0xff; csum ^= 0xffff; csum += oldmss ^ 0xffff; csum += newmss; csum = (csum & 0xffff) + (csum >> 16); csum += csum >> 16; csum ^= 0xffff; - DATA(packet)[start + 16] = csum >> 8; - DATA(packet)[start + 17] = csum; + packet->data[start + 16] = csum >> 8; + packet->data[start + 17] = csum; break; } } -static void age_subnets(void *data) { - (void)data; - bool left = false; - - for splay_each(subnet_t, s, myself->subnet_tree) { - if(s->expires && s->expires < now.tv_sec) { - if(debug_level >= DEBUG_TRAFFIC) { - char netstr[MAXNETSTR]; - - if(net2str(netstr, sizeof(netstr), s)) { - logger(DEBUG_TRAFFIC, LOG_INFO, "Subnet %s expired", netstr); - } - } - - for list_each(connection_t, c, connection_list) - if(c->edge) { - send_del_subnet(c, s); - } - - subnet_del(myself, s); - } else { - if(s->expires) { - left = true; - } - } - } - - if(left) - timeout_set(&age_subnets_timeout, &(struct timeval) { - 10, rand() % 100000 - }); -} - static void learn_mac(mac_t *address) { - subnet_t *subnet = lookup_subnet_mac(myself, address); + subnet_t *subnet; + avl_node_t *node; + connection_t *c; + + subnet = lookup_subnet_mac(myself, address); /* If we don't know this MAC address yet, store it */ if(!subnet) { - logger(DEBUG_TRAFFIC, LOG_INFO, "Learned new MAC address %x:%x:%x:%x:%x:%x", - address->x[0], address->x[1], address->x[2], address->x[3], - address->x[4], address->x[5]); + ifdebug(TRAFFIC) logger(LOG_INFO, "Learned new MAC address %x:%x:%x:%x:%x:%x", + address->x[0], address->x[1], address->x[2], address->x[3], + address->x[4], address->x[5]); subnet = new_subnet(); subnet->type = SUBNET_MAC; - subnet->expires = now.tv_sec + macexpire; + subnet->expires = now + macexpire; subnet->net.mac.address = *address; subnet->weight = 10; subnet_add(myself, subnet); @@ -547,17 +500,48 @@ static void learn_mac(mac_t *address) { /* And tell all other tinc daemons it's our MAC */ - for list_each(connection_t, c, connection_list) - if(c->edge) { + for(node = connection_tree->head; node; node = node->next) { + c = node->data; + + if(c->status.active) { send_add_subnet(c, subnet); } + } + } - timeout_add(&age_subnets_timeout, age_subnets, NULL, &(struct timeval) { - 10, rand() % 100000 - }); - } else { - if(subnet->expires) { - subnet->expires = now.tv_sec + macexpire; + if(subnet->expires) { + subnet->expires = now + macexpire; + } +} + +void age_subnets(void) { + subnet_t *s; + connection_t *c; + avl_node_t *node, *next, *node2; + + for(node = myself->subnet_tree->head; node; node = next) { + next = node->next; + s = node->data; + + if(s->expires && s->expires <= now) { + ifdebug(TRAFFIC) { + char netstr[MAXNETSTR]; + + if(net2str(netstr, sizeof(netstr), s)) { + logger(LOG_INFO, "Subnet %s expired", netstr); + } + } + + for(node2 = connection_tree->head; node2; node2 = node2->next) { + c = node2->data; + + if(c->status.active) { + send_del_subnet(c, s); + } + } + + subnet_update(myself, s, false); + subnet_del(myself, s); } } } @@ -576,13 +560,12 @@ static void route_broadcast(node_t *source, vpn_packet_t *packet) { static void fragment_ipv4_packet(node_t *dest, vpn_packet_t *packet, length_t ether_size) { struct ip ip; vpn_packet_t fragment; - int maxlen, todo; + int len, maxlen, todo; uint8_t *offset; uint16_t ip_off, origf; - memcpy(&ip, DATA(packet) + ether_size, ip_size); + memcpy(&ip, packet->data + ether_size, ip_size); fragment.priority = packet->priority; - fragment.offset = DEFAULT_PACKET_OFFSET; if(ip.ip_hl != ip_size / 4) { return; @@ -591,21 +574,21 @@ static void fragment_ipv4_packet(node_t *dest, vpn_packet_t *packet, length_t et todo = ntohs(ip.ip_len) - ip_size; if(ether_size + ip_size + todo != packet->len) { - logger(DEBUG_TRAFFIC, LOG_WARNING, "Length of packet (%d) doesn't match length in IPv4 header (%d)", packet->len, (int)(ether_size + ip_size + todo)); + ifdebug(TRAFFIC) logger(LOG_WARNING, "Length of packet (%d) doesn't match length in IPv4 header (%d)", packet->len, (int)(ether_size + ip_size + todo)); return; } - logger(DEBUG_TRAFFIC, LOG_INFO, "Fragmenting packet of %d bytes to %s (%s)", packet->len, dest->name, dest->hostname); + ifdebug(TRAFFIC) logger(LOG_INFO, "Fragmenting packet of %d bytes to %s (%s)", packet->len, dest->name, dest->hostname); - offset = DATA(packet) + ether_size + ip_size; - maxlen = (dest->mtu - ether_size - ip_size) & ~0x7; + offset = packet->data + ether_size + ip_size; + maxlen = (MAX(dest->mtu, 590) - ether_size - ip_size) & ~0x7; ip_off = ntohs(ip.ip_off); origf = ip_off & ~IP_OFFMASK; ip_off &= IP_OFFMASK; while(todo) { - int len = todo > maxlen ? maxlen : todo; - memcpy(DATA(&fragment) + ether_size + ip_size, offset, len); + len = todo > maxlen ? maxlen : todo; + memcpy(fragment.data + ether_size + ip_size, offset, len); todo -= len; offset += len; @@ -613,8 +596,8 @@ static void fragment_ipv4_packet(node_t *dest, vpn_packet_t *packet, length_t et ip.ip_off = htons(ip_off | origf | (todo ? IP_MF : 0)); ip.ip_sum = 0; ip.ip_sum = inet_checksum(&ip, ip_size, ~0); - memcpy(DATA(&fragment), DATA(packet), ether_size); - memcpy(DATA(&fragment) + ether_size, &ip, ip_size); + memcpy(fragment.data, packet->data, ether_size); + memcpy(fragment.data + ether_size, &ip, ip_size); fragment.len = ether_size + ip_size + len; send_packet(dest, &fragment); @@ -623,37 +606,28 @@ static void fragment_ipv4_packet(node_t *dest, vpn_packet_t *packet, length_t et } } -static void route_ipv4(node_t *source, vpn_packet_t *packet) { - if(!checklength(source, packet, ether_size + ip_size)) { - return; - } - +static void route_ipv4_unicast(node_t *source, vpn_packet_t *packet) { subnet_t *subnet; node_t *via; ipv4_t dest; - memcpy(&dest, &DATA(packet)[30], sizeof(dest)); + memcpy(&dest, &packet->data[30], sizeof(dest)); subnet = lookup_subnet_ipv4(&dest); if(!subnet) { - logger(DEBUG_TRAFFIC, LOG_WARNING, "Cannot route packet from %s (%s): unknown IPv4 destination address %d.%d.%d.%d", - source->name, source->hostname, - dest.x[0], - dest.x[1], - dest.x[2], - dest.x[3]); + ifdebug(TRAFFIC) logger(LOG_WARNING, "Cannot route packet from %s (%s): unknown IPv4 destination address %d.%d.%d.%d", + source->name, source->hostname, + dest.x[0], + dest.x[1], + dest.x[2], + dest.x[3]); route_ipv4_unreachable(source, packet, ether_size, ICMP_DEST_UNREACH, ICMP_NET_UNKNOWN); return; } - if(!subnet->owner) { - route_broadcast(source, packet); - return; - } - if(subnet->owner == source) { - logger(DEBUG_TRAFFIC, LOG_WARNING, "Packet looping back to %s (%s)!", source->name, source->hostname); + ifdebug(TRAFFIC) logger(LOG_WARNING, "Packet looping back to %s (%s)!", source->name, source->hostname); return; } @@ -673,13 +647,13 @@ static void route_ipv4(node_t *source, vpn_packet_t *packet) { } if(priorityinheritance) { - packet->priority = DATA(packet)[15]; + packet->priority = packet->data[15]; } via = (subnet->owner->via == myself) ? subnet->owner->nexthop : subnet->owner->via; if(via == source) { - logger(DEBUG_TRAFFIC, LOG_ERR, "Routing loop for packet from %s (%s)!", source->name, source->hostname); + ifdebug(TRAFFIC) logger(LOG_ERR, "Routing loop for packet from %s (%s)!", source->name, source->hostname); return; } @@ -689,9 +663,9 @@ static void route_ipv4(node_t *source, vpn_packet_t *packet) { } if(via && packet->len > MAX(via->mtu, 590) && via != myself) { - logger(DEBUG_TRAFFIC, LOG_INFO, "Packet for %s (%s) length %d larger than MTU %d", subnet->owner->name, subnet->owner->hostname, packet->len, via->mtu); + ifdebug(TRAFFIC) logger(LOG_INFO, "Packet for %s (%s) length %d larger than MTU %d", subnet->owner->name, subnet->owner->hostname, packet->len, via->mtu); - if(DATA(packet)[20] & 0x40) { + if(packet->data[20] & 0x40) { packet->len = MAX(via->mtu, 590); route_ipv4_unreachable(source, packet, ether_size, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED); } else { @@ -706,48 +680,48 @@ static void route_ipv4(node_t *source, vpn_packet_t *packet) { send_packet(subnet->owner, packet); } -static void route_neighborsol(node_t *source, vpn_packet_t *packet); - -static void route_ipv6(node_t *source, vpn_packet_t *packet) { - if(!checklength(source, packet, ether_size + ip6_size)) { +static void route_ipv4(node_t *source, vpn_packet_t *packet) { + if(!checklength(source, packet, ether_size + ip_size)) { return; } - if(DATA(packet)[20] == IPPROTO_ICMPV6 && checklength(source, packet, ether_size + ip6_size + icmp6_size) && DATA(packet)[54] == ND_NEIGHBOR_SOLICIT) { - route_neighborsol(source, packet); - return; + if(broadcast_mode && (((packet->data[30] & 0xf0) == 0xe0) || ( + packet->data[30] == 255 && + packet->data[31] == 255 && + packet->data[32] == 255 && + packet->data[33] == 255))) { + route_broadcast(source, packet); + } else { + route_ipv4_unicast(source, packet); } +} +static void route_ipv6_unicast(node_t *source, vpn_packet_t *packet) { subnet_t *subnet; node_t *via; ipv6_t dest; - memcpy(&dest, &DATA(packet)[38], sizeof(dest)); + memcpy(&dest, &packet->data[38], sizeof(dest)); subnet = lookup_subnet_ipv6(&dest); if(!subnet) { - logger(DEBUG_TRAFFIC, LOG_WARNING, "Cannot route packet from %s (%s): unknown IPv6 destination address %hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx", - source->name, source->hostname, - ntohs(dest.x[0]), - ntohs(dest.x[1]), - ntohs(dest.x[2]), - ntohs(dest.x[3]), - ntohs(dest.x[4]), - ntohs(dest.x[5]), - ntohs(dest.x[6]), - ntohs(dest.x[7])); + ifdebug(TRAFFIC) logger(LOG_WARNING, "Cannot route packet from %s (%s): unknown IPv6 destination address %hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx", + source->name, source->hostname, + ntohs(dest.x[0]), + ntohs(dest.x[1]), + ntohs(dest.x[2]), + ntohs(dest.x[3]), + ntohs(dest.x[4]), + ntohs(dest.x[5]), + ntohs(dest.x[6]), + ntohs(dest.x[7])); route_ipv6_unreachable(source, packet, ether_size, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADDR); return; } - if(!subnet->owner) { - route_broadcast(source, packet); - return; - } - if(subnet->owner == source) { - logger(DEBUG_TRAFFIC, LOG_WARNING, "Packet looping back to %s (%s)!", source->name, source->hostname); + ifdebug(TRAFFIC) logger(LOG_WARNING, "Packet looping back to %s (%s)!", source->name, source->hostname); return; } @@ -761,19 +735,20 @@ static void route_ipv6(node_t *source, vpn_packet_t *packet) { return; } - if(decrement_ttl && source != myself && subnet->owner != myself) + if(decrement_ttl && source != myself && subnet->owner != myself) { if(!do_decrement_ttl(source, packet)) { return; } + } if(priorityinheritance) { - packet->priority = ((DATA(packet)[14] & 0x0f) << 4) | (DATA(packet)[15] >> 4); + packet->priority = ((packet->data[14] & 0x0f) << 4) | (packet->data[15] >> 4); } via = (subnet->owner->via == myself) ? subnet->owner->nexthop : subnet->owner->via; if(via == source) { - logger(DEBUG_TRAFFIC, LOG_ERR, "Routing loop for packet from %s (%s)!", source->name, source->hostname); + ifdebug(TRAFFIC) logger(LOG_ERR, "Routing loop for packet from %s (%s)!", source->name, source->hostname); return; } @@ -783,7 +758,7 @@ static void route_ipv6(node_t *source, vpn_packet_t *packet) { } if(via && packet->len > MAX(via->mtu, 1294) && via != myself) { - logger(DEBUG_TRAFFIC, LOG_INFO, "Packet for %s (%s) length %d larger than MTU %d", subnet->owner->name, subnet->owner->hostname, packet->len, via->mtu); + ifdebug(TRAFFIC) logger(LOG_INFO, "Packet for %s (%s) length %d larger than MTU %d", subnet->owner->name, subnet->owner->hostname, packet->len, via->mtu); packet->len = MAX(via->mtu, 1294); route_ipv6_unreachable(source, packet, ether_size, ICMP6_PACKET_TOO_BIG, 0); return; @@ -805,8 +780,8 @@ static void route_neighborsol(node_t *source, vpn_packet_t *packet) { bool has_opt; struct { - struct in6_addr ip6_src; - struct in6_addr ip6_dst; + struct in6_addr ip6_src; /* source address */ + struct in6_addr ip6_dst; /* destination address */ uint32_t length; uint32_t next; } pseudo; @@ -818,30 +793,30 @@ static void route_neighborsol(node_t *source, vpn_packet_t *packet) { has_opt = packet->len >= ether_size + ip6_size + ns_size + opt_size + ETH_ALEN; if(source != myself) { - logger(DEBUG_TRAFFIC, LOG_WARNING, "Got neighbor solicitation request from %s (%s) while in router mode!", source->name, source->hostname); + ifdebug(TRAFFIC) logger(LOG_WARNING, "Got neighbor solicitation request from %s (%s) while in router mode!", source->name, source->hostname); return; } /* Copy headers from packet to structs on the stack */ - memcpy(&ip6, DATA(packet) + ether_size, ip6_size); - memcpy(&ns, DATA(packet) + ether_size + ip6_size, ns_size); + memcpy(&ip6, packet->data + ether_size, ip6_size); + memcpy(&ns, packet->data + ether_size + ip6_size, ns_size); if(has_opt) { - memcpy(&opt, DATA(packet) + ether_size + ip6_size + ns_size, opt_size); + memcpy(&opt, packet->data + ether_size + ip6_size + ns_size, opt_size); } /* First, snatch the source address from the neighbor solicitation packet */ if(overwrite_mac) { - memcpy(mymac.x, DATA(packet) + ETH_ALEN, ETH_ALEN); + memcpy(mymac.x, packet->data + ETH_ALEN, ETH_ALEN); } /* Check if this is a valid neighbor solicitation request */ if(ns.nd_ns_hdr.icmp6_type != ND_NEIGHBOR_SOLICIT || (has_opt && opt.nd_opt_type != ND_OPT_SOURCE_LINKADDR)) { - logger(DEBUG_TRAFFIC, LOG_WARNING, "Cannot route packet: received unknown type neighbor solicitation request"); + ifdebug(TRAFFIC) logger(LOG_WARNING, "Cannot route packet: received unknown type neighbor solicitation request"); return; } @@ -865,11 +840,11 @@ static void route_neighborsol(node_t *source, vpn_packet_t *packet) { if(has_opt) { checksum = inet_checksum(&opt, opt_size, checksum); - checksum = inet_checksum(DATA(packet) + ether_size + ip6_size + ns_size + opt_size, ETH_ALEN, checksum); + checksum = inet_checksum(packet->data + ether_size + ip6_size + ns_size + opt_size, ETH_ALEN, checksum); } if(checksum) { - logger(DEBUG_TRAFFIC, LOG_WARNING, "Cannot route packet: checksum error for neighbor solicitation request"); + ifdebug(TRAFFIC) logger(LOG_WARNING, "Cannot route packet: checksum error for neighbor solicitation request"); return; } @@ -878,15 +853,15 @@ static void route_neighborsol(node_t *source, vpn_packet_t *packet) { subnet = lookup_subnet_ipv6((ipv6_t *) &ns.nd_ns_target); if(!subnet) { - logger(DEBUG_TRAFFIC, LOG_WARNING, "Cannot route packet: neighbor solicitation request for unknown address %hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx", - ntohs(((uint16_t *) &ns.nd_ns_target)[0]), - ntohs(((uint16_t *) &ns.nd_ns_target)[1]), - ntohs(((uint16_t *) &ns.nd_ns_target)[2]), - ntohs(((uint16_t *) &ns.nd_ns_target)[3]), - ntohs(((uint16_t *) &ns.nd_ns_target)[4]), - ntohs(((uint16_t *) &ns.nd_ns_target)[5]), - ntohs(((uint16_t *) &ns.nd_ns_target)[6]), - ntohs(((uint16_t *) &ns.nd_ns_target)[7])); + ifdebug(TRAFFIC) logger(LOG_WARNING, "Cannot route packet: neighbor solicitation request for unknown address %hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx", + ntohs(((uint16_t *) &ns.nd_ns_target)[0]), + ntohs(((uint16_t *) &ns.nd_ns_target)[1]), + ntohs(((uint16_t *) &ns.nd_ns_target)[2]), + ntohs(((uint16_t *) &ns.nd_ns_target)[3]), + ntohs(((uint16_t *) &ns.nd_ns_target)[4]), + ntohs(((uint16_t *) &ns.nd_ns_target)[5]), + ntohs(((uint16_t *) &ns.nd_ns_target)[6]), + ntohs(((uint16_t *) &ns.nd_ns_target)[7])); return; } @@ -904,19 +879,19 @@ static void route_neighborsol(node_t *source, vpn_packet_t *packet) { /* Create neighbor advertation reply */ - memcpy(DATA(packet), DATA(packet) + ETH_ALEN, ETH_ALEN); /* copy destination address */ - DATA(packet)[ETH_ALEN * 2 - 1] ^= 0xFF; /* mangle source address so it looks like it's not from us */ + memcpy(packet->data, packet->data + ETH_ALEN, ETH_ALEN); /* copy destination address */ + packet->data[ETH_ALEN * 2 - 1] ^= 0xFF; /* mangle source address so it looks like it's not from us */ - ip6.ip6_dst = ip6.ip6_src; /* swap destination and source protocol address */ + ip6.ip6_dst = ip6.ip6_src; /* swap destination and source protocol address */ ip6.ip6_src = ns.nd_ns_target; if(has_opt) { - memcpy(DATA(packet) + ether_size + ip6_size + ns_size + opt_size, DATA(packet) + ETH_ALEN, ETH_ALEN); /* add fake source hard addr */ + memcpy(packet->data + ether_size + ip6_size + ns_size + opt_size, packet->data + ETH_ALEN, ETH_ALEN); /* add fake source hard addr */ } ns.nd_ns_cksum = 0; ns.nd_ns_type = ND_NEIGHBOR_ADVERT; - ns.nd_ns_reserved = htonl(0x40000000UL); /* Set solicited flag */ + ns.nd_ns_reserved = htonl(0x40000000UL); /* Set solicited flag */ opt.nd_opt_type = ND_OPT_TARGET_LINKADDR; /* Create pseudo header */ @@ -939,23 +914,40 @@ static void route_neighborsol(node_t *source, vpn_packet_t *packet) { if(has_opt) { checksum = inet_checksum(&opt, opt_size, checksum); - checksum = inet_checksum(DATA(packet) + ether_size + ip6_size + ns_size + opt_size, ETH_ALEN, checksum); + checksum = inet_checksum(packet->data + ether_size + ip6_size + ns_size + opt_size, ETH_ALEN, checksum); } ns.nd_ns_hdr.icmp6_cksum = checksum; /* Copy structs on stack back to packet */ - memcpy(DATA(packet) + ether_size, &ip6, ip6_size); - memcpy(DATA(packet) + ether_size + ip6_size, &ns, ns_size); + memcpy(packet->data + ether_size, &ip6, ip6_size); + memcpy(packet->data + ether_size + ip6_size, &ns, ns_size); if(has_opt) { - memcpy(DATA(packet) + ether_size + ip6_size + ns_size, &opt, opt_size); + memcpy(packet->data + ether_size + ip6_size + ns_size, &opt, opt_size); } send_packet(source, packet); } +static void route_ipv6(node_t *source, vpn_packet_t *packet) { + if(!checklength(source, packet, ether_size + ip6_size)) { + return; + } + + if(packet->data[20] == IPPROTO_ICMPV6 && checklength(source, packet, ether_size + ip6_size + icmp6_size) && packet->data[54] == ND_NEIGHBOR_SOLICIT) { + route_neighborsol(source, packet); + return; + } + + if(broadcast_mode && packet->data[38] == 255) { + route_broadcast(source, packet); + } else { + route_ipv6_unicast(source, packet); + } +} + /* RFC 826 */ static void route_arp(node_t *source, vpn_packet_t *packet) { @@ -968,25 +960,25 @@ static void route_arp(node_t *source, vpn_packet_t *packet) { } if(source != myself) { - logger(DEBUG_TRAFFIC, LOG_WARNING, "Got ARP request from %s (%s) while in router mode!", source->name, source->hostname); + ifdebug(TRAFFIC) logger(LOG_WARNING, "Got ARP request from %s (%s) while in router mode!", source->name, source->hostname); return; } /* First, snatch the source address from the ARP packet */ if(overwrite_mac) { - memcpy(mymac.x, DATA(packet) + ETH_ALEN, ETH_ALEN); + memcpy(mymac.x, packet->data + ETH_ALEN, ETH_ALEN); } /* Copy headers from packet to structs on the stack */ - memcpy(&arp, DATA(packet) + ether_size, arp_size); + memcpy(&arp, packet->data + ether_size, arp_size); /* Check if this is a valid ARP request */ if(ntohs(arp.arp_hrd) != ARPHRD_ETHER || ntohs(arp.arp_pro) != ETH_P_IP || arp.arp_hln != ETH_ALEN || arp.arp_pln != sizeof(addr) || ntohs(arp.arp_op) != ARPOP_REQUEST) { - logger(DEBUG_TRAFFIC, LOG_WARNING, "Cannot route packet: received unknown type ARP request"); + ifdebug(TRAFFIC) logger(LOG_WARNING, "Cannot route packet: received unknown type ARP request"); return; } @@ -995,9 +987,9 @@ static void route_arp(node_t *source, vpn_packet_t *packet) { subnet = lookup_subnet_ipv4((ipv4_t *) &arp.arp_tpa); if(!subnet) { - logger(DEBUG_TRAFFIC, LOG_WARNING, "Cannot route packet: ARP request for unknown address %d.%d.%d.%d", - arp.arp_tpa[0], arp.arp_tpa[1], arp.arp_tpa[2], - arp.arp_tpa[3]); + ifdebug(TRAFFIC) logger(LOG_WARNING, "Cannot route packet: ARP request for unknown address %d.%d.%d.%d", + arp.arp_tpa[0], arp.arp_tpa[1], arp.arp_tpa[2], + arp.arp_tpa[3]); return; } @@ -1012,18 +1004,20 @@ static void route_arp(node_t *source, vpn_packet_t *packet) { return; } - memcpy(&addr, arp.arp_tpa, sizeof(addr)); /* save protocol addr */ - memcpy(arp.arp_tpa, arp.arp_spa, sizeof(addr)); /* swap destination and source protocol address */ - memcpy(arp.arp_spa, &addr, sizeof(addr)); /* ... */ + memcpy(packet->data, packet->data + ETH_ALEN, ETH_ALEN); /* copy destination address */ + packet->data[ETH_ALEN * 2 - 1] ^= 0xFF; /* mangle source address so it looks like it's not from us */ - memcpy(arp.arp_tha, arp.arp_sha, ETH_ALEN); /* set target hard/proto addr */ - memcpy(arp.arp_sha, DATA(packet) + ETH_ALEN, ETH_ALEN); /* set source hard/proto addr */ - arp.arp_sha[ETH_ALEN - 1] ^= 0xFF; /* for consistency with route_packet() */ + memcpy(&addr, arp.arp_tpa, sizeof(addr)); /* save protocol addr */ + memcpy(arp.arp_tpa, arp.arp_spa, sizeof(addr)); /* swap destination and source protocol address */ + memcpy(arp.arp_spa, &addr, sizeof(addr)); /* ... */ + + memcpy(arp.arp_tha, arp.arp_sha, ETH_ALEN); /* set target hard/proto addr */ + memcpy(arp.arp_sha, packet->data + ETH_ALEN, ETH_ALEN); /* add fake source hard addr */ arp.arp_op = htons(ARPOP_REPLY); /* Copy structs on stack back to packet */ - memcpy(DATA(packet) + ether_size, &arp, arp_size); + memcpy(packet->data + ether_size, &arp, arp_size); send_packet(source, packet); } @@ -1036,22 +1030,22 @@ static void route_mac(node_t *source, vpn_packet_t *packet) { if(source == myself) { mac_t src; - memcpy(&src, &DATA(packet)[6], sizeof(src)); + memcpy(&src, &packet->data[6], sizeof(src)); learn_mac(&src); } /* Lookup destination address */ - memcpy(&dest, &DATA(packet)[0], sizeof(dest)); + memcpy(&dest, &packet->data[0], sizeof(dest)); subnet = lookup_subnet_mac(NULL, &dest); - if(!subnet || !subnet->owner) { + if(!subnet) { route_broadcast(source, packet); return; } if(subnet->owner == source) { - logger(DEBUG_TRAFFIC, LOG_WARNING, "Packet looping back to %s (%s)!", source->name, source->hostname); + ifdebug(TRAFFIC) logger(LOG_WARNING, "Packet looping back to %s (%s)!", source->name, source->hostname); return; } @@ -1064,13 +1058,13 @@ static void route_mac(node_t *source, vpn_packet_t *packet) { return; } - uint16_t type = DATA(packet)[12] << 8 | DATA(packet)[13]; + uint16_t type = packet->data[12] << 8 | packet->data[13]; if(priorityinheritance) { if(type == ETH_P_IP && packet->len >= ether_size + ip_size) { - packet->priority = DATA(packet)[15]; + packet->priority = packet->data[15]; } else if(type == ETH_P_IPV6 && packet->len >= ether_size + ip6_size) { - packet->priority = ((DATA(packet)[14] & 0x0f) << 4) | (DATA(packet)[15] >> 4); + packet->priority = ((packet->data[14] & 0x0f) << 4) | (packet->data[15] >> 4); } } @@ -1083,16 +1077,16 @@ static void route_mac(node_t *source, vpn_packet_t *packet) { } if(via && packet->len > via->mtu && via != myself) { - logger(DEBUG_TRAFFIC, LOG_INFO, "Packet for %s (%s) length %d larger than MTU %d", subnet->owner->name, subnet->owner->hostname, packet->len, via->mtu); + ifdebug(TRAFFIC) logger(LOG_INFO, "Packet for %s (%s) length %d larger than MTU %d", subnet->owner->name, subnet->owner->hostname, packet->len, via->mtu); length_t ethlen = 14; if(type == ETH_P_8021Q) { - type = DATA(packet)[16] << 8 | DATA(packet)[17]; + type = packet->data[16] << 8 | packet->data[17]; ethlen += 4; } if(type == ETH_P_IP && packet->len > 576 + ethlen) { - if(DATA(packet)[6 + ethlen] & 0x40) { + if(packet->data[6 + ethlen] & 0x40) { packet->len = via->mtu; route_ipv4_unreachable(source, packet, ethlen, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED); } else { @@ -1112,32 +1106,7 @@ static void route_mac(node_t *source, vpn_packet_t *packet) { send_packet(subnet->owner, packet); } -static void send_pcap(vpn_packet_t *packet) { - pcap = false; - - for list_each(connection_t, c, connection_list) { - if(!c->status.pcap) { - continue; - } - - pcap = true; - int len = packet->len; - - if(c->outmaclength && c->outmaclength < len) { - len = c->outmaclength; - } - - if(send_request(c, "%d %d %d", CONTROL, REQ_PCAP, len)) { - send_meta(c, (char *)DATA(packet), len); - } - } -} - void route(node_t *source, vpn_packet_t *packet) { - if(pcap) { - send_pcap(packet); - } - if(forwarding_mode == FMODE_KERNEL && source != myself) { send_packet(myself, packet); return; @@ -1147,10 +1116,10 @@ void route(node_t *source, vpn_packet_t *packet) { return; } - uint16_t type = DATA(packet)[12] << 8 | DATA(packet)[13]; - switch(routing_mode) { - case RMODE_ROUTER: + case RMODE_ROUTER: { + uint16_t type = packet->data[12] << 8 | packet->data[13]; + switch(type) { case ETH_P_ARP: route_arp(source, packet); @@ -1165,11 +1134,11 @@ void route(node_t *source, vpn_packet_t *packet) { break; default: - logger(DEBUG_TRAFFIC, LOG_WARNING, "Cannot route packet from %s (%s): unknown type %hx", source->name, source->hostname, type); + ifdebug(TRAFFIC) logger(LOG_WARNING, "Cannot route packet from %s (%s): unknown type %hx", source->name, source->hostname, type); break; } - - break; + } + break; case RMODE_SWITCH: route_mac(source, packet); diff --git a/src/route.h b/src/route.h index 095448a..5b9e808 100644 --- a/src/route.h +++ b/src/route.h @@ -50,10 +50,10 @@ extern bool directonly; extern bool overwrite_mac; extern bool priorityinheritance; extern int macexpire; -extern bool pcap; extern mac_t mymac; +extern void age_subnets(void); extern void route(struct node_t *source, struct vpn_packet_t *packet); #endif diff --git a/src/rsa.h b/src/rsa.h deleted file mode 100644 index a31ec24..0000000 --- a/src/rsa.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef TINC_RSA_H -#define TINC_RSA_H - -/* - rsa.h -- RSA key handling - Copyright (C) 2007-2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#ifndef TINC_RSA_INTERNAL -typedef struct rsa rsa_t; -#endif - -extern void rsa_free(rsa_t *rsa); -extern rsa_t *rsa_set_hex_public_key(char *n, char *e) __attribute__((__malloc__)); -extern rsa_t *rsa_set_hex_private_key(char *n, char *e, char *d) __attribute__((__malloc__)); -extern rsa_t *rsa_read_pem_public_key(FILE *fp) __attribute__((__malloc__)); -extern rsa_t *rsa_read_pem_private_key(FILE *fp) __attribute__((__malloc__)); -extern size_t rsa_size(rsa_t *rsa); -extern bool rsa_public_encrypt(rsa_t *rsa, void *in, size_t len, void *out) __attribute__((__warn_unused_result__)); -extern bool rsa_private_decrypt(rsa_t *rsa, void *in, size_t len, void *out) __attribute__((__warn_unused_result__)); - -#endif diff --git a/src/rsagen.h b/src/rsagen.h deleted file mode 100644 index a661607..0000000 --- a/src/rsagen.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef TINC_RSAGEN_H -#define TINC_RSAGEN_H - -/* - rsagen.h -- RSA key generation and export - Copyright (C) 2008-2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "rsa.h" - -extern rsa_t *rsa_generate(size_t bits, unsigned long exponent) __attribute__((__malloc__)); -extern bool rsa_write_pem_public_key(rsa_t *rsa, FILE *fp) __attribute__((__warn_unused_result__)); -extern bool rsa_write_pem_private_key(rsa_t *rsa, FILE *fp) __attribute__((__warn_unused_result__)); - -#endif diff --git a/src/script.c b/src/script.c deleted file mode 100644 index 81216a3..0000000 --- a/src/script.c +++ /dev/null @@ -1,232 +0,0 @@ -/* - script.c -- call an external script - Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2017 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include "conf.h" -#include "device.h" -#include "logger.h" -#include "names.h" -#include "script.h" -#include "xalloc.h" - -#ifdef HAVE_PUTENV -static void unputenv(const char *p) { - const char *e = strchr(p, '='); - - if(!e) { - return; - } - - int len = e - p; -#ifndef HAVE_UNSETENV -#ifdef HAVE_MINGW - // Windows requires putenv("FOO=") to unset %FOO% - len++; -#endif -#endif - char var[len + 1]; - strncpy(var, p, len); - var[len] = 0; -#ifdef HAVE_UNSETENV - unsetenv(var); -#else - // We must keep what we putenv() around in memory. - // To do this without memory leaks, keep things in a list and reuse if possible. - static list_t list = {}; - - for list_each(char, data, &list) { - if(!strcmp(data, var)) { - putenv(data); - return; - } - } - - char *data = xstrdup(var); - list_insert_tail(&list, data); - putenv(data); -#endif -} -#else -static void putenv(const char *p) {} -static void unputenv(const char *p) {} -#endif - -static const int min_env_size = 10; - -int environment_add(environment_t *env, const char *format, ...) { - if(env->n >= env->size) { - env->size = env->n ? env->n * 2 : min_env_size; - env->entries = xrealloc(env->entries, env->size * sizeof(*env->entries)); - } - - if(format) { - va_list ap; - va_start(ap, format); - vasprintf(&env->entries[env->n], format, ap); - va_end(ap); - } else { - env->entries[env->n] = NULL; - } - - return env->n++; -} - -void environment_update(environment_t *env, int pos, const char *format, ...) { - free(env->entries[pos]); - va_list ap; - va_start(ap, format); - vasprintf(&env->entries[pos], format, ap); - va_end(ap); -} - -void environment_init(environment_t *env) { - env->n = 0; - env->size = min_env_size; - env->entries = xzalloc(env->size * sizeof(*env->entries)); - - if(netname) { - environment_add(env, "NETNAME=%s", netname); - } - - if(myname) { - environment_add(env, "NAME=%s", myname); - } - - if(device) { - environment_add(env, "DEVICE=%s", device); - } - - if(iface) { - environment_add(env, "INTERFACE=%s", iface); - } - - if(debug_level >= 0) { - environment_add(env, "DEBUG=%d", debug_level); - } -} - -void environment_exit(environment_t *env) { - for(int i = 0; i < env->n; i++) { - free(env->entries[i]); - } - - free(env->entries); -} - -bool execute_script(const char *name, environment_t *env) { - char scriptname[PATH_MAX]; - char *command; - - snprintf(scriptname, sizeof(scriptname), "%s" SLASH "%s%s", confbase, name, scriptextension); - - /* First check if there is a script */ - -#ifdef HAVE_MINGW - - if(!*scriptextension) { - const char *pathext = getenv("PATHEXT") ? : ".COM;.EXE;.BAT;.CMD"; - size_t pathlen = strlen(pathext); - size_t scriptlen = strlen(scriptname); - char fullname[scriptlen + pathlen + 1]; - char *ext = fullname + scriptlen; - strncpy(fullname, scriptname, sizeof(fullname)); - - const char *p = pathext; - bool found = false; - - while(p && *p) { - const char *q = strchr(p, ';'); - - if(q) { - memcpy(ext, p, q - p); - ext[q - p] = 0; - q++; - } else { - strncpy(ext, p, pathlen + 1); - } - - if((found = !access(fullname, F_OK))) { - break; - } - - p = q; - } - - if(!found) { - return true; - } - } else -#endif - - if(access(scriptname, F_OK)) { - return true; - } - - logger(DEBUG_STATUS, LOG_INFO, "Executing script %s", name); - - /* Set environment */ - - for(int i = 0; i < env->n; i++) { - putenv(env->entries[i]); - } - - if(scriptinterpreter) { - xasprintf(&command, "%s \"%s\"", scriptinterpreter, scriptname); - } else { - xasprintf(&command, "\"%s\"", scriptname); - } - - int status = system(command); - - free(command); - - /* Unset environment */ - - for(int i = 0; i < env->n; i++) { - unputenv(env->entries[i]); - } - - if(status != -1) { -#ifdef WEXITSTATUS - - if(WIFEXITED(status)) { /* Child exited by itself */ - if(WEXITSTATUS(status)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Script %s exited with non-zero status %d", - name, WEXITSTATUS(status)); - return false; - } - } else if(WIFSIGNALED(status)) { /* Child was killed by a signal */ - logger(DEBUG_ALWAYS, LOG_ERR, "Script %s was killed by signal %d (%s)", - name, WTERMSIG(status), strsignal(WTERMSIG(status))); - return false; - } else { /* Something strange happened */ - logger(DEBUG_ALWAYS, LOG_ERR, "Script %s terminated abnormally", name); - return false; - } - -#endif - } else { - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "system", strerror(errno)); - return false; - } - - return true; -} diff --git a/src/script.h b/src/script.h deleted file mode 100644 index 5172034..0000000 --- a/src/script.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef TINC_SCRIPT_H -#define TINC_SCRIPT_H - -/* - script.h -- header file for script.c - Copyright (C) 1999-2005 Ivo Timmermans, - 2000-2017 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -typedef struct environment { - int n; - int size; - char **entries; -} environment_t; - -extern int environment_add(environment_t *env, const char *format, ...); -extern int environment_placeholder(environment_t *env); -extern void environment_update(environment_t *env, int pos, const char *format, ...); -extern void environment_init(environment_t *env); -extern void environment_exit(environment_t *env); - -extern bool execute_script(const char *name, environment_t *env); - -#endif diff --git a/src/solaris/device.c b/src/solaris/device.c index f27954b..fa2e6e6 100644 --- a/src/solaris/device.c +++ b/src/solaris/device.c @@ -2,7 +2,7 @@ device.c -- Interaction with Solaris tun device Copyright (C) 2001-2005 Ivo Timmermans, 2002-2010 OpenVPN Technologies, Inc. - 2001-2014 Guus Sliepen + 2001-2017 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,7 +29,6 @@ #include "../conf.h" #include "../device.h" #include "../logger.h" -#include "../names.h" #include "../net.h" #include "../route.h" #include "../utils.h" @@ -50,11 +49,15 @@ static enum { } device_type = DEVICE_TYPE_TUN; int device_fd = -1; +static int if_fd = -1; static int ip_fd = -1; char *device = NULL; char *iface = NULL; static const char *device_info = NULL; +uint64_t device_total_in = 0; +uint64_t device_total_out = 0; + static bool setup_device(void) { char *type; @@ -72,7 +75,7 @@ static bool setup_device(void) { else if(!strcasecmp(type, "tap")) { device_type = DEVICE_TYPE_TAP; } else { - logger(DEBUG_ALWAYS, LOG_ERR, "Unknown device type %s!", type); + logger(LOG_ERR, "Unknown device type %s!", type); return false; } } else { @@ -87,15 +90,19 @@ static bool setup_device(void) { device_info = "Solaris tap device"; } + if(device_type == DEVICE_TYPE_TAP && routing_mode == RMODE_ROUTER) { + overwrite_mac = true; + } + /* The following is black magic copied from OpenVPN. */ if((ip_fd = open(IP_DEVICE, O_RDWR, 0)) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not open %s: %s\n", IP_DEVICE, strerror(errno)); + logger(LOG_ERR, "Could not open %s: %s\n", IP_DEVICE, strerror(errno)); return false; } if((device_fd = open(device, O_RDWR, 0)) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not open %s: %s\n", device, strerror(errno)); + logger(LOG_ERR, "Could not open %s: %s\n", device, strerror(errno)); return false; } @@ -134,25 +141,23 @@ static bool setup_device(void) { } if(!found) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not find free PPA for %s %s!", device_info, device); + logger(LOG_ERR, "Could not find free PPA for %s %s!", device_info, device); return false; } } else { /* try this particular one */ if((ppa = ioctl(device_fd, I_STR, &strioc_ppa)) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not assign PPA %d for %s %s!", ppa, device_info, device); + logger(LOG_ERR, "Could not assign PPA %d for %s %s!", ppa, device_info, device); return false; } } - int if_fd; - if((if_fd = open(device, O_RDWR, 0)) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not open %s: %s\n", device, strerror(errno)); + logger(LOG_ERR, "Could not open %s: %s\n", device, strerror(errno)); return false; } if(ioctl(if_fd, I_PUSH, "ip") < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not push IP module onto %s %s!", device_info, device); + logger(LOG_ERR, "Could not push IP module onto %s %s!", device_info, device); return false; } @@ -174,7 +179,7 @@ static bool setup_device(void) { if(device_type == DEVICE_TYPE_TUN) { /* Assign ppa according to the unit number returned by tun device */ if(ioctl(if_fd, IF_UNITSEL, (char *)&ppa) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not set PPA %d on %s %s!", ppa, device_info, device); + logger(LOG_ERR, "Could not set PPA %d on %s %s!", ppa, device_info, device); return false; } } @@ -185,7 +190,7 @@ static bool setup_device(void) { struct lifreq ifr = {}; if(ioctl(if_fd, SIOCGLIFFLAGS, &ifr) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not set flags on %s %s!", device_info, device); + logger(LOG_ERR, "Could not set flags on %s %s!", device_info, device); return false; } @@ -194,18 +199,18 @@ static bool setup_device(void) { /* Assign ppa according to the unit number returned by tun device */ if(ioctl(if_fd, SIOCSLIFNAME, &ifr) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not set PPA %d on %s %s!", ppa, device_info, device); + logger(LOG_ERR, "Could not set PPA %d on %s %s!", ppa, device_info, device); return false; } if(ioctl(if_fd, SIOCGLIFFLAGS, &ifr) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not set flags on %s %s!", device_info, device); + logger(LOG_ERR, "Could not set flags on %s %s!", device_info, device); return false; } /* Push arp module to if_fd */ if(ioctl(if_fd, I_PUSH, "arp") < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not push ARP module onto %s %s!", device_info, device); + logger(LOG_ERR, "Could not push ARP module onto %s %s!", device_info, device); return false; } @@ -218,19 +223,19 @@ static bool setup_device(void) { /* Push arp module to ip_fd */ if(ioctl(ip_fd, I_PUSH, "arp") < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not push ARP module onto %s!", IP_DEVICE); + logger(LOG_ERR, "Could not push ARP module onto %s!", IP_DEVICE); return false; } /* Open arp_fd */ if((arp_fd = open(device, O_RDWR, 0)) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not open %s: %s\n", device, strerror(errno)); + logger(LOG_ERR, "Could not open %s: %s\n", device, strerror(errno)); return false; } /* Push arp module to arp_fd */ if(ioctl(arp_fd, I_PUSH, "arp") < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not push ARP module onto %s %s!", device_info, device); + logger(LOG_ERR, "Could not push ARP module onto %s %s!", device_info, device); return false; } @@ -242,7 +247,7 @@ static bool setup_device(void) { }; if(ioctl(arp_fd, I_STR, &strioc_if) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not set ifname to %s %s", device_info, device); + logger(LOG_ERR, "Could not set ifname to %s %s", device_info, device); return false; } } @@ -250,13 +255,13 @@ static bool setup_device(void) { int ip_muxid, arp_muxid; if((ip_muxid = ioctl(ip_fd, I_PLINK, if_fd)) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not link %s %s to IP", device_info, device); + logger(LOG_ERR, "Could not link %s %s to IP", device_info, device); return false; } if(device_type == DEVICE_TYPE_TAP) { if((arp_muxid = ioctl(ip_fd, I_PLINK, arp_fd)) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not link %s %s to ARP", device_info, device); + logger(LOG_ERR, "Could not link %s %s to ARP", device_info, device); return false; } @@ -279,7 +284,7 @@ static bool setup_device(void) { } ioctl(ip_fd, I_PUNLINK, ip_muxid); - logger(DEBUG_ALWAYS, LOG_ERR, "Could not set multiplexor id for %s %s", device_info, device); + logger(LOG_ERR, "Could not set multiplexor id for %s %s", device_info, device); return false; } @@ -290,7 +295,7 @@ static bool setup_device(void) { fcntl(ip_fd, F_SETFD, FD_CLOEXEC); #endif - logger(DEBUG_ALWAYS, LOG_INFO, "%s is a %s", device, device_info); + logger(LOG_INFO, "%s is a %s", device, device_info); return true; } @@ -309,14 +314,10 @@ static void close_device(void) { } close(ip_fd); - ip_fd = -1; close(device_fd); - device_fd = -1; free(device); - device = NULL; free(iface); - iface = NULL; } static bool read_packet(vpn_packet_t *packet) { @@ -327,36 +328,36 @@ static bool read_packet(vpn_packet_t *packet) { switch(device_type) { case DEVICE_TYPE_TUN: sbuf.maxlen = MTU - 14; - sbuf.buf = (char *)DATA(packet) + 14; + sbuf.buf = (char *)packet->data + 14; if((result = getmsg(device_fd, NULL, &sbuf, &f)) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); + logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); return false; } - switch(DATA(packet)[14] >> 4) { + switch(packet->data[14] >> 4) { case 4: - DATA(packet)[12] = 0x08; - DATA(packet)[13] = 0x00; + packet->data[12] = 0x08; + packet->data[13] = 0x00; break; case 6: - DATA(packet)[12] = 0x86; - DATA(packet)[13] = 0xDD; + packet->data[12] = 0x86; + packet->data[13] = 0xDD; break; default: - logger(DEBUG_TRAFFIC, LOG_ERR, "Unknown IP version %d while reading packet from %s %s", DATA(packet)[14] >> 4, device_info, device); + ifdebug(TRAFFIC) logger(LOG_ERR, "Unknown IP version %d while reading packet from %s %s", packet->data[14] >> 4, device_info, device); return false; } - memset(DATA(packet), 0, 12); + memset(packet->data, 0, 12); packet->len = sbuf.len + 14; break; case DEVICE_TYPE_TAP: sbuf.maxlen = MTU; - sbuf.buf = (char *)DATA(packet); + sbuf.buf = (char *)packet->data; if((result = getmsg(device_fd, NULL, &sbuf, &f)) < 0) { logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); @@ -370,20 +371,22 @@ static bool read_packet(vpn_packet_t *packet) { abort(); } - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, device_info); + device_total_in += packet->len; + + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, device_info); return true; } static bool write_packet(vpn_packet_t *packet) { - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Writing packet of %d bytes to %s", packet->len, device_info); + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Writing packet of %d bytes to %s", packet->len, device_info); struct strbuf sbuf; switch(device_type) { case DEVICE_TYPE_TUN: sbuf.len = packet->len - 14; - sbuf.buf = (char *)DATA(packet) + 14; + sbuf.buf = (char *)packet->data + 14; if(putmsg(device_fd, NULL, &sbuf, 0) < 0) { logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, strerror(errno)); @@ -394,7 +397,7 @@ static bool write_packet(vpn_packet_t *packet) { case DEVICE_TYPE_TAP: sbuf.len = packet->len; - sbuf.buf = (char *)DATA(packet); + sbuf.buf = (char *)packet->data; if(putmsg(device_fd, NULL, &sbuf, 0) < 0) { logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, strerror(errno)); @@ -407,12 +410,21 @@ static bool write_packet(vpn_packet_t *packet) { abort(); } + device_total_out += packet->len; + return true; } +static void dump_device_stats(void) { + logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); + logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); + logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); +} + const devops_t os_devops = { .setup = setup_device, .close = close_device, .read = read_packet, .write = write_packet, + .dump_stats = dump_device_stats, }; diff --git a/src/splay_tree.c b/src/splay_tree.c deleted file mode 100644 index 4d97373..0000000 --- a/src/splay_tree.c +++ /dev/null @@ -1,630 +0,0 @@ -/* - splay_tree.c -- splay tree and linked list convenience - Copyright (C) 2004-2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include "splay_tree.h" -#include "xalloc.h" - -/* Splay operation */ - -static splay_node_t *splay_top_down(splay_tree_t *tree, const void *data, int *result) { - splay_node_t left = {0}, right = {0}; - splay_node_t *leftbottom = &left, *rightbottom = &right, *child, *grandchild; - splay_node_t *root = tree->root; - int c; - - if(!root) { - if(result) { - *result = 0; - } - - return NULL; - } - - while((c = tree->compare(data, root->data))) { - if(c < 0 && (child = root->left)) { - c = tree->compare(data, child->data); - - if(c < 0 && (grandchild = child->left)) { - rightbottom->left = child; - child->parent = rightbottom; - rightbottom = child; - - if((root->left = child->right)) { - child->right->parent = root; - } - - child->right = root; - root->parent = child; - - child->left = NULL; - grandchild->parent = NULL; - - root = grandchild; - } else if(c > 0 && (grandchild = child->right)) { - leftbottom->right = child; - child->parent = leftbottom; - leftbottom = child; - - child->right = NULL; - grandchild->parent = NULL; - - rightbottom->left = root; - root->parent = rightbottom; - rightbottom = root; - - root->left = NULL; - - root = grandchild; - } else { - rightbottom->left = root; - root->parent = rightbottom; - rightbottom = root; - - root->left = NULL; - child->parent = NULL; - - root = child; - break; - } - } else if(c > 0 && (child = root->right)) { - c = tree->compare(data, child->data); - - if(c > 0 && (grandchild = child->right)) { - leftbottom->right = child; - child->parent = leftbottom; - leftbottom = child; - - if((root->right = child->left)) { - child->left->parent = root; - } - - child->left = root; - root->parent = child; - - child->right = NULL; - grandchild->parent = NULL; - - root = grandchild; - } else if(c < 0 && (grandchild = child->left)) { - rightbottom->left = child; - child->parent = rightbottom; - rightbottom = child; - - child->left = NULL; - grandchild->parent = NULL; - - leftbottom->right = root; - root->parent = leftbottom; - leftbottom = root; - - root->right = NULL; - - root = grandchild; - } else { - leftbottom->right = root; - root->parent = leftbottom; - leftbottom = root; - - root->right = NULL; - child->parent = NULL; - - root = child; - break; - } - } else { - break; - } - } - - /* Merge trees */ - - if(left.right) { - if(root->left) { - leftbottom->right = root->left; - root->left->parent = leftbottom; - } - - root->left = left.right; - left.right->parent = root; - } - - if(right.left) { - if(root->right) { - rightbottom->left = root->right; - root->right->parent = rightbottom; - } - - root->right = right.left; - right.left->parent = root; - } - - /* Return result */ - - tree->root = root; - - if(result) { - *result = c; - } - - return tree->root; -} - -static void splay_bottom_up(splay_tree_t *tree, splay_node_t *node) { - splay_node_t *parent, *grandparent, *greatgrandparent; - - while((parent = node->parent)) { - if(!(grandparent = parent->parent)) { /* zig */ - if(node == parent->left) { - if((parent->left = node->right)) { - parent->left->parent = parent; - } - - node->right = parent; - } else { - if((parent->right = node->left)) { - parent->right->parent = parent; - } - - node->left = parent; - } - - parent->parent = node; - node->parent = NULL; - } else { - greatgrandparent = grandparent->parent; - - if(node == parent->left && parent == grandparent->left) { /* left zig-zig */ - if((grandparent->left = parent->right)) { - grandparent->left->parent = grandparent; - } - - parent->right = grandparent; - grandparent->parent = parent; - - if((parent->left = node->right)) { - parent->left->parent = parent; - } - - node->right = parent; - parent->parent = node; - } else if(node == parent->right && parent == grandparent->right) { /* right zig-zig */ - if((grandparent->right = parent->left)) { - grandparent->right->parent = grandparent; - } - - parent->left = grandparent; - grandparent->parent = parent; - - if((parent->right = node->left)) { - parent->right->parent = parent; - } - - node->left = parent; - parent->parent = node; - } else if(node == parent->right && parent == grandparent->left) { /* left-right zig-zag */ - if((parent->right = node->left)) { - parent->right->parent = parent; - } - - node->left = parent; - parent->parent = node; - - if((grandparent->left = node->right)) { - grandparent->left->parent = grandparent; - } - - node->right = grandparent; - grandparent->parent = node; - } else { /* right-left zig-zag */ - if((parent->left = node->right)) { - parent->left->parent = parent; - } - - node->right = parent; - parent->parent = node; - - if((grandparent->right = node->left)) { - grandparent->right->parent = grandparent; - } - - node->left = grandparent; - grandparent->parent = node; - } - - if((node->parent = greatgrandparent)) { - if(grandparent == greatgrandparent->left) { - greatgrandparent->left = node; - } else { - greatgrandparent->right = node; - } - } - } - } - - tree->root = node; -} - -/* (De)constructors */ - -splay_tree_t *splay_alloc_tree(splay_compare_t compare, splay_action_t delete) { - splay_tree_t *tree; - - tree = xzalloc(sizeof(splay_tree_t)); - tree->compare = compare; - tree->delete = delete; - - return tree; -} - -void splay_free_tree(splay_tree_t *tree) { - free(tree); -} - -splay_node_t *splay_alloc_node(void) { - return xzalloc(sizeof(splay_node_t)); -} - -void splay_free_node(splay_tree_t *tree, splay_node_t *node) { - if(node->data && tree->delete) { - tree->delete(node->data); - } - - free(node); -} - -/* Searching */ - -void *splay_search(splay_tree_t *tree, const void *data) { - splay_node_t *node; - - node = splay_search_node(tree, data); - - return node ? node->data : NULL; -} - -void *splay_search_closest(splay_tree_t *tree, const void *data, int *result) { - splay_node_t *node; - - node = splay_search_closest_node(tree, data, result); - - return node ? node->data : NULL; -} - -void *splay_search_closest_smaller(splay_tree_t *tree, const void *data) { - splay_node_t *node; - - node = splay_search_closest_smaller_node(tree, data); - - return node ? node->data : NULL; -} - -void *splay_search_closest_greater(splay_tree_t *tree, const void *data) { - splay_node_t *node; - - node = splay_search_closest_greater_node(tree, data); - - return node ? node->data : NULL; -} - -splay_node_t *splay_search_node(splay_tree_t *tree, const void *data) { - splay_node_t *node; - int result; - - node = splay_search_closest_node(tree, data, &result); - - return result ? NULL : node; -} - -splay_node_t *splay_search_closest_node_nosplay(const splay_tree_t *tree, const void *data, int *result) { - splay_node_t *node; - int c; - - node = tree->root; - - if(!node) { - if(result) { - *result = 0; - } - - return NULL; - } - - for(;;) { - c = tree->compare(data, node->data); - - if(c < 0) { - if(node->left) { - node = node->left; - } else { - break; - } - } else if(c > 0) { - if(node->right) { - node = node->right; - } else { - break; - } - } else { - break; - } - } - - if(result) { - *result = c; - } - - return node; -} - -splay_node_t *splay_search_closest_node(splay_tree_t *tree, const void *data, int *result) { - return splay_top_down(tree, data, result); -} - -splay_node_t *splay_search_closest_smaller_node(splay_tree_t *tree, const void *data) { - splay_node_t *node; - int result; - - node = splay_search_closest_node(tree, data, &result); - - if(result < 0) { - node = node->prev; - } - - return node; -} - -splay_node_t *splay_search_closest_greater_node(splay_tree_t *tree, const void *data) { - splay_node_t *node; - int result; - - node = splay_search_closest_node(tree, data, &result); - - if(result > 0) { - node = node->next; - } - - return node; -} - -/* Insertion and deletion */ - -splay_node_t *splay_insert(splay_tree_t *tree, void *data) { - splay_node_t *closest, *new; - int result; - - if(!tree->root) { - new = splay_alloc_node(); - new->data = data; - splay_insert_top(tree, new); - } else { - closest = splay_search_closest_node(tree, data, &result); - - if(!result) { - return NULL; - } - - new = splay_alloc_node(); - new->data = data; - - if(result < 0) { - splay_insert_before(tree, closest, new); - } else { - splay_insert_after(tree, closest, new); - } - } - - return new; -} - -splay_node_t *splay_insert_node(splay_tree_t *tree, splay_node_t *node) { - splay_node_t *closest; - int result; - - node->left = node->right = node->parent = node->next = node->prev = NULL; - - if(!tree->root) { - splay_insert_top(tree, node); - } else { - closest = splay_search_closest_node(tree, node->data, &result); - - if(!result) { - return NULL; - } - - if(result < 0) { - splay_insert_before(tree, closest, node); - } else { - splay_insert_after(tree, closest, node); - } - } - - return node; -} - -void splay_insert_top(splay_tree_t *tree, splay_node_t *node) { - node->prev = node->next = node->left = node->right = node->parent = NULL; - tree->head = tree->tail = tree->root = node; - tree->count++; - tree->generation++; -} - -void splay_insert_before(splay_tree_t *tree, splay_node_t *before, splay_node_t *node) { - if(!before) { - if(tree->tail) { - splay_insert_after(tree, tree->tail, node); - } else { - splay_insert_top(tree, node); - } - - return; - } - - node->next = before; - - if((node->prev = before->prev)) { - before->prev->next = node; - } else { - tree->head = node; - } - - before->prev = node; - - splay_bottom_up(tree, before); - - node->right = before; - before->parent = node; - - if((node->left = before->left)) { - before->left->parent = node; - } - - before->left = NULL; - - node->parent = NULL; - tree->root = node; - tree->count++; - tree->generation++; -} - -void splay_insert_after(splay_tree_t *tree, splay_node_t *after, splay_node_t *node) { - if(!after) { - if(tree->head) { - splay_insert_before(tree, tree->head, node); - } else { - splay_insert_top(tree, node); - } - - return; - } - - node->prev = after; - - if((node->next = after->next)) { - after->next->prev = node; - } else { - tree->tail = node; - } - - after->next = node; - - splay_bottom_up(tree, after); - - node->left = after; - after->parent = node; - - if((node->right = after->right)) { - after->right->parent = node; - } - - after->right = NULL; - - node->parent = NULL; - tree->root = node; - tree->count++; - tree->generation++; -} - -splay_node_t *splay_unlink(splay_tree_t *tree, void *data) { - splay_node_t *node; - - node = splay_search_node(tree, data); - - if(node) { - splay_unlink_node(tree, node); - } - - return node; -} - -void splay_unlink_node(splay_tree_t *tree, splay_node_t *node) { - if(node->prev) { - node->prev->next = node->next; - } else { - tree->head = node->next; - } - - if(node->next) { - node->next->prev = node->prev; - } else { - tree->tail = node->prev; - } - - splay_bottom_up(tree, node); - - if(node->prev) { - node->left->parent = NULL; - tree->root = node->left; - - if((node->prev->right = node->right)) { - node->right->parent = node->prev; - } - } else if(node->next) { - tree->root = node->right; - node->right->parent = NULL; - } else { - tree->root = NULL; - } - - tree->count--; - tree->generation++; -} - -void splay_delete_node(splay_tree_t *tree, splay_node_t *node) { - splay_unlink_node(tree, node); - splay_free_node(tree, node); -} - -void splay_delete(splay_tree_t *tree, void *data) { - splay_node_t *node; - - node = splay_search_node(tree, data); - - if(node) { - splay_delete_node(tree, node); - } -} - -/* Fast tree cleanup */ - -void splay_delete_tree(splay_tree_t *tree) { - for(splay_node_t *node = tree->head, *next; node; node = next) { - next = node->next; - splay_free_node(tree, node); - } - - splay_free_tree(tree); -} - -/* Tree walking */ - -void splay_foreach(const splay_tree_t *tree, splay_action_t action) { - for(splay_node_t *node = tree->head, *next; node; node = next) { - next = node->next; - action(node->data); - } -} - -void splay_foreach_node(const splay_tree_t *tree, splay_action_t action) { - for(splay_node_t *node = tree->head, *next; node; node = next) { - next = node->next; - action(node); - } -} diff --git a/src/splay_tree.h b/src/splay_tree.h deleted file mode 100644 index d5ab742..0000000 --- a/src/splay_tree.h +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef TINC_SPLAY_TREE_H -#define TINC_SPLAY_TREE_H - -/* - splay_tree.h -- header file for splay_tree.c - Copyright (C) 2004-2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -typedef struct splay_node_t { - - /* Linked list part */ - - struct splay_node_t *next; - struct splay_node_t *prev; - - /* Tree part */ - - struct splay_node_t *parent; - struct splay_node_t *left; - struct splay_node_t *right; - - /* Payload */ - - void *data; - -} splay_node_t; - -typedef int (*splay_compare_t)(const void *data1, const void *data2); -typedef void (*splay_action_t)(const void *data); -typedef void (*splay_action_node_t)(const splay_node_t *node); - -typedef struct splay_tree_t { - - /* Linked list part */ - - splay_node_t *head; - splay_node_t *tail; - - /* Tree part */ - - splay_node_t *root; - - splay_compare_t compare; - splay_action_t delete; - - unsigned int count; - unsigned int generation; - -} splay_tree_t; - -/* (De)constructors */ - -extern splay_tree_t *splay_alloc_tree(splay_compare_t compare, splay_action_t delete) __attribute__((__malloc__)); -extern void splay_free_tree(splay_tree_t *tree); - -extern splay_node_t *splay_alloc_node(void) __attribute__((__malloc__)); -extern void splay_free_node(splay_tree_t *tree, splay_node_t *node); - -/* Insertion and deletion */ - -extern splay_node_t *splay_insert(splay_tree_t *tree, void *data); -extern splay_node_t *splay_insert_node(splay_tree_t *tree, splay_node_t *node); - -extern void splay_insert_top(splay_tree_t *tree, splay_node_t *node); -extern void splay_insert_before(splay_tree_t *tree, splay_node_t *before, splay_node_t *node); -extern void splay_insert_after(splay_tree_t *tree, splay_node_t *after, splay_node_t *node); - -extern splay_node_t *splay_unlink(splay_tree_t *tree, void *data); -extern void splay_unlink_node(splay_tree_t *tree, splay_node_t *node); -extern void splay_delete(splay_tree_t *tree, void *data); -extern void splay_delete_node(splay_tree_t *tree, splay_node_t *node); - -/* Fast tree cleanup */ - -extern void splay_delete_tree(splay_tree_t *tree); - -/* Searching */ - -extern void *splay_search(splay_tree_t *tree, const void *data); -extern void *splay_search_closest(splay_tree_t *tree, const void *data, int *result); -extern void *splay_search_closest_smaller(splay_tree_t *tree, const void *data); -extern void *splay_search_closest_greater(splay_tree_t *tree, const void *data); - -extern splay_node_t *splay_search_node(splay_tree_t *tree, const void *data); -extern splay_node_t *splay_search_closest_node(splay_tree_t *tree, const void *data, int *result); -extern splay_node_t *splay_search_closest_node_nosplay(const splay_tree_t *tree, const void *data, int *result); -extern splay_node_t *splay_search_closest_smaller_node(splay_tree_t *tree, const void *data); -extern splay_node_t *splay_search_closest_greater_node(splay_tree_t *tree, const void *data); - -/* Tree walking */ - -extern void splay_foreach(const splay_tree_t *tree, splay_action_t action); -extern void splay_foreach_node(const splay_tree_t *tree, splay_action_t action); - -/* - Iterates over a tree. - - CAUTION: while this construct supports deleting the current item, - it does *not* support deleting *other* nodes while iterating on the tree. - */ -#define splay_each(type, item, tree) (type *item = (type *)1; item; item = NULL) for(splay_node_t *node = (tree)->head, *next; item = node ? node->data : NULL, next = node ? node->next : NULL, node; node = next) - -#endif diff --git a/src/sptps.c b/src/sptps.c deleted file mode 100644 index eeaf833..0000000 --- a/src/sptps.c +++ /dev/null @@ -1,767 +0,0 @@ -/* - sptps.c -- Simple Peer-to-Peer Security - Copyright (C) 2011-2015 Guus Sliepen , - 2010 Brandon L. Black - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include "chacha-poly1305/chacha-poly1305.h" -#include "crypto.h" -#include "ecdh.h" -#include "ecdsa.h" -#include "logger.h" -#include "prf.h" -#include "sptps.h" - -unsigned int sptps_replaywin = 16; - -/* - Nonce MUST be exchanged first (done) - Signatures MUST be done over both nonces, to guarantee the signature is fresh - Otherwise: if ECDHE key of one side is compromised, it can be reused! - - Add explicit tag to beginning of structure to distinguish the client and server when signing. (done) - - Sign all handshake messages up to ECDHE kex with long-term public keys. (done) - - HMACed KEX finished message to prevent downgrade attacks and prove you have the right key material (done by virtue of Ed25519 over the whole ECDHE exchange?) - - Explicit close message needs to be added. - - Maybe do add some alert messages to give helpful error messages? Not more than TLS sends. - - Use counter mode instead of OFB. (done) - - Make sure ECC operations are fixed time (aka prevent side-channel attacks). -*/ - -void sptps_log_quiet(sptps_t *s, int s_errno, const char *format, va_list ap) { - (void)s; - (void)s_errno; - (void)format; - (void)ap; -} - -void sptps_log_stderr(sptps_t *s, int s_errno, const char *format, va_list ap) { - (void)s; - (void)s_errno; - - vfprintf(stderr, format, ap); - fputc('\n', stderr); -} - -void (*sptps_log)(sptps_t *s, int s_errno, const char *format, va_list ap) = sptps_log_stderr; - -// Log an error message. -static bool error(sptps_t *s, int s_errno, const char *format, ...) { - (void)s; - (void)s_errno; - - if(format) { - va_list ap; - va_start(ap, format); - sptps_log(s, s_errno, format, ap); - va_end(ap); - } - - errno = s_errno; - return false; -} - -static void warning(sptps_t *s, const char *format, ...) { - va_list ap; - va_start(ap, format); - sptps_log(s, 0, format, ap); - va_end(ap); -} - -// Send a record (datagram version, accepts all record types, handles encryption and authentication). -static bool send_record_priv_datagram(sptps_t *s, uint8_t type, const void *data, uint16_t len) { - char buffer[len + 21UL]; - - // Create header with sequence number, length and record type - uint32_t seqno = s->outseqno++; - uint32_t netseqno = ntohl(seqno); - - memcpy(buffer, &netseqno, 4); - buffer[4] = type; - memcpy(buffer + 5, data, len); - - if(s->outstate) { - // If first handshake has finished, encrypt and HMAC - chacha_poly1305_encrypt(s->outcipher, seqno, buffer + 4, len + 1, buffer + 4, NULL); - return s->send_data(s->handle, type, buffer, len + 21UL); - } else { - // Otherwise send as plaintext - return s->send_data(s->handle, type, buffer, len + 5UL); - } -} -// Send a record (private version, accepts all record types, handles encryption and authentication). -static bool send_record_priv(sptps_t *s, uint8_t type, const void *data, uint16_t len) { - if(s->datagram) { - return send_record_priv_datagram(s, type, data, len); - } - - char buffer[len + 19UL]; - - // Create header with sequence number, length and record type - uint32_t seqno = s->outseqno++; - uint16_t netlen = htons(len); - - memcpy(buffer, &netlen, 2); - buffer[2] = type; - memcpy(buffer + 3, data, len); - - if(s->outstate) { - // If first handshake has finished, encrypt and HMAC - chacha_poly1305_encrypt(s->outcipher, seqno, buffer + 2, len + 1, buffer + 2, NULL); - return s->send_data(s->handle, type, buffer, len + 19UL); - } else { - // Otherwise send as plaintext - return s->send_data(s->handle, type, buffer, len + 3UL); - } -} - -// Send an application record. -bool sptps_send_record(sptps_t *s, uint8_t type, const void *data, uint16_t len) { - // Sanity checks: application cannot send data before handshake is finished, - // and only record types 0..127 are allowed. - if(!s->outstate) { - return error(s, EINVAL, "Handshake phase not finished yet"); - } - - if(type >= SPTPS_HANDSHAKE) { - return error(s, EINVAL, "Invalid application record type"); - } - - return send_record_priv(s, type, data, len); -} - -// Send a Key EXchange record, containing a random nonce and an ECDHE public key. -static bool send_kex(sptps_t *s) { - size_t keylen = ECDH_SIZE; - - // Make room for our KEX message, which we will keep around since send_sig() needs it. - if(s->mykex) { - return false; - } - - s->mykex = realloc(s->mykex, 1 + 32 + keylen); - - if(!s->mykex) { - return error(s, errno, strerror(errno)); - } - - // Set version byte to zero. - s->mykex[0] = SPTPS_VERSION; - - // Create a random nonce. - randomize(s->mykex + 1, 32); - - // Create a new ECDH public key. - if(!(s->ecdh = ecdh_generate_public(s->mykex + 1 + 32))) { - return error(s, EINVAL, "Failed to generate ECDH public key"); - } - - return send_record_priv(s, SPTPS_HANDSHAKE, s->mykex, 1 + 32 + keylen); -} - -// Send a SIGnature record, containing an Ed25519 signature over both KEX records. -static bool send_sig(sptps_t *s) { - size_t keylen = ECDH_SIZE; - size_t siglen = ecdsa_size(s->mykey); - - // Concatenate both KEX messages, plus tag indicating if it is from the connection originator, plus label - char msg[(1 + 32 + keylen) * 2 + 1 + s->labellen]; - char sig[siglen]; - - msg[0] = s->initiator; - memcpy(msg + 1, s->mykex, 1 + 32 + keylen); - memcpy(msg + 1 + 33 + keylen, s->hiskex, 1 + 32 + keylen); - memcpy(msg + 1 + 2 * (33 + keylen), s->label, s->labellen); - - // Sign the result. - if(!ecdsa_sign(s->mykey, msg, sizeof(msg), sig)) { - return error(s, EINVAL, "Failed to sign SIG record"); - } - - // Send the SIG exchange record. - return send_record_priv(s, SPTPS_HANDSHAKE, sig, sizeof(sig)); -} - -// Generate key material from the shared secret created from the ECDHE key exchange. -static bool generate_key_material(sptps_t *s, const char *shared, size_t len) { - // Initialise cipher and digest structures if necessary - if(!s->outstate) { - s->incipher = chacha_poly1305_init(); - s->outcipher = chacha_poly1305_init(); - - if(!s->incipher || !s->outcipher) { - return error(s, EINVAL, "Failed to open cipher"); - } - } - - // Allocate memory for key material - size_t keylen = 2 * CHACHA_POLY1305_KEYLEN; - - s->key = realloc(s->key, keylen); - - if(!s->key) { - return error(s, errno, strerror(errno)); - } - - // Create the HMAC seed, which is "key expansion" + session label + server nonce + client nonce - char seed[s->labellen + 64 + 13]; - memcpy(seed, "key expansion", 13); - - if(s->initiator) { - memcpy(seed + 13, s->mykex + 1, 32); - memcpy(seed + 45, s->hiskex + 1, 32); - } else { - memcpy(seed + 13, s->hiskex + 1, 32); - memcpy(seed + 45, s->mykex + 1, 32); - } - - memcpy(seed + 77, s->label, s->labellen); - - // Use PRF to generate the key material - if(!prf(shared, len, seed, s->labellen + 64 + 13, s->key, keylen)) { - return error(s, EINVAL, "Failed to generate key material"); - } - - return true; -} - -// Send an ACKnowledgement record. -static bool send_ack(sptps_t *s) { - return send_record_priv(s, SPTPS_HANDSHAKE, "", 0); -} - -// Receive an ACKnowledgement record. -static bool receive_ack(sptps_t *s, const char *data, uint16_t len) { - (void)data; - - if(len) { - return error(s, EIO, "Invalid ACK record length"); - } - - if(s->initiator) { - if(!chacha_poly1305_set_key(s->incipher, s->key)) { - return error(s, EINVAL, "Failed to set counter"); - } - } else { - if(!chacha_poly1305_set_key(s->incipher, s->key + CHACHA_POLY1305_KEYLEN)) { - return error(s, EINVAL, "Failed to set counter"); - } - } - - free(s->key); - s->key = NULL; - s->instate = true; - - return true; -} - -// Receive a Key EXchange record, respond by sending a SIG record. -static bool receive_kex(sptps_t *s, const char *data, uint16_t len) { - // Verify length of the HELLO record - if(len != 1 + 32 + ECDH_SIZE) { - return error(s, EIO, "Invalid KEX record length"); - } - - // Ignore version number for now. - - // Make a copy of the KEX message, send_sig() and receive_sig() need it - if(s->hiskex) { - return error(s, EINVAL, "Received a second KEX message before first has been processed"); - } - - s->hiskex = realloc(s->hiskex, len); - - if(!s->hiskex) { - return error(s, errno, strerror(errno)); - } - - memcpy(s->hiskex, data, len); - - if(s->initiator) { - return send_sig(s); - } else { - return true; - } -} - -// Receive a SIGnature record, verify it, if it passed, compute the shared secret and calculate the session keys. -static bool receive_sig(sptps_t *s, const char *data, uint16_t len) { - size_t keylen = ECDH_SIZE; - size_t siglen = ecdsa_size(s->hiskey); - - // Verify length of KEX record. - if(len != siglen) { - return error(s, EIO, "Invalid KEX record length"); - } - - // Concatenate both KEX messages, plus tag indicating if it is from the connection originator - char msg[(1 + 32 + keylen) * 2 + 1 + s->labellen]; - - msg[0] = !s->initiator; - memcpy(msg + 1, s->hiskex, 1 + 32 + keylen); - memcpy(msg + 1 + 33 + keylen, s->mykex, 1 + 32 + keylen); - memcpy(msg + 1 + 2 * (33 + keylen), s->label, s->labellen); - - // Verify signature. - if(!ecdsa_verify(s->hiskey, msg, sizeof(msg), data)) { - return error(s, EIO, "Failed to verify SIG record"); - } - - // Compute shared secret. - char shared[ECDH_SHARED_SIZE]; - - if(!ecdh_compute_shared(s->ecdh, s->hiskex + 1 + 32, shared)) { - return error(s, EINVAL, "Failed to compute ECDH shared secret"); - } - - s->ecdh = NULL; - - // Generate key material from shared secret. - if(!generate_key_material(s, shared, sizeof(shared))) { - return false; - } - - if(!s->initiator && !send_sig(s)) { - return false; - } - - free(s->mykex); - free(s->hiskex); - - s->mykex = NULL; - s->hiskex = NULL; - - // Send cipher change record - if(s->outstate && !send_ack(s)) { - return false; - } - - // TODO: only set new keys after ACK has been set/received - if(s->initiator) { - if(!chacha_poly1305_set_key(s->outcipher, s->key + CHACHA_POLY1305_KEYLEN)) { - return error(s, EINVAL, "Failed to set key"); - } - } else { - if(!chacha_poly1305_set_key(s->outcipher, s->key)) { - return error(s, EINVAL, "Failed to set key"); - } - } - - return true; -} - -// Force another Key EXchange (for testing purposes). -bool sptps_force_kex(sptps_t *s) { - if(!s->outstate || s->state != SPTPS_SECONDARY_KEX) { - return error(s, EINVAL, "Cannot force KEX in current state"); - } - - s->state = SPTPS_KEX; - return send_kex(s); -} - -// Receive a handshake record. -static bool receive_handshake(sptps_t *s, const char *data, uint16_t len) { - // Only a few states to deal with handshaking. - switch(s->state) { - case SPTPS_SECONDARY_KEX: - - // We receive a secondary KEX request, first respond by sending our own. - if(!send_kex(s)) { - return false; - } - - // Fall through - case SPTPS_KEX: - - // We have sent our KEX request, we expect our peer to sent one as well. - if(!receive_kex(s, data, len)) { - return false; - } - - s->state = SPTPS_SIG; - return true; - - case SPTPS_SIG: - - // If we already sent our secondary public ECDH key, we expect the peer to send his. - if(!receive_sig(s, data, len)) { - return false; - } - - if(s->outstate) { - s->state = SPTPS_ACK; - } else { - s->outstate = true; - - if(!receive_ack(s, NULL, 0)) { - return false; - } - - s->receive_record(s->handle, SPTPS_HANDSHAKE, NULL, 0); - s->state = SPTPS_SECONDARY_KEX; - } - - return true; - - case SPTPS_ACK: - - // We expect a handshake message to indicate transition to the new keys. - if(!receive_ack(s, data, len)) { - return false; - } - - s->receive_record(s->handle, SPTPS_HANDSHAKE, NULL, 0); - s->state = SPTPS_SECONDARY_KEX; - return true; - - // TODO: split ACK into a VERify and ACK? - default: - return error(s, EIO, "Invalid session state %d", s->state); - } -} - -static bool sptps_check_seqno(sptps_t *s, uint32_t seqno, bool update_state) { - // Replay protection using a sliding window of configurable size. - // s->inseqno is expected sequence number - // seqno is received sequence number - // s->late[] is a circular buffer, a 1 bit means a packet has not been received yet - // The circular buffer contains bits for sequence numbers from s->inseqno - s->replaywin * 8 to (but excluding) s->inseqno. - if(s->replaywin) { - if(seqno != s->inseqno) { - if(seqno >= s->inseqno + s->replaywin * 8) { - // Prevent packets that jump far ahead of the queue from causing many others to be dropped. - bool farfuture = s->farfuture < s->replaywin >> 2; - - if(update_state) { - s->farfuture++; - } - - if(farfuture) { - return update_state ? error(s, EIO, "Packet is %d seqs in the future, dropped (%u)\n", seqno - s->inseqno, s->farfuture) : false; - } - - // Unless we have seen lots of them, in which case we consider the others lost. - if(update_state) { - warning(s, "Lost %d packets\n", seqno - s->inseqno); - } - - if(update_state) { - // Mark all packets in the replay window as being late. - memset(s->late, 255, s->replaywin); - } - } else if(seqno < s->inseqno) { - // If the sequence number is farther in the past than the bitmap goes, or if the packet was already received, drop it. - if((s->inseqno >= s->replaywin * 8 && seqno < s->inseqno - s->replaywin * 8) || !(s->late[(seqno / 8) % s->replaywin] & (1 << seqno % 8))) { - return update_state ? error(s, EIO, "Received late or replayed packet, seqno %d, last received %d\n", seqno, s->inseqno) : false; - } - } else if(update_state) { - // We missed some packets. Mark them in the bitmap as being late. - for(uint32_t i = s->inseqno; i < seqno; i++) { - s->late[(i / 8) % s->replaywin] |= 1 << i % 8; - } - } - } - - if(update_state) { - // Mark the current packet as not being late. - s->late[(seqno / 8) % s->replaywin] &= ~(1 << seqno % 8); - s->farfuture = 0; - } - } - - if(update_state) { - if(seqno >= s->inseqno) { - s->inseqno = seqno + 1; - } - - if(!s->inseqno) { - s->received = 0; - } else { - s->received++; - } - } - - return true; -} - -// Check datagram for valid HMAC -bool sptps_verify_datagram(sptps_t *s, const void *vdata, size_t len) { - if(!s->instate || len < 21) { - return error(s, EIO, "Received short packet"); - } - - const char *data = vdata; - uint32_t seqno; - memcpy(&seqno, data, 4); - seqno = ntohl(seqno); - - if(!sptps_check_seqno(s, seqno, false)) { - return false; - } - - char buffer[len]; - size_t outlen; - return chacha_poly1305_decrypt(s->incipher, seqno, data + 4, len - 4, buffer, &outlen); -} - -// Receive incoming data, datagram version. -static bool sptps_receive_data_datagram(sptps_t *s, const char *data, size_t len) { - if(len < (s->instate ? 21 : 5)) { - return error(s, EIO, "Received short packet"); - } - - uint32_t seqno; - memcpy(&seqno, data, 4); - seqno = ntohl(seqno); - data += 4; - len -= 4; - - if(!s->instate) { - if(seqno != s->inseqno) { - return error(s, EIO, "Invalid packet seqno: %d != %d", seqno, s->inseqno); - } - - s->inseqno = seqno + 1; - - uint8_t type = *(data++); - len--; - - if(type != SPTPS_HANDSHAKE) { - return error(s, EIO, "Application record received before handshake finished"); - } - - return receive_handshake(s, data, len); - } - - // Decrypt - - char buffer[len]; - size_t outlen; - - if(!chacha_poly1305_decrypt(s->incipher, seqno, data, len, buffer, &outlen)) { - return error(s, EIO, "Failed to decrypt and verify packet"); - } - - if(!sptps_check_seqno(s, seqno, true)) { - return false; - } - - // Append a NULL byte for safety. - buffer[outlen] = 0; - - data = buffer; - len = outlen; - - uint8_t type = *(data++); - len--; - - if(type < SPTPS_HANDSHAKE) { - if(!s->instate) { - return error(s, EIO, "Application record received before handshake finished"); - } - - if(!s->receive_record(s->handle, type, data, len)) { - return false; - } - } else if(type == SPTPS_HANDSHAKE) { - if(!receive_handshake(s, data, len)) { - return false; - } - } else { - return error(s, EIO, "Invalid record type %d", type); - } - - return true; -} - -// Receive incoming data. Check if it contains a complete record, if so, handle it. -size_t sptps_receive_data(sptps_t *s, const void *vdata, size_t len) { - const char *data = vdata; - size_t total_read = 0; - - if(!s->state) { - return error(s, EIO, "Invalid session state zero"); - } - - if(s->datagram) { - return sptps_receive_data_datagram(s, data, len) ? len : false; - } - - // First read the 2 length bytes. - if(s->buflen < 2) { - size_t toread = 2 - s->buflen; - - if(toread > len) { - toread = len; - } - - memcpy(s->inbuf + s->buflen, data, toread); - - total_read += toread; - s->buflen += toread; - len -= toread; - data += toread; - - // Exit early if we don't have the full length. - if(s->buflen < 2) { - return total_read; - } - - // Get the length bytes - - memcpy(&s->reclen, s->inbuf, 2); - s->reclen = ntohs(s->reclen); - - // If we have the length bytes, ensure our buffer can hold the whole request. - s->inbuf = realloc(s->inbuf, s->reclen + 19UL); - - if(!s->inbuf) { - return error(s, errno, strerror(errno)); - } - - // Exit early if we have no more data to process. - if(!len) { - return total_read; - } - } - - // Read up to the end of the record. - size_t toread = s->reclen + (s->instate ? 19UL : 3UL) - s->buflen; - - if(toread > len) { - toread = len; - } - - memcpy(s->inbuf + s->buflen, data, toread); - total_read += toread; - s->buflen += toread; - - // If we don't have a whole record, exit. - if(s->buflen < s->reclen + (s->instate ? 19UL : 3UL)) { - return total_read; - } - - // Update sequence number. - - uint32_t seqno = s->inseqno++; - - // Check HMAC and decrypt. - if(s->instate) { - if(!chacha_poly1305_decrypt(s->incipher, seqno, s->inbuf + 2UL, s->reclen + 17UL, s->inbuf + 2UL, NULL)) { - return error(s, EINVAL, "Failed to decrypt and verify record"); - } - } - - // Append a NULL byte for safety. - s->inbuf[s->reclen + 3UL] = 0; - - uint8_t type = s->inbuf[2]; - - if(type < SPTPS_HANDSHAKE) { - if(!s->instate) { - return error(s, EIO, "Application record received before handshake finished"); - } - - if(!s->receive_record(s->handle, type, s->inbuf + 3, s->reclen)) { - return false; - } - } else if(type == SPTPS_HANDSHAKE) { - if(!receive_handshake(s, s->inbuf + 3, s->reclen)) { - return false; - } - } else { - return error(s, EIO, "Invalid record type %d", type); - } - - s->buflen = 0; - - return total_read; -} - -// Start a SPTPS session. -bool sptps_start(sptps_t *s, void *handle, bool initiator, bool datagram, ecdsa_t *mykey, ecdsa_t *hiskey, const void *label, size_t labellen, send_data_t send_data, receive_record_t receive_record) { - // Initialise struct sptps - memset(s, 0, sizeof(*s)); - - s->handle = handle; - s->initiator = initiator; - s->datagram = datagram; - s->mykey = mykey; - s->hiskey = hiskey; - s->replaywin = sptps_replaywin; - - if(s->replaywin) { - s->late = malloc(s->replaywin); - - if(!s->late) { - return error(s, errno, strerror(errno)); - } - - memset(s->late, 0, s->replaywin); - } - - s->label = malloc(labellen); - - if(!s->label) { - return error(s, errno, strerror(errno)); - } - - if(!datagram) { - s->inbuf = malloc(7); - - if(!s->inbuf) { - return error(s, errno, strerror(errno)); - } - - s->buflen = 0; - } - - memcpy(s->label, label, labellen); - s->labellen = labellen; - - s->send_data = send_data; - s->receive_record = receive_record; - - // Do first KEX immediately - s->state = SPTPS_KEX; - return send_kex(s); -} - -// Stop a SPTPS session. -bool sptps_stop(sptps_t *s) { - // Clean up any resources. - chacha_poly1305_exit(s->incipher); - chacha_poly1305_exit(s->outcipher); - ecdh_free(s->ecdh); - free(s->inbuf); - free(s->mykex); - free(s->hiskex); - free(s->key); - free(s->label); - free(s->late); - memset(s, 0, sizeof(*s)); - return true; -} diff --git a/src/sptps.h b/src/sptps.h deleted file mode 100644 index f5686f4..0000000 --- a/src/sptps.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef TINC_SPTPS_H -#define TINC_SPTPS_H - -/* - sptps.h -- Simple Peer-to-Peer Security - Copyright (C) 2011-2014 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include "chacha-poly1305/chacha-poly1305.h" -#include "ecdh.h" -#include "ecdsa.h" - -#define SPTPS_VERSION 0 - -// Record types -#define SPTPS_HANDSHAKE 128 // Key exchange and authentication -#define SPTPS_ALERT 129 // Warning or error messages -#define SPTPS_CLOSE 130 // Application closed the connection - -// Key exchange states -#define SPTPS_KEX 1 // Waiting for the first Key EXchange record -#define SPTPS_SECONDARY_KEX 2 // Ready to receive a secondary Key EXchange record -#define SPTPS_SIG 3 // Waiting for a SIGnature record -#define SPTPS_ACK 4 // Waiting for an ACKnowledgement record - -// Overhead for datagrams -#define SPTPS_DATAGRAM_OVERHEAD 21 - -typedef bool (*send_data_t)(void *handle, uint8_t type, const void *data, size_t len); -typedef bool (*receive_record_t)(void *handle, uint8_t type, const void *data, uint16_t len); - -typedef struct sptps { - bool initiator; - bool datagram; - int state; - - char *inbuf; - size_t buflen; - uint16_t reclen; - - bool instate; - chacha_poly1305_ctx_t *incipher; - uint32_t inseqno; - uint32_t received; - unsigned int replaywin; - unsigned int farfuture; - char *late; - - bool outstate; - chacha_poly1305_ctx_t *outcipher; - uint32_t outseqno; - - ecdsa_t *mykey; - ecdsa_t *hiskey; - ecdh_t *ecdh; - - char *mykex; - char *hiskex; - char *key; - char *label; - size_t labellen; - - void *handle; - send_data_t send_data; - receive_record_t receive_record; -} sptps_t; - -extern unsigned int sptps_replaywin; -extern void sptps_log_quiet(sptps_t *s, int s_errno, const char *format, va_list ap); -extern void sptps_log_stderr(sptps_t *s, int s_errno, const char *format, va_list ap); -extern void (*sptps_log)(sptps_t *s, int s_errno, const char *format, va_list ap); -extern bool sptps_start(sptps_t *s, void *handle, bool initiator, bool datagram, ecdsa_t *mykey, ecdsa_t *hiskey, const void *label, size_t labellen, send_data_t send_data, receive_record_t receive_record); -extern bool sptps_stop(sptps_t *s); -extern bool sptps_send_record(sptps_t *s, uint8_t type, const void *data, uint16_t len); -extern size_t sptps_receive_data(sptps_t *s, const void *data, size_t len); -extern bool sptps_force_kex(sptps_t *s); -extern bool sptps_verify_datagram(sptps_t *s, const void *data, size_t len); - -#endif diff --git a/src/sptps_keypair.c b/src/sptps_keypair.c deleted file mode 100644 index 51a94ee..0000000 --- a/src/sptps_keypair.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - sptps_test.c -- Simple Peer-to-Peer Security test program - Copyright (C) 2011-2013 Guus Sliepen , - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include - -#include "crypto.h" -#include "ecdsagen.h" -#include "utils.h" - -static char *program_name; - -void logger(int level, int priority, const char *format, ...) { - (void)level; - (void)priority; - va_list ap; - - va_start(ap, format); - vfprintf(stderr, format, ap); - va_end(ap); - - fputc('\n', stderr); -} - -static void usage() { - fprintf(stderr, "Usage: %s [options] private_key_file public_key_file\n\n", program_name); - fprintf(stderr, "Valid options are:\n" - " --help Display this help and exit.\n" - "\n"); - fprintf(stderr, "Report bugs to tinc@tinc-vpn.org.\n"); -} - -static struct option const long_options[] = { - {"help", no_argument, NULL, 1}, - {NULL, 0, NULL, 0} -}; - -int main(int argc, char *argv[]) { - program_name = argv[0]; - int r; - int option_index = 0; - - while((r = getopt_long(argc, argv, "", long_options, &option_index)) != EOF) { - switch(r) { - case 0: /* long option */ - break; - - case '?': /* wrong options */ - usage(); - return 1; - - case 1: /* help */ - usage(); - return 0; - - default: - break; - } - } - - argc -= optind - 1; - argv += optind - 1; - - if(argc != 3) { - fprintf(stderr, "Wrong number of arguments.\n"); - usage(); - return 1; - } - - crypto_init(); - - ecdsa_t *key = ecdsa_generate(); - - if(!key) { - return 1; - } - - FILE *fp = fopen(argv[1], "w"); - - if(fp) { - if(!ecdsa_write_pem_private_key(key, fp)) { - fprintf(stderr, "Could not write ECDSA private key\n"); - return 1; - } - - fclose(fp); - } else { - fprintf(stderr, "Could not open '%s' for writing: %s\n", argv[1], strerror(errno)); - return 1; - } - - fp = fopen(argv[2], "w"); - - if(fp) { - if(!ecdsa_write_pem_public_key(key, fp)) { - fprintf(stderr, "Could not write ECDSA public key\n"); - } - - fclose(fp); - } else { - fprintf(stderr, "Could not open '%s' for writing: %s\n", argv[2], strerror(errno)); - return 1; - } - - return 0; -} diff --git a/src/sptps_speed.c b/src/sptps_speed.c deleted file mode 100644 index db7314e..0000000 --- a/src/sptps_speed.c +++ /dev/null @@ -1,308 +0,0 @@ -/* - sptps_speed.c -- SPTPS benchmark - Copyright (C) 2013-2014 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" -#include "utils.h" - -#include - -#include "crypto.h" -#include "ecdh.h" -#include "ecdsa.h" -#include "ecdsagen.h" -#include "sptps.h" - -// Symbols necessary to link with logger.o -bool send_request(void *c, const char *msg, ...) { - return false; -} -struct list_t *connection_list = NULL; -bool send_meta(void *c, const char *msg, int len) { - return false; -} -char *logfilename = NULL; -bool do_detach = false; -struct timeval now; - -static bool send_data(void *handle, uint8_t type, const void *data, size_t len) { - int fd = *(int *)handle; - send(fd, data, len, 0); - return true; -} - -static bool receive_record(void *handle, uint8_t type, const void *data, uint16_t len) { - return true; -} - -static void receive_data(sptps_t *sptps) { - char buf[4096], *bufp = buf; - int fd = *(int *)sptps->handle; - size_t len = recv(fd, buf, sizeof(buf), 0); - - while(len) { - size_t done = sptps_receive_data(sptps, bufp, len); - - if(!done) { - abort(); - } - - bufp += done; - len -= done; - } -} - -struct timespec start; -struct timespec end; -double elapsed; -double rate; -unsigned int count; - -static void clock_start() { - count = 0; - clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start); -} - -static bool clock_countto(double seconds) { - clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end); - elapsed = end.tv_sec + end.tv_nsec * 1e-9 - start.tv_sec - start.tv_nsec * 1e-9; - - if(elapsed < seconds) { - return ++count; - } - - rate = count / elapsed; - return false; -} - -int main(int argc, char *argv[]) { - ecdsa_t *key1, *key2; - ecdh_t *ecdh1, *ecdh2; - sptps_t sptps1, sptps2; - char buf1[4096], buf2[4096], buf3[4096]; - double duration = argc > 1 ? atof(argv[1]) : 10; - - crypto_init(); - - randomize(buf1, sizeof(buf1)); - randomize(buf2, sizeof(buf2)); - randomize(buf3, sizeof(buf3)); - - // Key generation - - fprintf(stderr, "Generating keys for %lg seconds: ", duration); - - for(clock_start(); clock_countto(duration);) { - ecdsa_free(ecdsa_generate()); - } - - fprintf(stderr, "%17.2lf op/s\n", rate); - - key1 = ecdsa_generate(); - key2 = ecdsa_generate(); - - // Ed25519 signatures - - fprintf(stderr, "Ed25519 sign for %lg seconds: ", duration); - - for(clock_start(); clock_countto(duration);) - if(!ecdsa_sign(key1, buf1, 256, buf2)) { - return 1; - } - - fprintf(stderr, "%20.2lf op/s\n", rate); - - fprintf(stderr, "Ed25519 verify for %lg seconds: ", duration); - - for(clock_start(); clock_countto(duration);) - if(!ecdsa_verify(key1, buf1, 256, buf2)) { - fprintf(stderr, "Signature verification failed\n"); - return 1; - } - - fprintf(stderr, "%18.2lf op/s\n", rate); - - ecdh1 = ecdh_generate_public(buf1); - fprintf(stderr, "ECDH for %lg seconds: ", duration); - - for(clock_start(); clock_countto(duration);) { - ecdh2 = ecdh_generate_public(buf2); - - if(!ecdh2) { - return 1; - } - - if(!ecdh_compute_shared(ecdh2, buf1, buf3)) { - return 1; - } - } - - fprintf(stderr, "%28.2lf op/s\n", rate); - ecdh_free(ecdh1); - - // SPTPS authentication phase - - int fd[2]; - - if(socketpair(AF_UNIX, SOCK_STREAM, 0, fd)) { - fprintf(stderr, "Could not create a UNIX socket pair: %s\n", sockstrerror(sockerrno)); - return 1; - } - - struct pollfd pfd[2] = {{fd[0], POLLIN}, {fd[1], POLLIN}}; - - fprintf(stderr, "SPTPS/TCP authenticate for %lg seconds: ", duration); - - for(clock_start(); clock_countto(duration);) { - sptps_start(&sptps1, fd + 0, true, false, key1, key2, "sptps_speed", 11, send_data, receive_record); - sptps_start(&sptps2, fd + 1, false, false, key2, key1, "sptps_speed", 11, send_data, receive_record); - - while(poll(pfd, 2, 0)) { - if(pfd[0].revents) { - receive_data(&sptps1); - } - - if(pfd[1].revents) { - receive_data(&sptps2); - } - } - - sptps_stop(&sptps1); - sptps_stop(&sptps2); - } - - fprintf(stderr, "%10.2lf op/s\n", rate * 2); - - // SPTPS data - - sptps_start(&sptps1, fd + 0, true, false, key1, key2, "sptps_speed", 11, send_data, receive_record); - sptps_start(&sptps2, fd + 1, false, false, key2, key1, "sptps_speed", 11, send_data, receive_record); - - while(poll(pfd, 2, 0)) { - if(pfd[0].revents) { - receive_data(&sptps1); - } - - if(pfd[1].revents) { - receive_data(&sptps2); - } - } - - fprintf(stderr, "SPTPS/TCP transmit for %lg seconds: ", duration); - - for(clock_start(); clock_countto(duration);) { - if(!sptps_send_record(&sptps1, 0, buf1, 1451)) { - abort(); - } - - receive_data(&sptps2); - } - - rate *= 2 * 1451 * 8; - - if(rate > 1e9) { - fprintf(stderr, "%14.2lf Gbit/s\n", rate / 1e9); - } else if(rate > 1e6) { - fprintf(stderr, "%14.2lf Mbit/s\n", rate / 1e6); - } else if(rate > 1e3) { - fprintf(stderr, "%14.2lf kbit/s\n", rate / 1e3); - } - - sptps_stop(&sptps1); - sptps_stop(&sptps2); - - // SPTPS datagram authentication phase - - close(fd[0]); - close(fd[1]); - - if(socketpair(AF_UNIX, SOCK_DGRAM, 0, fd)) { - fprintf(stderr, "Could not create a UNIX socket pair: %s\n", sockstrerror(sockerrno)); - return 1; - } - - fprintf(stderr, "SPTPS/UDP authenticate for %lg seconds: ", duration); - - for(clock_start(); clock_countto(duration);) { - sptps_start(&sptps1, fd + 0, true, true, key1, key2, "sptps_speed", 11, send_data, receive_record); - sptps_start(&sptps2, fd + 1, false, true, key2, key1, "sptps_speed", 11, send_data, receive_record); - - while(poll(pfd, 2, 0)) { - if(pfd[0].revents) { - receive_data(&sptps1); - } - - if(pfd[1].revents) { - receive_data(&sptps2); - } - } - - sptps_stop(&sptps1); - sptps_stop(&sptps2); - } - - fprintf(stderr, "%10.2lf op/s\n", rate * 2); - - // SPTPS datagram data - - sptps_start(&sptps1, fd + 0, true, true, key1, key2, "sptps_speed", 11, send_data, receive_record); - sptps_start(&sptps2, fd + 1, false, true, key2, key1, "sptps_speed", 11, send_data, receive_record); - - while(poll(pfd, 2, 0)) { - if(pfd[0].revents) { - receive_data(&sptps1); - } - - if(pfd[1].revents) { - receive_data(&sptps2); - } - } - - fprintf(stderr, "SPTPS/UDP transmit for %lg seconds: ", duration); - - for(clock_start(); clock_countto(duration);) { - if(!sptps_send_record(&sptps1, 0, buf1, 1451)) { - abort(); - } - - receive_data(&sptps2); - } - - rate *= 2 * 1451 * 8; - - if(rate > 1e9) { - fprintf(stderr, "%14.2lf Gbit/s\n", rate / 1e9); - } else if(rate > 1e6) { - fprintf(stderr, "%14.2lf Mbit/s\n", rate / 1e6); - } else if(rate > 1e3) { - fprintf(stderr, "%14.2lf kbit/s\n", rate / 1e3); - } - - sptps_stop(&sptps1); - sptps_stop(&sptps2); - - // Clean up - - close(fd[0]); - close(fd[1]); - ecdsa_free(key1); - ecdsa_free(key2); - crypto_exit(); - - return 0; -} diff --git a/src/sptps_test.c b/src/sptps_test.c deleted file mode 100644 index 4ff701e..0000000 --- a/src/sptps_test.c +++ /dev/null @@ -1,471 +0,0 @@ -/* - sptps_test.c -- Simple Peer-to-Peer Security test program - Copyright (C) 2011-2014 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#ifdef HAVE_LINUX -#include -#endif - -#include - -#include "crypto.h" -#include "ecdsa.h" -#include "sptps.h" -#include "utils.h" - -// Symbols necessary to link with logger.o -bool send_request(void *c, const char *msg, ...) { - (void)c; - (void)msg; - return false; -} - -struct list_t *connection_list = NULL; - -bool send_meta(void *c, const char *msg, int len) { - (void)c; - (void)msg; - (void)len; - return false; -} - -char *logfilename = NULL; -bool do_detach = false; -struct timeval now; - -static bool special; -static bool verbose; -static bool readonly; -static bool writeonly; -static int in = 0; -static int out = 1; -static int addressfamily = AF_UNSPEC; - -static bool send_data(void *handle, uint8_t type, const void *data, size_t len) { - (void)type; - char hex[len * 2 + 1]; - bin2hex(data, hex, len); - - if(verbose) { - fprintf(stderr, "Sending %d bytes of data:\n%s\n", (int)len, hex); - } - - const int *sock = handle; - - if((size_t)send(*sock, data, len, 0) != len) { - return false; - } - - return true; -} - -static bool receive_record(void *handle, uint8_t type, const void *data, uint16_t len) { - (void)handle; - if(verbose) { - fprintf(stderr, "Received type %d record of %u bytes:\n", type, len); - } - - if(!writeonly) { - write(out, data, len); - } - - return true; -} - -static struct option const long_options[] = { - {"datagram", no_argument, NULL, 'd'}, - {"quit", no_argument, NULL, 'q'}, - {"readonly", no_argument, NULL, 'r'}, - {"writeonly", no_argument, NULL, 'w'}, - {"packet-loss", required_argument, NULL, 'L'}, - {"replay-window", required_argument, NULL, 'W'}, - {"special", no_argument, NULL, 's'}, - {"verbose", required_argument, NULL, 'v'}, - {"help", no_argument, NULL, 1}, - {NULL, 0, NULL, 0} -}; - -const char *program_name; - -static void usage() { - fprintf(stderr, "Usage: %s [options] my_ed25519_key_file his_ed25519_key_file [host] port\n\n", program_name); - fprintf(stderr, "Valid options are:\n" - " -d, --datagram Enable datagram mode.\n" - " -q, --quit Quit when EOF occurs on stdin.\n" - " -r, --readonly Only send data from the socket to stdout.\n" -#ifdef HAVE_LINUX - " -t, --tun Use a tun device instead of stdio.\n" -#endif - " -w, --writeonly Only send data from stdin to the socket.\n" - " -L, --packet-loss RATE Fake packet loss of RATE percent.\n" - " -R, --replay-window N Set replay window to N bytes.\n" - " -s, --special Enable special handling of lines starting with #, ^ and $.\n" - " -v, --verbose Display debug messages.\n" - " -4 Use IPv4.\n" - " -6 Use IPv6.\n" - "\n"); - fprintf(stderr, "Report bugs to tinc@tinc-vpn.org.\n"); -} - -int main(int argc, char *argv[]) { - program_name = argv[0]; - bool initiator = false; - bool datagram = false; -#ifdef HAVE_LINUX - bool tun = false; -#endif - int packetloss = 0; - int r; - int option_index = 0; - ecdsa_t *mykey = NULL, *hiskey = NULL; - bool quit = false; - - while((r = getopt_long(argc, argv, "dqrstwL:W:v46", long_options, &option_index)) != EOF) { - switch(r) { - case 0: /* long option */ - break; - - case 'd': /* datagram mode */ - datagram = true; - break; - - case 'q': /* close connection on EOF from stdin */ - quit = true; - break; - - case 'r': /* read only */ - readonly = true; - break; - - case 't': /* read only */ -#ifdef HAVE_LINUX - tun = true; -#else - fprintf(stderr, "--tun is only supported on Linux.\n"); - usage(); - return 1; -#endif - break; - - case 'w': /* write only */ - writeonly = true; - break; - - case 'L': /* packet loss rate */ - packetloss = atoi(optarg); - break; - - case 'W': /* replay window size */ - sptps_replaywin = atoi(optarg); - break; - - case 'v': /* be verbose */ - verbose = true; - break; - - case 's': /* special character handling */ - special = true; - break; - - case '?': /* wrong options */ - usage(); - return 1; - - case '4': /* IPv4 */ - addressfamily = AF_INET; - break; - - case '6': /* IPv6 */ - addressfamily = AF_INET6; - break; - - case 1: /* help */ - usage(); - return 0; - - default: - break; - } - } - - argc -= optind - 1; - argv += optind - 1; - - if(argc < 4 || argc > 5) { - fprintf(stderr, "Wrong number of arguments.\n"); - usage(); - return 1; - } - - if(argc > 4) { - initiator = true; - } - - srand(time(NULL)); - -#ifdef HAVE_LINUX - - if(tun) { - in = out = open("/dev/net/tun", O_RDWR | O_NONBLOCK); - - if(in < 0) { - fprintf(stderr, "Could not open tun device: %s\n", strerror(errno)); - return 1; - } - - struct ifreq ifr = { - .ifr_flags = IFF_TUN - }; - - if(ioctl(in, TUNSETIFF, &ifr)) { - fprintf(stderr, "Could not configure tun interface: %s\n", strerror(errno)); - return 1; - } - - ifr.ifr_name[IFNAMSIZ - 1] = 0; - fprintf(stderr, "Using tun interface %s\n", ifr.ifr_name); - } - -#endif - -#ifdef HAVE_MINGW - static struct WSAData wsa_state; - - if(WSAStartup(MAKEWORD(2, 2), &wsa_state)) { - return 1; - } - -#endif - - struct addrinfo *ai, hint; - memset(&hint, 0, sizeof(hint)); - - hint.ai_family = addressfamily; - hint.ai_socktype = datagram ? SOCK_DGRAM : SOCK_STREAM; - hint.ai_protocol = datagram ? IPPROTO_UDP : IPPROTO_TCP; - hint.ai_flags = initiator ? 0 : AI_PASSIVE; - - if(getaddrinfo(initiator ? argv[3] : NULL, initiator ? argv[4] : argv[3], &hint, &ai) || !ai) { - fprintf(stderr, "getaddrinfo() failed: %s\n", sockstrerror(sockerrno)); - return 1; - } - - int sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); - - if(sock < 0) { - fprintf(stderr, "Could not create socket: %s\n", sockstrerror(sockerrno)); - return 1; - } - - int one = 1; - setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof(one)); - - if(initiator) { - if(connect(sock, ai->ai_addr, ai->ai_addrlen)) { - fprintf(stderr, "Could not connect to peer: %s\n", sockstrerror(sockerrno)); - return 1; - } - - fprintf(stderr, "Connected\n"); - } else { - if(bind(sock, ai->ai_addr, ai->ai_addrlen)) { - fprintf(stderr, "Could not bind socket: %s\n", sockstrerror(sockerrno)); - return 1; - } - - if(!datagram) { - if(listen(sock, 1)) { - fprintf(stderr, "Could not listen on socket: %s\n", sockstrerror(sockerrno)); - return 1; - } - - fprintf(stderr, "Listening...\n"); - - sock = accept(sock, NULL, NULL); - - if(sock < 0) { - fprintf(stderr, "Could not accept connection: %s\n", sockstrerror(sockerrno)); - return 1; - } - } else { - fprintf(stderr, "Listening...\n"); - - char buf[65536]; - struct sockaddr addr; - socklen_t addrlen = sizeof(addr); - - if(recvfrom(sock, buf, sizeof(buf), MSG_PEEK, &addr, &addrlen) <= 0) { - fprintf(stderr, "Could not read from socket: %s\n", sockstrerror(sockerrno)); - return 1; - } - - if(connect(sock, &addr, addrlen)) { - fprintf(stderr, "Could not accept connection: %s\n", sockstrerror(sockerrno)); - return 1; - } - } - - fprintf(stderr, "Connected\n"); - } - - crypto_init(); - - FILE *fp = fopen(argv[1], "r"); - - if(!fp) { - fprintf(stderr, "Could not open %s: %s\n", argv[1], strerror(errno)); - return 1; - } - - if(!(mykey = ecdsa_read_pem_private_key(fp))) { - return 1; - } - - fclose(fp); - - fp = fopen(argv[2], "r"); - - if(!fp) { - fprintf(stderr, "Could not open %s: %s\n", argv[2], strerror(errno)); - return 1; - } - - if(!(hiskey = ecdsa_read_pem_public_key(fp))) { - return 1; - } - - fclose(fp); - - if(verbose) { - fprintf(stderr, "Keys loaded\n"); - } - - sptps_t s; - - if(!sptps_start(&s, &sock, initiator, datagram, mykey, hiskey, "sptps_test", 10, send_data, receive_record)) { - return 1; - } - - while(true) { - if(writeonly && readonly) { - break; - } - - char buf[65535] = ""; - - fd_set fds; - FD_ZERO(&fds); -#ifndef HAVE_MINGW - - if(!readonly && s.instate) { - FD_SET(in, &fds); - } - -#endif - FD_SET(sock, &fds); - - if(select(sock + 1, &fds, NULL, NULL, NULL) <= 0) { - return 1; - } - - if(FD_ISSET(in, &fds)) { - ssize_t len = read(in, buf, sizeof(buf)); - - if(len < 0) { - fprintf(stderr, "Could not read from stdin: %s\n", strerror(errno)); - return 1; - } - - if(len == 0) { - if(quit) { - break; - } - - readonly = true; - continue; - } - - if(special && buf[0] == '#') { - s.outseqno = atoi(buf + 1); - } - - if(special && buf[0] == '^') { - sptps_send_record(&s, SPTPS_HANDSHAKE, NULL, 0); - } else if(special && buf[0] == '$') { - sptps_force_kex(&s); - - if(len > 1) { - sptps_send_record(&s, 0, buf, len); - } - } else if(!sptps_send_record(&s, buf[0] == '!' ? 1 : 0, buf, (len == 1 && buf[0] == '\n') ? 0 : buf[0] == '*' ? sizeof(buf) : (size_t)len)) { - return 1; - } - } - - if(FD_ISSET(sock, &fds)) { - ssize_t len = recv(sock, buf, sizeof(buf), 0); - - if(len < 0) { - fprintf(stderr, "Could not read from socket: %s\n", sockstrerror(sockerrno)); - return 1; - } - - if(len == 0) { - fprintf(stderr, "Connection terminated by peer.\n"); - break; - } - - if(verbose) { - char hex[len * 2 + 1]; - bin2hex(buf, hex, len); - fprintf(stderr, "Received %d bytes of data:\n%s\n", (int)len, hex); - } - - if(packetloss && (rand() % 100) < packetloss) { - if(verbose) { - fprintf(stderr, "Dropped.\n"); - } - - continue; - } - - char *bufp = buf; - - while(len) { - size_t done = sptps_receive_data(&s, bufp, len); - - if(!done) { - if(!datagram) { - return 1; - } - } - - bufp += done; - len -= done; - } - } - } - - if(!sptps_stop(&s)) { - return 1; - } - - return 0; -} diff --git a/src/subnet.c b/src/subnet.c index 4fefda6..154fd80 100644 --- a/src/subnet.c +++ b/src/subnet.c @@ -1,6 +1,6 @@ /* subnet.c -- handle subnet lookups and lists - Copyright (C) 2000-2017 Guus Sliepen , + Copyright (C) 2000-2019 Guus Sliepen , 2000-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -20,66 +20,164 @@ #include "system.h" -#include "splay_tree.h" -#include "control_common.h" +#include "avl_tree.h" #include "device.h" -#include "hash.h" #include "logger.h" -#include "names.h" #include "net.h" #include "netutl.h" #include "node.h" -#include "script.h" +#include "process.h" #include "subnet.h" #include "utils.h" #include "xalloc.h" /* lists type of subnet */ -splay_tree_t *subnet_tree; +avl_tree_t *subnet_tree; /* Subnet lookup cache */ -static hash_t *ipv4_cache; -static hash_t *ipv6_cache; -static hash_t *mac_cache; +static ipv4_t cache_ipv4_address[2]; +static subnet_t *cache_ipv4_subnet[2]; +static bool cache_ipv4_valid[2]; +static int cache_ipv4_slot; + +static ipv6_t cache_ipv6_address[2]; +static subnet_t *cache_ipv6_subnet[2]; +static bool cache_ipv6_valid[2]; +static int cache_ipv6_slot; + +static mac_t cache_mac_address[2]; +static subnet_t *cache_mac_subnet[2]; +static bool cache_mac_valid[2]; +static int cache_mac_slot; void subnet_cache_flush(void) { - hash_clear(ipv4_cache); - hash_clear(ipv6_cache); - hash_clear(mac_cache); + cache_ipv4_valid[0] = cache_ipv4_valid[1] = false; + cache_ipv6_valid[0] = cache_ipv6_valid[1] = false; + cache_mac_valid[0] = cache_mac_valid[1] = false; +} + +/* Subnet comparison */ + +static int subnet_compare_mac(const subnet_t *a, const subnet_t *b) { + int result; + + result = memcmp(&a->net.mac.address, &b->net.mac.address, sizeof(mac_t)); + + if(result) { + return result; + } + + result = a->weight - b->weight; + + if(result || !a->owner || !b->owner) { + return result; + } + + return strcmp(a->owner->name, b->owner->name); +} + +static int subnet_compare_ipv4(const subnet_t *a, const subnet_t *b) { + int result; + + result = b->net.ipv4.prefixlength - a->net.ipv4.prefixlength; + + if(result) { + return result; + } + + result = memcmp(&a->net.ipv4.address, &b->net.ipv4.address, sizeof(ipv4_t)); + + if(result) { + return result; + } + + result = a->weight - b->weight; + + if(result || !a->owner || !b->owner) { + return result; + } + + return strcmp(a->owner->name, b->owner->name); +} + +static int subnet_compare_ipv6(const subnet_t *a, const subnet_t *b) { + int result; + + result = b->net.ipv6.prefixlength - a->net.ipv6.prefixlength; + + if(result) { + return result; + } + + result = memcmp(&a->net.ipv6.address, &b->net.ipv6.address, sizeof(ipv6_t)); + + if(result) { + return result; + } + + result = a->weight - b->weight; + + if(result || !a->owner || !b->owner) { + return result; + } + + return strcmp(a->owner->name, b->owner->name); +} + +int subnet_compare(const subnet_t *a, const subnet_t *b) { + int result; + + result = a->type - b->type; + + if(result) { + return result; + } + + switch(a->type) { + case SUBNET_MAC: + return subnet_compare_mac(a, b); + + case SUBNET_IPV4: + return subnet_compare_ipv4(a, b); + + case SUBNET_IPV6: + return subnet_compare_ipv6(a, b); + + default: + logger(LOG_ERR, "subnet_compare() was called with unknown subnet type %d, exitting!", + a->type); + exit(0); + } + + return 0; } /* Initialising trees */ void init_subnets(void) { - subnet_tree = splay_alloc_tree((splay_compare_t) subnet_compare, (splay_action_t) free_subnet); + subnet_tree = avl_alloc_tree((avl_compare_t) subnet_compare, (avl_action_t) free_subnet); - ipv4_cache = hash_alloc(0x100, sizeof(ipv4_t)); - ipv6_cache = hash_alloc(0x100, sizeof(ipv6_t)); - mac_cache = hash_alloc(0x100, sizeof(mac_t)); + subnet_cache_flush(); } void exit_subnets(void) { - splay_delete_tree(subnet_tree); - - hash_free(ipv4_cache); - hash_free(ipv6_cache); - hash_free(mac_cache); + avl_delete_tree(subnet_tree); } -splay_tree_t *new_subnet_tree(void) { - return splay_alloc_tree((splay_compare_t) subnet_compare, NULL); +avl_tree_t *new_subnet_tree(void) { + return avl_alloc_tree((avl_compare_t) subnet_compare, NULL); } -void free_subnet_tree(splay_tree_t *subnet_tree) { - splay_delete_tree(subnet_tree); +void free_subnet_tree(avl_tree_t *subnet_tree) { + avl_delete_tree(subnet_tree); } /* Allocating and freeing space for subnets */ subnet_t *new_subnet(void) { - return xzalloc(sizeof(subnet_t)); + return xmalloc_and_zero(sizeof(subnet_t)); } void free_subnet(subnet_t *subnet) { @@ -91,43 +189,271 @@ void free_subnet(subnet_t *subnet) { void subnet_add(node_t *n, subnet_t *subnet) { subnet->owner = n; - splay_insert(subnet_tree, subnet); - - if(n) { - splay_insert(n->subnet_tree, subnet); - } + avl_insert(subnet_tree, subnet); + avl_insert(n->subnet_tree, subnet); subnet_cache_flush(); } void subnet_del(node_t *n, subnet_t *subnet) { - if(n) { - splay_delete(n->subnet_tree, subnet); - } - - splay_delete(subnet_tree, subnet); + avl_delete(n->subnet_tree, subnet); + avl_delete(subnet_tree, subnet); subnet_cache_flush(); } +/* Ascii representation of subnets */ + +bool str2net(subnet_t *subnet, const char *subnetstr) { + char str[1024]; + strncpy(str, subnetstr, sizeof(str)); + str[sizeof(str) - 1] = 0; + int consumed; + + int weight = 10; + char *weight_separator = strchr(str, '#'); + + if(weight_separator) { + char *weight_str = weight_separator + 1; + + if(sscanf(weight_str, "%d%n", &weight, &consumed) < 1) { + return false; + } + + if(weight_str[consumed]) { + return false; + } + + *weight_separator = 0; + } + + int prefixlength = -1; + char *prefixlength_separator = strchr(str, '/'); + + if(prefixlength_separator) { + char *prefixlength_str = prefixlength_separator + 1; + + if(sscanf(prefixlength_str, "%d%n", &prefixlength, &consumed) < 1) { + return false; + } + + if(prefixlength_str[consumed]) { + return false; + } + + *prefixlength_separator = 0; + + if(prefixlength < 0) { + return false; + } + } + + uint16_t x[8]; + + if(sscanf(str, "%hx:%hx:%hx:%hx:%hx:%hx%n", &x[0], &x[1], &x[2], &x[3], &x[4], &x[5], &consumed) >= 6 && !str[consumed]) { + /* + Normally we should check that each part has two digits to prevent ambiguities. + However, in old tinc versions net2str() will aggressively return MAC addresses with one-digit parts, + so we have to accept them otherwise we would be unable to parse ADD_SUBNET messages. + */ + if(prefixlength >= 0) { + return false; + } + + subnet->type = SUBNET_MAC; + subnet->weight = weight; + + for(int i = 0; i < 6; i++) { + subnet->net.mac.address.x[i] = x[i]; + } + + return true; + } + + if(sscanf(str, "%hu.%hu.%hu.%hu%n", &x[0], &x[1], &x[2], &x[3], &consumed) >= 4 && !str[consumed]) { + if(prefixlength == -1) { + prefixlength = 32; + } + + if(prefixlength > 32) { + return false; + } + + subnet->type = SUBNET_IPV4; + subnet->net.ipv4.prefixlength = prefixlength; + subnet->weight = weight; + + for(int i = 0; i < 4; i++) { + if(x[i] > 255) { + return false; + } + + subnet->net.ipv4.address.x[i] = x[i]; + } + + return true; + } + + /* IPv6 */ + + char *last_colon = strrchr(str, ':'); + + if(last_colon && sscanf(last_colon, ":%hu.%hu.%hu.%hu%n", &x[0], &x[1], &x[2], &x[3], &consumed) >= 4 && !last_colon[consumed]) { + /* Dotted quad suffix notation, convert to standard IPv6 notation */ + for(int i = 0; i < 4; i++) + if(x[i] > 255) { + return false; + } + + snprintf(last_colon, sizeof(str) - (last_colon - str), ":%02x%02x:%02x%02x", x[0], x[1], x[2], x[3]); + } + + char *double_colon = strstr(str, "::"); + + if(double_colon) { + /* Figure out how many zero groups we need to expand */ + int zero_group_count = 8; + + for(const char *cur = str; *cur; cur++) + if(*cur != ':') { + zero_group_count--; + + while(cur[1] && cur[1] != ':') { + cur++; + } + } + + if(zero_group_count < 1) { + return false; + } + + /* Split the double colon in the middle to make room for zero groups */ + double_colon++; + memmove(double_colon + (zero_group_count * 2 - 1), double_colon, strlen(double_colon) + 1); + + /* Write zero groups in the resulting gap, overwriting the second colon */ + for(int i = 0; i < zero_group_count; i++) { + memcpy(&double_colon[i * 2], "0:", 2); + } + + /* Remove any leading or trailing colons */ + if(str[0] == ':') { + memmove(&str[0], &str[1], strlen(&str[1]) + 1); + } + + if(str[strlen(str) - 1] == ':') { + str[strlen(str) - 1] = 0; + } + } + + if(sscanf(str, "%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx%n", + &x[0], &x[1], &x[2], &x[3], &x[4], &x[5], &x[6], &x[7], &consumed) >= 8 && !str[consumed]) { + if(prefixlength == -1) { + prefixlength = 128; + } + + if(prefixlength > 128) { + return false; + } + + subnet->type = SUBNET_IPV6; + subnet->net.ipv6.prefixlength = prefixlength; + subnet->weight = weight; + + for(int i = 0; i < 8; i++) { + subnet->net.ipv6.address.x[i] = htons(x[i]); + } + + return true; + } + + return false; +} + +bool net2str(char *netstr, int len, const subnet_t *subnet) { + if(!netstr || !subnet) { + logger(LOG_ERR, "net2str() was called with netstr=%p, subnet=%p!", (void *)netstr, (void *)subnet); + return false; + } + + switch(subnet->type) { + case SUBNET_MAC: + snprintf(netstr, len, "%x:%x:%x:%x:%x:%x#%d", + subnet->net.mac.address.x[0], + subnet->net.mac.address.x[1], + subnet->net.mac.address.x[2], + subnet->net.mac.address.x[3], + subnet->net.mac.address.x[4], + subnet->net.mac.address.x[5], + subnet->weight); + break; + + case SUBNET_IPV4: + snprintf(netstr, len, "%u.%u.%u.%u/%d#%d", + subnet->net.ipv4.address.x[0], + subnet->net.ipv4.address.x[1], + subnet->net.ipv4.address.x[2], + subnet->net.ipv4.address.x[3], + subnet->net.ipv4.prefixlength, + subnet->weight); + break; + + case SUBNET_IPV6: + snprintf(netstr, len, "%x:%x:%x:%x:%x:%x:%x:%x/%d#%d", + ntohs(subnet->net.ipv6.address.x[0]), + ntohs(subnet->net.ipv6.address.x[1]), + ntohs(subnet->net.ipv6.address.x[2]), + ntohs(subnet->net.ipv6.address.x[3]), + ntohs(subnet->net.ipv6.address.x[4]), + ntohs(subnet->net.ipv6.address.x[5]), + ntohs(subnet->net.ipv6.address.x[6]), + ntohs(subnet->net.ipv6.address.x[7]), + subnet->net.ipv6.prefixlength, + subnet->weight); + break; + + default: + logger(LOG_ERR, + "net2str() was called with unknown subnet type %d, exiting!", + subnet->type); + exit(0); + } + + return true; +} + /* Subnet lookup routines */ subnet_t *lookup_subnet(const node_t *owner, const subnet_t *subnet) { - return splay_search(owner->subnet_tree, subnet); + return avl_search(owner->subnet_tree, subnet); } subnet_t *lookup_subnet_mac(const node_t *owner, const mac_t *address) { - subnet_t *r = NULL; + subnet_t *p, *r = NULL; + avl_node_t *n; + int i; // Check if this address is cached - if((r = hash_search(mac_cache, address))) { - return r; + for(i = 0; i < 2; i++) { + if(!cache_mac_valid[i]) { + continue; + } + + if(owner && cache_mac_subnet[i] && cache_mac_subnet[i]->owner != owner) { + continue; + } + + if(!memcmp(address, &cache_mac_address[i], sizeof(*address))) { + return cache_mac_subnet[i]; + } } // Search all subnets for a matching one - for splay_each(subnet_t, p, owner ? owner->subnet_tree : subnet_tree) { + for(n = owner ? owner->subnet_tree->head : subnet_tree->head; n; n = n->next) { + p = n->data; + if(!p || p->type != SUBNET_MAC) { continue; } @@ -135,7 +461,7 @@ subnet_t *lookup_subnet_mac(const node_t *owner, const mac_t *address) { if(!memcmp(address, &p->net.mac.address, sizeof(*address))) { r = p; - if(!p->owner || p->owner->status.reachable) { + if(p->owner->status.reachable) { break; } } @@ -143,25 +469,36 @@ subnet_t *lookup_subnet_mac(const node_t *owner, const mac_t *address) { // Cache the result - if(r) { - hash_insert(mac_cache, address, r); - } + cache_mac_slot = !cache_mac_slot; + memcpy(&cache_mac_address[cache_mac_slot], address, sizeof(*address)); + cache_mac_subnet[cache_mac_slot] = r; + cache_mac_valid[cache_mac_slot] = true; return r; } subnet_t *lookup_subnet_ipv4(const ipv4_t *address) { - subnet_t *r = NULL; + subnet_t *p, *r = NULL; + avl_node_t *n; + int i; // Check if this address is cached - if((r = hash_search(ipv4_cache, address))) { - return r; + for(i = 0; i < 2; i++) { + if(!cache_ipv4_valid[i]) { + continue; + } + + if(!memcmp(address, &cache_ipv4_address[i], sizeof(*address))) { + return cache_ipv4_subnet[i]; + } } // Search all subnets for a matching one - for splay_each(subnet_t, p, subnet_tree) { + for(n = subnet_tree->head; n; n = n->next) { + p = n->data; + if(!p || p->type != SUBNET_IPV4) { continue; } @@ -169,7 +506,7 @@ subnet_t *lookup_subnet_ipv4(const ipv4_t *address) { if(!maskcmp(address, &p->net.ipv4.address, p->net.ipv4.prefixlength)) { r = p; - if(!p->owner || p->owner->status.reachable) { + if(p->owner->status.reachable) { break; } } @@ -177,25 +514,36 @@ subnet_t *lookup_subnet_ipv4(const ipv4_t *address) { // Cache the result - if(r) { - hash_insert(ipv4_cache, address, r); - } + cache_ipv4_slot = !cache_ipv4_slot; + memcpy(&cache_ipv4_address[cache_ipv4_slot], address, sizeof(*address)); + cache_ipv4_subnet[cache_ipv4_slot] = r; + cache_ipv4_valid[cache_ipv4_slot] = true; return r; } subnet_t *lookup_subnet_ipv6(const ipv6_t *address) { - subnet_t *r = NULL; + subnet_t *p, *r = NULL; + avl_node_t *n; + int i; // Check if this address is cached - if((r = hash_search(ipv6_cache, address))) { - return r; + for(i = 0; i < 2; i++) { + if(!cache_ipv6_valid[i]) { + continue; + } + + if(!memcmp(address, &cache_ipv6_address[i], sizeof(*address))) { + return cache_ipv6_subnet[i]; + } } // Search all subnets for a matching one - for splay_each(subnet_t, p, subnet_tree) { + for(n = subnet_tree->head; n; n = n->next) { + p = n->data; + if(!p || p->type != SUBNET_IPV6) { continue; } @@ -203,7 +551,7 @@ subnet_t *lookup_subnet_ipv6(const ipv6_t *address) { if(!maskcmp(address, &p->net.ipv6.address, p->net.ipv6.prefixlength)) { r = p; - if(!p->owner || p->owner->status.reachable) { + if(p->owner->status.reachable) { break; } } @@ -211,39 +559,45 @@ subnet_t *lookup_subnet_ipv6(const ipv6_t *address) { // Cache the result - if(r) { - hash_insert(ipv6_cache, address, r); - } + cache_ipv6_slot = !cache_ipv6_slot; + memcpy(&cache_ipv6_address[cache_ipv6_slot], address, sizeof(*address)); + cache_ipv6_subnet[cache_ipv6_slot] = r; + cache_ipv6_valid[cache_ipv6_slot] = true; return r; } void subnet_update(node_t *owner, subnet_t *subnet, bool up) { + avl_node_t *node; + int i; + char *envp[10] = {NULL}; char netstr[MAXNETSTR]; char *name, *address, *port; char empty[] = ""; // Prepare environment variables to be passed to the script - environment_t env; - environment_init(&env); - environment_add(&env, "NODE=%s", owner->name); + xasprintf(&envp[0], "NETNAME=%s", netname ? netname : ""); + xasprintf(&envp[1], "DEVICE=%s", device ? device : ""); + xasprintf(&envp[2], "INTERFACE=%s", iface ? iface : ""); + xasprintf(&envp[3], "NODE=%s", owner->name); + xasprintf(&envp[4], "NAME=%s", myself->name); if(owner != myself) { sockaddr2str(&owner->address, &address, &port); - environment_add(&env, "REMOTEADDRESS=%s", address); - environment_add(&env, "REMOTEPORT=%s", port); + // 5 and 6 are reserved for SUBNET and WEIGHT + xasprintf(&envp[7], "REMOTEADDRESS=%s", address); + xasprintf(&envp[8], "REMOTEPORT=%s", port); free(port); free(address); } - int env_subnet = environment_add(&env, NULL); - int env_weight = environment_add(&env, NULL); - name = up ? "subnet-up" : "subnet-down"; if(!subnet) { - for splay_each(subnet_t, subnet, owner->subnet_tree) { + for(node = owner->subnet_tree->head; node; node = node->next) { + subnet = node->data; + if(!net2str(netstr, sizeof(netstr), subnet)) { continue; } @@ -258,10 +612,13 @@ void subnet_update(node_t *owner, subnet_t *subnet, bool up) { } // Prepare the SUBNET and WEIGHT variables - environment_update(&env, env_subnet, "SUBNET=%s", netstr); - environment_update(&env, env_weight, "WEIGHT=%s", weight); + free(envp[5]); + free(envp[6]); - execute_script(name, &env); + xasprintf(&envp[5], "SUBNET=%s", netstr); + xasprintf(&envp[6], "WEIGHT=%s", weight); + + execute_script(name, envp); } } else { if(net2str(netstr, sizeof(netstr), subnet)) { @@ -275,28 +632,34 @@ void subnet_update(node_t *owner, subnet_t *subnet, bool up) { } // Prepare the SUBNET and WEIGHT variables - environment_update(&env, env_subnet, "SUBNET=%s", netstr); - environment_update(&env, env_weight, "WEIGHT=%s", weight); + xasprintf(&envp[5], "SUBNET=%s", netstr); + xasprintf(&envp[6], "WEIGHT=%s", weight); - execute_script(name, &env); + execute_script(name, envp); } } - environment_exit(&env); + for(i = 0; i < 9; i++) { + free(envp[i]); + } } -bool dump_subnets(connection_t *c) { - for splay_each(subnet_t, subnet, subnet_tree) { - char netstr[MAXNETSTR]; +void dump_subnets(void) { + char netstr[MAXNETSTR]; + subnet_t *subnet; + avl_node_t *node; + + logger(LOG_DEBUG, "Subnet list:"); + + for(node = subnet_tree->head; node; node = node->next) { + subnet = node->data; if(!net2str(netstr, sizeof(netstr), subnet)) { continue; } - send_request(c, "%d %d %s %s", - CONTROL, REQ_DUMP_SUBNETS, - netstr, subnet->owner ? subnet->owner->name : "(broadcast)"); + logger(LOG_DEBUG, " %s owner %s", netstr, subnet->owner->name); } - return send_request(c, "%d %d", CONTROL, REQ_DUMP_SUBNETS); + logger(LOG_DEBUG, "End of subnet list."); } diff --git a/src/subnet.h b/src/subnet.h index cfdf2d0..6fecca3 100644 --- a/src/subnet.h +++ b/src/subnet.h @@ -3,7 +3,7 @@ /* subnet.h -- header for subnet.c - Copyright (C) 2000-2012 Guus Sliepen , + Copyright (C) 2000-2009 Guus Sliepen , 2000-2005 Ivo Timmermans This program is free software; you can redistribute it and/or modify @@ -22,13 +22,12 @@ */ #include "net.h" -#include "node.h" typedef enum subnet_type_t { SUBNET_MAC = 0, SUBNET_IPV4, SUBNET_IPV6, - SUBNET_TYPES /* Guardian */ + SUBNET_TYPES, /* Guardian */ } subnet_type_t; typedef struct subnet_mac_t { @@ -45,12 +44,14 @@ typedef struct subnet_ipv6_t { int prefixlength; } subnet_ipv6_t; -typedef struct subnet_t { - struct node_t *owner; /* the owner of this subnet */ +#include "node.h" - subnet_type_t type; /* subnet type (IPv4? IPv6? MAC? something even weirder?) */ - time_t expires; /* expiry time */ - int weight; /* weight (higher value is higher priority) */ +typedef struct subnet_t { + struct node_t *owner; /* the owner of this subnet */ + + subnet_type_t type; /* subnet type (IPv4? IPv6? MAC? something even weirder?) */ + time_t expires; /* expiry time */ + int weight; /* weight (higher value is higher priority) */ /* And now for the actual subnet: */ @@ -63,29 +64,24 @@ typedef struct subnet_t { #define MAXNETSTR 64 -extern splay_tree_t *subnet_tree; +extern avl_tree_t *subnet_tree; -extern int subnet_compare(const struct subnet_t *a, const struct subnet_t *b); extern subnet_t *new_subnet(void) __attribute__((__malloc__)); extern void free_subnet(subnet_t *subnet); extern void init_subnets(void); extern void exit_subnets(void); -extern splay_tree_t *new_subnet_tree(void) __attribute__((__malloc__)); -extern void free_subnet_tree(splay_tree_t *); +extern avl_tree_t *new_subnet_tree(void) __attribute__((__malloc__)); +extern void free_subnet_tree(avl_tree_t *subnet_tree); extern void subnet_add(struct node_t *owner, subnet_t *subnet); extern void subnet_del(struct node_t *owner, subnet_t *subnet); extern void subnet_update(struct node_t *owner, subnet_t *subnet, bool up); -extern int maskcmp(const void *a, const void *b, int masklen); -extern void maskcpy(void *dest, const void *src, int masklen, int len); -extern void mask(void *mask, int masklen, int len); -extern bool maskcheck(const void *mask, int masklen, int len); extern bool net2str(char *netstr, int len, const subnet_t *subnet); extern bool str2net(subnet_t *subnet, const char *netstr); extern subnet_t *lookup_subnet(const struct node_t *owner, const subnet_t *subnet); extern subnet_t *lookup_subnet_mac(const struct node_t *owner, const mac_t *address); extern subnet_t *lookup_subnet_ipv4(const ipv4_t *address); extern subnet_t *lookup_subnet_ipv6(const ipv6_t *address); -extern bool dump_subnets(struct connection_t *c); +extern void dump_subnets(void); extern void subnet_cache_flush(void); #endif diff --git a/src/subnet_parse.c b/src/subnet_parse.c deleted file mode 100644 index d5b84eb..0000000 --- a/src/subnet_parse.c +++ /dev/null @@ -1,490 +0,0 @@ -/* - subnet_parse.c -- handle subnet parsing - Copyright (C) 2000-2012 Guus Sliepen , - 2000-2005 Ivo Timmermans - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include "logger.h" -#include "net.h" -#include "netutl.h" -#include "subnet.h" -#include "utils.h" -#include "xalloc.h" - -/* Changing this default will affect ADD_SUBNET messages - beware of inconsistencies between versions */ -static const int DEFAULT_WEIGHT = 10; - -/* Subnet mask handling */ - -int maskcmp(const void *va, const void *vb, int masklen) { - int i, m, result; - const char *a = va; - const char *b = vb; - - for(m = masklen, i = 0; m >= 8; m -= 8, i++) { - result = a[i] - b[i]; - - if(result) { - return result; - } - } - - if(m) - return (a[i] & (0x100 - (1 << (8 - m)))) - - (b[i] & (0x100 - (1 << (8 - m)))); - - return 0; -} - -void mask(void *va, int masklen, int len) { - int i; - char *a = va; - - i = masklen / 8; - masklen %= 8; - - if(masklen) { - a[i++] &= (0x100 - (1 << (8 - masklen))); - } - - for(; i < len; i++) { - a[i] = 0; - } -} - -void maskcpy(void *va, const void *vb, int masklen, int len) { - int i, m; - char *a = va; - const char *b = vb; - - for(m = masklen, i = 0; m >= 8; m -= 8, i++) { - a[i] = b[i]; - } - - if(m) { - a[i] = b[i] & (0x100 - (1 << (8 - m))); - i++; - } - - for(; i < len; i++) { - a[i] = 0; - } -} - -bool maskcheck(const void *va, int masklen, int len) { - int i; - const char *a = va; - - i = masklen / 8; - masklen %= 8; - - if(masklen && a[i++] & (0xff >> masklen)) { - return false; - } - - for(; i < len; i++) - if(a[i] != 0) { - return false; - } - - return true; -} - -/* Subnet comparison */ - -static int subnet_compare_mac(const subnet_t *a, const subnet_t *b) { - int result; - - result = memcmp(&a->net.mac.address, &b->net.mac.address, sizeof(a->net.mac.address)); - - if(result) { - return result; - } - - result = a->weight - b->weight; - - if(result || !a->owner || !b->owner) { - return result; - } - - return strcmp(a->owner->name, b->owner->name); -} - -static int subnet_compare_ipv4(const subnet_t *a, const subnet_t *b) { - int result; - - result = b->net.ipv4.prefixlength - a->net.ipv4.prefixlength; - - if(result) { - return result; - } - - result = memcmp(&a->net.ipv4.address, &b->net.ipv4.address, sizeof(ipv4_t)); - - if(result) { - return result; - } - - result = a->weight - b->weight; - - if(result || !a->owner || !b->owner) { - return result; - } - - return strcmp(a->owner->name, b->owner->name); -} - -static int subnet_compare_ipv6(const subnet_t *a, const subnet_t *b) { - int result; - - result = b->net.ipv6.prefixlength - a->net.ipv6.prefixlength; - - if(result) { - return result; - } - - result = memcmp(&a->net.ipv6.address, &b->net.ipv6.address, sizeof(ipv6_t)); - - if(result) { - return result; - } - - result = a->weight - b->weight; - - if(result || !a->owner || !b->owner) { - return result; - } - - return strcmp(a->owner->name, b->owner->name); -} - -int subnet_compare(const subnet_t *a, const subnet_t *b) { - int result; - - result = a->type - b->type; - - if(result) { - return result; - } - - switch(a->type) { - case SUBNET_MAC: - return subnet_compare_mac(a, b); - - case SUBNET_IPV4: - return subnet_compare_ipv4(a, b); - - case SUBNET_IPV6: - return subnet_compare_ipv6(a, b); - - default: - logger(DEBUG_ALWAYS, LOG_ERR, "subnet_compare() was called with unknown subnet type %d, exitting!", a->type); - exit(1); - } - - return 0; -} - -/* Ascii representation of subnets */ - -bool str2net(subnet_t *subnet, const char *subnetstr) { - char str[1024]; - strncpy(str, subnetstr, sizeof(str)); - str[sizeof(str) - 1] = 0; - int consumed; - - int weight = DEFAULT_WEIGHT; - char *weight_separator = strchr(str, '#'); - - if(weight_separator) { - char *weight_str = weight_separator + 1; - - if(sscanf(weight_str, "%d%n", &weight, &consumed) < 1) { - return false; - } - - if(weight_str[consumed]) { - return false; - } - - *weight_separator = 0; - } - - int prefixlength = -1; - char *prefixlength_separator = strchr(str, '/'); - - if(prefixlength_separator) { - char *prefixlength_str = prefixlength_separator + 1; - - if(sscanf(prefixlength_str, "%d%n", &prefixlength, &consumed) < 1) { - return false; - } - - if(prefixlength_str[consumed]) { - return false; - } - - *prefixlength_separator = 0; - - if(prefixlength < 0) { - return false; - } - } - - uint16_t x[8]; - - if(sscanf(str, "%hx:%hx:%hx:%hx:%hx:%hx%n", &x[0], &x[1], &x[2], &x[3], &x[4], &x[5], &consumed) >= 6 && !str[consumed]) { - /* - Normally we should check that each part has two digits to prevent ambiguities. - However, in old tinc versions net2str() will aggressively return MAC addresses with one-digit parts, - so we have to accept them otherwise we would be unable to parse ADD_SUBNET messages. - */ - if(prefixlength >= 0) { - return false; - } - - subnet->type = SUBNET_MAC; - subnet->weight = weight; - - for(int i = 0; i < 6; i++) { - subnet->net.mac.address.x[i] = x[i]; - } - - return true; - } - - if(sscanf(str, "%hu.%hu.%hu.%hu%n", &x[0], &x[1], &x[2], &x[3], &consumed) >= 4 && !str[consumed]) { - if(prefixlength == -1) { - prefixlength = 32; - } - - if(prefixlength > 32) { - return false; - } - - subnet->type = SUBNET_IPV4; - subnet->net.ipv4.prefixlength = prefixlength; - subnet->weight = weight; - - for(int i = 0; i < 4; i++) { - if(x[i] > 255) { - return false; - } - - subnet->net.ipv4.address.x[i] = x[i]; - } - - return true; - } - - /* IPv6 */ - - char *last_colon = strrchr(str, ':'); - - if(last_colon && sscanf(last_colon, ":%hu.%hu.%hu.%hu%n", &x[0], &x[1], &x[2], &x[3], &consumed) >= 4 && !last_colon[consumed]) { - /* Dotted quad suffix notation, convert to standard IPv6 notation */ - for(int i = 0; i < 4; i++) - if(x[i] > 255) { - return false; - } - - snprintf(last_colon, sizeof(str) - (last_colon - str), ":%02x%02x:%02x%02x", x[0], x[1], x[2], x[3]); - } - - char *double_colon = strstr(str, "::"); - - if(double_colon) { - /* Figure out how many zero groups we need to expand */ - int zero_group_count = 8; - - for(const char *cur = str; *cur; cur++) - if(*cur != ':') { - zero_group_count--; - - while(cur[1] && cur[1] != ':') { - cur++; - } - } - - if(zero_group_count < 1) { - return false; - } - - /* Split the double colon in the middle to make room for zero groups */ - double_colon++; - memmove(double_colon + (zero_group_count * 2 - 1), double_colon, strlen(double_colon) + 1); - - /* Write zero groups in the resulting gap, overwriting the second colon */ - for(int i = 0; i < zero_group_count; i++) { - memcpy(&double_colon[i * 2], "0:", 2); - } - - /* Remove any leading or trailing colons */ - if(str[0] == ':') { - memmove(&str[0], &str[1], strlen(&str[1]) + 1); - } - - if(str[strlen(str) - 1] == ':') { - str[strlen(str) - 1] = 0; - } - } - - if(sscanf(str, "%hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx%n", - &x[0], &x[1], &x[2], &x[3], &x[4], &x[5], &x[6], &x[7], &consumed) >= 8 && !str[consumed]) { - if(prefixlength == -1) { - prefixlength = 128; - } - - if(prefixlength > 128) { - return false; - } - - subnet->type = SUBNET_IPV6; - subnet->net.ipv6.prefixlength = prefixlength; - subnet->weight = weight; - - for(int i = 0; i < 8; i++) { - subnet->net.ipv6.address.x[i] = htons(x[i]); - } - - return true; - } - - return false; -} - -bool net2str(char *netstr, int len, const subnet_t *subnet) { - if(!netstr || !subnet) { - logger(DEBUG_ALWAYS, LOG_ERR, "net2str() was called with netstr=%p, subnet=%p!", (void *)netstr, (void *)subnet); - return false; - } - - int result; - int prefixlength = -1; - - switch(subnet->type) { - case SUBNET_MAC: - result = snprintf(netstr, len, "%02x:%02x:%02x:%02x:%02x:%02x", - subnet->net.mac.address.x[0], - subnet->net.mac.address.x[1], - subnet->net.mac.address.x[2], - subnet->net.mac.address.x[3], - subnet->net.mac.address.x[4], - subnet->net.mac.address.x[5]); - netstr += result; - len -= result; - break; - - case SUBNET_IPV4: - result = snprintf(netstr, len, "%u.%u.%u.%u", - subnet->net.ipv4.address.x[0], - subnet->net.ipv4.address.x[1], - subnet->net.ipv4.address.x[2], - subnet->net.ipv4.address.x[3]); - netstr += result; - len -= result; - prefixlength = subnet->net.ipv4.prefixlength; - - if(prefixlength == 32) { - prefixlength = -1; - } - - break; - - case SUBNET_IPV6: { - /* Find the longest sequence of consecutive zeroes */ - int max_zero_length = 0; - int max_zero_length_index = 0; - int current_zero_length = 0; - int current_zero_length_index = 0; - - for(int i = 0; i < 8; i++) { - if(subnet->net.ipv6.address.x[i] != 0) { - current_zero_length = 0; - } else { - if(current_zero_length == 0) { - current_zero_length_index = i; - } - - current_zero_length++; - - if(current_zero_length > max_zero_length) { - max_zero_length = current_zero_length; - max_zero_length_index = current_zero_length_index; - } - } - } - - /* Print the address */ - for(int i = 0; i < 8;) { - if(max_zero_length > 1 && max_zero_length_index == i) { - /* Shorten the representation as per RFC 5952 */ - const char *const FORMATS[] = { "%.1s", "%.2s", "%.3s" }; - const char *const *format = &FORMATS[0]; - - if(i == 0) { - format++; - } - - if(i + max_zero_length == 8) { - format++; - } - - result = snprintf(netstr, len, *format, ":::"); - i += max_zero_length; - } else { - result = snprintf(netstr, len, "%x:", ntohs(subnet->net.ipv6.address.x[i])); - i++; - } - - netstr += result; - len -= result; - } - - /* Remove the trailing colon */ - netstr--; - len++; - *netstr = 0; - - prefixlength = subnet->net.ipv6.prefixlength; - - if(prefixlength == 128) { - prefixlength = -1; - } - - break; - } - - default: - logger(DEBUG_ALWAYS, LOG_ERR, "net2str() was called with unknown subnet type %d, exiting!", subnet->type); - exit(1); - } - - if(prefixlength >= 0) { - result = snprintf(netstr, len, "/%d", prefixlength); - netstr += result; - len -= result; - } - - if(subnet->weight != DEFAULT_WEIGHT) { - snprintf(netstr, len, "#%d", subnet->weight); - } - - return true; -} diff --git a/src/system.h b/src/system.h index f9675f9..14db7f5 100644 --- a/src/system.h +++ b/src/system.h @@ -4,7 +4,7 @@ /* system.h -- system headers Copyright (C) 1998-2005 Ivo Timmermans - 2003-2016 Guus Sliepen + 2003-2006 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,7 +21,7 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "../config.h" +#include "config.h" #include "have.h" @@ -33,4 +33,8 @@ #include "dropin.h" +#ifndef HAVE_SOCKLEN_T +typedef int socklen_t; +#endif + #endif diff --git a/src/tincctl.c b/src/tincctl.c deleted file mode 100644 index dccd49d..0000000 --- a/src/tincctl.c +++ /dev/null @@ -1,3352 +0,0 @@ -/* - tincctl.c -- Controlling a running tincd - Copyright (C) 2007-2018 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#include - -#ifdef HAVE_READLINE -#include "readline/readline.h" -#include "readline/history.h" -#endif - -#include "xalloc.h" -#include "protocol.h" -#include "control_common.h" -#include "crypto.h" -#include "ecdsagen.h" -#include "fsck.h" -#include "info.h" -#include "invitation.h" -#include "names.h" -#include "rsagen.h" -#include "utils.h" -#include "tincctl.h" -#include "top.h" -#include "version.h" - -#ifndef MSG_NOSIGNAL -#define MSG_NOSIGNAL 0 -#endif - -static char **orig_argv; -static int orig_argc; - -/* If nonzero, display usage information and exit. */ -static bool show_help = false; - -/* If nonzero, print the version on standard output and exit. */ -static bool show_version = false; - -static char *name = NULL; -static char controlcookie[1025]; -char *tinc_conf = NULL; -char *hosts_dir = NULL; -struct timeval now; - -// Horrible global variables... -static int pid = 0; -int fd = -1; -char line[4096]; -static int code; -static int req; -static int result; -bool force = false; -bool tty = true; -bool confbasegiven = false; -bool netnamegiven = false; -char *scriptinterpreter = NULL; -char *scriptextension = ""; -static char *prompt; -char *device = NULL; -char *iface = NULL; -int debug_level = -1; - -static struct option const long_options[] = { - {"batch", no_argument, NULL, 'b'}, - {"config", required_argument, NULL, 'c'}, - {"net", required_argument, NULL, 'n'}, - {"help", no_argument, NULL, 1}, - {"version", no_argument, NULL, 2}, - {"pidfile", required_argument, NULL, 3}, - {"force", no_argument, NULL, 4}, - {NULL, 0, NULL, 0} -}; - -static void version(void) { - printf("%s version %s (built %s %s, protocol %d.%d)\n", PACKAGE, - BUILD_VERSION, BUILD_DATE, BUILD_TIME, PROT_MAJOR, PROT_MINOR); - printf("Copyright (C) 1998-2018 Ivo Timmermans, Guus Sliepen and others.\n" - "See the AUTHORS file for a complete list.\n\n" - "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" - "and you are welcome to redistribute it under certain conditions;\n" - "see the file COPYING for details.\n"); -} - -static void usage(bool status) { - if(status) { - fprintf(stderr, "Try `%s --help\' for more information.\n", program_name); - } else { - printf("Usage: %s [options] command\n\n", program_name); - printf("Valid options are:\n" - " -b, --batch Don't ask for anything (non-interactive mode).\n" - " -c, --config=DIR Read configuration options from DIR.\n" - " -n, --net=NETNAME Connect to net NETNAME.\n" - " --pidfile=FILENAME Read control cookie from FILENAME.\n" - " --force Force some commands to work despite warnings.\n" - " --help Display this help and exit.\n" - " --version Output version information and exit.\n" - "\n" - "Valid commands are:\n" - " init [name] Create initial configuration files.\n" - " get VARIABLE Print current value of VARIABLE\n" - " set VARIABLE VALUE Set VARIABLE to VALUE\n" - " add VARIABLE VALUE Add VARIABLE with the given VALUE\n" - " del VARIABLE [VALUE] Remove VARIABLE [only ones with watching VALUE]\n" - " start [tincd options] Start tincd.\n" - " stop Stop tincd.\n" - " restart [tincd options] Restart tincd.\n" - " reload Partially reload configuration of running tincd.\n" - " pid Show PID of currently running tincd.\n" -#ifdef DISABLE_LEGACY - " generate-keys Generate a new Ed25519 public/private keypair.\n" -#else - " generate-keys [bits] Generate new RSA and Ed25519 public/private keypairs.\n" - " generate-rsa-keys [bits] Generate a new RSA public/private keypair.\n" -#endif - " generate-ed25519-keys Generate a new Ed25519 public/private keypair.\n" - " dump Dump a list of one of the following things:\n" - " [reachable] nodes - all known nodes in the VPN\n" - " edges - all known connections in the VPN\n" - " subnets - all known subnets in the VPN\n" - " connections - all meta connections with ourself\n" - " [di]graph - graph of the VPN in dotty format\n" - " invitations - outstanding invitations\n" - " info NODE|SUBNET|ADDRESS Give information about a particular NODE, SUBNET or ADDRESS.\n" - " purge Purge unreachable nodes\n" - " debug N Set debug level\n" - " retry Retry all outgoing connections\n" - " disconnect NODE Close meta connection with NODE\n" -#ifdef HAVE_CURSES - " top Show real-time statistics\n" -#endif - " pcap [snaplen] Dump traffic in pcap format [up to snaplen bytes per packet]\n" - " log [level] Dump log output [up to the specified level]\n" - " export Export host configuration of local node to standard output\n" - " export-all Export all host configuration files to standard output\n" - " import Import host configuration file(s) from standard input\n" - " exchange Same as export followed by import\n" - " exchange-all Same as export-all followed by import\n" - " invite NODE [...] Generate an invitation for NODE\n" - " join INVITATION Join a VPN using an INVITATION\n" - " network [NETNAME] List all known networks, or switch to the one named NETNAME.\n" - " fsck Check the configuration files for problems.\n" - " sign [FILE] Generate a signed version of a file.\n" - " verify NODE [FILE] Verify that a file was signed by the given NODE.\n" - "\n"); - printf("Report bugs to tinc@tinc-vpn.org.\n"); - } -} - -static bool parse_options(int argc, char **argv) { - int r; - int option_index = 0; - - while((r = getopt_long(argc, argv, "+bc:n:", long_options, &option_index)) != EOF) { - switch(r) { - case 0: /* long option */ - break; - - case 'b': - tty = false; - break; - - case 'c': /* config file */ - confbase = xstrdup(optarg); - confbasegiven = true; - break; - - case 'n': /* net name given */ - netname = xstrdup(optarg); - break; - - case 1: /* show help */ - show_help = true; - break; - - case 2: /* show version */ - show_version = true; - break; - - case 3: /* open control socket here */ - pidfilename = xstrdup(optarg); - break; - - case 4: /* force */ - force = true; - break; - - case '?': /* wrong options */ - usage(true); - return false; - - default: - break; - } - } - - if(!netname && (netname = getenv("NETNAME"))) { - netname = xstrdup(netname); - } - - /* netname "." is special: a "top-level name" */ - - if(netname && (!*netname || !strcmp(netname, "."))) { - free(netname); - netname = NULL; - } - - if(netname && (strpbrk(netname, "\\/") || *netname == '.')) { - fprintf(stderr, "Invalid character in netname!\n"); - return false; - } - - return true; -} - -/* Open a file with the desired permissions, minus the umask. - Also, if we want to create an executable file, we call fchmod() - to set the executable bits. */ - -FILE *fopenmask(const char *filename, const char *mode, mode_t perms) { - mode_t mask = umask(0); - perms &= ~mask; - umask(~perms); - FILE *f = fopen(filename, mode); - - if(!f) { - fprintf(stderr, "Could not open %s: %s\n", filename, strerror(errno)); - return NULL; - } - -#ifdef HAVE_FCHMOD - - if((perms & 0444) && f) { - fchmod(fileno(f), perms); - } - -#endif - umask(mask); - return f; -} - -static void disable_old_keys(const char *filename, const char *what) { - char tmpfile[PATH_MAX] = ""; - char buf[1024]; - bool disabled = false; - bool block = false; - bool error = false; - FILE *r, *w; - - r = fopen(filename, "r"); - - if(!r) { - return; - } - - snprintf(tmpfile, sizeof(tmpfile), "%s.tmp", filename); - - struct stat st = {.st_mode = 0600}; - fstat(fileno(r), &st); - w = fopenmask(tmpfile, "w", st.st_mode); - - while(fgets(buf, sizeof(buf), r)) { - if(!block && !strncmp(buf, "-----BEGIN ", 11)) { - if((strstr(buf, " ED25519 ") && strstr(what, "Ed25519")) || (strstr(buf, " RSA ") && strstr(what, "RSA"))) { - disabled = true; - block = true; - } - } - - bool ed25519pubkey = !strncasecmp(buf, "Ed25519PublicKey", 16) && strchr(" \t=", buf[16]) && strstr(what, "Ed25519"); - - if(ed25519pubkey) { - disabled = true; - } - - if(w) { - if(block || ed25519pubkey) { - fputc('#', w); - } - - if(fputs(buf, w) < 0) { - error = true; - break; - } - } - - if(block && !strncmp(buf, "-----END ", 9)) { - block = false; - } - } - - if(w) - if(fclose(w) < 0) { - error = true; - } - - if(ferror(r) || fclose(r) < 0) { - error = true; - } - - if(disabled) { - if(!w || error) { - fprintf(stderr, "Warning: old key(s) found, remove them by hand!\n"); - - if(w) { - unlink(tmpfile); - } - - return; - } - -#ifdef HAVE_MINGW - // We cannot atomically replace files on Windows. - char bakfile[PATH_MAX] = ""; - snprintf(bakfile, sizeof(bakfile), "%s.bak", filename); - - if(rename(filename, bakfile) || rename(tmpfile, filename)) { - rename(bakfile, filename); -#else - - if(rename(tmpfile, filename)) { -#endif - fprintf(stderr, "Warning: old key(s) found, remove them by hand!\n"); - } else { -#ifdef HAVE_MINGW - unlink(bakfile); -#endif - fprintf(stderr, "Warning: old key(s) found and disabled.\n"); - } - } - - unlink(tmpfile); -} - -static FILE *ask_and_open(const char *filename, const char *what, const char *mode, bool ask, mode_t perms) { - FILE *r; - char directory[PATH_MAX] = "."; - char buf[PATH_MAX]; - char buf2[PATH_MAX]; - -ask_filename: - - /* Check stdin and stdout */ - if(ask && tty) { - /* Ask for a file and/or directory name. */ - fprintf(stderr, "Please enter a file to save %s to [%s]: ", what, filename); - - if(fgets(buf, sizeof(buf), stdin) == NULL) { - fprintf(stderr, "Error while reading stdin: %s\n", strerror(errno)); - return NULL; - } - - size_t len = strlen(buf); - - if(len) { - buf[--len] = 0; - } - - if(len) { - filename = buf; - } - } - -#ifdef HAVE_MINGW - - if(filename[0] != '\\' && filename[0] != '/' && !strchr(filename, ':')) { -#else - - if(filename[0] != '/') { -#endif - /* The directory is a relative path or a filename. */ - getcwd(directory, sizeof(directory)); - - if((size_t)snprintf(buf2, sizeof(buf2), "%s" SLASH "%s", directory, filename) >= sizeof(buf2)) { - fprintf(stderr, "Filename too long: %s" SLASH "%s\n", directory, filename); - - if(ask && tty) { - goto ask_filename; - } else { - return NULL; - } - } - - filename = buf2; - } - - disable_old_keys(filename, what); - - /* Open it first to keep the inode busy */ - - r = fopenmask(filename, mode, perms); - - if(!r) { - fprintf(stderr, "Error opening file `%s': %s\n", filename, strerror(errno)); - return NULL; - } - - return r; -} - -/* - Generate a public/private Ed25519 keypair, and ask for a file to store - them in. -*/ -static bool ed25519_keygen(bool ask) { - ecdsa_t *key; - FILE *f; - char fname[PATH_MAX]; - - fprintf(stderr, "Generating Ed25519 keypair:\n"); - - if(!(key = ecdsa_generate())) { - fprintf(stderr, "Error during key generation!\n"); - return false; - } else { - fprintf(stderr, "Done.\n"); - } - - snprintf(fname, sizeof(fname), "%s" SLASH "ed25519_key.priv", confbase); - f = ask_and_open(fname, "private Ed25519 key", "a", ask, 0600); - - if(!f) { - goto error; - } - - if(!ecdsa_write_pem_private_key(key, f)) { - fprintf(stderr, "Error writing private key!\n"); - goto error; - } - - fclose(f); - - if(name) { - snprintf(fname, sizeof(fname), "%s" SLASH "hosts" SLASH "%s", confbase, name); - } else { - snprintf(fname, sizeof(fname), "%s" SLASH "ed25519_key.pub", confbase); - } - - f = ask_and_open(fname, "public Ed25519 key", "a", ask, 0666); - - if(!f) { - return false; - } - - char *pubkey = ecdsa_get_base64_public_key(key); - fprintf(f, "Ed25519PublicKey = %s\n", pubkey); - free(pubkey); - - fclose(f); - ecdsa_free(key); - - return true; - -error: - - if(f) { - fclose(f); - } - - ecdsa_free(key); - return false; -} - -#ifndef DISABLE_LEGACY -/* - Generate a public/private RSA keypair, and ask for a file to store - them in. -*/ -static bool rsa_keygen(int bits, bool ask) { - rsa_t *key; - FILE *f; - char fname[PATH_MAX]; - - // Make sure the key size is a multiple of 8 bits. - bits &= ~0x7; - - // Make sure that a valid key size is used. - if(bits < 1024 || bits > 8192) { - fprintf(stderr, "Invalid key size %d specified! It should be between 1024 and 8192 bits.\n", bits); - return false; - } else if(bits < 2048) { - fprintf(stderr, "WARNING: generating a weak %d bits RSA key! 2048 or more bits are recommended.\n", bits); - } - - fprintf(stderr, "Generating %d bits keys:\n", bits); - - if(!(key = rsa_generate(bits, 0x10001))) { - fprintf(stderr, "Error during key generation!\n"); - return false; - } else { - fprintf(stderr, "Done.\n"); - } - - snprintf(fname, sizeof(fname), "%s" SLASH "rsa_key.priv", confbase); - f = ask_and_open(fname, "private RSA key", "a", ask, 0600); - - if(!f) { - goto error; - } - - if(!rsa_write_pem_private_key(key, f)) { - fprintf(stderr, "Error writing private key!\n"); - goto error; - } - - fclose(f); - - if(name) { - snprintf(fname, sizeof(fname), "%s" SLASH "hosts" SLASH "%s", confbase, name); - } else { - snprintf(fname, sizeof(fname), "%s" SLASH "rsa_key.pub", confbase); - } - - f = ask_and_open(fname, "public RSA key", "a", ask, 0666); - - if(!f) { - goto error; - } - - if(!rsa_write_pem_public_key(key, f)) { - fprintf(stderr, "Error writing public key!\n"); - goto error; - } - - fclose(f); - rsa_free(key); - - return true; - -error: - - if(f) { - fclose(f); - } - - rsa_free(key); - return false; -} -#endif - -char buffer[4096]; -size_t blen = 0; - -bool recvline(int fd, char *line, size_t len) { - char *newline = NULL; - - if(!fd) { - return false; - } - - while(!(newline = memchr(buffer, '\n', blen))) { - int result = recv(fd, buffer + blen, sizeof(buffer) - blen, 0); - - if(result == -1 && sockerrno == EINTR) { - continue; - } else if(result <= 0) { - return false; - } - - blen += result; - } - - if((size_t)(newline - buffer) >= len) { - return false; - } - - len = newline - buffer; - - memcpy(line, buffer, len); - line[len] = 0; - memmove(buffer, newline + 1, blen - len - 1); - blen -= len + 1; - - return true; -} - -static bool recvdata(int fd, char *data, size_t len) { - while(blen < len) { - int result = recv(fd, buffer + blen, sizeof(buffer) - blen, 0); - - if(result == -1 && sockerrno == EINTR) { - continue; - } else if(result <= 0) { - return false; - } - - blen += result; - } - - memcpy(data, buffer, len); - memmove(buffer, buffer + len, blen - len); - blen -= len; - - return true; -} - -bool sendline(int fd, char *format, ...) { - static char buffer[4096]; - char *p = buffer; - int blen; - va_list ap; - - va_start(ap, format); - blen = vsnprintf(buffer, sizeof(buffer), format, ap); - buffer[sizeof(buffer) - 1] = 0; - va_end(ap); - - if(blen < 1 || (size_t)blen >= sizeof(buffer)) { - return false; - } - - buffer[blen] = '\n'; - blen++; - - while(blen) { - int result = send(fd, p, blen, MSG_NOSIGNAL); - - if(result == -1 && sockerrno == EINTR) { - continue; - } else if(result <= 0) { - return false; - } - - p += result; - blen -= result; - } - - return true; -} - -static void pcap(int fd, FILE *out, uint32_t snaplen) { - sendline(fd, "%d %d %d", CONTROL, REQ_PCAP, snaplen); - char data[9018]; - - struct { - uint32_t magic; - uint16_t major; - uint16_t minor; - uint32_t tz_offset; - uint32_t tz_accuracy; - uint32_t snaplen; - uint32_t ll_type; - } header = { - 0xa1b2c3d4, - 2, 4, - 0, 0, - snaplen ? snaplen : sizeof(data), - 1, - }; - - struct { - uint32_t tv_sec; - uint32_t tv_usec; - uint32_t len; - uint32_t origlen; - } packet; - - struct timeval tv; - - fwrite(&header, sizeof(header), 1, out); - fflush(out); - - char line[32]; - - while(recvline(fd, line, sizeof(line))) { - int code, req, len; - int n = sscanf(line, "%d %d %d", &code, &req, &len); - gettimeofday(&tv, NULL); - - if(n != 3 || code != CONTROL || req != REQ_PCAP || len < 0 || (size_t)len > sizeof(data)) { - break; - } - - if(!recvdata(fd, data, len)) { - break; - } - - packet.tv_sec = tv.tv_sec; - packet.tv_usec = tv.tv_usec; - packet.len = len; - packet.origlen = len; - fwrite(&packet, sizeof(packet), 1, out); - fwrite(data, len, 1, out); - fflush(out); - } -} - -static void logcontrol(int fd, FILE *out, int level) { - sendline(fd, "%d %d %d", CONTROL, REQ_LOG, level); - char data[1024]; - char line[32]; - - while(recvline(fd, line, sizeof(line))) { - int code, req, len; - int n = sscanf(line, "%d %d %d", &code, &req, &len); - - if(n != 3 || code != CONTROL || req != REQ_LOG || len < 0 || (size_t)len > sizeof(data)) { - break; - } - - if(!recvdata(fd, data, len)) { - break; - } - - fwrite(data, len, 1, out); - fputc('\n', out); - fflush(out); - } -} - -#ifdef HAVE_MINGW -static bool remove_service(void) { - SC_HANDLE manager = NULL; - SC_HANDLE service = NULL; - SERVICE_STATUS status = {0}; - bool success = false; - - manager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); - - if(!manager) { - fprintf(stderr, "Could not open service manager: %s\n", winerror(GetLastError())); - goto exit; - } - - service = OpenService(manager, identname, SERVICE_ALL_ACCESS); - - if(!service) { - fprintf(stderr, "Could not open %s service: %s\n", identname, winerror(GetLastError())); - goto exit; - } - - if(!ControlService(service, SERVICE_CONTROL_STOP, &status)) { - fprintf(stderr, "Could not stop %s service: %s\n", identname, winerror(GetLastError())); - } else { - fprintf(stderr, "%s service stopped\n", identname); - } - - if(!DeleteService(service)) { - fprintf(stderr, "Could not remove %s service: %s\n", identname, winerror(GetLastError())); - goto exit; - } - - success = true; - -exit: - - if(service) { - CloseServiceHandle(service); - } - - if(manager) { - CloseServiceHandle(manager); - } - - if(success) { - fprintf(stderr, "%s service removed\n", identname); - } - - return success; -} -#endif - -bool connect_tincd(bool verbose) { - if(fd >= 0) { - fd_set r; - FD_ZERO(&r); - FD_SET(fd, &r); - struct timeval tv = {0, 0}; - - if(select(fd + 1, &r, NULL, NULL, &tv)) { - fprintf(stderr, "Previous connection to tincd lost, reconnecting.\n"); - close(fd); - fd = -1; - } else { - return true; - } - } - - FILE *f = fopen(pidfilename, "r"); - - if(!f) { - if(verbose) { - fprintf(stderr, "Could not open pid file %s: %s\n", pidfilename, strerror(errno)); - } - - return false; - } - - char host[129]; - char port[129]; - - if(fscanf(f, "%20d %1024s %128s port %128s", &pid, controlcookie, host, port) != 4) { - if(verbose) { - fprintf(stderr, "Could not parse pid file %s\n", pidfilename); - } - - fclose(f); - return false; - } - - fclose(f); - -#ifndef HAVE_MINGW - - if((pid == 0) || (kill(pid, 0) && (errno == ESRCH))) { - fprintf(stderr, "Could not find tincd running at pid %d\n", pid); - /* clean up the stale socket and pid file */ - unlink(pidfilename); - unlink(unixsocketname); - return false; - } - - struct sockaddr_un sa; - - sa.sun_family = AF_UNIX; - - strncpy(sa.sun_path, unixsocketname, sizeof(sa.sun_path)); - - sa.sun_path[sizeof(sa.sun_path) - 1] = 0; - - fd = socket(AF_UNIX, SOCK_STREAM, 0); - - if(fd < 0) { - if(verbose) { - fprintf(stderr, "Cannot create UNIX socket: %s\n", sockstrerror(sockerrno)); - } - - return false; - } - - if(connect(fd, (struct sockaddr *)&sa, sizeof(sa)) < 0) { - if(verbose) { - fprintf(stderr, "Cannot connect to UNIX socket %s: %s\n", unixsocketname, sockstrerror(sockerrno)); - } - - close(fd); - fd = -1; - return false; - } - -#else - struct addrinfo hints = { - .ai_family = AF_UNSPEC, - .ai_socktype = SOCK_STREAM, - .ai_protocol = IPPROTO_TCP, - .ai_flags = 0, - }; - - struct addrinfo *res = NULL; - - if(getaddrinfo(host, port, &hints, &res) || !res) { - if(verbose) { - fprintf(stderr, "Cannot resolve %s port %s: %s\n", host, port, sockstrerror(sockerrno)); - } - - return false; - } - - fd = socket(res->ai_family, SOCK_STREAM, IPPROTO_TCP); - - if(fd < 0) { - if(verbose) { - fprintf(stderr, "Cannot create TCP socket: %s\n", sockstrerror(sockerrno)); - } - - return false; - } - -#ifdef HAVE_MINGW - unsigned long arg = 0; - - if(ioctlsocket(fd, FIONBIO, &arg) != 0) { - if(verbose) { - fprintf(stderr, "System call `%s' failed: %s\n", "ioctlsocket", sockstrerror(sockerrno)); - } - } - -#endif - - if(connect(fd, res->ai_addr, res->ai_addrlen) < 0) { - if(verbose) { - fprintf(stderr, "Cannot connect to %s port %s: %s\n", host, port, sockstrerror(sockerrno)); - } - - close(fd); - fd = -1; - return false; - } - - freeaddrinfo(res); -#endif - -#ifdef SO_NOSIGPIPE - static const int one = 1; - setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&one, sizeof(one)); -#endif - - sendline(fd, "%d ^%s %d", ID, controlcookie, TINC_CTL_VERSION_CURRENT); - - char data[4096]; - int version; - - if(!recvline(fd, line, sizeof(line)) || sscanf(line, "%d %4095s %d", &code, data, &version) != 3 || code != 0) { - if(verbose) { - fprintf(stderr, "Cannot read greeting from control socket: %s\n", sockstrerror(sockerrno)); - } - - close(fd); - fd = -1; - return false; - } - - if(!recvline(fd, line, sizeof(line)) || sscanf(line, "%d %d %d", &code, &version, &pid) != 3 || code != 4 || version != TINC_CTL_VERSION_CURRENT) { - if(verbose) { - fprintf(stderr, "Could not fully establish control socket connection\n"); - } - - close(fd); - fd = -1; - return false; - } - - return true; -} - - -static int cmd_start(int argc, char *argv[]) { - if(connect_tincd(false)) { - if(netname) { - fprintf(stderr, "A tincd is already running for net `%s' with pid %d.\n", netname, pid); - } else { - fprintf(stderr, "A tincd is already running with pid %d.\n", pid); - } - - return 0; - } - - char *c; - char *slash = strrchr(program_name, '/'); - -#ifdef HAVE_MINGW - - if((c = strrchr(program_name, '\\')) > slash) { - slash = c; - } - -#endif - - if(slash++) { - xasprintf(&c, "%.*stincd", (int)(slash - program_name), program_name); - } else { - c = "tincd"; - } - - int nargc = 0; - char **nargv = xzalloc((optind + argc) * sizeof(*nargv)); - - char *arg0 = c; -#ifdef HAVE_MINGW - /* - Windows has no real concept of an "argv array". A command line is just one string. - The CRT of the new process will decode the command line string to generate argv before calling main(), and (by convention) - it uses quotes to handle spaces in arguments. - Therefore we need to quote all arguments that might contain spaces. No, execvp() won't do that for us (see MSDN). - If we don't do that, then execvp() will run fine but any spaces in the filename contained in arg0 will bleed - into the next arguments when the spawned process' CRT parses its command line, resulting in chaos. - */ - xasprintf(&arg0, "\"%s\"", arg0); -#endif - nargv[nargc++] = arg0; - - for(int i = 1; i < optind; i++) { - nargv[nargc++] = orig_argv[i]; - } - - for(int i = 1; i < argc; i++) { - nargv[nargc++] = argv[i]; - } - -#ifdef HAVE_MINGW - int status = spawnvp(_P_WAIT, c, nargv); - - if(status == -1) { - fprintf(stderr, "Error starting %s: %s\n", c, strerror(errno)); - return 1; - } - - return status; -#else - int pfd[2] = {-1, -1}; - - if(socketpair(AF_UNIX, SOCK_STREAM, 0, pfd)) { - fprintf(stderr, "Could not create umbilical socket: %s\n", strerror(errno)); - free(nargv); - return 1; - } - - pid_t pid = fork(); - - if(pid == -1) { - fprintf(stderr, "Could not fork: %s\n", strerror(errno)); - free(nargv); - return 1; - } - - if(!pid) { - close(pfd[0]); - char buf[100]; - snprintf(buf, sizeof(buf), "%d", pfd[1]); - setenv("TINC_UMBILICAL", buf, true); - exit(execvp(c, nargv)); - } else { - close(pfd[1]); - } - - free(nargv); - - int status = -1, result; -#ifdef SIGINT - signal(SIGINT, SIG_IGN); -#endif - - // Pass all log messages from the umbilical to stderr. - // A nul-byte right before closure means tincd started successfully. - bool failure = true; - char buf[1024]; - ssize_t len; - - while((len = read(pfd[0], buf, sizeof(buf))) > 0) { - failure = buf[len - 1]; - - if(!failure) { - len--; - } - - write(2, buf, len); - } - - if(len) { - failure = true; - } - - close(pfd[0]); - - // Make sure the child process is really gone. - result = waitpid(pid, &status, 0); - -#ifdef SIGINT - signal(SIGINT, SIG_DFL); -#endif - - if(failure || result != pid || !WIFEXITED(status) || WEXITSTATUS(status)) { - fprintf(stderr, "Error starting %s\n", c); - return 1; - } - - return 0; -#endif -} - -static int cmd_stop(int argc, char *argv[]) { - (void)argv; - - if(argc > 1) { - fprintf(stderr, "Too many arguments!\n"); - return 1; - } - -#ifndef HAVE_MINGW - - if(!connect_tincd(true)) { - if(pid) { - if(kill(pid, SIGTERM)) { - fprintf(stderr, "Could not send TERM signal to process with PID %d: %s\n", pid, strerror(errno)); - return 1; - } - - fprintf(stderr, "Sent TERM signal to process with PID %d.\n", pid); - waitpid(pid, NULL, 0); - return 0; - } - - return 1; - } - - sendline(fd, "%d %d", CONTROL, REQ_STOP); - - while(recvline(fd, line, sizeof(line))) { - // Wait for tincd to close the connection... - } - -#else - - if(!remove_service()) { - return 1; - } - -#endif - close(fd); - pid = 0; - fd = -1; - - return 0; -} - -static int cmd_restart(int argc, char *argv[]) { - cmd_stop(1, argv); - return cmd_start(argc, argv); -} - -static int cmd_reload(int argc, char *argv[]) { - (void)argv; - - if(argc > 1) { - fprintf(stderr, "Too many arguments!\n"); - return 1; - } - - if(!connect_tincd(true)) { - return 1; - } - - sendline(fd, "%d %d", CONTROL, REQ_RELOAD); - - if(!recvline(fd, line, sizeof(line)) || sscanf(line, "%d %d %d", &code, &req, &result) != 3 || code != CONTROL || req != REQ_RELOAD || result) { - fprintf(stderr, "Could not reload configuration.\n"); - return 1; - } - - return 0; - -} - -static int dump_invitations(void) { - char dname[PATH_MAX]; - snprintf(dname, sizeof(dname), "%s" SLASH "invitations", confbase); - DIR *dir = opendir(dname); - - if(!dir) { - if(errno == ENOENT) { - fprintf(stderr, "No outstanding invitations.\n"); - return 0; - } - - fprintf(stderr, "Cannot not read directory %s: %s\n", dname, strerror(errno)); - return 1; - } - - struct dirent *ent; - - bool found = false; - - while((ent = readdir(dir))) { - char buf[MAX_STRING_SIZE]; - - if(b64decode(ent->d_name, buf, 24) != 18) { - continue; - } - - char fname[PATH_MAX]; - - if((size_t)snprintf(fname, sizeof(fname), "%s" SLASH "%s", dname, ent->d_name) >= sizeof(fname)) { - fprintf(stderr, "Filename too long: %s" SLASH "%s\n", dname, ent->d_name); - continue; - } - - FILE *f = fopen(fname, "r"); - - if(!f) { - fprintf(stderr, "Cannot open %s: %s\n", fname, strerror(errno)); - continue; - } - - buf[0] = 0; - - if(!fgets(buf, sizeof(buf), f)) { - fprintf(stderr, "Invalid invitation file %s\n", fname); - fclose(f); - continue; - } - - fclose(f); - - char *eol = buf + strlen(buf); - - while(strchr("\t \r\n", *--eol)) { - *eol = 0; - } - - if(strncmp(buf, "Name = ", 7) || !check_id(buf + 7)) { - fprintf(stderr, "Invalid invitation file %s\n", fname); - continue; - } - - found = true; - printf("%s %s\n", ent->d_name, buf + 7); - } - - closedir(dir); - - if(!found) { - fprintf(stderr, "No outstanding invitations.\n"); - } - - return 0; -} - -static int cmd_dump(int argc, char *argv[]) { - bool only_reachable = false; - - if(argc > 2 && !strcasecmp(argv[1], "reachable")) { - if(strcasecmp(argv[2], "nodes")) { - fprintf(stderr, "`reachable' only supported for nodes.\n"); - usage(true); - return 1; - } - - only_reachable = true; - argv++; - argc--; - } - - if(argc != 2) { - fprintf(stderr, "Invalid number of arguments.\n"); - usage(true); - return 1; - } - - if(!strcasecmp(argv[1], "invitations")) { - return dump_invitations(); - } - - if(!connect_tincd(true)) { - return 1; - } - - int do_graph = 0; - - if(!strcasecmp(argv[1], "nodes")) { - sendline(fd, "%d %d", CONTROL, REQ_DUMP_NODES); - } else if(!strcasecmp(argv[1], "edges")) { - sendline(fd, "%d %d", CONTROL, REQ_DUMP_EDGES); - } else if(!strcasecmp(argv[1], "subnets")) { - sendline(fd, "%d %d", CONTROL, REQ_DUMP_SUBNETS); - } else if(!strcasecmp(argv[1], "connections")) { - sendline(fd, "%d %d", CONTROL, REQ_DUMP_CONNECTIONS); - } else if(!strcasecmp(argv[1], "graph")) { - sendline(fd, "%d %d", CONTROL, REQ_DUMP_NODES); - sendline(fd, "%d %d", CONTROL, REQ_DUMP_EDGES); - do_graph = 1; - } else if(!strcasecmp(argv[1], "digraph")) { - sendline(fd, "%d %d", CONTROL, REQ_DUMP_NODES); - sendline(fd, "%d %d", CONTROL, REQ_DUMP_EDGES); - do_graph = 2; - } else { - fprintf(stderr, "Unknown dump type '%s'.\n", argv[1]); - usage(true); - return 1; - } - - if(do_graph == 1) { - printf("graph {\n"); - } else if(do_graph == 2) { - printf("digraph {\n"); - } - - while(recvline(fd, line, sizeof(line))) { - char node1[4096], node2[4096]; - int n = sscanf(line, "%d %d %4095s %4095s", &code, &req, node1, node2); - - if(n == 2) { - if(do_graph && req == REQ_DUMP_NODES) { - continue; - } else { - if(do_graph) { - printf("}\n"); - } - - return 0; - } - } - - if(n < 2) { - break; - } - - char node[4096]; - char id[4096]; - char from[4096]; - char to[4096]; - char subnet[4096]; - char host[4096]; - char port[4096]; - char local_host[4096]; - char local_port[4096]; - char via[4096]; - char nexthop[4096]; - int cipher, digest, maclength, compression, distance, socket, weight; - short int pmtu, minmtu, maxmtu; - unsigned int options, status_int; - node_status_t status; - long int last_state_change; - int udp_ping_rtt; - uint64_t in_packets, in_bytes, out_packets, out_bytes; - - switch(req) { - case REQ_DUMP_NODES: { - int n = sscanf(line, "%*d %*d %4095s %4095s %4095s port %4095s %d %d %d %d %x %x %4095s %4095s %d %hd %hd %hd %ld %d %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64, node, id, host, port, &cipher, &digest, &maclength, &compression, &options, &status_int, nexthop, via, &distance, &pmtu, &minmtu, &maxmtu, &last_state_change, &udp_ping_rtt, &in_packets, &in_bytes, &out_packets, &out_bytes); - - if(n != 22) { - fprintf(stderr, "Unable to parse node dump from tincd: %s\n", line); - return 1; - } - - memcpy(&status, &status_int, sizeof(status)); - - if(do_graph) { - const char *color = "black"; - - if(!strcmp(host, "MYSELF")) { - color = "green"; - } else if(!status.reachable) { - color = "red"; - } else if(strcmp(via, node)) { - color = "orange"; - } else if(!status.validkey) { - color = "black"; - } else if(minmtu > 0) { - color = "green"; - } - - printf(" %s [label = \"%s\", color = \"%s\"%s];\n", node, node, color, strcmp(host, "MYSELF") ? "" : ", style = \"filled\""); - } else { - if(only_reachable && !status.reachable) { - continue; - } - - printf("%s id %s at %s port %s cipher %d digest %d maclength %d compression %d options %x status %04x nexthop %s via %s distance %d pmtu %d (min %d max %d) rx %"PRIu64" %"PRIu64" tx %"PRIu64" %"PRIu64, - node, id, host, port, cipher, digest, maclength, compression, options, status_int, nexthop, via, distance, pmtu, minmtu, maxmtu, in_packets, in_bytes, out_packets, out_bytes); - - if(udp_ping_rtt != -1) { - printf(" rtt %d.%03d", udp_ping_rtt / 1000, udp_ping_rtt % 1000); - } - - printf("\n"); - } - } - break; - - case REQ_DUMP_EDGES: { - int n = sscanf(line, "%*d %*d %4095s %4095s %4095s port %4095s %4095s port %4095s %x %d", from, to, host, port, local_host, local_port, &options, &weight); - - if(n != 8) { - fprintf(stderr, "Unable to parse edge dump from tincd.\n"); - return 1; - } - - if(do_graph) { - float w = 1 + 65536.0 / weight; - - if(do_graph == 1 && strcmp(node1, node2) > 0) { - printf(" %s -- %s [w = %f, weight = %f];\n", node1, node2, w, w); - } else if(do_graph == 2) { - printf(" %s -> %s [w = %f, weight = %f];\n", node1, node2, w, w); - } - } else { - printf("%s to %s at %s port %s local %s port %s options %x weight %d\n", from, to, host, port, local_host, local_port, options, weight); - } - } - break; - - case REQ_DUMP_SUBNETS: { - int n = sscanf(line, "%*d %*d %4095s %4095s", subnet, node); - - if(n != 2) { - fprintf(stderr, "Unable to parse subnet dump from tincd.\n"); - return 1; - } - - printf("%s owner %s\n", strip_weight(subnet), node); - } - break; - - case REQ_DUMP_CONNECTIONS: { - int n = sscanf(line, "%*d %*d %4095s %4095s port %4095s %x %d %x", node, host, port, &options, &socket, &status_int); - - if(n != 6) { - fprintf(stderr, "Unable to parse connection dump from tincd.\n"); - return 1; - } - - printf("%s at %s port %s options %x socket %d status %x\n", node, host, port, options, socket, status_int); - } - break; - - default: - fprintf(stderr, "Unable to parse dump from tincd.\n"); - return 1; - } - } - - fprintf(stderr, "Error receiving dump.\n"); - return 1; -} - -static int cmd_purge(int argc, char *argv[]) { - (void)argv; - - if(argc > 1) { - fprintf(stderr, "Too many arguments!\n"); - return 1; - } - - if(!connect_tincd(true)) { - return 1; - } - - sendline(fd, "%d %d", CONTROL, REQ_PURGE); - - if(!recvline(fd, line, sizeof(line)) || sscanf(line, "%d %d %d", &code, &req, &result) != 3 || code != CONTROL || req != REQ_PURGE || result) { - fprintf(stderr, "Could not purge old information.\n"); - return 1; - } - - return 0; -} - -static int cmd_debug(int argc, char *argv[]) { - if(argc != 2) { - fprintf(stderr, "Invalid number of arguments.\n"); - return 1; - } - - if(!connect_tincd(true)) { - return 1; - } - - int debuglevel = atoi(argv[1]); - int origlevel; - - sendline(fd, "%d %d %d", CONTROL, REQ_SET_DEBUG, debuglevel); - - if(!recvline(fd, line, sizeof(line)) || sscanf(line, "%d %d %d", &code, &req, &origlevel) != 3 || code != CONTROL || req != REQ_SET_DEBUG) { - fprintf(stderr, "Could not set debug level.\n"); - return 1; - } - - fprintf(stderr, "Old level %d, new level %d.\n", origlevel, debuglevel); - return 0; -} - -static int cmd_retry(int argc, char *argv[]) { - (void)argv; - - if(argc > 1) { - fprintf(stderr, "Too many arguments!\n"); - return 1; - } - - if(!connect_tincd(true)) { - return 1; - } - - sendline(fd, "%d %d", CONTROL, REQ_RETRY); - - if(!recvline(fd, line, sizeof(line)) || sscanf(line, "%d %d %d", &code, &req, &result) != 3 || code != CONTROL || req != REQ_RETRY || result) { - fprintf(stderr, "Could not retry outgoing connections.\n"); - return 1; - } - - return 0; -} - -static int cmd_connect(int argc, char *argv[]) { - if(argc != 2) { - fprintf(stderr, "Invalid number of arguments.\n"); - return 1; - } - - if(!check_id(argv[1])) { - fprintf(stderr, "Invalid name for node.\n"); - return 1; - } - - if(!connect_tincd(true)) { - return 1; - } - - sendline(fd, "%d %d %s", CONTROL, REQ_CONNECT, argv[1]); - - if(!recvline(fd, line, sizeof(line)) || sscanf(line, "%d %d %d", &code, &req, &result) != 3 || code != CONTROL || req != REQ_CONNECT || result) { - fprintf(stderr, "Could not connect to %s.\n", argv[1]); - return 1; - } - - return 0; -} - -static int cmd_disconnect(int argc, char *argv[]) { - if(argc != 2) { - fprintf(stderr, "Invalid number of arguments.\n"); - return 1; - } - - if(!check_id(argv[1])) { - fprintf(stderr, "Invalid name for node.\n"); - return 1; - } - - if(!connect_tincd(true)) { - return 1; - } - - sendline(fd, "%d %d %s", CONTROL, REQ_DISCONNECT, argv[1]); - - if(!recvline(fd, line, sizeof(line)) || sscanf(line, "%d %d %d", &code, &req, &result) != 3 || code != CONTROL || req != REQ_DISCONNECT || result) { - fprintf(stderr, "Could not disconnect %s.\n", argv[1]); - return 1; - } - - return 0; -} - -static int cmd_top(int argc, char *argv[]) { - (void)argv; - - if(argc > 1) { - fprintf(stderr, "Too many arguments!\n"); - return 1; - } - -#ifdef HAVE_CURSES - - if(!connect_tincd(true)) { - return 1; - } - - top(fd); - return 0; -#else - fprintf(stderr, "This version of tinc was compiled without support for the curses library.\n"); - return 1; -#endif -} - -static int cmd_pcap(int argc, char *argv[]) { - if(argc > 2) { - fprintf(stderr, "Too many arguments!\n"); - return 1; - } - - if(!connect_tincd(true)) { - return 1; - } - - pcap(fd, stdout, argc > 1 ? atoi(argv[1]) : 0); - return 0; -} - -#ifdef SIGINT -static void sigint_handler(int sig) { - (void)sig; - - fprintf(stderr, "\n"); - shutdown(fd, SHUT_RDWR); -} -#endif - -static int cmd_log(int argc, char *argv[]) { - if(argc > 2) { - fprintf(stderr, "Too many arguments!\n"); - return 1; - } - - if(!connect_tincd(true)) { - return 1; - } - -#ifdef SIGINT - signal(SIGINT, sigint_handler); -#endif - - logcontrol(fd, stdout, argc > 1 ? atoi(argv[1]) : -1); - -#ifdef SIGINT - signal(SIGINT, SIG_DFL); -#endif - - close(fd); - fd = -1; - return 0; -} - -static int cmd_pid(int argc, char *argv[]) { - (void)argv; - - if(argc > 1) { - fprintf(stderr, "Too many arguments!\n"); - return 1; - } - - if(!connect_tincd(true) || !pid) { - return 1; - } - - printf("%d\n", pid); - return 0; -} - -int rstrip(char *value) { - int len = strlen(value); - - while(len && strchr("\t\r\n ", value[len - 1])) { - value[--len] = 0; - } - - return len; -} - -char *get_my_name(bool verbose) { - FILE *f = fopen(tinc_conf, "r"); - - if(!f) { - if(verbose) { - fprintf(stderr, "Could not open %s: %s\n", tinc_conf, strerror(errno)); - } - - return NULL; - } - - char buf[4096]; - char *value; - - while(fgets(buf, sizeof(buf), f)) { - int len = strcspn(buf, "\t ="); - value = buf + len; - value += strspn(value, "\t "); - - if(*value == '=') { - value++; - value += strspn(value, "\t "); - } - - if(!rstrip(value)) { - continue; - } - - buf[len] = 0; - - if(strcasecmp(buf, "Name")) { - continue; - } - - if(*value) { - fclose(f); - return replace_name(value); - } - } - - fclose(f); - - if(verbose) { - fprintf(stderr, "Could not find Name in %s.\n", tinc_conf); - } - - return NULL; -} - -ecdsa_t *get_pubkey(FILE *f) { - char buf[4096]; - char *value; - - while(fgets(buf, sizeof(buf), f)) { - int len = strcspn(buf, "\t ="); - value = buf + len; - value += strspn(value, "\t "); - - if(*value == '=') { - value++; - value += strspn(value, "\t "); - } - - if(!rstrip(value)) { - continue; - } - - buf[len] = 0; - - if(strcasecmp(buf, "Ed25519PublicKey")) { - continue; - } - - if(*value) { - return ecdsa_set_base64_public_key(value); - } - } - - return NULL; -} - -const var_t variables[] = { - /* Server configuration */ - {"AddressFamily", VAR_SERVER}, - {"AutoConnect", VAR_SERVER | VAR_SAFE}, - {"BindToAddress", VAR_SERVER | VAR_MULTIPLE}, - {"BindToInterface", VAR_SERVER}, - {"Broadcast", VAR_SERVER | VAR_SAFE}, - {"BroadcastSubnet", VAR_SERVER | VAR_MULTIPLE | VAR_SAFE}, - {"ConnectTo", VAR_SERVER | VAR_MULTIPLE | VAR_SAFE}, - {"DecrementTTL", VAR_SERVER}, - {"Device", VAR_SERVER}, - {"DeviceStandby", VAR_SERVER}, - {"DeviceType", VAR_SERVER}, - {"DirectOnly", VAR_SERVER}, - {"Ed25519PrivateKeyFile", VAR_SERVER}, - {"ExperimentalProtocol", VAR_SERVER}, - {"Forwarding", VAR_SERVER}, - {"FWMark", VAR_SERVER}, - {"GraphDumpFile", VAR_SERVER | VAR_OBSOLETE}, - {"Hostnames", VAR_SERVER}, - {"IffOneQueue", VAR_SERVER}, - {"Interface", VAR_SERVER}, - {"InvitationExpire", VAR_SERVER}, - {"KeyExpire", VAR_SERVER}, - {"ListenAddress", VAR_SERVER | VAR_MULTIPLE}, - {"LocalDiscovery", VAR_SERVER}, - {"LogLevel", VAR_SERVER}, - {"MACExpire", VAR_SERVER}, - {"MaxConnectionBurst", VAR_SERVER}, - {"MaxOutputBufferSize", VAR_SERVER}, - {"MaxTimeout", VAR_SERVER}, - {"Mode", VAR_SERVER | VAR_SAFE}, - {"Name", VAR_SERVER}, - {"PingInterval", VAR_SERVER}, - {"PingTimeout", VAR_SERVER}, - {"PriorityInheritance", VAR_SERVER}, - {"PrivateKey", VAR_SERVER | VAR_OBSOLETE}, - {"PrivateKeyFile", VAR_SERVER}, - {"ProcessPriority", VAR_SERVER}, - {"Proxy", VAR_SERVER}, - {"ReplayWindow", VAR_SERVER}, - {"ScriptsExtension", VAR_SERVER}, - {"ScriptsInterpreter", VAR_SERVER}, - {"StrictSubnets", VAR_SERVER}, - {"TunnelServer", VAR_SERVER}, - {"UDPDiscovery", VAR_SERVER}, - {"UDPDiscoveryKeepaliveInterval", VAR_SERVER}, - {"UDPDiscoveryInterval", VAR_SERVER}, - {"UDPDiscoveryTimeout", VAR_SERVER}, - {"MTUInfoInterval", VAR_SERVER}, - {"UDPInfoInterval", VAR_SERVER}, - {"UDPRcvBuf", VAR_SERVER}, - {"UDPSndBuf", VAR_SERVER}, - {"UPnP", VAR_SERVER}, - {"UPnPDiscoverWait", VAR_SERVER}, - {"UPnPRefreshPeriod", VAR_SERVER}, - {"VDEGroup", VAR_SERVER}, - {"VDEPort", VAR_SERVER}, - /* Host configuration */ - {"Address", VAR_HOST | VAR_MULTIPLE}, - {"Cipher", VAR_SERVER | VAR_HOST}, - {"ClampMSS", VAR_SERVER | VAR_HOST}, - {"Compression", VAR_SERVER | VAR_HOST}, - {"Digest", VAR_SERVER | VAR_HOST}, - {"Ed25519PublicKey", VAR_HOST}, - {"Ed25519PublicKeyFile", VAR_SERVER | VAR_HOST}, - {"IndirectData", VAR_SERVER | VAR_HOST}, - {"MACLength", VAR_SERVER | VAR_HOST}, - {"PMTU", VAR_SERVER | VAR_HOST}, - {"PMTUDiscovery", VAR_SERVER | VAR_HOST}, - {"Port", VAR_HOST}, - {"PublicKey", VAR_HOST | VAR_OBSOLETE}, - {"PublicKeyFile", VAR_SERVER | VAR_HOST | VAR_OBSOLETE}, - {"Subnet", VAR_HOST | VAR_MULTIPLE | VAR_SAFE}, - {"TCPOnly", VAR_SERVER | VAR_HOST}, - {"Weight", VAR_HOST | VAR_SAFE}, - {NULL, 0} -}; - -static int cmd_config(int argc, char *argv[]) { - if(argc < 2) { - fprintf(stderr, "Invalid number of arguments.\n"); - return 1; - } - - if(strcasecmp(argv[0], "config")) { - argv--, argc++; - } - - int action = -2; - - if(!strcasecmp(argv[1], "get")) { - argv++, argc--; - } else if(!strcasecmp(argv[1], "add")) { - argv++, argc--, action = 1; - } else if(!strcasecmp(argv[1], "del")) { - argv++, argc--, action = -1; - } else if(!strcasecmp(argv[1], "replace") || !strcasecmp(argv[1], "set") || !strcasecmp(argv[1], "change")) { - argv++, argc--, action = 0; - } - - if(argc < 2) { - fprintf(stderr, "Invalid number of arguments.\n"); - return 1; - } - - // Concatenate the rest of the command line - strncpy(line, argv[1], sizeof(line) - 1); - - for(int i = 2; i < argc; i++) { - strncat(line, " ", sizeof(line) - 1 - strlen(line)); - strncat(line, argv[i], sizeof(line) - 1 - strlen(line)); - } - - // Liberal parsing into node name, variable name and value. - char *node = NULL; - char *variable; - char *value; - int len; - - len = strcspn(line, "\t ="); - value = line + len; - value += strspn(value, "\t "); - - if(*value == '=') { - value++; - value += strspn(value, "\t "); - } - - line[len] = '\0'; - variable = strchr(line, '.'); - - if(variable) { - node = line; - *variable++ = 0; - } else { - variable = line; - } - - if(!*variable) { - fprintf(stderr, "No variable given.\n"); - return 1; - } - - if(action >= 0 && !*value) { - fprintf(stderr, "No value for variable given.\n"); - return 1; - } - - if(action < -1 && *value) { - action = 0; - } - - /* Some simple checks. */ - bool found = false; - bool warnonremove = false; - - for(int i = 0; variables[i].name; i++) { - if(strcasecmp(variables[i].name, variable)) { - continue; - } - - found = true; - variable = (char *)variables[i].name; - - /* Discourage use of obsolete variables. */ - - if(variables[i].type & VAR_OBSOLETE && action >= 0) { - if(force) { - fprintf(stderr, "Warning: %s is an obsolete variable!\n", variable); - } else { - fprintf(stderr, "%s is an obsolete variable! Use --force to use it anyway.\n", variable); - return 1; - } - } - - /* Don't put server variables in host config files */ - - if(node && !(variables[i].type & VAR_HOST) && action >= 0) { - if(force) { - fprintf(stderr, "Warning: %s is not a host configuration variable!\n", variable); - } else { - fprintf(stderr, "%s is not a host configuration variable! Use --force to use it anyway.\n", variable); - return 1; - } - } - - /* Should this go into our own host config file? */ - - if(!node && !(variables[i].type & VAR_SERVER)) { - node = get_my_name(true); - - if(!node) { - return 1; - } - } - - /* Change "add" into "set" for variables that do not allow multiple occurrences. - Turn on warnings when it seems variables might be removed unintentionally. */ - - if(action == 1 && !(variables[i].type & VAR_MULTIPLE)) { - warnonremove = true; - action = 0; - } else if(action == 0 && (variables[i].type & VAR_MULTIPLE)) { - warnonremove = true; - } - - break; - } - - if(node && !check_id(node)) { - fprintf(stderr, "Invalid name for node.\n"); - return 1; - } - - if(!found) { - if(force || action < 0) { - fprintf(stderr, "Warning: %s is not a known configuration variable!\n", variable); - } else { - fprintf(stderr, "%s: is not a known configuration variable! Use --force to use it anyway.\n", variable); - return 1; - } - } - - // Open the right configuration file. - char filename[PATH_MAX]; - - if(node) { - snprintf(filename, sizeof(filename), "%s" SLASH "%s", hosts_dir, node); - } else { - snprintf(filename, sizeof(filename), "%s", tinc_conf); - } - - FILE *f = fopen(filename, "r"); - - if(!f) { - fprintf(stderr, "Could not open configuration file %s: %s\n", filename, strerror(errno)); - return 1; - } - - char tmpfile[PATH_MAX]; - FILE *tf = NULL; - - if(action >= -1) { - if((size_t)snprintf(tmpfile, sizeof(tmpfile), "%s.config.tmp", filename) >= sizeof(tmpfile)) { - fprintf(stderr, "Filename too long: %s.config.tmp\n", filename); - return 1; - } - - tf = fopen(tmpfile, "w"); - - if(!tf) { - fprintf(stderr, "Could not open temporary file %s: %s\n", tmpfile, strerror(errno)); - fclose(f); - return 1; - } - } - - // Copy the file, making modifications on the fly, unless we are just getting a value. - char buf1[4096]; - char buf2[4096]; - bool set = false; - bool removed = false; - found = false; - - while(fgets(buf1, sizeof(buf1), f)) { - buf1[sizeof(buf1) - 1] = 0; - strncpy(buf2, buf1, sizeof(buf2)); - - // Parse line in a simple way - char *bvalue; - int len; - - len = strcspn(buf2, "\t ="); - bvalue = buf2 + len; - bvalue += strspn(bvalue, "\t "); - - if(*bvalue == '=') { - bvalue++; - bvalue += strspn(bvalue, "\t "); - } - - rstrip(bvalue); - buf2[len] = '\0'; - - // Did it match? - if(!strcasecmp(buf2, variable)) { - // Get - if(action < -1) { - found = true; - printf("%s\n", bvalue); - // Del - } else if(action == -1) { - if(!*value || !strcasecmp(bvalue, value)) { - removed = true; - continue; - } - - // Set - } else if(action == 0) { - // Warn if "set" was used for variables that can occur multiple times - if(warnonremove && strcasecmp(bvalue, value)) { - fprintf(stderr, "Warning: removing %s = %s\n", variable, bvalue); - } - - // Already set? Delete the rest... - if(set) { - continue; - } - - // Otherwise, replace. - if(fprintf(tf, "%s = %s\n", variable, value) < 0) { - fprintf(stderr, "Error writing to temporary file %s: %s\n", tmpfile, strerror(errno)); - return 1; - } - - set = true; - continue; - // Add - } else if(action > 0) { - // Check if we've already seen this variable with the same value - if(!strcasecmp(bvalue, value)) { - found = true; - } - } - } - - if(action >= -1) { - // Copy original line... - if(fputs(buf1, tf) < 0) { - fprintf(stderr, "Error writing to temporary file %s: %s\n", tmpfile, strerror(errno)); - return 1; - } - - // Add newline if it is missing... - if(*buf1 && buf1[strlen(buf1) - 1] != '\n') { - if(fputc('\n', tf) < 0) { - fprintf(stderr, "Error writing to temporary file %s: %s\n", tmpfile, strerror(errno)); - return 1; - } - } - } - } - - // Make sure we read everything... - if(ferror(f) || !feof(f)) { - fprintf(stderr, "Error while reading from configuration file %s: %s\n", filename, strerror(errno)); - return 1; - } - - if(fclose(f)) { - fprintf(stderr, "Error closing configuration file %s: %s\n", filename, strerror(errno)); - return 1; - } - - // Add new variable if necessary. - if((action > 0 && !found) || (action == 0 && !set)) { - if(fprintf(tf, "%s = %s\n", variable, value) < 0) { - fprintf(stderr, "Error writing to temporary file %s: %s\n", tmpfile, strerror(errno)); - return 1; - } - } - - if(action < -1) { - if(found) { - return 0; - } else { - fprintf(stderr, "No matching configuration variables found.\n"); - return 1; - } - } - - // Make sure we wrote everything... - if(fclose(tf)) { - fprintf(stderr, "Error closing temporary file %s: %s\n", tmpfile, strerror(errno)); - return 1; - } - - // Could we find what we had to remove? - if(action < 0 && !removed) { - remove(tmpfile); - fprintf(stderr, "No configuration variables deleted.\n"); - return 1; - } - - // Replace the configuration file with the new one -#ifdef HAVE_MINGW - - if(remove(filename)) { - fprintf(stderr, "Error replacing file %s: %s\n", filename, strerror(errno)); - return 1; - } - -#endif - - if(rename(tmpfile, filename)) { - fprintf(stderr, "Error renaming temporary file %s to configuration file %s: %s\n", tmpfile, filename, strerror(errno)); - return 1; - } - - // Silently try notifying a running tincd of changes. - if(connect_tincd(false)) { - sendline(fd, "%d %d", CONTROL, REQ_RELOAD); - } - - return 0; -} - -static bool try_bind(int port) { - struct addrinfo *ai = NULL, *aip; - struct addrinfo hint = { - .ai_flags = AI_PASSIVE, - .ai_family = AF_UNSPEC, - .ai_socktype = SOCK_STREAM, - .ai_protocol = IPPROTO_TCP, - }; - - bool success = true; - char portstr[16]; - snprintf(portstr, sizeof(portstr), "%d", port); - - if(getaddrinfo(NULL, portstr, &hint, &ai) || !ai) { - return false; - } - - for(aip = ai; aip; aip = aip->ai_next) { - int fd = socket(ai->ai_family, SOCK_STREAM, IPPROTO_TCP); - - if(!fd) { - success = false; - break; - } - - int result = bind(fd, ai->ai_addr, ai->ai_addrlen); - closesocket(fd); - - if(result) { - success = false; - break; - } - } - - freeaddrinfo(ai); - return success; -} - -int check_port(const char *name) { - if(try_bind(655)) { - return 655; - } - - fprintf(stderr, "Warning: could not bind to port 655. "); - - for(int i = 0; i < 100; i++) { - int port = 0x1000 + (rand() & 0x7fff); - - if(try_bind(port)) { - char filename[PATH_MAX]; - snprintf(filename, sizeof(filename), "%s" SLASH "hosts" SLASH "%s", confbase, name); - FILE *f = fopen(filename, "a"); - - if(!f) { - fprintf(stderr, "Could not open %s: %s\n", filename, strerror(errno)); - fprintf(stderr, "Please change tinc's Port manually.\n"); - return 0; - } - - fprintf(f, "Port = %d\n", port); - fclose(f); - fprintf(stderr, "Tinc will instead listen on port %d.\n", port); - return port; - } - } - - fprintf(stderr, "Please change tinc's Port manually.\n"); - return 0; -} - -static int cmd_init(int argc, char *argv[]) { - if(!access(tinc_conf, F_OK)) { - fprintf(stderr, "Configuration file %s already exists!\n", tinc_conf); - return 1; - } - - if(argc > 2) { - fprintf(stderr, "Too many arguments!\n"); - return 1; - } else if(argc < 2) { - if(tty) { - char buf[1024]; - fprintf(stderr, "Enter the Name you want your tinc node to have: "); - - if(!fgets(buf, sizeof(buf), stdin)) { - fprintf(stderr, "Error while reading stdin: %s\n", strerror(errno)); - return 1; - } - - int len = rstrip(buf); - - if(!len) { - fprintf(stderr, "No name given!\n"); - return 1; - } - - name = strdup(buf); - } else { - fprintf(stderr, "No Name given!\n"); - return 1; - } - } else { - name = strdup(argv[1]); - - if(!*name) { - fprintf(stderr, "No Name given!\n"); - return 1; - } - } - - if(!check_id(name)) { - fprintf(stderr, "Invalid Name! Only a-z, A-Z, 0-9 and _ are allowed characters.\n"); - return 1; - } - - if(!confbase_given && mkdir(confdir, 0755) && errno != EEXIST) { - fprintf(stderr, "Could not create directory %s: %s\n", confdir, strerror(errno)); - return 1; - } - - if(mkdir(confbase, 0777) && errno != EEXIST) { - fprintf(stderr, "Could not create directory %s: %s\n", confbase, strerror(errno)); - return 1; - } - - if(mkdir(hosts_dir, 0777) && errno != EEXIST) { - fprintf(stderr, "Could not create directory %s: %s\n", hosts_dir, strerror(errno)); - return 1; - } - - FILE *f = fopen(tinc_conf, "w"); - - if(!f) { - fprintf(stderr, "Could not create file %s: %s\n", tinc_conf, strerror(errno)); - return 1; - } - - fprintf(f, "Name = %s\n", name); - fclose(f); - -#ifndef DISABLE_LEGACY - - if(!rsa_keygen(2048, false)) { - return 1; - } - -#endif - - if(!ed25519_keygen(false)) { - return 1; - } - - check_port(name); - -#ifndef HAVE_MINGW - char filename[PATH_MAX]; - snprintf(filename, sizeof(filename), "%s" SLASH "tinc-up", confbase); - - if(access(filename, F_OK)) { - FILE *f = fopenmask(filename, "w", 0777); - - if(!f) { - fprintf(stderr, "Could not create file %s: %s\n", filename, strerror(errno)); - return 1; - } - - fprintf(f, "#!/bin/sh\n\necho 'Unconfigured tinc-up script, please edit '$0'!'\n\n#ifconfig $INTERFACE netmask \n"); - fclose(f); - } - -#endif - - return 0; - -} - -static int cmd_generate_keys(int argc, char *argv[]) { -#ifdef DISABLE_LEGACY - - if(argc > 1) { -#else - - if(argc > 2) { -#endif - fprintf(stderr, "Too many arguments!\n"); - return 1; - } - - if(!name) { - name = get_my_name(false); - } - -#ifndef DISABLE_LEGACY - - if(!rsa_keygen(argc > 1 ? atoi(argv[1]) : 2048, true)) { - return 1; - } - -#endif - - if(!ed25519_keygen(true)) { - return 1; - } - - return 0; -} - -#ifndef DISABLE_LEGACY -static int cmd_generate_rsa_keys(int argc, char *argv[]) { - if(argc > 2) { - fprintf(stderr, "Too many arguments!\n"); - return 1; - } - - if(!name) { - name = get_my_name(false); - } - - return !rsa_keygen(argc > 1 ? atoi(argv[1]) : 2048, true); -} -#endif - -static int cmd_generate_ed25519_keys(int argc, char *argv[]) { - (void)argv; - - if(argc > 1) { - fprintf(stderr, "Too many arguments!\n"); - return 1; - } - - if(!name) { - name = get_my_name(false); - } - - return !ed25519_keygen(true); -} - -static int cmd_help(int argc, char *argv[]) { - (void)argc; - (void)argv; - - usage(false); - return 0; -} - -static int cmd_version(int argc, char *argv[]) { - (void)argv; - - if(argc > 1) { - fprintf(stderr, "Too many arguments!\n"); - return 1; - } - - version(); - return 0; -} - -static int cmd_info(int argc, char *argv[]) { - if(argc != 2) { - fprintf(stderr, "Invalid number of arguments.\n"); - return 1; - } - - if(!connect_tincd(true)) { - return 1; - } - - return info(fd, argv[1]); -} - -static const char *conffiles[] = { - "tinc.conf", - "tinc-up", - "tinc-down", - "subnet-up", - "subnet-down", - "host-up", - "host-down", - NULL, -}; - -static int cmd_edit(int argc, char *argv[]) { - if(argc != 2) { - fprintf(stderr, "Invalid number of arguments.\n"); - return 1; - } - - char filename[PATH_MAX] = ""; - - if(strncmp(argv[1], "hosts" SLASH, 6)) { - for(int i = 0; conffiles[i]; i++) { - if(!strcmp(argv[1], conffiles[i])) { - snprintf(filename, sizeof(filename), "%s" SLASH "%s", confbase, argv[1]); - break; - } - } - } else { - argv[1] += 6; - } - - if(!*filename) { - snprintf(filename, sizeof(filename), "%s" SLASH "%s", hosts_dir, argv[1]); - char *dash = strchr(argv[1], '-'); - - if(dash) { - *dash++ = 0; - - if((strcmp(dash, "up") && strcmp(dash, "down")) || !check_id(argv[1])) { - fprintf(stderr, "Invalid configuration filename.\n"); - return 1; - } - } - } - - char *command; -#ifndef HAVE_MINGW - const char *editor = getenv("VISUAL"); - if (!editor) - editor = getenv("EDITOR"); - if (!editor) - editor = "vi"; - - xasprintf(&command, "\"%s\" \"%s\"", editor, filename); -#else - xasprintf(&command, "edit \"%s\"", filename); -#endif - int result = system(command); - free(command); - - if(result) { - return result; - } - - // Silently try notifying a running tincd of changes. - if(connect_tincd(false)) { - sendline(fd, "%d %d", CONTROL, REQ_RELOAD); - } - - return 0; -} - -static int export(const char *name, FILE *out) { - char filename[PATH_MAX]; - snprintf(filename, sizeof(filename), "%s" SLASH "%s", hosts_dir, name); - FILE *in = fopen(filename, "r"); - - if(!in) { - fprintf(stderr, "Could not open configuration file %s: %s\n", filename, strerror(errno)); - return 1; - } - - fprintf(out, "Name = %s\n", name); - char buf[4096]; - - while(fgets(buf, sizeof(buf), in)) { - if(strcspn(buf, "\t =") != 4 || strncasecmp(buf, "Name", 4)) { - fputs(buf, out); - } - } - - if(ferror(in)) { - fprintf(stderr, "Error while reading configuration file %s: %s\n", filename, strerror(errno)); - fclose(in); - return 1; - } - - fclose(in); - return 0; -} - -static int cmd_export(int argc, char *argv[]) { - (void)argv; - - if(argc > 1) { - fprintf(stderr, "Too many arguments!\n"); - return 1; - } - - char *name = get_my_name(true); - - if(!name) { - return 1; - } - - int result = export(name, stdout); - - if(!tty) { - fclose(stdout); - } - - free(name); - return result; -} - -static int cmd_export_all(int argc, char *argv[]) { - (void)argv; - - if(argc > 1) { - fprintf(stderr, "Too many arguments!\n"); - return 1; - } - - DIR *dir = opendir(hosts_dir); - - if(!dir) { - fprintf(stderr, "Could not open host configuration directory %s: %s\n", hosts_dir, strerror(errno)); - return 1; - } - - bool first = true; - int result = 0; - struct dirent *ent; - - while((ent = readdir(dir))) { - if(!check_id(ent->d_name)) { - continue; - } - - if(first) { - first = false; - } else { - printf("#---------------------------------------------------------------#\n"); - } - - result |= export(ent->d_name, stdout); - } - - closedir(dir); - - if(!tty) { - fclose(stdout); - } - - return result; -} - -static int cmd_import(int argc, char *argv[]) { - (void)argv; - - if(argc > 1) { - fprintf(stderr, "Too many arguments!\n"); - return 1; - } - - FILE *in = stdin; - FILE *out = NULL; - - char buf[4096]; - char name[4096]; - char filename[PATH_MAX] = ""; - int count = 0; - bool firstline = true; - - while(fgets(buf, sizeof(buf), in)) { - if(sscanf(buf, "Name = %4095s", name) == 1) { - firstline = false; - - if(!check_id(name)) { - fprintf(stderr, "Invalid Name in input!\n"); - return 1; - } - - if(out) { - fclose(out); - } - - if((size_t)snprintf(filename, sizeof(filename), "%s" SLASH "%s", hosts_dir, name) >= sizeof(filename)) { - fprintf(stderr, "Filename too long: %s" SLASH "%s\n", hosts_dir, name); - return 1; - } - - if(!force && !access(filename, F_OK)) { - fprintf(stderr, "Host configuration file %s already exists, skipping.\n", filename); - out = NULL; - continue; - } - - out = fopen(filename, "w"); - - if(!out) { - fprintf(stderr, "Error creating configuration file %s: %s\n", filename, strerror(errno)); - return 1; - } - - count++; - continue; - } else if(firstline) { - fprintf(stderr, "Junk at the beginning of the input, ignoring.\n"); - firstline = false; - } - - - if(!strcmp(buf, "#---------------------------------------------------------------#\n")) { - continue; - } - - if(out) { - if(fputs(buf, out) < 0) { - fprintf(stderr, "Error writing to host configuration file %s: %s\n", filename, strerror(errno)); - return 1; - } - } - } - - if(out) { - fclose(out); - } - - if(count) { - fprintf(stderr, "Imported %d host configuration files.\n", count); - return 0; - } else { - fprintf(stderr, "No host configuration files imported.\n"); - return 1; - } -} - -static int cmd_exchange(int argc, char *argv[]) { - return cmd_export(argc, argv) ? 1 : cmd_import(argc, argv); -} - -static int cmd_exchange_all(int argc, char *argv[]) { - return cmd_export_all(argc, argv) ? 1 : cmd_import(argc, argv); -} - -static int switch_network(char *name) { - if(strcmp(name, ".")) { - if(!check_netname(name, false)) { - fprintf(stderr, "Invalid character in netname!\n"); - return 1; - } - - if(!check_netname(name, true)) { - fprintf(stderr, "Warning: unsafe character in netname!\n"); - } - } - - if(fd >= 0) { - close(fd); - fd = -1; - } - - free_names(); - netname = strcmp(name, ".") ? xstrdup(name) : NULL; - make_names(false); - - free(tinc_conf); - free(hosts_dir); - free(prompt); - - xasprintf(&tinc_conf, "%s" SLASH "tinc.conf", confbase); - xasprintf(&hosts_dir, "%s" SLASH "hosts", confbase); - xasprintf(&prompt, "%s> ", identname); - - return 0; -} - -static int cmd_network(int argc, char *argv[]) { - if(argc > 2) { - fprintf(stderr, "Too many arguments!\n"); - return 1; - } - - if(argc == 2) { - return switch_network(argv[1]); - } - - DIR *dir = opendir(confdir); - - if(!dir) { - fprintf(stderr, "Could not read directory %s: %s\n", confdir, strerror(errno)); - return 1; - } - - struct dirent *ent; - - while((ent = readdir(dir))) { - if(*ent->d_name == '.') { - continue; - } - - if(!strcmp(ent->d_name, "tinc.conf")) { - printf(".\n"); - continue; - } - - char fname[PATH_MAX]; - snprintf(fname, sizeof(fname), "%s/%s/tinc.conf", confdir, ent->d_name); - - if(!access(fname, R_OK)) { - printf("%s\n", ent->d_name); - } - } - - closedir(dir); - - return 0; -} - -static int cmd_fsck(int argc, char *argv[]) { - (void)argv; - - if(argc > 1) { - fprintf(stderr, "Too many arguments!\n"); - return 1; - } - - return fsck(orig_argv[0]); -} - -static void *readfile(FILE *in, size_t *len) { - size_t count = 0; - size_t bufsize = 4096; - char *buf = xmalloc(bufsize); - - while(!feof(in)) { - size_t read = fread(buf + count, 1, bufsize - count, in); - - if(!read) { - break; - } - - count += read; - - if(count >= bufsize) { - bufsize *= 2; - buf = xrealloc(buf, bufsize); - } - } - - if(len) { - *len = count; - } - - return buf; -} - -static int cmd_sign(int argc, char *argv[]) { - if(argc > 2) { - fprintf(stderr, "Too many arguments!\n"); - return 1; - } - - if(!name) { - name = get_my_name(true); - - if(!name) { - return 1; - } - } - - char fname[PATH_MAX]; - snprintf(fname, sizeof(fname), "%s" SLASH "ed25519_key.priv", confbase); - FILE *fp = fopen(fname, "r"); - - if(!fp) { - fprintf(stderr, "Could not open %s: %s\n", fname, strerror(errno)); - return 1; - } - - ecdsa_t *key = ecdsa_read_pem_private_key(fp); - - if(!key) { - fprintf(stderr, "Could not read private key from %s\n", fname); - fclose(fp); - return 1; - } - - fclose(fp); - - FILE *in; - - if(argc == 2) { - in = fopen(argv[1], "rb"); - - if(!in) { - fprintf(stderr, "Could not open %s: %s\n", argv[1], strerror(errno)); - ecdsa_free(key); - return 1; - } - } else { - in = stdin; - } - - size_t len; - char *data = readfile(in, &len); - - if(in != stdin) { - fclose(in); - } - - if(!data) { - fprintf(stderr, "Error reading %s: %s\n", argv[1], strerror(errno)); - ecdsa_free(key); - return 1; - } - - // Ensure we sign our name and current time as well - long t = time(NULL); - char *trailer; - xasprintf(&trailer, " %s %ld", name, t); - int trailer_len = strlen(trailer); - - data = xrealloc(data, len + trailer_len); - memcpy(data + len, trailer, trailer_len); - free(trailer); - - char sig[87]; - - if(!ecdsa_sign(key, data, len + trailer_len, sig)) { - fprintf(stderr, "Error generating signature\n"); - free(data); - ecdsa_free(key); - return 1; - } - - b64encode(sig, sig, 64); - ecdsa_free(key); - - fprintf(stdout, "Signature = %s %ld %s\n", name, t, sig); - fwrite(data, len, 1, stdout); - - free(data); - return 0; -} - -static int cmd_verify(int argc, char *argv[]) { - if(argc < 2) { - fprintf(stderr, "Not enough arguments!\n"); - return 1; - } - - if(argc > 3) { - fprintf(stderr, "Too many arguments!\n"); - return 1; - } - - char *node = argv[1]; - - if(!strcmp(node, ".")) { - if(!name) { - name = get_my_name(true); - - if(!name) { - return 1; - } - } - - node = name; - } else if(!strcmp(node, "*")) { - node = NULL; - } else { - if(!check_id(node)) { - fprintf(stderr, "Invalid node name\n"); - return 1; - } - } - - FILE *in; - - if(argc == 3) { - in = fopen(argv[2], "rb"); - - if(!in) { - fprintf(stderr, "Could not open %s: %s\n", argv[2], strerror(errno)); - return 1; - } - } else { - in = stdin; - } - - size_t len; - char *data = readfile(in, &len); - - if(in != stdin) { - fclose(in); - } - - if(!data) { - fprintf(stderr, "Error reading %s: %s\n", argv[1], strerror(errno)); - return 1; - } - - char *newline = memchr(data, '\n', len); - - if(!newline || (newline - data > MAX_STRING_SIZE - 1)) { - fprintf(stderr, "Invalid input\n"); - free(data); - return 1; - } - - *newline++ = '\0'; - size_t skip = newline - data; - - char signer[MAX_STRING_SIZE] = ""; - char sig[MAX_STRING_SIZE] = ""; - long t = 0; - - if(sscanf(data, "Signature = %s %ld %s", signer, &t, sig) != 3 || strlen(sig) != 86 || !t || !check_id(signer)) { - fprintf(stderr, "Invalid input\n"); - free(data); - return 1; - } - - if(node && strcmp(node, signer)) { - fprintf(stderr, "Signature is not made by %s\n", node); - free(data); - return 1; - } - - if(!node) { - node = signer; - } - - char *trailer; - xasprintf(&trailer, " %s %ld", signer, t); - int trailer_len = strlen(trailer); - - data = xrealloc(data, len + trailer_len); - memcpy(data + len, trailer, trailer_len); - free(trailer); - - newline = data + skip; - - char fname[PATH_MAX]; - snprintf(fname, sizeof(fname), "%s" SLASH "hosts" SLASH "%s", confbase, node); - FILE *fp = fopen(fname, "r"); - - if(!fp) { - fprintf(stderr, "Could not open %s: %s\n", fname, strerror(errno)); - free(data); - return 1; - } - - ecdsa_t *key = get_pubkey(fp); - - if(!key) { - rewind(fp); - key = ecdsa_read_pem_public_key(fp); - } - - if(!key) { - fprintf(stderr, "Could not read public key from %s\n", fname); - fclose(fp); - free(data); - return 1; - } - - fclose(fp); - - if(b64decode(sig, sig, 86) != 64 || !ecdsa_verify(key, newline, len + trailer_len - (newline - data), sig)) { - fprintf(stderr, "Invalid signature\n"); - free(data); - ecdsa_free(key); - return 1; - } - - ecdsa_free(key); - - fwrite(newline, len - (newline - data), 1, stdout); - - free(data); - return 0; -} - -static const struct { - const char *command; - int (*function)(int argc, char *argv[]); - bool hidden; -} commands[] = { - {"start", cmd_start, false}, - {"stop", cmd_stop, false}, - {"restart", cmd_restart, false}, - {"reload", cmd_reload, false}, - {"dump", cmd_dump, false}, - {"list", cmd_dump, false}, - {"purge", cmd_purge, false}, - {"debug", cmd_debug, false}, - {"retry", cmd_retry, false}, - {"connect", cmd_connect, false}, - {"disconnect", cmd_disconnect, false}, - {"top", cmd_top, false}, - {"pcap", cmd_pcap, false}, - {"log", cmd_log, false}, - {"pid", cmd_pid, false}, - {"config", cmd_config, true}, - {"add", cmd_config, false}, - {"del", cmd_config, false}, - {"get", cmd_config, false}, - {"set", cmd_config, false}, - {"init", cmd_init, false}, - {"generate-keys", cmd_generate_keys, false}, -#ifndef DISABLE_LEGACY - {"generate-rsa-keys", cmd_generate_rsa_keys, false}, -#endif - {"generate-ed25519-keys", cmd_generate_ed25519_keys, false}, - {"help", cmd_help, false}, - {"version", cmd_version, false}, - {"info", cmd_info, false}, - {"edit", cmd_edit, false}, - {"export", cmd_export, false}, - {"export-all", cmd_export_all, false}, - {"import", cmd_import, false}, - {"exchange", cmd_exchange, false}, - {"exchange-all", cmd_exchange_all, false}, - {"invite", cmd_invite, false}, - {"join", cmd_join, false}, - {"network", cmd_network, false}, - {"fsck", cmd_fsck, false}, - {"sign", cmd_sign, false}, - {"verify", cmd_verify, false}, - {NULL, NULL, false}, -}; - -#ifdef HAVE_READLINE -static char *complete_command(const char *text, int state) { - static int i; - - if(!state) { - i = 0; - } else { - i++; - } - - while(commands[i].command) { - if(!commands[i].hidden && !strncasecmp(commands[i].command, text, strlen(text))) { - return xstrdup(commands[i].command); - } - - i++; - } - - return NULL; -} - -static char *complete_dump(const char *text, int state) { - const char *matches[] = {"reachable", "nodes", "edges", "subnets", "connections", "graph", NULL}; - static int i; - - if(!state) { - i = 0; - } else { - i++; - } - - while(matches[i]) { - if(!strncasecmp(matches[i], text, strlen(text))) { - return xstrdup(matches[i]); - } - - i++; - } - - return NULL; -} - -static char *complete_config(const char *text, int state) { - static int i; - - if(!state) { - i = 0; - } else { - i++; - } - - while(variables[i].name) { - char *dot = strchr(text, '.'); - - if(dot) { - if((variables[i].type & VAR_HOST) && !strncasecmp(variables[i].name, dot + 1, strlen(dot + 1))) { - char *match; - xasprintf(&match, "%.*s.%s", (int)(dot - text), text, variables[i].name); - return match; - } - } else { - if(!strncasecmp(variables[i].name, text, strlen(text))) { - return xstrdup(variables[i].name); - } - } - - i++; - } - - return NULL; -} - -static char *complete_info(const char *text, int state) { - static int i; - - if(!state) { - i = 0; - - if(!connect_tincd(false)) { - return NULL; - } - - // Check the list of nodes - sendline(fd, "%d %d", CONTROL, REQ_DUMP_NODES); - sendline(fd, "%d %d", CONTROL, REQ_DUMP_SUBNETS); - } - - while(recvline(fd, line, sizeof(line))) { - char item[4096]; - int n = sscanf(line, "%d %d %4095s", &code, &req, item); - - if(n == 2) { - i++; - - if(i >= 2) { - break; - } else { - continue; - } - } - - if(n != 3) { - fprintf(stderr, "Unable to parse dump from tincd, n = %d, i = %d.\n", n, i); - break; - } - - if(!strncmp(item, text, strlen(text))) { - return xstrdup(strip_weight(item)); - } - } - - return NULL; -} - -static char *complete_nothing(const char *text, int state) { - (void)text; - (void)state; - return NULL; -} - -static char **completion(const char *text, int start, int end) { - (void)end; - char **matches = NULL; - - if(!start) { - matches = rl_completion_matches(text, complete_command); - } else if(!strncasecmp(rl_line_buffer, "dump ", 5)) { - matches = rl_completion_matches(text, complete_dump); - } else if(!strncasecmp(rl_line_buffer, "add ", 4)) { - matches = rl_completion_matches(text, complete_config); - } else if(!strncasecmp(rl_line_buffer, "del ", 4)) { - matches = rl_completion_matches(text, complete_config); - } else if(!strncasecmp(rl_line_buffer, "get ", 4)) { - matches = rl_completion_matches(text, complete_config); - } else if(!strncasecmp(rl_line_buffer, "set ", 4)) { - matches = rl_completion_matches(text, complete_config); - } else if(!strncasecmp(rl_line_buffer, "info ", 5)) { - matches = rl_completion_matches(text, complete_info); - } - - return matches; -} -#endif - -static int cmd_shell(int argc, char *argv[]) { - xasprintf(&prompt, "%s> ", identname); - int result = 0; - char buf[4096]; - char *line = NULL; - int maxargs = argc + 16; - char **nargv = xmalloc(maxargs * sizeof(*nargv)); - - for(int i = 0; i < argc; i++) { - nargv[i] = argv[i]; - } - -#ifdef HAVE_READLINE - rl_readline_name = "tinc"; - rl_completion_entry_function = complete_nothing; - rl_attempted_completion_function = completion; - rl_filename_completion_desired = 0; - char *copy = NULL; -#endif - - while(true) { -#ifdef HAVE_READLINE - - if(tty) { - free(copy); - free(line); - rl_basic_word_break_characters = "\t\n "; - line = readline(prompt); - copy = line ? xstrdup(line) : NULL; - } else { - line = fgets(buf, sizeof(buf), stdin); - } - -#else - - if(tty) { - fputs(prompt, stdout); - } - - line = fgets(buf, sizeof(buf), stdin); -#endif - - if(!line) { - break; - } - - /* Ignore comments */ - - if(*line == '#') { - continue; - } - - /* Split */ - - int nargc = argc; - char *p = line + strspn(line, " \t\n"); - char *next = strtok(p, " \t\n"); - - while(p && *p) { - if(nargc >= maxargs) { - maxargs *= 2; - nargv = xrealloc(nargv, maxargs * sizeof(*nargv)); - } - - nargv[nargc++] = p; - p = next; - next = strtok(NULL, " \t\n"); - } - - if(nargc == argc) { - continue; - } - - if(!strcasecmp(nargv[argc], "exit") || !strcasecmp(nargv[argc], "quit")) { -#ifdef HAVE_READLINE - free(copy); -#endif - free(nargv); - return result; - } - - bool found = false; - - for(int i = 0; commands[i].command; i++) { - if(!strcasecmp(nargv[argc], commands[i].command)) { - result |= commands[i].function(nargc - argc - 1, nargv + argc + 1); - found = true; - break; - } - } - -#ifdef HAVE_READLINE - - if(tty && found) { - add_history(copy); - } - -#endif - - if(!found) { - fprintf(stderr, "Unknown command `%s'.\n", nargv[argc]); - result |= 1; - } - } - -#ifdef HAVE_READLINE - free(copy); -#endif - free(nargv); - - if(tty) { - printf("\n"); - } - - return result; -} - - -int main(int argc, char *argv[]) { - program_name = argv[0]; - orig_argv = argv; - orig_argc = argc; - tty = isatty(0) && isatty(1); - - if(!parse_options(argc, argv)) { - return 1; - } - - make_names(false); - xasprintf(&tinc_conf, "%s" SLASH "tinc.conf", confbase); - xasprintf(&hosts_dir, "%s" SLASH "hosts", confbase); - - if(show_version) { - version(); - return 0; - } - - if(show_help) { - usage(false); - return 0; - } - -#ifdef HAVE_MINGW - static struct WSAData wsa_state; - - if(WSAStartup(MAKEWORD(2, 2), &wsa_state)) { - fprintf(stderr, "System call `%s' failed: %s\n", "WSAStartup", winerror(GetLastError())); - return false; - } - -#endif - - srand(time(NULL)); - crypto_init(); - - if(optind >= argc) { - return cmd_shell(argc, argv); - } - - for(int i = 0; commands[i].command; i++) { - if(!strcasecmp(argv[optind], commands[i].command)) { - return commands[i].function(argc - optind, argv + optind); - } - } - - fprintf(stderr, "Unknown command `%s'.\n", argv[optind]); - usage(true); - return 1; -} diff --git a/src/tincctl.h b/src/tincctl.h deleted file mode 100644 index 3f7d003..0000000 --- a/src/tincctl.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef TINC_TINCCTL_H -#define TINC_TINCCTL_H - -/* - tincctl.h -- header for tincctl.c. - Copyright (C) 2011-2016 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -extern bool tty; -extern bool force; -extern char line[4096]; -extern int fd; -extern char buffer[4096]; -extern size_t blen; -extern bool confbasegiven; -extern char *tinc_conf; -extern char *hosts_dir; - -#define VAR_SERVER 1 /* Should be in tinc.conf */ -#define VAR_HOST 2 /* Can be in host config file */ -#define VAR_MULTIPLE 4 /* Multiple statements allowed */ -#define VAR_OBSOLETE 8 /* Should not be used anymore */ -#define VAR_SAFE 16 /* Variable is safe when accepting invitations */ - -typedef struct { - const char *name; - int type; -} var_t; - -extern const var_t variables[]; - -extern int rstrip(char *value); -extern char *get_my_name(bool verbose); -extern bool connect_tincd(bool verbose); -extern bool sendline(int fd, char *format, ...); -extern bool recvline(int fd, char *line, size_t len); -extern int check_port(const char *name); -extern FILE *fopenmask(const char *filename, const char *mode, mode_t perms); -extern ecdsa_t *get_pubkey(FILE *f); - -#endif diff --git a/src/tincd.c b/src/tincd.c index dbf6bc8..066ad9c 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -1,7 +1,7 @@ /* tincd.c -- the main file for tincd Copyright (C) 1998-2005 Ivo Timmermans - 2000-2018 Guus Sliepen + 2000-2019 Guus Sliepen 2008 Max Rijevski 2009 Michael Tokarev 2010 Julien Muchembled @@ -33,6 +33,15 @@ #include #endif +#include +#include +#include +#include +#ifndef OPENSSL_NO_ENGINE +#include +#endif +#include + #ifdef HAVE_LZO #include LZO1X_H #endif @@ -43,66 +52,75 @@ #include #endif +#ifdef HAVE_GETOPT_LONG +#include +#else +#include "getopt.h" +#endif + +#include "pidfile.h" + #include "conf.h" -#include "control.h" -#include "crypto.h" #include "device.h" -#include "event.h" #include "logger.h" -#include "names.h" #include "net.h" #include "netutl.h" #include "process.h" #include "protocol.h" #include "utils.h" #include "xalloc.h" -#include "version.h" + +/* The name this program was run with. */ +char *program_name = NULL; /* If nonzero, display usage information and exit. */ -static bool show_help = false; +bool show_help = false; /* If nonzero, print the version on standard output and exit. */ -static bool show_version = false; +bool show_version = false; + +/* If nonzero, it will attempt to kill a running tincd and exit. */ +int kill_tincd = 0; + +/* If nonzero, generate public/private keypair for this host/net. */ +int generate_keys = 0; /* If nonzero, use null ciphers and skip all key exchanges. */ bool bypass_security = false; -#ifdef HAVE_MLOCKALL /* If nonzero, disable swapping for this process. */ -static bool do_mlock = false; -#endif +bool do_mlock = false; -#ifndef HAVE_MINGW /* If nonzero, chroot to netdir after startup. */ static bool do_chroot = false; /* If !NULL, do setuid to given user after startup */ static const char *switchuser = NULL; -#endif /* If nonzero, write log entries to a separate file. */ bool use_logfile = false; -/* If nonzero, use syslog instead of stderr in no-detach mode. */ -bool use_syslog = false; - -char **g_argv; /* a copy of the cmdline arguments */ +char *identname = NULL; /* program name for syslog */ +char *pidfilename = NULL; /* pid file location */ +char *logfilename = NULL; /* log file location */ +char **g_argv; /* a copy of the cmdline arguments */ static int status = 1; static struct option const long_options[] = { {"config", required_argument, NULL, 'c'}, + {"kill", optional_argument, NULL, 'k'}, {"net", required_argument, NULL, 'n'}, {"help", no_argument, NULL, 1}, {"version", no_argument, NULL, 2}, {"no-detach", no_argument, NULL, 'D'}, + {"generate-keys", optional_argument, NULL, 'K'}, {"debug", optional_argument, NULL, 'd'}, {"bypass-security", no_argument, NULL, 3}, {"mlock", no_argument, NULL, 'L'}, {"chroot", no_argument, NULL, 'R'}, {"user", required_argument, NULL, 'U'}, {"logfile", optional_argument, NULL, 4}, - {"syslog", no_argument, NULL, 's'}, {"pidfile", required_argument, NULL, 5}, {"option", required_argument, NULL, 'o'}, {NULL, 0, NULL, 0} @@ -110,6 +128,7 @@ static struct option const long_options[] = { #ifdef HAVE_MINGW static struct WSAData wsa_state; +CRITICAL_SECTION mutex; int main2(int argc, char **argv); #endif @@ -119,24 +138,20 @@ static void usage(bool status) { program_name); else { printf("Usage: %s [option]...\n\n", program_name); - printf(" -c, --config=DIR Read configuration options from DIR.\n" - " -D, --no-detach Don't fork and detach.\n" - " -d, --debug[=LEVEL] Increase debug level or set it to LEVEL.\n" - " -n, --net=NETNAME Connect to net NETNAME.\n" -#ifdef HAVE_MLOCKALL - " -L, --mlock Lock tinc into main memory.\n" -#endif - " --logfile[=FILENAME] Write log entries to a logfile.\n" - " -s --syslog Use syslog instead of stderr with --no-detach.\n" - " --pidfile=FILENAME Write PID and control socket cookie to FILENAME.\n" - " --bypass-security Disables meta protocol security, for debugging.\n" - " -o, --option[HOST.]KEY=VALUE Set global/host configuration value.\n" -#ifndef HAVE_MINGW - " -R, --chroot chroot to NET dir at startup.\n" - " -U, --user=USER setuid to given USER at startup.\n" -#endif - " --help Display this help and exit.\n" - " --version Output version information and exit.\n\n"); + printf(" -c, --config=DIR Read configuration options from DIR.\n" + " -D, --no-detach Don't fork and detach.\n" + " -d, --debug[=LEVEL] Increase debug level or set it to LEVEL.\n" + " -k, --kill[=SIGNAL] Attempt to kill a running tincd and exit.\n" + " -n, --net=NETNAME Connect to net NETNAME.\n" + " -K, --generate-keys[=BITS] Generate public/private RSA keypair.\n" + " -L, --mlock Lock tinc into main memory.\n" + " --logfile[=FILENAME] Write log entries to a logfile.\n" + " --pidfile=FILENAME Write PID to FILENAME.\n" + " -o, --option=[HOST.]KEY=VALUE Set global/host configuration value.\n" + " -R, --chroot chroot to NET dir at startup.\n" + " -U, --user=USER setuid to given USER at startup.\n" + " --help Display this help and exit.\n" + " --version Output version information and exit.\n\n"); printf("Report bugs to tinc@tinc-vpn.org.\n"); } } @@ -149,29 +164,35 @@ static bool parse_options(int argc, char **argv) { cmdline_conf = list_alloc((list_action_t)free_config); - while((r = getopt_long(argc, argv, "c:DLd::n:so:RU:", long_options, &option_index)) != EOF) { + while((r = getopt_long(argc, argv, "c:DLd::k::n:o:K::RU:", long_options, &option_index)) != EOF) { switch(r) { - case 0: /* long option */ + case 0: /* long option */ break; - case 'c': /* config file */ + case 'c': /* config file */ + if(confbase) { + fprintf(stderr, "Only one configuration directory can be given.\n"); + usage(true); + return false; + } + confbase = xstrdup(optarg); break; - case 'D': /* no detach */ + case 'D': /* no detach */ do_detach = false; break; - case 'L': /* no detach */ + case 'L': /* no detach */ #ifndef HAVE_MLOCKALL - logger(DEBUG_ALWAYS, LOG_ERR, "The %s option is not supported on this platform.", argv[optind - 1]); + logger(LOG_ERR, "%s not supported on this platform", "mlockall()"); return false; #else do_mlock = true; break; #endif - case 'd': /* increase debug level */ + case 'd': /* increase debug level */ if(!optarg && optind < argc && *argv[optind] != '-') { optarg = argv[optind++]; } @@ -184,16 +205,66 @@ static bool parse_options(int argc, char **argv) { break; - case 'n': /* net name given */ - netname = xstrdup(optarg); + case 'k': /* kill old tincds */ +#ifndef HAVE_MINGW + if(!optarg && optind < argc && *argv[optind] != '-') { + optarg = argv[optind++]; + } + + if(optarg) { + if(!strcasecmp(optarg, "HUP")) { + kill_tincd = SIGHUP; + } else if(!strcasecmp(optarg, "TERM")) { + kill_tincd = SIGTERM; + } else if(!strcasecmp(optarg, "KILL")) { + kill_tincd = SIGKILL; + } else if(!strcasecmp(optarg, "USR1")) { + kill_tincd = SIGUSR1; + } else if(!strcasecmp(optarg, "USR2")) { + kill_tincd = SIGUSR2; + } else if(!strcasecmp(optarg, "WINCH")) { + kill_tincd = SIGWINCH; + } else if(!strcasecmp(optarg, "INT")) { + kill_tincd = SIGINT; + } else if(!strcasecmp(optarg, "ALRM")) { + kill_tincd = SIGALRM; + } else if(!strcasecmp(optarg, "ABRT")) { + kill_tincd = SIGABRT; + } else { + kill_tincd = atoi(optarg); + + if(!kill_tincd) { + fprintf(stderr, "Invalid argument `%s'; SIGNAL must be a number or one of HUP, TERM, KILL, USR1, USR2, WINCH, INT or ALRM.\n", + optarg); + usage(true); + return false; + } + } + } else { + kill_tincd = SIGTERM; + } + +#else + kill_tincd = 1; +#endif break; - case 's': /* syslog */ - use_logfile = false; - use_syslog = true; + case 'n': /* net name given */ + + /* netname "." is special: a "top-level name" */ + if(netname) { + fprintf(stderr, "Only one netname can be given.\n"); + usage(true); + return false; + } + + if(optarg && strcmp(optarg, ".")) { + netname = xstrdup(optarg); + } + break; - case 'o': /* option */ + case 'o': /* option */ cfg = parse_config_line(optarg, NULL, ++lineno); if(!cfg) { @@ -203,37 +274,49 @@ static bool parse_options(int argc, char **argv) { list_insert_tail(cmdline_conf, cfg); break; -#ifdef HAVE_MINGW + case 'K': /* generate public/private keypair */ + if(!optarg && optind < argc && *argv[optind] != '-') { + optarg = argv[optind++]; + } - case 'R': - case 'U': - logger(DEBUG_ALWAYS, LOG_ERR, "The %s option is not supported on this platform.", argv[optind - 1]); - return false; -#else + if(optarg) { + generate_keys = atoi(optarg); - case 'R': /* chroot to NETNAME dir */ + if(generate_keys < 512) { + fprintf(stderr, "Invalid argument `%s'; BITS must be a number equal to or greater than 512.\n", + optarg); + usage(true); + return false; + } + + generate_keys &= ~7; /* Round it to bytes */ + } else { + generate_keys = 2048; + } + + break; + + case 'R': /* chroot to NETNAME dir */ do_chroot = true; break; - case 'U': /* setuid to USER */ + case 'U': /* setuid to USER */ switchuser = optarg; break; -#endif - case 1: /* show help */ + case 1: /* show help */ show_help = true; break; - case 2: /* show version */ + case 2: /* show version */ show_version = true; break; - case 3: /* bypass security */ + case 3: /* bypass security */ bypass_security = true; break; - case 4: /* write log entries to a file */ - use_syslog = false; + case 4: /* write log entries to a file */ use_logfile = true; if(!optarg && optind < argc && *argv[optind] != '-') { @@ -241,16 +324,28 @@ static bool parse_options(int argc, char **argv) { } if(optarg) { + if(logfilename) { + fprintf(stderr, "Only one logfile can be given.\n"); + usage(true); + return false; + } + logfilename = xstrdup(optarg); } break; - case 5: /* open control socket here */ + case 5: /* write PID to a file */ + if(pidfilename) { + fprintf(stderr, "Only one pidfile can be given.\n"); + usage(true); + return false; + } + pidfilename = xstrdup(optarg); break; - case '?': /* wrong options */ + case '?': usage(true); return false; @@ -265,38 +360,239 @@ static bool parse_options(int argc, char **argv) { return false; } - if(!netname && (netname = getenv("NETNAME"))) { - netname = xstrdup(netname); + return true; +} + +/* This function prettyprints the key generation process */ + +static int indicator(int a, int b, BN_GENCB *cb) { + (void)cb; + + switch(a) { + case 0: + fprintf(stderr, "."); + break; + + case 1: + fprintf(stderr, "+"); + break; + + case 2: + fprintf(stderr, "-"); + break; + + case 3: + switch(b) { + case 0: + fprintf(stderr, " p\n"); + break; + + case 1: + fprintf(stderr, " q\n"); + break; + + default: + fprintf(stderr, "?"); + } + + break; + + default: + fprintf(stderr, "?"); } - /* netname "." is special: a "top-level name" */ + return 1; +} - if(netname && (!*netname || !strcmp(netname, "."))) { - free(netname); - netname = NULL; +#ifndef HAVE_BN_GENCB_NEW +BN_GENCB *BN_GENCB_new(void) { + return xmalloc_and_zero(sizeof(BN_GENCB)); +} + +void BN_GENCB_free(BN_GENCB *cb) { + free(cb); +} +#endif + +/* + Generate a public/private RSA keypair, and ask for a file to store + them in. +*/ +static bool keygen(int bits) { + BIGNUM *e = NULL; + RSA *rsa_key; + FILE *f; + char filename[PATH_MAX]; + BN_GENCB *cb; + int result; + + fprintf(stderr, "Generating %d bits keys:\n", bits); + + cb = BN_GENCB_new(); + + if(!cb) { + abort(); } - if(netname && !check_netname(netname, false)) { - fprintf(stderr, "Invalid character in netname!\n"); + BN_GENCB_set(cb, indicator, NULL); + + rsa_key = RSA_new(); + + if(BN_hex2bn(&e, "10001") == 0) { + abort(); + } + + if(!rsa_key || !e) { + abort(); + } + + result = RSA_generate_key_ex(rsa_key, bits, e, cb); + + BN_free(e); + BN_GENCB_free(cb); + + if(!result) { + fprintf(stderr, "Error during key generation!\n"); + RSA_free(rsa_key); + return false; + } else { + fprintf(stderr, "Done.\n"); + } + + snprintf(filename, sizeof(filename), "%s/rsa_key.priv", confbase); + f = ask_and_open(filename, "private RSA key"); + + if(!f) { + RSA_free(rsa_key); return false; } - if(netname && !check_netname(netname, true)) { - fprintf(stderr, "Warning: unsafe character in netname!\n"); +#ifdef HAVE_FCHMOD + /* Make it unreadable for others. */ + fchmod(fileno(f), 0600); +#endif + + fputc('\n', f); + PEM_write_RSAPrivateKey(f, rsa_key, NULL, NULL, 0, NULL, NULL); + fclose(f); + + char *name = get_name(); + + if(name) { + snprintf(filename, sizeof(filename), "%s/hosts/%s", confbase, name); + free(name); + } else { + snprintf(filename, sizeof(filename), "%s/rsa_key.pub", confbase); } + f = ask_and_open(filename, "public RSA key"); + + if(!f) { + RSA_free(rsa_key); + return false; + } + + fputc('\n', f); + PEM_write_RSAPublicKey(f, rsa_key); + fclose(f); + + RSA_free(rsa_key); + return true; } -static bool drop_privs(void) { -#ifndef HAVE_MINGW +/* + Set all files and paths according to netname +*/ +static void make_names(void) { +#ifdef HAVE_MINGW + HKEY key; + char installdir[1024] = ""; + DWORD len = sizeof(installdir); +#endif + + if(netname) { + xasprintf(&identname, "tinc.%s", netname); + } else { + identname = xstrdup("tinc"); + } + +#ifdef HAVE_MINGW + + if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\tinc", 0, KEY_READ, &key)) { + if(!RegQueryValueEx(key, NULL, 0, 0, (LPBYTE)installdir, &len)) { + if(!confbase) { + if(netname) { + xasprintf(&confbase, "%s/%s", installdir, netname); + } else { + xasprintf(&confbase, "%s", installdir); + } + } + + if(!logfilename) { + xasprintf(&logfilename, "%s/tinc.log", confbase); + } + } + + RegCloseKey(key); + + if(*installdir) { + return; + } + } + +#endif + + if(!pidfilename) { + xasprintf(&pidfilename, RUNSTATEDIR "/%s.pid", identname); + } + + if(!logfilename) { + xasprintf(&logfilename, LOCALSTATEDIR "/log/%s.log", identname); + } + + if(netname) { + if(!confbase) { + xasprintf(&confbase, CONFDIR "/tinc/%s", netname); + } else { + logger(LOG_INFO, "Both netname and configuration directory given, using the latter..."); + } + } else { + if(!confbase) { + xasprintf(&confbase, CONFDIR "/tinc"); + } + } +} + +static void free_names() { + free(identname); + free(netname); + free(pidfilename); + free(logfilename); + free(confbase); +} + +static bool drop_privs() { +#ifdef HAVE_MINGW + + if(switchuser) { + logger(LOG_ERR, "%s not supported on this platform", "-U"); + return false; + } + + if(do_chroot) { + logger(LOG_ERR, "%s not supported on this platform", "-R"); + return false; + } + +#else uid_t uid = 0; if(switchuser) { struct passwd *pw = getpwnam(switchuser); if(!pw) { - logger(DEBUG_ALWAYS, LOG_ERR, "unknown user `%s'", switchuser); + logger(LOG_ERR, "unknown user `%s'", switchuser); return false; } @@ -304,12 +600,12 @@ static bool drop_privs(void) { if(initgroups(switchuser, pw->pw_gid) != 0 || setgid(pw->pw_gid) != 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", + logger(LOG_ERR, "System call `%s' failed: %s", "initgroups", strerror(errno)); return false; } -#ifndef __ANDROID__ +#ifndef ANDROID // Not supported in android NDK endgrent(); endpwent(); @@ -320,7 +616,7 @@ static bool drop_privs(void) { tzset(); /* for proper timestamps in logs */ if(chroot(confbase) != 0 || chdir("/") != 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", + logger(LOG_ERR, "System call `%s' failed: %s", "chroot", strerror(errno)); return false; } @@ -331,7 +627,7 @@ static bool drop_privs(void) { if(switchuser) if(setuid(uid) != 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", + logger(LOG_ERR, "System call `%s' failed: %s", "setuid", strerror(errno)); return false; } @@ -342,20 +638,6 @@ static bool drop_privs(void) { #ifdef HAVE_MINGW # define setpriority(level) !SetPriorityClass(GetCurrentProcess(), (level)) - -static void stop_handler(void *data, int flags) { - event_exit(); -} - -static BOOL WINAPI console_ctrl_handler(DWORD type) { - logger(DEBUG_ALWAYS, LOG_NOTICE, "Got console shutdown request"); - - if(WSASetEvent(stop_io.event) == FALSE) { - abort(); - } - - return TRUE; -} #else # define NORMAL_PRIORITY_CLASS 0 # define BELOW_NORMAL_PRIORITY_CLASS 10 @@ -371,9 +653,8 @@ int main(int argc, char **argv) { } if(show_version) { - printf("%s version %s (built %s %s, protocol %d.%d)\n", PACKAGE, - BUILD_VERSION, BUILD_DATE, BUILD_TIME, PROT_MAJOR, PROT_MINOR); - printf("Copyright (C) 1998-2018 Ivo Timmermans, Guus Sliepen and others.\n" + printf("%s version %s\n", PACKAGE, VERSION); + printf("Copyright (C) 1998-2019 Ivo Timmermans, Guus Sliepen and others.\n" "See the AUTHORS file for a complete list.\n\n" "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" "and you are welcome to redistribute it under certain conditions;\n" @@ -387,38 +668,12 @@ int main(int argc, char **argv) { return 0; } - make_names(true); - chdir(confbase); + make_names(); -#ifdef HAVE_MINGW - - if(WSAStartup(MAKEWORD(2, 2), &wsa_state)) { - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "WSAStartup", winerror(GetLastError())); - return 1; + if(kill_tincd) { + return !kill_other(kill_tincd); } -#else - // Check if we got an umbilical fd from the process that started us - char *umbstr = getenv("TINC_UMBILICAL"); - - if(umbstr) { - umbilical = atoi(umbstr); - - if(fcntl(umbilical, F_GETFL) < 0) { - umbilical = 0; - } - -#ifdef FD_CLOEXEC - - if(umbilical) { - fcntl(umbilical, F_SETFD, FD_CLOEXEC); - } - -#endif - } - -#endif - openlogger("tinc", use_logfile ? LOGMODE_FILE : LOGMODE_STDERR); g_argv = argv; @@ -433,54 +688,50 @@ int main(int argc, char **argv) { init_configuration(&config_tree); - /* Slllluuuuuuurrrrp! */ +#ifndef OPENSSL_NO_ENGINE + ENGINE_load_builtin_engines(); + ENGINE_register_all_complete(); +#endif - gettimeofday(&now, NULL); - srand(now.tv_sec + now.tv_usec); - crypto_init(); +#if OPENSSL_VERSION_NUMBER < 0x10100000L + OpenSSL_add_all_algorithms(); +#endif + + if(generate_keys) { + read_server_config(); + return !keygen(generate_keys); + } if(!read_server_config()) { return 1; } - if(!debug_level) { - get_config_int(lookup_config(config_tree, "LogLevel"), &debug_level); - } - #ifdef HAVE_LZO if(lzo_init() != LZO_E_OK) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error initializing LZO compressor!"); + logger(LOG_ERR, "Error initializing LZO compressor!"); return 1; } #endif #ifdef HAVE_MINGW - io_add_event(&stop_io, stop_handler, NULL, WSACreateEvent()); - if(stop_io.event == FALSE) { - abort(); + if(WSAStartup(MAKEWORD(2, 2), &wsa_state)) { + logger(LOG_ERR, "System call `%s' failed: %s", "WSAStartup", winerror(GetLastError())); + return 1; } - int result; - if(!do_detach || !init_service()) { - SetConsoleCtrlHandler(console_ctrl_handler, TRUE); - result = main2(argc, argv); + return main2(argc, argv); } else { - result = 1; + return 1; } - - if(WSACloseEvent(stop_io.event) == FALSE) { - abort(); - } - - io_del(&stop_io); - return result; } int main2(int argc, char **argv) { + InitializeCriticalSection(&mutex); + EnterCriticalSection(&mutex); #endif char *priority = NULL; @@ -494,7 +745,7 @@ int main2(int argc, char **argv) { * This has to be done after daemon()/fork() so it works for child. * No need to do that in parent as it's very short-lived. */ if(do_mlock && mlockall(MCL_CURRENT | MCL_FUTURE) != 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "mlockall", + logger(LOG_ERR, "System call `%s' failed: %s", "mlockall", strerror(errno)); return 1; } @@ -507,26 +758,33 @@ int main2(int argc, char **argv) { goto end; } + /* Initiate all outgoing connections. */ + + try_outgoing_connections(); + /* Change process priority */ if(get_config_string(lookup_config(config_tree, "ProcessPriority"), &priority)) { if(!strcasecmp(priority, "Normal")) { if(setpriority(NORMAL_PRIORITY_CLASS) != 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "setpriority", strerror(errno)); + logger(LOG_ERR, "System call `%s' failed: %s", + "setpriority", strerror(errno)); goto end; } } else if(!strcasecmp(priority, "Low")) { if(setpriority(BELOW_NORMAL_PRIORITY_CLASS) != 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "setpriority", strerror(errno)); + logger(LOG_ERR, "System call `%s' failed: %s", + "setpriority", strerror(errno)); goto end; } } else if(!strcasecmp(priority, "High")) { if(setpriority(HIGH_PRIORITY_CLASS) != 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "setpriority", strerror(errno)); + logger(LOG_ERR, "System call `%s' failed: %s", + "setpriority", strerror(errno)); goto end; } } else { - logger(DEBUG_ALWAYS, LOG_ERR, "Invalid priority `%s`!", priority); + logger(LOG_ERR, "Invalid priority `%s`!", priority); goto end; } } @@ -538,31 +796,34 @@ int main2(int argc, char **argv) { /* Start main loop. It only exits when tinc is killed. */ - logger(DEBUG_ALWAYS, LOG_NOTICE, "Ready"); - - if(umbilical) { // snip! - write(umbilical, "", 1); - close(umbilical); - umbilical = 0; - } - - try_outgoing_connections(); - status = main_loop(); /* Shutdown properly. */ -end: + ifdebug(CONNECTIONS) + devops.dump_stats(); + close_network_connections(); - logger(DEBUG_ALWAYS, LOG_NOTICE, "Terminating"); +end: + logger(LOG_NOTICE, "Terminating"); + +#ifndef HAVE_MINGW + remove_pid(pidfilename); +#endif free(priority); - crypto_exit(); +#if OPENSSL_VERSION_NUMBER < 0x10100000L + EVP_cleanup(); + ERR_free_strings(); +#ifndef OPENSSL_NO_ENGINE + ENGINE_cleanup(); +#endif +#endif exit_configuration(&config_tree); - free(cmdline_conf); + list_delete_list(cmdline_conf); free_names(); return status; diff --git a/src/top.c b/src/top.c deleted file mode 100644 index ab14619..0000000 --- a/src/top.c +++ /dev/null @@ -1,396 +0,0 @@ -/* - top.c -- Show real-time statistics from a running tincd - Copyright (C) 2011-2013 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "system.h" - -#ifdef HAVE_CURSES - -#undef KEY_EVENT /* There are conflicting declarations for KEY_EVENT in Windows wincon.h and curses.h. */ -#include - -#include "control_common.h" -#include "list.h" -#include "names.h" -#include "tincctl.h" -#include "top.h" -#include "xalloc.h" - -typedef struct nodestats_t { - char *name; - int i; - uint64_t in_packets; - uint64_t in_bytes; - uint64_t out_packets; - uint64_t out_bytes; - float in_packets_rate; - float in_bytes_rate; - float out_packets_rate; - float out_bytes_rate; - bool known; -} nodestats_t; - -static const char *const sortname[] = { - "name", - "in pkts", - "in bytes", - "out pkts", - "out bytes", - "tot pkts", - "tot bytes", -}; - -static int sortmode = 0; -static bool cumulative = false; - -static list_t node_list; -static struct timeval cur, prev, diff; -static int delay = 1000; -static bool changed = true; -static const char *bunit = "bytes"; -static float bscale = 1; -static const char *punit = "pkts"; -static float pscale = 1; - -static bool update(int fd) { - if(!sendline(fd, "%d %d", CONTROL, REQ_DUMP_TRAFFIC)) { - return false; - } - - gettimeofday(&cur, NULL); - - timersub(&cur, &prev, &diff); - prev = cur; - float interval = diff.tv_sec + diff.tv_usec * 1e-6; - - char line[4096]; - char name[4096]; - int code; - int req; - uint64_t in_packets; - uint64_t in_bytes; - uint64_t out_packets; - uint64_t out_bytes; - - for list_each(nodestats_t, ns, &node_list) { - ns->known = false; - } - - while(recvline(fd, line, sizeof(line))) { - int n = sscanf(line, "%d %d %4095s %"PRIu64" %"PRIu64" %"PRIu64" %"PRIu64, &code, &req, name, &in_packets, &in_bytes, &out_packets, &out_bytes); - - if(n == 2) { - return true; - } - - if(n != 7) { - return false; - } - - nodestats_t *found = NULL; - - for list_each(nodestats_t, ns, &node_list) { - int result = strcmp(name, ns->name); - - if(result > 0) { - continue; - } - - if(result == 0) { - found = ns; - break; - } else { - found = xzalloc(sizeof(*found)); - found->name = xstrdup(name); - list_insert_before(&node_list, node, found); - changed = true; - break; - } - } - - if(!found) { - found = xzalloc(sizeof(*found)); - found->name = xstrdup(name); - list_insert_tail(&node_list, found); - changed = true; - } - - found->known = true; - found->in_packets_rate = (in_packets - found->in_packets) / interval; - found->in_bytes_rate = (in_bytes - found->in_bytes) / interval; - found->out_packets_rate = (out_packets - found->out_packets) / interval; - found->out_bytes_rate = (out_bytes - found->out_bytes) / interval; - found->in_packets = in_packets; - found->in_bytes = in_bytes; - found->out_packets = out_packets; - found->out_bytes = out_bytes; - } - - return false; -} - -static int cmpfloat(float a, float b) { - if(a < b) { - return -1; - } else if(a > b) { - return 1; - } else { - return 0; - } -} - -static int cmpu64(uint64_t a, uint64_t b) { - if(a < b) { - return -1; - } else if(a > b) { - return 1; - } else { - return 0; - } -} - -static int sortfunc(const void *a, const void *b) { - const nodestats_t *na = *(const nodestats_t **)a; - const nodestats_t *nb = *(const nodestats_t **)b; - int result; - - switch(sortmode) { - case 1: - if(cumulative) { - result = -cmpu64(na->in_packets, nb->in_packets); - } else { - result = -cmpfloat(na->in_packets_rate, nb->in_packets_rate); - } - - break; - - case 2: - if(cumulative) { - result = -cmpu64(na->in_bytes, nb->in_bytes); - } else { - result = -cmpfloat(na->in_bytes_rate, nb->in_bytes_rate); - } - - break; - - case 3: - if(cumulative) { - result = -cmpu64(na->out_packets, nb->out_packets); - } else { - result = -cmpfloat(na->out_packets_rate, nb->out_packets_rate); - } - - break; - - case 4: - if(cumulative) { - result = -cmpu64(na->out_bytes, nb->out_bytes); - } else { - result = -cmpfloat(na->out_bytes_rate, nb->out_bytes_rate); - } - - break; - - case 5: - if(cumulative) { - result = -cmpu64(na->in_packets + na->out_packets, nb->in_packets + nb->out_packets); - } else { - result = -cmpfloat(na->in_packets_rate + na->out_packets_rate, nb->in_packets_rate + nb->out_packets_rate); - } - - break; - - case 6: - if(cumulative) { - result = -cmpu64(na->in_bytes + na->out_bytes, nb->in_bytes + nb->out_bytes); - } else { - result = -cmpfloat(na->in_bytes_rate + na->out_bytes_rate, nb->in_bytes_rate + nb->out_bytes_rate); - } - - break; - - default: - result = strcmp(na->name, nb->name); - break; - } - - if(result) { - return result; - } else { - return na->i - nb->i; - } -} - -static void redraw(void) { - erase(); - - mvprintw(0, 0, "Tinc %-16s Nodes: %4d Sort: %-10s %s", netname ? netname : "", node_list.count, sortname[sortmode], cumulative ? "Cumulative" : "Current"); - attrset(A_REVERSE); - mvprintw(2, 0, "Node IN %s IN %s OUT %s OUT %s", punit, bunit, punit, bunit); - chgat(-1, A_REVERSE, 0, NULL); - - static nodestats_t **sorted = 0; - static int n = 0; - - if(changed) { - n = 0; - sorted = xrealloc(sorted, node_list.count * sizeof(*sorted)); - - for list_each(nodestats_t, ns, &node_list) { - sorted[n++] = ns; - } - - changed = false; - } - - for(int i = 0; i < n; i++) { - sorted[i]->i = i; - } - - if(sorted) { - qsort(sorted, n, sizeof(*sorted), sortfunc); - } - - for(int i = 0, row = 3; i < n; i++, row++) { - nodestats_t *node = sorted[i]; - - if(node->known) - if(node->in_packets_rate || node->out_packets_rate) { - attrset(A_BOLD); - } else { - attrset(A_NORMAL); - } else { - attrset(A_DIM); - } - - if(cumulative) - mvprintw(row, 0, "%-16s %10.0f %10.0f %10.0f %10.0f", - node->name, node->in_packets * pscale, node->in_bytes * bscale, node->out_packets * pscale, node->out_bytes * bscale); - else - mvprintw(row, 0, "%-16s %10.0f %10.0f %10.0f %10.0f", - node->name, node->in_packets_rate * pscale, node->in_bytes_rate * bscale, node->out_packets_rate * pscale, node->out_bytes_rate * bscale); - } - - attrset(A_NORMAL); - move(1, 0); - - refresh(); -} - -void top(int fd) { - initscr(); - timeout(delay); - bool running = true; - - while(running) { - if(!update(fd)) { - break; - } - - redraw(); - - switch(getch()) { - case 's': { - timeout(-1); - float input = delay * 1e-3; - mvprintw(1, 0, "Change delay from %.1fs to: ", input); - scanw("%f", &input); - - if(input < 0.1) { - input = 0.1; - } - - delay = input * 1e3; - timeout(delay); - break; - } - - case 'c': - cumulative = !cumulative; - break; - - case 'n': - sortmode = 0; - break; - - case 'i': - sortmode = 2; - break; - - case 'I': - sortmode = 1; - break; - - case 'o': - sortmode = 4; - break; - - case 'O': - sortmode = 3; - break; - - case 't': - sortmode = 6; - break; - - case 'T': - sortmode = 5; - break; - - case 'b': - bunit = "bytes"; - bscale = 1; - punit = "pkts"; - pscale = 1; - break; - - case 'k': - bunit = "kbyte"; - bscale = 1e-3; - punit = "pkts"; - pscale = 1; - break; - - case 'M': - bunit = "Mbyte"; - bscale = 1e-6; - punit = "kpkt"; - pscale = 1e-3; - break; - - case 'G': - bunit = "Gbyte"; - bscale = 1e-9; - punit = "Mpkt"; - pscale = 1e-6; - break; - - case 'q': - case KEY_BREAK: - running = false; - break; - - default: - break; - } - } - - endwin(); -} - -#endif diff --git a/src/top.h b/src/top.h deleted file mode 100644 index 612d0d8..0000000 --- a/src/top.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef TINC_TOP_H -#define TINC_TOP_H - -/* - top.h -- header for top.c. - Copyright (C) 2011 Guus Sliepen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -extern void top(int fd); - -#endif diff --git a/src/uml_device.c b/src/uml_device.c index a675b62..66de431 100644 --- a/src/uml_device.c +++ b/src/uml_device.c @@ -1,7 +1,7 @@ /* device.c -- UML network socket Copyright (C) 2002-2005 Ivo Timmermans, - 2002-2017 Guus Sliepen + 2002-2012 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,7 +24,6 @@ #include "conf.h" #include "device.h" -#include "names.h" #include "net.h" #include "logger.h" #include "utils.h" @@ -38,6 +37,12 @@ static int write_fd = -1; static int state = 0; static const char *device_info = "UML network socket"; +extern char *identname; +extern volatile bool running; + +static uint64_t device_total_in = 0; +static uint64_t device_total_out = 0; + enum request_type { REQ_NEW_CONTROL }; static struct request { @@ -66,8 +71,8 @@ static bool setup_device(void) { get_config_string(lookup_config(config_tree, "Interface"), &iface); if((write_fd = socket(PF_UNIX, SOCK_DGRAM, 0)) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not open write %s: %s", device_info, strerror(errno)); - event_exit(); + logger(LOG_ERR, "Could not open write %s: %s", device_info, strerror(errno)); + running = false; return false; } @@ -78,14 +83,14 @@ static bool setup_device(void) { setsockopt(write_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); if(fcntl(write_fd, F_SETFL, O_NONBLOCK) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno)); - event_exit(); + logger(LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno)); + running = false; return false; } if((data_fd = socket(PF_UNIX, SOCK_DGRAM, 0)) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not open data %s: %s", device_info, strerror(errno)); - event_exit(); + logger(LOG_ERR, "Could not open data %s: %s", device_info, strerror(errno)); + running = false; return false; } @@ -96,8 +101,8 @@ static bool setup_device(void) { setsockopt(data_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); if(fcntl(data_fd, F_SETFL, O_NONBLOCK) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno)); - event_exit(); + logger(LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno)); + running = false; return false; } @@ -109,13 +114,13 @@ static bool setup_device(void) { memcpy(&data_sun.sun_path, &name, sizeof(name)); if(bind(data_fd, (struct sockaddr *)&data_sun, sizeof(data_sun)) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not bind data %s: %s", device_info, strerror(errno)); - event_exit(); + logger(LOG_ERR, "Could not bind data %s: %s", device_info, strerror(errno)); + running = false; return false; } if((listen_fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not open %s: %s", device_info, + logger(LOG_ERR, "Could not open %s: %s", device_info, strerror(errno)); return false; } @@ -127,28 +132,27 @@ static bool setup_device(void) { setsockopt(listen_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); if(fcntl(listen_fd, F_SETFL, O_NONBLOCK) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno)); + logger(LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno)); return false; } listen_sun.sun_family = AF_UNIX; strncpy(listen_sun.sun_path, device, sizeof(listen_sun.sun_path)); - listen_sun.sun_path[sizeof(listen_sun.sun_path) - 1] = 0; if(bind(listen_fd, (struct sockaddr *)&listen_sun, sizeof(listen_sun)) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not bind %s to %s: %s", device_info, device, strerror(errno)); + logger(LOG_ERR, "Could not bind %s to %s: %s", device_info, device, strerror(errno)); return false; } if(listen(listen_fd, 1) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not listen on %s %s: %s", device_info, device, strerror(errno)); + logger(LOG_ERR, "Could not listen on %s %s: %s", device_info, device, strerror(errno)); return false; } device_fd = listen_fd; state = 0; - logger(DEBUG_ALWAYS, LOG_INFO, "%s is a %s", device, device_info); + logger(LOG_INFO, "%s is a %s", device, device_info); if(routing_mode == RMODE_ROUTER) { overwrite_mac = true; @@ -160,37 +164,28 @@ static bool setup_device(void) { void close_device(void) { if(listen_fd >= 0) { close(listen_fd); - listen_fd = -1; } if(request_fd >= 0) { close(request_fd); - request_fd = -1; } if(data_fd >= 0) { close(data_fd); - data_fd = -1; } if(write_fd >= 0) { close(write_fd); - write_fd = -1; } unlink(device); free(device); - device = NULL; - free(iface); - iface = NULL; - - device_info = NULL; } static bool read_packet(vpn_packet_t *packet) { - int inlen; + int lenin; switch(state) { case 0: { @@ -200,7 +195,7 @@ static bool read_packet(vpn_packet_t *packet) { request_fd = accept(listen_fd, &sa, &salen); if(request_fd < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not accept connection to %s %s: %s", device_info, device, strerror(errno)); + logger(LOG_ERR, "Could not accept connection to %s %s: %s", device_info, device, strerror(errno)); return false; } @@ -209,8 +204,8 @@ static bool read_packet(vpn_packet_t *packet) { #endif if(fcntl(listen_fd, F_SETFL, O_NONBLOCK) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno)); - event_exit(); + logger(LOG_ERR, "System call `%s' failed: %s", "fcntl", strerror(errno)); + running = false; return false; } @@ -223,82 +218,93 @@ static bool read_packet(vpn_packet_t *packet) { } case 1: { - if((inlen = read(request_fd, &request, sizeof(request))) != sizeof(request)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading request from %s %s: %s", device_info, + if((lenin = read(request_fd, &request, sizeof(request))) != sizeof request) { + logger(LOG_ERR, "Error while reading request from %s %s: %s", device_info, device, strerror(errno)); - event_exit(); + running = false; return false; } if(request.magic != 0xfeedface || request.version != 3 || request.type != REQ_NEW_CONTROL) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unknown magic %x, version %d, request type %d from %s %s", + logger(LOG_ERR, "Unknown magic %x, version %d, request type %d from %s %s", request.magic, request.version, request.type, device_info, device); - event_exit(); + running = false; return false; } - if(connect(write_fd, (const struct sockaddr *)&request.sock, sizeof(request.sock)) < 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not bind write %s: %s", device_info, strerror(errno)); - event_exit(); + if(connect(write_fd, (struct sockaddr *)&request.sock, sizeof(request.sock)) < 0) { + logger(LOG_ERR, "Could not bind write %s: %s", device_info, strerror(errno)); + running = false; return false; } write(request_fd, &data_sun, sizeof(data_sun)); device_fd = data_fd; - logger(DEBUG_ALWAYS, LOG_INFO, "Connection with UML established"); + logger(LOG_INFO, "Connection with UML established"); state = 2; return false; } case 2: { - if((inlen = read(data_fd, DATA(packet), MTU)) <= 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from %s %s: %s", device_info, + if((lenin = read(data_fd, packet->data, MTU)) <= 0) { + logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); - event_exit(); + running = false; return false; } - packet->len = inlen; + packet->len = lenin; - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, - device_info); + device_total_in += packet->len; + + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, + device_info); return true; } default: - logger(DEBUG_ALWAYS, LOG_ERR, "Invalid value for state variable in " __FILE__); + logger(LOG_ERR, "Invalid value for state variable in " __FILE__); abort(); } } static bool write_packet(vpn_packet_t *packet) { if(state != 2) { - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Dropping packet of %d bytes to %s: not connected to UML yet", - packet->len, device_info); + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Dropping packet of %d bytes to %s: not connected to UML yet", + packet->len, device_info); return false; } - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Writing packet of %d bytes to %s", - packet->len, device_info); + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Writing packet of %d bytes to %s", + packet->len, device_info); - if(write(write_fd, DATA(packet), packet->len) < 0) { + if(write(write_fd, packet->data, packet->len) < 0) { if(errno != EINTR && errno != EAGAIN) { - logger(DEBUG_ALWAYS, LOG_ERR, "Can't write to %s %s: %s", device_info, device, strerror(errno)); - event_exit(); + logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, strerror(errno)); + running = false; } return false; } + device_total_out += packet->len; + return true; } +static void dump_device_stats(void) { + logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); + logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); + logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); +} + const devops_t uml_devops = { .setup = setup_device, .close = close_device, .read = read_packet, .write = write_packet, + .dump_stats = dump_device_stats, }; diff --git a/src/upnp.c b/src/upnp.c deleted file mode 100644 index 5e41d1b..0000000 --- a/src/upnp.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - upnp.c -- UPnP-IGD client - Copyright (C) 2015 Guus Sliepen , - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "upnp.h" - -#include - -#include "miniupnpc/miniupnpc.h" -#include "miniupnpc/upnpcommands.h" -#include "miniupnpc/upnperrors.h" - -#include "system.h" -#include "logger.h" -#include "names.h" -#include "net.h" -#include "netutl.h" -#include "utils.h" - -static bool upnp_tcp; -static bool upnp_udp; -static int upnp_discover_wait = 5; -static int upnp_refresh_period = 60; - -// Unfortunately, libminiupnpc devs don't seem to care about API compatibility, -// and there are slight changes to function signatures between library versions. -// Well, at least they publish a "MINIUPNPC_API_VERSION" constant, so we got that going for us, which is nice. -// Differences between API versions are documented in "apiversions.txt" in the libminiupnpc distribution. - -#ifndef MINIUPNPC_API_VERSION -#define MINIUPNPC_API_VERSION 0 -#endif - -static struct UPNPDev *upnp_discover(int delay, int *error) { -#if MINIUPNPC_API_VERSION <= 13 - -#if MINIUPNPC_API_VERSION < 8 -#warning "The version of libminiupnpc you're building against seems to be too old. Expect trouble." -#endif - - return upnpDiscover(delay, NULL, NULL, false, false, error); - -#elif MINIUPNPC_API_VERSION <= 14 - - return upnpDiscover(delay, NULL, NULL, false, false, 2, error); - -#else - -#if MINIUPNPC_API_VERSION > 17 -#warning "The version of libminiupnpc you're building against seems to be too recent. Expect trouble." -#endif - - return upnpDiscover(delay, NULL, NULL, UPNP_LOCAL_PORT_ANY, false, 2, error); - -#endif -} - -static void upnp_add_mapping(struct UPNPUrls *urls, struct IGDdatas *data, const char *myaddr, int socket, const char *proto) { - // Extract the port from the listening socket. - // Note that we can't simply use listen_socket[].sa because this won't have the port - // if we're running with Port=0 (dynamically assigned port). - sockaddr_t sa; - socklen_t salen = sizeof(sa); - - if(getsockname(socket, &sa.sa, &salen)) { - logger(DEBUG_PROTOCOL, LOG_ERR, "[upnp] Unable to get socket address: [%d] %s", sockerrno, sockstrerror(sockerrno)); - return; - } - - char *port; - sockaddr2str(&sa, NULL, &port); - - if(!port) { - logger(DEBUG_PROTOCOL, LOG_ERR, "[upnp] Unable to get socket port"); - return; - } - - // Use a lease twice as long as the refresh period so that the mapping won't expire before we refresh. - char lease_duration[16]; - snprintf(lease_duration, sizeof(lease_duration), "%d", upnp_refresh_period * 2); - - int error = UPNP_AddPortMapping(urls->controlURL, data->first.servicetype, port, port, myaddr, identname, proto, NULL, lease_duration); - - if(error == 0) { - logger(DEBUG_PROTOCOL, LOG_INFO, "[upnp] Successfully set port mapping (%s:%s %s for %s seconds)", myaddr, port, proto, lease_duration); - } else { - logger(DEBUG_PROTOCOL, LOG_ERR, "[upnp] Failed to set port mapping (%s:%s %s for %s seconds): [%d] %s", myaddr, port, proto, lease_duration, error, strupnperror(error)); - } - - free(port); -} - -static void upnp_refresh() { - logger(DEBUG_PROTOCOL, LOG_INFO, "[upnp] Discovering IGD devices"); - - int error; - struct UPNPDev *devices = upnp_discover(upnp_discover_wait * 1000, &error); - - if(!devices) { - logger(DEBUG_PROTOCOL, LOG_WARNING, "[upnp] Unable to find IGD devices: [%d] %s", error, strupnperror(error)); - freeUPNPDevlist(devices); - return; - } - - struct UPNPUrls urls; - - struct IGDdatas data; - - char myaddr[64]; - - int result = UPNP_GetValidIGD(devices, &urls, &data, myaddr, sizeof(myaddr)); - - if(result <= 0) { - logger(DEBUG_PROTOCOL, LOG_WARNING, "[upnp] No IGD found"); - freeUPNPDevlist(devices); - return; - } - - logger(DEBUG_PROTOCOL, LOG_INFO, "[upnp] IGD found: [%d] %s (local address: %s, service type: %s)", result, urls.controlURL, myaddr, data.first.servicetype); - - for(int i = 0; i < listen_sockets; i++) { - if(upnp_tcp) { - upnp_add_mapping(&urls, &data, myaddr, listen_socket[i].tcp.fd, "TCP"); - } - - if(upnp_udp) { - upnp_add_mapping(&urls, &data, myaddr, listen_socket[i].udp.fd, "UDP"); - } - } - - FreeUPNPUrls(&urls); - freeUPNPDevlist(devices); -} - -static void *upnp_thread(void *data) { - (void)data; - - while(true) { - time_t start = time(NULL); - upnp_refresh(); - - // Make sure we'll stick to the refresh period no matter how long upnp_refresh() takes. - time_t refresh_time = start + upnp_refresh_period; - time_t now = time(NULL); - - if(now < refresh_time) { - sleep(refresh_time - now); - } - } - - // TODO: we don't have a clean thread shutdown procedure, so we can't remove the mapping. - // this is probably not a concern as long as the UPnP device honors the lease duration, - // but considering how bug-riddled these devices often are, that's a big "if". - return NULL; -} - -void upnp_init(bool tcp, bool udp) { - upnp_tcp = tcp; - upnp_udp = udp; - - get_config_int(lookup_config(config_tree, "UPnPDiscoverWait"), &upnp_discover_wait); - get_config_int(lookup_config(config_tree, "UPnPRefreshPeriod"), &upnp_refresh_period); - - pthread_t thread; - int error = pthread_create(&thread, NULL, upnp_thread, NULL); - - if(error) { - logger(DEBUG_ALWAYS, LOG_ERR, "Unable to start UPnP-IGD client thread: [%d] %s", error, strerror(error)); - } -} diff --git a/src/utils.c b/src/utils.c index 857d47e..70a5c99 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,7 +1,7 @@ /* utils.c -- gathering of some stupid small functions Copyright (C) 1999-2005 Ivo Timmermans - 2000-2013 Guus Sliepen + 2000-2014 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,32 +18,12 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "logger.h" #include "system.h" + +#include "../src/logger.h" #include "utils.h" -#include "xalloc.h" static const char hexadecimals[] = "0123456789ABCDEF"; -static const char base64_original[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -static const char base64_urlsafe[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; -static const char base64_decode[256] = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, 62, -1, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, - -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, 63, - -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - }; static int charhex2bin(char c) { if(isdigit(c)) { @@ -53,124 +33,25 @@ static int charhex2bin(char c) { } } -size_t hex2bin(const char *src, void *vdst, size_t length) { - char *dst = vdst; - size_t i; +bool hex2bin(char *src, char *dst, int length) { + for(int i = 0; i < length; i++) { + if(!isxdigit(src[i * 2]) || !isxdigit(src[i * 2 + 1])) { + return false; + } - for(i = 0; i < length && isxdigit(src[i * 2]) && isxdigit(src[i * 2 + 1]); i++) { dst[i] = charhex2bin(src[i * 2]) * 16 + charhex2bin(src[i * 2 + 1]); } - return i; + return true; } -size_t bin2hex(const void *vsrc, char *dst, size_t length) { - const char *src = vsrc; +void bin2hex(char *src, char *dst, int length) { + int i; - for(size_t i = length; i-- > 0;) { + for(i = length - 1; i >= 0; i--) { dst[i * 2 + 1] = hexadecimals[(unsigned char) src[i] & 15]; dst[i * 2] = hexadecimals[(unsigned char) src[i] >> 4]; } - - dst[length * 2] = 0; - return length * 2; -} - -size_t b64decode(const char *src, void *dst, size_t length) { - size_t i; - uint32_t triplet = 0; - unsigned char *udst = (unsigned char *)dst; - - for(i = 0; i < length && src[i]; i++) { - triplet |= base64_decode[src[i] & 0xff] << (6 * (i & 3)); - - if((i & 3) == 3) { - if(triplet & 0xff000000U) { - return 0; - } - - udst[0] = triplet & 0xff; - triplet >>= 8; - udst[1] = triplet & 0xff; - triplet >>= 8; - udst[2] = triplet; - triplet = 0; - udst += 3; - } - } - - if(triplet & 0xff000000U) { - return 0; - } - - if((i & 3) == 3) { - udst[0] = triplet & 0xff; - triplet >>= 8; - udst[1] = triplet & 0xff; - return i / 4 * 3 + 2; - } else if((i & 3) == 2) { - udst[0] = triplet & 0xff; - return i / 4 * 3 + 1; - } else { - return i / 4 * 3; - } -} - -static size_t b64encode_internal(const void *src, char *dst, size_t length, const char *alphabet) { - uint32_t triplet; - const unsigned char *usrc = (unsigned char *)src; - size_t si = length / 3 * 3; - size_t di = length / 3 * 4; - - switch(length % 3) { - case 2: - triplet = usrc[si] | usrc[si + 1] << 8; - dst[di] = alphabet[triplet & 63]; - triplet >>= 6; - dst[di + 1] = alphabet[triplet & 63]; - triplet >>= 6; - dst[di + 2] = alphabet[triplet]; - dst[di + 3] = 0; - length = di + 3; - break; - - case 1: - triplet = usrc[si]; - dst[di] = alphabet[triplet & 63]; - triplet >>= 6; - dst[di + 1] = alphabet[triplet]; - dst[di + 2] = 0; - length = di + 2; - break; - - default: - dst[di] = 0; - length = di; - break; - } - - while(si > 0) { - di -= 4; - si -= 3; - triplet = usrc[si] | usrc[si + 1] << 8 | usrc[si + 2] << 16; - dst[di] = alphabet[triplet & 63]; - triplet >>= 6; - dst[di + 1] = alphabet[triplet & 63]; - triplet >>= 6; - dst[di + 2] = alphabet[triplet & 63]; - triplet >>= 6; - dst[di + 3] = alphabet[triplet]; - } - - return length; -} - -size_t b64encode(const void *src, char *dst, size_t length) { - return b64encode_internal(src, dst, length, base64_original); -} - -size_t b64encode_urlsafe(const void *src, char *dst, size_t length) { - return b64encode_internal(src, dst, length, base64_urlsafe); } #if defined(HAVE_MINGW) || defined(HAVE_CYGWIN) @@ -181,11 +62,11 @@ size_t b64encode_urlsafe(const void *src, char *dst, size_t length) { const char *winerror(int err) { static char buf[1024], *ptr; - ptr = buf + snprintf(buf, sizeof(buf), "(%d) ", err); + ptr = buf + sprintf(buf, "(%d) ", err); if(!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), ptr, sizeof(buf) - (ptr - buf), NULL)) { - strncpy(buf, "(unable to format errormessage)", sizeof(buf)); + NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), ptr, sizeof(buf) - (ptr - buf), NULL)) { + strcpy(ptr, "(unable to format errormessage)"); }; if((ptr = strchr(buf, '\r'))) { @@ -207,83 +88,18 @@ unsigned int bitfield_to_int(const void *bitfield, size_t size) { return value; } -bool check_id(const char *id) { - if(!id || !*id) { - return false; +/** + * As memcmp(), but constant-time. + * Returns 0 when data is equal, non-zero otherwise. + */ +int memcmp_constant_time(const void *a, const void *b, size_t size) { + const uint8_t *a1 = a, *b1 = b; + int ret = 0; + size_t i; + + for(i = 0; i < size; i++) { + ret |= *a1++ ^ *b1++; } - for(; *id; id++) - if(!isalnum(*id) && *id != '_') { - return false; - } - - return true; -} - -bool check_netname(const char *netname, bool strict) { - if(!netname || !*netname || *netname == '.') { - return false; - } - - for(const char *c = netname; *c; c++) { - if(iscntrl(*c)) { - return false; - } - - if(*c == '/' || *c == '\\') { - return false; - } - - if(strict && strchr(" $%<>:`\"|?*", *c)) { - return false; - } - } - - return true; -} - -/* Windows doesn't define HOST_NAME_MAX. */ -#ifndef HOST_NAME_MAX -#define HOST_NAME_MAX 255 -#endif - -char *replace_name(const char *name) { - char *ret_name; - - if(name[0] == '$') { - char *envname = getenv(name + 1); - char hostname[HOST_NAME_MAX + 1]; - - if(!envname) { - if(strcmp(name + 1, "HOST")) { - logger(DEBUG_ALWAYS, LOG_ERR, "Invalid Name: environment variable %s does not exist\n", name + 1); - return NULL; - } - - if(gethostname(hostname, sizeof(hostname)) || !*hostname) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not get hostname: %s\n", sockstrerror(sockerrno)); - return NULL; - } - - hostname[HOST_NAME_MAX] = 0; - envname = hostname; - } - - ret_name = xstrdup(envname); - - for(char *c = ret_name; *c; c++) - if(!isalnum(*c)) { - *c = '_'; - } - } else { - ret_name = xstrdup(name); - } - - if(!check_id(ret_name)) { - logger(DEBUG_ALWAYS, LOG_ERR, "Invalid name for myself!"); - free(ret_name); - return NULL; - } - - return ret_name; + return ret; } diff --git a/src/utils.h b/src/utils.h index 4285150..7952025 100644 --- a/src/utils.h +++ b/src/utils.h @@ -4,7 +4,7 @@ /* utils.h -- header file for utils.c Copyright (C) 1999-2005 Ivo Timmermans - 2000-2013 Guus Sliepen + 2000-2014 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,37 +21,30 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -extern size_t hex2bin(const char *src, void *dst, size_t length); -extern size_t bin2hex(const void *src, char *dst, size_t length); +extern bool hex2bin(char *src, char *dst, int length); +extern void bin2hex(char *src, char *dst, int length); -extern size_t b64encode(const void *src, char *dst, size_t length); -extern size_t b64encode_urlsafe(const void *src, char *dst, size_t length); -extern size_t b64decode(const char *src, void *dst, size_t length); +#if defined(HAVE_MINGW) || defined(HAVE_CYGWIN) +extern const char *winerror(int); +#endif #ifdef HAVE_MINGW -extern const char *winerror(int); #define strerror(x) ((x)>0?strerror(x):winerror(GetLastError())) #define sockerrno WSAGetLastError() #define sockstrerror(x) winerror(x) #define sockwouldblock(x) ((x) == WSAEWOULDBLOCK || (x) == WSAEINTR) #define sockmsgsize(x) ((x) == WSAEMSGSIZE) #define sockinprogress(x) ((x) == WSAEINPROGRESS || (x) == WSAEWOULDBLOCK) -#define sockinuse(x) ((x) == WSAEADDRINUSE) -#define socknotconn(x) ((x) == WSAENOTCONN) #else #define sockerrno errno #define sockstrerror(x) strerror(x) #define sockwouldblock(x) ((x) == EWOULDBLOCK || (x) == EINTR) #define sockmsgsize(x) ((x) == EMSGSIZE) #define sockinprogress(x) ((x) == EINPROGRESS) -#define sockinuse(x) ((x) == EADDRINUSE) -#define socknotconn(x) ((x) == ENOTCONN) #endif extern unsigned int bitfield_to_int(const void *bitfield, size_t size); -extern bool check_id(const char *id); -extern bool check_netname(const char *netname, bool strict); -char *replace_name(const char *name); +int memcmp_constant_time(const void *a, const void *b, size_t size); #endif diff --git a/src/vde_device.c b/src/vde_device.c index 0170af3..6d854a6 100644 --- a/src/vde_device.c +++ b/src/vde_device.c @@ -1,6 +1,6 @@ /* device.c -- VDE plug - Copyright (C) 2013 Guus Sliepen + Copyright (C) 2012 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,7 +23,6 @@ #include "conf.h" #include "device.h" -#include "names.h" #include "net.h" #include "logger.h" #include "utils.h" @@ -36,11 +35,17 @@ static int port = 0; static char *group = NULL; static const char *device_info = "VDE socket"; +extern char *identname; +extern volatile bool running; + +static uint64_t device_total_in = 0; +static uint64_t device_total_out = 0; + static bool setup_device(void) { libvdeplug_dynopen(plug); if(!plug.dl_handle) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not open libvdeplug library!"); + logger(LOG_ERR, "Could not open libvdeplug library!"); return false; } @@ -63,7 +68,7 @@ static bool setup_device(void) { conn = plug.vde_open(device, identname, &args); if(!conn) { - logger(DEBUG_ALWAYS, LOG_ERR, "Could not open VDE socket %s", device); + logger(LOG_ERR, "Could not open VDE socket %s", device); return false; } @@ -73,7 +78,7 @@ static bool setup_device(void) { fcntl(device_fd, F_SETFD, FD_CLOEXEC); #endif - logger(DEBUG_ALWAYS, LOG_INFO, "%s is a %s", device, device_info); + logger(LOG_INFO, "%s is a %s", device, device_info); if(routing_mode == RMODE_ROUTER) { overwrite_mac = true; @@ -85,7 +90,6 @@ static bool setup_device(void) { static void close_device(void) { if(conn) { plug.vde_close(conn); - conn = NULL; } if(plug.dl_handle) { @@ -93,46 +97,51 @@ static void close_device(void) { } free(device); - device = NULL; free(iface); - iface = NULL; - - device_info = NULL; } static bool read_packet(vpn_packet_t *packet) { - int lenin = (ssize_t)plug.vde_recv(conn, DATA(packet), MTU, 0); + int lenin = (ssize_t)plug.vde_recv(conn, packet->data, MTU, 0); if(lenin <= 0) { - logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); - event_exit(); + logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); + running = false; return false; } packet->len = lenin; - - logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, device_info); + device_total_in += packet->len; + ifdebug(TRAFFIC) logger(LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, device_info); return true; } static bool write_packet(vpn_packet_t *packet) { - if((ssize_t)plug.vde_send(conn, DATA(packet), packet->len, 0) < 0) { + if((ssize_t)plug.vde_send(conn, packet->data, packet->len, 0) < 0) { if(errno != EINTR && errno != EAGAIN) { - logger(DEBUG_ALWAYS, LOG_ERR, "Can't write to %s %s: %s", device_info, device, strerror(errno)); - event_exit(); + logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device, strerror(errno)); + running = false; } return false; } + device_total_out += packet->len; + return true; } +static void dump_device_stats(void) { + logger(LOG_DEBUG, "Statistics for %s %s:", device_info, device); + logger(LOG_DEBUG, " total bytes in: %10"PRIu64, device_total_in); + logger(LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out); +} + const devops_t vde_devops = { .setup = setup_device, .close = close_device, .read = read_packet, .write = write_packet, + .dump_stats = dump_device_stats, }; diff --git a/src/version.c b/src/version.c deleted file mode 100644 index d0af1cc..0000000 --- a/src/version.c +++ /dev/null @@ -1,31 +0,0 @@ -/* - version.c -- version information - Copyright (C) 2014 Etienne Dechamps - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "version.h" -#include "version_git.h" -#include "../config.h" - -/* This file is always rebuilt (even if there are no changes) so that the following is updated */ -const char *const BUILD_DATE = __DATE__; -const char *const BUILD_TIME = __TIME__; -#ifdef GIT_DESCRIPTION -const char *const BUILD_VERSION = GIT_DESCRIPTION; -#else -const char *const BUILD_VERSION = VERSION; -#endif diff --git a/src/version.h b/src/version.h deleted file mode 100644 index a4cf0a7..0000000 --- a/src/version.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef TINC_VERSION_H -#define TINC_VERSION_H - -/* - version.h -- header for version.c - Copyright (C) 2014 Etienne Dechamps - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -extern const char *const BUILD_DATE; -extern const char *const BUILD_TIME; -extern const char *const BUILD_VERSION; - -#endif diff --git a/src/xalloc.h b/src/xalloc.h index d9877a8..cda0871 100644 --- a/src/xalloc.h +++ b/src/xalloc.h @@ -4,7 +4,7 @@ /* xalloc.h -- malloc and related functions with out of memory checking Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. - Copyright (C) 2011-2013 Guus Sliepen + Copyright (C) 2011-2017 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -32,8 +32,8 @@ static inline void *xmalloc(size_t n) { return p; } -static inline void *xzalloc(size_t n) __attribute__((__malloc__)); -static inline void *xzalloc(size_t n) { +static inline void *xmalloc_and_zero(size_t n) __attribute__((__malloc__)); +static inline void *xmalloc_and_zero(size_t n) { void *p = calloc(1, n); if(!p) { @@ -53,7 +53,7 @@ static inline void *xrealloc(void *p, size_t n) { return p; } -static inline char *xstrdup(const char *s) __attribute__((__malloc__, __nonnull__)); +static inline char *xstrdup(const char *s) __attribute__((__malloc__)); static inline char *xstrdup(const char *s) { char *p = strdup(s); diff --git a/systemd/Makefile.in b/systemd/Makefile.in index ef4ed4e..376a668 100644 --- a/systemd/Makefile.in +++ b/systemd/Makefile.in @@ -95,12 +95,9 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/attribute.m4 \ $(top_srcdir)/m4/ax_cflags_warn_all.m4 \ $(top_srcdir)/m4/ax_check_compile_flag.m4 \ $(top_srcdir)/m4/ax_check_link_flag.m4 \ - $(top_srcdir)/m4/ax_code_coverage.m4 \ - $(top_srcdir)/m4/ax_require_defined.m4 \ - $(top_srcdir)/m4/curses.m4 $(top_srcdir)/m4/libgcrypt.m4 \ - $(top_srcdir)/m4/lzo.m4 $(top_srcdir)/m4/miniupnpc.m4 \ - $(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/readline.m4 \ - $(top_srcdir)/m4/zlib.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/ax_require_defined.m4 $(top_srcdir)/m4/lzo.m4 \ + $(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/zlib.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) @@ -169,15 +166,8 @@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_CPPFLAGS = @CODE_COVERAGE_CPPFLAGS@ -CODE_COVERAGE_CXXFLAGS = @CODE_COVERAGE_CXXFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CODE_COVERAGE_LIBS = @CODE_COVERAGE_LIBS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ -CURSES_LIBS = @CURSES_LIBS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ @@ -186,21 +176,17 @@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ -GCOV = @GCOV@ -GENHTML = @GENHTML@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LCOV = @LCOV@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ -MINIUPNPC_LIBS = @MINIUPNPC_LIBS@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ @@ -211,8 +197,6 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ -READLINE_LIBS = @READLINE_LIBS@ -SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ diff --git a/systemd/tinc@.service.in b/systemd/tinc@.service.in index 2d695ca..8fbf551 100644 --- a/systemd/tinc@.service.in +++ b/systemd/tinc@.service.in @@ -10,7 +10,7 @@ ReloadPropagatedFrom=tinc.service Type=simple WorkingDirectory=@sysconfdir@/tinc/%i ExecStart=@sbindir@/tincd -n %i -D -ExecReload=@sbindir@/tinc -n %i reload +ExecReload=@sbindir@/tincd -n %i -kHUP KillMode=mixed Restart=on-failure RestartSec=5 diff --git a/test-driver b/test-driver deleted file mode 100755 index b8521a4..0000000 --- a/test-driver +++ /dev/null @@ -1,148 +0,0 @@ -#! /bin/sh -# test-driver - basic testsuite driver script. - -scriptversion=2018-03-07.03; # UTC - -# Copyright (C) 2011-2018 Free Software Foundation, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# This file is maintained in Automake, please report -# bugs to or send patches to -# . - -# Make unconditional expansion of undefined variables an error. This -# helps a lot in preventing typo-related bugs. -set -u - -usage_error () -{ - echo "$0: $*" >&2 - print_usage >&2 - exit 2 -} - -print_usage () -{ - cat <$log_file 2>&1 -estatus=$? - -if test $enable_hard_errors = no && test $estatus -eq 99; then - tweaked_estatus=1 -else - tweaked_estatus=$estatus -fi - -case $tweaked_estatus:$expect_failure in - 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; - 0:*) col=$grn res=PASS recheck=no gcopy=no;; - 77:*) col=$blu res=SKIP recheck=no gcopy=yes;; - 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;; - *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;; - *:*) col=$red res=FAIL recheck=yes gcopy=yes;; -esac - -# Report the test outcome and exit status in the logs, so that one can -# know whether the test passed or failed simply by looking at the '.log' -# file, without the need of also peaking into the corresponding '.trs' -# file (automake bug#11814). -echo "$res $test_name (exit status: $estatus)" >>$log_file - -# Report outcome to console. -echo "${col}${res}${std}: $test_name" - -# Register the test result, and other relevant metadata. -echo ":test-result: $res" > $trs_file -echo ":global-test-result: $res" >> $trs_file -echo ":recheck: $recheck" >> $trs_file -echo ":copy-in-global-log: $gcopy" >> $trs_file - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'before-save-hook 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC0" -# time-stamp-end: "; # UTC" -# End: diff --git a/test/Makefile.am b/test/Makefile.am deleted file mode 100644 index 32b2e30..0000000 --- a/test/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -TESTS = \ - basic.test \ - commandline.test \ - executables.test \ - import-export.test \ - invite-join.test \ - invite-offline.test \ - invite-tinc-up.test \ - legacy-protocol.test \ - ns-ping.test \ - scripts.test \ - security.test \ - sptps-basic.test \ - variables.test - -dist_check_SCRIPTS = $(TESTS) - -EXTRA_DIST = testlib.sh - -AM_CFLAGS = -iquote. - -check_PROGRAMS = \ - splice - -splice_SOURCES = splice.c - -clean-local: - -for pid in *.test.?/pid; do ../src/tinc --pidfile="$$pid" stop; done - -killall ../src/sptps_test - -rm -rf *.test.? diff --git a/test/Makefile.in b/test/Makefile.in deleted file mode 100644 index a5f0487..0000000 --- a/test/Makefile.in +++ /dev/null @@ -1,951 +0,0 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2018 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -check_PROGRAMS = splice$(EXEEXT) -subdir = test -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/attribute.m4 \ - $(top_srcdir)/m4/ax_append_flag.m4 \ - $(top_srcdir)/m4/ax_cflags_warn_all.m4 \ - $(top_srcdir)/m4/ax_check_compile_flag.m4 \ - $(top_srcdir)/m4/ax_check_link_flag.m4 \ - $(top_srcdir)/m4/ax_code_coverage.m4 \ - $(top_srcdir)/m4/ax_require_defined.m4 \ - $(top_srcdir)/m4/curses.m4 $(top_srcdir)/m4/libgcrypt.m4 \ - $(top_srcdir)/m4/lzo.m4 $(top_srcdir)/m4/miniupnpc.m4 \ - $(top_srcdir)/m4/openssl.m4 $(top_srcdir)/m4/readline.m4 \ - $(top_srcdir)/m4/zlib.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(dist_check_SCRIPTS) \ - $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am_splice_OBJECTS = splice.$(OBJEXT) -splice_OBJECTS = $(am_splice_OBJECTS) -splice_LDADD = $(LDADD) -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__maybe_remake_depfiles = depfiles -am__depfiles_remade = ./$(DEPDIR)/splice.Po -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(splice_SOURCES) -DIST_SOURCES = $(splice_SOURCES) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__tty_colors_dummy = \ - mgn= red= grn= lgn= blu= brg= std=; \ - am__color_tests=no -am__tty_colors = { \ - $(am__tty_colors_dummy); \ - if test "X$(AM_COLOR_TESTS)" = Xno; then \ - am__color_tests=no; \ - elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ - am__color_tests=yes; \ - elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ - am__color_tests=yes; \ - fi; \ - if test $$am__color_tests = yes; then \ - red=''; \ - grn=''; \ - lgn=''; \ - blu=''; \ - mgn=''; \ - brg=''; \ - std=''; \ - fi; \ -} -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__recheck_rx = ^[ ]*:recheck:[ ]* -am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* -am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* -# A command that, given a newline-separated list of test names on the -# standard input, print the name of the tests that are to be re-run -# upon "make recheck". -am__list_recheck_tests = $(AWK) '{ \ - recheck = 1; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - { \ - if ((getline line2 < ($$0 ".log")) < 0) \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ - { \ - recheck = 0; \ - break; \ - } \ - else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ - { \ - break; \ - } \ - }; \ - if (recheck) \ - print $$0; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# A command that, given a newline-separated list of test names on the -# standard input, create the global log from their .trs and .log files. -am__create_global_log = $(AWK) ' \ -function fatal(msg) \ -{ \ - print "fatal: making $@: " msg | "cat >&2"; \ - exit 1; \ -} \ -function rst_section(header) \ -{ \ - print header; \ - len = length(header); \ - for (i = 1; i <= len; i = i + 1) \ - printf "="; \ - printf "\n\n"; \ -} \ -{ \ - copy_in_global_log = 1; \ - global_test_result = "RUN"; \ - while ((rc = (getline line < ($$0 ".trs"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".trs"); \ - if (line ~ /$(am__global_test_result_rx)/) \ - { \ - sub("$(am__global_test_result_rx)", "", line); \ - sub("[ ]*$$", "", line); \ - global_test_result = line; \ - } \ - else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ - copy_in_global_log = 0; \ - }; \ - if (copy_in_global_log) \ - { \ - rst_section(global_test_result ": " $$0); \ - while ((rc = (getline line < ($$0 ".log"))) != 0) \ - { \ - if (rc < 0) \ - fatal("failed to read from " $$0 ".log"); \ - print line; \ - }; \ - printf "\n"; \ - }; \ - close ($$0 ".trs"); \ - close ($$0 ".log"); \ -}' -# Restructured Text title. -am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } -# Solaris 10 'make', and several other traditional 'make' implementations, -# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it -# by disabling -e (using the XSI extension "set +e") if it's set. -am__sh_e_setup = case $$- in *e*) set +e;; esac -# Default flags passed to test drivers. -am__common_driver_flags = \ - --color-tests "$$am__color_tests" \ - --enable-hard-errors "$$am__enable_hard_errors" \ - --expect-failure "$$am__expect_failure" -# To be inserted before the command running the test. Creates the -# directory for the log if needed. Stores in $dir the directory -# containing $f, in $tst the test, in $log the log. Executes the -# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and -# passes TESTS_ENVIRONMENT. Set up options for the wrapper that -# will run the test scripts (or their associated LOG_COMPILER, if -# thy have one). -am__check_pre = \ -$(am__sh_e_setup); \ -$(am__vpath_adj_setup) $(am__vpath_adj) \ -$(am__tty_colors); \ -srcdir=$(srcdir); export srcdir; \ -case "$@" in \ - */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ - *) am__odir=.;; \ -esac; \ -test "x$$am__odir" = x"." || test -d "$$am__odir" \ - || $(MKDIR_P) "$$am__odir" || exit $$?; \ -if test -f "./$$f"; then dir=./; \ -elif test -f "$$f"; then dir=; \ -else dir="$(srcdir)/"; fi; \ -tst=$$dir$$f; log='$@'; \ -if test -n '$(DISABLE_HARD_ERRORS)'; then \ - am__enable_hard_errors=no; \ -else \ - am__enable_hard_errors=yes; \ -fi; \ -case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ - am__expect_failure=yes;; \ - *) \ - am__expect_failure=no;; \ -esac; \ -$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) -# A shell command to get the names of the tests scripts with any registered -# extension removed (i.e., equivalently, the names of the test logs, with -# the '.log' extension removed). The result is saved in the shell variable -# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, -# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", -# since that might cause problem with VPATH rewrites for suffix-less tests. -# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. -am__set_TESTS_bases = \ - bases='$(TEST_LOGS)'; \ - bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ - bases=`echo $$bases` -RECHECK_LOGS = $(TEST_LOGS) -AM_RECURSIVE_TARGETS = check recheck -TEST_SUITE_LOG = test-suite.log -TEST_EXTENSIONS = @EXEEXT@ .test -am__test_logs1 = $(TESTS:=.log) -am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) -TEST_LOGS = $(am__test_logs2:.test.log=.log) -TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver -TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ - $(TEST_LOG_FLAGS) -am__set_b = \ - case '$@' in \ - */*) \ - case '$*' in \ - */*) b='$*';; \ - *) b=`echo '$@' | sed 's/\.log$$//'`; \ - esac;; \ - *) \ - b='$*';; \ - esac -am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ - $(top_srcdir)/test-driver -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CODE_COVERAGE_CFLAGS = @CODE_COVERAGE_CFLAGS@ -CODE_COVERAGE_CPPFLAGS = @CODE_COVERAGE_CPPFLAGS@ -CODE_COVERAGE_CXXFLAGS = @CODE_COVERAGE_CXXFLAGS@ -CODE_COVERAGE_ENABLED = @CODE_COVERAGE_ENABLED@ -CODE_COVERAGE_LDFLAGS = @CODE_COVERAGE_LDFLAGS@ -CODE_COVERAGE_LIBS = @CODE_COVERAGE_LIBS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CURSES_LIBS = @CURSES_LIBS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -GCOV = @GCOV@ -GENHTML = @GENHTML@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LCOV = @LCOV@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MINIUPNPC_LIBS = @MINIUPNPC_LIBS@ -MKDIR_P = @MKDIR_P@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -READLINE_LIBS = @READLINE_LIBS@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -runstatedir = @runstatedir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -systemd_path = @systemd_path@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -TESTS = \ - basic.test \ - commandline.test \ - executables.test \ - import-export.test \ - invite-join.test \ - invite-offline.test \ - invite-tinc-up.test \ - legacy-protocol.test \ - ns-ping.test \ - scripts.test \ - security.test \ - sptps-basic.test \ - variables.test - -dist_check_SCRIPTS = $(TESTS) -EXTRA_DIST = testlib.sh -AM_CFLAGS = -iquote. -splice_SOURCES = splice.c -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .log .o .obj .test .test$(EXEEXT) .trs -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu test/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-checkPROGRAMS: - -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) - -splice$(EXEEXT): $(splice_OBJECTS) $(splice_DEPENDENCIES) $(EXTRA_splice_DEPENDENCIES) - @rm -f splice$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(splice_OBJECTS) $(splice_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/splice.Po@am__quote@ # am--include-marker - -$(am__depfiles_remade): - @$(MKDIR_P) $(@D) - @echo '# dummy' >$@-t && $(am__mv) $@-t $@ - -am--depfiles: $(am__depfiles_remade) - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ -@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -# Recover from deleted '.trs' file; this should ensure that -# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create -# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells -# to avoid problems with "make -n". -.log.trs: - rm -f $< $@ - $(MAKE) $(AM_MAKEFLAGS) $< - -# Leading 'am--fnord' is there to ensure the list of targets does not -# expand to empty, as could happen e.g. with make check TESTS=''. -am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) -am--force-recheck: - @: - -$(TEST_SUITE_LOG): $(TEST_LOGS) - @$(am__set_TESTS_bases); \ - am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ - redo_bases=`for i in $$bases; do \ - am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ - done`; \ - if test -n "$$redo_bases"; then \ - redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ - redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ - if $(am__make_dryrun); then :; else \ - rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ - fi; \ - fi; \ - if test -n "$$am__remaking_logs"; then \ - echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ - "recursion detected" >&2; \ - elif test -n "$$redo_logs"; then \ - am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ - fi; \ - if $(am__make_dryrun); then :; else \ - st=0; \ - errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ - for i in $$redo_bases; do \ - test -f $$i.trs && test -r $$i.trs \ - || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ - test -f $$i.log && test -r $$i.log \ - || { echo "$$errmsg $$i.log" >&2; st=1; }; \ - done; \ - test $$st -eq 0 || exit 1; \ - fi - @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ - ws='[ ]'; \ - results=`for b in $$bases; do echo $$b.trs; done`; \ - test -n "$$results" || results=/dev/null; \ - all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ - pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ - fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ - skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ - xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ - xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ - error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ - if test `expr $$fail + $$xpass + $$error` -eq 0; then \ - success=true; \ - else \ - success=false; \ - fi; \ - br='==================='; br=$$br$$br$$br$$br; \ - result_count () \ - { \ - if test x"$$1" = x"--maybe-color"; then \ - maybe_colorize=yes; \ - elif test x"$$1" = x"--no-color"; then \ - maybe_colorize=no; \ - else \ - echo "$@: invalid 'result_count' usage" >&2; exit 4; \ - fi; \ - shift; \ - desc=$$1 count=$$2; \ - if test $$maybe_colorize = yes && test $$count -gt 0; then \ - color_start=$$3 color_end=$$std; \ - else \ - color_start= color_end=; \ - fi; \ - echo "$${color_start}# $$desc $$count$${color_end}"; \ - }; \ - create_testsuite_report () \ - { \ - result_count $$1 "TOTAL:" $$all "$$brg"; \ - result_count $$1 "PASS: " $$pass "$$grn"; \ - result_count $$1 "SKIP: " $$skip "$$blu"; \ - result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ - result_count $$1 "FAIL: " $$fail "$$red"; \ - result_count $$1 "XPASS:" $$xpass "$$red"; \ - result_count $$1 "ERROR:" $$error "$$mgn"; \ - }; \ - { \ - echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ - $(am__rst_title); \ - create_testsuite_report --no-color; \ - echo; \ - echo ".. contents:: :depth: 2"; \ - echo; \ - for b in $$bases; do echo $$b; done \ - | $(am__create_global_log); \ - } >$(TEST_SUITE_LOG).tmp || exit 1; \ - mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ - if $$success; then \ - col="$$grn"; \ - else \ - col="$$red"; \ - test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ - fi; \ - echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ - echo "$${col}$$br$${std}"; \ - create_testsuite_report --maybe-color; \ - echo "$$col$$br$$std"; \ - if $$success; then :; else \ - echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ - if test -n "$(PACKAGE_BUGREPORT)"; then \ - echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ - fi; \ - echo "$$col$$br$$std"; \ - fi; \ - $$success || exit 1 - -check-TESTS: $(check_PROGRAMS) $(dist_check_SCRIPTS) - @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list - @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - trs_list=`for i in $$bases; do echo $$i.trs; done`; \ - log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ - exit $$?; -recheck: all $(check_PROGRAMS) $(dist_check_SCRIPTS) - @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - @set +e; $(am__set_TESTS_bases); \ - bases=`for i in $$bases; do echo $$i; done \ - | $(am__list_recheck_tests)` || exit 1; \ - log_list=`for i in $$bases; do echo $$i.log; done`; \ - log_list=`echo $$log_list`; \ - $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ - am__force_recheck=am--force-recheck \ - TEST_LOGS="$$log_list"; \ - exit $$? -.test.log: - @p='$<'; \ - $(am__set_b); \ - $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ - --log-file $$b.log --trs-file $$b.trs \ - $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ - "$$tst" $(AM_TESTS_FD_REDIRECT) -@am__EXEEXT_TRUE@.test$(EXEEXT).log: -@am__EXEEXT_TRUE@ @p='$<'; \ -@am__EXEEXT_TRUE@ $(am__set_b); \ -@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ -@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ -@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ -@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) - -distdir: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) distdir-am - -distdir-am: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) \ - $(dist_check_SCRIPTS) - $(MAKE) $(AM_MAKEFLAGS) check-TESTS -check: check-am -all-am: Makefile -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) - -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) - -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-checkPROGRAMS clean-generic clean-local mostlyclean-am - -distclean: distclean-am - -rm -f ./$(DEPDIR)/splice.Po - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f ./$(DEPDIR)/splice.Po - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: check-am install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-TESTS \ - check-am clean clean-checkPROGRAMS clean-generic clean-local \ - cscopelist-am ctags ctags-am distclean distclean-compile \ - distclean-generic distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic pdf pdf-am ps ps-am recheck tags tags-am \ - uninstall uninstall-am - -.PRECIOUS: Makefile - - -clean-local: - -for pid in *.test.?/pid; do ../src/tinc --pidfile="$$pid" stop; done - -killall ../src/sptps_test - -rm -rf *.test.? - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/test/basic.test b/test/basic.test deleted file mode 100755 index c377202..0000000 --- a/test/basic.test +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -. "${0%/*}/testlib.sh" - -# Initialize and test one node - -$tinc $c1 init foo -$tinc $c1 set DeviceType dummy -$tinc $c1 set Port 0 - -# Test running in the foreground - -(sleep 1; $tinc $c1 stop) & -$tinc $c1 start $r1 -D - -# Test running tinc in the background - -$tinc $c1 start $r1 -sleep 1 -$tinc $c1 stop diff --git a/test/commandline.test b/test/commandline.test deleted file mode 100755 index 44d651a..0000000 --- a/test/commandline.test +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh - -. "${0%/*}/testlib.sh" - -# Initialize one node - -$tinc $c1 <$d1/tinc-up <$d1/invitation-created <\$INVITATION_FILE -echo Ifconfig = 93.184.216.34/24 >>\$INVITATION_FILE -echo Route = 2606:2800:220:1::/64 2606:2800:220:1:248:1893:25c8:1946 >>\$INVITATION_FILE -echo Route = 1.2.3.4 1234:: >>\$INVITATION_FILE -$tinc $c1 export >>\$INVITATION_FILE -EOF - -chmod u+x $d1/invitation-created - -$tinc $c1 invite bar | $tinc $c2 --batch join - -# Test equivalence of host config files - -cmp $d1/hosts/foo $d2/hosts/foo -test "`grep ^Ed25519PublicKey $d1/hosts/bar`" = "`grep ^Ed25519PublicKey $d2/hosts/bar`" - -# Check if the tinc-up.invitation file is created and contains the right commands - -test -f $d2/tinc-up.invitation - -fgrep -q "93.184.216.34/24" $d2/tinc-up.invitation -fgrep -q "2606:2800:220:1::/64" $d2/tinc-up.invitation -fgrep -q "2606:2800:220:1:248:1893:25c8:1946" $d2/tinc-up.invitation -fgrep -q "1234::" $d2/tinc-up.invitation && exit 1 - -# Check that no tinc-up is created and that tinc-up.invitation is not executable - -test -x $d2/tinc-up.invitation && exit 1 -test -f $d2/tinc-up && exit 1 - -$tinc $c1 stop diff --git a/test/legacy-protocol.test b/test/legacy-protocol.test deleted file mode 100755 index ce8e614..0000000 --- a/test/legacy-protocol.test +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/sh - -. "${0%/*}/testlib.sh" - -# Initialize two nodes - -$tinc $c1 <$d1/tinc-up <$d2/tinc-up <$d1/$script << EOF -#!/bin/sh -echo $script \$NETNAME,\$NAME,\$DEVICE,\$IFACE,\$NODE,\$REMOTEADDRESS,\$REMOTEPORT,\$SUBNET,\$WEIGHT,\$INVITATION_FILE,\$INVITATION_URL,\$DEBUG >>$OUT -EOF -chmod u+x $d1/$script -done - -# Start server node - -$tinc -n netname $c1 start $r1 - -echo foo-started >>$OUT - -# Invite client node - -url=`$tinc -n netname2 $c1 invite bar` -file=`cd $d1/invitations; ls | grep -v ed25519_key.priv` -echo bar-invited >>$OUT -$tinc -n netname3 $c2 join $url -echo bar-joined >>$OUT - -# Start and stop client node - -$tinc $c2 << EOF -set DeviceType dummy -set Port 32760 -add Subnet 10.0.0.2 -add Subnet fec0::/64#5 -start $r2 -EOF - -sleep 1 - -echo bar-started >>$OUT - -$tinc $c1 debug 4 -$tinc $c2 stop - -sleep 1 - -echo bar-stopped >>$OUT - -$tinc $c1 debug 5 -$tinc $c2 start $r2 - -sleep 1 - -echo bar-started >>$OUT - -# Stop server node - -$tinc $c1 stop -sleep 1 -$tinc $c2 stop - -# Check if the script output is what is expected - -cat >$OUT.expected << EOF -tinc-up netname,foo,dummy,,,,,,,,,5 -subnet-up netname,foo,dummy,,foo,,,10.0.0.1,,,,5 -subnet-up netname,foo,dummy,,foo,,,fec0::/64,,,,5 -foo-started -invitation-created netname2,foo,,,bar,,,,,$d1/invitations/$file,$url, -bar-invited -invitation-accepted netname,foo,dummy,,bar,127.0.0.1,,,,,,5 -bar-joined -host-up netname,foo,dummy,,bar,127.0.0.1,32760,,,,,5 -hosts/bar-up netname,foo,dummy,,bar,127.0.0.1,32760,,,,,5 -subnet-up netname,foo,dummy,,bar,127.0.0.1,32760,10.0.0.2,,,,5 -subnet-up netname,foo,dummy,,bar,127.0.0.1,32760,fec0::/64,5,,,5 -bar-started -host-down netname,foo,dummy,,bar,127.0.0.1,32760,,,,,4 -hosts/bar-down netname,foo,dummy,,bar,127.0.0.1,32760,,,,,4 -subnet-down netname,foo,dummy,,bar,127.0.0.1,32760,10.0.0.2,,,,4 -subnet-down netname,foo,dummy,,bar,127.0.0.1,32760,fec0::/64,5,,,4 -bar-stopped -host-up netname,foo,dummy,,bar,127.0.0.1,32760,,,,,5 -hosts/bar-up netname,foo,dummy,,bar,127.0.0.1,32760,,,,,5 -subnet-up netname,foo,dummy,,bar,127.0.0.1,32760,10.0.0.2,,,,5 -subnet-up netname,foo,dummy,,bar,127.0.0.1,32760,fec0::/64,5,,,5 -bar-started -host-down netname,foo,dummy,,bar,127.0.0.1,32760,,,,,5 -hosts/bar-down netname,foo,dummy,,bar,127.0.0.1,32760,,,,,5 -subnet-down netname,foo,dummy,,bar,127.0.0.1,32760,10.0.0.2,,,,5 -subnet-down netname,foo,dummy,,bar,127.0.0.1,32760,fec0::/64,5,,,5 -subnet-down netname,foo,dummy,,foo,,,10.0.0.1,,,,5 -subnet-down netname,foo,dummy,,foo,,,fec0::/64,,,,5 -tinc-down netname,foo,dummy,,,,,,,,,5 -EOF - -cmp $OUT $OUT.expected diff --git a/test/security.test b/test/security.test deleted file mode 100755 index 91d29e2..0000000 --- a/test/security.test +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/sh - -. "${0%/*}/testlib.sh" - -# Skip this test if tools are missing - -which socket >/dev/null || exit 77 -which timeout >/dev/null || exit 77 - -# Initialize two nodes - -$tinc $c1 < - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_MINGW -extern const char *winerror(int); -#define strerror(x) ((x)>0?strerror(x):winerror(GetLastError())) -#define sockerrno WSAGetLastError() -#define sockstrerror(x) winerror(x) -#else -#define sockerrno errno -#define sockstrerror(x) strerror(x) -#endif - -int main(int argc, char *argv[]) { - if(argc < 7) { - fprintf(stderr, "Usage: %s name1 host1 port1 name2 host2 port2 [protocol]\n", argv[0]); - return 1; - } - - const char *protocol; - - if(argc >= 8) { - protocol = argv[7]; - } else { - protocol = "17.7"; - } - -#ifdef HAVE_MINGW - static struct WSAData wsa_state; - - if(WSAStartup(MAKEWORD(2, 2), &wsa_state)) { - return 1; - } - -#endif - int sock[2]; - char buf[1024]; - - struct addrinfo *ai, hint; - memset(&hint, 0, sizeof(hint)); - - hint.ai_family = AF_UNSPEC; - hint.ai_socktype = SOCK_STREAM; - hint.ai_protocol = IPPROTO_TCP; - hint.ai_flags = 0; - - for (int i = 0; i < 2; i++) { - if(getaddrinfo(argv[2 + 3 * i], argv[3 + 3 * i], &hint, &ai) || !ai) { - fprintf(stderr, "getaddrinfo() failed: %s\n", sockstrerror(sockerrno)); - return 1; - } - - sock[i] = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); - - if(sock[i] == -1) { - fprintf(stderr, "Could not create socket: %s\n", sockstrerror(sockerrno)); - return 1; - } - - if(connect(sock[i], ai->ai_addr, ai->ai_addrlen)) { - fprintf(stderr, "Could not connect to %s: %s\n", argv[i + 3 * i], sockstrerror(sockerrno)); - return 1; - } - - fprintf(stderr, "Connected to %s\n", argv[1 + 3 * i]); - - /* Pretend to be the other one */ - int len = snprintf(buf, sizeof buf, "0 %s %s\n", argv[4 - 3 * i], protocol); - if (send(sock[i], buf, len, 0) != len) { - fprintf(stderr, "Error sending data to %s: %s\n", argv[1 + 3 * i], sockstrerror(sockerrno)); - return 1; - } - - /* Ignore the response */ - do { - if (recv(sock[i], buf, 1, 0) != 1) { - fprintf(stderr, "Error reading data from %s: %s\n", argv[1 + 3 * i], sockstrerror(sockerrno)); - return 1; - } - } while(*buf != '\n'); - } - - fprintf(stderr, "Splicing...\n"); - - int nfds = (sock[0] > sock[1] ? sock[0] : sock[1]) + 1; - - while(true) { - fd_set fds; - FD_ZERO(&fds); - FD_SET(sock[0], &fds); - FD_SET(sock[1], &fds); - - if(select(nfds, &fds, NULL, NULL, NULL) <= 0) { - return 1; - } - - for(int i = 0; i < 2; i++ ) { - if(FD_ISSET(sock[i], &fds)) { - ssize_t len = recv(sock[i], buf, sizeof buf, 0); - - if(len < 0) { - fprintf(stderr, "Error while reading from %s: %s\n", argv[1 + i * 3], sockstrerror(sockerrno)); - return 1; - } - - if(len == 0) { - fprintf(stderr, "Connection closed by %s\n", argv[1 + i * 3]); - return 0; - } - - if(send(sock[i ^ 1], buf, len, 0) != len) { - fprintf(stderr, "Error while writing to %s: %s\n", argv[4 - i * 3], sockstrerror(sockerrno)); - return 1; - } - } - } - } - - return 0; -} diff --git a/test/sptps-basic.test b/test/sptps-basic.test deleted file mode 100755 index b6d081f..0000000 --- a/test/sptps-basic.test +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -. "${0%/*}/testlib.sh" - -# Skip this test if we did not compile sptps_test - -test -e $sptps_test -a -e $sptps_keypair || exit 77 - -# Generate keys - -mkdir -p $d1 - -$sptps_keypair $d1/server.priv $d1/server.pub -$sptps_keypair $d1/client.priv $d1/client.pub - -# Test transfer of a simple file. - -(sleep 1; $sptps_test -4 -q $d1/client.priv $d1/server.pub localhost 32750 $d1/out1 -cmp $d1/out1 Makefile - -$sptps_test -4 -q $d1/server.priv $d1/client.pub 32750 $d1/out2 -cmp $d1/out2 Makefile - -# Datagram mode - -$sptps_test -4 -dq $d1/server.priv $d1/client.pub 32750 $d1/out3 -cmp $d1/out3 Makefile diff --git a/test/testlib.sh b/test/testlib.sh deleted file mode 100644 index 75b60a7..0000000 --- a/test/testlib.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh - -# Paths to executables - -tincd=../src/tincd -tinc=../src/tinc -sptps_test=../src/sptps_test -sptps_keypair=../src/sptps_keypair - -# Test directories - -scriptname=`basename $0` -d1=$PWD/$scriptname.1 -d2=$PWD/$scriptname.2 -d3=$PWD/$scriptname.3 - -# Default arguments for both tinc and tincd - -c1="--config=$d1 --pidfile=$d1/pid" -c2="--config=$d2 --pidfile=$d2/pid" -c3="--config=$d3 --pidfile=$d3/pid" - -# Arguments when running tincd - -r1="--logfile=$d1/log -d5" -r2="--logfile=$d2/log -d5" -r3="--logfile=$d3/log -d5" - -# Check for leftover tinc daemons - -[ -f $d1/pid ] && $tinc $c1 stop -[ -f $d2/pid ] && $tinc $c2 stop -[ -f $d3/pid ] && $tinc $c3 stop - -# Remove test directories - -rm -rf $d1 $d2 $d3 - -# Exit on errors, log all commands being executed - -set -ex diff --git a/test/variables.test b/test/variables.test deleted file mode 100755 index f8656c9..0000000 --- a/test/variables.test +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/sh - -. "${0%/*}/testlib.sh" - -# Initialize one node - -$tinc $c1 init foo -test "`$tinc $c1 get Name`" = "foo" - -# Test case sensitivity - -$tinc $c1 set Mode switch -test "`$tinc $c1 get Mode`" = "switch" -test "`$tinc $c1 get mode`" = "switch" -$tinc $c1 set mode router -test "`$tinc $c1 get Mode`" = "router" -test "`$tinc $c1 get mode`" = "router" -$tinc $c1 set Mode Switch -test "`$tinc $c1 get Mode`" = "Switch" - -# Test deletion - -$tinc $c1 del Mode hub && exit 1 || true -$tinc $c1 del Mode switch -test -z "`$tinc $c1 get Mode`" - -# There can only be one Mode variable - -$tinc $c1 add Mode switch -$tinc $c1 add Mode hub -test "`$tinc $c1 get Mode`" = "hub" - -# Test addition/deletion of multivalued variables - -$tinc $c1 add Subnet 1 -$tinc $c1 add Subnet 2 -$tinc $c1 add Subnet 2 -$tinc $c1 add Subnet 3 -test "`$tinc $c1 get Subnet`" = "1 -2 -3" -$tinc $c1 del Subnet 2 -test "`$tinc $c1 get Subnet`" = "1 -3" -$tinc $c1 del Subnet -test -z "`$tinc $c1 get Subnet`" - -# We should not be able to get/set server variables using node.variable syntax - -test -z "`$tinc $c1 get foo.Name`" -$tinc $c1 set foo.Name bar && exit 1 || true - -# Test getting/setting host variables for other nodes - -touch $d1/hosts/bar - -$tinc $c1 add bar.PMTU 1 -$tinc $c1 add bar.PMTU 2 -test "`$tinc $c1 get bar.PMTU`" = "2" - -$tinc $c1 add bar.Subnet 1 -$tinc $c1 add bar.Subnet 2 -$tinc $c1 add bar.Subnet 2 -$tinc $c1 add bar.Subnet 3 -test "`$tinc $c1 get bar.Subnet`" = "1 -2 -3" -$tinc $c1 del bar.Subnet 2 -test "`$tinc $c1 get bar.Subnet`" = "1 -3" -$tinc $c1 del bar.Subnet -test -z "`$tinc $c1 get bar.Subnet`" - -# We should not be able to get/set for nodes with invalid names - -touch $d1/hosts/qu-ux - -$tinc $c1 set qu-ux.Subnet 1 && exit 1 || true - -# We should not be able to set obsolete variables unless forced - -$tinc $c1 set PrivateKey 12345 && exit 1 || true -$tinc $c1 --force set PrivateKey 12345 -test "`$tinc $c1 get PrivateKey`" = "12345" -$tinc $c1 del PrivateKey -test -z "`$tinc $c1 get PrivateKey`"