Documentation ¶
Index ¶
- func ParseShadowsocksOutbound(param ProtocolParam, config ...interface{}) (err error)
- func ParseSocksOutbound(param ProtocolParam, config ...interface{}) (err error)
- func ParseVlessOutbound(param ProtocolParam, config ...interface{}) (err error)
- func ParseVmessOutbound(param ProtocolParam, config ...interface{}) (err error)
- type API
- type Account
- type Allocate
- type Balancer
- type BaseCnf
- type BlackholeOutbound
- type Bridge
- type Certificates
- type Client
- type Config
- type DNS
- type DNSOutbound
- type Default
- type Detour
- type Dispatcher
- type DokodemoDoorInbound
- type DomainSocket
- type Fallback
- type FreedomOutbound
- type HTTP2
- type HTTPHeader
- type HTTPInbound
- type HTTPOutbound
- type HTTPRequest
- type HTTPResponse
- type HTTPServer
- type Header
- type Inbound
- type InboundConfiguration
- type KCP
- type LevelPolicy
- type Log
- type MTProtoInbound
- type MTProtoOutbound
- type MTProtoUser
- type Mux
- type NoneHeader
- type Outbound
- type OutboundConfiguration
- type Policy
- type Portal
- type ProtocolParam
- type ProxySetting
- type QUIC
- type Response
- type Reverse
- type Routing
- type Rule
- type Server
- type SettingsParam
- type Shadowsocks
- type ShadowsocksInbound
- type ShadowsocksOutbound
- type Sniffing
- type Sockopt
- type SocksInbound
- type SocksOutbound
- type SocksServer
- type SocksUser
- type Stats
- type Status
- type StreamSettings
- type SystemPolicy
- type TCP
- type TLS
- type Transport
- type VlessClient
- type VlessInbound
- type VlessOutbound
- type VlessServer
- type VlessUser
- type VmessInbound
- type VmessOutbound
- type VmessServer
- type VmessUser
- type WebSocket
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseShadowsocksOutbound ¶ added in v1.5.0
func ParseShadowsocksOutbound(param ProtocolParam, config ...interface{}) (err error)
ParseShadowsocksOutbound 解析 shadowsocks 协议
func ParseSocksOutbound ¶ added in v1.5.0
func ParseSocksOutbound(param ProtocolParam, config ...interface{}) (err error)
ParseSocksOutbound 解析 socks 协议
func ParseVlessOutbound ¶ added in v1.4.0
func ParseVlessOutbound(param ProtocolParam, config ...interface{}) (err error)
ParseVlessOutbound 解析 vless 协议
func ParseVmessOutbound ¶ added in v1.4.0
func ParseVmessOutbound(param ProtocolParam, config ...interface{}) (err error)
ParseVmessOutbound 解析 vmess 协议
Types ¶
type API ¶
type API struct { // 出站代理标识 Tag string `json:"tag"` // 开启的API列表 Services []string `json:"services"` }
API 远程控制。
type Allocate ¶
type Allocate struct { Strategy string `json:"strategy"` Refresh int `json:"refresh"` Concurrency int `json:"concurrency"` }
Allocate 端口分配设置
type Balancer ¶
type Balancer struct { // 此负载均衡器的标识,用于匹配 RuleObject 中的 balancerTag。 Tag string `json:"tag"` // 一个字符串数组,其中每一个字符串将用于和出站协议标识的前缀匹配。 Selector []string `json:"selector"` }
Balancer 负载均衡器
type BaseCnf ¶ added in v1.2.0
type BaseCnf struct { Log map[string]interface{} `json:"log"` API map[string]interface{} `json:"api"` DNS map[string]interface{} `json:"dns"` Routing map[string]interface{} `json:"routing"` Policy map[string]interface{} `json:"policy"` Inbounds []map[string]interface{} `json:"inbounds"` Outbounds []map[string]interface{} `json:"outbounds"` Transport map[string]interface{} `json:"transport"` Stats map[string]interface{} `json:"stats"` Reverse map[string]interface{} `json:"reverse"` }
BaseCnf v2ray config struct to json.
type BlackholeOutbound ¶ added in v1.2.0
type BlackholeOutbound struct {
Response Response `json:"response"`
}
BlackholeOutbound blackhole 出站协议
type Certificates ¶ added in v1.2.0
type Certificates struct { // 证书用途,默认值为 "encipherment"。取值为 "encipherment" | "verify" | "issue" Usage string `json:"usage"` // 证书文件路径,如使用 OpenSSL 生成,后缀名为 .crt。 CertificateFile string `json:"certificateFile"` // 一个字符串数组,表示证书内容,格式如样例所示。 Certificate []string `json:"certificate"` // 密钥文件路径 KeyFile string `json:"keyFile"` // 一个字符串数组,表示密钥内容 Key []string `json:"key"` }
Certificates 证书列表。
type Client ¶
type Client struct { ID string `json:"id"` Level int `json:"level"` AlterID int `json:"alterId"` Email string `json:"email"` }
Client 服务器认可的用户
type Config ¶
type Config struct { Log Log `json:"log"` Inbounds []Inbound `json:"inbounds"` Outbounds []Outbound `json:"outbounds"` }
Config v2ray config struct to json
type DNS ¶
type DNS struct { // 静态 IP 列表 Hosts map[string]string `json:"hosts"` // DNS 服务器列表。类型为[string | Server] Servers interface{} `json:"servers"` // 当前系统的 IP 地址 ClientIP string `json:"clientIp"` // 标识 Tag string `json:"tag"` }
DNS 内置的 DNS 服务器,若此项不存在,则默认使用本机的 DNS 设置。
type DNSOutbound ¶ added in v1.2.0
type DNSOutbound struct { Network string `json:"network"` Address string `json:"address"` Port int `json:"port"` }
DNSOutbound dns 出站协议
type Dispatcher ¶
type Dispatcher struct { }
Dispatcher v2ray 功能相关的控制器
func (Dispatcher) ListSettings ¶ added in v1.2.0
func (Dispatcher) ListSettings(c *gin.Context)
ListSettings 获取 v2ray 配置文件参数
func (Dispatcher) Settings ¶ added in v1.2.0
func (Dispatcher) Settings(c *gin.Context)
Settings 修改 v2ray 的配置文件
type DokodemoDoorInbound ¶ added in v1.2.0
type DokodemoDoorInbound struct { Address string `json:"address"` Port int `json:"port"` Network string `json:"network"` Timeout int `json:"timeout"` FollowRedirect bool `json:"followRedirect"` UserLevel int `json:"userLevel"` }
DokodemoDoorInbound 任意门入站协议
type DomainSocket ¶ added in v1.2.0
DomainSocket 使用 unix domain socket 来传输数据。
type Fallback ¶ added in v1.2.0
type Fallback struct { Alpn string `json:"alpn"` Path string `json:"path"` Dest int `json:"dest"` Xver int `json:"xver"` }
Fallback .
type FreedomOutbound ¶ added in v1.2.0
type FreedomOutbound struct { DomainStrategy string `json:"domainStrategy"` Redirect string `json:"redirect"` UserLevel int `json:"userLevel"` }
FreedomOutbound 出站协议。
type HTTPHeader ¶ added in v1.2.0
type HTTPHeader struct { // 指定进行 HTTP 伪装 Type string `json:"type"` // HTTP 请求 Request HTTPRequest `json:"request"` // HTTP 响应 Response HTTPResponse `json:"response"` }
HTTPHeader HTTP 伪装配置
type HTTPInbound ¶ added in v1.2.0
type HTTPInbound struct { Timeout int `json:"timeout"` Accounts []Account `json:"account"` AllowTransparent bool `json:"allowTransparent"` UserLevel int `json:"userLevel"` }
HTTPInbound http 入站协议
type HTTPOutbound ¶ added in v1.2.0
type HTTPOutbound struct { Servers []HTTPServer `json:"servers"` Address string `json:"address"` Port int `json:"port"` User []Account `json:"user"` }
HTTPOutbound http 出站协议
type HTTPRequest ¶ added in v1.2.0
type HTTPRequest struct { // HTTP 版本,默认值为 "1.1"。 Version string `json:"version"` // HTTP 方法,默认值为 "GET"。 Method string `json:"method"` // 路径,一个字符串数组。默认值为 ["/"]。 Path []string `json:"path"` // HTTP 头,一个键值对,每个键表示一个 HTTP 头的名称,对应的值是一个数组。 Headers map[string][]string `json:"headers"` }
HTTPRequest http 请求
type HTTPResponse ¶ added in v1.2.0
type HTTPResponse struct { // HTTP 版本,默认值为 "1.1"。 Version string `json:"version"` //HTTP 状态,默认值为 "200"。 Status string `json:"status"` // HTTP 状态说明,默认值为 "OK"。 Reason string `json:"reason"` // HTTP 头,一个键值对,每个键表示一个 HTTP 头的名称,对应的值是一个数组。 Headers map[string][]string `json:"headers"` }
HTTPResponse http 响应
type HTTPServer ¶ added in v1.2.0
type HTTPServer struct { Address string `json:"address"` Port int `json:"port"` Users []Account `json:"users"` }
HTTPServer http 服务器
type Inbound ¶
type Inbound struct { // 端口。类型为 number | "env:variable" | string Port interface{} `json:"port"` // 监听地址,只允许 IP 地址,默认值为 "0.0.0.0" Listen string `json:"listen"` // 连接协议名称,可选的值见协议列表。 Protocol string `json:"protocol"` // 具体的配置内容,视协议不同而不同。类型为 InboundConfigurationObject Settings InboundConfiguration `json:"settings"` // 底层传输配置 // StreamSettings StreamSettings `json:"streamSettings"` // 此入站连接的标识,用于在其它的配置中定位此连接。 Tag string `json:"tag"` // 尝试探测流量的类型 Sniffing Sniffing `json:"sniffing"` }
Inbound 入站连接配置
type KCP ¶ added in v1.2.0
type KCP struct { // 最大传输单元 Mtu int `json:"mtu"` // 传输时间间隔 Tti int `json:"tti"` // 上行链路容量 UplinkCapacity int `json:"UplinkCapacity"` // 下行链路容量 DownlinkCapacity int `json:"downlinkCapacity"` // 是否启用拥塞控制 Congestion bool `json:"congestion"` // 单个连接的读取缓冲区大小 ReadBufferSize int `json:"readBufferSize"` // 单个连接的写入缓冲区大小 WriteBufferSize int `json:"writeBufferSize"` // 数据包头部伪装设置 Header Header `json:"header"` // v4.24.2+,可选的混淆密码 Seed string `json:"seed"` }
KCP 当前连接的 mKCP 配置,仅当此连接使用 mKCP 时有效
type LevelPolicy ¶
type LevelPolicy struct { // 连接建立时的握手时间限制。单位为秒。默认值为 4。 Handshake int `json:"handshake"` // 连接空闲的时间限制。单位为秒。默认值为 300。 ConnIdle int `json:"connIdle"` // 当连接下行线路关闭后的时间限制。单位为秒。默认值为 2。 UplinkOnly int `json:"uplinkOnly"` // 当连接上行线路关闭后的时间限制。单位为秒。默认值为 5。 DownlinkOnly int `json:"downlinkOnly"` // 当值为 true 时,开启当前等级的所有用户的上行流量统计。 StatsUserUplink bool `json:"statsUserUplink"` // 当值为 true 时,开启当前等级的所有用户的下行流量统计。 StatsUserDownlink bool `json:"statsUserDownlink"` // 每个连接的内部缓存大小。单位为 kB。 BufferSize int `json:"bufferSize"` }
LevelPolicy 策略等级
type Log ¶
type Log struct { // 访问日志的文件地址 Access string `json:"access"` // 错误日志的文件地址 Error string `json:"error"` // 错误日志的级别 LogLevel string `json:"loglevel"` }
Log 日志配置,表示 V2Ray 如何输出日志。
type MTProtoInbound ¶ added in v1.2.0
type MTProtoInbound struct {
Users []MTProtoUser `json:"users"`
}
MTProtoInbound MTProto 入站协议
type MTProtoOutbound ¶ added in v1.2.0
type MTProtoOutbound struct { Tag string `json:"tag"` Port int `json:"port"` Protocol string `json:"protocol"` Settings interface{} `json:"settings"` }
MTProtoOutbound MTProto 入站协议
type MTProtoUser ¶ added in v1.2.0
type MTProtoUser struct { Email string `json:"email"` Level int `json:"level"` Secret string `json:"secret"` }
MTProtoUser MTProto user 对象
type NoneHeader ¶ added in v1.2.0
type NoneHeader struct {
Type string `json:"type"`
}
NoneHeader 不进行伪装
type Outbound ¶
type Outbound struct { SendThrough string `json:"sendThrough"` Protocol string `json:"protocol"` Settings OutboundConfiguration `json:"settings"` Tag string `json:"tag"` StreamSettings StreamSettings `json:"streamSettings"` // ProxySettings ProxySetting `json:"proxySettings"` Mux Mux `json:"mux"` }
Outbound 出站连接配置
type Policy ¶
type Policy struct { // 一组键值对 Level map[string]LevelPolicy `json:"levels"` System SystemPolicy `json:"system"` }
Policy 本地策略,可以进行权限相关的配置
type ProtocolParam ¶ added in v1.2.0
type ProtocolParam struct { Protocol string // 协议名称 ID int // 协议 id Address string `json:"address"` Port int `json:"port"` UserID string AlertID int `json:"alertId"` // vless 协议参数 Flow string `json:"flow"` // vless 协议参数 Encryption string `json:"encryption"` Level int `json:"level"` Security string `json:"security"` // socks 协议参数 User string `json:"user"` Passwd string `json:"passwd"` Network string `json:"network"` Domains string `json:"domains"` Path string `json:"path"` NetSecurity string ConfigFile string // 国内直连 Direct bool `json:"direct"` }
ProtocolParam accept parameters pass from network.
type QUIC ¶ added in v1.2.0
type QUIC struct { // 加密方式。取值为 "none" | "aes-128-gcm" | "chacha20-poly1305" Security string `json:"security"` // 加密时用的密钥 Key string `json:"key"` // 数据包头部伪装设置 Header Header `json:"header"` }
QUIC udp 多路并发传输协议配置
type Response ¶ added in v1.2.0
type Response struct { // 取值为 "http" | "none" Type string `json:"type"` }
Response blackhole response 对象
type Routing ¶
type Routing struct { // 域名解析策略,根据不同的设置使用不同的策略。 取值 "AsIs" | "IPIfNonMatch" | "IPOnDemand" DomainStrategy string `json:"domainStrategy"` // 对应一个数组,数组中每个元素是一个规则。 Rules []*Rule `json:"rules"` // 一个数组,数组中每个元素是一个负载均衡器的配置。 Balancers []Balancer `json:"balancers"` }
Routing 路由
type Rule ¶
type Rule struct { // 目前只支持"field"这一个选项。 Type string `json:"type"` // 一个数组,数组每一项是一个域名的匹配。 Domain []string `json:"domain"` // 一个数组,数组内每一个元素代表一个 IP 范围。 IP []string `json:"ip"` // 目标端口范围。类型为 number | string Port interface{} `json:"port"` // 可选的值有 "tcp"、"udp" 或 "tcp,udp",当连接方式是指定的方式时,此规则生效。 Network string `json:"network"` // 一个数组,数组内每一个元素是一个 IP 或 CIDR。 Source []string `json:"source"` // 一个数组,数组内每一个元素是一个邮箱地址。 User []string `json:"user"` // 一个数组,数组内每一个元素是一个标识。 InboundTag []string `json:"inboundTag"` // 一个数组,数组内每一个元素表示一种协议。取值为 [ "http" | "tls" | "bittorrent" ] Protocol []string `json:"protocol"` // 一段脚本,用于检测流量的属性值。 Attr string `json:"attrs"` // 对应一个 额外出站连接配置 的标识。 OutboundTag string `json:"outboundTag"` // 对应一个负载均衡器的标识。 BalancerTag string `json:"balancerTag"` }
Rule 规则
type Server ¶
type Server struct { // DNS 服务器地址 Address string `json:"address"` // DNS 服务器端口 Port int `json:"port"` // 一个域名列表,此列表包含的域名,将优先使用此服务器进行查询。 Domains []string `json:"domains"` // 一个 IP 范围列表,格式和路由配置中相同。 ExpectIPs []string `json:"expectIPs"` }
Server DNS 服务器对象
type SettingsParam ¶ added in v1.2.0
type SettingsParam struct { Protocol string `json:"protocol"` Address string `json:"address"` Port int `json:"port"` }
SettingsParam .
type Shadowsocks ¶ added in v1.2.0
type Shadowsocks struct { Email string `json:"email"` Method string `json:"method"` Password string `json:"password"` Level int `json:"level"` Ota bool `json:"ota"` Network string `json:"network"` }
Shadowsocks .
type ShadowsocksInbound ¶ added in v1.2.0
type ShadowsocksInbound struct {
Shadowsocks
}
ShadowsocksInbound shadowsocks 入站协议
type ShadowsocksOutbound ¶ added in v1.2.0
type ShadowsocksOutbound struct {
Servers []Shadowsocks `json:"servers"`
}
ShadowsocksOutbound shadowsocks 入站协议
type Sockopt ¶ added in v1.2.0
type Sockopt struct { // 一个整数。 Mark int `json:"mark"` // 是否启用 tcp fast open TCPFastOpen bool `json:"tcpFastOpen"` // 是否开启透明代理仅适用于Linux。取值为 "redirect" | "tproxy" | "off" Tproxy string `json:"Tproxy"` }
Sockopt 透明代理配置
type SocksInbound ¶ added in v1.2.0
type SocksInbound struct { Auth string `json:"auth"` // Accounts []Account `json:"accounts"` UDP bool `json:"udp"` IP string `json:"ip"` }
SocksInbound socks 入站协议
type SocksOutbound ¶ added in v1.2.0
type SocksOutbound struct {
Servers []SocksServer `json:"servers"`
}
SocksOutbound socks 出站协议
type SocksServer ¶ added in v1.2.0
type SocksServer struct { Address string `json:"address"` Port int `json:"port"` Users []SocksUser `json:"users"` }
SocksServer .
type SocksUser ¶ added in v1.2.0
type SocksUser struct { User string `json:"user"` Pass string `json:"pass"` Level int `json:"level"` }
SocksUser .
type StreamSettings ¶
type StreamSettings struct { // 数据流所使用的网络类型,默认值为 "tcp" NetWork string `json:"network"` // 是否启用传输层加密。取值为 "none" | "tls",默认值为 "none"。 Security string `json:"security"` // TLS 配置 // TLSSettings TLS `json:"tlsSettings"` // 当前连接的 TCP 配置,仅当此连接使用 TCP 时有效。 // TCPSettings TCP `json:"tcpSettings"` // 当前连接的 mKCP 配置,仅当此连接使用 mKCP 时有效 // KCPSettings KCP `json:"kcpSettings"` // 当前连接的 WebSocket 配置,仅当此连接使用 WebSocket 时有效。 WSSettings WebSocket `json:"wsSettings"` }
StreamSettings 底层传输配置
type SystemPolicy ¶
type SystemPolicy struct { // 当值为 true 时,开启所有入站代理的上行流量统计。 StatsInboundUplink bool `json:"statsInboundUplink"` // 当值为 true 时,开启所有入站代理的下行流量统计。 StatsInboundDownlink bool `json:"statsInboundDownlink"` // 当值为 true 时,开启所有出站代理的上行流量统计。 StatsOutboundUplink bool `json:"statsOutboundUplink"` // 当值为 true 时,开启所有出站代理的下行流量统计。 StatsOutboundDownlink bool `json:"statsOutboundDownlink"` }
SystemPolicy 系统策略
type TCP ¶ added in v1.2.0
type TCP struct { // v4.27.1+,仅用于 inbound,是否接收 PROXY protocol,默认值为 false。 AcceptProxyProtocol bool `json:"acceptProxyProtocol"` // 数据包头部伪装设置,默认值为 NoneHeaderObject。 // 类型为 NoneHeaderObject | HttpHeaderobject Header interface{} `json:"header"` }
TCP TCP配置。
type TLS ¶ added in v1.2.0
type TLS struct { // 指定服务器端证书的域名,在连接由 IP 建立时有用。 ServerName string `json:"serverName"` // 一个字符串数组,指定了 TLS 握手时指定的 ALPN 数值。 ALPN []string `json:"alpn"` // 是否允许不安全连接(仅用于客户端)。默认值为 false AllowInsecure bool `json:"allowInsecure"` // (V2Ray 4.18+)是否禁用操作系统自带的 CA 证书。默认值为 false。 DisableSystemRoot bool `json:"disableSystemRoot"` // 证书列表,其中每一项表示一个证书(建议 fullchain)。 Certificates []Certificates `json:"certificates"` }
TLS TLS配置。
type Transport ¶
type Transport struct { TCPSettings TCP `json:"tcpSettings"` KCPSettings KCP `json:"kcpSettings"` WSSettings WebSocket `json:"wsSettings"` HTTPSettings HTTP2 `json:"httpSettings"` DSSettings DomainSocket `json:"dsSettings"` QUICSettings QUIC `json:"quicSettings"` }
Transport 用于配置 V2Ray 如何与其它服务器建立和使用网络连接。
type VlessClient ¶ added in v1.2.0
type VlessClient struct { ID string `json:"id"` Flow string `json:"flow"` Level int `json:"level"` Email string `json:"email"` }
VlessClient .
type VlessInbound ¶ added in v1.2.0
type VlessInbound struct { Clients []VlessClient `json:"clients"` Decryption string `json:"decryption"` Fallbacks []Fallback `json:"fallbacks"` }
VlessInbound vless 入口协议
type VlessOutbound ¶ added in v1.2.0
type VlessOutbound struct {
Vnext []VlessServer `json:"vnext"`
}
VlessOutbound vless 出口协议
type VlessServer ¶ added in v1.2.0
type VlessServer struct { Address string `json:"address"` Port int `json:"port"` Users []VlessUser `json:"users"` }
VlessServer .
type VlessUser ¶ added in v1.2.0
type VlessUser struct { ID string `json:"id"` Flow string `json:"flow"` Encryption string `json:"encryption"` Level int `json:"level"` }
VlessUser .
type VmessInbound ¶ added in v1.2.0
type VmessInbound struct { Clients []Client `json:"clients"` Default Default `json:"default"` Detour Detour `json:"detour"` DisableInsecureEncryption bool `json:"disableInsecureEncryption"` }
VmessInbound vmess 入站协议
type VmessOutbound ¶ added in v1.2.0
type VmessOutbound struct {
Vnext []VmessServer `json:"vnext"`
}
VmessOutbound vmess 出站协议
type VmessServer ¶ added in v1.2.0
type VmessServer struct { Address string `json:"address"` Port int `json:"port"` Users []VmessUser `json:"users"` }
VmessServer vmess 协议