| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- import fs from "fs"
- import path from "path"
- const proxies = fs
- .readFileSync("links.txt", "utf8")
- .toString()
- .split("\n")
- .map(proxy => proxy.trim())
- .filter(i => !!i)
- .map(proxy => {
- return new URL(proxy)
- })
- const countries = ["RCS-ZA", "RCS-US", "RCS-TR"]
- const configTemplate = fs
- .readFileSync(path.resolve("config", "template.yaml"), "utf8")
- .toString()
- countries.forEach((country, index) => {
- let proxyArg = proxies
- .filter(proxy => proxy.hash.replace("#", "").startsWith(country))
- .map((proxy, i) => {
- return ` - {name: ${proxy.hash.replace("#", "")}, server: ${
- proxy.hostname
- }, port: ${
- proxy.port
- }, reality-opts: {public-key: ${proxy.searchParams.get(
- "pbk"
- )}, short-id: ${proxy.searchParams.get(
- "sid"
- )}}, client-fingerprint: chrome, type: vless, uuid: ${
- proxy.username
- }, tls: true, tfo: false, skip-cert-verify: false, servername: yahoo.com, network: tcp}`
- })
- .join("\n")
- let groupArg = ""
- let ruleArg = ["192.168.10", "192.168.11", "192.168.12"]
- .map((ip, index) => {
- return [...Array(200).keys()]
- .map(
- i =>
- ` - SRC-IP-CIDR,${ip}.${i + 50}/32,${country}-IPWEB-${
- Math.ceil(i / 3) + index * 67 + 1
- }`
- )
- .join("\n")
- })
- .join("\n")
- fs.writeFileSync(
- path.resolve("dist", `${country}.yaml`),
- configTemplate
- .replace("${proxy}", proxyArg)
- .replace("${group}", groupArg)
- .replace("${rule}", ruleArg)
- )
- })
|