mirror of
https://github.com/fatedier/frp.git
synced 2024-11-27 20:49:10 +08:00
fix panic when using socks5 plugin with encryption and compression, fix #446
This commit is contained in:
parent
5b08201e5d
commit
338d5bae37
@ -426,7 +426,7 @@ func HandleTcpWorkConnection(localInfo *config.LocalSvrConf, proxyPlugin plugin.
|
||||
if proxyPlugin != nil {
|
||||
// if plugin is set, let plugin handle connections first
|
||||
workConn.Debug("handle by plugin: %s", proxyPlugin.Name())
|
||||
proxyPlugin.Handle(remote)
|
||||
proxyPlugin.Handle(remote, workConn)
|
||||
workConn.Debug("handle by plugin finished")
|
||||
return
|
||||
} else {
|
||||
|
@ -106,13 +106,8 @@ func (hp *HttpProxy) Name() string {
|
||||
return PluginHttpProxy
|
||||
}
|
||||
|
||||
func (hp *HttpProxy) Handle(conn io.ReadWriteCloser) {
|
||||
var wrapConn frpNet.Conn
|
||||
if realConn, ok := conn.(frpNet.Conn); ok {
|
||||
wrapConn = realConn
|
||||
} else {
|
||||
wrapConn = frpNet.WrapReadWriteCloserToConn(conn, realConn)
|
||||
}
|
||||
func (hp *HttpProxy) Handle(conn io.ReadWriteCloser, realConn frpNet.Conn) {
|
||||
wrapConn := frpNet.WrapReadWriteCloserToConn(conn, realConn)
|
||||
|
||||
sc, rd := frpNet.NewShareConn(wrapConn)
|
||||
request, err := http.ReadRequest(bufio.NewReader(rd))
|
||||
|
@ -17,6 +17,8 @@ package plugin
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
frpNet "github.com/fatedier/frp/utils/net"
|
||||
)
|
||||
|
||||
// Creators is used for create plugins to handle connections.
|
||||
@ -40,6 +42,6 @@ func Create(name string, params map[string]string) (p Plugin, err error) {
|
||||
|
||||
type Plugin interface {
|
||||
Name() string
|
||||
Handle(conn io.ReadWriteCloser)
|
||||
Handle(conn io.ReadWriteCloser, realConn frpNet.Conn)
|
||||
Close() error
|
||||
}
|
||||
|
@ -43,16 +43,9 @@ func NewSocks5Plugin(params map[string]string) (p Plugin, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (sp *Socks5Plugin) Handle(conn io.ReadWriteCloser) {
|
||||
func (sp *Socks5Plugin) Handle(conn io.ReadWriteCloser, realConn frpNet.Conn) {
|
||||
defer conn.Close()
|
||||
|
||||
var wrapConn frpNet.Conn
|
||||
if realConn, ok := conn.(frpNet.Conn); ok {
|
||||
wrapConn = realConn
|
||||
} else {
|
||||
wrapConn = frpNet.WrapReadWriteCloserToConn(conn, realConn)
|
||||
}
|
||||
|
||||
wrapConn := frpNet.WrapReadWriteCloserToConn(conn, realConn)
|
||||
sp.Server.ServeConn(wrapConn)
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
"net"
|
||||
|
||||
frpIo "github.com/fatedier/frp/utils/io"
|
||||
frpNet "github.com/fatedier/frp/utils/net"
|
||||
)
|
||||
|
||||
const PluginUnixDomainSocket = "unix_domain_socket"
|
||||
@ -51,7 +52,7 @@ func NewUnixDomainSocketPlugin(params map[string]string) (p Plugin, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (uds *UnixDomainSocketPlugin) Handle(conn io.ReadWriteCloser) {
|
||||
func (uds *UnixDomainSocketPlugin) Handle(conn io.ReadWriteCloser, realConn frpNet.Conn) {
|
||||
localConn, err := net.DialUnix("unix", nil, uds.UnixAddr)
|
||||
if err != nil {
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user