SpoofDPI/net/dial.go

32 lines
517 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) {
2022-11-29 07:54:28 +00:00
p, _ := strconv.Atoi(port)
2022-05-13 09:49:05 +00:00
2022-11-29 07:54:28 +00:00
addr := &net.TCPAddr{
IP: net.ParseIP(ip),
Port: p,
}
2022-05-13 09:49:05 +00:00
conn, err := net.DialTCP(network, nil, addr)
if err != nil {
2022-01-13 16:06:14 +00:00
return &Conn{}, err
}
return &Conn{*conn}, nil
}