User can set use aes or gzip

This commit is contained in:
Gogs
2016-06-14 16:58:53 +08:00
parent 740fb05b21
commit ab6c5c813e
7 changed files with 173 additions and 83 deletions

View File

@@ -32,7 +32,7 @@ type ProxyClient struct {
LocalIp string
LocalPort int64
Type string
UseEncryption bool
UseEncryption int
}
func (p *ProxyClient) GetLocalConn() (c *conn.Conn, err error) {
@@ -89,11 +89,7 @@ func (p *ProxyClient) StartTunnel(serverAddr string, serverPort int64) (err erro
// l means local, r means remote
log.Debug("Join two connections, (l[%s] r[%s]) (l[%s] r[%s])", localConn.GetLocalAddr(), localConn.GetRemoteAddr(),
remoteConn.GetLocalAddr(), remoteConn.GetRemoteAddr())
if p.UseEncryption {
go conn.JoinMore(localConn, remoteConn, p.AuthToken)
} else {
go conn.Join(localConn, remoteConn)
}
go conn.JoinMore(localConn, remoteConn, p.AuthToken, p.UseEncryption)
return nil
}

View File

@@ -122,10 +122,15 @@ func LoadConf(confFile string) (err error) {
}
// use_encryption
proxyClient.UseEncryption = false
proxyClient.UseEncryption = 0
useEncryptionStr, ok := section["use_encryption"]
if ok && useEncryptionStr == "true" {
proxyClient.UseEncryption = true
if ok {
tmpRes, err := strconv.Atoi(useEncryptionStr)
if err != nil {
proxyClient.UseEncryption = 0
}
proxyClient.UseEncryption = tmpRes
}
ProxyClients[proxyClient.Name] = proxyClient

View File

@@ -24,7 +24,7 @@ type ControlReq struct {
Type int64 `json:"type"`
ProxyName string `json:"proxy_name,omitempty"`
AuthKey string `json:"auth_key, omitempty"`
UseEncryption bool `json:"use_encryption, omitempty"`
UseEncryption int `json:"use_encryption, omitempty"`
Timestamp int64 `json:"timestamp, omitempty"`
}

View File

@@ -38,7 +38,7 @@ type ProxyServer struct {
CustomDomains []string
// configure in frpc.ini
UseEncryption bool
UseEncryption int
Status int64
CtlConn *conn.Conn // control connection with frpc
@@ -144,11 +144,7 @@ func (p *ProxyServer) Start(c *conn.Conn) (err error) {
log.Debug("Join two connections, (l[%s] r[%s]) (l[%s] r[%s])", workConn.GetLocalAddr(), workConn.GetRemoteAddr(),
userConn.GetLocalAddr(), userConn.GetRemoteAddr())
if p.UseEncryption {
go conn.JoinMore(userConn, workConn, p.AuthToken)
} else {
go conn.Join(userConn, workConn)
}
go conn.JoinMore(userConn, workConn, p.AuthToken, p.UseEncryption)
}()
}
}(listener)