90e1e9a72509ffaf80a0600a4247300c688dfb48
pyxray
pyxray is a lightweight Xray resource and node-link toolkit.
Current stage:
- Download and check Xray assets.
- Import and normalize proxy node links.
- Manage local nodes and selected node.
- Generate Xray config from selected node and settings.
- Run a Chinese, light, single-page Web UI.
Out of scope for the current stage:
- Subscriptions.
- Authentication.
Xray 配置生成设置
这些设置由 pyxray.libs.xray_config.settings.XrayConfigSettings 定义,并可通过 XrayConfigSettingsStore 保存为 settings.toml。
[core]
| 设置 | 默认值 | 可选值 / 类型 | 作用 |
|---|---|---|---|
log_level |
info |
trace / debug / info / warn / warning / error |
生成 Xray log;trace/debug 会映射为 Xray debug。 |
tcp_fast_open |
default |
default / yes / no |
非默认时写入 outbound streamSettings.sockopt.tcpFastOpen。 |
mux_enabled |
false |
bool |
是否给主代理 outbound 启用 mux。 |
mux_concurrency |
8 |
1-1024 |
mux.concurrency。 |
ss_backend |
"" |
string |
预留 Shadowsocks 后端设置;当前 Xray JSON 生成不使用。 |
trojan_backend |
"" |
string |
预留 Trojan 后端设置;当前 Xray JSON 生成不使用。 |
[inbounds]
| 设置 | 默认值 | 可选值 / 类型 | 作用 |
|---|---|---|---|
listen |
127.0.0.1 |
IP 字符串 | 普通 socks/http/rule/vmess 入站监听地址。 |
port_sharing |
false |
bool |
为 true 时普通入站监听 0.0.0.0,等价于端口共享。 |
socks_port |
20170 |
0-65535 |
普通 SOCKS 入站端口,0 表示不生成。 |
http_port |
20171 |
0-65535 |
普通 HTTP 入站端口,0 表示不生成。 |
rule_socks_port |
0 |
0-65535 |
规则 SOCKS 入站端口,流量走 [routing] 规则。 |
rule_http_port |
20172 |
0-65535 |
规则 HTTP 入站端口,流量走 [routing] 规则。 |
vmess_port |
0 |
0-65535 |
额外 VMess 入站端口,0 表示不生成。 |
inbound_sniffing |
http,tls,quic |
disable / http,tls / http,tls,quic |
控制入站 sniffing.enabled 和 destOverride。 |
route_only |
false |
bool |
写入 sniffing.routeOnly。 |
domains_excluded |
"" |
换行分隔字符串 | 写入 sniffing.domainsExcluded。 |
api.port |
0 |
0-65535 |
Xray API 入站端口,0 表示不生成 API。 |
api.services |
["LoggerService"] |
字符串数组 | Xray api.services;生成时会确保包含 LoggerService。 |
custom |
[] |
自定义入站列表 | 额外生成 socks/http 入站。 |
[[inbounds.custom]]
| 设置 | 默认值 | 可选值 / 类型 | 作用 |
|---|---|---|---|
tag |
无 | 非空字符串 | 自定义入站 tag。 |
protocol |
无 | socks / http |
自定义入站协议。 |
port |
无 | 1-65535 |
自定义入站端口。 |
[routing]
| 设置 | 默认值 | 可选值 / 类型 | 作用 |
|---|---|---|---|
mode |
whitelist |
whitelist / gfwlist / custom / routingA / proxy / direct / block |
控制 rule 入站流量的路由生成方式。 |
default_rule |
proxy |
direct / proxy / block |
custom / routingA 等模式的兜底出口。 |
routing_a |
"" |
RoutingA 风格字符串 | 解析 default:、domain(...) -> outbound、ip(...) -> outbound 规则。 |
custom_rules |
[] |
自定义规则列表 | mode = "custom" 时生成规则。 |
[[routing.custom_rules]]
| 设置 | 默认值 | 可选值 / 类型 | 作用 |
|---|---|---|---|
filename |
"" |
字符串 | 非空时生成 ext:<filename>:<tag>。 |
tags |
[] |
字符串数组 | geosite/geoip/tag 列表。 |
match_type |
domain |
domain / ip |
写入 Xray rule 的 domain 或 ip 字段。 |
rule_type |
proxy |
direct / proxy / block |
命中后的出口。 |
[transparent]
| 设置 | 默认值 | 可选值 / 类型 | 作用 |
|---|---|---|---|
mode |
close |
close / proxy / whitelist / gfwlist / pac |
是否生成透明代理入站,以及透明代理流量走什么规则。 |
type |
redirect |
redirect / tproxy / system_proxy / tun |
透明代理入站类型。 |
port |
52345 |
0-65535 |
redirect/tproxy/system_proxy/tun 主透明代理端口。 |
socks_port |
52306 |
0-65535 |
system_proxy 模式额外 SOCKS 入站端口。 |
ipforward |
false |
bool |
系统 IP forward 设置;当前不写入 Xray JSON。 |
tproxy_excluded_interfaces |
docker*,veth*,wg*,ppp*,br-* |
字符串 | 系统 tproxy 规则排除接口;当前不写入 Xray JSON。 |
tproxy_white_country_codes |
[] |
字符串数组 | tproxy 白名单国家/地区;当前不写入 Xray JSON。 |
tproxy_white_custom_ips |
[] |
字符串数组 | tproxy 自定义白名单 IP;当前不写入 Xray JSON。 |
tun_bypass_interfaces |
"" |
字符串 | TUN 绕过接口;当前不写入 Xray JSON。 |
tun_auto_route |
true |
bool |
TUN 自动路由设置;当前不写入 Xray JSON。 |
tun_route_shell_type |
"" |
字符串 | TUN 路由脚本类型;当前不写入 Xray JSON。 |
tun_route_shell_path |
"" |
字符串 | TUN 路由脚本路径;当前不写入 Xray JSON。 |
tun_setup_script |
"" |
字符串 | TUN 启动脚本;当前不写入 Xray JSON。 |
tun_teardown_script |
"" |
字符串 | TUN 关闭脚本;当前不写入 Xray JSON。 |
tun_process_backend |
"" |
字符串 | TUN 进程匹配后端;当前不写入 Xray JSON。 |
tun_exclude_processes |
"" |
字符串 | TUN 排除进程列表;当前不写入 Xray JSON。 |
[dns]
| 设置 | 默认值 | 可选值 / 类型 | 作用 |
|---|---|---|---|
query_strategy |
"" |
UseIP / UseIPv4 / UseIPv6 / 空 |
非空时写入 dns.queryStrategy。 |
disable_fallback |
false |
bool |
为 true 时写入 dns.disableFallback。 |
local_dns_listen |
true |
bool |
是否生成本地 dns-in dokodemo-door 入站。 |
hosts |
{ "courier.push.apple.com": ["1-courier.push.apple.com"] } |
字典 | 写入 dns.hosts。 |
rules |
见下方默认规则 | DNS 规则列表 | 生成 dns.servers 和 DNS 服务器自身的 routing。 |
antipollution |
closed |
closed / none / dnsforward / doh / advanced |
DNS 防污染预留设置;当前不直接改变 Xray JSON。 |
special_mode |
none |
none / supervisor / fakedns |
特殊 DNS 模式预留设置;当前不直接改变 Xray JSON。 |
默认 [[dns.rules]]
| server | domains | outbound | 作用 |
|---|---|---|---|
localhost |
geosite:private |
direct |
私有域名走本地 DNS。 |
223.5.5.5 |
geosite:cn |
direct |
中国域名走国内 DNS。 |
8.8.8.8 |
"" |
proxy |
兜底 DNS 走代理。 |
[[dns.rules]]
| 设置 | 默认值 | 可选值 / 类型 | 作用 |
|---|---|---|---|
server |
无 | DNS 地址字符串 | 支持 localhost、IP、host:port、DoH URL 等。 |
domains |
"" |
换行分隔字符串 | 非空时作为该 DNS server 的匹配域名列表。 |
outbound |
direct |
direct / proxy / block / 自定义 outbound tag |
DNS 服务器自身连接使用的出口。 |
[[outbounds]]
| 设置 | 默认值 | 可选值 / 类型 | 作用 |
|---|---|---|---|
tag |
proxy |
字符串 | 出站组 tag。当前单节点配置默认使用 proxy。 |
probe_url |
https://www.gstatic.com/generate_204 |
URL 字符串 | 出站组观测 URL,预留给 balancer/observatory。 |
probe_interval |
60s |
duration 字符串 | 出站组观测间隔,预留给 balancer/observatory。 |
type |
leastping |
字符串 | 出站组策略类型,预留给 balancer/observatory。 |
[auto_update]
| 设置 | 默认值 | 可选值 / 类型 | 作用 |
|---|---|---|---|
gfwlist_auto_update_mode |
none |
none / auto_update / auto_update_at_intervals |
GFWList 更新策略;不写入 Xray JSON。 |
gfwlist_auto_update_interval_hour |
0 |
整数 | GFWList 定时更新间隔小时数。 |
subscription_auto_update_mode |
none |
none / auto_update / auto_update_at_intervals |
订阅更新策略;当前订阅不在实现范围。 |
subscription_auto_update_interval_hour |
0 |
整数 | 订阅定时更新间隔小时数。 |
proxy_mode_when_subscribe |
direct |
direct / proxy / pac |
订阅更新时偏好的连接模式;当前订阅不在实现范围。 |
Description
Languages
Python
85.6%
JavaScript
6.4%
HTML
6.4%
CSS
0.9%
Dockerfile
0.5%
Other
0.2%