srun

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrResultCannotFound = errors.New("result cannot found from response")
	ErrAcidCannotFound   = errors.New("acid not found")
	ErrEnvCannotFound    = errors.New("enc not found")
)

Functions

func Base64

func Base64(s []byte) string

func Md5

func Md5(token, password string) (string, error)

Md5 编码

func Sha1

func Sha1(content string) string

Sha1 编码

func XDecode added in v1.5.2

func XDecode(encodedContent []byte, key string) string

func XEncode

func XEncode(content string, key string) []byte

Types

type Api

type Api struct {
	BaseUrl string
	Client  *http.Client
	// 禁用自动重定向
	NoDirect *http.Client

	CustomHeader map[string]interface{}
}

func (*Api) GetChallenge

func (a *Api) GetChallenge(username, ip string) (map[string]interface{}, error)

func (*Api) GetUserInfo

func (a *Api) GetUserInfo() (map[string]interface{}, error)

func (*Api) Init

func (a *Api) Init(conf *ApiConfig)

func (*Api) Login

func (a *Api) Login(req *LoginRequest) (map[string]interface{}, error)

func (*Api) NewDetector added in v1.5.1

func (a *Api) NewDetector() *Detector

type ApiConfig added in v1.4.7

type ApiConfig struct {
	Https        bool
	Domain       string
	Client       *http.Client
	CustomHeader map[string]interface{}
}

type Conf

type Conf struct {
	//调用 API 时直接访问 https URL
	Https bool
	//登录参数,不可缺省
	LoginInfo    LoginInfo
	Client       *http.Client
	CustomHeader map[string]interface{}
}

type Detector added in v1.5.1

type Detector struct {
	// contains filtered or unexported fields
}

func (*Detector) DetectAcid added in v1.5.1

func (a *Detector) DetectAcid() (string, error)

DetectAcid err 为 nil 时 acid 一定存在

func (*Detector) DetectEnc added in v1.5.1

func (a *Detector) DetectEnc() (string, error)

func (*Detector) Reality added in v1.5.1

func (a *Detector) Reality(addr string, getAcid bool) (acid string, online bool, err error)

Reality acid 可能为空字符串

func (*Detector) Reset added in v1.5.1

func (a *Detector) Reset()

type LoginForm

type LoginForm struct {
	Domain   string `json:"domain" yaml:"domain"`
	Username string `json:"username" yaml:"username"`
	//运营商类型
	UserType string `json:"user_type" yaml:"user_type"`
	Password string `json:"password" yaml:"password"`
}

type LoginInfo

type LoginInfo struct {
	Form LoginForm
	Meta LoginMeta
}

type LoginMeta

type LoginMeta struct {
	N           string `json:"n" yaml:"n"`
	Type        string `json:"type" yaml:"type"`
	Acid        string `json:"acid" yaml:"acid"`
	Enc         string `json:"enc" yaml:"enc"`
	OS          string `json:"os" yaml:"os"`
	Name        string `json:"name" yaml:"name"`
	InfoPrefix  string `json:"info_prefix" yaml:"info_prefix"`
	DoubleStack bool   `json:"double_stack" yaml:"double_stack"`
}

type LoginRequest added in v1.4.5

type LoginRequest struct {
	Username    string
	Password    string
	AcID        string
	IP          string
	Info        string
	ChkSum      string
	N           string
	Type        string
	OS          string
	Name        string
	DoubleStack string
}

type Srun added in v1.3.9

type Srun struct {
	//登录参数,不可缺省
	LoginInfo LoginInfo
	Api       Api
}

func New added in v1.3.9

func New(conf *Conf) *Srun

func (Srun) DoLogin added in v1.3.9

func (c Srun) DoLogin(clientIP string) error

func (Srun) LoginStatus added in v1.3.9

func (c Srun) LoginStatus() (online bool, ip string, err error)

Jump to

Keyboard shortcuts

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