From 623d261932ce8eb20d583222aec200dc6ccde273 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Mon, 21 Sep 2020 22:22:07 +0800 Subject: [PATCH] Chore: sync necessary changes from premium --- common/cache/lrucache.go | 2 +- component/fakeip/pool.go | 2 +- tunnel/connection.go | 13 ++++++------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/common/cache/lrucache.go b/common/cache/lrucache.go index 4246d841..a2e0e903 100644 --- a/common/cache/lrucache.go +++ b/common/cache/lrucache.go @@ -188,7 +188,7 @@ func (c *LruCache) get(key interface{}) *entry { } // Delete removes the value associated with a key. -func (c *LruCache) Delete(key string) { +func (c *LruCache) Delete(key interface{}) { c.mu.Lock() if le, ok := c.cache[key]; ok { diff --git a/component/fakeip/pool.go b/component/fakeip/pool.go index dd8749a6..46fe5927 100644 --- a/component/fakeip/pool.go +++ b/component/fakeip/pool.go @@ -121,7 +121,7 @@ func ipToUint(ip net.IP) uint32 { } func uintToIP(v uint32) net.IP { - return net.IPv4(byte(v>>24), byte(v>>16), byte(v>>8), byte(v)) + return net.IP{byte(v >> 24), byte(v >> 16), byte(v >> 8), byte(v)} } // New return Pool instance diff --git a/tunnel/connection.go b/tunnel/connection.go index 13f7875a..1e8ee1df 100644 --- a/tunnel/connection.go +++ b/tunnel/connection.go @@ -9,14 +9,13 @@ import ( "strings" "time" - adapters "github.com/Dreamacro/clash/adapters/inbound" + "github.com/Dreamacro/clash/adapters/inbound" + "github.com/Dreamacro/clash/common/pool" "github.com/Dreamacro/clash/component/resolver" C "github.com/Dreamacro/clash/constant" - - "github.com/Dreamacro/clash/common/pool" ) -func handleHTTP(request *adapters.HTTPAdapter, outbound net.Conn) { +func handleHTTP(request *inbound.HTTPAdapter, outbound net.Conn) { req := request.R host := req.Host @@ -28,7 +27,7 @@ func handleHTTP(request *adapters.HTTPAdapter, outbound net.Conn) { req.Header.Set("Connection", "close") req.RequestURI = "" - adapters.RemoveHopByHopHeaders(req.Header) + inbound.RemoveHopByHopHeaders(req.Header) err := req.Write(outbound) if err != nil { break @@ -39,7 +38,7 @@ func handleHTTP(request *adapters.HTTPAdapter, outbound net.Conn) { if err != nil { break } - adapters.RemoveHopByHopHeaders(resp.Header) + inbound.RemoveHopByHopHeaders(resp.Header) if resp.StatusCode == http.StatusContinue { err = resp.Write(request) @@ -128,7 +127,7 @@ func handleUDPToLocal(packet C.UDPPacket, pc net.PacketConn, key string, fAddr n } } -func handleSocket(request *adapters.SocketAdapter, outbound net.Conn) { +func handleSocket(request C.ServerAdapter, outbound net.Conn) { relay(request, outbound) }