Skip to content

Commit

Permalink
add option to change scanner port
Browse files Browse the repository at this point in the history
  • Loading branch information
Shrecknt committed Feb 22, 2024
1 parent 4786154 commit 7e8573e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ nano Snowstorm.toml # modify Snowstorm.toml to your liking
cd web
npm run build
cd ..
iptables -A INPUT -p tcp --dport 61000 -j DROP # prevent os from closing the connections
cargo r -r --bin snowstorm
```
1 change: 1 addition & 0 deletions Snowstorm.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ secret = "some random key"
[scanner]
enabled = true
interface_name = "eth0"
source_port = 61000
task_size_sanity_limit = 1000000
mode_duration = 300
push_to_db = true
Expand Down
7 changes: 6 additions & 1 deletion crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ pub struct ScannerConfig {
#[default = false]
pub enabled: bool,
pub interface_name: String,
#[serde(default = "default_source_port")]
pub source_port: u16,
pub task_size_sanity_limit: u64,
pub mode_duration: u64,
#[serde(default = "_true")]
Expand Down Expand Up @@ -113,6 +115,9 @@ pub struct OauthForgejoConfig {
pub user_api_uri: String,
}

fn _true() -> bool {
const fn _true() -> bool {
true
}
const fn default_source_port() -> u16 {
61000
}
2 changes: 1 addition & 1 deletion crates/io/src/pnet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl PnetScanner {
state: Arc<Mutex<ScannerState>>,
sender: Sender<(PingResult, Vec<PlayerInfo>)>,
) -> Self {
let source_port = SourcePort::Number(61000);
let source_port = SourcePort::Number(config::get().scanner.source_port);
let socket = StatelessTcp::new(source_port);
let syn_writer = socket.write.clone();
tokio::spawn(async move { receive::start_server(socket, sender).await });
Expand Down

0 comments on commit 7e8573e

Please sign in to comment.