feat: extend announce_ip to accept hostnames
Add new 'announce' field to ListenerConfig that accepts both IP addresses and hostnames for proxy link generation. The old 'announce_ip' field is deprecated but still supported via automatic migration. Changes: - Add 'announce: Option<String>' field to ListenerConfig - Add migration logic: announce_ip → announce if announce not set - Update main.rs to use announce field for link generation - Support both hostnames (e.g., 'proxy.example.com') and IPs Backward compatible: existing configs using announce_ip continue to work.
This commit is contained in:
@@ -497,6 +497,12 @@ pub struct UpstreamConfig {
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ListenerConfig {
|
||||
pub ip: IpAddr,
|
||||
/// IP address or hostname to announce in proxy links.
|
||||
/// Takes precedence over `announce_ip` if both are set.
|
||||
#[serde(default)]
|
||||
pub announce: Option<String>,
|
||||
/// Deprecated: Use `announce` instead. IP address to announce in proxy links.
|
||||
/// Migrated to `announce` automatically if `announce` is not set.
|
||||
#[serde(default)]
|
||||
pub announce_ip: Option<IpAddr>,
|
||||
}
|
||||
@@ -716,6 +722,7 @@ impl ProxyConfig {
|
||||
if let Ok(ipv4) = ipv4_str.parse::<IpAddr>() {
|
||||
config.server.listeners.push(ListenerConfig {
|
||||
ip: ipv4,
|
||||
announce: None,
|
||||
announce_ip: None,
|
||||
});
|
||||
}
|
||||
@@ -723,12 +730,20 @@ impl ProxyConfig {
|
||||
if let Ok(ipv6) = ipv6_str.parse::<IpAddr>() {
|
||||
config.server.listeners.push(ListenerConfig {
|
||||
ip: ipv6,
|
||||
announce: None,
|
||||
announce_ip: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Migration: announce_ip → announce for each listener
|
||||
for listener in &mut config.server.listeners {
|
||||
if listener.announce.is_none() && listener.announce_ip.is_some() {
|
||||
listener.announce = Some(listener.announce_ip.unwrap().to_string());
|
||||
}
|
||||
}
|
||||
|
||||
// Migration: show_link (top-level) → general.links.show
|
||||
if !config.show_link.is_empty() && config.general.links.show.is_empty() {
|
||||
config.general.links.show = config.show_link.clone();
|
||||
|
||||
Reference in New Issue
Block a user