-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
49 lines (42 loc) · 968 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
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"flag"
"fmt"
"os"
"github.com/adamkirchberger/mtufind/pkg/mtufind"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
func usage() {
fmt.Printf("MTUFind is a tool to find the maximum transmission unit (MTU) to a destination")
fmt.Printf("\n\nUsage: mtufind [OPTIONS] host\n")
flag.PrintDefaults()
}
func main() {
debug := flag.Bool("debug", false, "enable debug")
flag.Usage = usage
flag.Parse()
// Logging
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
zerolog.SetGlobalLevel(zerolog.InfoLevel)
if *debug {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}
args := flag.Args()
if len(args) < 1 {
flag.Usage()
os.Exit(0)
}
p, err := mtufind.New(args[0])
if err != nil {
fmt.Println(err)
os.Exit(1)
}
maxSize, err := p.Run()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Printf("MTU to %s is %d bytes\n", p.Destination, maxSize)
}