shithub: front

Download patch

ref: a916137c973c6f0d3c3da14eb5a3d8ca735525fc
parent: 7ee606d02740831c843a323d35b8a6051b08ad27
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Oct 26 13:05:35 EDT 2024

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.

--- a/sys/src/9/ip/ipaux.c
+++ b/sys/src/9/ip/ipaux.c
@@ -520,7 +520,8 @@
 	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 {
--