srun

package
v1.6.6 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: AGPL-3.0 Imports: 18 Imported by: 1

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{}

	Logger log.FieldLogger
}

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

func (*Api) WithLogger added in v1.6.4

func (a *Api) WithLogger(logger log.FieldLogger) *Api

type ApiConfig added in v1.4.7

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

type Conf

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

	Logger log.FieldLogger
}

type Detector added in v1.5.1

type Detector struct {
	Logger log.FieldLogger
	// contains filtered or unexported fields
}

func (*Detector) DetectAcid added in v1.5.1

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

DetectAcid err 为 nil 时 acid 一定存在

func (*Detector) DetectEnc added in v1.5.1

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

func (*Detector) DetectIp added in v1.6.4

func (d *Detector) DetectIp() (string, error)

func (*Detector) Reality added in v1.5.1

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

Reality acid 可能为空字符串

func (*Detector) Reset added in v1.5.1

func (d *Detector) Reset()

func (*Detector) WithLogger added in v1.6.4

func (d *Detector) WithLogger(logger log.FieldLogger) *Detector

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
	Logger    log.FieldLogger
}

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)

LoginStatus err will not be nil only when both online and ip is found.

Jump to

Keyboard shortcuts

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