Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve IPv4 and IPv6 address handling #104

Merged
merged 4 commits into from
Jul 19, 2023

Conversation

tomeon
Copy link
Collaborator

@tomeon tomeon commented Apr 9, 2022

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 tomeon force-pushed the improve-ip-expansion-and-validation branch 3 times, most recently from b5d0bad to 01ddf0f Compare April 9, 2022 20:13
update-systemd-resolved Outdated Show resolved Hide resolved
@tomeon tomeon force-pushed the improve-ip-expansion-and-validation branch 2 times, most recently from 9506ce7 to 834b3bf Compare May 13, 2022 15:42
@tomeon tomeon marked this pull request as ready for review May 13, 2022 16:03
@tomeon tomeon force-pushed the improve-ip-expansion-and-validation branch from 834b3bf to 451e782 Compare June 22, 2022 12:02
@tomeon tomeon force-pushed the improve-ip-expansion-and-validation branch from 1dcf2be to 838fd3d Compare July 18, 2023 22:24
@tomeon tomeon self-assigned this Jul 18, 2023
@tomeon tomeon force-pushed the improve-ip-expansion-and-validation branch 2 times, most recently from ee733d6 to 1e8c18f Compare July 19, 2023 01:38
@tomeon tomeon linked an issue Jul 19, 2023 that may be closed by this pull request
@tomeon tomeon force-pushed the improve-ip-expansion-and-validation branch from aa75e00 to 147f375 Compare July 19, 2023 13:14
by:

    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.
@tomeon tomeon force-pushed the improve-ip-expansion-and-validation branch from 147f375 to 79e91f4 Compare July 19, 2023 13:50
and Bash >= 4.3 requirement in the changelog.
@tomeon tomeon force-pushed the improve-ip-expansion-and-validation branch from 79e91f4 to 8c5bd54 Compare July 19, 2023 13:54
@tomeon tomeon merged commit a6ce2a1 into jonathanio:master Jul 19, 2023
3 checks passed
@tomeon tomeon deleted the improve-ip-expansion-and-validation branch July 19, 2023 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error if IPv6 address is valid but didn't match recommendation
1 participant