aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorEdward Wang <[email protected]>2024-06-14 17:16:17 -0700
committerMatthew (mbg) <[email protected]>2024-06-21 09:54:09 -0700
commit9500e628553edf971bd555c09ccc83308cef60f9 (patch)
treec19e6662a8f7de1dfea82de87ba8f3989b314fe4
parent899d86c5d48deb2a01c66e431726e1fda030f48d (diff)
downloadpingora-9500e628553edf971bd555c09ccc83308cef60f9.tar.gz
pingora-9500e628553edf971bd555c09ccc83308cef60f9.zip
Make ipv6_only flag an Option<bool>
Fixes #279. This allows falling back to the system default on None, or explicitly setting false if the system default happens to be true.
-rw-r--r--.bleep2
-rw-r--r--pingora-core/src/listeners/l4.rs8
2 files changed, 5 insertions, 5 deletions
diff --git a/.bleep b/.bleep
index c2ad58a..ff01eba 100644
--- a/.bleep
+++ b/.bleep
@@ -1 +1 @@
-50e4cca6db37ad41adb4a8a46445651e28a69fb4 \ No newline at end of file
+afbee799f578048eb9f05afc0abc259ba1d0f40a \ No newline at end of file
diff --git a/pingora-core/src/listeners/l4.rs b/pingora-core/src/listeners/l4.rs
index 406190e..42adc87 100644
--- a/pingora-core/src/listeners/l4.rs
+++ b/pingora-core/src/listeners/l4.rs
@@ -69,7 +69,7 @@ pub struct TcpSocketOptions {
/// IPV6_V6ONLY flag (if true, limit socket to IPv6 communication only).
/// This is mostly useful when binding to `[::]`, which on most Unix distributions
/// will bind to both IPv4 and IPv6 addresses by default.
- pub ipv6_only: bool,
+ pub ipv6_only: Option<bool>,
/// Enable TCP fast open and set the backlog size of it.
/// See the [man page](https://man7.org/linux/man-pages/man7/tcp.7.html) for more information.
pub tcp_fastopen: Option<usize>,
@@ -140,10 +140,10 @@ fn apply_tcp_socket_options(sock: &TcpSocket, opt: Option<&TcpSocketOptions>) ->
let Some(opt) = opt else {
return Ok(());
};
- if opt.ipv6_only {
+ if let Some(ipv6_only) = opt.ipv6_only {
let socket_ref = socket2::SockRef::from(sock);
socket_ref
- .set_only_v6(opt.ipv6_only)
+ .set_only_v6(ipv6_only)
.or_err(BindError, "failed to set IPV6_V6ONLY")?;
}
@@ -318,7 +318,7 @@ mod test {
#[tokio::test]
async fn test_listen_tcp_ipv6_only() {
let sock_opt = Some(TcpSocketOptions {
- ipv6_only: true,
+ ipv6_only: Some(true),
..Default::default()
});
let mut listener = ListenerEndpoint::new(ServerAddress::Tcp("[::]:7101".into(), sock_opt));