diff options
author | Gilles Henaux <gill.henaux@gmail.com> | 2023-02-20 21:55:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-20 21:55:35 +0100 |
commit | b3b926fb27012bf5f975efd3cd80dab0c65bda2e (patch) | |
tree | 38a9eeee0ad07b8ee6e970b524133b116e7bb767 /tests/utils/mod.rs | |
parent | 81527b24060ab73f5bdaad252a2d62fd42f36dd7 (diff) | |
parent | c77e90c7b322b8ada71590d938150579b76431d5 (diff) |
Merge pull request #14 from Henauxg/ipv6-handling
[client & server] Fix IPv6 handling
Diffstat (limited to 'tests/utils/mod.rs')
-rw-r--r-- | tests/utils/mod.rs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/tests/utils/mod.rs b/tests/utils/mod.rs index 24b0ac8..55a1353 100644 --- a/tests/utils/mod.rs +++ b/tests/utils/mod.rs @@ -1,4 +1,8 @@ -use std::{thread::sleep, time::Duration}; +use std::{ + net::{IpAddr, Ipv4Addr}, + thread::sleep, + time::Duration, +}; use bevy::{ app::ScheduleRunnerPlugin, @@ -17,7 +21,7 @@ use bevy_quinnet::{ }, server::{ self, certificate::CertificateRetrievalMode, QuinnetServerPlugin, Server, - ServerConfigurationData, + ServerConfiguration, }, shared::{ channel::{ChannelId, ChannelType}, @@ -56,7 +60,8 @@ pub enum SharedMessage { TestMessage(String), } -pub const SERVER_HOST: &str = "127.0.0.1"; +pub const SERVER_IP: IpAddr = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)); +pub const LOCAL_BIND_IP: IpAddr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)); pub fn build_client_app() -> App { let mut client_app = App::new(); @@ -81,7 +86,7 @@ pub fn build_server_app() -> App { } pub fn default_client_configuration(port: u16) -> ConnectionConfiguration { - ConnectionConfiguration::new(SERVER_HOST.to_string(), port, "0.0.0.0".to_string(), 0) + ConnectionConfiguration::from_ips(SERVER_IP, port, LOCAL_BIND_IP, 0) } pub fn start_simple_connection(mut client: ResMut<Client>, port: Res<Port>) { @@ -96,8 +101,10 @@ pub fn start_simple_connection(mut client: ResMut<Client>, port: Res<Port>) { pub fn start_listening(mut server: ResMut<Server>, port: Res<Port>) { server .start_endpoint( - ServerConfigurationData::new(SERVER_HOST.to_string(), port.0, "0.0.0.0".to_string()), - CertificateRetrievalMode::GenerateSelfSigned, + ServerConfiguration::from_ip(LOCAL_BIND_IP, port.0), + CertificateRetrievalMode::GenerateSelfSigned { + server_hostname: SERVER_IP.to_string(), + }, ) .unwrap(); } |