1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-12 15:27:16 -05:00
v2fly/common/net/port.go

24 lines
355 B
Go
Raw Normal View History

2015-12-02 06:47:54 -05:00
package net
import (
"strconv"
)
type Port uint16
2015-12-02 15:44:01 -05:00
func PortFromBytes(port []byte) Port {
return Port(uint16(port[0])<<8 + uint16(port[1]))
2015-12-02 06:47:54 -05:00
}
func (this Port) Value() uint16 {
return uint16(this)
}
func (this Port) Bytes() []byte {
return []byte{byte(this >> 8), byte(this)}
}
func (this Port) String() string {
return strconv.Itoa(int(this))
}