FAQ
Reviewers: golang-dev_googlegroups.com,

Message:
Hello golang-dev@googlegroups.com,

I'd like you to review this change to
https://code.google.com/p/go.net


Description:
go.net/proxy: correctly sets IPv4 addresses in socks5 request now

net.ParseIP(host) always returns a 16-byte array, we should convert
it into 4-byte array before copy it to the IP field if it is a IPv4
address.

Please review this at https://codereview.appspot.com/6922050/

Affected files:
M proxy/socks5.go


Index: proxy/socks5.go
===================================================================
--- a/proxy/socks5.go
+++ b/proxy/socks5.go
@@ -142,12 +142,13 @@
buf = append(buf, socks5Version, socks5Connect, 0 /* reserved */)

if ip := net.ParseIP(host); ip != nil {
- if ip.To4() != nil {
+ if ipv4 := ip.To4(); ipv4 != nil {
buf = append(buf, socks5IP4)
+ buf = append(buf, []byte(ipv4)...)
} else {
buf = append(buf, socks5IP6)
+ buf = append(buf, []byte(ip)...)
}
- buf = append(buf, []byte(ip)...)
} else {
buf = append(buf, socks5Domain)
buf = append(buf, byte(len(host)))

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 3 | next ›
Discussion Overview
groupgolang-dev @
categoriesgo
postedDec 12, '12 at 2:06p
activeDec 12, '12 at 7:34p
posts3
users2
websitegolang.org

2 users in discussion

Raptium: 2 posts Rsc: 1 post

People

Translate

site design / logo © 2022 Grokbase