Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sunwxg/Goshark


https://github.com/sunwxg/Goshark

Last synced: 20 days ago
JSON representation

Awesome Lists containing this project

README

        

# goshark
[![Build Status](https://travis-ci.org/sunwxg/goshark.svg?branch=master)](https://travis-ci.org/sunwxg/goshark)
[![GoDoc](http://godoc.org/github.com/sunwxg/goshark?status.svg)](http://godoc.org/github.com/sunwxg/goshark)

Package goshark use tshark to decode IP packet and create data struct to analyse packet.

### Dependency

* tshark

### Examples

```go
file := "2.pcap"
d := goshark.NewDecoder()
if err := d.DecodeStart(file); err != nil {
log.Println("Decode start fail:", err)
return
}
defer d.DecodeEnd()

f, err := d.NextPacket()
if err != nil {
log.Println("Get packet fail:", err)
return
}

key := "igmp.maddr"
value, ok := f.Iskey(key)
if ok {
fmt.Printf("key: %s\nvalue: %s\n", key, value)
}
```
Output:
```
key: igmp.maddr
value: 224.0.0.251
```