Skip to content

Commit

Permalink
fixed #1189 - update default config to listen on IPv6 as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed Dec 25, 2024
1 parent 010534a commit d51d882
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
14 changes: 5 additions & 9 deletions warpgate-common/src/config/defaults.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::net::ToSocketAddrs;
use std::net::{Ipv6Addr, SocketAddr, ToSocketAddrs};

Check warning on line 1 in warpgate-common/src/config/defaults.rs

View workflow job for this annotation

GitHub Actions / Build (arm64-linux)

unused import: `ToSocketAddrs`

Check warning on line 1 in warpgate-common/src/config/defaults.rs

View workflow job for this annotation

GitHub Actions / Build (arm64-macos)

unused import: `ToSocketAddrs`

Check warning on line 1 in warpgate-common/src/config/defaults.rs

View workflow job for this annotation

GitHub Actions / Build (x86_64-linux)

unused import: `ToSocketAddrs`

Check warning on line 1 in warpgate-common/src/config/defaults.rs

View workflow job for this annotation

GitHub Actions / Build (x86_64-macos)

unused import: `ToSocketAddrs`
use std::time::Duration;

use crate::{ListenEndpoint, Secret};
Expand Down Expand Up @@ -41,20 +41,17 @@ pub(crate) fn _default_database_url() -> Secret<String> {

#[inline]
pub(crate) fn _default_http_listen() -> ListenEndpoint {
#[allow(clippy::unwrap_used)]
ListenEndpoint("0.0.0.0:8888".to_socket_addrs().unwrap().next().unwrap())
ListenEndpoint(SocketAddr::new(Ipv6Addr::UNSPECIFIED.into(), 8888))
}

#[inline]
pub(crate) fn _default_mysql_listen() -> ListenEndpoint {
#[allow(clippy::unwrap_used)]
ListenEndpoint("0.0.0.0:33306".to_socket_addrs().unwrap().next().unwrap())
ListenEndpoint(SocketAddr::new(Ipv6Addr::UNSPECIFIED.into(), 33306))
}

#[inline]
pub(crate) fn _default_postgres_listen() -> ListenEndpoint {
#[allow(clippy::unwrap_used)]
ListenEndpoint("0.0.0.0:55432".to_socket_addrs().unwrap().next().unwrap())
ListenEndpoint(SocketAddr::new(Ipv6Addr::UNSPECIFIED.into(), 55432))
}

#[inline]
Expand All @@ -78,8 +75,7 @@ pub(crate) fn _default_empty_vec<T>() -> Vec<T> {
}

pub(crate) fn _default_ssh_listen() -> ListenEndpoint {
#[allow(clippy::unwrap_used)]
ListenEndpoint("0.0.0.0:2222".to_socket_addrs().unwrap().next().unwrap())
ListenEndpoint(SocketAddr::new(Ipv6Addr::UNSPECIFIED.into(), 2222))
}

pub(crate) fn _default_ssh_keys_path() -> String {
Expand Down
17 changes: 11 additions & 6 deletions warpgate/src/commands/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use std::fs::{create_dir_all, File};
use std::io::Write;
use std::net::{SocketAddr, ToSocketAddrs};
use std::net::{Ipv6Addr, SocketAddr, ToSocketAddrs};
use std::path::{Path, PathBuf};

use anyhow::Result;
Expand Down Expand Up @@ -137,7 +137,8 @@ pub(crate) async fn command(cli: &crate::Cli) -> Result<()> {

store.http.enable = true;
if let Commands::UnattendedSetup { http_port, .. } = &cli.command {
store.http.listen = ListenEndpoint(SocketAddr::from(([0, 0, 0, 0], *http_port)));
store.http.listen =
ListenEndpoint(SocketAddr::new(Ipv6Addr::UNSPECIFIED.into(), *http_port));
} else {
if !is_docker() {
store.http.listen = prompt_endpoint(
Expand All @@ -150,7 +151,8 @@ pub(crate) async fn command(cli: &crate::Cli) -> Result<()> {
if let Commands::UnattendedSetup { ssh_port, .. } = &cli.command {
if let Some(ssh_port) = ssh_port {
store.ssh.enable = true;
store.ssh.listen = ListenEndpoint(SocketAddr::from(([0, 0, 0, 0], *ssh_port)));
store.ssh.listen =
ListenEndpoint(SocketAddr::new(Ipv6Addr::UNSPECIFIED.into(), *ssh_port));
}
} else {
if is_docker() {
Expand Down Expand Up @@ -178,7 +180,8 @@ pub(crate) async fn command(cli: &crate::Cli) -> Result<()> {
if let Commands::UnattendedSetup { mysql_port, .. } = &cli.command {
if let Some(mysql_port) = mysql_port {
store.mysql.enable = true;
store.mysql.listen = ListenEndpoint(SocketAddr::from(([0, 0, 0, 0], *mysql_port)));
store.mysql.listen =
ListenEndpoint(SocketAddr::new(Ipv6Addr::UNSPECIFIED.into(), *mysql_port));
}
} else {
if is_docker() {
Expand All @@ -200,8 +203,10 @@ pub(crate) async fn command(cli: &crate::Cli) -> Result<()> {
if let Commands::UnattendedSetup { postgres_port, .. } = &cli.command {
if let Some(postgres_port) = postgres_port {
store.postgres.enable = true;
store.postgres.listen =
ListenEndpoint(SocketAddr::from(([0, 0, 0, 0], *postgres_port)));
store.postgres.listen = ListenEndpoint(SocketAddr::new(
Ipv6Addr::UNSPECIFIED.into(),
*postgres_port,
));
}
} else {
if is_docker() {
Expand Down

0 comments on commit d51d882

Please sign in to comment.