config

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Copyright 2022 gdy, 272288813@qq.com

Copyright 2022 gdy, 272288813@qq.com

Copyright 2022 gdy, 272288813@qq.com

Copyright 2022 gdy, 272288813@qq.com

Index

Constants

This section is empty.

Variables

View Source
var DefaultIPv4DNSServerList = []string{
	"1.1.1.1:53",
	"1.2.4.8:53",
	"8.8.8.8:53",
	"9.9.9.9:53",
	"8.8.4.4:53",
	"114.114.114.114:53",
	"223.5.5.5:53",
	"223.6.6.6:53",
	"101.226.4.6:53",
	"218.30.118.6:53",
	"119.28.28.28:53",
}
View Source
var DefaultIPv6DNSServerList = []string{
	"[2001:4860:4860::8888]:53",
	"[2001:4860:4860::8844]:53",
	"[2606:4700:4700::64]:53",
	"[2606:4700:4700::6400]:53",
	"[240C::6666]:53",
	"[240C::6644]:53",
	"[2402:4e00::]:53",

	"[240e:4c:4008::1]:53",
	"[240e:4c:4808::1]:53",
	"[2408:8899::8]:53",
	"[2408:8888::8]:53",
	"[2409:8088::a]:53",
	"[2409:8088::b]:53",
	"[2001:dc7:1000::1]:53",
	"[2400:da00::6666]:53",
}

Functions

func BlackListAdd

func BlackListAdd(ip string, activelifeDuration int32) (string, error)

func BlackListDelete

func BlackListDelete(ip string) error

func BlackListFlush

func BlackListFlush(lock bool) error

func CheckDDNSTaskAvalid

func CheckDDNSTaskAvalid(task *DDNSTask) error

func CheckTCPPortAvalid

func CheckTCPPortAvalid(port int) bool

func DDNSTaskListAdd

func DDNSTaskListAdd(task *DDNSTask) error

func DDNSTaskListConfigureCheck added in v1.2.1

func DDNSTaskListConfigureCheck()

func DDNSTaskListDelete

func DDNSTaskListDelete(taskKey string) error

func DDNSTaskSetWebhookCallResult

func DDNSTaskSetWebhookCallResult(taskKey string, result bool, message string)

func EnableDDNSTaskByKey

func EnableDDNSTaskByKey(taskKey string, enable bool) error

func FlushLoginRandomKey

func FlushLoginRandomKey()

func GetAuthAccount

func GetAuthAccount() map[string]string

func GetConfigureBytes added in v1.1.8

func GetConfigureBytes() []byte

func GetLoginRandomKey

func GetLoginRandomKey() string

func GetRunMode

func GetRunMode() string

func GetVersion

func GetVersion() string

func InitAppInfo

func InitAppInfo(version, date string)

func LoadDefault

func LoadDefault(proxyCountLimit int64,
	adminWebListenPort int,
	globalMaxConnections int64)

func Read

func Read(filePath string) (err error)

func SafeCheck

func SafeCheck(mode, ip string) bool

func Save

func Save() (err error)

func SetBaseConfigure

func SetBaseConfigure(conf *BaseConfigure) error

保存基础配置

func SetConfig added in v1.1.8

func SetConfig(p *ProgramConfigure) error

func SetConfigRuleList

func SetConfigRuleList(ruleList *[]ConfigureRelayRule)

func SetDDNSConfigure

func SetDDNSConfigure(conf *DDNSConfigure) error

func SetRunMode

func SetRunMode(mode string)

func SetVersion

func SetVersion(v string)

func SetWhiteListBaseConfigure

func SetWhiteListBaseConfigure(activelifeDuration int32, url, account, password string) error

func UpdateTaskToDDNSTaskList

func UpdateTaskToDDNSTaskList(taskKey string, task DDNSTask) error

func WhiteListAdd

func WhiteListAdd(ip string, activelifeDuration int32) (string, error)

func WhiteListDelete

