-
Notifications
You must be signed in to change notification settings - Fork 53
Recipe: rotating upstream proxies
Snawoot edited this page Dec 27, 2024
·
3 revisions
We can rotate upstream proxy from the list with -js-proxy-router script like this:
const serverList = [
"https://USERNAME:[email protected]:443",
"https://USERNAME:[email protected]:443",
"https://USERNAME:[email protected]:443",
"https://USERNAME:[email protected]:443",
"https://USERNAME:[email protected]:443",
"https://USERNAME:[email protected]:443",
"https://USERNAME:[email protected]:443",
"https://USERNAME:[email protected]:443",
]
const rotationPeriod = 600 // 10 minutes
function getProxy() {
const ts = Math.floor(Date.now() / 1000)
return serverList[Math.floor(ts / rotationPeriod) % serverList.length]
}Each 10 minutes next proxy from the list will be selected for a new connection. Note that already established connections will remain on the same proxy chosen once that connection was established.