From 41c41789b6f7098e043f6043f2aeeac16426bf15 Mon Sep 17 00:00:00 2001 From: fatedier Date: Wed, 24 Jan 2018 23:04:55 +0800 Subject: [PATCH] plugin: socks5 support user password auth, close #484 --- conf/frpc_full.ini | 9 ++++++++- models/plugin/socks5.go | 16 +++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/conf/frpc_full.ini b/conf/frpc_full.ini index 1b152ed8..1204b266 100644 --- a/conf/frpc_full.ini +++ b/conf/frpc_full.ini @@ -142,9 +142,16 @@ plugin = http_proxy plugin_http_user = abc plugin_http_passwd = abc -[plugin_static_file] +[plugin_socks5] type = tcp remote_port = 6005 +plugin = socks5 +plugin_user = abc +plugin_passwd = abc + +[plugin_static_file] +type = tcp +remote_port = 6006 plugin = static_file plugin_local_path = /var/www/blog plugin_strip_prefix = static diff --git a/models/plugin/socks5.go b/models/plugin/socks5.go index d7804885..fba9f5df 100644 --- a/models/plugin/socks5.go +++ b/models/plugin/socks5.go @@ -32,13 +32,23 @@ func init() { type Socks5Plugin struct { Server *gosocks5.Server + + user string + passwd string } func NewSocks5Plugin(params map[string]string) (p Plugin, err error) { - sp := &Socks5Plugin{} - sp.Server, err = gosocks5.New(&gosocks5.Config{ + user := params["plugin_user"] + passwd := params["plugin_passwd"] + + cfg := &gosocks5.Config{ 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 return }