X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=daemon%2Fnet.c;h=4147031c2048794da9a107a16d2f22c9a43ec863;hb=0ecdd176e7eba9fb46f4b3228f8b109a7cf20ab4;hp=389072aa44e5be7a64ba928d3493e64a4a1196c0;hpb=c8a729d72dfda116361913464e023f0cea6f269a;p=doldaconnect.git diff --git a/daemon/net.c b/daemon/net.c index 389072a..4147031 100644 --- a/daemon/net.c +++ b/daemon/net.c @@ -48,17 +48,40 @@ static struct configvar myvars[] = { - /* 0 = Direct mode, 1 = Passive mode, 2 = SOCKS proxy */ + /** The network mode to use. Currently supported values are 0 for + * active mode and 1 for passive mode. In the future, SOCKS5 proxy + * support may be added. */ {CONF_VAR_INT, "mode", {.num = 0}}, + /** Set the SO_REUSEADDR socket option on listening sockets, so + * that dead TCP connections waiting for timeout are ignored. */ {CONF_VAR_BOOL, "reuseaddr", {.num = 0}}, - /* Only for direct mode */ + /** Overrides the IPv4 address reported to other clients in active + * mode. Useful for servers behind NAT routers. If both this and + * net.publicif are unspecified the address of the hub connection + * is used. */ {CONF_VAR_IPV4, "visibleipv4", {.ipv4 = {0}}}, + /** Specifies an interface name from which to fetch the IPv4 + * address reported to other clients in active mode. If both this + * and net.visibleipv4 are unspecified the address of the hub + * connection is used. */ {CONF_VAR_STRING, "publicif", {.str = L""}}, /* Diffserv should be supported on IPv4, too, but I don't know the * API to do that. */ + /** The Diffserv value to use on IPv6 connections when the + * minimize cost TOS value is used (see the TOS VALUES + * section). */ {CONF_VAR_INT, "diffserv-mincost", {.num = 0}}, + /** The Diffserv value to use on IPv6 connections when the + * maximize reliability TOS value is used (see the TOS VALUES + * section). */ {CONF_VAR_INT, "diffserv-maxrel", {.num = 0}}, + /** The Diffserv value to use on IPv6 connections when the + * maximize throughput TOS value is used (see the TOS VALUES + * section). */ {CONF_VAR_INT, "diffserv-maxtp", {.num = 0}}, + /** The Diffserv value to use on IPv6 connections when the + * minimize delay TOS value is used (see the TOS VALUES + * section). */ {CONF_VAR_INT, "diffserv-mindelay", {.num = 0}}, {CONF_VAR_END} }; @@ -253,12 +276,14 @@ void putsock(struct socket *sk) { sk->outbuf.d.f = buf->next; free(buf->data); + free(buf->addr); free(buf); } while((buf = sk->inbuf.d.f) != NULL) { sk->inbuf.d.f = buf->next; free(buf->data); + free(buf->addr); free(buf); } break; @@ -1112,6 +1137,29 @@ int sockgetremotename(struct socket *sk, struct sockaddr **namebuf, socklen_t *l } } +int sockgetremotename2(struct socket *sk, struct socket *sk2, struct sockaddr **namebuf, socklen_t *lenbuf) +{ + struct sockaddr *name1, *name2; + socklen_t len1, len2; + + if(sk->family != sk2->family) + { + flog(LOG_ERR, "using sockgetremotename2 with sockets of differing family: %i %i", sk->family, sk2->family); + return(-1); + } + if(sockgetremotename(sk, &name1, &len1)) + return(-1); + if(sockgetremotename(sk2, &name2, &len2)) { + free(name1); + return(-1); + } + sethostaddr(name1, name2); + free(name2); + *namebuf = name1; + *lenbuf = len1; + return(0); +} + int addreq(struct sockaddr *x, struct sockaddr *y) { struct sockaddr_un *u1, *u2;