common

package
v0.0.0-...-ab66116 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const Name = "clash"

Name used in $HOME/.config/${Name}

Variables

This section is empty.

Functions

func GetCfgPath

func GetCfgPath() (string, error)

func Init

func Init() error

Init create config if not exist

func MakeRequest

func MakeRequest(s Server) *resty.Client

MakeRequest compose a resty.Client that send request to given Server

func MakeWebsocket

func MakeWebsocket(s Server, path string) (*websocket.Conn, error)

func ReadMap

func ReadMap(mapping []Field) (map[string]string, error)

func SaveCfg

func SaveCfg(cfg *Config) error

Types

type Config

type Config struct {
	Servers  map[string]Server `toml:"servers"`
	Selected string            `toml:"selected"`
}

func ReadCfg

func ReadCfg() (*Config, error)

type Field

type Field struct {
	Name   string
	Prompt promptui.Prompt
}

type HTTPError

type HTTPError struct {
	Message string `json:"message"`
}

type Node

type Node struct {
	Text        string
	Description string
	Resolver    func(params []string) (int, []Node)
	Children    []Node
}

type Server

type Server struct {
	Host   string `toml:"host"`
	Port   string `toml:"port"`
	Secret string `toml:"secret"`
	HTTPS  bool   `toml:"https"`
}

func GetCurrentServer

func GetCurrentServer(cfg *Config) (string, *Server, error)

func (Server) URL

func (s Server) URL() url.URL

func (Server) WebsocketURL

func (s Server) WebsocketURL() url.URL

Jump to

Keyboard shortcuts

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