Skip to content

Commit cf44465

Browse files
committed
说明
1 parent 56b7c44 commit cf44465

1 file changed

Lines changed: 81 additions & 50 deletions

File tree

docs/other/xray.md

Lines changed: 81 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,12 @@ toc: 使用心得
1313
![alt 属性文本](/images/xray-router.png)
1414

1515
### 准备工作
16-
16+
- mac下
1717
- 下载 [xray-core 1.75](https://github.com/XTLS/Xray-core/releases/tag/v1.7.5) 目前稳定版就是1.75
1818
- 准备 [config.json ](https://xtls.github.io/document/level-0/ch08-xray-clients.html#_8-3-%E9%99%84%E5%8A%A0%E9%A2%98-1-%E5%9C%A8-pc-%E7%AB%AF%E6%89%8B%E5%B7%A5%E9%85%8D%E7%BD%AE-xray-core) 记得删除注释内容
19-
- 启动脚本 shell
20-
``` shell
21-
# 10801 是config.json中配置的, 不知道为什么 10800 即使没有监听也会有数据会判断不准确, 所以监听 10801
22-
lsof -i:10801 > /dev/null
23-
# [ $? -ne 0 ] = 上一条命令执行失败
24-
# ohup xray >/dev/null 2>&1 & 这样写可以免去回车操作
25-
if [ $? -ne 0 ];then nohup xray >/dev/null 2>&1 &; fi
26-
27-
# 下面个指令是结束 xray的进程, 非常好用
28-
# killall xray
2919

30-
```
3120

3221
### 操作步骤
33-
- 添加启动脚本到 登录项 位于 "系统偏好设置" => "登录项" 添加 xxx.sh 勾选隐藏
3422
- 为了方便操作我把xray所在的目录添加到了 path中, 不添加也可以但是需要绝对路径运行
3523
```shell
3624
# 编辑终端文件
@@ -43,6 +31,9 @@ vim ~/.zshrc
4331
# 根据程序名杀死进程 比如: killall xray 回车
4432
export PATH=$PATH:/Users/wz/Proxy/xray-core
4533

34+
# 重启xray 相当于重新加载confdir内配置内容
35+
alias rexray='killall xray; sleep 2s; nohup xray run -confdir confs >/dev/null 2>&1 &;'
36+
4637
# 让终端走代理 10801 是config.json中配置的
4738
alias proxy='export http_proxy="http://127.0.0.1:10801"; export HTTP_PROXY="http://127.0.0.1:10801"; export https_proxy="http://127.0.0.1:10801"; export HTTPS_PROXY="http://127.0.0.1:10801"'
4839

@@ -52,50 +43,90 @@ alias p=proxy
5243
# 后台运行指令: nohup xray & 注意 `&` 符号一定不能忘记
5344

5445
```
46+
- 然后在本机的 wifi ===> 详细信息 ===> 代理 ===> 网页代理&网页安全代理
47+
`根据自己的配置内容进行填写 比如我的就是:`
48+
服务器:127.0.0.1
49+
端口: 10801
5550

5651
### 后续遇到没有代理的网站可以直接修改 [config.json](https://xtls.github.io/document/level-0/ch08-xray-clients.html#_8-3-%E9%99%84%E5%8A%A0%E9%A2%98-1-%E5%9C%A8-pc-%E7%AB%AF%E6%89%8B%E5%B7%A5%E9%85%8D%E7%BD%AE-xray-core)
5752
```json
5853
// 3.4 国外域名代理
5954
domain 这是一个字符串数组, 例如 "domain":["www.baidu.com","zhihu.com"] 就会让百度和知乎走代理了, 其他的配置同理
6055
...
6156
"routing": {
62-
"domainStrategy": "IPIfNonMatch",
63-
"rules": [
64-
// 3.1 广告域名屏蔽
65-
{
66-
"type": "field",
67-
"domain": ["geosite:category-ads-all"],
68-
"outboundTag": "block"
69-
},
70-
// 3.2 国内域名直连
71-
{
72-
"type": "field",
73-
"domain": ["geosite:cn"],
74-
"outboundTag": "direct"
75-
},
76-
// 3.3 国内IP直连
77-
{
78-
"type": "field",
79-
"ip": ["geoip:cn", "geoip:private"],
80-
"outboundTag": "direct"
81-
},
82-
// 3.4 国外域名代理
83-
{
84-
"type": "field",
85-
"domain": ["geosite:geolocation-!cn"],
86-
"outboundTag": "proxy"
87-
},
88-
// 3.5 默认规则
89-
// 在Xray中,任何不符合上述路由规则的流量,都会默认使用【第一个outbound(5.1)】的设置,所以一定要把转发VPS的outbound放第一个
90-
// 3.6 走国内"223.5.5.5"的DNS查询流量分流走direct出站
91-
{
92-
"type": "field",
93-
"ip": ["223.5.5.5"],
94-
"outboundTag": "direct"
95-
}
96-
]
97-
},
98-
...
57+
"domainMatcher": "hybrid",
58+
"domainStrategy": "AsIs",
59+
"rules": [
60+
{
61+
"domain": [
62+
"domain:google.com",
63+
"domain:youtube.com",
64+
"regexp:\\.goo.*\\.com$",
65+
"*.googlevideo.com",
66+
"domain:google.com.hk",
67+
"domain:googleapis.com",
68+
"domain:gstatic.com",
69+
"domain:ggpht.com",
70+
"domain:ytimg.com",
71+
"domain:googleusercontent.com",
72+
"domain:twimg.com",
73+
"domain:npmjs.com",
74+
"domain:twitter.com",
75+
"domain:soundcloud.com",
76+
"domain:sndcdn.com",
77+
"domain:googletagmanager.com",
78+
"domain:appspot.com",
79+
"domain:wikipedia.org",
80+
"domain:codesandbox.io",
81+
"domain:unpkg.com",
82+
"domain:apache.org",
83+
"domain:jsdelivr.net",
84+
"domain:cloudflareinsights.com",
85+
"domain:visualstudio.com",
86+
"domain:csb.app",
87+
"domain:instagram.com",
88+
"domain:cdninstagram.com",
89+
"domain:fbcdn.net",
90+
"domain:pinterest.com",
91+
"domain:pinterest.fr",
92+
"domain:babylonjs-playground.com",
93+
"domain:githack.com",
94+
"domain:speedtest.net",
95+
"domain:openwrt.org",
96+
"domain:nuxt.com",
97+
"domain:duckduckgo.com",
98+
"domain:npmmirror.com",
99+
"domain:v2ex.com",
100+
"domain:feel-gpt.top",
101+
"domain:huggingface.co",
102+
"domain:theb.ai",
103+
"domain:mercari.com",
104+
"domain:pcwrap.com",
105+
"beta.theb.ai",
106+
"domain:binance.com",
107+
"domain:bnbstatic.com",
108+
"domain:deepswap.ai",
109+
"regexp:eacg",
110+
"regexp:telegram",
111+
"regexp:mercdn",
112+
"regexp:github",
113+
],
114+
"outboundTag": "proxyvps",
115+
"type": "field"
116+
},
117+
{
118+
"domain": [
119+
"domain:djgo.cc",
120+
"regexp:\\*baidu\\$",
121+
"regexp:360buyimg",
122+
"regexp:jd"
123+
],
124+
"outboundTag": "direct",
125+
"type": "field"
126+
}
127+
]
128+
}
129+
...
99130

100131
```
101132

0 commit comments

Comments
 (0)