Browse Source

UDS: prevent crash when proxy udp (#3967)

* net: Prevent nil pointer err in NetAddr()

* Fix dsworker saddr problem
pull/3971/head
风扇滑翔翼 2 weeks ago committed by GitHub
parent
commit
057e6284b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      app/proxyman/inbound/worker.go
  2. 10
      common/net/destination.go

3
app/proxyman/inbound/worker.go

@ -464,7 +464,8 @@ func (w *dsWorker) callback(conn stat.Connection) {
} }
} }
ctx = session.ContextWithInbound(ctx, &session.Inbound{ ctx = session.ContextWithInbound(ctx, &session.Inbound{
Source: net.DestinationFromAddr(conn.RemoteAddr()), // Unix have no source addr, so we use gateway as source for log.
Source: net.UnixDestination(w.address),
Gateway: net.UnixDestination(w.address), Gateway: net.UnixDestination(w.address),
Tag: w.tag, Tag: w.tag,
Conn: conn, Conn: conn,

10
common/net/destination.go

@ -89,10 +89,12 @@ func UnixDestination(address Address) Destination {
// NetAddr returns the network address in this Destination in string form. // NetAddr returns the network address in this Destination in string form.
func (d Destination) NetAddr() string { func (d Destination) NetAddr() string {
addr := "" addr := ""
if d.Network == Network_TCP || d.Network == Network_UDP { if d.Address != nil {
addr = d.Address.String() + ":" + d.Port.String() if d.Network == Network_TCP || d.Network == Network_UDP {
} else if d.Network == Network_UNIX { addr = d.Address.String() + ":" + d.Port.String()
addr = d.Address.String() } else if d.Network == Network_UNIX {
addr = d.Address.String()
}
} }
return addr return addr
} }

Loading…
Cancel
Save