HomePhabricator

Normalize remote IP addresses when writing to logs, etc

Description

Normalize remote IP addresses when writing to logs, etc

Summary:
Ref T11939. IPv4 addresses can normally only be written in one way, but IPv6 addresses have several formats.

For example, the addresses "FFF::", "FfF::", "fff::", "0ffF::", "0fFf:0::", and "0FfF:0:0:0:0:0:0:0" are all the same address.

Normalize all addresses before writing them to logs, etc, so we store the most-preferred form ("fff::", above).

Test Plan:
Ran an SSH clone over IPv6:

$ git fetch ssh://local@::1/diffusion/26/locktopia.git

It worked; verified that address read out of SSH_CLIENT sensibly.

Faked my remote address as a non-preferred-form IPv6 address using preamble.php.

Failed to login, verified that the preferred-form version of the address appeared in the user activity log.

Made IPv6 requests over HTTP:

$ curl -H "Host: local.phacility.com" "http://[::1]/"

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11939

Differential Revision: https://secure.phabricator.com/D16987

Details

Provenance
epriestleyAuthored on Dec 5 2016, 6:25 PM
epriestleyPushed on Dec 5 2016, 7:20 PM
Reviewer
chad
Differential Revision
D16987: Normalize remote IP addresses when writing to logs, etc
Parents
rP5a060b34df81: Add IPv6 reserved addresses to the default outbound blacklist
Branches
Unknown
Tags
Unknown
Tasks
T11939: IPv6 Support
Build Status
Buildable 14758
Build 19290: Run Core Tests