From 6e2b33269a8a25d7c64ed57d084c812f4ab3cc8d Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Fri, 11 Jul 2025 19:28:56 +0800 Subject: [PATCH] Add provider type --- src/framework/mirror.c | 31 +++++++++++++++++++++++++++++++ src/framework/struct.h | 14 +++++++++++++- src/recipe/lang/Dart/common.h | 1 + src/recipe/lang/Go.c | 2 ++ src/recipe/lang/Lua.c | 1 + src/recipe/lang/Node.js/common.h | 1 + src/recipe/lang/NuGet.c | 1 + src/recipe/lang/Ruby.c | 1 + src/recipe/lang/Rust/common.h | 1 + src/recipe/ware/Docker-Hub.c | 3 +++ src/recipe/ware/Emacs.c | 1 + src/recipe/ware/Flathub.c | 2 ++ 12 files changed, 58 insertions(+), 1 deletion(-) diff --git a/src/framework/mirror.c b/src/framework/mirror.c index 0c5734c..255bf23 100644 --- a/src/framework/mirror.c +++ b/src/framework/mirror.c @@ -28,12 +28,14 @@ */ MirrorSite_t MirrorZ = { + IS_GeneralMirrorSite, "mirrorz", "MirrorZ", "校园网联合镜像站(MirrorZ)", "https://mirrors.cernet.edu.cn/", {SKIP, "功能特殊无法测速,跳过", "SKIP because of its special function", NULL, ROUGH} }, Tuna = { + IS_GeneralMirrorSite, "tuna", "TUNA", "清华大学开源软件镜像站", "https://mirrors.tuna.tsinghua.edu.cn/", {NotSkip, NA, NA, "https://mirrors.tuna.tsinghua.edu.cn/speedtest/1000mb.bin", ROUGH} }, @@ -45,66 +47,77 @@ Tuna = Sjtug_Zhiyuan = { + IS_GeneralMirrorSite, "sjtu-zy", "SJTUG-zhiyuan", "上海交通大学致远镜像站", "https://mirrors.sjtug.sjtu.edu.cn/", {NotSkip, NA, NA, "https://mirrors.sjtug.sjtu.edu.cn/ctan" Big_File_ctan, ROUGH} }, Sjtug_Siyuan = { + IS_GeneralMirrorSite, "sjtu-sy", "SJTUG-siyuan", "上海交通大学思源镜像站", "https://mirror.sjtu.edu.cn/", {NotSkip, NA, NA, "https://mirror.sjtu.edu.cn/ctan" Big_File_ctan, ROUGH} }, Zju = { + IS_GeneralMirrorSite, "zju", "ZJU", "浙江大学开源软件镜像站", "https://mirrors.zju.edu.cn/", {NotSkip, NA, NA, "https://mirrors.zju.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH} }, Lzuoss = { + IS_GeneralMirrorSite, "lzu", "LZUOSS", "兰州大学开源社区镜像站", "https://mirror.lzu.edu.cn/", {NotSkip, NA, NA, "https://mirror.lzu.edu.cn/CTAN" Big_File_ctan, ROUGH} }, Jlu = { + IS_GeneralMirrorSite, "jlu", "JLU", "吉林大学开源镜像站", "https://mirrors.jlu.edu.cn/", {NotSkip, NA, NA, "https://mirrors.jlu.edu.cn/_static/speedtest.bin", ROUGH} }, Bfsu = { + IS_GeneralMirrorSite, "bfsu", "BFSU", "北京外国语大学开源软件镜像站", "https://mirrors.bfsu.edu.cn/", {NotSkip, NA, NA, "https://mirrors.bfsu.edu.cn/speedtest/1000mb.bin", ROUGH} }, Pku = { + IS_GeneralMirrorSite, "pku", "PKU", "北京大学开源镜像站", "https://mirrors.pku.edu.cn/", {NotSkip, NA, NA, "https://mirrors.pku.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH} }, Bjtu = { + IS_GeneralMirrorSite, "bjtu", "BJTU", "北京交通大学自由与开源软件镜像站", "https://mirror.bjtu.edu.cn/", {NotSkip, NA, NA, "https://mirror.bjtu.edu.cn/archlinux" Big_File_archlinux, ROUGH} }, Sustech = { + IS_GeneralMirrorSite, "sustech", "SUSTech", "南方科技大学开源软件镜像站", "https://mirrors.sustech.edu.cn/", {NotSkip, NA, NA, "https://mirrors.sustech.edu.cn/site/speedtest/1000mb.bin", ROUGH} }, Ustc = { + IS_GeneralMirrorSite, "ustc", "USTC", "中国科学技术大学开源镜像站", "https://mirrors.ustc.edu.cn/", {NotSkip, NA, NA, "https://mirrors.ustc.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH} }, Hust = { + IS_GeneralMirrorSite, "hust", "HUST", "华中科技大学开源镜像站", "https://mirrors.hust.edu.cn/", {NotSkip, NA, NA, "https://mirrors.hust.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH} }, @@ -113,42 +126,49 @@ Hust = Iscas = { + IS_GeneralMirrorSite, "iscas", "ISCAS", "中科院软件所智能软件研究中心开源镜像站", "https://mirror.iscas.ac.cn/", {NotSkip, NA, NA, "https://mirror.iscas.ac.cn/ubuntu-releases" Big_File_ubuntu, ROUGH} }, Scau = { + IS_GeneralMirrorSite, "scau", "SCAU", "华南农业大学开源软件镜像站", "https://mirrors.scau.edu.cn/", {NotSkip, NA, NA, "https://mirrors.scau.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH} }, NJTech = { + IS_GeneralMirrorSite, "njtech", "NJTech", "南京工业大学开源软件镜像站", "https://mirrors.njtech.edu.cn/", {NotSkip, NA, NA, "https://mirrors.njtech.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH} }, Nyist = { + IS_GeneralMirrorSite, "nyist", "NYIST", "南阳理工学院开源软件镜像站", "https://mirror.nyist.edu.cn/", {NotSkip, NA, NA, "https://mirror.nyist.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH} }, Sdu = { + IS_GeneralMirrorSite, "sdu", "SDU", "山东大学镜像站", "https://mirrors.sdu.edu.cn/", {NotSkip, NA, NA, "https://mirrors.sdu.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH} }, Cqupt = { + IS_GeneralMirrorSite, "cqupt", "CQUPT", "重庆邮电大学开源镜像站", "https://mirrors.cqupt.edu.cn/", {NotSkip, NA, NA, "https://mirrors.cqupt.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH} }, Nju = { + IS_GeneralMirrorSite, "nju", "NJU", "南京大学开源镜像站", "https://mirrors.nju.edu.cn/", {NotSkip, NA, NA, "https://mirrors.nju.edu.cn/archlinux" Big_File_archlinux, ROUGH} }, @@ -158,6 +178,7 @@ Nju = */ Cqu = { + IS_GeneralMirrorSite, "cqu", "CQU", "重庆大学开源软件镜像站", "https://mirrors.cqu.edu.cn/", {NotSkip, NA, NA, "https://mirrors.cqu.edu.cn/ubuntu-releases" Big_File_ubuntu, ROUGH} }; @@ -167,6 +188,7 @@ Cqu = */ MirrorSite_t Ali = { + IS_GeneralMirrorSite, "ali", "Ali OPSX Public", "阿里巴巴开源镜像站(公网)", "https://developer.aliyun.com/mirror/", {NotSkip, NA, NA, "https://mirrors.aliyun.com/ubuntu/ls-lR.gz", ROUGH} // 31MB左右 }, @@ -174,6 +196,7 @@ MirrorSite_t Ali = // https://mirrors.cloud.aliyuncs.com/ Ali_ECS_VPC = { + IS_GeneralMirrorSite, "ali-ECS-VPC", "Ali OPSX ECS VPC", "阿里巴巴开源镜像站(ECS VPC网络)", "https://developer.aliyun.com/mirror/", {NotSkip, NA, NA, "https://mirrors.cloud.aliyuncs.com/deepin-cd" Big_File_deepin, ROUGH} }, @@ -181,6 +204,7 @@ Ali_ECS_VPC = // https://mirrors.aliyuncs.com/ Ali_ECS_classic = { + IS_GeneralMirrorSite, "ali-ECS", "Ali OPSX ECS", "阿里巴巴开源镜像站(ECS 经典网络)", "https://developer.aliyun.com/mirror/", {NotSkip, NA, NA, "https://mirrors.aliyuncs.com/deepin-cd" Big_File_deepin, ROUGH} }, @@ -188,12 +212,14 @@ Ali_ECS_classic = Tencent = { + IS_GeneralMirrorSite, "tencent", "Tencent Public", "腾讯软件源(公网)", "https://mirrors.tencent.com/", {NotSkip, NA, NA, "https://mirrors.cloud.tencent.com/mariadb/mariadb-12.1.0/winx64-packages/mariadb-12.1.0-winx64-debugsymbols.zip", ROUGH} // 110MB左右 }, /* Tencent_Intra = { + IS_GeneralMirrorSite, "tencent-intra", "Tencent Intranet", "腾讯软件源(内网)", "https://mirrors.tencent.com/", {NotSkip, NA, NA, "https://mirrors.cloud.tencentyun.com/ubuntu-releases" Big_File_ubuntu, ROUGH} }, @@ -201,18 +227,21 @@ Tencent_Intra = Huawei = { + IS_GeneralMirrorSite, "huawei", "Huawei Cloud", "华为开源镜像站", "https://mirrors.huaweicloud.com/", {NotSkip, NA, NA, "https://mirrors.huaweicloud.com/ubuntu-releases" Big_File_ubuntu, ROUGH} }, Volcengine = { + IS_GeneralMirrorSite, "volc", "Volcengine", "火山引擎开源软件镜像站(公网)", "https://developer.volcengine.com/mirror/", {NotSkip, NA, NA, "https://mirrors.volces.com/ubuntu-releases" Big_File_ubuntu, ROUGH} }, /* Volceengine_Intra = { + IS_GeneralMirrorSite, "volc-intra", "Volcengine Intranet", "火山引擎开源软件镜像站(内网)", "https://developer.volcengine.com/mirror/", "https://mirrors.ivolces.com/ubuntu-releases" Big_File_ubuntu, ROUGH}, @@ -224,6 +253,7 @@ Volceengine_Intra = */ Netease = { + IS_GeneralMirrorSite, "netease", "Netease", "网易开源镜像站", "https://mirrors.163.com/", {NotSkip, NA, NA, "https://mirrors.163.com/deepin-cd" Big_File_deepin, ROUGH} }, @@ -233,6 +263,7 @@ Netease = */ Sohu = { + IS_GeneralMirrorSite, "sohu", "SOHU", "搜狐开源镜像站", "https://mirrors.sohu.com/", {NotSkip, NA, NA, "https://mirrors.sohu.com/deepin-cd" Big_File_deepin, ROUGH} }; diff --git a/src/framework/struct.h b/src/framework/struct.h index f802944..b282b1d 100644 --- a/src/framework/struct.h +++ b/src/framework/struct.h @@ -30,8 +30,18 @@ ProviderSpeedMeasureInfo_t; #define ACCURATE true #define ROUGH false +typedef enum ProviderType_t +{ + IS_GeneralMirrorSite, /* 通用镜像站 */ + IS_DedicatedMirrorSite, /* 专用镜像站 */ + IS_UpstreamProvider, /* 上游默认源 */ + IS_VirtualProvider, /* 用户提供 */ +} +ProviderType_t; + typedef struct SourceProvider_t { + const ProviderType_t type; /* 类型 */ const char *code; /* 用于用户指定某一 Provider */ const char *abbr; /* 需要使用 Provider 的英文名时,用这个代替,因为大部分 Provider 没有提供正式的英文名 */ const char *name; /* Provider 中文名 */ @@ -44,17 +54,19 @@ typedef SourceProvider_t MirrorSite_t; SourceProvider_t UpstreamProvider = { + IS_UpstreamProvider, /* 引入新的上游默认源时,请使下面第一行的前三个字段保持不变,只添加第四个字段,可使用 def_upstream 宏 */ "upstream", "Upstream", "上游默认源", NULL, /* 引入新的上游默认源时,请完全修改下面这个结构体,可使用 def_need_measure_info 宏 */ {SKIP, "URL未知,邀您参与贡献!", "URL unknown, welcome to contribute!", NULL, ACCURATE} }; -#define def_upstream "upstream", "Upstream", "上游默认源" +#define def_upstream IS_UpstreamProvider, "upstream", "Upstream", "上游默认源" #define def_need_measure_info {SKIP, "缺乏较大的测速对象,邀您参与贡献!", "Lack of large object URL, welcome to contribute!", NULL, ACCURATE} SourceProvider_t UserDefinedProvider = { + IS_VirtualProvider, "user", "用户自定义", "用户自定义", NULL, {SKIP, "用户自定义源不测速", "SKIP for user-defined source", NULL, ACCURATE} }; diff --git a/src/recipe/lang/Dart/common.h b/src/recipe/lang/Dart/common.h index a58683f..a68cae5 100644 --- a/src/recipe/lang/Dart/common.h +++ b/src/recipe/lang/Dart/common.h @@ -11,6 +11,7 @@ static MirrorSite_t FlutterCN = { + IS_DedicatedMirrorSite, "cfug", "CFUG", "Flutter 社区", "https://flutter.cn/", {NotSkip, NA, NA, "https://storage.flutter-io.cn/flutter_infra_release/releases/stable/linux/flutter_linux_v1.0.0-stable.tar.xz", ACCURATE} // 231 MB }; diff --git a/src/recipe/lang/Go.c b/src/recipe/lang/Go.c index 4c837af..21b3b9d 100644 --- a/src/recipe/lang/Go.c +++ b/src/recipe/lang/Go.c @@ -17,12 +17,14 @@ static SourceProvider_t pl_go_upstream = static MirrorSite_t GoProxyCN = { + IS_DedicatedMirrorSite, "goproxy.cn", "Goproxy.cn", "Goproxy.cn (七牛云)", "https://goproxy.cn/", {NotSkip, NA, NA, "https://goproxy.cn/github.com/aws/aws-sdk-go/@v/v1.45.2.zip", ACCURATE} // 30 MB }, GoProxyIO = { + IS_DedicatedMirrorSite, "goproxy.io", "GOPROXY.IO", "GOPROXY.IO", "https://goproxy.io/", {NotSkip, NA, NA, "https://goproxy.io/github.com/aws/aws-sdk-go/@v/v1.45.2.zip", ACCURATE} // 30 MB }; diff --git a/src/recipe/lang/Lua.c b/src/recipe/lang/Lua.c index 5f8ec1a..3262813 100644 --- a/src/recipe/lang/Lua.c +++ b/src/recipe/lang/Lua.c @@ -9,6 +9,7 @@ static MirrorSite_t Api7 = { + IS_DedicatedMirrorSite, "api7", "api7.ai", "深圳支流科技有限公司", "https://www.apiseven.com/", {SKIP, ToFill, ToFill, NULL, ROUGH} }; diff --git a/src/recipe/lang/Node.js/common.h b/src/recipe/lang/Node.js/common.h index 80c60d8..e016a78 100644 --- a/src/recipe/lang/Node.js/common.h +++ b/src/recipe/lang/Node.js/common.h @@ -17,6 +17,7 @@ static SourceProvider_t pl_nodejs_npm_upstream = static MirrorSite_t NpmMirror = { + IS_DedicatedMirrorSite, "npmmirror", "npmmirror", "npmmirror (阿里云赞助)", "https://npmmirror.com/", // 注意,下面这个是跳转后的地址,不确定未来会不会改变 {NotSkip, NA, NA, "https://cdn.npmmirror.com/packages/%40tensorflow/tfjs/4.22.0/tfjs-4.22.0.tgz", ACCURATE} // 29MB diff --git a/src/recipe/lang/NuGet.c b/src/recipe/lang/NuGet.c index 8713683..b78ee5c 100644 --- a/src/recipe/lang/NuGet.c +++ b/src/recipe/lang/NuGet.c @@ -9,6 +9,7 @@ static MirrorSite_t NugetOrg = { + IS_UpstreamProvider, "nuget.org", "NuGet Org", "Nuget Organization", "https://www.nuget.org/", {SKIP, ToFill, ToFill, NULL, ROUGH} }; diff --git a/src/recipe/lang/Ruby.c b/src/recipe/lang/Ruby.c index 4c27543..2c163a1 100644 --- a/src/recipe/lang/Ruby.c +++ b/src/recipe/lang/Ruby.c @@ -16,6 +16,7 @@ static SourceProvider_t pl_ruby_upstream = static MirrorSite_t RubyChina = { + IS_DedicatedMirrorSite, "rubychina", "RubyChina", "Ruby China 社区", "https://gems.ruby-china.com/", {NotSkip, NA, NA, "https://gems.ruby-china.com/rubygems/gems/nokogiri-1.15.0-java.gem", ACCURATE} // 9.9 MB }; diff --git a/src/recipe/lang/Rust/common.h b/src/recipe/lang/Rust/common.h index 16114e9..fcf8895 100644 --- a/src/recipe/lang/Rust/common.h +++ b/src/recipe/lang/Rust/common.h @@ -9,6 +9,7 @@ static MirrorSite_t RsProxyCN = { + IS_DedicatedMirrorSite, "rsproxycn", "RsProxy.cn", "字节跳动基础架构Dev Infra", "https://rsproxy.cn/", {NotSkip, NA, NA, "https://rsproxy.cn/api/v1/crates/windows/0.58.0/download", ACCURATE} }; diff --git a/src/recipe/ware/Docker-Hub.c b/src/recipe/ware/Docker-Hub.c index 3abb386..b16bb75 100644 --- a/src/recipe/ware/Docker-Hub.c +++ b/src/recipe/ware/Docker-Hub.c @@ -11,6 +11,7 @@ static MirrorSite_t DaoCloud = { + IS_DedicatedMirrorSite, "daocloud", "DaoCloud","上海道客网络科技有限公司", "https://www.daocloud.io/", // 没有找到 DaoCloud 合适的下载链接,先随便给一个,以规避 chsrc 自动测速时所有 dockerhub 镜像站都没有测速链接带来的 bug {NotSkip, NA, NA, "https://qiniu-download-public.daocloud.io/DaoCloud_Enterprise/dce5/offline-community-v0.18.0-amd64.tar", ACCURATE} @@ -18,12 +19,14 @@ static MirrorSite_t DaoCloud = Fit2Cloud = { + IS_DedicatedMirrorSite, "fit2cloud", "FIT2CLOUD", "杭州飞致云信息科技有限公司", "https://www.fit2cloud.com/", {SKIP, ToFill, ToFill, NULL, ROUGH} }, Huecker = { + IS_DedicatedMirrorSite, "huecker", "(Russia) Huecker", "俄罗斯 Huecker.io", "https://huecker.io/", // 同 DaoCloud,没有合适的下载链接,先随便给一个,以避免 bug {NotSkip, NA, NA, "https://huecker.io/en/use.html", ROUGH} diff --git a/src/recipe/ware/Emacs.c b/src/recipe/ware/Emacs.c index ae2e3cc..c7e565f 100644 --- a/src/recipe/ware/Emacs.c +++ b/src/recipe/ware/Emacs.c @@ -9,6 +9,7 @@ static MirrorSite_t EmacsChina = { + IS_DedicatedMirrorSite, "emacschina", "EmacsChina", "Emacs China 社区", "https://elpamirror.emacs-china.org/", {SKIP, ToFill, ToFill, NULL, ROUGH} }; diff --git a/src/recipe/ware/Flathub.c b/src/recipe/ware/Flathub.c index b5c265d..d31388f 100644 --- a/src/recipe/ware/Flathub.c +++ b/src/recipe/ware/Flathub.c @@ -26,12 +26,14 @@ static SourceProvider_t wr_flathub_upstream = wr_flathub_siyuan = { + IS_DedicatedMirrorSite, "sjtu-sy", "SJTUG-siyuan", "上海交通大学思源镜像站Flathub", "https://mirror.sjtu.edu.cn/", {NotSkip, NA, NA, "https://mirror.sjtu.edu.cn/flathub/flathub.gpg"} }, wr_flathub_zhiyuan = { + IS_DedicatedMirrorSite, "sjtu-zy", "SJTUG-zhiyuan", "上海交通大学致远镜像站Flathub", "https://mirrors.sjtug.sjtu.edu.cn/", {NotSkip, NA, NA, "https://mirrors.sjtug.sjtu.edu.cn/flathub/flathub.gpg"} };