mihomo/listener/inner/tcp.go

26 lines
448 B
Go
Raw Normal View History

package inner
import (
"errors"
"net"
"github.com/Dreamacro/clash/adapter/inbound"
C "github.com/Dreamacro/clash/constant"
)
var tunnel C.Tunnel
func New(t C.Tunnel) {
tunnel = t
}
func HandleTcp(address string) (conn net.Conn, err error) {
if tunnel == nil {
return nil, errors.New("tcp uninitialized")
}
// executor Parsed
conn1, conn2 := net.Pipe()
2023-10-11 10:55:12 +08:00
go tunnel.HandleTCPConn(inbound.NewInner(conn2, address))
return conn1, nil
}