utils

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAuthHeaderNotRight = errors.New("remote: auth header is not right")
	ErrHeaderNotRight     = errors.New("header format is not valid")
	ErrAuthNotRight       = errors.New("local: auth is not right")
)

Functions

func DialTCP added in v0.0.4

func DialTCP(address string, dnsserver string) (net.Conn, error)

通过指定的dnsserver查询dns, 返回和address的TCP连接 e.g. address www.baidu.com dnsserver 8.8.8.8:53

Windows下,会直接使用调用系统的dns查询,不会生效
其它系统,会从8.8.8.8:53查询到对应ip,并与之建立TCP连接

以下为解释: https://pkg.go.dev/net#hdr-Name_Resolution Windows下总是会调用C库,所以无法指定

https://github.com/golang/go/issues/22846 容器里需要注意新建 /etc/nsswitch.conf文件

	echo "hosts: files dns" > /etc/nsswitch.conf

	Android Termux, 如果不指定dnsserver, 则默认会去读取/etc/resolv.conf
 问题是该文件不存在, 或者是没有权限读取, 默认dns server [::1]:53, 那么肯定失败

echo "nameserver 114.114.114.114" > /etc/resolv.conf

func DialTCPContext added in v0.0.11

func DialTCPContext(ctx context.Context, address string, dnsserver string) (net.Conn, error)

func HandleError

func HandleError()

func Pip

func Pip(from Connection, to Connection)

func RandKey

func RandKey() string

func ReadHeader

func ReadHeader(conn net.Conn) (string, error)

Types

type Connection added in v0.0.6

type Connection interface {
	Read(b []byte) (n int, err error)

	Write(b []byte) (n int, err error)

	Close() error
}

type TlsCert added in v0.0.12

type TlsCert struct {
	CertPath string
	KeyPath  string

	AttempDuration time.Duration
	// contains filtered or unexported fields
}

func (*TlsCert) CheckCert added in v0.0.12

func (t *TlsCert) CheckCert(now *time.Time)

func (*TlsCert) GetCertFunc added in v0.0.12

func (t *TlsCert) GetCertFunc() func(*tls.ClientHelloInfo) (*tls.Certificate, error)

func (*TlsCert) LoadCert added in v0.0.12

func (t *TlsCert) LoadCert()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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