udp: add network.only_ipv6 config flag

This commit is contained in:
Joakim Frostegård 2021-11-14 22:07:58 +01:00
parent 4641dd29f2
commit 4b07e007f3
3 changed files with 6 additions and 2 deletions

View file

@ -20,12 +20,10 @@
* uring
* ValidUntil periodic update
* statistics
* ipv6_only
* shared config keys such as poll interval
* mio
* stagger connection cleaning intervals?
* ipv4-mapped addresses
* ipv6_only
* glommio
* consider sending local responses immediately
* consider adding ConnectedScrapeRequest::Scrape(PendingScrapeRequest)

View file

@ -123,6 +123,10 @@ pub fn create_socket(config: &Config) -> ::std::net::UdpSocket {
}
.expect("create socket");
if config.network.only_ipv6 {
socket.set_only_v6(true).expect("socket: set only ipv6");
}
socket.set_reuse_port(true).expect("socket: set reuse port");
socket

View file

@ -38,6 +38,7 @@ impl aquatic_cli_helpers::Config for Config {
pub struct NetworkConfig {
/// Bind to this address
pub address: SocketAddr,
pub only_ipv6: bool,
/// Size of socket recv buffer. Use 0 for OS default.
///
/// This setting can have a big impact on dropped packages. It might
@ -120,6 +121,7 @@ impl Default for NetworkConfig {
fn default() -> Self {
Self {
address: SocketAddr::from(([0, 0, 0, 0], 3000)),
only_ipv6: false,
socket_recv_buffer_size: 4096 * 128,
#[cfg(feature = "with-mio")]
poll_event_capacity: 4096,