netchan

package
v0.5.14 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2019 License: GPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const LocalConnGoCount = 5 // 本地连接时使用的线程数(只对dns解析结果生效)

Variables

View Source
var HostsDns *hostsDns
View Source
var SAFE_PORET_LIST map[int]int = map[int]int{
	21:   0,
	22:   0,
	23:   0,
	25:   0,
	53:   0,
	80:   0,
	110:  0,
	443:  -500,
	465:  -500,
	993:  -500,
	995:  -500,
	3389: 0,
}

端口需要的安全等级 例如 80 端口的安全等级是0,表示 -100 的 ip 不能用在 80 端口的访问上面。 主要目的是通过一些渠道获得的ip不可靠,不建议 80 之类的不安全的协议使用不可靠的 ip。

Functions

func ChanDialTimeout

func ChanDialTimeout(dial DialTimeouter, dialCredit int, connChan chan ConnRes, exitChan chan int, dnsResolve bool, userData interface{}, filter DialFilterer, network, address string, timeout time.Duration) (err error)

将标准的 Dial 接口转换成 Chan 返回。

可以通过选项指定是否本地dns解析,使用本地解析时会同时使用获得的多个ip连接,同样通过 chan 返回所有建立的连接。

filter 过滤器,确定是否使用dns解析得到的ip

func LoadHostsStream added in v0.4.0

func LoadHostsStream(f io.Reader) (d map[string][]string, err error)

载入 hosts 不处理泛解析及正则解析 由于不知道之后由什么处理,并不会进行小写转换。 不会检查 ip 格式是不是合法,计划不合法的ip 当作 CNAME 处理。

func NewDialFilter

func NewDialFilter(port_list map[int]int) *dialFilter

func NewDnsDns added in v0.5.10

func NewDnsDns() *dnsDns

func NewHostsDns added in v0.4.0

func NewHostsDns(c *DnschanHostsConfig) (*hostsDns, error)

func NewHttpDns

func NewHttpDns(u string) (*httpDNS, error)

Types

type ConfigDnsServer added in v0.5.10

type ConfigDnsServer struct {
	Addr   string
	Credit int
}

type ConnRes

type ConnRes struct {
	Dial       DialTimeouter
	Conn       net.Conn
	Ping       time.Duration // 连接耗时
	DomainAddr string
	IpAddr     string //当使用DNS解析时,保存着 ip:端口 格式的地址
	UserData   interface{}
}

type DialFilterer

type DialFilterer interface {
	// DialFilter 连接过滤器
	// 只有返回值是 True 的才会执行连接。
	// 主要目的是某些线路、某些 dns 解析结果不可靠,对于不可靠的线路及dns解析结果只用于 https 、smtp ssl 等自带验证的协议。
	// 参数: host、ip、port 为连接目标
	//       dialCredit 为 线路 的可靠程度
	//       ipCredit 为 IP 的可靠程度。
	//                调用方不进行dns解析时将=dialCredit。
	DialFilter(network, host, ip string, port int, dialCredit, ipCredit int) bool
}

type DialTimeouter

type DialTimeouter interface {
	DialTimeout(network, address string, timeout time.Duration) (net.Conn, error)
}

type DnsQuery

type DnsQuery struct {
	// 返回dns查询结果
	RecordChan chan *DnsRecord

	Domain string
	// contains filtered or unexported fields
}

表示dns 查询

func NewDnsQuery

func NewDnsQuery(domain string) *DnsQuery

返回 DNS 记录信道及取消信道

func (*DnsQuery) Stop

func (dq *DnsQuery) Stop()

type DnsRecord

type DnsRecord struct {
	Ip     string //地址
	Credit int    //信誉 0 是本机标准的DNS解析结果 越高越可信
}

表示 DNS 记录

type DnschanHostsConfig added in v0.4.0

type DnschanHostsConfig struct {
	BashPath      string        // hosts 路径前缀
	CheckInterval time.Duration //http检测间隔
	Hostss        []*DnschanHostsConfigHosts
}

配置(对外)

type DnschanHostsConfigHosts added in v0.4.0

type DnschanHostsConfigHosts struct {
	Path           string `required:"true"` // host 文件路径、本地或远程url(http、https)
	UpdateInterval string `default:"24h"`   // 更新间隔、当使用远程 url 时检查更新间隔
	Credit         int    `default:"0"`     // dns信誉
	Type           string `default:"base"`
}

type HttpQueryRes

type HttpQueryRes struct {
	Domain  string
	Status  int
	Message string
	Ips     []*IpRecord
}

type IpRecord

type IpRecord struct {
	Ip     string
	Ping   time.Duration
	Credit int //信誉
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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