| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import fs, { readFileSync } from "fs"
- const outbounds = fs
- .readFileSync("proxies.txt")
- .toString()
- .split("\n")
- .filter(line => !!line)
- .map((line, i) => {
- const [host, port, username, password] = line.split(":")
- return {
- tag: `us-${i + 1}`,
- protocol: "http",
- settings: {
- servers: [
- {
- address: host,
- port: parseInt(port),
- users: [
- {
- user: username,
- pass: password
- }
- ]
- }
- ]
- }
- }
- })
- fs.writeFileSync("outbounds.json", JSON.stringify(outbounds, null, 2))
- const routingRules = outbounds.map((p, i) => {
- return {
- type: "field",
- user: [`rcs_${i + 1}`],
- outboundTag: p.tag
- }
- })
- fs.writeFileSync("routingRules.json", JSON.stringify(routingRules, null, 2))
- const xray = JSON.parse(fs.readFileSync("xray.json").toString())
- xray.outbounds = xray.outbounds.concat(outbounds)
- xray.routing.rules = xray.routing.rules.concat(routingRules)
- fs.writeFileSync("xray_edited.json", JSON.stringify(xray, null, 2))
|