1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-04 08:15:21 -05:00

Add Port as a type

This commit is contained in:
V2Ray
2015-12-02 12:47:54 +01:00
parent e8e6cf1429
commit cee85bdf26
16 changed files with 125 additions and 98 deletions

23
common/net/port.go Normal file
View File

@@ -0,0 +1,23 @@
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))
}