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

Feature, hide dns queries by default #161

Merged
merged 3 commits into from
Apr 5, 2020

Conversation

olehs0
Copy link
Contributor

@olehs0 olehs0 commented Apr 2, 2020

Fixes #153 .
Provide ability to switch shown DNS queries by default, additionally with CLI flag to manage it. Now you can track only needed incoming requests.

@olehs0 olehs0 changed the title Feature/hide dns queries by default Feature, hide dns queries by default Apr 2, 2020
Copy link
Owner

@imsnif imsnif left a comment

Choose a reason for hiding this comment

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

Hey @olehs0 - great work! Thank you for keeping at it and giving your time for this feature. :)

I left just a few comments in the code. Other than that, can we add a test for this? Something like "pass the flag, send some DNS queries, see that they do not appear"? You can see examples in the other tests.

return None;
}
}

Copy link
Owner

Choose a reason for hiding this comment

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

I think it would be more accurate to do this after creating the connection... something like:

         if !show_dns {                                                                                                                                                                                                                     
             if connection.remote_socket.port == 53 {
                 return None;
             }
         }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @imsnif! Thank you, yeah, sure, i just was going to add a tests for this. This PR should be work in progress yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@imsnif Good afternoon, could you please check my pr?

src/main.rs Outdated
@@ -115,6 +118,7 @@ where
{
let running = Arc::new(AtomicBool::new(true));
let paused = Arc::new(AtomicBool::new(false));
let dns_shown = Arc::new(AtomicBool::new(opts.render_opts.show_dns));
Copy link
Owner

Choose a reason for hiding this comment

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

Why does this need to be an Arc<AtomicBool> - do you think we can make it a normal boolean and then pass it around without cloning or anything? Seems easier to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just thought that we could switch between show_dns modes via some key. But, yeah, i will replace it, or maybe should I add switching functionality to it?

@olehs0 olehs0 changed the title Feature, hide dns queries by default WIP: Feature, hide dns queries by default Apr 4, 2020
@olehs0 olehs0 changed the title WIP: Feature, hide dns queries by default Feature, hide dns queries by default Apr 5, 2020
Copy link
Owner

@imsnif imsnif left a comment

Choose a reason for hiding this comment

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

Nice work! Just one small change and we can merge this.

fn handle_v4(
ip_packet: Ipv4Packet,
network_interface: &NetworkInterface,
show_dns: bool,
Copy link
Owner

Choose a reason for hiding this comment

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

Hmm... can't we use self.dns_shown inside this function instead of passing show_dns to it?

Copy link
Owner

Choose a reason for hiding this comment

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

You're right. I'm not sure why we implemented it like that shrugs nevermind. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@imsnif ok, so, we keep at as it is, or should i try to modify it and passing self parameter ?

54321,
53,
b"I am a fake DNS query packet",
)),
Copy link
Owner

Choose a reason for hiding this comment

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

Nice! This way all the other tests test this feature as well, because they should not show this packet.

@imsnif
Copy link
Owner

imsnif commented Apr 5, 2020

Thank you very much for this @olehs0. Solid work. I hope to see more contributions from you in the future.

@imsnif imsnif merged commit 11da099 into imsnif:master Apr 5, 2020
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.

2 participants