Skip to content

Commit

Permalink
优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
bjdgyc committed Nov 6, 2024
1 parent 7116aaa commit 7d1b4b5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

AnyLink 是一个企业级远程办公 sslvpn 的软件,可以支持多人同时在线使用。

使用 AnyLink,你可以随时随地安全的访问你的内部网络。

With AnyLink, you can securely access your internal network anytime and anywhere.

## Repo

> github: https://github.com/bjdgyc/anylink
Expand All @@ -26,7 +30,7 @@ AnyLink 基于 [ietf-openconnect](https://tools.ietf.org/html/draft-mavrogiannop
AnyLink 使用 TLS/DTLS 进行数据加密,因此需要 RSA 或 ECC 证书,可以使用私有自签证书,可以通过 Let's Encrypt 和 TrustAsia
申请免费的 SSL 证书。

AnyLink 服务端仅在 CentOS 7、CentOS 8、Ubuntu 18.04、Ubuntu 20.04 测试通过,如需要安装在其他系统,需要服务端支持 tun/tap
AnyLink 服务端仅在 CentOS 7、CentOS 8、Ubuntu 18、Ubuntu 20、Ubuntu 20、AnolisOS 8 测试通过,如需要安装在其他系统,需要服务端支持 tun/tap
功能、ip 设置命令、iptables命令。

## Screenshot
Expand Down
8 changes: 8 additions & 0 deletions server/dbdata/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ func checkLocalUser(name, pwd, group string) error {
// }
// }
// 判断用户密码
// 兼容明文密码
if len(v.PinCode) != 60 {
if pwd != v.PinCode {
return fmt.Errorf("%s %s", name, "密码错误")
}
return nil
}
// 密文密码
if !utils.PasswordVerify(pwd, v.PinCode) {
return fmt.Errorf("%s %s", name, "密码错误")
}
Expand Down
7 changes: 4 additions & 3 deletions server/dbdata/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ func TestCheckUser(t *testing.T) {
ast.Equal(g.RouteInclude[0].IpMask, "192.168.1.0/255.255.255.0")

// 添加一个用户
u := User{Username: "aaa", Groups: []string{group}, Status: 1}
pincode := "a123456"
u := User{Username: "aaa", PinCode: pincode, Groups: []string{group}, Status: 1}
err = SetUser(&u)
ast.Nil(err)

Expand All @@ -37,7 +38,7 @@ func TestCheckUser(t *testing.T) {
// 单独验证密码
u.DisableOtp = true
_ = SetUser(&u)
err = CheckUser("aaa", u.PinCode, group)
err = CheckUser("aaa", pincode, group)
ast.Nil(err)

// 添加一个radius组
Expand All @@ -62,7 +63,7 @@ func TestCheckUser(t *testing.T) {
p1 := Policy{Username: "aaa", Status: 1, ClientDns: dns2, RouteInclude: route2}
err = SetPolicy(&p1)
ast.Nil(err)
err = CheckUser("aaa", u.PinCode, group)
err = CheckUser("aaa", pincode, group)
ast.Nil(err)
// 添加一个ldap组
group3 := "group3"
Expand Down

0 comments on commit 7d1b4b5

Please sign in to comment.