mirror of https://github.com/ginuerzh/gost
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
625 B
39 lines
625 B
package main
|
|
|
|
import (
|
|
//"github.com/ginuerzh/gosocks5"
|
|
//"github.com/golang/glog"
|
|
"net"
|
|
)
|
|
|
|
type UDPConn struct {
|
|
isClient bool
|
|
udpConn *net.UDPConn
|
|
addr net.Addr
|
|
tcpConn net.Conn
|
|
}
|
|
|
|
func Client(conn net.Conn, addr net.Addr) *UDPConn {
|
|
client := &UDPConn{isClient: true}
|
|
|
|
switch conn := conn.(type) {
|
|
case *net.UDPConn:
|
|
client.udpConn = conn
|
|
client.addr = addr
|
|
default:
|
|
client.tcpConn = conn
|
|
}
|
|
|
|
return client
|
|
}
|
|
|
|
func Server(conn net.Conn) *UDPConn {
|
|
server := &UDPConn{}
|
|
switch conn := conn.(type) {
|
|
case *net.UDPConn:
|
|
server.udpConn = conn
|
|
default:
|
|
server.tcpConn = conn
|
|
}
|
|
return server
|
|
}
|
|
|