Skip to content

Commit

Permalink
Use binary.BigEndian to generate port in rawAddr.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyfdecyf committed Dec 27, 2012
1 parent efec84e commit ab4a49a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions shadowsocks/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package shadowsocks

import (
"errors"
"encoding/binary"
"fmt"
"net"
"strconv"
Expand Down Expand Up @@ -36,8 +37,7 @@ func rawAddr(addr string) (buf []byte, err error) {
buf[0] = 3 // 3 means the address is domain name
buf[1] = byte(hostLen) // host address length followed by host address
copy(buf[2:], host)
buf[2+hostLen] = byte(port >> 8 & 0xFF) // the next 2 bytes are port
buf[2+hostLen+1] = byte(port) & 0xFF
binary.BigEndian.PutUint16(buf[2+hostLen:2+hostLen+2], uint16(port))
return
}

Expand Down

0 comments on commit ab4a49a

Please sign in to comment.