瀏覽代碼

Feat: auto generate AWS S3 domain list

SukkaW 3 年之前
父節點
當前提交
980cf95c43
共有 5 個文件被更改,包括 29 次插入4 次删除
  1. 1 0
      .github/workflows/main.yml
  2. 24 0
      Build/build-cdn-conf.js
  3. 0 2
      List/domainset/cdn.conf
  4. 2 0
      List/non_ip/cdn.conf
  5. 2 2
      README.md

+ 1 - 0
.github/workflows/main.yml

@@ -31,6 +31,7 @@ jobs:
     - run: node ./Build/build-reject-domainset.js
     - run: node ./Build/build-telegram-cidr.js
     - run: node ./Build/build-index.html.js
+    - run: node Build/build-cdn-conf.js
     - name: Deploy
       uses: peaceiris/actions-gh-pages@v3
       with:

+ 24 - 0
Build/build-cdn-conf.js

@@ -0,0 +1,24 @@
+const { fetch } = require('undici');
+const fs = require('fs');
+const path = require('path');
+
+(async () => {
+  const domains = (await (await fetch('https://publicsuffix.org/list/public_suffix_list.dat')).text()).split('\n');
+
+  const awsS3 = domains.filter(line => {
+    if (line) {
+      return line.startsWith('s3') && line.endsWith('.amazonaws.com') && !line.includes('cn-')
+    }
+
+    return false;
+  })
+
+  const filePath = path.resolve(__dirname, '../List/non_ip/cdn.conf');
+  const content = (await fs.promises.readFile(filePath, 'utf-8'))
+    .replace(
+      '# --- [AWS S3 Replace Me] ---',
+      awsS3.map(domain => `DOMAIN-SUFFIX,${domain}`).join('\n')
+    );
+
+  await fs.promises.writeFile(filePath, content, 'utf-8');
+})();

+ 0 - 2
List/domainset/cdn.conf

@@ -271,8 +271,6 @@ images.prismic.io
 # >> General CDN
 # CookieLaw
 .cdn.cookielaw.org
-# AWS S3
-.s3.amazonaws.com
 # Cloudflare
 static.dash.cloudflare.com
 # Tumblr

+ 2 - 0
List/non_ip/cdn.conf

@@ -23,3 +23,5 @@ DOMAIN-SUFFIX,firebaseapp.com
 DOMAIN-SUFFIX,csb.app
 # >> Microsoft Azure
 DOMAIN-SUFFIX,azurestaticapps.net
+# >> AWS S3
+# --- [AWS S3 Replace Me] ---

+ 2 - 2
README.md

@@ -46,8 +46,8 @@ DOMAIN-SET,https://ruleset.skk.moe/List/domainset/cdn.conf,[Replace with your po
 RULE-SET,https://ruleset.skk.moe/List/non_ip/cdn.conf,[Replace with your policy]
 ```
 
-- 人工维护
-- 包含所有常见静态资源 CDN 域名
+- 自动生成 + 人工维护
+- 包含所有常见静态资源 CDN 域名、对象存储域名
 - 如果你正在使用商业性质的公共代理服务、且你的服务商提供按低倍率结算流量消耗的节点,可使用上述规则组将流量分配给这部分节点
 
 #### 流媒体