-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: mikemiles-dev <michaelmileusnich@Michaels-MacBook-Air-2.local>
- Loading branch information
1 parent
17a3371
commit 378dc0f
Showing
7 changed files
with
47 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use std::collections::HashMap; | ||
use std::io; | ||
use tokio::net::UdpSocket; | ||
|
||
use netflow_parser::NetflowParser; | ||
|
||
#[tokio::main] | ||
async fn main() -> io::Result<()> { | ||
let mut parsers: HashMap<String, NetflowParser> = HashMap::new(); | ||
|
||
let sock = UdpSocket::bind("0.0.0.0:9995").await?; | ||
|
||
let mut buf = [0; 65535]; | ||
|
||
loop { | ||
let (len, addr) = sock.recv_from(&mut buf).await?; | ||
|
||
let data = buf[..len].to_vec(); | ||
let data = data.as_slice(); | ||
|
||
let result = match parsers.get_mut(&addr.to_string()) { | ||
Some(parser) => parser.parse_bytes(data), | ||
None => { | ||
let mut new_parser = NetflowParser::default(); | ||
let result = new_parser.parse_bytes(data); | ||
parsers.insert(addr.to_string(), new_parser); | ||
result | ||
} | ||
}; | ||
println!("{:?}", result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters