Signed-off-by: arraykeys@gmail.com <arraykeys@gmail.com>

This commit is contained in:
arraykeys@gmail.com
2017-11-03 19:16:52 +08:00
parent 577261806c
commit e45bf338cb
5 changed files with 15 additions and 8 deletions

View File

@ -1,4 +1,7 @@
proxy更新日志 proxy更新日志
v3.6
1.http(s),socks代理,认证增加了外部api认证,可以通过外部api对用户名和密码进行认证.
v3.5 v3.5
1.优化了kcp参数,速度有所提升. 1.优化了kcp参数,速度有所提升.
2.修复了socks无法正常工作的问题. 2.修复了socks无法正常工作的问题.

View File

@ -9,7 +9,7 @@ import (
"syscall" "syscall"
) )
const APP_VERSION = "3.5" const APP_VERSION = "3.6"
func main() { func main() {
err := initConfig() err := initConfig()

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
VER="3.5" VER="3.6"
RELEASE="release-${VER}" RELEASE="release-${VER}"
rm -rf .cert rm -rf .cert
mkdir .cert mkdir .cert

View File

@ -10,6 +10,7 @@ import (
"proxy/utils/aes" "proxy/utils/aes"
"proxy/utils/socks" "proxy/utils/socks"
"runtime/debug" "runtime/debug"
"strings"
"time" "time"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
@ -353,7 +354,8 @@ func (s *Socks) socksConnCallback(inConn net.Conn) {
pass := string(r[2+r[1]+1:]) pass := string(r[2+r[1]+1:])
//log.Printf("user:%s,pass:%s", user, pass) //log.Printf("user:%s,pass:%s", user, pass)
//auth //auth
if s.basicAuth.CheckUserPass(user, pass) { _addr := strings.Split(inConn.RemoteAddr().String(), ":")
if s.basicAuth.CheckUserPass(user, pass, _addr[0]) {
inConn.Write([]byte{0x01, 0x00}) inConn.Write([]byte{0x01, 0x00})
} else { } else {
inConn.Write([]byte{0x01, 0x01}) inConn.Write([]byte{0x01, 0x01})
@ -560,6 +562,10 @@ func (s *Socks) ConnectSSH() (err error) {
} }
func (s *Socks) InitBasicAuth() (err error) { func (s *Socks) InitBasicAuth() (err error) {
s.basicAuth = utils.NewBasicAuth() s.basicAuth = utils.NewBasicAuth()
if *s.cfg.AuthURL != "" {
s.basicAuth.SetAuthURL(*s.cfg.AuthURL, *s.cfg.AuthURLOkCode, *s.cfg.AuthURLTimeout, *s.cfg.AuthURLRetry)
log.Printf("auth from %s", *s.cfg.AuthURL)
}
if *s.cfg.AuthFile != "" { if *s.cfg.AuthFile != "" {
var n = 0 var n = 0
n, err = s.basicAuth.AddFromFile(*s.cfg.AuthFile) n, err = s.basicAuth.AddFromFile(*s.cfg.AuthFile)

View File

@ -223,11 +223,9 @@ func (ba *BasicAuth) Add(userpassArr []string) (n int) {
} }
return return
} }
func (ba *BasicAuth) CheckUserPass(user, pass string) (ok bool) { func (ba *BasicAuth) CheckUserPass(user, pass, ip string) (ok bool) {
if p, _ok := ba.data.Get(user); _ok {
return p.(string) == pass return ba.Check(user+":"+pass, ip)
}
return
} }
func (ba *BasicAuth) Check(userpass string, ip string) (ok bool) { func (ba *BasicAuth) Check(userpass string, ip string) (ok bool) {
u := strings.Split(strings.Trim(userpass, " "), ":") u := strings.Split(strings.Trim(userpass, " "), ":")