1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-29 10:45:22 +00:00

Remove Intxx interfaces

This commit is contained in:
v2ray 2016-05-24 22:15:46 +02:00
parent ab39750ceb
commit 444808a51a
4 changed files with 26 additions and 81 deletions

View File

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

View File

@ -12,88 +12,29 @@ func Uint16ToString(value uint16) string {
return strconv.Itoa(int(value))
}
func Uint32ToBytes(value uint32) []byte {
return []byte{
byte(value >> 24),
byte(value >> 16),
byte(value >> 8),
byte(value),
}
}
func IntToBytes(value int) []byte {
return []byte{
byte(value >> 24),
byte(value >> 16),
byte(value >> 8),
byte(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()
return []byte{
byte(value >> 24),
byte(value >> 16),
byte(value >> 8),
byte(value),
}
}
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()
return []byte{
byte(value >> 24),
byte(value >> 16),
byte(value >> 8),
byte(value),
}
}
type Int64Literal int64
func (this Int64Literal) String() string {
return strconv.FormatInt(this.Value(), 10)
}
func (this Int64Literal) Value() int64 {
return int64(this)
}
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)
}

View File

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

View File

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