- Julien Muchembled <jm@jmuchemb.eu>
- Timothy Redaelli <timothy@redaelli.eu>
- Brandon Black <blblack@gmail.com>
+- Loïc Grenié <loic.grenie@gmail.com>
These files are from other sources:
* lib/pidfile.h and lib/pidfile.c are by Martin Schulze, taken from
* Use splay trees instead of AVL trees.
+ * Fix ProcessPriority option under Windows.
+
Version 1.0.14 May 8 2011
* Fixed reading configuration files that do not end with a newline. Again.
* Jeroen Ubbink
* Jerome Etienne
* Julien Muchembled
+* Loïc Grenié
* Lubomír Bulej
* Mads Kiilerich
* Marc A. Lehmann
dnl Checks for library functions.
AC_TYPE_SIGNAL
-AC_CHECK_FUNCS([asprintf daemon fchmod flock ftime fork get_current_dir_name gettimeofday mlockall putenv random select strdup strerror strsignal strtol system time usleep unsetenv vsyslog writev],
+AC_CHECK_FUNCS([asprintf daemon fchmod flock ftime fork get_current_dir_name gettimeofday mlockall pselect putenv random select strdup strerror strsignal strtol system time usleep unsetenv vsyslog writev],
[], [], [#include "have.h"]
)
Partially rereads configuration files.
Connections to hosts whose host config file are removed are closed.
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.
@end table
New outgoing connections specified in
.Pa tinc.conf
will be made.
+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.
AC_DEFUN([tinc_OPENSSL],
[
+ case $host_os in
+ *mingw*)
+ ;;
+ *)
+ AC_CHECK_FUNC(dlopen,
+ [],
+ [AC_CHECK_LIB(dl, dlopen,
+ [LIBS="$LIBS -ldl"],
+ [AC_MSG_ERROR([OpenSSL depends on libdl.]); break]
+ )]
+ )
+ ;;
+ esac
+
AC_ARG_WITH(openssl,
AS_HELP_STRING([--with-openssl=DIR], [OpenSSL base directory, or:]),
[openssl="$withval"
[AC_MSG_ERROR([OpenSSL libraries not found.])]
)
-case $host_os in
- *mingw*)
- ;;
- *)
- AC_CHECK_FUNC(dlopen,
- [],
- [AC_CHECK_LIB(dl, dlopen,
- [LIBS="$LIBS -ldl"],
- [AC_MSG_ERROR([OpenSSL depends on libdl.]); break]
- )]
- )
- ;;
-esac
-
AC_CHECK_FUNCS([RAND_pseudo_bytes EVP_EncryptInit_ex], ,
[AC_MSG_ERROR([Missing OpenSSL functionality, make sure you have installed the latest version.]); break],
)
#include "system.h"
#include "conf.h"
+#include "device.h"
#include "logger.h"
#include "net.h"
#include "route.h"
#include "splay_tree.h"
#include "connection.h"
#include "conf.h"
+#include "list.h"
#include "logger.h"
#include "netutl.h" /* for str2address */
#include "protocol.h"
#include "control_common.h"
#include "list.h"
#include "logger.h"
-#include "net.h" /* Don't ask. */
-#include "netutl.h"
#include "subnet.h"
#include "utils.h"
#include "xalloc.h"
} connection_status_t;
#include "edge.h"
-#include "list.h"
#include "net.h"
#include "node.h"
#include <w32api/winioctl.h>
#include "conf.h"
+#include "device.h"
#include "logger.h"
#include "net.h"
#include "route.h"
#include "system.h"
+#include "device.h"
#include "logger.h"
#include "net.h"
#include "connection.h"
#include "device.h"
#include "edge.h"
+#include "graph.h"
#include "logger.h"
#include "netutl.h"
#include "node.h"
n->address is set to the e->address of the edge left of n to n.
We are currently examining the edge e right of n from n:
- - If e->reverse->address != n->address, then e->to is probably
- not reachable for the nodes left of n. We do as if the indirectdata
- flag is set on edge e.
- If edge e provides for better reachability of e->to, update e->to.
*/
e->to->via = indirect ? n->via : e->to;
e->to->options = e->options;
- if(sockaddrcmp(&e->to->address, &e->address)) {
- node = splay_unlink(node_udp_tree, e->to);
- sockaddrfree(&e->to->address);
- sockaddrcpy(&e->to->address, &e->address);
-
- if(e->to->hostname)
- free(e->to->hostname);
-
- e->to->hostname = sockaddr2hostname(&e->to->address);
-
- if(node)
- splay_insert_node(node_udp_tree, node);
-
- if(e->to->options & OPTION_PMTU_DISCOVERY) {
- e->to->mtuprobes = 0;
- e->to->minmtu = 0;
- e->to->maxmtu = MTU;
- if(e->to->status.validkey)
- send_mtu_probe(e->to);
- }
- }
+ if(e->to->address.sa.sa_family == AF_UNSPEC && e->address.sa.sa_family != AF_UNKNOWN)
+ update_node_udp(e->to, &e->address);
ifdebug(SCARY_THINGS) logger(LOG_DEBUG, " Updating edge %s - %s weight %d distance %d", e->from->name,
e->to->name, e->weight, e->to->distance);
#define __TINC_GRAPH_H__
extern void graph(void);
-extern void mst_kruskal(void);
-extern void sssp_bfs(void);
+extern void dump_graph(void);
#endif /* __TINC_GRAPH_H__ */
#define DEFAULT_DEVICE "/dev/net/tun"
#include "conf.h"
+#include "device.h"
#include "logger.h"
#include "net.h"
#include "route.h"
case LOGMODE_FILE:
logpid = getpid();
logfile = fopen(logfilename, "a");
- if(!logfile)
+ if(!logfile) {
+ fprintf(stderr, "Could not open log file %s: %s\n", logfilename, strerror(errno));
logmode = LOGMODE_NULL;
+ }
break;
case LOGMODE_SYSLOG:
#ifdef HAVE_MINGW
loghandle = RegisterEventSource(NULL, logident);
- if(!loghandle)
+ if(!loghandle) {
+ fprintf(stderr, "Could not open log handle!");
logmode = LOGMODE_NULL;
+ }
break;
#else
#ifdef HAVE_SYSLOG_H
}
}
+void reopenlogger() {
+ if(logmode != LOGMODE_FILE)
+ return;
+
+ fflush(logfile);
+ FILE *newfile = fopen(logfilename, "a");
+ if(!newfile) {
+ logger(LOG_ERR, "Unable to reopen log file %s: %s\n", logfilename, strerror(errno));
+ return;
+ }
+ fclose(logfile);
+ logfile = newfile;
+}
+
void logger(int priority, const char *format, ...) {
va_list ap;
+ char timestr[32] = "";
+ time_t now;
va_start(ap, format);
fflush(stderr);
break;
case LOGMODE_FILE:
- fprintf(logfile, "%ld %s[%ld]: ", time(NULL), logident, (long)logpid);
+ 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);
extern debug_t debug_level;
extern void openlogger(const char *, logmode_t);
+extern void reopenlogger(void);
extern void logger(int, const char *, ...) __attribute__ ((__format__(printf, 2, 3)));
extern void closelogger(void);
#include <winioctl.h>
#include "conf.h"
+#include "device.h"
#include "logger.h"
#include "net.h"
#include "route.h"
Copyright (C) 1998-2005 Ivo Timmermans,
2000-2011 Guus Sliepen <guus@tinc-vpn.org>
2006 Scott Lamb <slamb@slamb.org>
+ 2011 Loïc Grenié <loic.grenie@gmail.com>
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
next = node->next;
c = node->data;
- if(c->last_ping_time + pingtimeout < now) {
+ 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, now - c->last_ping_time);
terminate_connection(c, true);
continue;
- } else if(c->last_ping_time + pinginterval < now) {
+ } else if(c->last_ping_time + pinginterval <= now) {
send_ping(c);
}
} else {
extern int setup_listen_socket(const sockaddr_t *);
extern int setup_vpn_in_socket(const sockaddr_t *);
extern void send_packet(struct node_t *, vpn_packet_t *);
-extern void receive_tcppacket(struct connection_t *, char *, int);
+extern void receive_tcppacket(struct connection_t *, const char *, int);
extern void broadcast_packet(const struct node_t *, vpn_packet_t *);
extern bool setup_network(void);
extern void setup_outgoing_connection(struct outgoing_t *);
extern void send_mtu_probe(struct node_t *);
extern void handle_device_data(int, short, void *);
extern void handle_meta_connection_data(int, short, void *);
-extern void regenerate_key();
+extern void regenerate_key(void);
extern void purge(void);
extern void retry(void);
extern int reload_configuration(void);
-extern void load_all_subnets();
+extern void load_all_subnets(void);
#ifndef HAVE_MINGW
#define closesocket(s) close(s)
#include "device.h"
#include "ethernet.h"
#include "graph.h"
-#include "list.h"
#include "logger.h"
#include "net.h"
#include "netutl.h"
receive_packet(n, inpkt);
}
-void receive_tcppacket(connection_t *c, char *buffer, int len) {
+void receive_tcppacket(connection_t *c, const char *buffer, int len) {
vpn_packet_t outpkt;
outpkt.len = len;
"No valid key known yet for %s (%s), forwarding via TCP",
n->name, n->hostname);
- if(n->last_req_key + 10 < now) {
+ if(n->last_req_key + 10 <= now) {
send_req_key(n);
n->last_req_key = now;
}
#include "cipher.h"
#include "connection.h"
#include "digest.h"
-#include "list.h"
#include "subnet.h"
typedef struct node_status_t {
#include "device.h"
#include "edge.h"
#include "logger.h"
+#include "net.h"
#include "node.h"
#include "process.h"
#include "subnet.h"
next = node->next;
p = node->data;
- if(p->firstseen + pinginterval < now)
+ if(p->firstseen + pinginterval <= now)
splay_delete_node(past_request_tree, node), deleted++;
else
left++;
extern bool send_del_subnet(struct connection_t *, const struct subnet_t *);
extern bool send_add_edge(struct connection_t *, const struct edge_t *);
extern bool send_del_edge(struct connection_t *, const struct edge_t *);
-extern void send_key_changed();
+extern void send_key_changed(void);
extern bool send_req_key(struct node_t *);
extern bool send_ans_key(struct node_t *);
-extern bool send_tcppacket(struct connection_t *, struct vpn_packet_t *);
+extern bool send_tcppacket(struct connection_t *, const struct vpn_packet_t *);
/* Request handlers */
/* Sending and receiving packets via TCP */
-bool send_tcppacket(connection_t *c, vpn_packet_t *packet) {
+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. */
#include <netpacket/packet.h>
#include "conf.h"
+#include "device.h"
#include "net.h"
#include "logger.h"
#include "utils.h"
#include <net/if_tun.h>
#include "conf.h"
+#include "device.h"
#include "logger.h"
#include "net.h"
#include "utils.h"
}
#ifdef HAVE_MINGW
-# define setpriority(level) SetPriorityClass(GetCurrentProcess(), (level))
+# define setpriority(level) !SetPriorityClass(GetCurrentProcess(), (level))
#else
# define NORMAL_PRIORITY_CLASS 0
# define BELOW_NORMAL_PRIORITY_CLASS 10
#include <sys/un.h>
#include "conf.h"
+#include "device.h"
#include "net.h"
#include "logger.h"
#include "utils.h"
}
#endif
-unsigned int bitfield_to_int(void *bitfield, size_t size) {
+unsigned int bitfield_to_int(const void *bitfield, size_t size) {
unsigned int value = 0;
if(size > sizeof value)
size = sizeof value;
#define sockinuse(x) ((x) == EADDRINUSE)
#endif
-extern unsigned int bitfield_to_int(void *bitfield, size_t size);
+extern unsigned int bitfield_to_int(const void *bitfield, size_t size);
#endif /* __TINC_UTILS_H__ */
#include <libvdeplug_dyn.h>
#include "conf.h"
+#include "device.h"
#include "net.h"
#include "logger.h"
#include "utils.h"