Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sunwxg/goshark
https://github.com/sunwxg/goshark
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sunwxg/goshark
- Owner: sunwxg
- License: mit
- Created: 2015-11-01T07:23:09.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-24T11:36:13.000Z (about 7 years ago)
- Last Synced: 2024-10-25T05:24:21.864Z (about 2 months ago)
- Language: Go
- Size: 27.3 KB
- Stars: 19
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - goshark - Package goshark use tshark to decode IP packet and create data struct to analyse packet. (Networking / Transliteration)
- zero-alloc-awesome-go - goshark - Package goshark use tshark to decode IP packet and create data struct to analyse packet. (Networking / Transliteration)
- cybersecurity-golang-security - goshark - Package goshark use tshark to decode IP packet and create data struct to analyse packet. (Network Analysis)
- awesome-go-security - goshark - Package goshark use tshark to decode IP packet and create data struct to analyse packet. (Network Analysis)
- awesome-go - goshark - ★ 7 (Networking)
- awesome-go-extra - goshark - 11-01T07:23:09Z|2017-10-24T11:36:13Z| (Networking / Uncategorized)
- awesome-go-zh - goshark
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
```