1 Star 0 Fork 0

zhangjungang/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
devices.go 752 Bytes
一键复制 编辑 原始数据 按行查看 历史
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
})
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangjungang/beats.git
git@gitee.com:zhangjungang/beats.git
zhangjungang
beats
beats
v5.5.0

搜索帮助