netx

package
v0.0.0-...-45da7de Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RootCaName  = "root.pem"
	RootKeyName = "root.key"
)

Functions

func IsLocalAddr

func IsLocalAddr(addr string) (bool, error)

IsLocalAddr 判断addr(ip,域名等)是否指向本机 由于IP可能经由 iptable 指向,或者可能是域名,或者其它,不能直接与本机IP做对比 本方法构建一个临时的HTTP服务,然后使用指定的addr去连接改HTTP服务,如果能连接上,说明addr是指向本机的地址

func JoinHostPort

func JoinHostPort(host string, port int) string

JoinHostPort make IP:Port for ipv4/domain or [IPv6]:Port for ipv6.

func NewProxyDialer

func NewProxyDialer(proxyUrl string) (proxy.Dialer, error)

NewProxyDialer based on proxy url.

func PathExists

func PathExists(path string) bool

Types

type CertFiles

type CertFiles struct {
	Cert string
	Key  string
}

func LoadCerts

func LoadCerts(caRoot string) *CertFiles

LoadCerts loads an existing certificate and key or creates new. CaRoot can be {dir}:{name}, like "" will default to .cert directory ":server" will find server.key and server.pem in .cert directory "." will default to xxx.key and xxx.pem in current directory ".:server" will find server.key and server.pem in . directory

func ParseCerts

func ParseCerts(certPath string) (string, *CertFiles, error)

ParseCerts tries to parse the certificate and key in the certPath.

type MkCert

type MkCert struct {
	Pkcs12, Ecdsa, Client, Silent bool
	KeyFile, CertFile, P12File    string
	CaRoot, CsrPath               string
	RootYears, CertYears          int
	// contains filtered or unexported fields
}

func (*MkCert) Run

func (m *MkCert) Run(hosts ...string) error

type StatConn

type StatConn struct {
	net.Conn
	Reads, Writes *uint64
}

StatConn statistics read and write bytes for net connection.

func NewStatConn

func NewStatConn(c net.Conn) *StatConn

func NewStatConnReadWrite

func NewStatConnReadWrite(c net.Conn, reads, writes *uint64) *StatConn

func (*StatConn) Read

func (s *StatConn) Read(b []byte) (n int, err error)

Read reads bytes from net connection.

func (StatConn) ReadBytes

func (s StatConn) ReadBytes() uint64

func (*StatConn) Write

func (s *StatConn) Write(b []byte) (n int, err error)

Write writes bytes to net.

func (StatConn) WriteBytes

func (s StatConn) WriteBytes() uint64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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