Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/ahornerr/go-dash-button

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/ahornerr/go-dash-button

  • v0.0.0-20190313205240-044230a3f9b5
  • Source
  • Go
  • Socket score

Version published
Created
Source

go-dash-button

GoDoc

This Go library listens for DHCP requests and calls registered handlers when a request is made. Typically this will be used for Amazon Dash buttons which, when pressed, connect to WiFI and send a DHCP request. Devices are identified by their hardware address (MAC address) and handlers are registered as so.

Example

// Make sure to receive from your button handler channels. A non blocking channel send is used in the library.
// buttonChan := make(dashbutton.ButtonHandler)
// unknownButtonChan := make(dashbutton.ButtonHandler)

func listen(buttonChan, unknownButtonChan dashbutton.ButtonHandler) {
    handler := dashbutton.NewHandler()
    handler.SetUnknownButtonHandler(unknownButtonChan)
    handler.AddButtonHandler("fc:65:de:b2:8c:df", buttonChan)

    defer handler.Close()

    fmt.Println("Listening for Dash buttons...")
    
    // handler.Listen() blocks until an error is returned or handler.Close() is called
    err := handler.Listen();
}

Docker

Given the -p 0.0.0.0:67:67/udp flag to docker run, this library (and example app) is usable inside a Docker container with no modifications or host network flag necessary.

$ go build -o dash-button-example example/main.go

$ docker build -t dash-button-example -f example.Dockerfile .
...
Successfully built 292fa312f9bc
Successfully tagged dash-button-example:latest

$ docker run -p 0.0.0.0:67:67/udp dash-button-example
Listening for Dash buttons...
2019/03/13 20:36:22 Received registered button press: fc:65:de:b2:8c:df

FAQs

Package last updated on 13 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc