Skip to content

Commit 83a085a

Browse files
committed
优化代码
1 parent e7686b4 commit 83a085a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616

1717
var debugmode bool
1818

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

@@ -37,12 +37,14 @@ func init() {
3737
}
3838

3939
func main() {
40+
Init()
41+
4042
handle, err := pcap.OpenLive(configuration.Device, SnapshotLen, false, pcap.BlockForever)
41-
defer handle.Close()
4243
if err != nil {
4344
logrus.Error(err)
4445
logrus.Fatal("Try sudo.")
4546
}
47+
defer handle.Close()
4648

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

0 commit comments

Comments
 (0)