wormhole

package module
v0.0.0-...-c465d95 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2021 License: MIT Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

coredns_wormhole_plugin

Coredns Plugin

Documentation

Overview

* @Author: Charley * @Date: 2021-08-16 18:02:04 * @LastEditors: Charley * @LastEditTime: 2021-08-19 10:09:28 * @FilePath: /coredns/plugin/wormhole/clash_rule_file.go * @Description: clash订阅文件的Yaml模型

* @Author: Charley * @Date: 2021-08-18 16:21:34 * @LastEditors: Charley * @LastEditTime: 2021-08-23 11:43:36 * @FilePath: /coredns/plugin/wormhole/constant.go * @Description: 常量定义

* @Author: Charley * @Date: 2021-08-18 15:37:45 * @LastEditors: Charley * @LastEditTime: 2021-08-20 17:22:52 * @FilePath: /coredns/plugin/wormhole/defaults.go * @Description: 默认定义

* @Author: Charley * @Date: 2021-08-18 17:45:45 * @LastEditors: Charley * @LastEditTime: 2021-08-20 14:18:57 * @FilePath: /coredns/plugin/wormhole/load_http_list.go * @Description: 加载订阅文件

* @Author: Charley * @Date: 2021-08-20 14:54:48 * @LastEditors: Charley * @LastEditTime: 2021-08-20 17:36:20 * @FilePath: /coredns/plugin/wormhole/policy.go * @Description: 负载顺序

* @Author: Charley * @Date: 2021-08-17 17:30:46 * @LastEditors: Charley * @LastEditTime: 2021-08-20 15:32:12 * @FilePath: /coredns/plugin/wormhole/proxy.go * @Description: 转发代理

* @Author: Charley * @Date: 2021-08-20 17:25:57 * @LastEditors: Charley * @LastEditTime: 2021-08-20 17:26:41 * @FilePath: /coredns/plugin/forward/query_model.go * @Description: dns 查询模型

* @Author: Charley * @Date: 2021-08-23 09:56:26 * @LastEditors: Charley * @LastEditTime: 2021-08-23 11:49:06 * @FilePath: /coredns/plugin/wormhole/routeros.go * @Description: ROS 相关定义

* @Author: Charley * @Date: 2021-08-17 10:43:03 * @LastEditors: Charley * @LastEditTime: 2021-08-20 09:15:08 * @FilePath: /coredns/plugin/wormhole/rule.go * @Description: 匹配规则定义

* @Author: Charley * @Date: 2021-08-20 09:14:33 * @LastEditors: Charley * @LastEditTime: 2021-08-20 14:48:10 * @FilePath: /coredns/plugin/wormhole/rule_group.go * @Description: 规则组

* @Author: Charley * @Date: 2021-08-17 08:57:54 * @LastEditors: Charley * @LastEditTime: 2021-08-19 16:35:35 * @FilePath: /coredns/plugin/wormhole/rule_type.go * @Description: 匹配规则类型

* @Author: Charley * @Date: 2021-08-13 11:48:18 * @LastEditors: Charley * @LastEditTime: 2021-08-23 10:29:20 * @FilePath: /coredns/plugin/wormhole/setup.go * @Description: 配置读取配置文件初始化插件

* @Author: Charley * @Date: 2021-08-13 11:53:13 * @LastEditors: Charley * @LastEditTime: 2021-08-23 11:26:49 * @FilePath: /coredns/plugin/wormhole/wormhole.go * @Description: 插件主题结构

* @Author: Charley * @Date: 2021-08-18 15:26:38 * @LastEditors: Charley * @LastEditTime: 2021-08-23 11:26:06 * @FilePath: /coredns/plugin/wormhole/wormhole_config.go * @Description: 配置模型定义

Index

Constants

