Chore: sync necessary changes from premium

This commit is contained in:
Dreamacro 2020-09-21 22:22:07 +08:00
parent 10f9571c9e
commit 8766287e72
3 changed files with 8 additions and 9 deletions

View file

@ -188,7 +188,7 @@ func (c *LruCache) get(key interface{}) *entry {
} }
// Delete removes the value associated with a key. // Delete removes the value associated with a key.
func (c *LruCache) Delete(key string) { func (c *LruCache) Delete(key interface{}) {
c.mu.Lock() c.mu.Lock()
if le, ok := c.cache[key]; ok { if le, ok := c.cache[key]; ok {

View file

@ -121,7 +121,7 @@ func ipToUint(ip net.IP) uint32 {
} }
func uintToIP(v uint32) net.IP { 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 // New return Pool instance

View file

@ -9,14 +9,13 @@ import (
"strings" "strings"
"time" "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" "github.com/Dreamacro/clash/component/resolver"
C "github.com/Dreamacro/clash/constant" 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 req := request.R
host := req.Host host := req.Host
@ -28,7 +27,7 @@ func handleHTTP(request *adapters.HTTPAdapter, outbound net.Conn) {
req.Header.Set("Connection", "close") req.Header.Set("Connection", "close")
req.RequestURI = "" req.RequestURI = ""
adapters.RemoveHopByHopHeaders(req.Header) inbound.RemoveHopByHopHeaders(req.Header)
err := req.Write(outbound) err := req.Write(outbound)
if err != nil { if err != nil {
break break
@ -39,7 +38,7 @@ func handleHTTP(request *adapters.HTTPAdapter, outbound net.Conn) {
if err != nil { if err != nil {
break break
} }
adapters.RemoveHopByHopHeaders(resp.Header) inbound.RemoveHopByHopHeaders(resp.Header)
if resp.StatusCode == http.StatusContinue { if resp.StatusCode == http.StatusContinue {
err = resp.Write(request) 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) relay(request, outbound)
} }