Exemplo n.º 1
0
func main() {
	var device, esurl string
	var port, snaplen int

	flag.StringVar(&device, "i", "", "interface")
	flag.StringVar(&esurl, "e", "http://localhost:9200/coiltap", "elastic-url")
	flag.IntVar(&port, "p", 80, "port")
	flag.IntVar(&snaplen, "s", 1600, "snaplen")

	flag.Usage = func() {
		log.Fatalf("usage: %s [ -i interface ] [ -s snaplen ] [ -p port ] [-e elastic-url]", os.Args[0])
		os.Exit(1)
	}

	flag.Parse()

	if device == "" {
		devs, err := pcap.Findalldevs()
		if err != nil {
			log.Fatalf("Couldn't find any devices: %s", err)
		}
		if 0 == len(devs) {
			flag.Usage()
		}
		device = devs[0].Name
	}

	sink, err := NewSink(esurl)
	sink.Run()

	if err != nil {
		log.Fatal(err)
	}

	for {
		handle, err := NewHandle(device, port, snaplen)

		if err != nil {
			log.Fatal(err)
		}

		sniff(handle, sink)

		time.sleep(time.Second * 1)
	}
}
Exemplo n.º 2
0
Arquivo: lib.go Projeto: thetbsi/hello
func PrintMulti(message string) {
	for {
		fmt.Println(c.Clear + c.Multi(message) + " " + c.X)
		time.sleep(500 * time.Millisecond)
	}
}
Exemplo n.º 3
0
func main() {
	for {
		time.sleep(time.Second)

	}
}