diff options
| author | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-05-23 23:31:11 +0200 |
|---|---|---|
| committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-05-23 23:31:11 +0200 |
| commit | a54804ed24165e4d9e3d433149f8535f6ce01058 (patch) | |
| tree | a86fe3816e30aa5459ae9b8ada2ef0103656251f | |
| parent | ec737b6a2e464330946d5800841a1e631cd36acd (diff) | |
| download | plan9front-a54804ed24165e4d9e3d433149f8535f6ce01058.tar.xz | |
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.
| -rw-r--r-- | sys/src/cmd/ip/tinc.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/src/cmd/ip/tinc.c b/sys/src/cmd/ip/tinc.c index 6694e47a3..4dacdd31c 100644 --- a/sys/src/cmd/ip/tinc.c +++ b/sys/src/cmd/ip/tinc.c @@ -1440,12 +1440,16 @@ udpclient(int fd, int incoming) { 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); |
