1 Star 0 Fork 0

sqos/beats

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
devices.go 752 Bytes
Copy Edit Raw Blame History
package beater
import (
"flag"
"fmt"
"runtime"
"github.com/elastic/beats/libbeat/beat"
"github.com/elastic/beats/packetbeat/sniffer"
)
func init() {
printDevices := flag.Bool("devices", false, "Print the list of devices and exit")
beat.AddFlagsCallback(func(_ *beat.Beat) error {
if *printDevices == false {
return nil
}
devs, err := sniffer.ListDeviceNames(true, true)
if err != nil {
return fmt.Errorf("Error getting devices list: %v\n", err)
}
if len(devs) == 0 {
fmt.Printf("No devices found.")
if runtime.GOOS != "windows" {
fmt.Printf(" You might need sudo?\n")
} else {
fmt.Printf("\n")
}
}
for i, dev := range devs {
fmt.Printf("%d: %s\n", i, dev)
}
return beat.GracefulExit
})
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sqos/beats.git
git@gitee.com:sqos/beats.git
sqos
beats
beats
v6.0.0-alpha2

Search