general: add vendor folder

This commit is contained in:
nadoo committed 2018-07-07 11:07:38 +08:00
1 parent 621e8ed018
commit 3c766d0b68
103 files changed
+18061 -19

No files matched your search

+13 -13
View File
@@ -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
}