diff --git a/app/lib/dto/ConfDTO.ts b/app/lib/dto/ConfDTO.ts index 69325df7b8a4b8a77ed390d61268249b0e57fae1..85743afa9c1fd83141b8bee47ba81eedfe695c84 100644 --- a/app/lib/dto/ConfDTO.ts +++ b/app/lib/dto/ConfDTO.ts @@ -182,7 +182,8 @@ export class ConfDTO public proxiesConf: ProxiesConf | undefined, public gva?: { enabled: boolean; - host?: string; + ip4?: string; + ip6?: string; port?: number; path?: string; subscriptionsPath?: string; diff --git a/neon/native/server.d.ts b/neon/native/server.d.ts index 4f001ec48a7b60051330429e30d766b3c1b9d142..d7d5c1ac8b8c36fde8762ab5ff9bc6f7649240a2 100644 --- a/neon/native/server.d.ts +++ b/neon/native/server.d.ts @@ -11,7 +11,8 @@ export class RustServerConf { } export class GvaConf { - host?: string + ip4?: string + ip6?: string port?: number path?: string; subscriptionsPath?: string; diff --git a/rust-libs/duniter-conf/src/gva_conf.rs b/rust-libs/duniter-conf/src/gva_conf.rs index 4d83d311927055b56dbf7c787f8d59cc51f2b390..bad62480bec695117c26ed5a401ac878e9becabc 100644 --- a/rust-libs/duniter-conf/src/gva_conf.rs +++ b/rust-libs/duniter-conf/src/gva_conf.rs @@ -13,12 +13,15 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. +use std::net::{Ipv4Addr, Ipv6Addr}; + use crate::*; #[derive(Clone, Debug, Default, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct GvaConf { - host: Option<String>, + ip4: Option<Ipv4Addr>, + ip6: Option<Ipv6Addr>, port: Option<u16>, path: Option<String>, subscriptions_path: Option<String>, @@ -30,10 +33,11 @@ pub struct GvaConf { } impl GvaConf { - pub fn get_host(&self) -> String { - self.host - .to_owned() - .unwrap_or_else(|| "localhost".to_owned()) + pub fn get_ip4(&self) -> Ipv4Addr { + self.ip4.unwrap_or(Ipv4Addr::LOCALHOST) + } + pub fn get_ip6(&self) -> Option<Ipv6Addr> { + self.ip6 } pub fn get_port(&self) -> u16 { self.port.unwrap_or(30901) @@ -65,8 +69,10 @@ impl GvaConf { pub fn get_remote_host(&self) -> String { if let Some(ref remote_host) = self.remote_host { remote_host.to_owned() + } else if let Some(ip6) = self.ip6 { + format!("{} [{}]", self.get_ip4(), ip6) } else { - self.get_host() + self.get_ip4().to_string() } } pub fn get_remote_port(&self) -> u16 { diff --git a/rust-libs/modules/duniter-gva/src/lib.rs b/rust-libs/modules/duniter-gva/src/lib.rs index 461057bdd864f2cfdd7f0ede421c4672d12303c4..51ddaae30b7aac811520c04b7ba288e07f8c4128 100644 --- a/rust-libs/modules/duniter-gva/src/lib.rs +++ b/rust-libs/modules/duniter-gva/src/lib.rs @@ -212,13 +212,27 @@ impl GvaModule { log::info!( "GVA server listen on http://{}:{}/{}", - &conf.get_host(), + conf.get_ip4(), conf.get_port(), &conf.get_path() ); - warp::serve(routes) - .run(([0, 0, 0, 0], conf.get_port())) + if let Some(ip6) = conf.get_ip6() { + log::info!( + "GVA server listen on http://{}:{}/{}", + ip6, + conf.get_port(), + &conf.get_path() + ); + futures::future::join( + warp::serve(routes.clone()).run((conf.get_ip4(), conf.get_port())), + warp::serve(routes).run((ip6, conf.get_port())), + ) .await; + } else { + warp::serve(routes) + .run((conf.get_ip4(), conf.get_port())) + .await; + } log::warn!("GVA server stopped"); } }