-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.js
More file actions
59 lines (56 loc) · 1.91 KB
/
update.js
File metadata and controls
59 lines (56 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import {db} from './db/db.js'
import * as fs from 'node:fs';
import 'dotenv/config';
import {config} from 'dotenv'
//read all vless inbound clients from xray.config
config({path : '../.env'})
let file = JSON.parse(fs.readFileSync(process.env.XRAY_JSON_PATH));
setTimeout(()=> {
(function vless2db(){
let clients = file["inbounds"][0]["settings"]["clients"]
for (let i of clients) {
let email = i['email'], uuid = i['id'];
let flow=null;
if(i['flow']) {
flow = i['flow']
}
db.run(`INSERT INTO users VALUES ('${email}', '${uuid}', 'vless', '${flow}')`)
}
})();
(function trojan2db(){
let clients = file["inbounds"][1]["settings"]["clients"]
for (let i of clients) {
let email = i['email'], uuid = i['id'];
let flow=null;
if(i['flow']) {
flow = i['flow']
}
db.run(`INSERT INTO users VALUES ('${email}', '${uuid}', 'trojan', '${flow}')`)
}
})();
(function vless_ws2db(){
let clients = file["inbounds"][2]["settings"]["clients"]
for (let i of clients) {
let email = i['email'], uuid = i['id'];
let flow=null;
if(i['flow']) {
flow = i['flow']
}
db.run(`INSERT INTO users VALUES ('${email}', '${uuid}', 'vless-ws', '${flow}')`)
}
})();
(function vmess2db(){
let clients = file["inbounds"][3]["settings"]["clients"]
for (let i of clients) {
let email = i['email'], uuid = i['id'];
let flow=null;
if(i['flow']) {
flow = i['flow']
}
db.run(`INSERT INTO users VALUES ('${email}', '${uuid}', 'vmess', '${flow}')`)
}
})();
(async function() {
console.log(await db.all('SELECT * FROM users'))
})()
}, 2000);