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

View file

@ -53,9 +53,13 @@ pub struct Config {
#[arg(long, default_value_t = false)] #[arg(long, default_value_t = false)]
pub enable_tcp: bool, 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)] #[arg(long, default_value_t = false)]
pub enable_upnp_port_forwarding: bool, pub listen_upnp: bool,
/// Enable upload (share bytes received with BitTorrent network) /// Enable upload (share bytes received with BitTorrent network)
#[arg(long, default_value_t = false)] #[arg(long, default_value_t = false)]

View file

@ -13,11 +13,11 @@ use config::Config;
use index::Index; use index::Index;
use librqbit::{ use librqbit::{
AddTorrent, AddTorrentOptions, AddTorrentResponse, ByteBufOwned, ConnectionOptions, AddTorrent, AddTorrentOptions, AddTorrentResponse, ByteBufOwned, ConnectionOptions,
PeerConnectionOptions, SessionOptions, TorrentMetaV1Info, ListenerOptions, PeerConnectionOptions, SessionOptions, TorrentMetaV1Info,
}; };
use peers::Peers; use peers::Peers;
use rss::Rss; 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 torrent::Torrent;
use trackers::Trackers; use trackers::Trackers;
use url::Url; use url::Url;
@ -51,6 +51,17 @@ async fn main() -> Result<()> {
None => PathBuf::new(), None => PathBuf::new(),
}, },
SessionOptions { 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 { connect: Some(ConnectionOptions {
enable_tcp: config.enable_tcp, enable_tcp: config.enable_tcp,
proxy_url: config.proxy_url, proxy_url: config.proxy_url,