Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateRandomString(n int) (string, error)
- func GjsonGet(json []byte, path string) (gjson.Result, error)
- func GjsonParseStringMap(jsonObject string) (map[string]string, error)
- func HashSessionToken(plain string) string
- func IPDesensitize(ipAddr string) string
- func IsFileExists(path string) bool
- func IsWindows() bool
- func SplitIPAddr(v4v6Bundle string) (string, string, string)
- func Uint64SubInt64(a uint64, b int64) uint64
- func ValidateAdminPassword(password string) error
- type HybridFS
- type RequestWrapper
- type SessionToken
Constants ¶
View Source
const BcryptCost = 12
BcryptCost 密码 bcrypt 哈希 cost(默认 10,此处提高到 12 以增强离线破解成本)。
Variables ¶
View Source
var ( ErrGjsonNotFound = errors.New("specified path does not exist") ErrGjsonWrongType = errors.New("wrong type") )
View Source
var ( HttpClientSkipTlsVerify *http.Client HttpClient *http.Client )
View Source
var ( Json = jsoniter.ConfigCompatibleWithStandardLibrary DNSServers = []string{"1.1.1.1:53", "223.5.5.5:53"} )
View Source
var ErrAdminPasswordPolicy = errors.New("管理员密码需不少于8位,且大写字母、小写字母、数字、特殊字符至少包含三种")
ErrAdminPasswordPolicy 管理员密码不符合复杂度要求。
Functions ¶
func GenerateRandomString ¶
func HashSessionToken ¶ added in v0.20.27
HashSessionToken 将会话 Token 明文转为 SHA-256 十六进制摘要,用于入库与校验。
func IPDesensitize ¶
func IsFileExists ¶
func SplitIPAddr ¶
SplitIPAddr 传入/分割的v4v6混合地址,返回v4和v6地址与有效地址
func Uint64SubInt64 ¶
func ValidateAdminPassword ¶ added in v0.20.27
ValidateAdminPassword 校验管理员明文密码:长度不少于 8 位,且四类字符至少包含三种。
Types ¶
type HybridFS ¶
type HybridFS struct {
// contains filtered or unexported fields
}
HybridFS combines embed.FS and os.DirFS.
func NewHybridFS ¶
type RequestWrapper ¶
type RequestWrapper struct {
// contains filtered or unexported fields
}
func NewRequestWrapper ¶
func NewRequestWrapper(req *http.Request, writer gin.ResponseWriter) (*RequestWrapper, error)
func (*RequestWrapper) Close ¶
func (rw *RequestWrapper) Close() error
type SessionToken ¶ added in v0.20.27
SessionToken 会话 Token:Plain 发给客户端,Hash 写入 users.token。
func NewSessionToken ¶ added in v0.20.27
func NewSessionToken() (SessionToken, error)
NewSessionToken 生成会话 Token(明文 + SHA-256 十六进制摘要)。
Click to show internal directories.
Click to hide internal directories.