Merge pull request #110 from op3/feat/support-listening-on-ipv6

Support listening on IPv6 addresses
This commit is contained in:
rustmailer
2026-01-13 23:59:02 +08:00
committed by GitHub
3 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ pub type ApiResult<T, E = ApiErrorResponse> = std::result::Result<T, E>;
pub async fn start_http_server() -> BichonResult<()> {
let listener = TcpListener::bind((
SETTINGS.bichon_bind_ip.clone().unwrap_or("0.0.0.0".into()),
SETTINGS.bichon_bind_ip.clone().unwrap_or("::".into()),
SETTINGS.bichon_http_port as u16,
));
+6 -6
View File
@@ -46,16 +46,16 @@ pub struct Settings {
)]
pub bichon_http_port: i32,
/// The IP address that the node binds to, in IPv4 format (e.g., 192.168.1.1).
/// The IP address that the node binds to, in IPv4 or IPv6 format (e.g., 192.168.1.1 or ::1).
#[clap(
long,
env,
default_value = "0.0.0.0",
help = "The IP address that the node binds to, in IPv4 format (e.g., 192.168.1.1). Required in cluster mode.",
default_value = "::",
help = "The IP address that the node binds to, in IPv4 or IPv6 format (e.g., 192.168.1.1 or ::1). Required in cluster mode.",
value_parser = ValueParser::new(|s: &str| {
// Ensure the input is a valid IPv4 address
if s.parse::<std::net::Ipv4Addr>().is_err() {
return Err("The bind IP address must be a valid IPv4 address.".to_string());
// Ensure the input is a valid IPv4 or IPv6 address
if s.parse::<std::net::Ipv4Addr>().is_err() && s.parse::<std::net::Ipv6Addr>().is_err() {
return Err("The bind IP address must be a valid IPv4 or IPv6 address.".to_string());
}
// If the address is valid, return it