-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
Add exclude private URLs feature #7
Conversation
I quite honestly don't know why the build is failing. The tests run on my local machine just fine (Rust 1.47.0, Linux, x86_64). |
The CLI options parser generated weird flag names for this:
Any preferences as what to should the flags be? I have a proposal:
What do you think? |
I was able to work out that it uses Rust 1.46.0, as included in I have installed Rust 1.46.0 locally using rustup, and re-ran the tests, and they did fail indeed, with the same message. Then I installed Rust 1.45.2 and re-ran the tests for So, it's likely a problem with Rust 1.46.0... Some compiler bug perhaps? I found this one: rust-lang/rust#54540 PS: For reference, here's how to install toolchains:
|
For the record: adding #![type_length_limit = "7912782"] At the very top of |
@xiaochuanyu found a fix in #6. As you guessed, it's likely an issue with the 1.46.0 toolchain. Updating to the latest version seems to fix the issue. |
return true; | ||
} | ||
|
||
// Note: in a pathological case, an IPv6 address can be IPv4-mapped |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow. That's both shocking and hilarious. 😆
@@ -285,12 +363,14 @@ mod test { | |||
checker | |||
} | |||
|
|||
fn website_url(s: &str) -> Uri { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
@@ -23,6 +24,17 @@ impl Uri { | |||
Uri::Mail(_address) => None, | |||
} | |||
} | |||
|
|||
pub fn host_ip(&self) -> Option<IpAddr> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nicely done
@pawroman can you reintegrate |
This lets extract the host IP address, if defined for a website. Mail addresses are not supported.
The exclusion is currently based on IP addresses, as specified by inputs. We support IPv4 and IPv6, where possible using the current stable stdlib (as of Rust 1.47.0). Note that we could go one step further and resolve all URIs using DNS and then exclude-filter the private IPs.
This makes the test code shorter and more readable.
6bb9e59
to
c043776
Compare
Thanks for the review. I have rebased against master, good to see that the CI is green now :) Any thoughts on the CLI options? #7 (comment) |
Sounds very reasonable to me. 👍 |
👍 Implemented, along with a test that runs the program against a test file with the flag. This should now be ready to merge. |
Just gave it a spin locally and it does what it says on the can. Great work and thanks for your contribution @pawroman. 😃 |
Currently, the excludes are based purely on IP address ranges and only work for websites (no support for mail addresses). The IPv6 support is implemented, to a degree possible with Rust standard library as of 1.47.0. See commit messages and code comments for more details.
Note: while IP address exclude works, it's possible that some URLs will resolve to link-local, private or loopback addresses. While this is not very likely, it's a possibility. To address this, we'd have to DNS-resolve all URIs and then run them through IP exclude rules. I have skipped this part because of extra effort involved.
Closes #5.