Skip to content

Commit

Permalink
Create IPv4 address by calling net.IPv4
Browse files Browse the repository at this point in the history
  • Loading branch information
cyfdecyf committed Dec 27, 2012
1 parent ab4a49a commit 8c7663c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions cmd/shadowsocks-local/local.go
Expand Up @@ -122,8 +122,7 @@ func getRequest(conn net.Conn) (rawaddr []byte, host string, err error) {
if buf[idType] == typeDm {
host = string(buf[idDm0 : idDm0+buf[idDmLen]])
} else if buf[idType] == typeIP {
addrIp := make(net.IP, 4)
copy(addrIp, buf[idIP0:idIP0+4])
addrIp := net.IPv4(buf[idIP0], buf[idIP0+1], buf[idIP0+2], buf[idIP0+3])
host = addrIp.String()
}
port := binary.BigEndian.Uint16(buf[reqLen-2 : reqLen])
Expand Down
3 changes: 1 addition & 2 deletions cmd/shadowsocks-server/server.go
Expand Up @@ -70,8 +70,7 @@ func getRequest(conn *ss.Conn) (host string, extra []byte, err error) {
if buf[idType] == typeDm {
host = string(buf[idDm0 : idDm0+buf[idDmLen]])
} else if buf[idType] == typeIP {
addrIp := make(net.IP, 4)
copy(addrIp, buf[idIP0:idIP0+4])
addrIp := net.IPv4(buf[idIP0], buf[idIP0+1], buf[idIP0+2], buf[idIP0+3])
host = addrIp.String()
}
// parse port
Expand Down

0 comments on commit 8c7663c

Please sign in to comment.