nthclient

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatSIP002 = iota
	FormatSIP002Unshielded
	FormatSIP002QSAuth
)
View Source
const ConfigRoutePath = "/getserver-190831.php"
View Source
const DefaultPublicKeyPEM = `` /* 800-byte string literal not displayed */

Variables

View Source
var DefaultAndroidSettings = &Settings{
	DomainSeed:  "ewriWabKW6aMTa2W7vFNxKqgUutgpWwH",
	PlatformKey: "Cxgh48fDSJhiWpk9",
	JSONSeed:    "Gu82kdDgus0248gzkqpsl948ab7a8dse",
	TLD:         "info",
	Language:    "en-US",
	ID:          uuid.Must(uuid.NewRandom()).String(),
	AppVersion:  "5.1.0",
	UserAgent:   "",
	PublicKey:   DefaultPublicKey(),
	BackupDomains: []string{
		"https://s3.us-west-1.amazonaws.com/nthassets/getserver.a",
		"https://s3-ap-northeast-1.amazonaws.com/nthassets-tokyo/getserver.a",
		"https://s3.eu-west-2.amazonaws.com/nthassets-london/getserver.a",
	},
	Timeout: 5 * time.Second,
}
View Source
var DefaultIOSSettings = &Settings{
	DomainSeed:  "ewriWabKW6aMTa2W7vFNxKqgUutgpWwH",
	PlatformKey: "gvaiDcY7Z5ufX4b6",
	JSONSeed:    "Gu82kdDgus0248gzkqpsl948ab7a8dse",
	TLD:         "info",
	Language:    "en-US",
	ID:          uuid.Must(uuid.NewRandom()).String(),
	AppVersion:  "5.1.0",
	UserAgent:   "",
	PublicKey:   DefaultPublicKey(),
	BackupDomains: []string{
		"https://s3.us-west-1.amazonaws.com/nthassets/getserver.i",
		"https://s3-ap-northeast-1.amazonaws.com/nthassets-tokyo/getserver.i",
		"https://s3.eu-west-2.amazonaws.com/nthassets-london/getserver.i",
	},
	Timeout: 5 * time.Second,
}
View Source
var DefaultMacSettings = &Settings{
	DomainSeed:  "ewriWabKW6aMTa2W7vFNxKqgUutgpWwH",
	PlatformKey: "HnxjpP2gd6sZGdkh",
	JSONSeed:    "Gu82kdDgus0248gzkqpsl948ab7a8dse",
	TLD:         "info",
	Language:    "en-US",
	ID:          uuid.Must(uuid.NewRandom()).String(),
	AppVersion:  "5.1.0",
	UserAgent:   "",
	PublicKey:   DefaultPublicKey(),
	BackupDomains: []string{
		"https://s3.us-west-1.amazonaws.com/nthassets/getserver.m",
		"https://s3-ap-northeast-1.amazonaws.com/nthassets-tokyo/getserver.m",
		"https://s3.eu-west-2.amazonaws.com/nthassets-london/getserver.m",
	},
	Timeout: 5 * time.Second,
}
View Source
var DefaultSettings = DefaultAndroidSettings

DefaultSettings is Settings with working defaults

View Source
var DefaultWinSettings = &Settings{
	DomainSeed: "ewriWabKW6aMTa2W7vFNxKqgUutgpWwH",

	PlatformKey: "jk8Gh9wweC4gF8et",
	JSONSeed:    "Gu82kdDgus0248gzkqpsl948ab7a8dse",
	TLD:         "info",
	Language:    "en-US",
	ID:          uuid.Must(uuid.NewRandom()).String(),
	AppVersion:  "5.0.0",
	UserAgent:   "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) nthLink/5.0.0 Chrome/78.0.3905.1 Electron/7.0.0 Safari/537.36",
	PublicKey:   DefaultPublicKey(),
	BackupDomains: []string{
		"https://s3.us-west-1.amazonaws.com/nthassets/getserver.w",
		"https://s3-ap-northeast-1.amazonaws.com/nthassets-tokyo/getserver.w",
		"https://s3.eu-west-2.amazonaws.com/nthassets-london/getserver.w",
	},
	Timeout: 5 * time.Second,
}

Functions

func CalculateAPIHostname

func CalculateAPIHostname(seed, tld string) string

func Decrypt

func Decrypt(ciphertext, key string) ([]byte, error)

func DefaultPublicKey

func DefaultPublicKey() *rsa.PublicKey

func VerifyResponse

func VerifyResponse(response string, pubkey *rsa.PublicKey) ([]byte, error)

Types

type Client

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

Client for nthLink API backend, capable of retrieving server configuration from it.

func New

func New() *Client

Creates new client

func (*Client) Clone

func (c *Client) Clone() *Client

Copies Client

func (*Client) GetServerConfig

func (c *Client) GetServerConfig(ctx context.Context) ([]byte, error)

func (*Client) WithHTTPClient

func (c *Client) WithHTTPClient(httpClient *http.Client) *Client

Creates new Client with specified http.Client

func (*Client) WithSettings

func (c *Client) WithSettings(settings *Settings) *Client

Creates new Client with specified Settings

type DomainSeedTLDDefinition

type DomainSeedTLDDefinition struct {
	Seed string `json:"seed"`
	TLD  string `json:"tld"`
}

type ServerConfigResponse

type ServerConfigResponse struct {
	Servers                 []*ServerDefinition        `json:"servers"`
	DomainSeed              string                     `json:"domainSeed,omitempty"`
	DomainSeedTLD           []*DomainSeedTLDDefinition `json:"domainSeedTLD,omitempty"`
	FilterdFeaturedNewsHost string                     `json:"filterdFeaturedNewsHost,omitempty"`
	OFUInterval             int64                      `json:"ofuInterval,string"`
	OFUMax                  int64                      `json:"ofuMax,string"`
}

func UnmarshalServerConfig

func UnmarshalServerConfig(input []byte) (*ServerConfigResponse, error)

type ServerDefinition

type ServerDefinition struct {
	Host     string `json:"host"`
	Port     uint16 `json:"port,string"`
	Method   string `json:"method"`
	Name     string `json:"name"`
	Password string `json:"password"`
}

func (*ServerDefinition) Format added in v1.1.0

func (sd *ServerDefinition) Format(format int) string

func (*ServerDefinition) String

func (sd *ServerDefinition) String() string

type Settings

type Settings struct {
	DomainSeed    string         `json:"domainSeed"`
	PlatformKey   string         `json:"platformKey"`
	JSONSeed      string         `json:"jsonSeed"`
	TLD           string         `json:"tld"`
	Language      string         `json:"lang"`
	ID            string         `json:"id"`
	AppVersion    string         `json:"appVersion"`
	UserAgent     string         `json:"userAgent"`
	PublicKey     *rsa.PublicKey `json:"publicKey"`
	BackupDomains []string       `json:"backupDomains"`
	Timeout       time.Duration  `json:"timeout"`
}

Settings define important constants required for Client operation

Jump to

Keyboard shortcuts

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