web

package
v0.0.0-...-5f892d9 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: GPL-3.0 Imports: 27 Imported by: 1

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
	JSON_OUTPUT
	TEXT_OUTPUT
)
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 ParseLinksWithOption

func ParseLinksWithOption(message string, opt ParseOption) ([]string, error)

api

func PeekClash

func PeekClash(input string, n int) ([]string, error)

api

func ServeFile

func ServeFile(port int) error

func TestAsyncContext

func TestAsyncContext(ctx context.Context, options ProfileTestOptions) (chan render.Node, []string, error)

use as golang api

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 JSONOutput

type JSONOutput struct {
	Nodes        []render.Node      `json:"nodes"`
	Options      ProfileTestOptions `json:"options"`
	Traffic      int64              `json:"traffic"`
	Duration     string             `json:"duration"`
	SuccessCount int                `json:"successCount"`
	LinksCount   int                `json:"linksCount"`
}

type Message

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

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 PAESE_TYPE

type PAESE_TYPE int
const (
	PARSE_ANY PAESE_TYPE = iota
	PARSE_URL
	PARSE_FILE
	PARSE_BASE64
	PARSE_CLASH
	PARSE_PROFILE
)

type ParseOption

type ParseOption struct {
	Type PAESE_TYPE
}

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, trafficChan chan<- int64) (chan render.Node, error)

api render.Node contain the final test result

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"`
	Unique          bool          `json:"unique"`
	GeneratePicMode int           `json:"generatePicMode"` // 0: base64 1:pic path 2: no pic 3: json @deprecated use outputMode
	OutputMode      int           `json:"outputMode"`
}

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