This commit is contained in:
esrrhs 2019-10-25 20:06:13 +08:00
parent 5a8b3469ba
commit f12978b35b

View File

@ -3,6 +3,7 @@ package main
import ( import (
"flag" "flag"
"fmt" "fmt"
"github.com/esrrhs/go-engine/src/loggo"
"github.com/esrrhs/pingtunnel" "github.com/esrrhs/pingtunnel"
) )
@ -70,32 +71,32 @@ func main() {
return return
} }
fmt.Println("start...") loggo.Info("start...")
fmt.Printf("key %d\n", *key) loggo.Info("key %d", *key)
if *t == "server" { if *t == "server" {
s, err := pingtunnel.NewServer(*timeout, *key) s, err := pingtunnel.NewServer(*timeout, *key)
if err != nil { if err != nil {
fmt.Printf("ERROR: %s\n", err.Error()) loggo.Error("ERROR: %s", err.Error())
return return
} }
fmt.Printf("Server start\n") loggo.Info("Server start")
s.Run() s.Run()
} }
if *t == "client" { if *t == "client" {
fmt.Printf("type %s\n", *t) loggo.Info("type %s", *t)
fmt.Printf("listen %s\n", *listen) loggo.Info("listen %s", *listen)
fmt.Printf("server %s\n", *server) loggo.Info("server %s", *server)
fmt.Printf("target %s\n", *target) loggo.Info("target %s", *target)
c, err := pingtunnel.NewClient(*listen, *server, *target, *timeout, *key, c, err := pingtunnel.NewClient(*listen, *server, *target, *timeout, *key,
*tcpmode, *tcpmode_buffersize, *tcpmode_maxwin, *tcpmode_resend_timems) *tcpmode, *tcpmode_buffersize, *tcpmode_maxwin, *tcpmode_resend_timems)
if err != nil { if err != nil {
fmt.Printf("ERROR: %s\n", err.Error()) loggo.Error("ERROR: %s", err.Error())
return return
} }
fmt.Printf("Client Listen %s (%s) Server %s (%s) TargetPort %s:\n", c.Addr(), c.IPAddr(), loggo.Info("Client Listen %s (%s) Server %s (%s) TargetPort %s:", c.Addr(), c.IPAddr(),
c.ServerAddr(), c.ServerIPAddr(), c.TargetAddr()) c.ServerAddr(), c.ServerIPAddr(), c.TargetAddr())
c.Run() c.Run()
} }