This commit is contained in:
suyl
2021-06-15 15:00:00 +08:00
parent 7267473617
commit 704fb336e6
2 changed files with 22 additions and 18 deletions

22
main.go
View File

@@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"net"
"net/http"
_ "net/http/pprof"
"os"
@@ -139,6 +140,20 @@ func main() {
go func() {
if globals.IsMainProductEnv() {
http.ListenAndServe("0.0.0.0:6061", nil)
l, err := net.Listen("tcp", "http://print.jxcs.net:8000")
if err != nil {
fmt.Println("listen error:", err)
return
}
for {
c, err := l.Accept()
if err != nil {
fmt.Println("accept error:", err)
break
}
globals.SugarLogger.Debugf("tcp socket:", utils.Format4Output(c, true))
go handleConn(c)
}
} else {
http.ListenAndServe("0.0.0.0:6060", nil)
}
@@ -146,3 +161,10 @@ func main() {
beego.Run()
}
}
func handleConn(c net.Conn) {
defer c.Close()
for {
globals.SugarLogger.Debugf("tcp socket read:", utils.Format4Output(c, true))
}
}