mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
dhcpd: support static ip address for mac
This commit is contained in:
1 parent
41fee381d0
commit
d92e7f6191
6 files changed
+48
-11
No files matched your search
@@ -87,6 +87,19 @@ func (p *Pool) LeaseIP(mac net.HardwareAddr) (net.IP, error) {
|
||||
return nil, errors.New("no more ip can be leased")
|
||||
}
|
||||
|
||||
// LeaseStaticIP leases static ip from pool according to the given mac.
|
||||
func (p *Pool) LeaseStaticIP(mac net.HardwareAddr, ip net.IP) {
|
||||
p.mutex.Lock()
|
||||
defer p.mutex.Unlock()
|
||||
|
||||
for _, item := range p.items {
|
||||
if item.ip.Equal(ip) {
|
||||
item.mac = mac
|
||||
item.expire = time.Now().Add(time.Hour * 24 * 365 * 50) // 50 years
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ReleaseIP releases ip from pool according to the given mac.
|
||||
func (p *Pool) ReleaseIP(mac net.HardwareAddr) {
|
||||
p.mutex.Lock()
|
||||
|
||||
Reference in new issue
Block a user