feat(listener/runix): support remote UDS forwarding (#102)

This commit is contained in:
Yuan Tong
2026-06-13 13:39:14 +08:00
committed by GitHub
parent 9f610fd163
commit 8b0806bad4
14 changed files with 247 additions and 34 deletions
+11 -2
View File
@@ -236,6 +236,7 @@ func (h *relayHandler) Handle(ctx context.Context, conn net.Conn, opts ...handle
var user, pass string
var address string
var addrFeature *relay.AddrFeature
var networkID relay.NetworkID
for _, f := range req.Features {
switch f.Type() {
@@ -245,7 +246,7 @@ func (h *relayHandler) Handle(ctx context.Context, conn net.Conn, opts ...handle
}
case relay.FeatureAddr:
if feature, _ := f.(*relay.AddrFeature); feature != nil {
address = net.JoinHostPort(feature.Host, strconv.Itoa(int(feature.Port)))
addrFeature = feature
}
case relay.FeatureNetwork:
if feature, _ := f.(*relay.NetworkFeature); feature != nil {
@@ -275,6 +276,14 @@ func (h *relayHandler) Handle(ctx context.Context, conn net.Conn, opts ...handle
if (req.Cmd & relay.FUDP) == relay.FUDP {
network = "udp"
}
if addrFeature != nil {
switch network {
case "unix", "serial":
address = addrFeature.Host
default:
address = net.JoinHostPort(addrFeature.Host, strconv.Itoa(int(addrFeature.Port)))
}
}
ro.Network = network
ro.Host = address
log = log.WithFields(map[string]any{"network": network})
@@ -302,4 +311,4 @@ func (h *relayHandler) Close() error {
h.cancel()
}
return nil
}
}