v2ray_v5

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package v2ray_v5 supports v2ray v5 config and convertion methods between vs standard toml config format See https://www.v2fly.org/v5/config/

v2ray v5的配置看起来比v4配置简介不少,整体形态更接近vs的配置

v2ray和 vs之间的配置的显著差别是,v2ray没有vs的 fallback配置部分。

vs的fallback配置是单独列出来的,而v2ray则是藏在各个inbounds和outbounds中

vs 没有Log项,因为日志部分直接放在app项中。vs也没有services项,如果有的话,也会加到app项中

而app项不属于vs的proxy包,而属于app实现的部分,vs的app是cmd/verysimple

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToVS

func ToVS(c *Conf) (s proxy.StandardConf, err error)

Types

type CIDRObject

type CIDRObject struct {
	IA string `json:"ipAddr"`
	P  int    `json:"prefix"`
}

type Conf

type Conf struct {
	Log       *LogObject     `json:"log"`
	DNS       *DNSObject     `json:"dns"`
	Router    *RoutingObject `json:"router"`
	Inbounds  []Inbound      `json:"inbounds"`
	Outbounds []Outbound     `json:"outbounds"`
	Services  any            `json:"services"` //vs 不支持v2ray的 Services https://www.v2fly.org/v5/config/service.html
}

func FromVS

func FromVS(lc *proxy.StandardConf) (c Conf, err error)

type DNSObject

type DNSObject struct {
	A        []NameServerObject  `json:"nameServer"`
	ClientIP string              `json:"clientIp"`      //当前网络的 IP 地址。用于 DNS 查询时通知 DNS 服务器,客户端所在的地理位置(不能是私有 IP 地址)。此功能需要 DNS 服务器支持 EDNS Client Subnet(RFC7871)。
	QS       string              `json:"queryStrategy"` //"UseIP" | "UseIPv4" | "UseIPv6"
	T        string              `json:"tag"`
	SH       []HostMappingObject `json:"staticHosts"`
	DC       bool                `json:"disableCache"`
	DF       bool                `json:"disableFallback"`
	DFIM     bool                `json:"disableFallbackIfMatch"`
}

type DomainObject

type DomainObject struct {
	T string `json:"type"` // "Plain" | "Regex" | "RootDomain" | "Full"
	V string `json:"value"`
}

type EndpointObject

type EndpointObject struct {
	A string `json:"address"`
	P int    `json:"port"`
}

type GeoDomain

type GeoDomain struct {
	P string `json:"filePath"`
	D string `json:"domain"`
	C string `json:"code"`
}

type GeoIP

type GeoIP struct {
	Code     string     `json:"code"`
	FilePath string     `json:"filepath"`
	IM       bool       `json:"invertMatch"`
	CIDR     CIDRObject `json:"cidr"`
}

type HostMappingObject

type HostMappingObject struct {
	T string   `json:"type"`          // "full" | "subdomain" | "keyword" | "regex"
	D string   `json:"domain"`        //与 type 所对应的 domain 值。格式与 PriorityDomainObject 相同。
	P string   `json:"proxiedDomain"` //如指定 proxiedDomain,匹配的域名将直接使用该域名的查询结果,类似于 CNAME。
	I []string `json:"ip"`            //匹配的域名所映射的 IP 地址列表。
}

type Inbound

type Inbound struct {
	N   string          `json:"protocol"`
	S   any             `json:"settings"`
	P   string          `json:"port"`
	L   string          `json:"listen"`
	T   string          `json:"tag"`
	SIO *SniffingObject `json:"sniffing"`
	STO *StreamObject   `json:"streamSettings"`
}

type LogObject

type LogObject struct {
	A LogSpecObject `json:"access"`
	E LogSpecObject `json:"error"`
}

type LogSpecObject

type LogSpecObject struct {
	T string `json:"type"` //"None" | "Console" | "File"
	P string `json:"path"`
	L string `json:"level"` //"Debug" | "Info" | "Warning" | "Error" | "None"
}

type MuxObject

type MuxObject struct {
	E bool `json:"enabled"`
	C int  `json:"concurrency"`
}

type NameServerObject

