-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (33 loc) · 847 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"encoding/csv"
"flag"
"github.com/NiceLabs/pppoe-kit/pppoe"
"log"
"os"
)
var device string
var csvOutput bool
func init() {
flag.StringVar(&device, "device", "eth0", "specified network devices")
flag.BoolVar(&csvOutput, "csv", false, "CSV format output")
flag.Parse()
}
func main() {
var err error
if csvOutput {
writer := csv.NewWriter(os.Stdout)
_ = writer.Write([]string{"timestamp", "peer-id", "password", "mac-address"})
err = pppoe.Hijack(device, func(c *pppoe.PAPCredentials) {
_ = writer.Write([]string{c.Timestamp.String(), c.PeerID, c.Password, c.MACAddress.String()})
})
} else {
err = pppoe.Hijack(device, func(c *pppoe.PAPCredentials) { log.Println(c) })
}
if err != nil {
log.Fatalln(err)
}
}
func onCredentials(credentials *pppoe.PAPCredentials) {
log.Println(credentials)
}