Skip to content

bug: Handle private networks as trusted proxies #53

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

Merged
merged 2 commits into from
Nov 7, 2018
Merged

bug: Handle private networks as trusted proxies #53

merged 2 commits into from
Nov 7, 2018

Conversation

jrconlin
Copy link
Member

@jrconlin jrconlin commented Nov 6, 2018

Local private networks should be automatically considered proxies and
skipped for metadata lookup.

Closes #51

Local private networks should be automatically considered proxies and
skipped for metadata lookup.

Closes #51
match fixed.parse::<ipnet::IpNet>() {
Ok(addr) => trusted_list.push(addr),
Err(err) => {
error!(logger.log, "Ignoring unparsable IP address \"{}\"", proxy);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: don't forget raw strings

Suggested change
error!(logger.log, "Ignoring unparsable IP address \"{}\"", proxy);
error!(logger.log, r#"Ignoring unparsable IP address "{}""#, proxy);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

honestly, I do. Frequently. Thanks!

@@ -127,14 +127,10 @@ fn get_ua(
None
}

fn is_trusted_proxy(proxy_list: &[IpNet], host: &str) -> Result<bool, HandlerError> {
fn is_trusted_proxy(proxy_list: &[IpNet], host: &IpAddr) -> Result<bool, HandlerError> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for a Result now, this can just return a bool (this could also be a one liner: proxy_list.iter().any(|range| range.contains(host)))

@@ -127,14 +127,10 @@ fn get_ua(
None
}

fn is_trusted_proxy(proxy_list: &[IpNet], host: &str) -> Result<bool, HandlerError> {
fn is_trusted_proxy(proxy_list: &[IpNet], host: &IpAddr) -> Result<bool, HandlerError> {
// Return if an address is NOT part of the allow list
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did I read this comment wrong or is it describing the opposite of what's happening?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sigh, no, you read it right. It's wrong. Thanks!

@jrconlin jrconlin merged commit 2566d6b into master Nov 7, 2018
@jrconlin jrconlin deleted the bug/51 branch November 7, 2018 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants