| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- import { Document, parseDocument } from "yaml"
- import fs from "fs"
- import axios from "axios"
- import * as randomstring from "randomstring"
- import { bridges } from "./bridges.js"
- import { commonRules } from "./rules.js"
- const country = "US"
- const groupSize = 1
- const proxyNumEachGroup = 2
- const bridge = bridges[0]
- const nets = [
- {
- router: "192.168.6.1",
- subnets: ["192.168.10", "10.1.100", "10.1.101", "10.1.102"]
- },
- {
- router: "192.168.7.1",
- subnets: ["192.168.11", "192.168.12"]
- },
- {
- router: "192.168.8.1",
- subnets: ["192.168.13", "192.168.14"]
- },
- {
- router: "192.168.9.1",
- subnets: ["192.168.9"]
- },
- {
- router: "10.1.103.1",
- subnets: ["10.1.103"]
- },
- {
- router: "10.1.104.1",
- subnets: ["10.1.104"]
- }
- ]
- const {
- data: { data: countryList }
- } = await axios.get("http://admin.uipoxy.com/proxy/web/map/countryList", {
- params: {
- page: 1,
- limit: 1000
- }
- })
- // const { data: template, config } = await axios.get(
- // "http://192.168.50.47:25500/sub",
- // {
- // params: {
- // target: "clash",
- // url: "http://192.168.50.46:3000/download/collection/all?target=ClashMeta",
- // insert: false,
- // config: "https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Full_NoAuto.ini",
- // emoji: true,
- // list: false,
- // xudp: true,
- // udp: true,
- // tfo: false,
- // expand: true,
- // scv: true,
- // fdn: false,
- // new_name: true
- // }
- // }
- // )
- // fs.writeFileSync(`dist/sub.yaml`, template)
- const template = fs.readFileSync(`dist/sub.yaml`, "utf-8")
- let countryId = countryList.find(i => i.abbr === country)?.id
- for (let bridge of bridges) {
- for (let net of nets) {
- const ips = net.subnets.flatMap(subnet => {
- return Array.from({ length: 200 }, (_, i) => `${subnet}.${i + 50}`)
- })
- const doc = parseDocument(template)
- doc.set("dns", {
- nameserver: ["114.114.114.114", "223.5.5.5"],
- "proxy-server-nameserver": ["114.114.114.114"],
- "use-hosts": true,
- "default-nameserver": ["114.114.114.114", "223.5.5.5"]
- })
- doc.set("hosts", {
- "zipfile.mesgity.top": "154.21.92.47"
- })
- doc.set("unified-delay", true)
- const proxies = doc.get("proxies")
- const proxyGroups = doc.get("proxy-groups")
- let rules = doc.get("rules").items
- proxies.add(doc.createNode(bridge, { flow: true }))
- let c = 0,
- g = 0
- ips.forEach((ip, i) => {
- if (i % groupSize === 0) {
- const groupProxies = Array.from(
- { length: proxyNumEachGroup },
- (_, j) => {
- const p = doc.createNode(
- {
- name: `${country}-${++c}`,
- type: "socks5",
- server: "adv1.uipoxy.com",
- port: 3000,
- username: `haoge11-zone-custom-region-${country}-session-${randomstring.generate(
- {
- length: 8,
- charset: "alphanumeric"
- }
- )}-sessTime-300-rc-0`,
- password: "qaz112211",
- "dialer-proxy": bridge.name,
- udp: true
- },
- { flow: true }
- )
- proxies.add(p)
- return p
- }
- )
- const group = doc.createNode(
- {
- name: `${country}-GROUP-${++g}`,
- type: "url-test",
- url: "http://www.gstatic.com/generate_204",
- interval: 150,
- tolerance: 50,
- proxies: groupProxies.map(p => p.get("name"))
- },
- { flow: true }
- )
- proxyGroups.add(group)
- }
- rules.unshift(
- `SRC-IP-CIDR,${ip}/32,${proxyGroups
- .get(proxyGroups.items.length - 1)
- .get("name")}`
- )
- })
- rules = commonRules
- .map(r => r.replace("$bridge", bridge.name))
- .concat(rules)
- doc.set("rules", rules)
- fs.writeFileSync(
- `dist/${net.router}-${country}-IPMOYU-${bridge.name}.yaml`,
- doc.toString({
- lineWidth: 0
- })
- )
- }
- }
- const doc = parseDocument(template)
- doc.set("unified-delay", true)
- const proxies = doc.get("proxies")
- proxies.add(doc.createNode(bridge, { flow: true }))
- countryList
- .filter(country => country.abbr && country.abbr !== "-")
- .sort((a, b) => a.abbr.localeCompare(b.abbr))
- .forEach((country, i) => {
- const p = doc.createNode(
- {
- name: `${country.abbr}-${country.chnName}`,
- type: "socks5",
- server: "adv1.uipoxy.com",
- port: 3000,
- username: `haoge11-zone-custom-region-${country.abbr}-session-${randomstring.generate(
- {
- length: 8,
- charset: "alphanumeric"
- }
- )}-sessTime-300-rc-0`,
- password: "qaz112211",
- "dialer-proxy": bridge.name,
- udp: true
- },
- { flow: true }
- )
- proxies.add(p)
- })
- fs.writeFileSync(`dist/IPMOYU-GLOBAL.yaml`, doc.toString({ lineWidth: 0 }))
|