diff --git a/src/framework/core.c b/src/framework/core.c index 98cfc26..097cb92 100644 --- a/src/framework/core.c +++ b/src/framework/core.c @@ -597,8 +597,8 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor { Source_t src = sources[i]; - const SourceProvider_t *provider = src.provider; - const SpeedMeasureInfo_t smi = provider->smi; + SourceProvider_t *provider = src.provider; + SpeedMeasureInfo_t smi = provider->smi; bool skip = smi.skip; @@ -621,18 +621,23 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor { if (xy_streql ("upstream", provider->code)) { - // 上游源不测速,但不置0,因为要避免这种情况: 可能其他镜像站测速都为0,最后反而选择了该 upstream + /* 上游源不测速,但不置0,因为要避免这种情况: 可能其他镜像站测速都为0,最后反而选择了该 upstream */ speed = -1024*1024*1024; + if (!src.url) + { + smi.skip_reason_CN = "默认上游源URL未知,请帮助补充"; + smi.skip_reason_EN = "The default upstream source URL is unknown, please help to add"; + } } else if (xy_streql ("user", provider->code)) { - // 代码不会执行至此 + /* 代码不会执行至此 */ speed = 1024*1024*1024; } else { - // 什么情况? - speed = -1; + /* 不测速的 Provider */ + speed = 0; } get_measured[i] = false; speed_records[i] = speed; @@ -649,7 +654,11 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor else { const char *msg = CliOpt_InEnglish ? provider->abbr : provider->name; - measure_msgs[i] = xy_strjoin (3, " - ", msg, " ... "); + if (xy_streql ("upstream", provider->code)) + measure_msgs[i] = xy_strjoin (3, " ^ ", msg, " ... "); + else + measure_msgs[i] = xy_strjoin (3, " - ", msg, " ... "); + printf ("%s", measure_msgs[i]); fflush (stdout); diff --git a/src/framework/struct.h b/src/framework/struct.h index c20ac0d..c70b8e5 100644 --- a/src/framework/struct.h +++ b/src/framework/struct.h @@ -14,10 +14,10 @@ typedef struct SpeedMeasureInfo_t { - bool skip; /* 是否默认跳过 */ - const char *skip_reason_CN; /* 跳过的原因(中文)*/ - const char *skip_reason_EN; /* 跳过的原因(英文)*/ - const char *url; /* 测速链接 */ + bool skip; /* 是否默认跳过 */ + char *skip_reason_CN; /* 跳过的原因(中文)*/ + char *skip_reason_EN; /* 跳过的原因(英文)*/ + char *url; /* 测速链接 */ } SpeedMeasureInfo_t; @@ -54,10 +54,10 @@ UserDefinedProvider = { typedef struct Source_t { union { - const SourceProvider_t *provider; - const MirrorSite_t *mirror; + SourceProvider_t *provider; + MirrorSite_t *mirror; }; - const char *url; + char *url; } Source_t; diff --git a/src/recipe/os/APT/Ubuntu.c b/src/recipe/os/APT/Ubuntu.c index 375125f..734c49b 100644 --- a/src/recipe/os/APT/Ubuntu.c +++ b/src/recipe/os/APT/Ubuntu.c @@ -6,7 +6,7 @@ * Contributors : Zhao <1792582687@qq.com> * | * Created On : <2023-08-30> - * Last Modified : <2024-11-21> + * Last Modified : <2024-11-22> * ------------------------------------------------------------*/ /** @@ -14,18 +14,18 @@ */ static Source_t os_ubuntu_sources[] = { - {&UpstreamProvider, "http://archive.ubuntu.com/ubuntu/"}, //不支持https - {&MirrorZ, "https://mirrors.cernet.edu.cn/ubuntu/"}, - {&Ali, "https://mirrors.aliyun.com/ubuntu"}, - {&Volcengine, "https://mirrors.volces.com/ubuntu"}, - {&Bfsu, "https://mirrors.bfsu.edu.cn/ubuntu"}, - {&Ustc, "https://mirrors.ustc.edu.cn/ubuntu"}, - {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/ubuntu"}, - {&Tencent, "https://mirrors.tencent.com/ubuntu"}, + {&UpstreamProvider, "http://archive.ubuntu.com/ubuntu/"}, //不支持https + {&MirrorZ, "https://mirrors.cernet.edu.cn/ubuntu/"}, + {&Ali, "https://mirrors.aliyun.com/ubuntu"}, + {&Volcengine, "https://mirrors.volces.com/ubuntu"}, + {&Bfsu, "https://mirrors.bfsu.edu.cn/ubuntu"}, + {&Ustc, "https://mirrors.ustc.edu.cn/ubuntu"}, + {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/ubuntu"}, + {&Tencent, "https://mirrors.tencent.com/ubuntu"}, // {&Tencent_Intra, "https://mirrors.tencentyun.com/ubuntu"}, - {&Huawei, "https://mirrors.huaweicloud.com/ubuntu"}, - {&Netease, "https://mirrors.163.com/ubuntu"}, - {&Sohu, "https://mirrors.sohu.com/ubuntu"} + {&Huawei, "https://mirrors.huaweicloud.com/ubuntu"}, + {&Netease, "https://mirrors.163.com/ubuntu"}, + {&Sohu, "https://mirrors.sohu.com/ubuntu"} }; def_sources_n(os_ubuntu); @@ -88,6 +88,11 @@ os_ubuntu_setsrc (char *option) { chsrc_ensure_root (); + // https://github.com/RubyMetric/chsrc/issues/121 + SpeedMeasureInfo_t *upsmi = &UpstreamProvider.smi; + upsmi->skip = NotSkip; + upsmi->url = "http://archive.ubuntu.com/ubuntu/dists/noble/Contents-amd64.gz"; + if (chsrc_check_file (OS_Ubuntu_SourceList_DEB822)) { char *msg = CliOpt_InEnglish ? "Will change source based on new format"