mirror of https://github.com/fatedier/frp.git
fix xtcp encryption
This commit is contained in:
parent
9e0fd0c4ef
commit
fa2b9a836c
|
@ -115,7 +115,8 @@ func (pxy *TcpProxy) Close() {
|
|||
}
|
||||
|
||||
func (pxy *TcpProxy) InWorkConn(conn frpNet.Conn) {
|
||||
HandleTcpWorkConnection(&pxy.cfg.LocalSvrConf, pxy.proxyPlugin, &pxy.cfg.BaseProxyConf, conn)
|
||||
HandleTcpWorkConnection(&pxy.cfg.LocalSvrConf, pxy.proxyPlugin, &pxy.cfg.BaseProxyConf, conn,
|
||||
[]byte(config.ClientCommonCfg.PrivilegeToken))
|
||||
}
|
||||
|
||||
// HTTP
|
||||
|
@ -143,7 +144,8 @@ func (pxy *HttpProxy) Close() {
|
|||
}
|
||||
|
||||
func (pxy *HttpProxy) InWorkConn(conn frpNet.Conn) {
|
||||
HandleTcpWorkConnection(&pxy.cfg.LocalSvrConf, pxy.proxyPlugin, &pxy.cfg.BaseProxyConf, conn)
|
||||
HandleTcpWorkConnection(&pxy.cfg.LocalSvrConf, pxy.proxyPlugin, &pxy.cfg.BaseProxyConf, conn,
|
||||
[]byte(config.ClientCommonCfg.PrivilegeToken))
|
||||
}
|
||||
|
||||
// HTTPS
|
||||
|
@ -171,7 +173,8 @@ func (pxy *HttpsProxy) Close() {
|
|||
}
|
||||
|
||||
func (pxy *HttpsProxy) InWorkConn(conn frpNet.Conn) {
|
||||
HandleTcpWorkConnection(&pxy.cfg.LocalSvrConf, pxy.proxyPlugin, &pxy.cfg.BaseProxyConf, conn)
|
||||
HandleTcpWorkConnection(&pxy.cfg.LocalSvrConf, pxy.proxyPlugin, &pxy.cfg.BaseProxyConf, conn,
|
||||
[]byte(config.ClientCommonCfg.PrivilegeToken))
|
||||
}
|
||||
|
||||
// STCP
|
||||
|
@ -199,7 +202,8 @@ func (pxy *StcpProxy) Close() {
|
|||
}
|
||||
|
||||
func (pxy *StcpProxy) InWorkConn(conn frpNet.Conn) {
|
||||
HandleTcpWorkConnection(&pxy.cfg.LocalSvrConf, pxy.proxyPlugin, &pxy.cfg.BaseProxyConf, conn)
|
||||
HandleTcpWorkConnection(&pxy.cfg.LocalSvrConf, pxy.proxyPlugin, &pxy.cfg.BaseProxyConf, conn,
|
||||
[]byte(config.ClientCommonCfg.PrivilegeToken))
|
||||
}
|
||||
|
||||
// XTCP
|
||||
|
@ -291,7 +295,8 @@ func (pxy *XtcpProxy) InWorkConn(conn frpNet.Conn) {
|
|||
return
|
||||
}
|
||||
|
||||
HandleTcpWorkConnection(&pxy.cfg.LocalSvrConf, pxy.proxyPlugin, &pxy.cfg.BaseProxyConf, frpNet.WrapConn(kcpConn))
|
||||
HandleTcpWorkConnection(&pxy.cfg.LocalSvrConf, pxy.proxyPlugin, &pxy.cfg.BaseProxyConf,
|
||||
frpNet.WrapConn(kcpConn), []byte(pxy.cfg.Sk))
|
||||
}
|
||||
|
||||
// UDP
|
||||
|
@ -401,7 +406,7 @@ func (pxy *UdpProxy) InWorkConn(conn frpNet.Conn) {
|
|||
|
||||
// Common handler for tcp work connections.
|
||||
func HandleTcpWorkConnection(localInfo *config.LocalSvrConf, proxyPlugin plugin.Plugin,
|
||||
baseInfo *config.BaseProxyConf, workConn frpNet.Conn) {
|
||||
baseInfo *config.BaseProxyConf, workConn frpNet.Conn, encKey []byte) {
|
||||
|
||||
var (
|
||||
remote io.ReadWriteCloser
|
||||
|
@ -409,7 +414,7 @@ func HandleTcpWorkConnection(localInfo *config.LocalSvrConf, proxyPlugin plugin.
|
|||
)
|
||||
remote = workConn
|
||||
if baseInfo.UseEncryption {
|
||||
remote, err = frpIo.WithEncryption(remote, []byte(config.ClientCommonCfg.PrivilegeToken))
|
||||
remote, err = frpIo.WithEncryption(remote, encKey)
|
||||
if err != nil {
|
||||
workConn.Error("create encryption stream error: %v", err)
|
||||
return
|
||||
|
|
|
@ -295,6 +295,7 @@ func (sv *XtcpVistor) handleConn(userConn frpNet.Conn) {
|
|||
}
|
||||
|
||||
frpIo.Join(userConn, remote)
|
||||
sv.Debug("join connections closed")
|
||||
}
|
||||
|
||||
func (sv *XtcpVistor) sendDetectMsg(addr string, port int64, laddr *net.UDPAddr, content []byte) (err error) {
|
||||
|
|
|
@ -157,3 +157,5 @@ server_name = p2p_tcp
|
|||
sk = abcdefg
|
||||
bind_addr = 127.0.0.1
|
||||
bind_port = 9001
|
||||
use_encryption = false
|
||||
use_compression = false
|
||||
|
|
Loading…
Reference in New Issue