func WhiteListDelete(ip string) error

func WhiteListFlush

func WhiteListFlush(lock bool) error

Types

type AppInfo

type AppInfo struct {
	AppName   string
	Version   string
	OS        string
	ARCH      string
	Date      string
	RunTime   string
	GoVersion string
}

func GetAppInfo

func GetAppInfo() *AppInfo

type BaseConfigure

type BaseConfigure struct {
	AdminWebListenPort   int    `json:"AdminWebListenPort"`   //管理后台端口
	ProxyCountLimit      int64  `json:"ProxyCountLimit"`      //全局代理数量限制
	AdminAccount         string `json:"AdminAccount"`         //登录账号
	AdminPassword        string `json:"AdminPassword"`        //登录密码
	AllowInternetaccess  bool   `json:"AllowInternetaccess"`  //允许外网访问
	GlobalMaxConnections int64  `json:"GlobalMaxConnections"` //全局最大连接数
}

func GetBaseConfigure

func GetBaseConfigure() BaseConfigure

type BlackListConfigure

type BlackListConfigure struct {
	BlackList []BlackListItem `json:"BlackList"` //黑名单列表
}

type BlackListItem

type BlackListItem WhiteListItem

func DeleteBlackListlice

func DeleteBlackListlice(a []BlackListItem, deleteIndex int) []BlackListItem

func GetBlackList

func GetBlackList() []BlackListItem

type ConfigureRelayRule

type ConfigureRelayRule struct {
	Name         string                `json:"Name"`
	Configurestr string                `json:"Configurestr"`
	Enable       bool                  `json:"Enable"`
	Options      base.RelayRuleOptions `json:"Options"`
}

type DDNSConfigure

type DDNSConfigure struct {
	Enable                 bool `json:"Enable"`
	HttpClientSecureVerify bool `json:"HttpClientSecureVerify"`
	FirstCheckDelay        int  `json:"FirstCheckDelay"` //首次检查延迟时间
	Intervals              int  `json:"Intervals"`
}

func GetDDNSConfigure

func GetDDNSConfigure() DDNSConfigure

type DDNSTask

type DDNSTask struct {
	TaskName string `json:"TaskName"`
	TaskKey  string `json:"TaskKey"` //添加任务时随机生成,方便管理任务(修改删除)
	//规则类型 IPv4/IPv6
	TaskType string `json:"TaskType"`
	Enable   bool

	GetType      string    `json:"GetType"`
	URL          []string  `json:"URL"`
	NetInterface string    `json:"NetInterface"`
	IPReg        string    `json:"IPReg"`
	Domains      []string  `json:"Domains"`
	DNS          DNSConfig `json:"DNS"`
	Webhook
	TTL               string `json:"TTL"`
	HttpClientTimeout int    `json:"HttpClientTimeout"`
}

func DeleteDDNSTaskListlice

func DeleteDDNSTaskListlice(a []DDNSTask, deleteIndex int) []DDNSTask

func GetDDNSTaskByKey

func GetDDNSTaskByKey(taskKey string) *DDNSTask

func GetDDNSTaskConfigureList added in v1.2.1

func GetDDNSTaskConfigureList() []*DDNSTask

type DNSCallback

type DNSCallback struct {
	URL                                string   `json:"URL"`    //请求地址
	Method                             string   `json:"Method"` //请求方法
	Headers                            []string `json:"Headers"`
	RequestBody                        string   `json:"RequestBody"`
	Server                             string   `json:"Server"`                             //预设服务商
	DisableCallbackSuccessContentCheck bool     `json:"DisableCallbackSuccessContentCheck"` //禁用成功调用返回检测
	CallbackSuccessContent             []string `json:"CallbackSuccessContent"`             //接口调用成功包含内容
}

type DNSConfig

