提交 41c41789 编写于 作者: F fatedier

plugin: socks5 support user password auth, close #484

上级 68dfc89b
...@@ -142,9 +142,16 @@ plugin = http_proxy ...@@ -142,9 +142,16 @@ plugin = http_proxy
plugin_http_user = abc plugin_http_user = abc
plugin_http_passwd = abc plugin_http_passwd = abc
[plugin_static_file] [plugin_socks5]
type = tcp type = tcp
remote_port = 6005 remote_port = 6005
plugin = socks5
plugin_user = abc
plugin_passwd = abc
[plugin_static_file]
type = tcp
remote_port = 6006
plugin = static_file plugin = static_file
plugin_local_path = /var/www/blog plugin_local_path = /var/www/blog
plugin_strip_prefix = static plugin_strip_prefix = static
......
...@@ -32,13 +32,23 @@ func init() { ...@@ -32,13 +32,23 @@ func init() {
type Socks5Plugin struct { type Socks5Plugin struct {
Server *gosocks5.Server Server *gosocks5.Server
user string
passwd string
} }
func NewSocks5Plugin(params map[string]string) (p Plugin, err error) { func NewSocks5Plugin(params map[string]string) (p Plugin, err error) {
sp := &Socks5Plugin{} user := params["plugin_user"]
sp.Server, err = gosocks5.New(&gosocks5.Config{ passwd := params["plugin_passwd"]
cfg := &gosocks5.Config{
Logger: log.New(ioutil.Discard, "", log.LstdFlags), Logger: log.New(ioutil.Discard, "", log.LstdFlags),
}) }
if user != "" || passwd != "" {
cfg.Credentials = gosocks5.StaticCredentials(map[string]string{user: passwd})
}
sp := &Socks5Plugin{}
sp.Server, err = gosocks5.New(cfg)
p = sp p = sp
return return
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册