Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/philipjscott/plisten
Register callback functions that trigger on tcp/udp requests.
https://github.com/philipjscott/plisten
Last synced: about 1 month ago
JSON representation
Register callback functions that trigger on tcp/udp requests.
- Host: GitHub
- URL: https://github.com/philipjscott/plisten
- Owner: philipjscott
- License: mit
- Created: 2018-12-20T03:15:20.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-27T15:31:30.000Z (almost 6 years ago)
- Last Synced: 2024-05-28T10:29:11.912Z (7 months ago)
- Language: Go
- Homepage: https://godoc.org/github.com/ScottyFillups/plisten/pkg/dnsl
- Size: 20.5 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# plisten
Register callback functions that trigger on tcp/udp requests. Currently only supports DNS; I may add more functionality in the future.
## Documentation
The godoc can be found here: https://godoc.org/github.com/ScottyFillups/plisten/pkg/dnsl
## Installation
The binary provided in `cmd/` is currently just a DNS sniffer that logs requests; in the future I'm considering making a CLI for sniffing different layers (eg. HTTP)
```
go get github.com/ScottyFillups/plisten/cmd/plisten
```If `$GOPATH/bin` is in your `$PATH`, then you can invoke the binary:
```
sudo plisten
```## Usage
```go
package mainimport (
"github.com/ScottyFillups/plisten/pkg/dnsl"
"fmt"
"log"
)func logDNSWarn(d *dnsl.DNSListener, match string) {
fmt.Println("You visited: " + match + ". Shouldn't you be working?")
}func main() {
dataChan := make(chan dnsl.Packet)
dl := dnsl.New()err := dl.Listen(dataChan)
if err != nil {
log.Fatal("Failed to initialize DNS listener")
}err = dl.Register(".*facebook.*", logDNSWarn)
if err != nil {
log.Fatal("Failed to compile regexp")
}for data := range dataChan {
if data.Error != nil {
fmt.Println(data.Error)
dl.Close()
break
}fmt.Println(data.Host)
}
}
```See `/examples` for more specific and creative usages.