implement listen option, rename enable_upnp_port_forwarding to listen_upnp

This commit is contained in:
yggverse 2025-07-10 02:56:45 +03:00
parent a762cb59b6
commit fbc80843c7
3 changed files with 25 additions and 8 deletions

View file

@ -55,12 +55,11 @@ aquatic-crawler --infohash /path/to/info-hash-ipv4.bin\
### Options
``` bash
-d, --debug <DEBUG>
-d, --debug
Print debug output
--infohash <INFOHASH>
Absolute path(s) or URL(s) to import infohashes from the Aquatic tracker binary API
* PR#233 feature ([Wiki](https://github.com/YGGverse/aquatic-crawler/wiki/Aquatic))
--tracker <TRACKER>
@ -95,8 +94,11 @@ aquatic-crawler --infohash /path/to/info-hash-ipv4.bin\
--enable-tcp
Enable TCP connection
--enable-upnp-port-forwarding
Enable UPnP
--listen <LISTEN>
Bind listener on specified `host:port` (`[host]:port` for IPv6)
--listen-upnp
Enable UPnP forwarding
--enable-upload
Enable upload (share bytes received with BitTorrent network)

View file

@ -53,9 +53,13 @@ pub struct Config {
#[arg(long, default_value_t = false)]
pub enable_tcp: bool,
/// Enable UPnP
/// Bind listener on specified `host:port` (`[host]:port` for IPv6)
#[arg(long)]
pub listen: Option<String>,
/// Enable UPnP forwarding
#[arg(long, default_value_t = false)]
pub enable_upnp_port_forwarding: bool,
pub listen_upnp: bool,
/// Enable upload (share bytes received with BitTorrent network)
#[arg(long, default_value_t = false)]

View file

@ -13,11 +13,11 @@ use config::Config;
use index::Index;
use librqbit::{
AddTorrent, AddTorrentOptions, AddTorrentResponse, ByteBufOwned, ConnectionOptions,
PeerConnectionOptions, SessionOptions, TorrentMetaV1Info,
ListenerOptions, PeerConnectionOptions, SessionOptions, TorrentMetaV1Info,
};
use peers::Peers;
use rss::Rss;
use std::{collections::HashSet, num::NonZero, path::PathBuf, time::Duration};
use std::{collections::HashSet, num::NonZero, path::PathBuf, str::FromStr, time::Duration};
use torrent::Torrent;
use trackers::Trackers;
use url::Url;
@ -51,6 +51,17 @@ async fn main() -> Result<()> {
None => PathBuf::new(),
},
SessionOptions {
listen: Some(match config.listen {
Some(l) => ListenerOptions {
listen_addr: std::net::SocketAddr::from_str(&l).unwrap(),
enable_upnp_port_forwarding: config.listen_upnp,
..ListenerOptions::default()
},
None => ListenerOptions {
enable_upnp_port_forwarding: config.listen_upnp,
..ListenerOptions::default()
},
}),
connect: Some(ConnectionOptions {
enable_tcp: config.enable_tcp,
proxy_url: config.proxy_url,