Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sunwxg/golibwireshark
https://github.com/sunwxg/golibwireshark
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sunwxg/golibwireshark
- Owner: sunwxg
- License: mit
- Created: 2015-11-16T06:48:41.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-24T11:56:01.000Z (about 7 years ago)
- Last Synced: 2024-10-25T05:24:21.841Z (3 months ago)
- Language: Go
- Size: 38.7 MB
- Stars: 29
- Watchers: 4
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - golibwireshark - Package golibwireshark use libwireshark library to decode pcap file and analyse dissection data. (Networking / Transliteration)
- zero-alloc-awesome-go - golibwireshark - Package golibwireshark use libwireshark library to decode pcap file and analyse dissection data. (Networking / Transliteration)
- awesome-go - golibwireshark - ★ 12 (Networking)
- awesome-go-extra - golibwireshark - 11-16T06:48:41Z|2017-10-24T11:56:01Z| (Networking / Uncategorized)
- awesome-go-zh - golibwireshark
README
# golibwireshark
[![GoDoc](http://godoc.org/github.com/sunwxg/golibwireshark?status.svg)](http://godoc.org/github.com/sunwxg/golibwireshark)Package golibwireshark use libwireshark library to decode pcap file and analyse dissection data.
This package can only be used in OS linux with CPU x86_64.
If you want to use it on other CPU structure, you need compile library in libs folder from source code.### Dependencies
* libwireshark library (version 1.12.8)* libglib2.0
### Install
- ubuntu
```
apt-get install libglib2.0-dev
go get github.com/sunwxg/golibwiresharkcd $GOPATH/src/github.com/sunwxg/golibwireshark
cat libs/libwireshark.{00,01,02,03} > libs/libwireshark.so
chmod 775 libs/libwireshark.sogo build
go test
```
### Examples
```go
file := "1.pcap"
outfile := "o.pcap"
key := "ip.addr"err := golibwireshark.Init(file, outfile)
if err != nil {
fmt.Printf("open file failed\n")
return
}
defer golibwireshark.Clean()var p golibwireshark.Packet
for {
p.GetPacket()
if p.Edt == nil {
break
}if _, ok := p.IsKey(key); ok {
p.WriteToFile()
}p.FreePacket()
}
```