Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions const.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package main

// 参数常量
const (
SnapshotLen int32 = 65536 * 4
SettingsFilePath = "./settings.json"
SnapshotLen int32 = 65536 * 4
SettingsFilePath = "./settings.json"
)

// 应用层协议类型
Expand All @@ -14,4 +14,4 @@ const (

const (
ApiAddRecord = "/record/add"
)
)
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

var debugmode bool

func init() {
func Init() {
flag.BoolVar(&debugmode, "debug", false, "Run as debug mode, read settings file to override task configuration if existsed.")
flag.Parse()

Expand All @@ -37,12 +37,14 @@ func init() {
}

func main() {
Init()

handle, err := pcap.OpenLive(configuration.Device, SnapshotLen, false, pcap.BlockForever)
defer handle.Close()
if err != nil {
logrus.Error(err)
logrus.Fatal("Try sudo.")
}
defer handle.Close()

// 过滤出当前服务的流量
filter := fmt.Sprintf(
Expand Down