mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 02:35:31 +00:00
aquatic_ws: add setting Config.ipv6_only
This commit is contained in:
parent
416d61a2b2
commit
d4bcc14c82
4 changed files with 15 additions and 4 deletions
|
|
@ -143,6 +143,7 @@ socket_workers = 1
|
||||||
|
|
||||||
[network]
|
[network]
|
||||||
address = '0.0.0.0:3000'
|
address = '0.0.0.0:3000'
|
||||||
|
ipv6_only = false
|
||||||
use_tls = false
|
use_tls = false
|
||||||
tls_pkcs12_path = ''
|
tls_pkcs12_path = ''
|
||||||
tls_pkcs12_password = ''
|
tls_pkcs12_password = ''
|
||||||
|
|
@ -151,6 +152,8 @@ max_offers = 10
|
||||||
peer_announce_interval = 120
|
peer_announce_interval = 120
|
||||||
poll_event_capacity = 4096
|
poll_event_capacity = 4096
|
||||||
poll_timeout_milliseconds = 50
|
poll_timeout_milliseconds = 50
|
||||||
|
websocket_max_message_size = 65536
|
||||||
|
websocket_max_frame_size = 16384
|
||||||
|
|
||||||
[handlers]
|
[handlers]
|
||||||
max_requests_per_iter = 10000
|
max_requests_per_iter = 10000
|
||||||
|
|
|
||||||
2
TODO.md
2
TODO.md
|
|
@ -3,7 +3,7 @@
|
||||||
## aquatic_ws
|
## aquatic_ws
|
||||||
* network
|
* network
|
||||||
* send/recv buffer size config
|
* send/recv buffer size config
|
||||||
* ipv6_only setting
|
* tcp backlog setting
|
||||||
* is it even necessary to check if event is readable in poll, since that
|
* is it even necessary to check if event is readable in poll, since that
|
||||||
is all we're listening for?
|
is all we're listening for?
|
||||||
* panic/error in workers: print error, exit program with non-zero exit code
|
* panic/error in workers: print error, exit program with non-zero exit code
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ pub struct Config {
|
||||||
pub struct NetworkConfig {
|
pub struct NetworkConfig {
|
||||||
/// Bind to this address
|
/// Bind to this address
|
||||||
pub address: SocketAddr,
|
pub address: SocketAddr,
|
||||||
|
pub ipv6_only: bool,
|
||||||
pub use_tls: bool,
|
pub use_tls: bool,
|
||||||
pub tls_pkcs12_path: String,
|
pub tls_pkcs12_path: String,
|
||||||
pub tls_pkcs12_password: String,
|
pub tls_pkcs12_password: String,
|
||||||
|
|
@ -90,6 +91,7 @@ impl Default for NetworkConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
address: SocketAddr::from(([0, 0, 0, 0], 3000)),
|
address: SocketAddr::from(([0, 0, 0, 0], 3000)),
|
||||||
|
ipv6_only: false,
|
||||||
use_tls: false,
|
use_tls: false,
|
||||||
tls_pkcs12_path: "".into(),
|
tls_pkcs12_path: "".into(),
|
||||||
tls_pkcs12_password: "".into(),
|
tls_pkcs12_password: "".into(),
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
|
use anyhow::Context;
|
||||||
use mio::Token;
|
use mio::Token;
|
||||||
use net2::{TcpBuilder, unix::UnixTcpBuilderExt};
|
use net2::{TcpBuilder, unix::UnixTcpBuilderExt};
|
||||||
|
|
||||||
|
|
@ -11,14 +12,19 @@ use super::connection::*;
|
||||||
pub fn create_listener(
|
pub fn create_listener(
|
||||||
config: &Config
|
config: &Config
|
||||||
) -> ::anyhow::Result<::std::net::TcpListener> {
|
) -> ::anyhow::Result<::std::net::TcpListener> {
|
||||||
let builder = if config.network.address.is_ipv4(){
|
let mut builder = &if config.network.address.is_ipv4(){
|
||||||
TcpBuilder::new_v4()
|
TcpBuilder::new_v4()
|
||||||
} else {
|
} else {
|
||||||
TcpBuilder::new_v6()
|
TcpBuilder::new_v6()
|
||||||
}?;
|
}?;
|
||||||
|
|
||||||
let builder = builder.reuse_port(true)?;
|
if config.network.ipv6_only {
|
||||||
let builder = builder.bind(&config.network.address)?;
|
builder = builder.only_v6(true)
|
||||||
|
.context("Failed setting ipv6_only to true")?
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = builder.reuse_port(true)?;
|
||||||
|
builder = builder.bind(&config.network.address)?;
|
||||||
|
|
||||||
let listener = builder.listen(128)?;
|
let listener = builder.listen(128)?;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue