prawnsalad / KiwiIRC

This is **DEPRECATED**! Please go to https://github.com/kiwiirc/kiwiirc
https://kiwiirc.com
GNU Affero General Public License v3.0
891 stars 277 forks source link

Improve IPv6 support #917

Open ShadowNinja opened 7 years ago

ShadowNinja commented 7 years ago

IPv6 idents are now the first ten characters of the base32 encoded SHA-1 hash of the user's IP. Unlike IPv4 addresses, there is a possibility that there will be collisions (i.e., two IPs that get the same ident). This is unfourtunate, but it is unavoidable given that IRCds typically only allow about ten characters for the username. Fourtunately, the probability of collision is quite small (assuming SHA-1 produces well distributed output, the probability of even an 8-character ident collising is one in 32^8 or about one in a trillion).

This also fixes addresses starting with a colon (e.g., IPv4-mapped IPv6 addresses), unmaps IPv4-mapped IPv6 addresses, and fixes a spot where it was assumed that addresses with a dot were IPv4.

Note: I chose ten characters because a typical IRCd (Charybdis) limits the username to ten characters (or 9 characters if a tilde is added due to identd not being used).