Skip to content

Commit 9962bdb

Browse files
committed
removed debug print statement and added better log
1 parent 5f25e0c commit 9962bdb

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

allocator.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ func (a *Allocator) GetAvailableIP(mac net.HardwareAddr) (net.IP, error) {
3939
a.mutex.Lock()
4040
defer a.mutex.Unlock()
4141

42-
fmt.Println(a.Allocated)
4342
for _, c := range a.Allocated {
4443
if c.MAC.String() == mac.String() {
45-
fmt.Println("found:", c)
4644
return c.IP, nil
4745
}
4846
}
@@ -53,7 +51,6 @@ func (a *Allocator) GetAvailableIP(mac net.HardwareAddr) (net.IP, error) {
5351

5452
ip := a.AvailableIPs[0]
5553
a.AvailableIPs = a.AvailableIPs[1:]
56-
fmt.Println(a.AvailableIPs)
5754

5855
a.Allocated = append(a.Allocated, Client{
5956
MAC: mac,

main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,13 @@ func main() {
5858
continue
5959
}
6060

61-
log.Println(res.Chaddr, "->", res.Ciaddr)
61+
logmsg := fmt.Sprintf("IP: %s is allocated to %s", res.Ciaddr.String(), res.Chaddr.String())
62+
if msg.Options.GetHostName() != "" {
63+
logmsg += fmt.Sprintf("(%s)", msg.Options.GetHostName())
64+
}
65+
logmsg += fmt.Sprintf(" for %d seconds", res.Options.GetLeaseTime())
66+
log.Println(logmsg)
67+
6268
resbuf := PackMessage(res)
6369

6470
copy(addr.IP, broadcast)

0 commit comments

Comments
 (0)