mirror of
https://github.com/gl-inet/glkvm-cloud.git
synced 2026-09-23 11:13:21 +00:00
windows: Login with system username and password for web
Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
This commit is contained in:
@@ -10,7 +10,6 @@ generate() {
|
||||
cp conf/rttys.crt conf/rttys.key output/$dir
|
||||
|
||||
[ "$os" = "windows" ] && {
|
||||
cp conf/rttys.ini output/$dir
|
||||
bin="rttys.exe"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
[login]
|
||||
username = rttys
|
||||
password = rttys
|
||||
+15
-9
@@ -1,7 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/robfig/config"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func checkUser() bool {
|
||||
@@ -9,14 +10,19 @@ func checkUser() bool {
|
||||
}
|
||||
|
||||
func login(username, password string) bool {
|
||||
c, err := config.ReadDefault("rttys.ini")
|
||||
mod := syscall.NewLazyDLL("Advapi32.dll")
|
||||
LOGON32_LOGON_INTERACTIVE := 2
|
||||
LOGON32_PROVIDER_DEFAULT := 0
|
||||
var token syscall.Handle
|
||||
|
||||
if err != nil {
|
||||
return true
|
||||
}
|
||||
proc := mod.NewProc("LogonUserW")
|
||||
ret, _, err := proc.Call(
|
||||
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(username))),
|
||||
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr("."))),
|
||||
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(password))),
|
||||
uintptr(LOGON32_LOGON_INTERACTIVE),
|
||||
uintptr(LOGON32_PROVIDER_DEFAULT),
|
||||
uintptr(unsafe.Pointer(&token)))
|
||||
|
||||
u, _ := c.String("login", "username")
|
||||
p, _ := c.String("login", "password")
|
||||
|
||||
return username == u && password == p
|
||||
return ret == 1 || err.(syscall.Errno) == 1327
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user