mirror of https://github.com/dnomd343/XProxy.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
783 B
30 lines
783 B
package dhcp
|
|
|
|
import (
|
|
"XProxy/cmd/common"
|
|
log "github.com/sirupsen/logrus"
|
|
"path"
|
|
)
|
|
|
|
var WorkDir = "/etc/dhcp"
|
|
|
|
type dhcpConfig struct {
|
|
Enable bool `yaml:"enable" json:"enable" toml:"enable"`
|
|
Configure string `yaml:"config" json:"config" toml:"config"`
|
|
}
|
|
|
|
type Config struct {
|
|
IPv4 dhcpConfig `yaml:"ipv4" json:"ipv4" toml:"ipv4"`
|
|
IPv6 dhcpConfig `yaml:"ipv6" json:"ipv6" toml:"ipv6"`
|
|
}
|
|
|
|
func Load(config *Config) {
|
|
if config.IPv4.Enable {
|
|
log.Infof("Load DHCPv4 configure")
|
|
common.WriteFile(path.Join(WorkDir, "dhcp4.conf"), config.IPv4.Configure, true)
|
|
}
|
|
if config.IPv6.Enable {
|
|
log.Infof("Load DHCPv6 configure")
|
|
common.WriteFile(path.Join(WorkDir, "dhcp6.conf"), config.IPv6.Configure, true)
|
|
}
|
|
}
|
|
|