This commit is contained in:
esrrhs 2019-11-12 17:11:30 +08:00
parent 3050373508
commit 8651c222c4

18
main.go
View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"errors"
"flag" "flag"
"fmt" "fmt"
"github.com/esrrhs/go-engine/src/geoip" "github.com/esrrhs/go-engine/src/geoip"
@ -100,6 +101,23 @@ Usage:
func main() { func main() {
defer func() {
if r := recover(); r != nil {
var err error
switch x := r.(type) {
case string:
err = errors.New(x)
case error:
err = x
default:
err = errors.New("Unknown panic")
}
if err != nil {
loggo.Error("crash %s", err)
}
}
}()
t := flag.String("type", "", "client or server") t := flag.String("type", "", "client or server")
listen := flag.String("l", "", "listen addr") listen := flag.String("l", "", "listen addr")
target := flag.String("t", "", "target addr") target := flag.String("t", "", "target addr")