瀏覽代碼

plugins/file: better logging

Signed-off-by: Andrea Barberio <insomniac@slackware.it>
Andrea Barberio 6 年之前
父節點
當前提交
5b3e2075c1
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      plugins/file/plugin.go

+ 4 - 2
plugins/file/plugin.go

@@ -41,7 +41,7 @@ func LoadDHCPv6Records(filename string) (map[string]net.IP, error) {
 	if err != nil {
 		return nil, err
 	}
-	records := make(map[string]net.IP, 0)
+	records := make(map[string]net.IP)
 	// TODO ignore comments
 	for _, lineBytes := range bytes.Split(data, []byte{'\n'}) {
 		line := string(lineBytes)
@@ -71,12 +71,14 @@ func Handler6(req, resp dhcpv6.DHCPv6) (dhcpv6.DHCPv6, bool) {
 	if err != nil {
 		return nil, false
 	}
+	log.Printf("plugins/file: looking up an IP address for MAC %s", mac.String())
 
 	ipaddr, ok := StaticRecords[mac.String()]
 	if !ok {
+		log.Warningf("plugins/file: MAC address %s is unknown", mac.String())
 		return nil, false
 	}
-	log.Printf("Found IP address %s for MAC %s", ipaddr, mac)
+	log.Printf("plugins/file: found IP address %s for MAC %s", ipaddr, mac.String())
 	resp.AddOption(&dhcpv6.OptIANA{
 		// FIXME this must be unique per client address
 		IaId: [4]byte{0xaa, 0xbb, 0xcc, 0xdd},