type NameServerObject struct {
	Address      *EndpointObject        `json:"address"`
	ClientIP     string                 `json:"clientIp"`
	Port         uint16                 `json:"port"`
	SkipFallback bool                   `json:"skipFallback"`
	Domains      []PriorityDomainObject `json:"prioritizedDomain"`
	ExpectIPs    []GeoIP                `json:"expectIps"`
}

type Outbound

type Outbound struct {
	N   string        `json:"protocol"`
	S   any           `json:"settings"`
	ST  string        `json:"sendThrough"`
	T   string        `json:"tag"`
	STO *StreamObject `json:"streamSettings"`
	PS  *ProxyObject  `json:"proxySettings"`
	M   *MuxObject    `json:"mux"`
}

type PriorityDomainObject

type PriorityDomainObject struct {
	T string `json:"type"` // "full" | "subdomain" | "keyword" | "regex"

	/*
			与 type 所对应的 domain 值。以下为 type 与domain 的对应关系:

		    full:当此域名完整匹配目标域名时,该规则生效。例如 v2ray.com 匹配 v2ray.com 但不匹配 www.v2ray.com。
		    regex:当 domain 所表示的正则表达式匹配目标域名时,该规则生效。例如 \.goo.*\.com$ 匹配 www.google.com、fonts.googleapis.com,但不匹配 google.com。
		    subdomain (推荐):当此域名是目标域名或其子域名时,该规则生效。例如 v2ray.com 匹配 www.v2ray.com、v2ray.com,但不匹配 xv2ray.com。
		    keyword:当此字符串匹配目标域名中任意部分,该规则生效。比如 sina.com 可以匹配 sina.com、sina.com.cn、www.sina.com 和 www.sina.company,但不匹配 sina.cn。
	*/
	D string `json:"domain"`
}

type ProxyObject

type ProxyObject struct {
	T  string `json:"tag"` //当指定另一个出站连接的标识时,此出站连接发出的数据,将被转发至所指定的出站连接发出。
	TL bool   `json:"transportLayer"`
}

type RoutingObject

type RoutingObject struct {
	S  string       `json:"domainStrategy"` //AsIs | UseIp | IpIfNonMatch | IpOnDemand
	R  []RuleObject `json:"rule"`
	BR any          `json:"balancingRule"`
}

type RuleObject

type RuleObject struct {
	Code     string       `json:"tag"`
	FilePath string       `json:"balancingTag"`
	D        DomainObject `json:"domain"`
	GD       GeoDomain    `json:"geoDomain"`
	GI       GeoIP        `json:"geoip"`
	SGI      GeoIP        `json:"sourceGeoip"`

	/*
	   a-b:a 和 b 均为正整数,且小于 65536。这个范围是一个前后闭合区间,当端口落在此范围内时,此规则生效。
	   a:a 为正整数,且小于 65536。当目标端口为 a 时,此规则生效。
	   以上两种形式的混合,以逗号 "," 分隔。形如:53,443,1000-2000。
	*/
	PL  string   `json:"portList"`
	SPL string   `json:"sourcePortList"`
	P   []string `json:"protocol"` //[ "http" | "tls" | "bittorrent" ]
	UE  []string `json:"userEmail"`
	IT  []string `json:"inboundTag"`
	DM  string   `json:"domainMatcher"` //"linear" | "mph"
}

type SniffingObject

type SniffingObject struct {
	E  bool     `json:"enabled"`
	DO []string `json:"destOverride"` //["http" | "tls" | "quic" | "fakedns" | "fakedns+others"]
	MO bool     `json:"metadataOnly"`
}

type SocketConfigObject

type SocketConfigObject struct {
	M int    `json:"mark"`
	F bool   `json:"tcpFastOpen"`
	T string `json:"tproxy"` //"redirect" | "tproxy" | "off"
	K int    `json:"tcpKeepAliveInterval"`
	B string `json:"bindToDevice"`
}

type StreamObject

type StreamObject struct {
	N   string              `json:"transport"`
	TP  any                 `json:"transportSettings"`
	S   string              `json:"security"`
	SES any                 `json:"securitySettings"`
	SS  *SocketConfigObject `json:"socketSettings"`
}

Jump to

Keyboard shortcuts

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