mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-15 19:22:53 +08:00
chore: cleaned up some confusing code
Some checks failed
Trigger CMFA Update / trigger-CMFA-update (push) Has been cancelled
Some checks failed
Trigger CMFA Update / trigger-CMFA-update (push) Has been cancelled
This commit is contained in:
parent
d4478dbfa2
commit
ce52c3438b
|
@ -117,24 +117,19 @@ func (tt *tcpTracker) Upstream() any {
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseRemoteDestination(addr net.Addr, conn C.Connection) string {
|
func parseRemoteDestination(addr net.Addr, conn C.Connection) string {
|
||||||
if addr == nil && conn != nil {
|
if addr != nil {
|
||||||
return conn.RemoteDestination()
|
if addrPort, err := netip.ParseAddrPort(addr.String()); err == nil && addrPort.Addr().IsValid() {
|
||||||
}
|
return addrPort.Addr().String()
|
||||||
if addrPort, err := netip.ParseAddrPort(addr.String()); err == nil && addrPort.Addr().IsValid() {
|
|
||||||
return addrPort.Addr().String()
|
|
||||||
} else {
|
|
||||||
if conn != nil {
|
|
||||||
return conn.RemoteDestination()
|
|
||||||
} else {
|
|
||||||
return ""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if conn != nil {
|
||||||
|
return conn.RemoteDestination()
|
||||||
|
}
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTCPTracker(conn C.Conn, manager *Manager, metadata *C.Metadata, rule C.Rule, uploadTotal int64, downloadTotal int64, pushToManager bool) *tcpTracker {
|
func NewTCPTracker(conn C.Conn, manager *Manager, metadata *C.Metadata, rule C.Rule, uploadTotal int64, downloadTotal int64, pushToManager bool) *tcpTracker {
|
||||||
if conn != nil {
|
metadata.RemoteDst = parseRemoteDestination(conn.RemoteAddr(), conn)
|
||||||
metadata.RemoteDst = parseRemoteDestination(conn.RemoteAddr(), conn)
|
|
||||||
}
|
|
||||||
|
|
||||||
t := &tcpTracker{
|
t := &tcpTracker{
|
||||||
Conn: conn,
|
Conn: conn,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user