mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-19 07:40:47 +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>
|
||||
|
||||
- 优化系统服务版本检查:版本与当前应用要求不一致时,提示卸载后重新安装
|
||||
- 优化预构建资源,补充 ASN 数据库文件
|
||||
|
||||
</details>
|
||||
|
||||
+18
-11
@@ -1,9 +1,9 @@
|
||||
import { execFileSync, execSync } from 'child_process'
|
||||
import { createHash } from 'crypto'
|
||||
import fs from 'fs'
|
||||
import fsp from 'fs/promises'
|
||||
import path from 'path'
|
||||
import zlib from 'zlib'
|
||||
import { execFileSync, execSync } from 'node:child_process'
|
||||
import { createHash } from 'node:crypto'
|
||||
import fs from 'node:fs'
|
||||
import fsp from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
import zlib from 'node:zlib'
|
||||
|
||||
import AdmZip from 'adm-zip'
|
||||
import { glob } from 'glob'
|
||||
@@ -485,7 +485,7 @@ const resolvePlugin = async () => {
|
||||
const zip = new AdmZip(tempZip)
|
||||
zip
|
||||
.getEntries()
|
||||
.forEach((entry) => log_debug(`"SimpleSC" entry`, entry.entryName))
|
||||
.forEach((entry) => void log_debug(`"SimpleSC" entry`, entry.entryName))
|
||||
zip.extractAllTo(tempDir, true)
|
||||
if (fs.existsSync(tempDll)) {
|
||||
await fsp.cp(tempDll, pluginPath, { recursive: true, force: true })
|
||||
@@ -553,7 +553,7 @@ const SERVICE_BINARIES = [
|
||||
|
||||
function serviceFileInfo(name) {
|
||||
const ext = platform === 'win32' ? '.exe' : ''
|
||||
const suffix = platform === 'linux' ? '-' + SIDECAR_HOST : ''
|
||||
const suffix = platform === 'linux' ? `-${SIDECAR_HOST}` : ''
|
||||
return {
|
||||
sourceFile: `${name}${ext}`,
|
||||
targetFile: `${name}${suffix}${ext}`,
|
||||
@@ -604,8 +604,9 @@ async function resolveServiceBundle() {
|
||||
const zip = new AdmZip(tempArchive)
|
||||
zip
|
||||
.getEntries()
|
||||
.forEach((entry) =>
|
||||
log_debug('"clash-verge-service-ipc" entry:', entry.entryName),
|
||||
.forEach(
|
||||
(entry) =>
|
||||
void log_debug('"clash-verge-service-ipc" entry:', entry.entryName),
|
||||
)
|
||||
zip.extractAllTo(tempDir, true)
|
||||
} else {
|
||||
@@ -652,7 +653,7 @@ async function resolveCoreHashes() {
|
||||
.digest('hex')
|
||||
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}`)
|
||||
}
|
||||
|
||||
@@ -661,6 +662,11 @@ const resolveMmdb = () =>
|
||||
file: '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 = () =>
|
||||
resolveResource({
|
||||
file: 'geosite.dat',
|
||||
@@ -706,6 +712,7 @@ const tasks = [
|
||||
{ name: 'plugin', func: resolvePlugin, retry: 5, winOnly: true },
|
||||
{ name: 'service', func: resolveServiceBundle, retry: 5 },
|
||||
{ name: 'mmdb', func: resolveMmdb, retry: 5 },
|
||||
{ name: 'asn_mmdb', func: resolveASNMmdb, retry: 5 },
|
||||
{ name: 'geosite', func: resolveGeosite, retry: 5 },
|
||||
{ name: 'geoip', func: resolveGeoIP, retry: 5 },
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ use std::path::{Component, Path, PathBuf};
|
||||
|
||||
pub(crate) const GEO_ASSETS: &[&str] = &[
|
||||
"Country.mmdb",
|
||||
"ASN.mmdb",
|
||||
"geoip.dat",
|
||||
"geosite.dat",
|
||||
"geoip.metadb",
|
||||
|
||||
@@ -516,7 +516,7 @@ pub async fn init_resources() -> Result<()> {
|
||||
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() {
|
||||
let src_path = res_dir.join(file);
|
||||
|
||||
Reference in New Issue
Block a user