diff --git a/README.md b/README.md index 11cb512..bd986fb 100644 --- a/README.md +++ b/README.md @@ -353,16 +353,12 @@ httpport | 代理的http端口(socks5连接端口) u | 验证的用户名 p | 验证的密码 -**说明**:用户名和密码验证模式,仅部分socks5客户端支持,例如proxifer。 +**说明**:用户名和密码验证模式,仅部分socks5客户端支持,例如proxifer。命令行执行加上,web管理模式中可单独配置 -默认验证的用户名和密码为/conf/app.conf中的用户名和密码,为空则不验证 - -如需不同,可在服务端命令后加上 ``` -u=user -p=password ``` -即可,将会覆盖/conf/app.conf中的配置 - 客户端 @@ -387,8 +383,8 @@ p | 验证的密码  -### 使用 -- 服务端 +### 使用 +- 服务端 ``` ./easyProxy -mode=httpProxyServer -vkey=DKibZF5TXvic1g3kY -tcpport=8284 -httpport=8024 @@ -434,12 +430,11 @@ httpport | http代理连接端口 如果公司内网防火墙对外网访问进行了流量识别与屏蔽,例如禁止了ssh协议等,通过设置 配置文件,将服务端与客户端之间的通信内容加密传输,将会有效防止流量被拦截。 -- 在server端加上参数 -crypt=1(或在web管理中设置),例如在TCP隧道模式 +- 在server端加上参数 -crypt=1(或在web管理中设置) ``` -./easyProxy -mode tunnelServer -vkey DKibZF5TXvic1g3kY -tcpport=8284 -httpport=8024 -target=10.1.50.203:80 -crypt=1 +-crypt=1 ``` -**注意:** 优先级:命令行或者web管理设置>配置文件 ## 站点保护 @@ -447,9 +442,12 @@ httpport | http代理连接端口 easyProxy支持通过 HTTP Basic Auth 来保护你的 web 服务,使用户需要通过用户名和密码才能访问到你的服务。 -该功能目前可以在 域名代理模式、http代理请求模式、http代理模式 中使用,需要在/conf/app.conf或者命令行或者webg管理中设置,请按照自己选择的使用方式设置则可。 +目前支持使用tcp协议的web站点保护,命令行运行时可设置 +``` +-u=user -p=password +``` -**注意:** 优先级:命令行或者web管理设置>配置文件,为空则表示无需验证 +web管理中也可配置 @@ -461,9 +459,6 @@ easyProxy支持通过 HTTP Basic Auth 来保护你的 web 服务,使用户需 httpport | web管理端口 password | web界面管理密码 hostPort | 域名代理模式监听端口 -auth.user | 验证用户名(socks5、http代理、http代理请求、域名代理模式) -auth.password | 验证密码(socks5、http代理、http代理请求、域名代理模式) -crypt | 是否加密传输(全局控制) ## 操作系统支持 diff --git a/conf/app.conf b/conf/app.conf index 86b9d35..f28fad1 100755 --- a/conf/app.conf +++ b/conf/app.conf @@ -10,11 +10,4 @@ runmode = pro password=123 #http监听端口 -hostPort=8028 - -#basic auth认证用户名和密码,为空则不验证,全局控制 -auth.user= -auth.password= - -#是否加密传输(0|1),全局控制 -crypt=0 \ No newline at end of file +hostPort=80 diff --git a/conf/tasks.csv b/conf/tasks.csv index 7f430fc..19ba826 100644 --- a/conf/tasks.csv +++ b/conf/tasks.csv @@ -1,2 +1,3 @@ -0,hostServer,,ts08z6vk5nc72fs8,,,,1,0 -8001,tunnelServer,127.0.0.1:88,jq5i7n0sjs1h0jje,,,,1,1 +0,hostServer,,ts08z6vk5nc72fs8,aaa,bbb,,1,0 +0,hostServer,,7n7bxc2bm1fyjfab,a,b,,1,0 +8001,tunnelServer,127.0.0.1:88,jq5i7n0sjs1h0jje,aaa,bbb,,1,1 diff --git a/lib/init.go b/lib/init.go index ed101a3..3511e1d 100644 --- a/lib/init.go +++ b/lib/init.go @@ -3,7 +3,6 @@ package lib import ( "errors" "flag" - "github.com/astaxie/beego" "log" "reflect" "strings" @@ -27,7 +26,6 @@ var ( RunList map[string]interface{} //运行中的任务 bridge *Tunnel CsvDb *Csv - //crypt = GetBoolNoErrFromConfig("crypt") ) const cryptKey = "1234567812345678" @@ -76,13 +74,6 @@ func InitFromCsv() { } func newMode(mode string, bridge *Tunnel, httpPort int, tunnelTarget string, u string, p string, enCompress int, deCompress int, vkey string, crypt string) interface{} { - if u == "" || p == "" { //如果web管理或者命令中设置了用户名和密码,则覆盖配置文件 - u = beego.AppConfig.String("auth.user") - p = beego.AppConfig.String("auth.password") - } - if crypt == "" { //如果web管理或者命令中设置了是否加密,则覆盖配置文件 - crypt = beego.AppConfig.String("crypt") - } bCrypt := GetBoolByStr(crypt) switch mode { case "httpServer": diff --git a/lib/server.go b/lib/server.go index 885b1e7..01153ad 100755 --- a/lib/server.go +++ b/lib/server.go @@ -195,8 +195,8 @@ func (s *TunnelModeServer) Start() error { } //权限认证 -func (s *TunnelModeServer) auth(r *http.Request, c *Conn) error { - if s.basicUser != "" && s.basicPassword != "" && !checkAuth(r, s.basicUser, s.basicPassword) { +func (s *TunnelModeServer) auth(r *http.Request, c *Conn, u, p string) error { + if u != "" && p != "" && !checkAuth(r, u, p) { c.Write([]byte(Unauthorized_BYTES)) c.Close() return errors.New("401 Unauthorized") @@ -237,7 +237,7 @@ func (s *TunnelModeServer) Close() error { func ProcessTunnel(c *Conn, s *TunnelModeServer) error { method, _, rb, err, r := c.GetHost() if err == nil { - if err := s.auth(r, c); err != nil { + if err := s.auth(r, c, s.basicUser, s.basicPassword); err != nil { return err } } @@ -251,7 +251,7 @@ func ProcessHttp(c *Conn, s *TunnelModeServer) error { c.Close() return err } - if err := s.auth(r, c); err != nil { + if err := s.auth(r, c, s.basicUser, s.basicPassword); err != nil { return err } return s.dealClient(s.vKey, s.enCompress, s.deCompress, c, addr, method, rb) @@ -264,10 +264,10 @@ func ProcessHost(c *Conn, s *TunnelModeServer) error { c.Close() return err } - if err := s.auth(r, c); err != nil { + host, task, err := getKeyByHost(addr) + if err := s.auth(r, c, task.U, task.P); err != nil { return err } - host, task, err := getKeyByHost(addr) if err != nil { c.Close() return err diff --git a/views/index/add.html b/views/index/add.html index fe3415e..4da2817 100755 --- a/views/index/add.html +++ b/views/index/add.html @@ -45,11 +45,11 @@