Skip to content

Commit

Permalink
oops, forgot to filter by the Dash's MAC address
Browse files Browse the repository at this point in the history
  • Loading branch information
joeshaw authored and Joe Shaw committed Aug 24, 2015
1 parent 1d13ce7 commit 5485fc4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion gyro.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import (
"net/http"
"net/url"
"os"
"time"

"github.com/mdlayher/arp"
)

const gyroURL = "http://saltmines.us/gyroup.php"
const name = "Some button pusher"

const dashMac = "74:c2:46:81:f2:ac"

func main() {
if len(os.Args) < 2 {
log.Fatal("Usage: arp <iface>")
Expand All @@ -23,6 +26,11 @@ func main() {
log.Fatal("InterfaceByName: ", err)
}

mac, err := net.ParseMAC(dashMac)
if err != nil {
log.Fatal("ParseMAC: ", err)
}

c, err := arp.NewClient(iface)
if err != nil {
log.Fatal("arp.NewClient: ", err)
Expand All @@ -34,7 +42,11 @@ func main() {
log.Fatal(err)
}

if p.Operation == arp.OperationRequest && p.SenderIP.Equal(net.IPv4zero) {
if p.Operation == arp.OperationRequest &&
p.SenderIP.Equal(net.IPv4zero) &&
p.SenderHardwareAddr.String() == mac.String() {

log.Printf("Gyro button pressed at %s!", time.Now())
resp, err := http.PostForm(gyroURL, url.Values{"user_name": {name}})
if err != nil {
log.Printf("Error updating count: %s", err)
Expand Down

0 comments on commit 5485fc4

Please sign in to comment.