Browse Source

comments

pull/432/head
Darien Raymond 8 years ago
parent
commit
76d2e5517b
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
  1. 2
      common/net/address.proto
  2. 1
      common/net/network.proto
  3. 2
      common/protocol/server_spec.proto
  4. 1
      common/protocol/user.proto
  5. 3
      common/serial/bytes.go
  6. 10
      common/serial/hash.go
  7. 1
      common/serial/numbers.go
  8. 1
      common/serial/string.go

2
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.

1
common/net/network.proto

@ -14,6 +14,7 @@ enum Network {
UDP = 3;
}
// NetworkList is a list of Networks.
message NetworkList {
repeated Network network = 1;
}

2
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;
}
}

1
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;

3
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 |

10
common/serial/hash.go

@ -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
}
}

1
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))
}

1
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 " "

Loading…
Cancel
Save