View Source
const Config_Key_DisableAutoUpdate = "DisableAutoUpdate"
View Source
const Config_Key_Domain = "Domain"
View Source
const Config_Key_DomainKeyword = "DomainKeyword"
View Source
const Config_Key_DomainSuffix = "DomainSuffix"
View Source
const Config_Key_FileRenewalInterval = "FileRenewalInterval"
View Source
const Config_Key_HttpRenewalInterval = "HttpRenewalInterval"
View Source
const Config_Key_IgnoreDomain = "IgnoreDomain"
View Source
const Config_Key_IgnoreDomainKeyword = "IgnoreDomainKeyword"
View Source
const Config_Key_IgnoreDomainSuffix = "IgnoreDomainSuffix"
View Source
const Config_Key_IgnoreList = "IgnoreList"
View Source
const Config_Key_IgnoreRegexlistRules = "IgnoreRegexlistRules"
View Source
const Config_Key_List = "List"
View Source
const Config_Key_Policy = "Policy"
View Source
const Config_Key_RegexlistRules = "RegexlistRules"
View Source
const Config_Key_RetryCount = "RetryCount"
View Source
const Config_Key_RetryInterval = "RetryInterval"
View Source
const Config_Key_RouterOS = "ROS"
View Source
const Config_Key_RouterOS_Enabled_IPV6 = "ROS_Enabled_Ipv6"
View Source
const Config_Key_RouterOS_Timeout = "ROS_Timeout"
View Source
const Config_Key_Router_Host = "Host"
View Source
const Config_Key_Router_ListName = "ListName"
View Source
const Config_Key_Router_Password = "Password"
View Source
const Config_Key_Router_Username = "Username"
View Source
const Config_List_Key_Clash = "clash"
View Source
const Config_List_Key_Dnsmasq = "dnsmasq"

Variables

This section is empty.

Functions

This section is empty.

Types

type AvgRttQueryModel

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

func NewAvgRttQueryModel

func NewAvgRttQueryModel(msg *dns.Msg, rtt, ping time.Duration, err error) AvgRttQueryModel

type ClashRuleFile

type ClashRuleFile struct {
	Payload []string
}

clash订阅文件的Yaml模型

type Policy

type Policy int
const (
	PolicyBalancing Policy = iota
	PolicyParallel
	PolicyFastTest
)

func (Policy) String

func (p Policy) String() string

type Proxy

type Proxy struct {
	Client *dns.Client
	// contains filtered or unexported fields
}

func NewProxy

func NewProxy(trans, addr string) *Proxy

func (*Proxy) Query

func (p *Proxy) Query(m *dns.Msg) (*dns.Msg, time.Duration, error)

type QueryModel

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

func NewQueryModel

func NewQueryModel(msg *dns.Msg, rtt time.Duration, err error) QueryModel

type RouterOS

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

func NewRouterOS

func NewRouterOS(cfg *RouterOSConfig) *RouterOS

func (*RouterOS) AddAddress

func (ros *RouterOS) AddAddress(msg *dns.Msg) error

type RouterOSConfig

type RouterOSConfig struct {
	Host           string
	Username       string
	Password       string
	ListName       string
	AddressTimeOut string
	Enabled_IPV6   bool
}

type Rule

type Rule interface {
	RuleType() RuleType
	Match(msg *dns.Msg) bool
	Payload() string
}

type RuleDomain

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

RuleDomain

func NewRuleDomain

func NewRuleDomain(domain string) RuleDomain

func (RuleDomain) Match

func (rd RuleDomain) Match(msg *dns.Msg) bool

func (RuleDomain) Payload

func (rd RuleDomain) Payload() string

func (RuleDomain) RuleType

func (rd RuleDomain) RuleType() RuleType

type RuleDomainKeyword

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

RuleDomainKeyword

func NewRuleDomainKeyword

func NewRuleDomainKeyword(keyword string) RuleDomainKeyword

func (RuleDomainKeyword) Match

func (rdk RuleDomainKeyword) Match(msg *dns.Msg) bool

func (RuleDomainKeyword) Payload

func (rdk RuleDomainKeyword) Payload() string

func (RuleDomainKeyword) RuleType

func (rdk RuleDomainKeyword) RuleType() RuleType

type RuleDomainSuffix

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

RuleSuffix

func NewRuleDomainSuffix

func NewRuleDomainSuffix(domain string) RuleDomainSuffix

func (RuleDomainSuffix) Match

func (rds RuleDomainSuffix) Match(msg *dns.Msg) bool

func (RuleDomainSuffix) Payload

func (rds RuleDomainSuffix) Payload() string

func (RuleDomainSuffix) RuleType

func (rds RuleDomainSuffix) RuleType() RuleType

type RuleRegex

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

RuleRegex

func NewRuleRegex

func NewRuleRegex(regex string) RuleRegex

func (RuleRegex) Match

func (rr RuleRegex) Match(msg *dns.Msg) bool

func (RuleRegex) Payload

func (rr RuleRegex) Payload() string

func (RuleRegex) RuleType

func (rr RuleRegex) RuleType() RuleType

type RuleType

type RuleType int
const (
	RuleTypeDomain RuleType = iota
	RuleTypeDomainSuffix
	RuleTypeDomainKeyword
	RuleTypeRegex
	RuleTypeSubscribeGroup
	RuleTypeStaticGroup
	RuleTypeUnknown
)

func (RuleType) String

