-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat(network scan): A working scanner with ping, port discovery, broadcast, and netbios #683
Conversation
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 work!
Let me know if smaller PR would be preferable
It would indeed be very much welcomed as smaller PRs. Probably it’s too much work for you to change that now so we can try to handle this the way it is now. I’ll not go through every change though.
1. uses DashMap to imporve the preformance of event loop
Did you perform any form of benchmarking before making this move?
I would be interested in seeing some numbers before we add this dependency.
(Following on the above: this alone could be a dedicated PR.)
I’ll continue reviewing tomorrow.
rm bench marks remove clone functions remove unnessary Ok!() macro
4e6f34d
to
a227487
Compare
I'll try give a benchmark, but notably,even if the performance is slightly worse, the logic is much more strightforward and now lock-free. Plus, it gives our the potential ability to implement method like |
futures = "0.3.30" | ||
parking_lot = "0.12.1" | ||
polling = { git = "https://github.com/smol-rs/polling", rev = "62430fd56e668559d08ca7071ab13a0e116ba515" } | ||
polling = { git = "https://github.com/irvingoujAtDevolution/polling.git", branch = "fix-linux-tcp-fail" } |
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.
Wasn't aware the problem of Linux side until CI reported the error. :( , this is actually a hard one to fix.
This is currently necessary for linux TCP to work, see line 237 for reason in socket.rs.
I will try convince the repo owner of Polling to merge it, otherwise let's use a branch on our own repo for now.
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.
Can you link to the issue / pull request you created on their side?
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.
the problem on polling is that they are trying to have a platform indepent interface for all polling mechanisms, so I guess they would particularly against have something like this. I have a better idea in mind to how to implement this so it is more acceptable for both us and them, I'll put on a update shortly.
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.
A PR on polling smol-rs/polling#189
@@ -40,7 +41,7 @@ impl Drop for Socket2Runtime { | |||
} | |||
} | |||
|
|||
const QUEUE_CAPACITY: usize = 1024; | |||
const QUEUE_CAPACITY: usize = 8024; |
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.
Maybe too big?
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.
Any reason why you changed? It wasn’t big enough?
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.
yes, it was causing errors on registering the events.
return std::task::Poll::Ready(Ok(())); | ||
// This is a special case, this happens when using epoll to wait for a unconnected TCP socket. | ||
// We clearly needs to call connect function, so we break the loop and call connect. | ||
#[cfg(target_os = "linux")] |
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.
Linux and Windows have different behavior, Linux shots event to you even before you call connect, we need to identify if the event is "Connect failed" or "Connect successful" or something else (out and hup). Polling does not expose plateform dependent args, so we have to make a banch specific to our needs here. Will disguss with Polling's owner later.
@@ -15,7 +15,6 @@ use tokio::{ | |||
use crate::socket::AsyncRawSocket; | |||
|
|||
#[tokio::test(flavor = "multi_thread", worker_threads = 4)] | |||
#[ignore = "TODO"] | |||
async fn multiple_udp() -> anyhow::Result<()> { |
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.
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!!
pub(crate) handles_sender: HandlesSender, | ||
} | ||
|
||
impl TaskExecutionContext { |
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.
This is created purely for the sake of readability, it was super hard of keep track of things without it.
Co-authored-by: Benoît Cortier <[email protected]>
…ions-gateway into Network-Scan-Scanner
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.
We need to clean up the dependencies before we merge. Incidentally, the dependency on futures
is unrequired not only for network-scanner
but also for network-scanner-net
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.
There is also a conflict to fix with master, but otherwise I’m thinking about merging today
updated, removed all unsued dependencies |
updated, thank you! |
polling = { git = "https://github.com/devolutions/polling.git", branch = "fix-detect-connection-fail" } | ||
polling = { git = "https://github.com/devolutions/polling.git", rev = "c04e8ee40415cad551fe044457270f4a2d7c491d" } |
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.
Let’s hardcode the commit rather than the branch
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.
Let’s merge. Thank you for this work!
In the future, try to send single-purpose PRs, please.
It’s okay even if the PR is very small, it’ll be quick to review.
This PR contains code necessary for new functionalities, changes,improvement and refactoring of the network scan crates. Please see network-scan/examples for usages.
@CBenoit Let me know if smaller PR would be preferable, The main changes include