|
1 | 1 | //! Tracker configuration factories for testing.
|
2 | 2 | use std::env;
|
3 |
| -use std::net::{IpAddr, Ipv4Addr, SocketAddr}; |
| 3 | +use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; |
4 | 4 |
|
5 | 5 | use torrust_tracker_configuration::Configuration;
|
6 | 6 | use torrust_tracker_primitives::TrackerMode;
|
@@ -44,7 +44,7 @@ pub fn ephemeral() -> Configuration {
|
44 | 44 | // Ephemeral socket address for UDP tracker
|
45 | 45 | let udp_port = 0u16;
|
46 | 46 | config.udp_trackers[0].enabled = true;
|
47 |
| - config.udp_trackers[0].bind_address = format!("127.0.0.1:{}", &udp_port); |
| 47 | + config.udp_trackers[0].bind_address = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), udp_port); |
48 | 48 |
|
49 | 49 | // Ephemeral socket address for HTTP tracker
|
50 | 50 | let http_port = 0u16;
|
@@ -136,10 +136,10 @@ pub fn ephemeral_with_external_ip(ip: IpAddr) -> Configuration {
|
136 | 136 | pub fn ephemeral_ipv6() -> Configuration {
|
137 | 137 | let mut cfg = ephemeral();
|
138 | 138 |
|
139 |
| - let ipv6 = format!("[::]:{}", 0); |
| 139 | + let ipv6 = SocketAddr::new(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0)), 0); |
140 | 140 |
|
141 |
| - cfg.http_api.bind_address.clone_from(&ipv6); |
142 |
| - cfg.http_trackers[0].bind_address.clone_from(&ipv6); |
| 141 | + cfg.http_api.bind_address.clone_from(&ipv6.to_string()); |
| 142 | + cfg.http_trackers[0].bind_address.clone_from(&ipv6.to_string()); |
143 | 143 | cfg.udp_trackers[0].bind_address = ipv6;
|
144 | 144 |
|
145 | 145 | cfg
|
|
0 commit comments