mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-28 09:58:52 +03:00
minor
This commit is contained in:
parent
6b2fa5779e
commit
d0bb127a11
5 changed files with 26 additions and 27 deletions
|
@ -53,7 +53,7 @@ func TestDB(t *testing.T) {
|
||||||
|
|
||||||
_ = os.Remove("leases.db")
|
_ = os.Remove("leases.db")
|
||||||
s.dbStore()
|
s.dbStore()
|
||||||
s.srv4.Reset()
|
s.srv4.ResetLeases(nil)
|
||||||
|
|
||||||
s.dbLoad()
|
s.dbLoad()
|
||||||
|
|
||||||
|
|
|
@ -7,42 +7,52 @@ import (
|
||||||
|
|
||||||
// DHCPServer - DHCP server interface
|
// DHCPServer - DHCP server interface
|
||||||
type DHCPServer interface {
|
type DHCPServer interface {
|
||||||
|
// ResetLeases - reset leases
|
||||||
ResetLeases(leases []*Lease)
|
ResetLeases(leases []*Lease)
|
||||||
|
// GetLeases - get leases
|
||||||
GetLeases(flags int) []Lease
|
GetLeases(flags int) []Lease
|
||||||
|
// GetLeasesRef - get reference to leases array
|
||||||
GetLeasesRef() []*Lease
|
GetLeasesRef() []*Lease
|
||||||
|
// AddStaticLease - add a static lease
|
||||||
AddStaticLease(lease Lease) error
|
AddStaticLease(lease Lease) error
|
||||||
|
// RemoveStaticLease - remove a static lease
|
||||||
RemoveStaticLease(l Lease) error
|
RemoveStaticLease(l Lease) error
|
||||||
|
// FindMACbyIP - find a MAC address by IP address in the currently active DHCP leases
|
||||||
FindMACbyIP(ip net.IP) net.HardwareAddr
|
FindMACbyIP(ip net.IP) net.HardwareAddr
|
||||||
|
|
||||||
|
// WriteDiskConfig4 - copy disk configuration
|
||||||
WriteDiskConfig4(c *V4ServerConf)
|
WriteDiskConfig4(c *V4ServerConf)
|
||||||
|
// WriteDiskConfig6 - copy disk configuration
|
||||||
WriteDiskConfig6(c *V6ServerConf)
|
WriteDiskConfig6(c *V6ServerConf)
|
||||||
|
|
||||||
|
// Start - start server
|
||||||
Start() error
|
Start() error
|
||||||
|
// Stop - stop server
|
||||||
Stop()
|
Stop()
|
||||||
Reset()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// V4ServerConf - server configuration
|
// V4ServerConf - server configuration
|
||||||
type V4ServerConf struct {
|
type V4ServerConf struct {
|
||||||
Enabled bool `yaml:"enabled"`
|
Enabled bool `yaml:"enabled"`
|
||||||
InterfaceName string `yaml:"interface_name"` // eth0, en0 and so on
|
InterfaceName string `yaml:"interface_name"`
|
||||||
GatewayIP string `yaml:"gateway_ip"`
|
GatewayIP string `yaml:"gateway_ip"`
|
||||||
SubnetMask string `yaml:"subnet_mask"`
|
SubnetMask string `yaml:"subnet_mask"`
|
||||||
RangeStart string `yaml:"range_start"`
|
RangeStart string `yaml:"range_start"`
|
||||||
RangeEnd string `yaml:"range_end"`
|
RangeEnd string `yaml:"range_end"`
|
||||||
LeaseDuration uint32 `yaml:"lease_duration"` // in seconds
|
LeaseDuration uint32 `yaml:"lease_duration"` // in seconds
|
||||||
|
|
||||||
// IP conflict detector: time (ms) to wait for ICMP reply.
|
// IP conflict detector: time (ms) to wait for ICMP reply
|
||||||
// 0: disable
|
// 0: disable
|
||||||
ICMPTimeout uint32 `yaml:"icmp_timeout_msec"`
|
ICMPTimeout uint32 `yaml:"icmp_timeout_msec"`
|
||||||
|
|
||||||
ipStart net.IP
|
ipStart net.IP // starting IP address for dynamic leases
|
||||||
ipEnd net.IP
|
ipEnd net.IP // ending IP address for dynamic leases
|
||||||
leaseTime time.Duration
|
leaseTime time.Duration // the time during which a dynamic lease is considered valid
|
||||||
dnsIPAddrs []net.IP // IPv4 addresses to return to DHCP clients as DNS server addresses
|
dnsIPAddrs []net.IP // IPv4 addresses to return to DHCP clients as DNS server addresses
|
||||||
routerIP net.IP
|
routerIP net.IP // value for Option Router
|
||||||
subnetMask net.IPMask
|
subnetMask net.IPMask // value for Option SubnetMask
|
||||||
|
|
||||||
|
// Server calls this function when leases data changes
|
||||||
notify func(uint32)
|
notify func(uint32)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,9 +63,10 @@ type V6ServerConf struct {
|
||||||
RangeStart string `yaml:"range_start"`
|
RangeStart string `yaml:"range_start"`
|
||||||
LeaseDuration uint32 `yaml:"lease_duration"` // in seconds
|
LeaseDuration uint32 `yaml:"lease_duration"` // in seconds
|
||||||
|
|
||||||
ipStart net.IP
|
ipStart net.IP // starting IP address for dynamic leases
|
||||||
leaseTime time.Duration
|
leaseTime time.Duration // the time during which a dynamic lease is considered valid
|
||||||
dnsIPAddrs []net.IP // IPv6 addresses to return to DHCP clients as DNS server addresses
|
dnsIPAddrs []net.IP // IPv6 addresses to return to DHCP clients as DNS server addresses
|
||||||
|
|
||||||
|
// Server calls this function when leases data changes
|
||||||
notify func(uint32)
|
notify func(uint32)
|
||||||
}
|
}
|
||||||
|
|
|
@ -562,13 +562,6 @@ func (s *v4Server) Stop() {
|
||||||
s.srv = nil
|
s.srv = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset - stop server
|
|
||||||
func (s *v4Server) Reset() {
|
|
||||||
s.leasesLock.Lock()
|
|
||||||
s.leases = nil
|
|
||||||
s.leasesLock.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create DHCPv4 server
|
// Create DHCPv4 server
|
||||||
func v4Create(conf V4ServerConf) (DHCPServer, error) {
|
func v4Create(conf V4ServerConf) (DHCPServer, error) {
|
||||||
s := &v4Server{}
|
s := &v4Server{}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package dhcpd
|
package dhcpd
|
||||||
|
|
||||||
|
// 'u-root/u-root' package, a dependency of 'insomniacslk/dhcp' package, doesn't build on Windows
|
||||||
|
|
||||||
import "net"
|
import "net"
|
||||||
|
|
||||||
type winServer struct {
|
type winServer struct {
|
||||||
|
|
|
@ -606,13 +606,6 @@ func (s *v6Server) Stop() {
|
||||||
s.srv = nil
|
s.srv = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset - stop server
|
|
||||||
func (s *v6Server) Reset() {
|
|
||||||
s.leasesLock.Lock()
|
|
||||||
s.leases = nil
|
|
||||||
s.leasesLock.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create DHCPv6 server
|
// Create DHCPv6 server
|
||||||
func v6Create(conf V6ServerConf) (DHCPServer, error) {
|
func v6Create(conf V6ServerConf) (DHCPServer, error) {
|
||||||
s := &v6Server{}
|
s := &v6Server{}
|
||||||
|
|
Loading…
Reference in a new issue