github.com/metacubex/mihomo@v1.18.5/adapter/inbound/socket.go (about)

     1  package inbound
     2  
     3  import (
     4  	"net"
     5  
     6  	C "github.com/metacubex/mihomo/constant"
     7  	"github.com/metacubex/mihomo/transport/socks5"
     8  )
     9  
    10  // NewSocket receive TCP inbound and return ConnContext
    11  func NewSocket(target socks5.Addr, conn net.Conn, source C.Type, additions ...Addition) (net.Conn, *C.Metadata) {
    12  	metadata := parseSocksAddr(target)
    13  	metadata.NetWork = C.TCP
    14  	metadata.Type = source
    15  	ApplyAdditions(metadata, WithSrcAddr(conn.RemoteAddr()), WithInAddr(conn.LocalAddr()))
    16  	ApplyAdditions(metadata, additions...)
    17  	return conn, metadata
    18  }