mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-13 17:50:34 +08:00
Chore: minor changes
This commit is contained in:
parent
7acda2b5a4
commit
ac2d140893
@ -9,20 +9,20 @@ import fs from 'node:fs';
|
||||
import { OUTPUT_INTERNAL_DIR } from './constants/dir';
|
||||
import { asyncWriteToStream } from './lib/async-write-to-stream';
|
||||
import { mkdirp } from './lib/misc';
|
||||
import { appendArrayInPlace } from './lib/append-array-in-place';
|
||||
|
||||
export const buildInternalReverseChnCIDR = task(require.main === module, __filename)(async () => {
|
||||
const [cidr] = await getChnCidrPromise();
|
||||
|
||||
const reversedCidr = merge(
|
||||
const reversedCidr = merge(appendArrayInPlace(
|
||||
exclude(
|
||||
['0.0.0.0/0'],
|
||||
RESERVED_IPV4_CIDR.concat(cidr),
|
||||
true
|
||||
).concat(
|
||||
// https://github.com/misakaio/chnroutes2/issues/25
|
||||
NON_CN_CIDR_INCLUDED_IN_CHNROUTE
|
||||
)
|
||||
);
|
||||
),
|
||||
// https://github.com/misakaio/chnroutes2/issues/25
|
||||
NON_CN_CIDR_INCLUDED_IN_CHNROUTE
|
||||
));
|
||||
|
||||
const outputFile = path.join(OUTPUT_INTERNAL_DIR, 'reversed-chn-cidr.txt');
|
||||
await mkdirp(OUTPUT_INTERNAL_DIR);
|
||||
|
||||
@ -5,6 +5,7 @@ import { DIRECTS, LANS } from '../Source/non_ip/direct';
|
||||
import * as yaml from 'yaml';
|
||||
import { writeFile } from './lib/misc';
|
||||
import { OUTPUT_INTERNAL_DIR, OUTPUT_MODULES_DIR } from './constants/dir';
|
||||
import { appendArrayInPlace } from './lib/append-array-in-place';
|
||||
|
||||
const HOSTNAMES = [
|
||||
// Network Detection, Captive Portal
|
||||
@ -48,7 +49,7 @@ export const buildAlwaysRealIPModule = task(require.main === module, __filename)
|
||||
// Intranet, Router Setup, and mant more
|
||||
const dataset = [Object.entries(DIRECTS), Object.entries(LANS)];
|
||||
const surge = dataset.flatMap(data => data.flatMap(([, { domains }]) => domains.flatMap((domain) => [`*.${domain}`, domain])));
|
||||
const clash = dataset.flatMap(data => data.flatMap(([, { domains }]) => domains.map((domain) => `+.${domain}`)));
|
||||
const clash = ;
|
||||
|
||||
return Promise.all([
|
||||
compareAndWriteFile(
|
||||
@ -67,7 +68,10 @@ export const buildAlwaysRealIPModule = task(require.main === module, __filename)
|
||||
yaml.stringify(
|
||||
{
|
||||
dns: {
|
||||
'fake-ip-filter': HOSTNAMES.concat(clash)
|
||||
'fake-ip-filter': appendArrayInPlace(
|
||||
dataset.flatMap(data => data.flatMap(([, { domains }]) => domains.map((domain) => `+.${domain}`))),
|
||||
HOSTNAMES
|
||||
)
|
||||
}
|
||||
},
|
||||
{ version: '1.1' }
|
||||
|
||||
@ -97,7 +97,7 @@ export class RulesetOutput extends RuleOutput {
|
||||
const singbox: SingboxSourceFormat = {
|
||||
version: 2,
|
||||
rules: [{
|
||||
domain: ['this_ruleset_is_made_by_sukkaw.ruleset.skk.moe'].concat(this.computed()[0]),
|
||||
domain: appendArrayInPlace(['this_ruleset_is_made_by_sukkaw.ruleset.skk.moe'], this.computed()[0]),
|
||||
domain_suffix: this.computed()[1],
|
||||
domain_keyword: Array.from(this.domainKeywords),
|
||||
domain_regex: Array.from(this.domainWildcard).map(RuleOutput.domainWildCardToRegex),
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { domainWildCardToRegex } from './misc';
|
||||
import { isProbablyIpv4, isProbablyIpv6 } from './is-fast-ip';
|
||||
|
||||
const unsupported = Symbol('unsupported');
|
||||
@ -10,13 +9,6 @@ const toNumberTuple = <T extends string>(key: T, value: string): [T, number] | n
|
||||
|
||||
// https://sing-box.sagernet.org/configuration/rule-set/source-format/
|
||||
export const PROCESSOR: Record<string, ((raw: string, type: string, value: string) => [key: keyof SingboxHeadlessRule, value: Required<SingboxHeadlessRule>[keyof SingboxHeadlessRule][number]] | null) | typeof unsupported> = {
|
||||
DOMAIN: (_1, _2, value) => ['domain', value],
|
||||
'DOMAIN-SUFFIX': (_1, _2, value) => ['domain_suffix', value],
|
||||
'DOMAIN-KEYWORD': (_1, _2, value) => ['domain_keyword', value],
|
||||
'DOMAIN-WILDCARD': (_1, _2, value) => ['domain_regex', domainWildCardToRegex(value)],
|
||||
GEOIP: unsupported,
|
||||
'IP-CIDR': (_1, _2, value) => ['ip_cidr', value.endsWith(',no-resolve') ? value.slice(0, -11) : value],
|
||||
'IP-CIDR6': (_1, _2, value) => ['ip_cidr', value.endsWith(',no-resolve') ? value.slice(0, -11) : value],
|
||||
'IP-ASN': unsupported,
|
||||
'SRC-IP': (_1, _2, value) => {
|
||||
if (value.includes('/')) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user