Documentation
¶
Index ¶
- Variables
- func Dial(dial *config.Dial, index int) (net.Conn, error)
- func GenerateRandomPassword(length int) (string, error)
- func GenerateToken(userID uint, email string) (string, error)
- func HashPassword(password string) (string, error)
- func IsLinuxPhysicalInterface(iface *net.Interface) bool
- func IsLocallyAdministeredMAC(mac string) bool
- func IsMacPhysicalInterface(iface *net.Interface) bool
- func IsValidMAC(mac string) bool
- func IsWindowsPhysicalInterface(iface *net.Interface) bool
- func Listen(listen *config.Listen) (net.Listener, error)
- func NormalizeMAC(mac string) string
- func RefreshToken(tokenString string) (string, error)
- func SetJWTSecret(secret string) error
- func SetRLimit(fileLimit uint64) error
- func VerifyPassword(password, encodedHash string) (bool, error)
- type Claims
- type FingerprintComponents
- type JWTConfig
- type PasswordConfig
- type WindowsNetworkAdapter
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // safe ciperSuites with DH exchange algorithms. CiperSuites = []uint16{ tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305, tls.TLS_FALLBACK_SCSV, } )
View Source
var DefaultJWTConfig = &JWTConfig{ SecretKey: "", ExpirationTime: 24 * time.Hour, }
DefaultJWTConfig 默认JWT配置
View Source
var DefaultPasswordConfig = &PasswordConfig{
Time: 1,
Memory: 64 * 1024,
Threads: 4,
KeyLen: 32,
}
DefaultPasswordConfig 默认密码配置
Functions ¶
func GenerateRandomPassword ¶
GenerateRandomPassword 生成随机密码
func GenerateToken ¶
GenerateToken 生成JWT token
func IsLinuxPhysicalInterface ¶
IsLinuxPhysicalInterface Linux 专用的物理接口判断 只做基本过滤,不使用 sysfs 检查(适用于容器环境)
func IsLocallyAdministeredMAC ¶
IsLocallyAdministeredMAC 判断 MAC 地址是否是本地管理的 本地管理的 MAC 地址的第 2 位为 1
func IsMacPhysicalInterface ¶
IsMacPhysicalInterface macOS 专用的物理接口判断 注意:不检查 MAC 是否是本地管理的,即使 MAC 是本地管理的也会被获取(用于指纹生成)
func IsWindowsPhysicalInterface ¶
IsWindowsPhysicalInterface Windows 专用的物理接口判断
func SetJWTSecret ¶
SetJWTSecret 设置JWT密钥(用于从配置文件读取) 如果secret为空,将返回错误
func VerifyPassword ¶
VerifyPassword 验证密码
Types ¶
type Claims ¶
type Claims struct {
UserID uint `json:"user_id"`
Email string `json:"email"`
jwt.RegisteredClaims
}
Claims JWT声明
func ValidateToken ¶
ValidateToken 验证JWT token
type FingerprintComponents ¶
FingerprintComponents 指纹组成信息
func GetFingerprint ¶
func GetFingerprint() (string, *FingerprintComponents, error)
GetFingerprint 获取设备指纹 基于 MAC、CPU、磁盘序列号生成指纹 所有组件都进行排序,确保指纹稳定性 返回指纹字符串、组成信息和错误
type PasswordConfig ¶
PasswordConfig 密码配置
Click to show internal directories.
Click to hide internal directories.