mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-18 07:17:32 -05:00
24 lines
322 B
Go
24 lines
322 B
Go
|
package net
|
||
|
|
||
|
import (
|
||
|
"strconv"
|
||
|
)
|
||
|
|
||
|
type Port uint16
|
||
|
|
||
|
func NewPort(port int) Port {
|
||
|
return Port(uint16(port))
|
||
|
}
|
||
|
|
||
|
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))
|
||
|
}
|