mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 02:35:31 +00:00
udp: open one socket each for IPv4 and IPv6 (#220)
* tmp work on udp double sockets * WIP: udp: open two sockets (one for ipv4, one for ipv6) io_uring not ported yet * udp: open one socket each for IPv4 and IPv6 Config file now has one setting for each * file transfer ci: fix udp network.address_ipv4
This commit is contained in:
parent
192b22fcdd
commit
048c297fc7
19 changed files with 863 additions and 525 deletions
|
|
@ -25,14 +25,26 @@ pub const APP_VERSION: &str = env!("CARGO_PKG_VERSION");
|
|||
pub fn run(mut config: Config) -> ::anyhow::Result<()> {
|
||||
let mut signals = Signals::new([SIGUSR1])?;
|
||||
|
||||
if !(config.network.use_ipv4 || config.network.use_ipv6) {
|
||||
return Result::Err(anyhow::anyhow!(
|
||||
"Both use_ipv4 and use_ipv6 can not be set to false"
|
||||
));
|
||||
}
|
||||
|
||||
if config.socket_workers == 0 {
|
||||
config.socket_workers = available_parallelism().map(Into::into).unwrap_or(1);
|
||||
};
|
||||
|
||||
let num_sockets_per_worker =
|
||||
if config.network.use_ipv4 { 1 } else { 0 } + if config.network.use_ipv6 { 1 } else { 0 };
|
||||
|
||||
let state = State::default();
|
||||
let statistics = Statistics::new(&config);
|
||||
let connection_validator = ConnectionValidator::new(&config)?;
|
||||
let priv_dropper = PrivilegeDropper::new(config.privileges.clone(), config.socket_workers);
|
||||
let priv_dropper = PrivilegeDropper::new(
|
||||
config.privileges.clone(),
|
||||
config.socket_workers * num_sockets_per_worker,
|
||||
);
|
||||
let (statistics_sender, statistics_receiver) = unbounded();
|
||||
|
||||
update_access_list(&config.access_list, &state.access_list)?;
|
||||
|
|
@ -44,10 +56,15 @@ pub fn run(mut config: Config) -> ::anyhow::Result<()> {
|
|||
let state = state.clone();
|
||||
let config = config.clone();
|
||||
let connection_validator = connection_validator.clone();
|
||||
let priv_dropper = priv_dropper.clone();
|
||||
let statistics = statistics.socket[i].clone();
|
||||
let statistics_sender = statistics_sender.clone();
|
||||
|
||||
let mut priv_droppers = Vec::new();
|
||||
|
||||
for _ in 0..num_sockets_per_worker {
|
||||
priv_droppers.push(priv_dropper.clone());
|
||||
}
|
||||
|
||||
let handle = Builder::new()
|
||||
.name(format!("socket-{:02}", i + 1))
|
||||
.spawn(move || {
|
||||
|
|
@ -57,7 +74,7 @@ pub fn run(mut config: Config) -> ::anyhow::Result<()> {
|
|||
statistics,
|
||||
statistics_sender,
|
||||
connection_validator,
|
||||
priv_dropper,
|
||||
priv_droppers,
|
||||
)
|
||||
})
|
||||
.with_context(|| "spawn socket worker")?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue