data

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SettingsBucket .
	SettingsBucket = "settings"

	// SettingsV2ray v2ray 配置模板
	SettingsV2ray = "v2ray"

	// SettingsSettings 系統設定
	SettingsSettings = "settings"

	// SettingsIPTables iptables 防火牆 命令模板
	SettingsIPTables = "iptables"

	// SettingsLast 最後啓動的 v2ray 服務
	SettingsLast = "last"
)
View Source
const ElementBucket = "element"

ElementBucket .

View Source
const SubscriptionBucket = "subscription"

SubscriptionBucket .

View Source
const UserBucket = "user"

UserBucket .

View Source
const V2rayTemplate = `{
"_tag":"` + version.Tag + `",
"_date":"` + version.Date + `",
"_commit":"` + version.Commit + `",
"log": {
	"loglevel": "warning"
},
"dns": {
	"disableCache": false,
	"tag": "dns",
	"hosts": {
		"{{.Outbound.Add}}": "{{.AddIP}}"
	},
	"servers": [
		// 使用 google 解析
		{
			"address": "8.8.8.8",
			"port": 53,
			"domains": [
				"geosite:google",
				"geosite:facebook",
				"geosite:geolocation-!cn"
			]
		},
		// 使用 趙國 解析服務
		{
			"address": "114.114.114.114",
			"port": 53,
			"domains": [
				"geosite:cn",
				"geosite:speedtest",
				"domain:cn"
			]
		},
		"8.8.8.8",
		"8.8.4.4",
		"localhost"
	]
},
"inbounds": [
	// 本地 socks5 代理
	{
		"tag": "socks",
		"listen": "127.0.0.1",
		"protocol": "socks",
		"port": 1080,
		"settings": {
			"auth": "noauth"
		}
	},
	// 本地 http 代理
	{
		"tag": "http",
		"listen": "127.0.0.1",
		"protocol": "http",
		"port": 8118
	},  
	// 透明代理
	{
		"tag": "redir",
		"protocol": "dokodemo-door",
		"port": 10090,
		"settings": {
			"network": "tcp,udp",
			"followRedirect": true
		},
		"sniffing": {
			"enabled": true,
			"destOverride": [
				"http",
				"tls"
			]
		}
	},
	// dns 代理 解決 域名污染
	{
		"tag": "dns",
		"protocol": "dokodemo-door",
		"port": 10054,
		"settings": {
			"address": "8.8.8.8",
			"port": 53,
			"network": "tcp,udp",
			"followRedirect": false
		}
	}
],
"outbounds": [
	// 代理 訪問
	{
		"tag": "proxy",
		"protocol": "{{.Outbound.Protocol}}",
{{if eq .Outbound.Protocol "shadowsocks"}}
"settings": {
	"servers": [
		{
			"address": "{{.AddIP}}",
			"port": {{.Outbound.Port}},
			"method": "{{.Outbound.Security}}",
			"password": "{{.Outbound.UserID}}",
			"ota": false,
			{{if eq .Outbound.Level ""}}
					"level": 0
			{{else}}
					"level": {{.Outbound.Level}}
			{{end}}
		}
	],
	"streamSettings": {
		"sockopt": {
			"mark": 255,
			"tcpFastOpen": false,
			"tproxy": "off"
		}
	}
},
"mux": {
	"enabled": false
}
{{else if eq .Outbound.Protocol "trojan"}}
"settings": {
	"servers": [
		{
			"address": "{{.AddIP}}",
			"port": {{.Outbound.Port}},
			"password": "{{.Outbound.UserID}}",
			{{if eq .Outbound.Level ""}}
					"level": 0
			{{else}}
					"level": {{.Outbound.Level}}
			{{end}}
		}
	],
	"streamSettings": {
		"sockopt": {
			"mark": 255,
			"tcpFastOpen": false,
			"tproxy": "off"
		}
	}
},
"mux": {
	"enabled": false
}
{{else}}
"settings": {
	"vnext": [{
		"address": "{{.AddIP}}",
		"port": {{.Outbound.Port}},
		"users": [{
			"id": "{{.Outbound.UserID}}",

			{{if eq .Outbound.Protocol "vmess"}}
				{{if eq .Outbound.AlterID ""}}
						"alterId": 0,
				{{else}}
						"alterId": {{.Outbound.AlterID}},
				{{end}}
				"security": "{{.Outbound.Security}}",
			{{else if eq .Outbound.Protocol "vless"}}
				"flow": "",
				"encryption": "none",
			{{end}}

			{{if eq .Outbound.Level ""}}
					"level": 0
			{{else}}
					"level": {{.Outbound.Level}}
			{{end}}
		}]
	}]
},
"streamSettings": {
	"network": "{{.Outbound.Net}}",
	"security": "{{.Outbound.TLS}}",
	{{if eq .Outbound.TLS "tls"}}
		"tlsSettings": {
			{{if eq .Outbound.Host ""}}
			"serverName": "{{.Outbound.Add}}",
			{{else}}
			"serverName": "{{.Outbound.Host}}",
			{{end}}
			"allowInsecure": false,
			"alpn": ["http/1.1"],
			"certificates": [],
			"disableSystemRoot": false
		},
	{{end}}

	{{if eq .Outbound.Net "tcp"}}
		"tcpSettings": {
			"header": {
				"type": "none"
			}
		},
	{{else if eq .Outbound.Net "kcp"}}
		"kcpSettings": {
			"mtu": 1350,
			"tti": 20,
			"uplinkCapacity": 5,
			"downlinkCapacity": 20,
			"congestion": false,
			"readBufferSize": 1,
			"writeBufferSize": 1,
			"header": {
				"type": "none"
			}
		},
	{{else if eq .Outbound.Net "ws"}}
		"wsSettings": {
			{{if eq .Outbound.Path ""}}
				"path": "/",
			{{else}}
				"path": "{{.Outbound.Path}}",
			{{end}}
			
			"headers": {
				{{if eq .Outbound.Host ""}}
					"Host": "{{.Outbound.Add}}"
				{{else}}
					"Host": "{{.Outbound.Host}}"
				{{end}}
			}
		},
	{{else if eq .Outbound.Net "http"}}
		"httpSettings": {
			{{if eq .Outbound.Path ""}}
				"path": "/"
			{{else}}
				"path": "{{.Outbound.Path}}"
			{{end}}
		},
	{{else if eq .Outbound.Net "domainsocket"}}
		"dsSettings": {
			{{if eq .Outbound.Path ""}}
				"path": "/"
			{{else}}
				"path": "{{.Outbound.Path}}"
			{{end}}
		},
	{{else if eq .Outbound.Net "quic"}}
		"quicSettings": {
			"security": "none",
			"key": "",
			"header": {
				"type": "none"
			}
		},
	{{end}}
	"sockopt": {
		"mark": 255,
		"tcpFastOpen": false,
		"tproxy": "off"
	}
},
"mux": {
	"enabled": true
}
{{end}}
	},
	// 直接 訪問
	{
		"tag": "freedom",
		"protocol": "freedom",
		"settings": {}
	},
	// 拒絕 訪問
	{
		"tag": "blackhole",
		"protocol": "blackhole",
		"settings": {}
	}
],
"routing": {
	"domainStrategy": "IPIfNonMatch",
	"rules": [
		// 通過透明代理 進入 一律 代理訪問
		{
			"type": "field",
			"network": "tcp,udp",
			"inboundTag": [
				"redir",
				"dns"
			],
			"outboundTag": "proxy"
		},
		// 代理訪問
		{
			"type": "field",
			"domain": [
				"geosite:google",
				"geosite:facebook",
				"geosite:geolocation-!cn"
			],
			"network": "tcp,udp",
			"outboundTag": "proxy"
		},
		// 直接訪問
		{
			"type": "field",
			"domain": [
				"geosite:cn",
				"geosite:speedtest",
				"domain:cn",
				"geoip:private"
			],
			"network": "tcp,udp",
			"outboundTag": "freedom"
		},
		{
			"type": "field",
			"ip": [
				"geoip:cn"
			],
			"network": "tcp,udp",
			"outboundTag": "freedom"
		}
	]
}
}`

V2rayTemplate v2ray 默認設定模板

Variables

This section is empty.

Functions

func DecoderID

func DecoderID(b []byte) (id uint64, e error)

DecoderID .

func EncodeID

func EncodeID(id uint64) (b []byte, e error)

EncodeID .

Types

type Element

type Element struct {
	// 唯一識別碼
	ID uint64 `json:"id,omitempty" xml:"id,omitempty" yaml:"id,omitempty"`
	// 所屬的 訂閱組 如果爲0 則爲 自定義節點
	Subscription uint64 `json:"subscription,omitempty" xml:"subscription,omitempty" yaml:"subscription,omitempty"`
	// 節點信息
	Outbound *Outbound `json:"outbound,omitempty" xml:"outbound,omitempty" yaml:"outbound,omitempty"`
}

Element 代理節點

func (*Element) Decode

func (element *Element) Decode(b []byte) (e error)

Decode 由 []byte 解碼

func (*Element) Encoder

func (element *Element) Encoder() (b []byte, e error)

Encoder 編碼到 []byte

type IPTables

type IPTables struct {
	Shell string `json:"shell,omitempty" xml:"shell,omitempty" yaml:"shell,omitempty"`
	View  string `json:"view,omitempty" xml:"view,omitempty" yaml:"view,omitempty"`
	Clear string `json:"clear,omitempty" xml:"clear,omitempty" yaml:"clear,omitempty"`
	Init  string `json:"init,omitempty" xml:"init,omitempty" yaml:"init,omitempty"`
}

