remove Port.Bytes()

pull/1366/head
Darien Raymond 2018-11-02 15:14:34 +01:00
parent 58e2ed3381
commit ee489c95b3
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
3 changed files with 4 additions and 7 deletions

View File

@ -39,11 +39,6 @@ func (p Port) Value() uint16 {
return uint16(p)
}
// Bytes returns the correspoding bytes of a Port, in big endian order.
func (p Port) Bytes(b []byte) []byte {
return serial.Uint16ToBytes(p.Value(), b)
}
// String returns the string presentation of a Port.
func (p Port) String() string {
return serial.Uint16ToString(p.Value())

View File

@ -7,6 +7,7 @@ import (
"v2ray.com/core/common/buf"
"v2ray.com/core/common/net"
"v2ray.com/core/common/task"
"v2ray.com/core/common/vio"
)
type AddressOption func(*AddressParser)
@ -166,7 +167,7 @@ func (p *AddressParser) ReadAddressPort(buffer *buf.Buffer, input io.Reader) (ne
}
func (p *AddressParser) writePort(writer io.Writer, port net.Port) error {
return common.Error2(writer.Write(port.Bytes(nil)))
return common.Error2(vio.WriteUint16(writer, port.Value()))
}
func (p *AddressParser) writeAddress(writer io.Writer, address net.Address) error {

View File

@ -9,6 +9,7 @@ import (
"v2ray.com/core/common/protocol"
"v2ray.com/core/common/serial"
"v2ray.com/core/common/uuid"
"v2ray.com/core/common/vio"
)
var (
@ -95,7 +96,7 @@ func (f *CommandSwitchAccountFactory) Marshal(command interface{}, writer io.Wri
common.Must2(writer.Write([]byte(hostStr)))
}
common.Must2(writer.Write(cmd.Port.Bytes(nil)))
common.Must2(vio.WriteUint16(writer, cmd.Port.Value()))
idBytes := cmd.ID.Bytes()
common.Must2(writer.Write(idBytes))