Merge branch 'dev' of https://github.com/Dreamacro/clash into Alpha
This commit is contained in:
@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"github.com/database64128/tfo-go"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/Dreamacro/clash/common/cache"
|
||||
N "github.com/Dreamacro/clash/common/net"
|
||||
@ -18,8 +17,9 @@ import (
|
||||
type Listener struct {
|
||||
listener net.Listener
|
||||
addr string
|
||||
cache *cache.Cache[string, bool]
|
||||
closed bool
|
||||
|
||||
cache *cache.LruCache[string, bool]
|
||||
closed bool
|
||||
}
|
||||
|
||||
// RawAddress implements C.Listener
|
||||
@ -50,7 +50,7 @@ func New(addr string, inboundTfo bool, in chan<- C.ConnContext) (*Listener, erro
|
||||
ml := &Listener{
|
||||
listener: l,
|
||||
addr: addr,
|
||||
cache: cache.New[string, bool](30 * time.Second),
|
||||
cache: cache.New[string, bool](cache.WithAge[string, bool](30)),
|
||||
}
|
||||
go func() {
|
||||
for {
|
||||
@ -68,7 +68,7 @@ func New(addr string, inboundTfo bool, in chan<- C.ConnContext) (*Listener, erro
|
||||
return ml, nil
|
||||
}
|
||||
|
||||
func handleConn(conn net.Conn, in chan<- C.ConnContext, cache *cache.Cache[string, bool]) {
|
||||
func handleConn(conn net.Conn, in chan<- C.ConnContext, cache *cache.LruCache[string, bool]) {
|
||||
conn.(*net.TCPConn).SetKeepAlive(true)
|
||||
|
||||
bufConn := N.NewBufferedConn(conn)
|
||||
|
Reference in New Issue
Block a user