clash

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Secret = ""
View Source
var Url = "http://127.0.0.1:9090"

Functions

func EasyRequest

func EasyRequest(method, route string, headers map[string]string, body map[string]interface{}) (int, []byte, error)

func EnableConfigs added in v0.0.2

func EnableConfigs(path string) error

EnableConfigs 这个接口不会影响 external-controller 和 secret 的值

func EnableGeo added in v0.0.2

func EnableGeo() error

EnableGeo 更新 GEO 数据库,因更新后会自动重载一次配置

func GetLogs

func GetLogs(level LogLevel) (chan *Log, error)

func GetMemory added in v0.0.2

func GetMemory(handler func(memory *Memory) (stop bool)) error

GetMemory 获取实时内存占用,单位 kb

func GetProxies

func GetProxies() (map[string]*Proxies, error)

func GetTraffic

func GetTraffic(handler func(traffic *Traffic) (stop bool)) error

func HandleStreamResp

func HandleStreamResp(resp *http.Response, handler func(line []byte) (stop bool))

func IsTunEnabled added in v0.0.4

func IsTunEnabled(raw RawConfigs) (bool, error)

func Request

func Request(method, route string, headers map[string]string, body io.Reader) (*http.Response, error)

func Restart added in v0.0.2

func Restart() error

Restart 重启内核

func SetConfigs added in v0.0.2

func SetConfigs(raw RawConfigs) error

SetConfigs 更新基本配置,只传入需要修改的配置即可,传入的数据需以 json 格式传入

命令行调用示例:curl ${controller-api}/configs -X PATCH -d '{"mixed-port": 7890}' 参数示例:

raw := RawConfigs{
  "port":       2333,
  "socks-port": 2334,
  }

func SetSecret added in v0.0.2

func SetSecret(secret string)

func SetSecretFromEnv added in v0.0.2

func SetSecretFromEnv(name string) error

func SetSecretFromFile added in v0.0.2

func SetSecretFromFile(file string) error

func SetSecrete

func SetSecrete(secret string)

func SetSecreteFromEnv

func SetSecreteFromEnv(name string) error

func SetSecreteFromFile

func SetSecreteFromFile(file string) error

func SetTunEnable added in v0.0.4

func SetTunEnable(enable bool) error

func SetURL

func SetURL(url string)

func Shutdown added in v0.0.7

func Shutdown() error

Shutdown 关闭内核

待内核合并 PR 后可用

func SwitchProxy

func SwitchProxy(selector, name string) error

func UnmarshalRequest

func UnmarshalRequest(method, route string, headers map[string]string, body map[string]interface{}, obj interface{}) error

Types

type History

type History struct {
	Time      string `json:"time"`
	Delay     int    `json:"delay"`
	MeanDelay int    `json:"meanDelay"`
}

type Log

type Log struct {
	Type    string `json:"type"`
	Socket  string `json:"socket"`
	Message string `json:"message"`
	LAddr   string `json:"local_addr"`
	RAddr   string `json:"remote_addr"`
	Mode    string `json:"mode"`
	Rule    string `json:"rule"`
	Proxy   string `json:"proxy"`
	Error   string `json:"error"`
}

type LogLevel

type LogLevel string
const (
	LevelError   LogLevel = "error"
	LevelInfo    LogLevel = "info"
	LevelWarning LogLevel = "warning"
	LevelDebug   LogLevel = "debug"
)

type LogMessage

type LogMessage struct {
	Type    string `json:"type"`
	Payload string `json:"payload"`
}

func (*LogMessage) ToLog

func (msg *LogMessage) ToLog() *Log

type Memory added in v0.0.2

type Memory struct {
	Inuse   uint64 `json:"inuse"`
	OsLimit uint64 `json:"oslimit"`
}

Memory 内存占用,单位 kb

示例: {"inuse":111673344,"oslimit":0}

type Ports added in v0.0.6

type Ports struct {
	Port       int `json:"port"`
	SocksPort  int `json:"socks-port"`
	RedirPort  int `json:"redir-port"`
	TProxyPort int `json:"tproxy-port"`
	MixedPort  int `json:"mixed-port"`
}

func GetPorts added in v0.0.6

func GetPorts(raw RawConfigs) (Ports, error)

获取端口信息

type Proxies

type Proxies struct {
	All     []string   `json:"all"`
	History []*History `json:"history"`
	Name    string     `json:"name"`
	Now     string     `json:"now"`
	Type    string     `json:"type"`
	UDP     bool       `json:"udp"`
}

type Proxy

type Proxy struct {
	History []*History `json:"history"`
	Name    string     `json:"name"`
	Type    string     `json:"type"`
	UDP     bool       `json:"udp"`
}

func GetProxyMessage

func GetProxyMessage(name string) (*Proxy, error)

type ProxyDelay

type ProxyDelay struct {
	Delay     int    `json:"delay"`
	MeanDelay int    `json:"meanDelay"`
	Error     string `json:"error"`
	Message   string `json:"message"`
}

func GetProxyDelay

func GetProxyDelay(name string, url string, timeout int) (*ProxyDelay, error)

type RawConfigs added in v0.0.4

type RawConfigs map[string]interface{}

RawConfigs (map 指针)存储 GetConfigs() 获取的 Clash 配置

func GetConfigs added in v0.0.2

func GetConfigs() (RawConfigs, error)

type Rule

type Rule struct {
	Type    string `json:"type"`
	Payload string `json:"payload"`
	Proxy   string `json:"proxy"`
}

func GetRules

func GetRules() ([]*Rule, error)

type Traffic

type Traffic struct {
	Up   uint64 `json:"up"`
	Down uint64 `json:"down"`
}

type Version

type Version struct {
	Meta    bool   `json:"meta"`
	Version string `json:"version"`
}

Version Clash 版本信息

func GetVersion

func GetVersion() (*Version, error)

GetVersion 获取 Clash 版本信息

Jump to

Keyboard shortcuts

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