dns: change cache to lrucache

This commit is contained in:
nadoo committed 2020-10-08 18:48:23 +08:00
1 parent 8495f16a76
commit 6d64ee4c0e
11 files changed
+146 -90

No files matched your search

+2 -1
View File
@@ -28,7 +28,8 @@ func NewPktConn(c net.PacketConn, writeAddr net.Addr, tgtAddr socks.Addr, tgtHea
writeAddr: writeAddr,
tgtAddr: tgtAddr,
tgtHeader: tgtHeader,
ctrlConn: ctrlConn}
ctrlConn: ctrlConn,
}
if ctrlConn != nil {
go func() {
+4 -3
View File
@@ -54,11 +54,12 @@ func NewTLS(s string, d proxy.Dialer, p proxy.Proxy) (*TLS, error) {
}
if t.serverName == "" {
host, port, _ := net.SplitHostPort(t.addr)
if port == "" {
idx := strings.LastIndex(t.addr, ":")
if idx == -1 {
idx = len(t.addr)
t.addr = net.JoinHostPort(t.addr, "443")
}
t.serverName = host
t.serverName = t.addr[:idx]
}
return t, nil
+5 -3
View File
@@ -9,6 +9,7 @@ import (
"encoding/hex"
"net"
"net/url"
"strings"
"github.com/nadoo/glider/log"
"github.com/nadoo/glider/pool"
@@ -50,11 +51,12 @@ func NewTrojan(s string, d proxy.Dialer, p proxy.Proxy) (*Trojan, error) {
}
if t.serverName == "" {
host, port, _ := net.SplitHostPort(t.addr)
if port == "" {
idx := strings.LastIndex(t.addr, ":")
if idx == -1 {
idx = len(t.addr)
t.addr = net.JoinHostPort(t.addr, "443")
}
t.serverName = host
t.serverName = t.addr[:idx]
}
// pass