mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-09-02 01:03:54 +00:00
feat: add DHCP subnet (CIDR) configuration parameter
Allow -d to optionally accept a CIDR subnet (e.g. -d 10.0.0.0/24) to fix the DHCP address range. When specified, the DHCP allocator uses the configured subnet instead of deriving it from peer IPs. Changes: - Add dhcp_cidr field to config struct and ConfigLoader trait - Modify -d CLI arg to accept optional CIDR string value - Update DHCP logic to use configured CIDR as default subnet - Add dhcp_cidr to NetworkConfig proto message - Update launcher to handle dhcp_cidr in gen_config/new_from_config - Update i18n translations
This commit is contained in:
committed by
GitHub
parent
0a8c95879b
commit
8181830902
@@ -185,6 +185,9 @@ pub trait ConfigLoader: Send + Sync {
|
||||
fn get_dhcp(&self) -> bool;
|
||||
fn set_dhcp(&self, dhcp: bool);
|
||||
|
||||
fn get_dhcp_cidr(&self) -> Option<cidr::Ipv4Cidr>;
|
||||
fn set_dhcp_cidr(&self, cidr: Option<cidr::Ipv4Cidr>);
|
||||
|
||||
fn add_proxy_cidr(
|
||||
&self,
|
||||
cidr: cidr::Ipv4Cidr,
|
||||
@@ -535,6 +538,7 @@ struct Config {
|
||||
ipv6_public_addr_auto: Option<bool>,
|
||||
ipv6_public_addr_prefix: Option<String>,
|
||||
dhcp: Option<bool>,
|
||||
dhcp_cidr: Option<String>,
|
||||
network_identity: Option<NetworkIdentity>,
|
||||
listeners: Option<Vec<url::Url>>,
|
||||
mapped_listeners: Option<Vec<url::Url>>,
|
||||
@@ -768,6 +772,18 @@ impl ConfigLoader for TomlConfigLoader {
|
||||
self.config.lock().unwrap().dhcp = Some(dhcp);
|
||||
}
|
||||
|
||||
fn get_dhcp_cidr(&self) -> Option<cidr::Ipv4Cidr> {
|
||||
let locked_config = self.config.lock().unwrap();
|
||||
locked_config
|
||||
.dhcp_cidr
|
||||
.as_ref()
|
||||
.and_then(|s| s.parse().ok())
|
||||
}
|
||||
|
||||
fn set_dhcp_cidr(&self, cidr: Option<cidr::Ipv4Cidr>) {
|
||||
self.config.lock().unwrap().dhcp_cidr = cidr.map(|c| c.to_string());
|
||||
}
|
||||
|
||||
fn add_proxy_cidr(
|
||||
&self,
|
||||
cidr: cidr::Ipv4Cidr,
|
||||
|
||||
Reference in New Issue
Block a user