ref: b562eebb96bf132eedb5e35e26d907180864b666
parent: 8ab4f89068110c14870162fbb233cccb3e094e1d
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat May 23 19:31:11 EDT 2020
ip/tinc: accept udp connection from any udp source port the remote host might be behind a NAT which translates the source port, so if no host could be found, lookup the ip address only.
--- a/sys/src/cmd/ip/tinc.c
+++ b/sys/src/cmd/ip/tinc.c
@@ -1440,12 +1440,16 @@
{uchar ip[IPaddrlen];
char dir[128];
+ int port;
Host *h;
- h = findhost(ip, dir2ipport(fd2dir(fd, dir, sizeof(dir)), ip));
+ port = dir2ipport(fd2dir(fd, dir, sizeof(dir)), ip);
+ h = findhost(ip, port);
+ if(h == nil && incoming)
+ h = findhost(ip, -1); /* might be behind NAT */
if(h != nil && h != myhost){ procsetname("udpclient %s %s %s %I!%d %s", myhost->name,- incoming ? "in": "out", dir, h->ip, h->port, h->name);
+ incoming ? "in": "out", dir, ip, port, h->name);
if(!incoming){lock(h->cin);
--
⑨