Skip to content

Commit

Permalink
添加REALITY分享随机选择sni方便使用any_SNI_No_SNI配置方案
Browse files Browse the repository at this point in the history
  • Loading branch information
qist committed Apr 28, 2023
1 parent 140418b commit f27a71e
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 12 deletions.
11 changes: 10 additions & 1 deletion Nginx前置SNI分流.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ xray-ui 面板配置
## reality 配置 dest serverNames 每个配置不能重复别使用www.bing.com这个域名

![vless+xtls+tcp+reality+sni](./media/vless+xtls+tcp+reality+sni.png)

![vless+grpc+sni](./media/vless+grpc+sni.png)
any_SNI_No_SNI 配置
![any_SNI_No_SNI](./media/any_SNI_No_SNI.png)


## nginx 配置

Expand Down Expand Up @@ -151,7 +155,7 @@ sni 分流配置
map $ssl_preread_server_name $stream_map {
example.com web; # vless+grpc+sni 配置
www.apple.com vlesstcpreality; # vless+xtls+tcp+reality+sni配置 reality 配置 dest serverNames 每个配置不能重复别使用www.bing.com这个域名
default web; # 默认转发
default sni; # 默认转发到any_SNI_No_SNI
}
upstream web {
Expand All @@ -162,6 +166,11 @@ upstream web {
upstream vlesstcpreality {
server 127.0.0.1:36712;
}
# 下面是转发到any_SNI_No_SNI
upstream sni {
server 127.0.0.1:49026;
}
server {
listen [服务器公网IP]:443 reuseport so_keepalive=on backlog=4096;
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ firewall-cmd --list-all
----------------------------------------------------------------------------------------------------------------------------------------------
更新日志:

2023.4.28 添加REALITY分享随机选择sni方便使用any_SNI_No_SNI配置方案

2023.4.26 [添加 Nginx前置SNI分流](./Nginx前置SNI分流.md)

2023.4.24 添加一键更新geoip,geosite 添加geoip,geosite 更新版本号
Expand Down
2 changes: 1 addition & 1 deletion config/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.8.7
1.8.8
Binary file added media/any_SNI_No_SNI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 12 additions & 10 deletions web/assets/js/model/xray.js
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,8 @@ class Inbound extends XrayCommonClass {

if (this.stream.security === 'reality') {
if (!ObjectUtil.isArrEmpty(this.stream.reality.serverNames)) {
params.set("sni", this.stream.reality.serverNames.split(/,||\s+/)[0]);
// params.set("sni", this.stream.reality.serverNames.split(/,|,|\s+/)[0]);
params.set("sni", ObjectUtil.generateSid(this.stream.reality.serverNames));
}
if (this.stream.reality.publicKey != "") {
params.set("pbk", this.stream.reality.publicKey);
Expand All @@ -1284,10 +1285,10 @@ class Inbound extends XrayCommonClass {
params.set("flow", this.settings.vlesses[0].flow);
}

var shortIds1 = this.stream.reality.shortIds.split(/,||\s+/);
var index1 = Math.floor(Math.random() * shortIds1.length);
var value1 = shortIds1[index1];
params.set("sid", value1);
// var shortIds1 = this.stream.reality.shortIds.split(/,|,|\s+/);
// var index1 = Math.floor(Math.random() * shortIds1.length);
// var value1 = shortIds1[index1];
params.set("sid", ObjectUtil.generateSid(this.stream.reality.shortIds));

if (this.stream.reality.fingerprint != "") {
params.set("fp", this.stream.reality.fingerprint);
Expand Down Expand Up @@ -1389,16 +1390,17 @@ class Inbound extends XrayCommonClass {

if (this.stream.security === 'reality') {
if (!ObjectUtil.isArrEmpty(this.stream.reality.serverNames)) {
params.set("sni", this.stream.reality.serverNames.split(/,||\s+/)[0]);
// params.set("sni", this.stream.reality.serverNames.split(/,|,|\s+/)[0]);
params.set("sni", ObjectUtil.generateSid(this.stream.reality.serverNames));
}
if (this.stream.reality.publicKey != "") {
params.set("pbk", this.stream.reality.publicKey);
}

var shortIds1 = this.stream.reality.shortIds.split(/,||\s+/);
var index1 = Math.floor(Math.random() * shortIds1.length);
var value1 = shortIds1[index1];
params.set("sid", value1);
// var shortIds1 = this.stream.reality.shortIds.split(/,|,|\s+/);
// var index1 = Math.floor(Math.random() * shortIds1.length);
// var value1 = shortIds1[index1];
params.set("sid", ObjectUtil.generateSid(this.stream.reality.shortIds));

if (this.stream.reality.fingerprint != "") {
params.set("fp", this.stream.reality.fingerprint);
Expand Down
7 changes: 7 additions & 0 deletions web/assets/js/util/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,11 @@ class ObjectUtil {
return true;
}

static generateSid(obj) {
const shortIds = obj;
const shortIds1 = shortIds.split(/,||\s+/);
const index1 = Math.floor(Math.random() * shortIds1.length);
const value1 = shortIds1[index1];
return value1;
}
}

0 comments on commit f27a71e

Please sign in to comment.