config

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2018 License: MIT Imports: 17 Imported by: 47

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ModeMapping is a mapping for Mode enum
	ModeMapping = map[string]Mode{
		"Global": Global,
		"Rule":   Rule,
		"Direct": Direct,
	}
)

Functions

func Init

func Init()

Init prepare necessary files

Types

type Config

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

Config is clash config manager

func Instance

func Instance() *Config

Instance return singleton instance of Config

func (*Config) General

func (c *Config) General() General

General return clash general config

func (*Config) Parse

func (c *Config) Parse() error

Parse config

func (*Config) Proxies

func (c *Config) Proxies() map[string]C.Proxy

Proxies return proxies of clash

func (*Config) Report

func (c *Config) Report() chan<- interface{}

Report return a channel for collecting report message

func (*Config) Rules

func (c *Config) Rules() []C.Rule

Rules return rules of clash

func (*Config) SetLogLevel

func (c *Config) SetLogLevel(level C.LogLevel)

SetLogLevel change log level of clash

func (*Config) SetMode

func (c *Config) SetMode(mode Mode)

SetMode change mode of clash

func (*Config) Subscribe

func (c *Config) Subscribe() observable.Subscription

Subscribe config stream

func (*Config) UpdateGeneral

func (c *Config) UpdateGeneral(general General)

UpdateGeneral dispatch update event

func (*Config) UpdateProxy

func (c *Config) UpdateProxy(pc ProxyConfig)

UpdateProxy dispatch update proxy event

func (*Config) UpdateRules

func (c *Config) UpdateRules() error

UpdateRules is a function for hot reload rules

type Event

type Event struct {
	Type    string
	Payload interface{}
}

Event is event of clash config

type General

type General struct {
	Port      int
	SocksPort int
	RedirPort int
	AllowLan  bool
	Mode      Mode
	LogLevel  C.LogLevel
}

General config

type Mode

type Mode int
const (
	Global Mode = iota
	Rule
	Direct
)

func (Mode) String

func (m Mode) String() string

type ProxyConfig

type ProxyConfig struct {
	Port      *int
	SocksPort *int
	RedirPort *int
	AllowLan  *bool
}

ProxyConfig is update proxy schema

Jump to

Keyboard shortcuts

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