utils

package
v0.0.28 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2024 License: GPL-3.0 Imports: 21 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

func GetIntValueFromStr

func GetIntValueFromStr(c context.Context, key string) (int, bool)

func GetJwtToken

func GetJwtToken(secretKey string, iat, seconds int64, payload string) (string, error)

@secretKey: JWT 加解密密钥 @iat: 时间戳 @seconds: 过期时间,单位秒 @payload: 数据载体

func GetJwtTokenFromMap

func GetJwtTokenFromMap(secretKey string, iat, seconds int64, payload map[string]string) (string, error)

@secretKey: JWT 加解密密钥 @iat: 时间戳 @seconds: 过期时间,单位秒 @payload: 数据载体

func GetValue

func GetValue[T any](c context.Context, key string) (T, bool)

func HashPassword

func HashPassword(password string) (string, error)

func IsInteger

func IsInteger(str string) bool

func LoadClientConfig

func LoadClientConfig(content []byte, strict bool) (
	*v1.ClientCommonConfig,
	[]v1.ProxyConfigurer,
	[]v1.VisitorConfigurer,
	error,
)

func LoadClientConfigNormal

func LoadClientConfigNormal(content []byte, strict bool) (*v1.ClientConfig, error)

func LoadConfigureFromContent

func LoadConfigureFromContent(content []byte, c any, strict bool) error

func LoadContentWithTemplate

func LoadContentWithTemplate(content []byte, values *config.Values) ([]byte, error)

func LoadServerConfig

func LoadServerConfig(content []byte, strict bool) (*v1.ServerConfig, error)

func MD5

func MD5(input string) string

func NewBaseFRPClientConfig

func NewBaseFRPClientConfig(serverAddr string, serverPort int, token string) *v1.ClientCommonConfig

func NewBaseFRPClientUserAuthConfig

func NewBaseFRPClientUserAuthConfig(serverAddr string, serverPort int, user, token string) *v1.ClientCommonConfig

func NewBaseFRPServerConfig

func NewBaseFRPServerConfig(port int, token string) *v1.ServerConfig

func NewBaseFRPServerUserAuthConfig

func NewBaseFRPServerUserAuthConfig(port int, opts []v1.HTTPPluginOptions) *v1.ServerConfig

func ParseToken

func ParseToken(secretKey, tokenStr string) (u jwt.MapClaims, err error)

func PemBlockForPrivKey

func PemBlockForPrivKey(priv interface{}) *pem.Block

func PublicKey

func PublicKey(priv interface{}) interface{}

func SHA1

func SHA1(input string) string

func Str2Int64

func Str2Int64(str string) int64

func Str2Int64Default

func Str2Int64Default(str string, intVal int64) int64

func TLSClientCert

func TLSClientCert(caPem []byte) (credentials.TransportCredentials, error)

func TLSClientCertNoValidate

func TLSClientCertNoValidate(caPem []byte) (credentials.TransportCredentials, error)

func TLSServerCert

func TLSServerCert(certPem, keyPem []byte) (credentials.TransportCredentials, error)

func ToStr

func ToStr(any interface{}) string

func TransformProxyConfigurerToMap

func TransformProxyConfigurerToMap(origin v1.ProxyConfigurer) (key string, r v1.ProxyConfigurer)

func TransformVisitorConfigurerToMap

func TransformVisitorConfigurerToMap(origin v1.VisitorConfigurer) (key string, r v1.VisitorConfigurer)

func ValidateJwtToken

func ValidateJwtToken(secretKey, token string) (bool, error)

@secretKey: JWT 加解密密钥 @token: JWT Token 的字符串

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL