-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
Local private networks should be automatically considered proxies and skipped for metadata lookup. Closes #51
channelserver/src/main.rs
Outdated
match fixed.parse::<ipnet::IpNet>() { | ||
Ok(addr) => trusted_list.push(addr), | ||
Err(err) => { | ||
error!(logger.log, "Ignoring unparsable IP address \"{}\"", proxy); |
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.
nit: don't forget raw strings
error!(logger.log, "Ignoring unparsable IP address \"{}\"", proxy); | |
error!(logger.log, r#"Ignoring unparsable IP address "{}""#, proxy); |
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.
honestly, I do. Frequently. Thanks!
channelserver/src/meta.rs
Outdated
@@ -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> { |
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.
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))
)
channelserver/src/meta.rs
Outdated
@@ -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 |
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.
did I read this comment wrong or is it describing the opposite of what's happening?
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.
Sigh, no, you read it right. It's wrong. Thanks!
Local private networks should be automatically considered proxies and
skipped for metadata lookup.
Closes #51