IPTables 防火牆設置

func (*IPTables) Decode

func (iptables *IPTables) Decode(b []byte) (e error)

Decode 由 []byte 解碼

func (*IPTables) Encoder

func (iptables *IPTables) Encoder() (b []byte, e error)

Encoder 編碼到 []byte

func (*IPTables) ResetDefault

func (iptables *IPTables) ResetDefault()

ResetDefault 重新 置爲默認值

type Outbound

type Outbound struct {

	// 給人類看的 名稱
	Name string `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty"`

	// 連接地址
	Add string `json:"add,omitempty" xml:"add,omitempty" yaml:"add,omitempty"`
	// 連接端口
	Port string `json:"port,omitempty" xml:"port,omitempty" yaml:"port,omitempty"`
	// 連接主機名
	Host string `json:"host,omitempty" xml:"host,omitempty" yaml:"host,omitempty"`

	// 加密方案
	TLS string `json:"tls,omitempty" xml:"tls,omitempty" yaml:"tls,omitempty"`

	// 使用的網路協議
	Net string `json:"net,omitempty" xml:"net,omitempty" yaml:"net,omitempty"`

	// websocket 請求路徑
	Path string `json:"path,omitempty" xml:"path,omitempty" yaml:"path,omitempty"`

	// 用戶身份識別碼
	UserID string `json:"userID,omitempty" xml:"userID,omitempty" yaml:"userID,omitempty"`
	// 另外一個可選的用戶id
	AlterID string `json:"alterID,omitempty" xml:"alterID,omitempty" yaml:"alterID,omitempty"`
	// Security 加密方式
	Security string `json:"security,omitempty" xml:"security,omitempty" yaml:"security,omitempty"`
	// 用戶等級
	Level string `json:"level,omitempty" xml:"level,omitempty" yaml:"level,omitempty"`

	// 協議 名稱
	Protocol string `json:"protocol,omitempty" xml:"protocol,omitempty" yaml:"protocol,omitempty"`
}

Outbound 可用的 出棧 配置

func (*Outbound) ToContext

func (o *Outbound) ToContext() (context *OutboundContext, e error)

ToContext .

func (*Outbound) ToTemplate added in v1.2.0

func (o *Outbound) ToTemplate(name, text string) (result string, e error)

ToTemplate .

type OutboundContext

type OutboundContext struct {
	Outbound *Outbound
	AddIP    string
	BasePath string
}

OutboundContext 模板 環境

type Settings

type Settings struct {
	URL      string `json:"url,omitempty" json:"xml,omitempty" json:"yaml,omitempty"`
	V2ray    bool   `json:"v2ray,omitempty" xml:"v2ray,omitempty" yaml:"v2ray,omitempty"`
	IPTables bool   `json:"iptables,omitempty" xml:"iptables,omitempty" yaml:"iptables,omitempty"`
}

Settings 系統設定

func (*Settings) Decode

func (settings *Settings) Decode(b []byte) (e error)

Decode 由 []byte 解碼

func (*Settings) Encoder

func (settings *Settings) Encoder() (b []byte, e error)

Encoder 編碼到 []byte

func (*Settings) ResetDefault

func (settings *Settings) ResetDefault()

ResetDefault 重新 置爲默認值

type Subscription

type Subscription struct {
	// 唯一識別碼
	ID uint64 `json:"id,omitempty" xml:"id,omitempty" yaml:"id,omitempty"`
	// 給人類看的名稱
	Name string `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty"`
	// 訂閱地址
	URL string `json:"url,omitempty" xml:"url,omitempty" yaml:"url,omitempty"`
}

Subscription 訂閱服務

func (*Subscription) Decode

func (s *Subscription) Decode(b []byte) (e error)

Decode 由 []byte 解碼

func (*Subscription) Encoder

func (s *Subscription) Encoder() (b []byte, e error)

Encoder 編碼到 []byte

type User

type User struct {
	Name     string `json:"name,omitempty" xml:"name,omitempty" json:"yaml,omitempty"`
	Password string `json:"-" xml:"-" yaml:"-"`
}

User 用戶

Jump to

Keyboard shortcuts

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