admin

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TokenSize           = 32
	TokenExpiration     = 10 * time.Minute
	TokenRotateInterval = 5 * time.Minute
)

Variables

View Source
var (
	ErrReplyTimeout = errors.New("wait for reply timeout")
)

Functions

func StartNKNServer added in v1.0.2

func StartNKNServer(account *nkn.Account, identifier string, clientConfig *nkn.ClientConfig, tun *tunnel.Tunnel, persistConf, mergedConf *config.Config) error

func StartWebServer added in v1.0.2

func StartWebServer(listenAddr string, tun *tunnel.Tunnel, persistConf, mergedConf *config.Config) error

Types

type Client added in v1.0.2

type Client struct {
	*nkn.MultiClient
	ReplyTimeout time.Duration
}

func NewClient added in v1.0.2

func NewClient(account *nkn.Account, clientConfig *nkn.ClientConfig, identifier string) (*Client, error)

func (*Client) GetInfo added in v1.0.2

func (c *Client) GetInfo(addr string) (*GetInfoJSON, error)

func (*Client) RPCCall added in v1.0.2

func (c *Client) RPCCall(addr, method string, params interface{}, result interface{}) error

func (*Client) SendMsg added in v1.2.0

func (c *Client) SendMsg(address string, msg interface{}, waitResponse bool) (reply *nkn.Message, err error)

type GetInfoJSON added in v1.0.2

type GetInfoJSON struct {
	Addr                 string       `json:"addr"`
	LocalIP              *localIPJSON `json:"localIP"`
	AdminHTTPAPIDisabled bool         `json:"adminHttpApiDisabled"`
	Version              string       `json:"version"`
	Tuna                 bool         `json:"tuna"`
	TunaServiceName      string       `json:"tunaServiceName,omitempty"`
	TunaCountry          []string     `json:"tunaCountry,omitempty"`
	InPrice              []string     `json:"inPrice,omitempty"`
	OutPrice             []string     `json:"outPrice,omitempty"`
	Tags                 []string     `json:"tags,omitempty"`
}

type RpcReq added in v1.2.0

type RpcReq struct {
	ID      string                 `json:"id"`
	JSONRPC string                 `json:"jsonrpc"`
	Method  string                 `json:"method"`
	Params  map[string]interface{} `json:"params"`
	Token   string                 `json:"token"`
}

type RpcResp added in v1.2.0

type RpcResp struct {
	Result interface{} `json:"result,omitempty"`
	Error  string      `json:"error,omitempty"`
}

type Token

type Token struct {
	Token     string   `json:"token"`
	ExpiresAt UnixTime `json:"expiresAt"`
}

func NewToken

func NewToken(expiration time.Duration) *Token

func (*Token) IsValid

func (t *Token) IsValid(token string) bool

type TokenStore

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

func NewTokenStore

func NewTokenStore(tokenExpiration, rotateInterval time.Duration) *TokenStore

func (*TokenStore) GetCurrentToken

func (tr *TokenStore) GetCurrentToken() *Token

func (*TokenStore) IsValid

func (tr *TokenStore) IsValid(token string) bool

func (*TokenStore) Start

func (tr *TokenStore) Start()

type UnixTime

type UnixTime time.Time

func (UnixTime) MarshalJSON

func (t UnixTime) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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