type DNSConfig struct {
	// 名称。如:alidns,webhook
	Name                    string      `json:"Name"`
	ID                      string      `json:"ID"`
	Secret                  string      `json:"Secret"`
	ForceInterval           int         `json:"ForceInterval"`       //(秒)即使IP没有变化,到一定时间后依然强制更新或先DNS解析比较IP再更新
	ResolverDoaminCheck     bool        `json:"ResolverDoaminCheck"` //调用callback同步前先解析一次域名,如果IP相同就不同步
	DNSServerList           []string    `json:"DNSServerList"`       //DNS服务器列表
	Callback                DNSCallback `json:"Callback"`
	HttpClientProxyType     string      `json:"HttpClientProxyType"`     //http client代理服务器设置
	HttpClientProxyAddr     string      `json:"HttpClientProxyAddr"`     //代理服务器IP
	HttpClientProxyUser     string      `json:"HttpClientProxyUser"`     //代理用户
	HttpClientProxyPassword string      `json:"HttpClientProxyPassword"` //代理密码
}

DNSConfig DNS配置

type ProgramConfigure

type ProgramConfigure struct {
	BaseConfigure      BaseConfigure        `json:"BaseConfigure"`
	RelayRuleList      []ConfigureRelayRule `json:"RelayRuleList"`
	WhiteListConfigure WhiteListConfigure   `json:"WhiteListConfigure"`
	BlackListConfigure BlackListConfigure   `json:"BlackListConfigure"`
	DDNSConfigure      DDNSConfigure        `json:"DDNSConfigure"` //DDNS 参数设置
	DDNSTaskList       []DDNSTask           `json:"DDNSTaskList"`
}

func GetConfig

func GetConfig() *ProgramConfigure

type Webhook

type Webhook struct {
	WebhookEnable                             bool     `json:"WebhookEnable"`          //Webhook开关
	WebhookCallOnGetIPfail                    bool     `json:"WebhookCallOnGetIPfail"` //获取IP失败时触发Webhook 开关
	WebhookURL                                string   `json:"WebhookURL"`
	WebhookMethod                             string   `json:"WebhookMethod"`
	WebhookHeaders                            []string `json:"WebhookHeaders"`
	WebhookRequestBody                        string   `json:"WebhookRequestBody"`
	WebhookDisableCallbackSuccessContentCheck bool     `json:"WebhookDisableCallbackSuccessContentCheck"` //禁用成功调用返回检测
	WebhookSuccessContent                     []string `json:"WebhookSuccessContent"`                     //接口调用成功包含的内容
	WebhookProxy                              string   `json:"WebhookProxy"`                              //使用DNS代理设置  ""表示禁用,"dns"表示使用dns的代理设置
	WebhookProxyAddr                          string   `json:"WebhookProxyAddr"`                          //代理服务器IP
	WebhookProxyUser                          string   `json:"WebhookProxyUser"`                          //代理用户
	WebhookProxyPassword                      string   `json:"WebhookProxyPassword"`                      //代理密码
}

type WhiteListBaseConfigure

type WhiteListBaseConfigure struct {
	URL                string `json:"URL"`
	ActivelifeDuration int32  `json:"ActivelifeDuration"` //有效期限,小时
	BasicAccount       string `json:"BasicAccount"`
	BasicPassword      string `json:"BasicPassword"`
}

func GetWhiteListBaseConfigure

func GetWhiteListBaseConfigure() WhiteListBaseConfigure

type WhiteListConfigure

type WhiteListConfigure struct {
	BaseConfigure WhiteListBaseConfigure `json:"BaseConfigure"`
	WhiteList     []WhiteListItem        `json:"WhiteList"` //白名单列表
}

type WhiteListItem

type WhiteListItem struct {
	IP            string `json:"IP"`
	EffectiveTime string `json:"Effectivetime"` //有效时间
}

func DeleteWhiteListlice

func DeleteWhiteListlice(a []WhiteListItem, deleteIndex int) []WhiteListItem

func GetWhiteList

func GetWhiteList() []WhiteListItem

Jump to

Keyboard shortcuts

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