代码拉取完成,页面将自动刷新
同步操作将从 红日初升/劳资实在受不了github的龟速了 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
const dns = require("dns")
const handleHosts = require("./handleHosts")
const front = "#官网:47.108.77.223"
const rear = "#当前版本更新于:" + new Date().toLocaleString("zh-CN") + "\n#end"
const domains = [
/*
* 这些地址来源于github520,
* 但有些地址可能会返回0.0.0.0,
* 但这不是程序自身的问题,
* 而是防火墙的问题,
* 尚未得到解决
*/
"github.githubassets.com",
"central.github.com",
"desktop.githubusercontent.com",
"assets-cdn.github.com",
"camo.githubusercontent.com",
"github.map.fastly.net",
"github.global.ssl.fastly.net",
"gist.github.com",
"github.io",
"github.com",
"api.github.com",
"raw.githubusercontent.com",
"user-images.githubusercontent.com",
"favicons.githubusercontent.com",
"avatars5.githubusercontent.com",
"avatars4.githubusercontent.com",
"avatars3.githubusercontent.com",
"avatars2.githubusercontent.com",
"avatars1.githubusercontent.com",
"avatars0.githubusercontent.com",
"avatars.githubusercontent.com",
"codeload.github.com",
"github-cloud.s3.amazonaws.com",
"github-com.s3.amazonaws.com",
"github-production-release-asset-2e65be.s3.amazonaws.com",
"github-production-user-asset-6210df.s3.amazonaws.com",
"github-production-repository-file-5c1aeb.s3.amazonaws.com",
"githubstatus.com",
"github.community",
"media.githubusercontent.com"
]
const handleError = require("./handleError")
const jsonToHosts = (data) => {
let result = ""
for (let key in data) {
const value = data[key] //遍历对象时的值
result += "\n" + value + " " + key
}
return result
}
const getHosts = () => {
const hosts = {}
let resultNum = 0
for (let i of domains) {
dns.resolve(i, (err, address) => {
if (err) {
handleError(err)
} else if (address) {
if (address.length > 1) {
for (let j of address) {
if (j !== "0.0.0.0") {
address = j
}
}
} else {
address = address[0]
}
hosts[i] = address
}
resultNum++
})
}
const polling = () => {
if (resultNum === domains.length) {
const resultHosts = front + "\n\n" + jsonToHosts(hosts) + "\n\n" + rear //将结果加上前置文本与后缀文本
handleHosts(resultHosts)
return resultHosts
} else {
setTimeout(polling, 1000) //轮询
}
}
polling()
}
module.exports = getHosts
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。