convert.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import fs from "fs"
  2. import path from "path"
  3. const proxies = fs
  4. .readFileSync("links.txt", "utf8")
  5. .toString()
  6. .split("\n")
  7. .map(proxy => proxy.trim())
  8. .filter(i => !!i)
  9. .map(proxy => {
  10. return new URL(proxy)
  11. })
  12. const configTemplate = fs
  13. .readFileSync(path.resolve("config", "template.yaml"), "utf8")
  14. .toString()
  15. ;["RCS-ZA", "RCS-US", "RCS-TR"].forEach((country, index) => {
  16. let arg1 = proxies
  17. .filter(proxy => proxy.hash.replace("#", "").startsWith(country))
  18. .map((proxy, i) => {
  19. return ` - {name: ${proxy.hash.replace("#", "")}, server: ${
  20. proxy.hostname
  21. }, port: ${
  22. proxy.port
  23. }, reality-opts: {public-key: ${proxy.searchParams.get(
  24. "pbk"
  25. )}, short-id: ${proxy.searchParams.get(
  26. "sid"
  27. )}}, client-fingerprint: chrome, type: vless, uuid: ${
  28. proxy.username
  29. }, tls: true, tfo: false, skip-cert-verify: false, servername: yahoo.com, network: tcp}`
  30. })
  31. .join("\n")
  32. let arg2 = ["192.168.10", "192.168.11", "192.168.12"]
  33. .map((ip, index) => {
  34. return [...Array(200).keys()]
  35. .map(
  36. i =>
  37. ` - SRC-IP-CIDR,${ip}.${i + 50}/32,${country}-IPWEB-${
  38. i + index * 200 + 1
  39. }`
  40. )
  41. .join("\n")
  42. })
  43. .join("\n")
  44. fs.writeFileSync(
  45. path.resolve("dist", `${country}.yaml`),
  46. configTemplate.replace("${1}", arg1).replace("${2}", arg2)
  47. )
  48. })