From 7bcb3c901baab6c7e6daa45df0f0f1f066e2d7a1 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Wed, 6 Apr 2022 01:24:43 -0400 Subject: [PATCH] Fix client dialer log (#1568) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix client dialer log Log such as: tunneling request to tcp:www.google.com:80 via tcp:x.x.x.x:443 the second "tcp" is misleading when using mKcp or quic transport Remove the second "tcp" and add the correct logging for transport dialer: - transport/internet/tcp: dialing TCP to tcp:x.x.x.x:443 - transport/internet/quic: dialing quic to udp:x.x.x.x:443 * Update transport/internet/quic/dialer.go Co-authored-by: 秋のかえで Co-authored-by: 秋のかえで Co-authored-by: Kslr --- proxy/shadowsocks/client.go | 2 +- proxy/trojan/client.go | 2 +- proxy/vless/outbound/outbound.go | 2 +- proxy/vmess/outbound/outbound.go | 2 +- transport/internet/quic/dialer.go | 2 ++ 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/proxy/shadowsocks/client.go b/proxy/shadowsocks/client.go index b66534fd1..5c735cb65 100644 --- a/proxy/shadowsocks/client.go +++ b/proxy/shadowsocks/client.go @@ -75,7 +75,7 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter if err != nil { return newError("failed to find an available destination").AtWarning().Base(err) } - newError("tunneling request to ", destination, " via ", server.Destination()).WriteToLog(session.ExportIDToError(ctx)) + newError("tunneling request to ", destination, " via ", network, ":", server.Destination().NetAddr()).WriteToLog(session.ExportIDToError(ctx)) defer conn.Close() diff --git a/proxy/trojan/client.go b/proxy/trojan/client.go index 293e20797..8305ac167 100644 --- a/proxy/trojan/client.go +++ b/proxy/trojan/client.go @@ -71,7 +71,7 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter if err != nil { return newError("failed to find an available destination").AtWarning().Base(err) } - newError("tunneling request to ", destination, " via ", server.Destination()).WriteToLog(session.ExportIDToError(ctx)) + newError("tunneling request to ", destination, " via ", server.Destination().NetAddr()).WriteToLog(session.ExportIDToError(ctx)) defer conn.Close() diff --git a/proxy/vless/outbound/outbound.go b/proxy/vless/outbound/outbound.go index 94c57bebf..596ab8898 100644 --- a/proxy/vless/outbound/outbound.go +++ b/proxy/vless/outbound/outbound.go @@ -98,7 +98,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } target := outbound.Target - newError("tunneling request to ", target, " via ", rec.Destination()).AtInfo().WriteToLog(session.ExportIDToError(ctx)) + newError("tunneling request to ", target, " via ", rec.Destination().NetAddr()).AtInfo().WriteToLog(session.ExportIDToError(ctx)) command := protocol.RequestCommandTCP if target.Network == net.Network_UDP { diff --git a/proxy/vmess/outbound/outbound.go b/proxy/vmess/outbound/outbound.go index 2c2bfe374..9e19f8900 100644 --- a/proxy/vmess/outbound/outbound.go +++ b/proxy/vmess/outbound/outbound.go @@ -81,7 +81,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } target := outbound.Target - newError("tunneling request to ", target, " via ", rec.Destination()).WriteToLog(session.ExportIDToError(ctx)) + newError("tunneling request to ", target, " via ", rec.Destination().NetAddr()).WriteToLog(session.ExportIDToError(ctx)) command := protocol.RequestCommandTCP if target.Network == net.Network_UDP { diff --git a/transport/internet/quic/dialer.go b/transport/internet/quic/dialer.go index 85bf838ff..5e4d3bd05 100644 --- a/transport/internet/quic/dialer.go +++ b/transport/internet/quic/dialer.go @@ -138,6 +138,8 @@ func (s *clientConnections) openConnection(destAddr net.Addr, config *Config, tl } conns = removeInactiveConnections(conns) + + newError("dialing QUIC to ", dest).WriteToLog() rawConn, err := internet.ListenSystemPacket(context.Background(), &net.UDPAddr{ IP: []byte{0, 0, 0, 0},