fix bad encryption and compression when use xtcp

This commit is contained in:
zhouwenfeng 2019-08-31 21:24:20 +08:00
parent e611c44dea
commit dc6a5a29c1

View File

@ -293,18 +293,6 @@ func (sv *XtcpVisitor) handleConn(userConn frpNet.Conn) {
return
}
if sv.cfg.UseEncryption {
remote, err = frpIo.WithEncryption(remote, []byte(sv.cfg.Sk))
if err != nil {
sv.Error("create encryption stream error: %v", err)
return
}
}
if sv.cfg.UseCompression {
remote = frpIo.WithCompression(remote)
}
fmuxCfg := fmux.DefaultConfig()
fmuxCfg.KeepAliveInterval = 5 * time.Second
fmuxCfg.LogOutput = ioutil.Discard
@ -320,6 +308,18 @@ func (sv *XtcpVisitor) handleConn(userConn frpNet.Conn) {
return
}
frpIo.Join(userConn, muxConn)
var muxConnRWCloser io.ReadWriteCloser = muxConn
if sv.cfg.UseEncryption {
muxConnRWCloser, err = frpIo.WithEncryption(muxConnRWCloser, []byte(sv.cfg.Sk))
if err != nil {
sv.Error("create encryption stream error: %v", err)
return
}
}
if sv.cfg.UseCompression {
muxConnRWCloser = frpIo.WithCompression(muxConnRWCloser)
}
frpIo.Join(userConn, muxConnRWCloser)
sv.Debug("join connections closed")
}