mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-12-05 14:10:18 +08:00
feat: build in asn mmdb (#7974)
* chore(scripts): add ASN mmdb resolution to prebuild tasks * docs: update Changelog.md * docs: update Cangelog.md * feat: include ASN database in runtime resources
This commit is contained in:
@@ -14,5 +14,6 @@
|
|||||||
<summary><strong> 🚀 优化改进 </strong></summary>
|
<summary><strong> 🚀 优化改进 </strong></summary>
|
||||||
|
|
||||||
- 优化系统服务版本检查:版本与当前应用要求不一致时,提示卸载后重新安装
|
- 优化系统服务版本检查:版本与当前应用要求不一致时,提示卸载后重新安装
|
||||||
|
- 优化预构建资源,补充 ASN 数据库文件
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|||||||
+18
-11
@@ -1,9 +1,9 @@
|
|||||||
import { execFileSync, execSync } from 'child_process'
|
import { execFileSync, execSync } from 'node:child_process'
|
||||||
import { createHash } from 'crypto'
|
import { createHash } from 'node:crypto'
|
||||||
import fs from 'fs'
|
import fs from 'node:fs'
|
||||||
import fsp from 'fs/promises'
|
import fsp from 'node:fs/promises'
|
||||||
import path from 'path'
|
import path from 'node:path'
|
||||||
import zlib from 'zlib'
|
import zlib from 'node:zlib'
|
||||||
|
|
||||||
import AdmZip from 'adm-zip'
|
import AdmZip from 'adm-zip'
|
||||||
import { glob } from 'glob'
|
import { glob } from 'glob'
|
||||||
@@ -485,7 +485,7 @@ const resolvePlugin = async () => {
|
|||||||
const zip = new AdmZip(tempZip)
|
const zip = new AdmZip(tempZip)
|
||||||
zip
|
zip
|
||||||
.getEntries()
|
.getEntries()
|
||||||
.forEach((entry) => log_debug(`"SimpleSC" entry`, entry.entryName))
|
.forEach((entry) => void log_debug(`"SimpleSC" entry`, entry.entryName))
|
||||||
zip.extractAllTo(tempDir, true)
|
zip.extractAllTo(tempDir, true)
|
||||||
if (fs.existsSync(tempDll)) {
|
if (fs.existsSync(tempDll)) {
|
||||||
await fsp.cp(tempDll, pluginPath, { recursive: true, force: true })
|
await fsp.cp(tempDll, pluginPath, { recursive: true, force: true })
|
||||||
@@ -553,7 +553,7 @@ const SERVICE_BINARIES = [
|
|||||||
|
|
||||||
function serviceFileInfo(name) {
|
function serviceFileInfo(name) {
|
||||||
const ext = platform === 'win32' ? '.exe' : ''
|
const ext = platform === 'win32' ? '.exe' : ''
|
||||||
const suffix = platform === 'linux' ? '-' + SIDECAR_HOST : ''
|
const suffix = platform === 'linux' ? `-${SIDECAR_HOST}` : ''
|
||||||
return {
|
return {
|
||||||
sourceFile: `${name}${ext}`,
|
sourceFile: `${name}${ext}`,
|
||||||
targetFile: `${name}${suffix}${ext}`,
|
targetFile: `${name}${suffix}${ext}`,
|
||||||
@@ -604,8 +604,9 @@ async function resolveServiceBundle() {
|
|||||||
const zip = new AdmZip(tempArchive)
|
const zip = new AdmZip(tempArchive)
|
||||||
zip
|
zip
|
||||||
.getEntries()
|
.getEntries()
|
||||||
.forEach((entry) =>
|
.forEach(
|
||||||
log_debug('"clash-verge-service-ipc" entry:', entry.entryName),
|
(entry) =>
|
||||||
|
void log_debug('"clash-verge-service-ipc" entry:', entry.entryName),
|
||||||
)
|
)
|
||||||
zip.extractAllTo(tempDir, true)
|
zip.extractAllTo(tempDir, true)
|
||||||
} else {
|
} else {
|
||||||
@@ -652,7 +653,7 @@ async function resolveCoreHashes() {
|
|||||||
.digest('hex')
|
.digest('hex')
|
||||||
lines.push(`!define ${define} "${digest}"`)
|
lines.push(`!define ${define} "${digest}"`)
|
||||||
}
|
}
|
||||||
await fsp.writeFile(CORE_HASHES_NSH, lines.join('\n') + '\n')
|
await fsp.writeFile(CORE_HASHES_NSH, `${lines.join('\n')}\n`)
|
||||||
log_success(`Generated ${CORE_HASHES_NSH}`)
|
log_success(`Generated ${CORE_HASHES_NSH}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -661,6 +662,11 @@ const resolveMmdb = () =>
|
|||||||
file: 'Country.mmdb',
|
file: 'Country.mmdb',
|
||||||
downloadURL: `https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/country.mmdb`,
|
downloadURL: `https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/country.mmdb`,
|
||||||
})
|
})
|
||||||
|
const resolveASNMmdb = () =>
|
||||||
|
resolveResource({
|
||||||
|
file: 'ASN.mmdb',
|
||||||
|
downloadURL: `https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/GeoLite2-ASN.mmdb`,
|
||||||
|
})
|
||||||
const resolveGeosite = () =>
|
const resolveGeosite = () =>
|
||||||
resolveResource({
|
resolveResource({
|
||||||
file: 'geosite.dat',
|
file: 'geosite.dat',
|
||||||
@@ -706,6 +712,7 @@ const tasks = [
|
|||||||
{ name: 'plugin', func: resolvePlugin, retry: 5, winOnly: true },
|
{ name: 'plugin', func: resolvePlugin, retry: 5, winOnly: true },
|
||||||
{ name: 'service', func: resolveServiceBundle, retry: 5 },
|
{ name: 'service', func: resolveServiceBundle, retry: 5 },
|
||||||
{ name: 'mmdb', func: resolveMmdb, retry: 5 },
|
{ name: 'mmdb', func: resolveMmdb, retry: 5 },
|
||||||
|
{ name: 'asn_mmdb', func: resolveASNMmdb, retry: 5 },
|
||||||
{ name: 'geosite', func: resolveGeosite, retry: 5 },
|
{ name: 'geosite', func: resolveGeosite, retry: 5 },
|
||||||
{ name: 'geoip', func: resolveGeoIP, retry: 5 },
|
{ name: 'geoip', func: resolveGeoIP, retry: 5 },
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use std::path::{Component, Path, PathBuf};
|
|||||||
|
|
||||||
pub(crate) const GEO_ASSETS: &[&str] = &[
|
pub(crate) const GEO_ASSETS: &[&str] = &[
|
||||||
"Country.mmdb",
|
"Country.mmdb",
|
||||||
|
"ASN.mmdb",
|
||||||
"geoip.dat",
|
"geoip.dat",
|
||||||
"geosite.dat",
|
"geosite.dat",
|
||||||
"geoip.metadb",
|
"geoip.metadb",
|
||||||
|
|||||||
@@ -516,7 +516,7 @@ pub async fn init_resources() -> Result<()> {
|
|||||||
std::mem::drop(fs::create_dir_all(&res_dir).await);
|
std::mem::drop(fs::create_dir_all(&res_dir).await);
|
||||||
}
|
}
|
||||||
|
|
||||||
let file_list = ["Country.mmdb", "geoip.dat", "geosite.dat"];
|
let file_list = ["Country.mmdb", "ASN.mmdb", "geoip.dat", "geosite.dat"];
|
||||||
|
|
||||||
for file in file_list.iter() {
|
for file in file_list.iter() {
|
||||||
let src_path = res_dir.join(file);
|
let src_path = res_dir.join(file);
|
||||||
|
|||||||
Reference in New Issue
Block a user