| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- 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: "10.2.100.1",
- subnets: ["10.2.100"]
- },
- {
- router: "10.2.101.1",
- subnets: ["10.2.101"]
- },
- {
- router: "10.2.102.1",
- subnets: ["10.2.102"]
- }
- ]
- const {
- data: { data: countryList }
- } = await axios.get("http://adv1.uipoxy.com/proxy/web/map/countryList", {
- params: {
- page: 1,
- limit: 1000
- }
- })
- const template = fs.readFileSync(`dist/sub-vn.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: ["8.8.8.8", "114.114.114.114"],
- "proxy-server-nameserver": ["8.8.8.8"],
- "use-hosts": true,
- "default-nameserver": ["8.8.8.8", "114.114.114.114"]
- })
- doc.set("hosts", {
- "zipfile.mesgity.top": "154.21.92.47"
- })
- doc.set("unified-delay", true)
- const proxies = doc.get("proxies")
- const proxyGroups = []
- doc.set("proxy-groups", proxyGroups)
- 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_${countryId}_0_0_10_${randomstring.generate({
- length: 8,
- charset: "alphanumeric"
- })}_5_1`,
- password: "qaz112211",
- 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.push(group)
- }
- rules.unshift(
- `SRC-IP-CIDR,${ip}/32,${proxyGroups[proxyGroups.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_${country.id}_0_0_10_${randomstring.generate({
- length: 8,
- charset: "alphanumeric"
- })}_5_1`,
- password: "qaz112211",
- udp: true
- },
- { flow: true }
- )
- proxies.add(p)
- })
- // fs.writeFileSync(`dist/IPMOYU-GLOBAL.yaml`, doc.toString({ lineWidth: 0 }))
|