util

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: AGPL-3.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GoogleDNS6 = "2001:4860:4860::8888"
	AliDNS6    = "2400:3200::1"
)
View Source
const (
	SpeedtestURL1  = "https://speed.cloudflare.com/__down?bytes=1000000"  //1MB
	SpeedtestURL10 = "https://speed.cloudflare.com/__down?bytes=10000000" //10MB
)
View Source
const ExtensionEncryptedClientHello = 0xfe0d
View Source
const KDF_HKDF_SHA384 = 0x0002
View Source
const KDF_HKDF_SHA512 = 0x0003

Variables

View Source
var TraceList = []string{
	"https://blog.cloudflare.com/cdn-cgi/trace",
	"https://developers.cloudflare.com/cdn-cgi/trace",
	"https://hostinger.com/cdn-cgi/trace",
	"https://ahrefs.com/cdn-cgi/trace",
}
View Source
var (
	UsableTestUrls = []string{
		"https://www.google.com/generate_204",
		"https://www.gstatic.com/generate_204",
		"https://www.apple.com/library/test/success.html",
		"http://www.msftconnecttest.com/connecttest.txt",
		"http://jsonplaceholder.typicode.com/posts/1",
	}
)

Functions

func ApiHandlerPing

func ApiHandlerPing(ctx context.Context, h i.Outbound, url string) (int, error)

func ApiHandlerUsable1

func ApiHandlerUsable1(ctx context.Context, h i.Outbound, url string) (bool, error)

func Curve25519Genkey

func Curve25519Genkey(StdEncoding bool, input_base64 string) (string, string, error)

func DownloadToFile

func DownloadToFile(url string, client *http.Client, dest string) error

func DownloadToMemory

func DownloadToMemory(url string, handlers []i.Handler) ([]byte, error)

func DownloadToMemoryResty

func DownloadToMemoryResty(ctx context.Context, url string, handlers ...i.Outbound) ([]byte, error)

func ExecuteECH

func ExecuteECH(serverName string) ([]byte, []byte, error)

func GenerateECHKeySet

func GenerateECHKeySet(configID uint8, domain string, kem uint16) (reality.EchConfig, []byte, error)

func GetMyIPv4

func GetMyIPv4() (string, error)

func HandlerToHttpClient

func HandlerToHttpClient(h i.FlowHandler) *http.Client

func InboundConfigToOutboundConfig

func InboundConfigToOutboundConfig(namePrefix string, inboundConfig *configs.ProxyInboundConfig,
	serverAddress string) ([]*configs.OutboundHandlerConfig, error)

func MarshalBinary

func MarshalBinary(ech reality.EchConfig) ([]byte, error)

reference github.com/OmarTariq612/goech

func MultiInboundConfigToOutboundConfig

func MultiInboundConfigToOutboundConfig(namePrefix string, inboundConfig *configs.MultiProxyInboundConfig,
	serverAddress string) ([]*configs.OutboundHandlerConfig, error)

unencrypted options will not be included in the final results. For example, unencrypted proxy protocols without security will not be included

func NICHasGlobalIPv6Address

func NICHasGlobalIPv6Address(index uint32) (bool, error)

func NICSupportIPv6Index

func NICSupportIPv6Index(index uint32) bool

func NICSupportIPv6Name

func NICSupportIPv6Name(nicName string) bool

func ParseKeyValueText

func ParseKeyValueText(text string) map[string]string

func RttTest

func RttTest(ctx context.Context, ap net.AddressPort,
	dl i.Dialer, pl i.PacketListener, ipResolver i.IPResolver) (int, error)

func Speedtest

func Speedtest(ctx context.Context, url string, h i.Outbound) int64

func TestIpv6

func TestIpv6(ctx context.Context, h i.Outbound, address string) (bool, error)

Types

type FlowHandlerToDialer

type FlowHandlerToDialer struct {
	i.FlowHandler
}

Adapt FlowHandler to Dialer

func (*FlowHandlerToDialer) Dial

type HandlerToDialerListener

type HandlerToDialerListener struct {
	PacketHandlerToListener
	FlowHandlerToDialer
}

type HandlerToProxyClient

type HandlerToProxyClient struct {
	i.Handler
}

func (*HandlerToProxyClient) Dial

func (*HandlerToProxyClient) DialWithInitialData

func (h *HandlerToProxyClient) DialWithInitialData(ctx context.Context, dst net.Destination,
	initialData []byte) (net.Conn, error)

func (*HandlerToProxyClient) ListenPacket

func (h *HandlerToProxyClient) ListenPacket(ctx context.Context, dst net.Destination) (udp.UdpConn, error)

type IPv6SupportChangeNotifier

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

func (*IPv6SupportChangeNotifier) Notify

func (n *IPv6SupportChangeNotifier) Notify()

func (*IPv6SupportChangeNotifier) Register

func (*IPv6SupportChangeNotifier) Unregister

func (n *IPv6SupportChangeNotifier) Unregister(observer i.IPv6SupportChangeObserver)

type OnIPv6SupportChangedFunc

type OnIPv6SupportChangedFunc func()

func (OnIPv6SupportChangedFunc) OnIPv6SupportChanged

func (f OnIPv6SupportChangedFunc) OnIPv6SupportChanged()

type PacketHandlerToListener

type PacketHandlerToListener struct {
	i.PacketHandler
	Target *net.Destination
}

func (*PacketHandlerToListener) ListenPacket

func (h *PacketHandlerToListener) ListenPacket(ctx context.Context, network, address string) (net.PacketConn, error)

type PacketRwToPacketConn

type PacketRwToPacketConn struct {
	udp.UdpConn
	udp.PacketReaderToReadFromer
	udp.PacketWriterToWriteToer
	// contains filtered or unexported fields
}

func (*PacketRwToPacketConn) LocalAddr

func (p *PacketRwToPacketConn) LocalAddr() net.Addr

func (*PacketRwToPacketConn) SetDeadline

func (l *PacketRwToPacketConn) SetDeadline(t time.Time) error

func (*PacketRwToPacketConn) SetReadDeadline

func (l *PacketRwToPacketConn) SetReadDeadline(t time.Time) error

func (*PacketRwToPacketConn) SetWriteDeadline

func (l *PacketRwToPacketConn) SetWriteDeadline(t time.Time) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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