Skip to content

Commit c02bf8d

Browse files
committed
Translate an FQDN URL into a /dns multiaddr
1 parent 98579e5 commit c02bf8d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

misc/multiaddr/src/from_url.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn from_url_inner_http_ws(url: url::Url, lossy: bool) -> std::result::Result<Mul
7070
if let Ok(ip) = hostname.parse::<IpAddr>() {
7171
Protocol::from(ip)
7272
} else {
73-
Protocol::Dns4(hostname.into())
73+
Protocol::Dns(hostname.into())
7474
}
7575
} else {
7676
return Err(FromUrlErr::BadUrl);
@@ -185,31 +185,31 @@ mod tests {
185185
#[test]
186186
fn dns_addr_ws() {
187187
let addr = from_url("ws://example.com").unwrap();
188-
assert_eq!(addr, "/dns4/example.com/tcp/80/ws".parse().unwrap());
188+
assert_eq!(addr, "/dns/example.com/tcp/80/ws".parse().unwrap());
189189
}
190190

191191
#[test]
192192
fn dns_addr_http() {
193193
let addr = from_url("http://example.com").unwrap();
194-
assert_eq!(addr, "/dns4/example.com/tcp/80/http".parse().unwrap());
194+
assert_eq!(addr, "/dns/example.com/tcp/80/http".parse().unwrap());
195195
}
196196

197197
#[test]
198198
fn dns_addr_wss() {
199199
let addr = from_url("wss://example.com").unwrap();
200-
assert_eq!(addr, "/dns4/example.com/tcp/443/wss".parse().unwrap());
200+
assert_eq!(addr, "/dns/example.com/tcp/443/wss".parse().unwrap());
201201
}
202202

203203
#[test]
204204
fn dns_addr_https() {
205205
let addr = from_url("https://example.com").unwrap();
206-
assert_eq!(addr, "/dns4/example.com/tcp/443/https".parse().unwrap());
206+
assert_eq!(addr, "/dns/example.com/tcp/443/https".parse().unwrap());
207207
}
208208

209209
#[test]
210210
fn bad_hostname() {
211211
let addr = from_url("wss://127.0.0.1x").unwrap();
212-
assert_eq!(addr, "/dns4/127.0.0.1x/tcp/443/wss".parse().unwrap());
212+
assert_eq!(addr, "/dns/127.0.0.1x/tcp/443/wss".parse().unwrap());
213213
}
214214

215215
#[test]
@@ -223,7 +223,7 @@ mod tests {
223223
#[test]
224224
fn dns_and_port() {
225225
let addr = from_url("http://example.com:1000").unwrap();
226-
assert_eq!(addr, "/dns4/example.com/tcp/1000/http".parse().unwrap());
226+
assert_eq!(addr, "/dns/example.com/tcp/1000/http".parse().unwrap());
227227
}
228228

229229
#[test]

0 commit comments

Comments
 (0)