diff --git a/Build/build-ai-cidr.ts b/Build/build-ai-cidr.ts index 615b91e7..5c54c361 100644 --- a/Build/build-ai-cidr.ts +++ b/Build/build-ai-cidr.ts @@ -1,11 +1,16 @@ +import path from 'node:path'; import { fastIpVersion } from 'foxts/fast-ip-version'; import { SHARED_DESCRIPTION } from './constants/description'; +import { SOURCE_DIR } from './constants/dir'; import { $$fetch } from './lib/fetch-retry'; +import { readFileIntoProcessedArray } from './lib/fetch-text-by-line'; import { RulesetOutput } from './lib/rules/ruleset'; import { SpanCategory, task } from './trace'; const OPENAI_VOICE_IP_URL = 'https://openai.com/chatgpt-voice.json'; +const localAIIPRulesetPromise = readFileIntoProcessedArray(path.join(SOURCE_DIR, 'ip/ai.conf')); + function parseOpenAIVoiceJSON(data: unknown) { if ( data === null @@ -70,14 +75,15 @@ export const buildAICIDR = task(require.main === module, __filename)(async (span }, SpanCategory.Network); return new RulesetOutput(span, 'ai', 'ip') - .withTitle('Sukka\'s Ruleset - ChatGPT Voice IP CIDR') + .withTitle('Sukka\'s Ruleset - AI IP CIDR') .appendDescription( SHARED_DESCRIPTION, '', - 'This file contains IP ranges used by ChatGPT Voice.' + 'This file contains IP ranges used by AI services, including ChatGPT Voice.' ) - .withDate(lastUpdated) + // .withDate(lastUpdated) // With local source, we no longer use the upstream date for file date .appendDataSource(`${OPENAI_VOICE_IP_URL} (last updated: ${lastUpdated.toISOString()})`) + .addFromRuleset(localAIIPRulesetPromise) .bulkAddCIDR4NoResolve(cidr4) .bulkAddCIDR6NoResolve(cidr6) .write(); diff --git a/Source/ip/ai.conf b/Source/ip/ai.conf new file mode 100644 index 00000000..4c673313 --- /dev/null +++ b/Source/ip/ai.conf @@ -0,0 +1,9 @@ +# $ custom_build_script +# Merged with the ChatGPT Voice IP ranges fetched in Build/build-ai-cidr.ts + +# Add AI service IP rules below, e.g. +# IP-CIDR,192.0.2.0/24,no-resolve +# IP-CIDR6,2001:db8::/32,no-resolve + +# >> Anthropic / Claude +IP-ASN,399358 diff --git a/Source/non_ip/ai.conf b/Source/non_ip/ai.conf index 36f43c3d..45a4b1b9 100644 --- a/Source/non_ip/ai.conf +++ b/Source/non_ip/ai.conf @@ -28,10 +28,13 @@ DOMAIN-KEYWORD,openai # >> Perplexity DOMAIN-SUFFIX,perplexity.ai -# >> Claude +# >> Anthropic / Claude DOMAIN-SUFFIX,anthropic.com DOMAIN-SUFFIX,claude.ai DOMAIN-SUFFIX,claude.com +# For the record, I don't believe Claude will use Short URLs to geo blocking. +# However, since there is some conspiracy theories surrounding it, I will include it. +DOMAIN-SUFFIX,clau.de # >> Google # Gemini