1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Address string parsing for Minecraft server addresses.
//!
//! Handles all common address formats:
//!
//! | Input | Host | Port | Explicit port |
//! |-------|------|------|---------------|
//! | `"mc.hypixel.net"` | `"mc.hypixel.net"` | default | `false` |
//! | `"mc.hypixel.net:19132"` | `"mc.hypixel.net"` | `19132` | `true` |
//! | `"192.168.1.1"` | `"192.168.1.1"` | default | `false` |
//! | `"192.168.1.1:25566"` | `"192.168.1.1"` | `25566` | `true` |
//! | `"[::1]"` | `"::1"` | default | `false` |
//! | `"[::1]:25565"` | `"::1"` | `25565` | `true` |
//! | `"::1"` (bare) | `"::1"` | default | `false` |
use crateMcError;
/// Parse an address string into `(host, port, explicit_port)`.
///
/// `explicit_port` is `true` when a port was present in the string, `false`
/// when `default_port` was used as a fallback. This flag is used by
/// [`McClient`](crate::McClient) to decide whether to attempt an SRV lookup —
/// SRV is skipped when the caller already specified an explicit port.
///
/// # Supported formats
///
/// - `"hostname"` — uses `default_port`
/// - `"hostname:port"` — uses the given port
/// - `"[::1]"` — IPv6 without port, uses `default_port`
/// - `"[::1]:port"` — IPv6 with port
/// - `"::1"` — bare IPv6 (detected by multiple colons), uses `default_port`
///
/// # Errors
///
/// - [`McError::Config(InvalidAddress)`](crate::error::ConfigError::InvalidAddress)
/// — IPv6 address is missing the closing `]`.
/// - [`McError::Config(InvalidPort)`](crate::error::ConfigError::InvalidPort)
/// — port string cannot be parsed as `u16`.