You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
v2ray-core/common/net/port.go

24 lines
415 B

package net
import (
9 years ago
"github.com/v2ray/v2ray-core/common/serial"
)
9 years ago
type Port serial.Uint16Literal
func PortFromBytes(port []byte) Port {
return Port(uint16(port[0])<<8 + uint16(port[1]))
}
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 {
9 years ago
return serial.Uint16Literal(this).String()
}