SpoofDPI/net/dial.go

32 lines
541 B
Go
Raw Normal View History

package net
import (
"net"
2022-05-13 09:49:05 +00:00
"strconv"
)
2022-05-13 09:49:05 +00:00
func ListenTCP(network string, addr *TCPAddr) (Listener, error) {
l, err := net.ListenTCP(network, addr.Addr)
if err != nil {
return Listener{}, err
}
2022-01-11 17:15:45 +00:00
return Listener{listener: l}, nil
}
2022-05-13 09:49:05 +00:00
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 {
2022-01-13 16:06:14 +00:00
return &Conn{}, err
}
2022-01-13 16:06:14 +00:00
return &Conn{conn: conn}, nil
}