@eooce/idx 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +83 -60
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -128,12 +128,6 @@ function cleanupOldFiles() {
|
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
// 根路由
|
|
133
|
-
app.get("/", function(req, res) {
|
|
134
|
-
res.send("Hello world!");
|
|
135
|
-
});
|
|
136
|
-
|
|
137
131
|
// 获取固定隧道json
|
|
138
132
|
function argoType() {
|
|
139
133
|
if (!ARGO_AUTH || !ARGO_DOMAIN) {
|
|
@@ -842,69 +836,87 @@ async function extractDomains() {
|
|
|
842
836
|
}
|
|
843
837
|
}
|
|
844
838
|
}
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
839
|
+
|
|
840
|
+
// 获取isp信息
|
|
841
|
+
async function getMetaInfo() {
|
|
842
|
+
try {
|
|
843
|
+
const response1 = await axios.get('https://api.ip.sb/geoip', { headers: { 'User-Agent': 'Mozilla/5.0', timeout: 3000 }});
|
|
844
|
+
if (response1.data && response1.data.country_code && response1.data.isp) {
|
|
845
|
+
return `${response1.data.country_code}_${response1.data.isp}`.replace(/\s+/g, '_');
|
|
846
|
+
}
|
|
847
|
+
} catch (error) {
|
|
852
848
|
try {
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
849
|
+
// 备用 ip-api.com 获取isp
|
|
850
|
+
const response2 = await axios.get('http://ip-api.com/json', { headers: { 'User-Agent': 'Mozilla/5.0', timeout: 3000 }});
|
|
851
|
+
if (response2.data && response2.data.status === 'success' && response2.data.countryCode && response2.data.org) {
|
|
852
|
+
return `${response2.data.countryCode}_${response2.data.org}`.replace(/\s+/g, '_');
|
|
853
|
+
}
|
|
854
|
+
} catch (error) {
|
|
855
|
+
// console.error('Backup API also failed');
|
|
856
856
|
}
|
|
857
|
-
|
|
857
|
+
}
|
|
858
|
+
return 'Unknown';
|
|
859
|
+
}
|
|
858
860
|
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
const
|
|
861
|
+
// 生成 list 和 sub 信息
|
|
862
|
+
async function generateLinks(argoDomain) {
|
|
863
|
+
let SERVER_IP = '';
|
|
864
|
+
try {
|
|
865
|
+
const response = await axios.get('https://ipv4.ip.sb', { timeout: 3000 });
|
|
866
|
+
SERVER_IP = response.data.trim();
|
|
867
|
+
} catch (err) {
|
|
868
|
+
try {
|
|
869
|
+
const response = await axios.get('https://ipv6.ip.sb', { timeout: 2000 });
|
|
870
|
+
SERVER_IP = `[${response.data.trim()}]`;
|
|
871
|
+
} catch (ipv6Err) {
|
|
872
|
+
SERVER_IP = execSync('curl -sm 3 ipv4.ip.sb').toString().trim();
|
|
873
|
+
}
|
|
874
|
+
}
|
|
864
875
|
|
|
865
|
-
|
|
876
|
+
const ISP = await getMetaInfo();
|
|
877
|
+
const nodeName = NAME ? `${NAME}-${ISP}` : ISP;
|
|
866
878
|
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
879
|
+
return new Promise((resolve) => {
|
|
880
|
+
setTimeout(() => {
|
|
881
|
+
const vmessNode = `vmess://${Buffer.from(JSON.stringify({ v: '2', ps: `${nodeName}`, add: CFIP, port: CFPORT, id: UUID, aid: '0', scy: 'auto', net: 'ws', type: 'none', host: argoDomain, path: '/vmess-argo?ed=2560', tls: 'tls', sni: argoDomain, alpn: '', fp: 'firefox'})).toString('base64')}`;
|
|
870
882
|
|
|
871
|
-
|
|
883
|
+
let subTxt = vmessNode; // 始终生成vmess节点
|
|
872
884
|
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
885
|
+
// TUIC_PORT是有效端口号时生成tuic节点
|
|
886
|
+
if (isValidPort(TUIC_PORT)) {
|
|
887
|
+
const tuicNode = `\ntuic://${UUID}:@${SERVER_IP}:${TUIC_PORT}?sni=www.bing.com&congestion_control=bbr&udp_relay_mode=native&alpn=h3&allow_insecure=1#${nodeName}`;
|
|
888
|
+
subTxt += tuicNode;
|
|
889
|
+
}
|
|
878
890
|
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
891
|
+
// HY2_PORT是有效端口号时生成hysteria2节点
|
|
892
|
+
if (isValidPort(HY2_PORT)) {
|
|
893
|
+
const hysteriaNode = `\nhysteria2://${UUID}@${SERVER_IP}:${HY2_PORT}/?sni=www.bing.com&insecure=1&alpn=h3&obfs=none#${nodeName}`;
|
|
894
|
+
subTxt += hysteriaNode;
|
|
895
|
+
}
|
|
884
896
|
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
897
|
+
// REALITY_PORT是有效端口号时生成reality节点
|
|
898
|
+
if (isValidPort(REALITY_PORT)) {
|
|
899
|
+
const vlessNode = `\nvless://${UUID}@${SERVER_IP}:${REALITY_PORT}?encryption=none&flow=xtls-rprx-vision&security=reality&sni=www.iij.ad.jp&fp=firefox&pbk=${publicKey}&type=tcp&headerType=none#${nodeName}`;
|
|
900
|
+
subTxt += vlessNode;
|
|
901
|
+
}
|
|
890
902
|
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
903
|
+
// 打印 sub.txt 内容到控制台
|
|
904
|
+
console.log(Buffer.from(subTxt).toString('base64'));
|
|
905
|
+
fs.writeFileSync(subPath, Buffer.from(subTxt).toString('base64'));
|
|
906
|
+
fs.writeFileSync(listPath, subTxt, 'utf8');
|
|
907
|
+
console.log(`${FILE_PATH}/sub.txt saved successfully`);
|
|
908
|
+
sendTelegram(); // 发送tg消息提醒
|
|
909
|
+
uplodNodes(); // 推送节点到订阅器
|
|
910
|
+
// 将内容进行 base64 编码并写入 SUB_PATH 路由
|
|
911
|
+
app.get(`/${SUB_PATH}`, (req, res) => {
|
|
912
|
+
const encodedContent = Buffer.from(subTxt).toString('base64');
|
|
913
|
+
res.set('Content-Type', 'text/plain; charset=utf-8');
|
|
914
|
+
res.send(encodedContent);
|
|
915
|
+
});
|
|
916
|
+
resolve(subTxt);
|
|
917
|
+
}, 2000);
|
|
918
|
+
});
|
|
919
|
+
}
|
|
908
920
|
|
|
909
921
|
// 90s分钟后删除相关文件
|
|
910
922
|
function cleanFiles() {
|
|
@@ -1040,5 +1052,16 @@ async function startserver() {
|
|
|
1040
1052
|
cleanFiles();
|
|
1041
1053
|
}
|
|
1042
1054
|
startserver();
|
|
1043
|
-
|
|
1055
|
+
|
|
1056
|
+
// 根路由
|
|
1057
|
+
app.get("/", async function(req, res) {
|
|
1058
|
+
try {
|
|
1059
|
+
const filePath = path.join(__dirname, 'index.html');
|
|
1060
|
+
const data = await fs.promises.readFile(filePath, 'utf8');
|
|
1061
|
+
res.send(data);
|
|
1062
|
+
} catch (err) {
|
|
1063
|
+
res.send("Hello world!<br><br>You can visit /{SUB_PATH}(Default: /sub) get your nodes!");
|
|
1064
|
+
}
|
|
1065
|
+
});
|
|
1066
|
+
|
|
1044
1067
|
app.listen(PORT, () => console.log(`server is running on port:${PORT}!`));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eooce/idx",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "@eooce/idx",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"axios": "^1.12.2",
|
|
28
|
-
"express": "^
|
|
28
|
+
"express": "^4.18.2",
|
|
29
29
|
"dotenv": "^17.2.3"
|
|
30
30
|
},
|
|
31
31
|
"engines": {
|