Skip to content

Commit

Permalink
Add option: userPasswdFile.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyfdecyf committed Jun 13, 2013
1 parent 407787d commit cb94c1b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
18 changes: 15 additions & 3 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ type Config struct {
hasHttpParent bool

// authenticate client
UserPasswd string
AllowedClient string
AuthTimeout time.Duration
UserPasswd string
UserPasswdFile string // file that contains user:passwd:[port] pairs
AllowedClient string
AuthTimeout time.Duration

// advanced options
DialTimeout time.Duration
Expand Down Expand Up @@ -339,6 +340,17 @@ func (p configParser) ParseUserPasswd(val string) {
}
}

func (p configParser) ParseUserPasswdFile(val string) {
exist, err := isFileExists(val)
if err != nil {
Fatal("userPasswdFile error:", err)
}
if !exist {
Fatal("userPasswdFile", val, "does not exist")
}
config.UserPasswdFile = val
}

func (p configParser) ParseAllowedClient(val string) {
config.AllowedClient = val
}
Expand Down
5 changes: 5 additions & 0 deletions doc/sample-config/rc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ listen = 127.0.0.1:7777
# COW 总是先验证 IP 是否在 allowedClient 中,若不在其中再通过用户名密码认证
#userPasswd = username:password

# 如需指定多个用户名密码,可在下面选项指定的文件中列出,文件中每行内容如下
# username:password[:port]
# port 为可选项,若指定,则该用户只能从指定端口连接 COW
#userPasswdFile = /path/to/file

# 认证失效时间
# 语法:2h3m4s 表示 2 小时 3 分钟 4 秒
#authTimeout = 2h
Expand Down

0 comments on commit cb94c1b

Please sign in to comment.