web

package
v0.0.0-...-133c9a2 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2022 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TROJAN_DEFAULT_GROUP    = "TrojanProvider"
	V2RAY_DEFAULT_GROUP     = "V2RayProvider"
	SS_DEFAULT_GROUP        = "SSProvider"
	SSR_DEFAULT_GROUP       = "SSRProvider"
	SPEEDTEST_ERROR_NONODES = "{\"info\":\"error\",\"reason\":\"nonodes\"}\n"
)
View Source
const (
	PIC_BASE64 = iota
	PIC_PATH
	PIC_NONE
)
View Source
const (
	SpeedOnly = "speedonly"
	PingOnly  = "pingonly"
	ALLTEST   = iota
	RETEST
)

Variables

View Source
var ErrInvalidData = errors.New("invalid data")
View Source
var FontBytes []byte

Functions

func FormatDuration

func FormatDuration(duration time.Duration) string

func GetRemarks

func GetRemarks(link string) (string, string, error)
func ParseLinks(message string) ([]string, error)

api

func ServeFile

func ServeFile(port int) error

func TestContext

func TestContext(ctx context.Context, options ProfileTestOptions, w MessageWriter) (render.Nodes, error)

use as golang api

func TestFromCMD

func TestFromCMD(subscription string, configPath *string) error

Types

type EmptyMessageWriter

type EmptyMessageWriter struct {
}

func (*EmptyMessageWriter) WriteMessage

func (w *EmptyMessageWriter) WriteMessage(messageType int, data []byte) error
type GetSubscriptionLink struct {
	FilePath string `json:"filePath"`
	Group    string `json:"group"`
}

type Message

type Message struct {
	ID       int       `json:"id"`
	Info     string    `json:"info"`
	Remarks  string    `json:"remarks"`
	Server   string    `json:"server"`
	Group    string    `json:"group"`
	Ping     int64     `json:"ping"`
	Lost     string    `json:"lost"`
	Speed    string    `json:"speed"`
	MaxSpeed string    `json:"maxspeed"`
	Traffic  int64     `json:"traffic"`
	Link     string    `json:"link"`
	Protocol string    `json:"protocol"`
	PicData  string    `json:"data,omitempty"`
	Servers  []Message `json:"servers"`
}

type MessageWriter

type MessageWriter interface {
	WriteMessage(messageType int, data []byte) error
}

type OutputMessageWriter

type OutputMessageWriter struct {
}

func (*OutputMessageWriter) WriteMessage

func (p *OutputMessageWriter) WriteMessage(messageType int, data []byte) error

type ProfileTest

type ProfileTest struct {
	Writer      MessageWriter
	Options     *ProfileTestOptions
	MessageType int
	Links       []string
	// contains filtered or unexported fields
}

func (*ProfileTest) TestAll

func (p *ProfileTest) TestAll(ctx context.Context, links []string, max int, trafficChan chan<- int64) (chan render.Node, error)

api

func (*ProfileTest) WriteMessage

func (p *ProfileTest) WriteMessage(data []byte) error

func (*ProfileTest) WriteString

func (p *ProfileTest) WriteString(data string) error

type ProfileTestOptions

type ProfileTestOptions struct {
	GroupName       string        `json:"group"`
	SpeedTestMode   string        `json:"speedtestMode"` // speedonly pingonly all
	PingMethod      string        `json:"pingMethod"`    // googleping
	SortMethod      string        `json:"sortMethod"`    // speed rspeed ping rping
	Concurrency     int           `json:"concurrency"`
	TestMode        int           `json:"testMode"` // 2: ALLTEST 3: RETEST
	TestIDs         []int         `json:"testids"`
	Timeout         time.Duration `json:"timeout"`
	Links           []string      `json:"links"`
	Subscription    string        `json:"subscription"`
	Language        string        `json:"language"`
	FontSize        int           `json:"fontSize"`
	Theme           string        `json:"theme"`
	GeneratePicMode int           `json:"generatePicMode"` // 0: base64 1:file path 2: no pic
}

type TestResult

type TestResult struct {
	TotalTraffic string `json:"totalTraffic"`
	TotalTime    string `json:"totalTime"`
	Language     string `json:"language"`
	FontSize     int    `json:"fontSize"`
	Theme        string `json:"theme"`
	// SortMethod   string       `json:"sortMethod"`
	Nodes render.Nodes `json:"nodes"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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