all: change passwd to auth_token and improve authentication
This commit is contained in:
@@ -75,9 +75,9 @@ func LoadConf(confFile string) (err error) {
|
||||
proxyServer := &ProxyServer{}
|
||||
proxyServer.Name = name
|
||||
|
||||
proxyServer.Passwd, ok = section["passwd"]
|
||||
proxyServer.AuthToken, ok = section["auth_token"]
|
||||
if !ok {
|
||||
return fmt.Errorf("Parse ini file error: proxy [%s] no passwd found", proxyServer.Name)
|
||||
return fmt.Errorf("Parse ini file error: proxy [%s] no auth_token found", proxyServer.Name)
|
||||
}
|
||||
|
||||
proxyServer.BindAddr, ok = section["bind_addr"]
|
||||
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
|
||||
type ProxyServer struct {
|
||||
Name string
|
||||
Passwd string
|
||||
AuthToken string
|
||||
UseEncryption bool
|
||||
BindAddr string
|
||||
ListenPort int64
|
||||
@@ -135,7 +135,7 @@ func (p *ProxyServer) Start() (err error) {
|
||||
userConn.GetLocalAddr(), userConn.GetRemoteAddr())
|
||||
|
||||
if p.UseEncryption {
|
||||
go conn.JoinMore(userConn, workConn, p.Passwd)
|
||||
go conn.JoinMore(userConn, workConn, p.AuthToken)
|
||||
} else {
|
||||
go conn.Join(userConn, workConn)
|
||||
}
|
||||
@@ -147,13 +147,15 @@ func (p *ProxyServer) Start() (err error) {
|
||||
|
||||
func (p *ProxyServer) Close() {
|
||||
p.Lock()
|
||||
p.Status = consts.Idle
|
||||
if p.listener != nil {
|
||||
p.listener.Close()
|
||||
if p.Status != consts.Closed {
|
||||
p.Status = consts.Closed
|
||||
if p.listener != nil {
|
||||
p.listener.Close()
|
||||
}
|
||||
close(p.ctlMsgChan)
|
||||
close(p.workConnChan)
|
||||
p.userConnList = list.New()
|
||||
}
|
||||
close(p.ctlMsgChan)
|
||||
close(p.workConnChan)
|
||||
p.userConnList = list.New()
|
||||
p.Unlock()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user