mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-11-12 20:23:52 +08:00
版本预发布
This commit is contained in:
@@ -8,11 +8,36 @@ package simple
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/crypto/gmd5"
|
||||
"github.com/gogf/gf/v2/encoding/gbase64"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/glog"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/utility/encrypt"
|
||||
)
|
||||
|
||||
// CheckPassword 检查密码
|
||||
func CheckPassword(input, salt, hash string) (err error) {
|
||||
// 解密密码
|
||||
password, err := gbase64.Decode([]byte(input))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
password, err = encrypt.AesECBDecrypt(password, consts.RequestEncryptKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if hash != gmd5.MustEncryptString(string(password)+salt) {
|
||||
err = gerror.New("用户密码不正确")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func SafeGo(ctx context.Context, f func(ctx context.Context), level ...interface{}) {
|
||||
go func() {
|
||||
defer func() {
|
||||
|
||||
@@ -59,7 +59,7 @@ func GetAddr(ctx context.Context) string {
|
||||
func GetDomain(ctx context.Context) string {
|
||||
r := ghttp.RequestFromCtx(ctx)
|
||||
if r == nil {
|
||||
g.Log().Warningf(ctx, "GetDomain ctx not request")
|
||||
g.Log().Info(ctx, "GetDomain ctx not request")
|
||||
return ""
|
||||
}
|
||||
if validate.IsDNSName(r.Host) {
|
||||
|
||||
@@ -25,7 +25,7 @@ func IsDNSName(s string) bool {
|
||||
func IsHTTPS(ctx context.Context) bool {
|
||||
r := ghttp.RequestFromCtx(ctx)
|
||||
if r == nil {
|
||||
g.Log().Warningf(ctx, "IsHTTPS ctx not request")
|
||||
g.Log().Infof(ctx, "IsHTTPS ctx not request")
|
||||
return false
|
||||
}
|
||||
var (
|
||||
|
||||
Reference in New Issue
Block a user