update-systemd-resolved icon indicating copy to clipboard operation
update-systemd-resolved copied to clipboard

Improve IPv4 and IPv6 address handling

Open tomeon opened this issue 2 years ago • 0 comments

Motivation

Atoning for the sins I committed in #3, and addressing #71.

Summary of changes

  1. Farming out address expansion and validation to battle-tested tools, when possible (sipcalc, Python's ipaddress module),
  2. Making native IPv6 expansion and validation handle a wider variety of address representations (not just what is allowed by RFC 5952),
  3. Fixing various bugs in the native IPv6 address expansion routines,
  4. Making the native IP expansion routines log why address expansion failed, when it failed, and
  5. Adding a variety of test cases to show that addresses are expanded properly and that the different expansion implementations (Python, sipcalc, and native) agree with one another.

Caveats and Reservations

Complexity

There is a significant quotient of incidental complexity here, especially around testing for whether Python/ipaddress and/or sipcalc are available. This PR would be half as large if it were limited to just Bash-native address handling.

Maybe any Python stuff should wait for #57?

Differences of opinion

sipcalc does not like addresses in the form ::1:2:3:4:5:6:7 or 1:2:3:4:5:6:7::, whereas Python's ipaddress module likes them just fine. I've made the native expansion routine accept them as well. Not sure what the right call is, but it does seem wrong to me that update-systemd-resolved would accept an address in some system configurations (Python available, or neither Python nor sipcalc available) but not others (Python not available, sipcalc available).

tomeon avatar Apr 09 '22 17:04 tomeon