func (r RuleType) String() string

type StaticRuleGroup

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

func NewStaticRuleGroup

func NewStaticRuleGroup(ruleGroup []Rule) StaticRuleGroup

func (StaticRuleGroup) Match

func (srg StaticRuleGroup) Match(msg *dns.Msg) bool

func (StaticRuleGroup) Payload

func (srg StaticRuleGroup) Payload() string

func (StaticRuleGroup) RuleType

func (srg StaticRuleGroup) RuleType() RuleType

type SubscribeFile

type SubscribeFile struct {
	Url string

	FileType SubscribeFileType
	// contains filtered or unexported fields
}

订阅文件

type SubscribeFileType

type SubscribeFileType int
const (
	// clash订阅的域名列表
	SubscribeFileTypeClash SubscribeFileType = iota
	// dnsmasq类型的文件列表
	SubscribeFileTypeDnsmasq
)

订阅文件类型

type SubscribeRuleGroup

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

func NewSubscribeRuleGroup

func NewSubscribeRuleGroup(subscribe SubscribeFile, ruleGroup []Rule, listRenewalRetryCount int, listRenewalRetryInterval time.Duration) SubscribeRuleGroup

func (*SubscribeRuleGroup) LastUpdateTime

func (srg *SubscribeRuleGroup) LastUpdateTime() int64

func (SubscribeRuleGroup) Match

func (srg SubscribeRuleGroup) Match(msg *dns.Msg) bool

func (SubscribeRuleGroup) Payload

func (srg SubscribeRuleGroup) Payload() string

func (SubscribeRuleGroup) RuleType

func (srg SubscribeRuleGroup) RuleType() RuleType

func (*SubscribeRuleGroup) UpdateRule

func (srg *SubscribeRuleGroup) UpdateRule() error

type Wormhole

type Wormhole struct {
	StaticRuleList       []Rule
	StaticIgnoreRuleList []Rule

	RuleList       []SubscribeRuleGroup
	IgnoreRuleList []SubscribeRuleGroup

	Next plugin.Handler
	// contains filtered or unexported fields
}

func NewWormhole

func NewWormhole() *Wormhole

func (*Wormhole) BalancingQuery

func (wh *Wormhole) BalancingQuery(r *dns.Msg) (*dns.Msg, time.Duration, error)

func (*Wormhole) FastTestQuery

func (wh *Wormhole) FastTestQuery(r *dns.Msg) (*dns.Msg, time.Duration, error)

func (*Wormhole) Name

func (wh *Wormhole) Name() string

Name implements the Handler interface.

func (*Wormhole) OnShutdown

func (c *Wormhole) OnShutdown() error

OnShutdown stops all configured proxies.

func (*Wormhole) OnStartup

func (c *Wormhole) OnStartup() (err error)

OnStartup starts a goroutines for all proxies.

func (*Wormhole) ParallelQuery

func (wh *Wormhole) ParallelQuery(r *dns.Msg) (*dns.Msg, time.Duration, error)

func (*Wormhole) QueryAndWriteMsg

func (wh *Wormhole) QueryAndWriteMsg(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

func (*Wormhole) ServeDNS

func (wh *Wormhole) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

func (*Wormhole) TestPing

func (wh *Wormhole) TestPing(address string) time.Duration

type WormholeConfig

type WormholeConfig struct {
	// 转发的dns服务器
	RemoteServers []string

	SubscribeList     []SubscribeFile // 订阅列表
	DomainList        []string        // 自定义域名列表
	DomainSuffixList  []string        // 自定义主域列表
	DomainKeywordList []string        // 自定义域名中的关键字列表
	RegexlistRules    []string        // 用于匹配的正则表达式列表

	IgnoreSubscribeList     []SubscribeFile //订阅忽略的文件列表
	IgnoreDomainList        []string        // 自定义忽略域名列表
	IgnoreDomainSuffixList  []string        // 自定义忽略主域列表
	IgnoreDomainKeywordList []string        // 自定义忽略域名中的关键字列表
	IgnoreRegexlistRules    []string        // 用于匹配忽略的正则表达式列表

	Policy string

	HttpListRenewalInterval  time.Duration //http订阅的更新间隔时间
	FileListRenewalInterval  time.Duration //本地文件更新间隔时间
	ListRenewalRetryCount    int           //遇到错误以后重试的次数
	ListRenewalRetryInterval time.Duration //遇到错误以后重试的间隔时间

	EnableAutoUpdate bool // 是否开启自动更新

	ROSConfig *RouterOSConfig
}

配置文件

Jump to

Keyboard shortcuts

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