Skip to content

Commit b116e23

Browse files
committed
udp: skip h3 proxying for rpnwin
1 parent ea84b98 commit b116e23

4 files changed

Lines changed: 23 additions & 7 deletions

File tree

intra/common.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,13 @@ func (h *baseHandler) flowing(smm *FlowSummary) {
790790
h.listener.Flowing(smm.postMark())
791791
}
792792

793+
func maybeH3(addr netip.AddrPort) bool {
794+
if !addr.IsValid() {
795+
return false
796+
}
797+
return addr.Port() == 443 || addr.Port() == 80
798+
}
799+
793800
func conn2str(a net.Conn, b net.Conn) string {
794801
ar := a.RemoteAddr()
795802
br := b.RemoteAddr()

intra/ipn/proxies.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,6 +1474,10 @@ func isRPN(id string) bool {
14741474
return strings.Contains(id, RPN) // RPN is a suffix
14751475
}
14761476

1477+
func DontProxyH3(id string) bool {
1478+
return strings.Contains(id, RpnWin)
1479+
}
1480+
14771481
func isWG(id string) bool {
14781482
return strings.HasPrefix(id, WG) || strings.HasPrefix(id, WGFAST)
14791483
}

intra/tcp.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (h *tcpHandler) ReverseProxy(gconn *netstack.GTCPConn, in net.Conn, to, fro
161161
cid, uid, _, pids := h.judge(fm)
162162
smm := tcpSummary(cid, uid, to.Addr(), from.Addr())
163163

164-
if settings.Debug {
164+
if log.Verbose {
165165
log.V("tcp: %s [%s]: reverse: %s => %s; pids: %v", cid, uid, from, to, pids)
166166
}
167167

@@ -314,7 +314,7 @@ func (h *tcpHandler) Proxy(gconn *netstack.GTCPConn, src, target netip.AddrPort)
314314
} // else not a dns request
315315
} // if ipn.Exit then let it connect as-is (aka exit)
316316

317-
if settings.Debug {
317+
if log.Verbose {
318318
log.V("tcp: %s proxying %s => %s [%v] (excluded: %v) for %s; pids: %s; localnat64? %t / happyeye? %t",
319319
cid, src, target, actualTargets, excluded, uid, pids, targetIsLocalNat64, happyeyeballs)
320320
}
@@ -402,7 +402,7 @@ func (h *tcpHandler) handle(px ipn.Proxy, gconn *netstack.GTCPConn, src, target
402402

403403
start := time.Now()
404404

405-
if settings.Debug {
405+
if log.Verbose {
406406
log.V("tcp: %s dial %s: attempt(eim? %t / fwd? %t / canfwd? %t): %s [%s [%s]] => %s for %s",
407407
smm.ID, pid, eim, portfwd, canportfwd, src, gconn.LocalAddr(), bindAddr, targetstr, smm.UID)
408408
}

intra/udp.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (h *udpHandler) ReverseProxy(gconn *netstack.GUDPConn, in net.Conn, to, fro
9595
cid, uid, _, pids := h.judge(fm)
9696
smm := udpSummary(cid, uid, to.Addr(), from.Addr())
9797

98-
if settings.Debug {
98+
if log.Verbose {
9999
log.V("udp: %s [%s]: reverse: %s => %s; pids: %v", cid, uid, from, to, pids)
100100
}
101101

@@ -295,15 +295,15 @@ func (h *udpHandler) Connect(gconn *netstack.GUDPConn, src, target netip.AddrPor
295295
canportfwd := portfwd
296296
if mux {
297297
if muxpid := h.mux.pid(src); len(muxpid) > 0 && containsPid(pids, muxpid) {
298-
if settings.Debug {
298+
if log.Debug {
299299
log.D("udp: connect: %s [%s] mux: %s => %s using muxed-pid %s; all pids %s",
300300
cid, uid, src, target, muxpid, pids)
301301
}
302302
pids = []string{muxpid}
303303
} // else: mxr will dial this conn with a different pid
304304
}
305305

306-
if settings.Debug {
306+
if log.Verbose {
307307
log.V("udp: connect: %s [%s] proxying %s => %s [%v]; pids: %s, mux? %t / fwd? %t / localnat64? %t",
308308
cid, uid, src, target, actualTargets, pids, mux, canportfwd, targetIsLocalNat64)
309309
}
@@ -339,13 +339,18 @@ func (h *udpHandler) Connect(gconn *netstack.GUDPConn, src, target netip.AddrPor
339339
continue
340340
}
341341

342+
if maybeH3(dstipp) && ipn.DontProxyH3(pxid) {
343+
errs = log.WE("udp: connect: #%d: %s [%s] proxy(%s) no h3 to dst(%s)", i, cid, uid, pxid, dstipp)
344+
continue
345+
}
346+
342347
pxid = smm.PID
343348
canportfwd = portfwd && ipn.Remote(pxid)
344349

345350
if mux { // mux is not supported by all proxies (few like Exit, Base, WG support it)
346351
pc, err = h.mux.associate(cid, pxid, uid, src, selectedTarget, px.Dialer().Announce, vendor(dmx), canportfwd)
347352
} else {
348-
if settings.Debug {
353+
if log.Verbose {
349354
log.VV("udp: connect: #%d: attempt: %s [%s] proxy(%s) to dst(%s); mux? %t / fwd? %t",
350355
i, cid, uid, pxid, selectedTarget, mux, canportfwd)
351356
}

0 commit comments

Comments
 (0)