v2ray

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: MulanPSL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TransportTypeTcp = iota + 1
	TransportTypeWebSocket
	TransportTypeKcp
	TransportTypeHttp2
)
View Source
const (
	TcpTypeNone = "none"
	TcpTypeHttp = "http"
)
View Source
const CmdPath = "/usr/local/bin/v2ray"
View Source
const ConfigPath = "/usr/local/etc/v2ray/config.json"
View Source
const InstallTo = "/usr/local/bin"
View Source
const SharePath = "/usr/local/share"
View Source
const SystemdPath = "/etc"

Variables

This section is empty.

Functions

func CheckExists

func CheckExists(v2rayPath string) error

CheckExists 检查系统内是否已存在V2ray

func CheckSystem

func CheckSystem(goos, goArch string) bool

CheckSystem 检查是否支持系统

func Enable

func Enable() error

Enable 设为开机启动

func GetConfig added in v1.1.0

func GetConfig(configPath string) (*vConfig, error)

GetConfig 读取配置文件

func GetDownloadUrl

func GetDownloadUrl(goos, goArch, version string) (string, error)

GetDownloadUrl 获取版本的下载链接

func GetLastReleaseVersion

func GetLastReleaseVersion() (string, error)

GetLastReleaseVersion 获取V2ray最后一个版本的版本号

func Install

func Install(goos, goArch, version, installTo, sharePath, systemdPath, configPath string) error

Install 安装指定版本

func InstallLastRelease

func InstallLastRelease() error

InstallLastRelease 安装最新版本

func IsRunning

func IsRunning() (bool, error)

IsRunning 检查是否在运行

func SetConfig

func SetConfig(configPath string, config *Config) error

SetConfig 设置V2ray配置

func Start

func Start() error

Start 启动服务

func Stop

func Stop() error

Stop 停止服务

Types

type Config

type Config struct {
	Clients []ConfigClient `json:"clients"`

	V2rayPort     int `json:"v2ray_port"`
	TransportType int `json:"transport_type"`

	Tcp struct {
		Type    string `json:"type"`
		Request struct {
			Version string         `json:"version"`
			Method  string         `json:"method"`
			Path    string         `json:"path"`
			Headers []ConfigHeader `json:"headers"`
		} `json:"request"`
		Response struct {
			Version string         `json:"version"`
			Status  string         `json:"status"`
			Reason  string         `json:"reason"`
			Headers []ConfigHeader `json:"headers"`
		} `json:"response"`
	} `json:"tcp"`
	WebSocket struct {
		Path    string         `json:"path"`
		Headers []ConfigHeader `json:"headers"`
	} `json:"web_socket"`
	Kcp struct {
		Type             string `json:"type"`
		Mtu              int    `json:"mtu"`
		Tti              int    `json:"tti"`
		UpLinkCapacity   int    `json:"uplink_capacity"`
		DownLinkCapacity int    `json:"downlink_capacity"`
		Congestion       bool   `json:"congestion"`
		ReadBufferSize   int    `json:"read_buffer_size"`
		WriteBufferSize  int    `json:"write_buffer_size"`
	} `json:"kcp"`
	Http2 struct {
		Host string `json:"host"`
		Path string `json:"path"`
	} `json:"http2"`

	UseTls      bool
	TlsHost     string
	TlsKeyFile  string
	TlsCertFile string
}

Config 配置结构

type ConfigClient

type ConfigClient struct {
	UserId  string `json:"user_id"`
	AlterId int    `json:"alter_id"`
}

type ConfigHeader

type ConfigHeader struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Jump to

Keyboard shortcuts

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