From c019f1d6211534ed63a60fa552ef2adea1ca9922 Mon Sep 17 00:00:00 2001 From: zanjie1999 Date: Thu, 12 Oct 2023 16:17:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9C=E7=A8=8B=E7=AB=AF=E8=BF=9E=E4=B8=8D?= =?UTF-8?q?=E4=B8=8A=E7=9A=84=E6=97=B6=E5=80=99=E6=8A=8A=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E5=85=B3=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tcp2ws.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tcp2ws.go b/tcp2ws.go index 244eb8a..a03bc19 100644 --- a/tcp2ws.go +++ b/tcp2ws.go @@ -1,7 +1,7 @@ // Tcp over WebSocket (tcp2ws) // 基于ws的内网穿透工具 // Sparkle 20210430 -// 11.0 +// 11.1 package main @@ -382,6 +382,8 @@ func runServer(wsConn *websocket.Conn) { udpConn, err = net.DialUDP("udp", nil, udpAddr) if err != nil { log.Print("connect to udp err: ", err) + wsConn.WriteMessage(websocket.TextMessage, []byte("tcp2wsSparkleClose")) + wsConn.Close() return } @@ -395,6 +397,8 @@ func runServer(wsConn *websocket.Conn) { tcpConn, err = net.Dial("tcp", tcpAddr) if err != nil { log.Print("connect to tcp err: ", err) + wsConn.WriteMessage(websocket.TextMessage, []byte("tcp2wsSparkleClose")) + wsConn.Close() return } @@ -646,7 +650,7 @@ func dnsPreferIpWithTtl(hostname string, ttl uint32) { func main() { arg_num := len(os.Args) if arg_num < 3 { - fmt.Println("TCP over WebSocket (tcp2ws) with UDP support 11.0\nhttps://github.com/zanjie1999/tcp-over-websocket") + fmt.Println("TCP over WebSocket (tcp2ws) with UDP support 11.1\nhttps://github.com/zanjie1999/tcp-over-websocket") fmt.Println("Client: ws://tcp2wsUrl localPort\nServer: ip:port tcp2wsPort\nUse wss: ip:port tcp2wsPort server.crt server.key") fmt.Println("Make ssl cert:\nopenssl genrsa -out server.key 2048\nopenssl ecparam -genkey -name secp384r1 -out server.key\nopenssl req -new -x509 -sha256 -key server.key -out server.crt -days 36500") os.Exit(0)