mirror of
https://github.com/fumiama/WireGold.git
synced 2026-06-28 14:50:26 +08:00
fix(main): mtu check
This commit is contained in:
21
main.go
21
main.go
@@ -6,6 +6,7 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
base14 "github.com/fumiama/go-base16384"
|
base14 "github.com/fumiama/go-base16384"
|
||||||
curve "github.com/fumiama/go-x25519"
|
curve "github.com/fumiama/go-x25519"
|
||||||
@@ -82,7 +83,7 @@ func main() {
|
|||||||
fmt.Println("nil ip")
|
fmt.Println("nil ip")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
f.WriteString("IP: " + r + "\n")
|
f.WriteString("IP: " + strings.TrimSpace(r) + "\n")
|
||||||
r = ""
|
r = ""
|
||||||
|
|
||||||
fmt.Print("SubNet: ")
|
fmt.Print("SubNet: ")
|
||||||
@@ -91,7 +92,7 @@ func main() {
|
|||||||
fmt.Println("nil subnet")
|
fmt.Println("nil subnet")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
f.WriteString("SubNet: " + r + "\n")
|
f.WriteString("SubNet: " + strings.TrimSpace(r) + "\n")
|
||||||
r = ""
|
r = ""
|
||||||
|
|
||||||
fmt.Print("PrivateKey: ")
|
fmt.Print("PrivateKey: ")
|
||||||
@@ -100,7 +101,7 @@ func main() {
|
|||||||
fmt.Println("nil private key")
|
fmt.Println("nil private key")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
f.WriteString("PrivateKey: " + r + "\n")
|
f.WriteString("PrivateKey: " + strings.TrimSpace(r) + "\n")
|
||||||
r = ""
|
r = ""
|
||||||
|
|
||||||
fmt.Print("EndPoint: ")
|
fmt.Print("EndPoint: ")
|
||||||
@@ -109,7 +110,16 @@ func main() {
|
|||||||
fmt.Println("nil endpoint")
|
fmt.Println("nil endpoint")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
f.WriteString("EndPoint: " + r + "\n")
|
f.WriteString("EndPoint: " + strings.TrimSpace(r) + "\n")
|
||||||
|
r = ""
|
||||||
|
|
||||||
|
fmt.Print("MTU: ")
|
||||||
|
fmt.Scanln(&r)
|
||||||
|
if r == "" {
|
||||||
|
fmt.Println("nil endpoint")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
f.WriteString("MTU: " + strings.TrimSpace(r) + "\n")
|
||||||
r = ""
|
r = ""
|
||||||
|
|
||||||
cfgf, err := os.Create(*file)
|
cfgf, err := os.Create(*file)
|
||||||
@@ -132,6 +142,9 @@ func main() {
|
|||||||
if c.EndPoint == "" {
|
if c.EndPoint == "" {
|
||||||
displayHelp("nil endpoint")
|
displayHelp("nil endpoint")
|
||||||
}
|
}
|
||||||
|
if c.MTU == 0 {
|
||||||
|
displayHelp("nil mtu")
|
||||||
|
}
|
||||||
w, err := wg.NewWireGold(&c)
|
w, err := wg.NewWireGold(&c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|||||||
Reference in New Issue
Block a user