Skip to content

Commit

Permalink
we have to actually check that the MAC address matches πŸ€¦πŸ»β€β™‚οΈ
Browse files Browse the repository at this point in the history
  • Loading branch information
joeshaw committed Jan 31, 2019
1 parent 4d47bee commit e889ff6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions gyro.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package main

import (
"bytes"
"log"
"net"
"os"
"os/exec"
"time"
Expand All @@ -21,6 +23,11 @@ func main() {

log.Printf("Starting gyro at %s", time.Now().Format(time.RFC3339))

mac, err := net.ParseMAC(dashMAC)
if err != nil {
log.Fatalf("Unable to parse MAC address %q: %s", dashMAC, err)
}

dhcp, err := dhcp4.NewSnooperConn("0.0.0.0:67")
if err != nil {
log.Fatalf("Cannot start DHCP server: %s", err)
Expand All @@ -36,6 +43,10 @@ func main() {
continue
}

if !bytes.Equal(pkt.HardwareAddr, mac) {
continue
}

if pkt.Type != dhcp4.MsgDiscover {
continue
}
Expand Down

0 comments on commit e889ff6

Please sign in to comment.