devip: allow (NAT) hole punching for ICMP and UDP

When establishing an translation for ICMP or UDP,
allow the reply to be matched from ANY source ip/port.
This commit is contained in:
cinap_lenrek 2024-10-26 17:05:35 +00:00
parent 7ee606d027
commit a916137c97

View file

@ -520,7 +520,8 @@ transforward(Proto *p, Ipht *ht, uchar *sa, int sp, uchar *da, int dp, Route *r)
q->backward.trans = 2;
q->backward.lport = lport;
ipmove(q->backward.laddr, ia);
if(p->ipproto == 1 || ipismulticast(da)){
if(p->ipproto == 1 || p->ipproto == 17){
/* ICMP and UDP allow reply from anyone (for hole punching) */
q->backward.rport = 0;
ipmove(q->backward.raddr, IPnoaddr);
} else {