mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
vless: added udp support
This commit is contained in:
1 parent
bc68535dcd
commit
b323a62ce6
10 files changed
+97
-34
No files matched your search
@@ -27,8 +27,8 @@ type Conn struct {
|
||||
rcved bool
|
||||
}
|
||||
|
||||
// NewConn returns a new vless client conn.
|
||||
func NewConn(c net.Conn, uuid [16]byte, target string) (*Conn, error) {
|
||||
// ClientConn returns a new vless client conn.
|
||||
func ClientConn(c net.Conn, uuid [16]byte, network, target string) (*Conn, error) {
|
||||
atyp, addr, port, err := ParseAddr(target)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -40,7 +40,12 @@ func NewConn(c net.Conn, uuid [16]byte, target string) (*Conn, error) {
|
||||
buf.WriteByte(Version) // ver
|
||||
buf.Write(uuid[:]) // uuid
|
||||
buf.WriteByte(0) // addLen
|
||||
buf.WriteByte(CmdTCP) // cmd
|
||||
|
||||
cmd := CmdTCP
|
||||
if network == "udp" {
|
||||
cmd = CmdUDP
|
||||
}
|
||||
buf.WriteByte(cmd) // cmd
|
||||
|
||||
// target
|
||||
err = binary.Write(buf, binary.BigEndian, uint16(port)) // port
|
||||
|
||||
Reference in new issue
Block a user