mirror of
https://github.com/RubyMetric/chsrc
synced 2025-06-28 15:32:46 +08:00
parent
fd762f9d3c
commit
e65a16c009
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user