style:修正拼写错误

This commit is contained in:
Mmx
2021-07-27 09:47:45 +08:00
parent f0c262a2b0
commit a6be2fa234
5 changed files with 7 additions and 7 deletions

64
models/config.go Normal file
View File

@@ -0,0 +1,64 @@
package models
import (
"autoLogin/models/util"
"reflect"
)
type Settings struct {
QuitIfNetOk bool `json:"quit_if_net_ok"`
DemoMode bool `json:"demo_mode"`
Dns string `json:"dns"`
Guardian uint `json:"guardian"`
Daemon bool `json:"daemon"`
}
type Config struct {
From LoginForm `json:"from"`
Meta LoginMeta `json:"meta"`
Settings Settings `json:"settings"`
}
func (a *Config) Generate() *LoginInfo {
return &LoginInfo{
UrlLoginPage: "http://" + a.From.Domain + "/srun_portal_success",
UrlGetChallengeApi: "http://" + a.From.Domain + "/cgi-bin/get_challenge",
UrlLoginApi: "http://" + a.From.Domain + "/cgi-bin/srun_portal",
UrlCheckApi: "http://" + a.From.Domain + "/cgi-bin/rad_user_info",
Meta: &a.Meta,
Form: &LoginForm{
UserName: a.From.UserName + "@" + a.From.UserType,
PassWord: a.From.PassWord,
},
}
}
func (a *Config) FillDefault() *Config {
var m = map[interface{}]map[string]interface{}{
&a.From: {
"Domain": "www.msftconnecttest.com",
"UserType": "cmcc",
},
&a.Meta: {
"N": "200",
"Type": "1",
"Acid": "5",
"Enc": "srun_bx1",
},
&a.Settings: {
"Dns": "1.2.4.8",
},
}
for q, w := range m {
t := reflect.ValueOf(q).Elem()
for k, v := range w {
tt := t.FieldByName(k)
if util.Reflect.IsEmpty(tt) {
tt.Set(reflect.ValueOf(v))
}
}
}
return a
}

33
models/login.go Normal file
View File

@@ -0,0 +1,33 @@
package models
type LoginForm struct {
Domain string `json:"domain"`
UserName string `json:"username"`
UserType string `json:"user_type"`
PassWord string `json:"password"`
}
type LoginMeta struct {
N string `json:"n"`
Type string `json:"type"`
Acid string `json:"acid"`
Enc string `json:"enc"`
}
type LoginInfo struct {
UrlLoginPage string
UrlGetChallengeApi string
UrlLoginApi string
UrlCheckApi string
Ip string
Token string
EncryptedInfo string
Md5 string
EncryptedMd5 string
EncryptedChkstr string
LoginResult string
Form *LoginForm
Meta *LoginMeta
}

19
models/util/reflect.go Normal file
View File

@@ -0,0 +1,19 @@
package util
import "reflect"
type reflectR struct{}
var Reflect reflectR
func (*reflectR) IsEmpty(v reflect.Value) bool {
switch v.Kind() {
case reflect.Bool:
return !v.Bool()
case reflect.String:
return v.String() == ""
default:
panic("未设定值")
}
return false
}