mirror of
https://github.com/xvzc/SpoofDPI.git
synced 2024-12-22 22:36:53 +00:00
32 lines
517 B
Go
32 lines
517 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}, nil
|
|
}
|