1
0
Fork 0
forked from External/ergo

fix PROXY protocol support for IPv6

1. Handle PROXY lines with IPv6 addresses starting with ::
(similar to WEBIRC in issue #211)

2. Strip v6 mapping from v4 addresses when handling proxied IPs.
This commit is contained in:
Shivaram Lingamneni 2018-09-03 00:19:10 -04:00
parent f0491c2254
commit 10d4f77638
5 changed files with 68 additions and 39 deletions

View file

@ -246,6 +246,8 @@ func (client *Client) run() {
// (may be overridden by a later PROXY command from stunnel)
client.rawHostname = utils.AddrLookupHostname(client.socket.conn.RemoteAddr())
firstLine := true
for {
maxlenTags, maxlenRest := client.recomputeMaxlens()
@ -259,7 +261,20 @@ func (client *Client) run() {
break
}
client.server.logger.Debug("userinput ", client.nick, "<- ", line)
client.server.logger.Debug("userinput", client.nick, "<- ", line)
// special-cased handling of PROXY protocol, see `handleProxyCommand` for details:
if firstLine {
firstLine = false
if strings.HasPrefix(line, "PROXY") {
err = handleProxyCommand(client.server, client, line)
if err != nil {
break
} else {
continue
}
}
}
msg, err = ircmsg.ParseLineMaxLen(line, maxlenTags, maxlenRest)
if err == ircmsg.ErrorLineIsEmpty {