feat: 加入对直接访问https api的支持
This commit is contained in:
@@ -5,12 +5,17 @@ import (
|
||||
"github.com/Mmx233/BitSrunLoginGo/v1/transfer"
|
||||
)
|
||||
|
||||
func GenerateLoginInfo(Form *srunTransfer.LoginForm, Meta *srunTransfer.LoginMeta) *srunModels.LoginInfo {
|
||||
func GenerateLoginInfo(https bool, Form *srunTransfer.LoginForm, Meta *srunTransfer.LoginMeta) *srunModels.LoginInfo {
|
||||
portal := "http"
|
||||
if https {
|
||||
portal += "s"
|
||||
}
|
||||
portal += "://"
|
||||
return &srunModels.LoginInfo{
|
||||
UrlLoginPage: "http://" + Form.Domain + "/srun_portal_success",
|
||||
UrlGetChallengeApi: "http://" + Form.Domain + "/cgi-bin/get_challenge",
|
||||
UrlLoginApi: "http://" + Form.Domain + "/cgi-bin/srun_portal",
|
||||
UrlCheckApi: "http://" + Form.Domain + "/cgi-bin/rad_user_info",
|
||||
UrlLoginPage: portal + Form.Domain + "/srun_portal_success",
|
||||
UrlGetChallengeApi: portal + Form.Domain + "/cgi-bin/get_challenge",
|
||||
UrlLoginApi: portal + Form.Domain + "/cgi-bin/srun_portal",
|
||||
UrlCheckApi: portal + Form.Domain + "/cgi-bin/rad_user_info",
|
||||
Meta: Meta,
|
||||
Form: &srunTransfer.LoginForm{
|
||||
UserName: Form.UserName + "@" + Form.UserType,
|
||||
|
||||
17
util/log.go
17
util/log.go
@@ -2,7 +2,6 @@ package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Mmx233/BitSrunLoginGo/global"
|
||||
"github.com/Mmx233/tool"
|
||||
"log"
|
||||
"os"
|
||||
@@ -13,12 +12,24 @@ import (
|
||||
type loG struct {
|
||||
timeStamp string
|
||||
WriteFile bool
|
||||
Path string
|
||||
Debug bool
|
||||
OutPut bool
|
||||
}
|
||||
|
||||
var Log loG
|
||||
|
||||
func (c *loG) Init(debug, logFile, outPut bool, path string) {
|
||||
c.Debug = debug
|
||||
c.WriteFile = logFile
|
||||
c.OutPut = outPut
|
||||
c.Path = path
|
||||
}
|
||||
|
||||
func (c *loG) time() string {
|
||||
return time.Now().Format("2006/01/02 15:04:05")
|
||||
}
|
||||
|
||||
func (c *loG) WriteLog(name string, a ...interface{}) {
|
||||
if !(c.Debug && c.WriteFile) {
|
||||
return
|
||||
@@ -30,7 +41,7 @@ func (c *loG) WriteLog(name string, a ...interface{}) {
|
||||
t += " "
|
||||
}
|
||||
}
|
||||
err := tool.File.Add(global.Config.Settings.Debug.Path+name, fmt.Sprintf(time.Now().Format("2006/01/02 15:04:05 "))+t, 700)
|
||||
err := tool.File.Add(c.Path+name, c.time()+" "+t, 700)
|
||||
if err != nil {
|
||||
log.Println("Write log error: ", err)
|
||||
}
|
||||
@@ -38,7 +49,7 @@ func (c *loG) WriteLog(name string, a ...interface{}) {
|
||||
|
||||
func (c *loG) genTimeStamp() {
|
||||
if c.timeStamp == "" {
|
||||
c.timeStamp = time.Now().Format("2006.01.02-15.04.05")
|
||||
c.timeStamp = c.time()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user