From 93d2cfa0918e27b28a00496c57d38575a29a2f1a Mon Sep 17 00:00:00 2001 From: fishg <1423545+fishg@users.noreply.github.com> Date: Mon, 4 Apr 2022 10:39:26 +0800 Subject: [PATCH 1/2] fix: when ssh connect to a ip, if this ip map to a domain in clash, change ip to host may redirect to a diffrent ip --- constant/metadata.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/constant/metadata.go b/constant/metadata.go index f63816b18..3da67201a 100644 --- a/constant/metadata.go +++ b/constant/metadata.go @@ -83,7 +83,11 @@ type Metadata struct { } func (m *Metadata) RemoteAddress() string { - return net.JoinHostPort(m.String(), m.DstPort) + if m.DstIP != nil { + return net.JoinHostPort(m.DstIP.String(), m.DstPort) + } else { + return net.JoinHostPort(m.String(), m.DstPort) + } } func (m *Metadata) SourceAddress() string { From 7a8af90b8654ea5b1a6af1abaae3dbede333d700 Mon Sep 17 00:00:00 2001 From: fishg <1423545+fishg@users.noreply.github.com> Date: Mon, 4 Apr 2022 10:43:25 +0800 Subject: [PATCH 2/2] feat: add SMTPS/POP3S/IMAPS port to sni detect --- tunnel/statistic/tracker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tunnel/statistic/tracker.go b/tunnel/statistic/tracker.go index f213ca61b..db018c05c 100644 --- a/tunnel/statistic/tracker.go +++ b/tunnel/statistic/tracker.go @@ -52,7 +52,7 @@ func (tt *tcpTracker) Write(b []byte) (int, error) { n, err := tt.Conn.Write(b) upload := int64(n) tt.manager.PushUploaded(upload) - if tt.UploadTotal.Load() < 128 && tt.Metadata.Host == "" && (tt.Metadata.DstPort == "443" || tt.Metadata.DstPort == "8443") { + if tt.UploadTotal.Load() < 128 && tt.Metadata.Host == "" && (tt.Metadata.DstPort == "443" || tt.Metadata.DstPort == "8443" || tt.Metadata.DstPort == "993" || tt.Metadata.DstPort == "465" || tt.Metadata.DstPort == "995") { header, err := tls.SniffTLS(b) if err != nil { // log.Errorln("Expect no error but actually %s %s:%s:%s", err.Error(), tt.Metadata.Host, tt.Metadata.DstIP.String(), tt.Metadata.DstPort)