mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
general: add vendor folder
This commit is contained in:
1 parent
621e8ed018
commit
3c766d0b68
103 files changed
+18061
-19
No files matched your search
+13
-13
@@ -5,15 +5,15 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// AType is vmess addr type
|
||||
type AType byte
|
||||
// Atyp is vmess addr type
|
||||
type Atyp byte
|
||||
|
||||
// Atyp
|
||||
const (
|
||||
ATypeErr AType = 0
|
||||
ATypeIP4 AType = 1
|
||||
ATypeDomain AType = 2
|
||||
ATypeIP6 AType = 3
|
||||
AtypErr Atyp = 0
|
||||
AtypIP4 Atyp = 1
|
||||
AtypDomain Atyp = 2
|
||||
AtypIP6 Atyp = 3
|
||||
)
|
||||
|
||||
// Addr is vmess addr
|
||||
@@ -22,9 +22,9 @@ type Addr []byte
|
||||
// Port is vmess addr port
|
||||
type Port uint16
|
||||
|
||||
// ParseAddr parses the address in string s. return AType = 0 if error.
|
||||
func ParseAddr(s string) (AType, Addr, Port, error) {
|
||||
var atype AType
|
||||
// ParseAddr parses the address in string s
|
||||
func ParseAddr(s string) (Atyp, Addr, Port, error) {
|
||||
var atyp Atyp
|
||||
var addr Addr
|
||||
|
||||
host, port, err := net.SplitHostPort(s)
|
||||
@@ -35,11 +35,11 @@ func ParseAddr(s string) (AType, Addr, Port, error) {
|
||||
if ip := net.ParseIP(host); ip != nil {
|
||||
if ip4 := ip.To4(); ip4 != nil {
|
||||
addr = make([]byte, net.IPv4len)
|
||||
atype = ATypeIP4
|
||||
atyp = AtypIP4
|
||||
copy(addr[:], ip4)
|
||||
} else {
|
||||
addr = make([]byte, net.IPv6len)
|
||||
atype = ATypeIP6
|
||||
atyp = AtypIP6
|
||||
copy(addr[:], ip)
|
||||
}
|
||||
} else {
|
||||
@@ -47,7 +47,7 @@ func ParseAddr(s string) (AType, Addr, Port, error) {
|
||||
return 0, nil, 0, err
|
||||
}
|
||||
addr = make([]byte, 1+len(host))
|
||||
atype = ATypeDomain
|
||||
atyp = AtypDomain
|
||||
addr[0] = byte(len(host))
|
||||
copy(addr[1:], host)
|
||||
}
|
||||
@@ -57,5 +57,5 @@ func ParseAddr(s string) (AType, Addr, Port, error) {
|
||||
return 0, nil, 0, err
|
||||
}
|
||||
|
||||
return atype, addr, Port(portnum), err
|
||||
return atyp, addr, Port(portnum), err
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package vmess
|
||||
|
||||
// chunk: plain, AES-128-CFB, AES-128-GCM, ChaCha20-Poly1305
|
||||
@@ -51,9 +51,9 @@ type Conn struct {
|
||||
user *User
|
||||
security byte
|
||||
|
||||
atype AType
|
||||
addr Addr
|
||||
port Port
|
||||
atyp Atyp
|
||||
addr Addr
|
||||
port Port
|
||||
|
||||
reqBodyIV [16]byte
|
||||
reqBodyKey [16]byte
|
||||
@@ -99,7 +99,7 @@ func (c *Client) NewConn(rc net.Conn, target string) (*Conn, error) {
|
||||
conn := &Conn{user: c.users[r], security: c.security}
|
||||
|
||||
var err error
|
||||
conn.atype, conn.addr, conn.port, err = ParseAddr(target)
|
||||
conn.atyp, conn.addr, conn.port, err = ParseAddr(target)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -161,7 +161,7 @@ func (c *Conn) EncodeRequest() ([]byte, error) {
|
||||
|
||||
// target
|
||||
binary.Write(buf, binary.BigEndian, uint16(c.port)) // port
|
||||
buf.WriteByte(byte(c.atype)) // atype
|
||||
buf.WriteByte(byte(c.atyp)) // atyp
|
||||
buf.Write(c.addr) // addr
|
||||
|
||||
// padding
|
||||
@@ -211,7 +211,6 @@ func (c *Conn) DecodeRespHeader() error {
|
||||
|
||||
c.connected = true
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func (c *Conn) Read(b []byte) (n int, err error) {
|
||||
|
||||
Reference in new issue
Block a user