SpoofDPI/net/dial.go
2022-11-29 16:54:28 +09:00

32 lines
522 B
Go

package net
import (
"net"
"strconv"
)
func ListenTCP(network string, addr *TCPAddr) (Listener, error) {
l, err := net.ListenTCP(network, addr.Addr)
if err != nil {
return Listener{}, err
}
return Listener{listener: l}, nil
}
func DialTCP(network string, ip string, port string) (*Conn, error) {
p, _ := strconv.Atoi(port)
addr := &net.TCPAddr{
IP: net.ParseIP(ip),
Port: p,
}
conn, err := net.DialTCP(network, nil, addr)
if err != nil {
return &Conn{}, err
}
return &Conn{conn: conn}, nil
}