pkg

package
v0.0.0-...-ff20c23 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: GPL-3.0-or-later

SPDX-License-Identifier: GPL-3.0-or-later

defaults.go +build !debug

SPDX-License-Identifier: GPL-3.0-or-later

SPDX-License-Identifier: GPL-3.0-or-later

Index

Constants

View Source
const (
	// Default template for run command
	DEF_Run_Template = `` /* 266-byte string literal not displayed */

	// Default template for test command
	DEF_Test_Template = `
         {
              "log": {"loglevel": "none"}
         }`
)
View Source
const (
	// Default test endpoint
	Test_Endpoint_0 = "http://www.google.com"
	// IP address API test endpoints
	Test_Endpoint_1 = "http://api4.ipify.org"
	Test_Endpoint_2 = "http://v4.api.ipinfo.io/ip"
	Test_Endpoint_3 = "http://check-host.net/ip"
	Test_Endpoint_4 = "http://ipv4.icanhazip.com"
)

Variables

View Source
var (
	// Timeout to fail a test
	TestTimeout time.Duration = 10 * time.Second
	// Maximum number of endpoints to test
	TestCount int = 3

	TestEndpoints = []string{
		Test_Endpoint_0,
		Test_Endpoint_1, Test_Endpoint_2, Test_Endpoint_3, Test_Endpoint_4,
	}
)

Functions

func GetFormatByExtension

func GetFormatByExtension(filename string) string

Types

type V2utils

type V2utils struct {
	CFG *conf.Config

	Xray_instance *core.Instance // xray-core client instance
	// contains filtered or unexported fields
}

func (V2utils) Apply_URL

func (v2 V2utils) Apply_URL(url string) error

func (*V2utils) Apply_template

func (v2 *V2utils) Apply_template(file_path string) error

Applies the template v2.template_path to v2.CFG

func (*V2utils) Apply_template_byio

func (v2 *V2utils) Apply_template_byio(rio io.Reader) error

func (*V2utils) Apply_template_bystr

func (v2 *V2utils) Apply_template_bystr(template string) error

func (V2utils) CFG_Out

func (v2 V2utils) CFG_Out(w io.Writer, indention bool) error

Makes json output of v2.CFG, on @w

func (V2utils) Convert_conf2url

func (v2 V2utils) Convert_conf2url() (string, error)

URL generator

func (V2utils) CustomDial

func (v2 V2utils) CustomDial(ctx context.Context, network, addr string) (xnet.Conn, error)

This will utilize the xray-core Dial function (DialContext compatible)

func (*V2utils) Exec_Xray

func (v2 *V2utils) Exec_Xray() error

Run_Xray (blocking)

func (*V2utils) HasTemplate

func (v2 *V2utils) HasTemplate() bool

func (*V2utils) Init_Outbound_byURL

func (v2 *V2utils) Init_Outbound_byURL(url string) error

Initializes @v2.CFG.OutboundConfig by the provided proxy URL @url

func (V2utils) Kill_Xray

func (v2 V2utils) Kill_Xray()

Do NOT use v2.Xray_instance after this call

func (*V2utils) Run_Xray

func (v2 *V2utils) Run_Xray() error

Runs xray-core instance (non-blocking)

func (*V2utils) Test_CFG

func (v2 *V2utils) Test_CFG(path string) (result bool, duration int64)

Tests a config file @path

func (*V2utils) Test_URL

func (v2 *V2utils) Test_URL(url string) (result bool, duration int64)

Tests a minimal config generated by DEF_Test_Template It will not create any local listening proxy, instead it passes a simple HTTP request through the running xray-core instance @v2.Xray_instance.

func (*V2utils) UnsetTemplate

func (v2 *V2utils) UnsetTemplate()

Jump to

Keyboard shortcuts

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