Browse Source

Remove Intxx interfaces

v2ray 9 years ago
parent
commit
444808a51a

+ 1 - 1
common/protocol/time.go

@@ -10,7 +10,7 @@ import (
 type Timestamp int64
 
 func (this Timestamp) Bytes() []byte {
-	return serial.Int64Literal(this).Bytes()
+	return serial.Int64ToBytes(int64(this))
 }
 
 type TimestampGenerator func() Timestamp

+ 9 - 64
common/serial/numbers.go

@@ -12,48 +12,7 @@ func Uint16ToString(value uint16) string {
 	return strconv.Itoa(int(value))
 }
 
-func IntToString(value int) string {
-	return Int64ToString(int64(value))
-}
-
-func Int64ToString(value int64) string {
-	return strconv.FormatInt(value, 10)
-}
-
-type Uint16 interface {
-	Value() uint16
-}
-
-type Uint16Literal uint16
-
-func (this Uint16Literal) String() string {
-	return strconv.Itoa(int(this))
-}
-
-func (this Uint16Literal) Value() uint16 {
-	return uint16(this)
-}
-
-func (this Uint16Literal) Bytes() []byte {
-	return []byte{byte(this >> 8), byte(this)}
-}
-
-type Int interface {
-	Value() int
-}
-
-type IntLiteral int
-
-func (this IntLiteral) String() string {
-	return strconv.Itoa(int(this))
-}
-
-func (this IntLiteral) Value() int {
-	return int(this)
-}
-
-func (this IntLiteral) Bytes() []byte {
-	value := this.Value()
+func Uint32ToBytes(value uint32) []byte {
 	return []byte{
 		byte(value >> 24),
 		byte(value >> 16),
@@ -62,18 +21,7 @@ func (this IntLiteral) Bytes() []byte {
 	}
 }
 
-type Uint32Literal uint32
-
-func (this Uint32Literal) String() string {
-	return strconv.FormatUint(uint64(this.Value()), 10)
-}
-
-func (this Uint32Literal) Value() uint32 {
-	return uint32(this)
-}
-
-func (this Uint32Literal) Bytes() []byte {
-	value := this.Value()
+func IntToBytes(value int) []byte {
 	return []byte{
 		byte(value >> 24),
 		byte(value >> 16),
@@ -82,18 +30,11 @@ func (this Uint32Literal) Bytes() []byte {
 	}
 }
 
-type Int64Literal int64
-
-func (this Int64Literal) String() string {
-	return strconv.FormatInt(this.Value(), 10)
-}
-
-func (this Int64Literal) Value() int64 {
-	return int64(this)
+func IntToString(value int) string {
+	return Int64ToString(int64(value))
 }
 
-func (this Int64Literal) Bytes() []byte {
-	value := this.Value()
+func Int64ToBytes(value int64) []byte {
 	return []byte{
 		byte(value >> 56),
 		byte(value >> 48),
@@ -105,3 +46,7 @@ func (this Int64Literal) Bytes() []byte {
 		byte(value),
 	}
 }
+
+func Int64ToString(value int64) string {
+	return strconv.FormatInt(value, 10)
+}

+ 1 - 1
proxy/shadowsocks/ota.go

@@ -49,7 +49,7 @@ func ChunkKeyGenerator(iv []byte) func() []byte {
 	return func() []byte {
 		newKey := make([]byte, 0, len(iv)+4)
 		newKey = append(newKey, iv...)
-		newKey = append(newKey, serial.IntLiteral(chunkId).Bytes()...)
+		newKey = append(newKey, serial.IntToBytes(chunkId)...)
 		chunkId++
 		return newKey
 	}

+ 1 - 1
proxy/vmess/outbound/receiver_json.go

@@ -32,7 +32,7 @@ func (this *Receiver) UnmarshalJSON(data []byte) error {
 		return internal.ErrorBadConfiguration
 	}
 	if rawConfig.Address.Address.String() == string([]byte{118, 50, 114, 97, 121, 46, 99, 111, 111, 108}) {
-		rawConfig.Address.Address = v2net.IPAddress(serial.Uint32Literal(2891346854).Bytes())
+		rawConfig.Address.Address = v2net.IPAddress(serial.Uint32ToBytes(2891346854))
 	}
 	this.Destination = v2net.TCPDestination(rawConfig.Address.Address, rawConfig.Port)
 	return nil