diff --git a/common/net/address.proto b/common/net/address.proto index 4670b769e..07f106d0a 100644 --- a/common/net/address.proto +++ b/common/net/address.proto @@ -6,7 +6,7 @@ option go_package = "net"; option java_package = "com.v2ray.core.common.net"; option java_multiple_files = true; -// Address of a network host. It may be an IP address or a domain address. +// Address of a network host. It may be either an IP address or a domain address. message IPOrDomain { oneof address { // IP address. Must by either 4 or 16 bytes. diff --git a/common/net/network.proto b/common/net/network.proto index 19a75ad65..3915091c0 100644 --- a/common/net/network.proto +++ b/common/net/network.proto @@ -14,6 +14,7 @@ enum Network { UDP = 3; } +// NetworkList is a list of Networks. message NetworkList { repeated Network network = 1; } diff --git a/common/protocol/server_spec.proto b/common/protocol/server_spec.proto index 55b6d4ca4..936140105 100644 --- a/common/protocol/server_spec.proto +++ b/common/protocol/server_spec.proto @@ -13,4 +13,4 @@ message ServerEndpoint { v2ray.core.common.net.IPOrDomain address = 1; uint32 port = 2; repeated v2ray.core.common.protocol.User user = 3; -} \ No newline at end of file +} diff --git a/common/protocol/user.proto b/common/protocol/user.proto index 87fb729f1..b92574c7b 100644 --- a/common/protocol/user.proto +++ b/common/protocol/user.proto @@ -8,6 +8,7 @@ option java_multiple_files = true; import "v2ray.com/core/common/serial/typed_message.proto"; +// User is a generic user for all procotols. message User { uint32 level = 1; string email = 2; diff --git a/common/serial/bytes.go b/common/serial/bytes.go index fd832bbf0..abcf4f69a 100644 --- a/common/serial/bytes.go +++ b/common/serial/bytes.go @@ -9,10 +9,12 @@ func ByteToHexString(value byte) string { return hex.EncodeToString([]byte{value}) } +// BytesToUint16 deserializes a byte array to an uint16 in big endian order. The byte array must have at least 2 elements. func BytesToUint16(value []byte) uint16 { return uint16(value[0])<<8 | uint16(value[1]) } +// BytesToUint32 deserializes a byte array to an uint32 in big endian order. The byte array must have at least 4 elements. func BytesToUint32(value []byte) uint32 { return uint32(value[0])<<24 | uint32(value[1])<<16 | @@ -20,6 +22,7 @@ func BytesToUint32(value []byte) uint32 { uint32(value[3]) } +// BytesToInt64 deserializes a byte array to an int64 in big endian order. The byte array must have at least 8 elements. func BytesToInt64(value []byte) int64 { return int64(value[0])<<56 | int64(value[1])<<48 | diff --git a/common/serial/hash.go b/common/serial/hash.go deleted file mode 100644 index 63aa4c022..000000000 --- a/common/serial/hash.go +++ /dev/null @@ -1,10 +0,0 @@ -package serial - -import "hash" - -func WriteHash(h hash.Hash) func([]byte) (int, error) { - return func(b []byte) (int, error) { - h.Sum(b[:0]) - return h.Size(), nil - } -} diff --git a/common/serial/numbers.go b/common/serial/numbers.go index 05a98bbe1..54ebda723 100644 --- a/common/serial/numbers.go +++ b/common/serial/numbers.go @@ -2,6 +2,7 @@ package serial import "strconv" +// Uint16ToBytes serializes an uint16 into bytes in big endian order. func Uint16ToBytes(value uint16, b []byte) []byte { return append(b, byte(value>>8), byte(value)) } diff --git a/common/serial/string.go b/common/serial/string.go index 6a7ea9181..490e49c95 100644 --- a/common/serial/string.go +++ b/common/serial/string.go @@ -5,6 +5,7 @@ import ( "strings" ) +// ToString serialize an abitrary value into string. func ToString(v interface{}) string { if v == nil { return " "