优化多连接版本内网穿透连接释放逻辑

This commit is contained in:
arraykeys@gmail.com
2018-08-30 17:00:21 +08:00
parent f9a2c3cd75
commit 187a3f58dd
12 changed files with 40 additions and 13 deletions

View File

@ -161,7 +161,7 @@ curl -L https://raw.githubusercontent.com/snail007/goproxy/master/install_auto.s
下载地址:https://github.com/snail007/goproxy/releases
```shell
cd /root/proxy/
wget https://github.com/snail007/goproxy/releases/download/v5.4/proxy-linux-amd64.tar.gz
wget https://github.com/snail007/goproxy/releases/download/v5.5/proxy-linux-amd64.tar.gz
```
#### **2.下载自动安装脚本**
```shell

View File

@ -5,7 +5,7 @@ if [ -e /tmp/proxy ]; then
fi
mkdir /tmp/proxy
cd /tmp/proxy
wget https://github.com/snail007/goproxy/releases/download/v5.4/proxy-linux-amd64.tar.gz
wget https://github.com/snail007/goproxy/releases/download/v5.5/proxy-linux-amd64.tar.gz
# #install proxy
tar zxvf proxy-linux-amd64.tar.gz

View File

@ -9,7 +9,7 @@ import (
"github.com/snail007/goproxy/services"
)
const APP_VERSION = "5.4"
const APP_VERSION = "5.5"
func main() {
err := initConfig()

View File

@ -1,5 +1,5 @@
#!/bin/bash
VER="5.4"
VER="5.5"
RELEASE="release-${VER}"
rm -rf .cert
mkdir .cert

View File

@ -1,5 +1,5 @@
#/bin/bash
VER="v5.4"
VER="v5.5"
rm -rf sdk-android-*.tar.gz
rm -rf android
mkdir android

View File

@ -1,5 +1,5 @@
#/bin/bash
VER="v5.4"
VER="v5.5"
rm -rf sdk-ios-*.tar.gz
rm -rf ios
mkdir ios

View File

@ -24,7 +24,7 @@ import (
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
const SDK_VERSION = "5.4"
const SDK_VERSION = "5.5"
var (
app *kingpin.Application

View File

@ -1,5 +1,5 @@
#/bin/bash
VER="v5.4"
VER="v5.5"
rm -rf sdk-linux-*.tar.gz
rm -rf README.md libproxy-sdk.so libproxy-sdk.h libproxy-sdk.a

View File

@ -1,5 +1,5 @@
#/bin/bash
VER="v5.4"
VER="v5.5"
rm -rf *.tar.gz
rm -rf README.md libproxy-sdk.dylib libproxy-sdk.h

View File

@ -1,5 +1,5 @@
#/bin/bash
VER="v5.4"
VER="v5.5"
#sudo rm /usr/local/go
#sudo ln -s /usr/local/go1.10.1 /usr/local/go

View File

@ -123,7 +123,20 @@ func (s *TunnelBridge) callback(inConn net.Conn) {
s.log.Printf("mux server conn accept error,ERR:%s", err)
return
}
go func() {
defer func() {
_ = recover()
}()
timer := time.NewTicker(time.Second * 3)
for {
<-timer.C
if sess.NumStreams() == 0 {
sess.Close()
timer.Stop()
return
}
}
}()
var buf = make([]byte, 1024)
n, _ := inConn.Read(buf)
reader := bytes.NewReader(buf[:n])

View File

@ -183,7 +183,7 @@ func (s *TunnelClient) GetConn() (conn net.Conn, err error) {
}
}
if err == nil {
c, e := smux.Client(conn, &smux.Config{
sess, e := smux.Client(conn, &smux.Config{
AcceptBacklog: 256,
EnableKeepAlive: true,
KeepAliveInterval: 9 * time.Second,
@ -196,12 +196,26 @@ func (s *TunnelClient) GetConn() (conn net.Conn, err error) {
err = e
return
}
conn, e = c.OpenStream()
conn, e = sess.OpenStream()
if e != nil {
s.log.Printf("mux client conn open stream error,ERR:%s", e)
err = e
return
}
go func() {
defer func() {
_ = recover()
}()
timer := time.NewTicker(time.Second * 3)
for {
<-timer.C
if sess.NumStreams() == 0 {
sess.Close()
timer.Stop()
return
}
}
}()
}
return
}