Code Monkey home page Code Monkey logo

rate-mirrors's Introduction

Rate Mirrors

former Rate Arch Mirrors (changed in v0.4.0) - previous README

Tag Badge

This is a tool, which tests mirror speed for:

  • Arch Linux
    • including Chaotic-AUR
    • including Arch Linux CN
  • Arch Linux ARM
  • Manjaro
  • RebornOS
  • Artix Linux
  • CachyOS
  • EndeavourOS
  • any http/https mirrors via stdin.

It uses info about submarine cables and internet exchanges (kudos to TeleGeography for data) to jump between countries and find fast mirrors. And it's fast enough to run it before each system update (~30 seconds with default options).

Installation

  • ArchLinux AUR: yay -S rate-mirrors-bin - pre-built binary with statically linked musl
  • ArchLinux AUR: yay -S rate-mirrors - build binary from sources, linking glibc dynamically
  • Github releases: pre-built binary with statically linked musl

or build manually:

cargo build --release --locked

Usage

  • format is: rate-mirrors {base options} subcommand {subcommand options}
  • run rate-mirrors help to see base options, which go before subcommand
  • it doesn't need root, but if you wish just pass --allow-root option.

Here are supported subcommands:

Each subcommand has its own options, so run rate-mirrors arch --help to see arch specific options, which should go after arch sub-command.

  1. rate-mirrors arch — fetches Arch Linux mirrors, skips outdated/syncing ones and tests them.

    To backup /etc/pacman.d/mirrorlist file and update it with the rated mirrors run the command below:

    export TMPFILE="$(mktemp)"; \
        sudo true; \
        rate-mirrors --save=$TMPFILE arch --max-delay=43200 \
          && sudo mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist-backup \
          && sudo mv $TMPFILE /etc/pacman.d/mirrorlist
    

    Or if you don't need a backup: rate-mirrors arch | sudo tee /etc/pacman.d/mirrorlist.

  2. rate-mirrors archlinuxcn - fetches Arch Linux CN mirrors and tests them

  3. rate-mirrors archarm — fetches Arch Linux ARM mirrors and tests them

  4. rate-mirrors artix — fetches Artix Linux mirrors and tests them

  5. rate-mirrors blackarch - fetches BlackArch mirrors and tests them

  6. rate-mirrors cachyos — fetches CachyOS mirrors and tests them

  7. rate-mirrors chaotic-aur - fetches Arch Linux Chaotic-AUR mirrors and tests them

  8. rate-mirrors endeavouros — fetches/reads EndeavourOS mirrors, skips outdated ones and tests them

  9. rate-mirrors manjaro — fetches Manjaro mirrors, skips outdated ones and tests them

  10. rate-mirrors rebornos — fetches RebornOS mirrors and tests them

  11. rate-mirrors stdin — takes mirrors from stdin

    Each string should comply with one of two supported formats:

    • tab-separated url and country (either name or country code)
    • tab-separated country and url — just in case :)
    • url

    Urls should be what --path-to-test and --path-to-return are joined to.

    e.g. we have a file with mirrors (countries are required for country-hopping):

    https://mirror-a.mirrors.org/best-linux-distro/
    US\thttps://mirror-b.mirrors.org/best-linux-distro/
    https://mirror-c.mirrors.org/best-linux-distro/\tDE
    https://mirror-d.mirrors.org/best-linux-distro/\tAustria
    

    and we'd like to test it & format output for Arch:

    cat mirrors_by_country.txt | \
        rate-mirrors --concurrency=40 stdin \
           --path-to-test="extra/os/x86_64/extra.files" \
           --path-to-return='$repo/os/$arch' \
           --comment-prefix="# " \
           --output-prefix="Server = "
    

Algorithm

The tool uses the following info:

  • submarine cable connections
  • number of internet exchanges per country and distances to weight country connections
  • continents to naively assume countries of the same continent are directly linked

e.g. steps for arch:

  1. fetch mirrors from Arch Linux - Mirror status as json

  2. skip ones, which haven’t completed syncing (--completion=1 option)

  3. skip ones with delays-since-the-last-sync longer than 1 day (--max-delay option)

  4. sort mirrors by “Arch Linux - Mirror Status” score - the lower the better (--sort-mirrors-by=score_asc option)

  5. take the next country to explore (or --entry-country option, US by default -- no need to change)

  6. find neighbor countries --country-neighbors-per-country=3, using multiple strategies:

    • major internet hubs first ( first two jumps only )
    • closest by distance first ( every jump )
  7. take --country-test-mirrors-per-country=2 mirrors per country, selected at step 6, test speed and find 2 mirrors: 1 fastest and 1 with shortest connection time

  8. take countries of mirrors from step 7 and go to step 5

  9. after --max-jumps=7 jumps are done, take top M mirrors by speed (--top-mirrors-number-to-retest=5), test them with no concurrency, sort by speed and prepend to the resulting list

Example of everyday use on Arch Linux:

alias ua-drop-caches='sudo paccache -rk3; yay -Sc --aur --noconfirm'
alias ua-update-all='export TMPFILE="$(mktemp)"; \
    sudo true; \
    rate-mirrors --save=$TMPFILE arch --max-delay=21600 \
      && sudo mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist-backup \
      && sudo mv $TMPFILE /etc/pacman.d/mirrorlist \
      && ua-drop-caches \
      && yay -Syyu --noconfirm'

Few notes:

  • the tool won't work with root permissions because it doesn't need them
  • ua- prefix means "user alias"
  • paccache from pacman-contrib package
  • yay is an AUR helper
  • sudo true forces password prompt in the very beginning

To persist aliases, add them to ~/.zshrc or ~/.bashrc (based on the shell you use)

Once done, just launch a new terminal and run:

ua-update-all

Output example:

Here is an example of running the arch mode from Belarus (output truncated):

# STARTED AT: 2021-06-23 21:44:49.694758291 +03:00
# ARGS: rate-mirrors arch
# FETCHED MIRRORS: 845
# MIRRORS LEFT AFTER FILTERING: 471
# JUMP #1
# EXPLORING US
# VISITED US
#     + NEIGHBOR ID (by HubsFirst)
#     + NEIGHBOR UK (by HubsFirst)
#     + NEIGHBOR CN (by HubsFirst)
#     + NEIGHBOR DE (by DistanceFirst)
#     + NEIGHBOR CA (by DistanceFirst)
#     + NEIGHBOR FR (by DistanceFirst)
# [US] SpeedTestResult { speed: 561.60 KB/s; elapsed: 1.087839405s; connection_time: 381.733267ms}
# [US] SpeedTestResult { speed: 1.32 MB/s; elapsed: 1.157819036s; connection_time: 276.577298ms}
# [UK] SpeedTestResult { speed: 2.65 MB/s; elapsed: 1.224126693s; connection_time: 261.353312ms}
# [UK] SpeedTestResult { speed: 5.48 MB/s; elapsed: 1.327602061s; connection_time: 94.138156ms}
# [ID] SpeedTestResult { speed: 179.68 KB/s; elapsed: 745.86963ms; connection_time: 670.100893ms}
# [DE] SpeedTestResult { speed: 1.98 MB/s; elapsed: 1.392069748s; connection_time: 106.878831ms}
# [DE] SpeedTestResult { speed: 1.76 MB/s; elapsed: 1.26812617s; connection_time: 223.358858ms}
# [CA] SpeedTestResult { speed: 1.04 MB/s; elapsed: 962.017229ms; connection_time: 517.499369ms}
# [CA] SpeedTestResult { speed: 1.67 MB/s; elapsed: 1.20327262s; connection_time: 296.884889ms}
# [FR] SpeedTestResult { speed: 2.50 MB/s; elapsed: 1.154907178s; connection_time: 341.534506ms}
# [FR] SpeedTestResult { speed: 2.25 MB/s; elapsed: 1.374341411s; connection_time: 118.696039ms}
#     TOP NEIGHBOR - CONNECTION TIME: UK - 94.138156ms
#     TOP NEIGHBOR - SPEED: UK - 5.48 MB/s
#
# JUMP #2
# EXPLORING UK
#     + NEIGHBOR NL (by HubsFirst)
#     + NEIGHBOR NO (by HubsFirst)
#     + NEIGHBOR AU (by HubsFirst)
#     + NEIGHBOR CZ (by DistanceFirst)
#     + NEIGHBOR CH (by DistanceFirst)
#     + NEIGHBOR SE (by DistanceFirst)
# ...
# JUMP #7
# ...

# RE-TESTING TOP MIRRORS
# [EE] SpeedTestResult { speed: 4.92 MB/s; elapsed: 1.320800025s; connection_time: 178.606272ms}
# [UK] SpeedTestResult { speed: 6.95 MB/s; elapsed: 791.741365ms; connection_time: 709.525808ms}
# [FI] SpeedTestResult { speed: 8.94 MB/s; elapsed: 1.376742398s; connection_time: 123.530685ms}
# [TR] SpeedTestResult { speed: 5.57 MB/s; elapsed: 1.243114863s; connection_time: 257.162963ms}
# [EE] SpeedTestResult { speed: 9.68 MB/s; elapsed: 1.41574022s; connection_time: 84.436077ms}
# ==== RESULTS (top re-tested) ====
#   1. [EE] SpeedTestResult { speed: 9.68 MB/s; elapsed: 1.41574022s; connection_time: 84.436077ms} -> http://mirror.cspacehostings.com/archlinux/
#   2. [FI] SpeedTestResult { speed: 8.94 MB/s; elapsed: 1.376742398s; connection_time: 123.530685ms} -> http://arch.mirror.far.fi/
#   3. [UK] SpeedTestResult { speed: 6.95 MB/s; elapsed: 791.741365ms; connection_time: 709.525808ms} -> http://archlinux.uk.mirror.allworldit.com/archlinux/
#   4. [TR] SpeedTestResult { speed: 5.57 MB/s; elapsed: 1.243114863s; connection_time: 257.162963ms} -> http://mirror.veriteknik.net.tr/archlinux/
#   5. [EE] SpeedTestResult { speed: 4.92 MB/s; elapsed: 1.320800025s; connection_time: 178.606272ms} -> https://mirror.cspacehostings.com/archlinux/
#   6. [BY] SpeedTestResult { speed: 3.66 MB/s; elapsed: 1.455269308s; connection_time: 44.256906ms} -> http://ftp.byfly.by/pub/archlinux/
#   7. [SE] SpeedTestResult { speed: 3.40 MB/s; elapsed: 1.270306507s; connection_time: 230.675741ms} -> https://mirror.osbeck.com/archlinux/
#   8. [BY] SpeedTestResult { speed: 3.40 MB/s; elapsed: 1.467606681s; connection_time: 32.547398ms} -> http://mirror.datacenter.by/pub/archlinux/
# ...
# FINISHED AT: 2021-06-23 21:45:15.555642390 +03:00
Server = http://mirror.cspacehostings.com/archlinux/$repo/os/$arch
Server = http://arch.mirror.far.fi/$repo/os/$arch
Server = http://archlinux.uk.mirror.allworldit.com/archlinux/$repo/os/$arch
Server = http://mirror.veriteknik.net.tr/archlinux/$repo/os/$arch
Server = https://mirror.cspacehostings.com/archlinux/$repo/os/$arch
Server = http://ftp.byfly.by/pub/archlinux/$repo/os/$arch
Server = https://mirror.osbeck.com/archlinux/$repo/os/$arch
Server = http://mirror.datacenter.by/pub/archlinux/$repo/os/$arch

Support

License

The tool is made available under the following Creative Commons License: Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0).

rate-mirrors's People

Contributors

anexen avatar erenkarakas1 avatar giga-bowser avatar marcuscastelo avatar pvshvp-oss avatar rippanda12 avatar soulharsh007 avatar teppyboy avatar vnepogodin avatar westandskif avatar witcher01 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

rate-mirrors's Issues

Connection problem

Thank you in advance for developing this tool.

Executing it gives me the following output:

thread 'main' panicked at 'called Result::unwrap() on an Err value: reqwest::Error { kind: Request, url: Url { scheme: "https", host: Some(Domain("www.archlinux.org")), port: None, path: "/mirrors/status/json/", query: None, fragment: None }, source: hyper::Error(Connect, ConnectError("dns error", Custom { kind: Other, error: "failed to lookup address information: Try again" })) }', src/mirrors.rs:140:10
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Doing a ping to www.archlinux.org I get this:

PING www.archlinux.org (95.217.163.246) 56(84) bytes of data.
64 bytes from 95.217.163.246: icmp_seq=1 ttl=46 time=61.5 ms
64 bytes from 95.217.163.246: icmp_seq=2 ttl=46 time=62.9 ms
64 bytes from 95.217.163.246: icmp_seq=3 ttl=46 time=58.7 ms
64 bytes from 95.217.163.246: icmp_seq=4 ttl=46 time=59.4 ms
64 bytes from 95.217.163.246: icmp_seq=5 ttl=46 time=60.2 ms
^C
--- www.archlinux.org ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4004ms
rtt min/avg/max/mdev = 58.710/60.515/62.859/1.496 ms

Unsure wheres the problem.

Permit other CPU architectures in the Arch Linux PKGBUILD

Rate-Mirrors appears to run fine on aarch64 and will likely run fine on other CPU architectures too. Perhaps we should change the architecture from x86_64 to any in the PKGBUILD file.

Suggested edit:

arch=('x86_64')

to

arch=('any')

Here is a screenshot of rate-mirrors running on a phone:
Screenshot_20220313_164204

The --protocol option isn't working

If I run the option, I'm presented with the same output I would receive if I just ran `rate-mirrors help'.

Specifically, I've tried running rate-mirrors --protocol https arch

I've also tried enclosing the http argument in quotes.

I've tried the command from both fish and bash.

The command works without the --protocol option.

  • rate-mirrors config 0.6.0
  • rate-mirrors-bin (AUR)

Cheers

intermitten error

Hi

I am using rate-arch-mirrors via the suggested alias. However, from time to time I get the following error message:

thread 'main' panicked at '`at` split index (is 5) should be <= len (is 0)'

The suggest backtracing is difficult as the tool always works the second time.

The full output looks like this

# EXPLORING DE
# VISITED DE
#     + NEIGHBOR US (by HubsFirst)
#     + NEIGHBOR GB (by HubsFirst)
#     + NEIGHBOR CN (by HubsFirst)
#     + NEIGHBOR FR (by DistanceFirst)
#     + NEIGHBOR PL (by DistanceFirst)
#     + NEIGHBOR DK (by DistanceFirst)
thread 'main' panicked at '`at` split index (is 5) should be <= len (is 0)', library/alloc/src/vec/mod.rs:1751:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
# blank iteration

# RE-TESTING TOP MIRRORS
==> no candidate packages found for pruning
:: Synchronizing package databases...
error: failed to update core (no servers configured for repository)
error: failed to update extra (no servers configured for repository)
error: failed to update community (no servers configured for repository)
error: failed to update multilib (no servers configured for repository)
error: failed to synchronize all databases
Command 'sudo pacman --color=always --sync --refresh --refresh' failed to execute.
Do you want to retry? [Y/n] n
Do you want to proceed? [y/N] n

Unable to save to file owned by root

I find the suggested way of updating the mirrorlist file extremely inelegant since reflector can be run as root and directly save to the mirrorlist file.

Here is the issue I am having:

With root

/etc/pacman.d ❯ sudo /bin/bash -c '/usr/bin/rate-mirrors --save=/etc/pacman.d/mirrorlist arch && /usr/bin/rate-mirrors --save=/etc/pacman.d/cachyos-mirrorlist cachyos && test -f /etc/pacman.d/cachyos-v3-mirrorlist && /usr/bin/rate-mirrors --save=/etc/pacman.d/cachyos-v3-mirrorlist cachyos --arch=v3'

Error

thread 'main' panicked at 'do not run rate-mirrors with root permissions', src/main.rs:82:9
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Without root

/etc/pacman.d ❯ /bin/bash -c '/usr/bin/rate-mirrors --save=/etc/pacman.d/mirrorlist arch && /usr/bin/rate-mirrors --save=/etc/pacman.d/cachyos-mirrorlist cachyos && test -f /etc/pacman.d/cachyos-v3-mirrorlist && /usr/bin/rate-mirrors --save=/etc/pacman.d/cachyos-v3-mirrorlist cachyos --arch=v3'

Error

Error: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }

Thank you.

Request : --save option or immediate overwrite

Testing it out now like this
rate-arch-mirrors | sudo tee /etc/pacman.d/mirrorlist
that works

having a switch like -d = dry-run nothing saved - I believe that is now when you type rate-arch-mirrors without anything
then you can implement the overwrite like this
if you just type rate-arch-mirrors it will overwrite /etc/pacman.d/mirrorlist - in the end that is what you want
making difficult aliases ... rather not

Feature request: config file

Hi,

I've run into a situation where perhaps a configuration file for rate-mirrors would be helpful.

The current currency default is 8 and that works well for users on slower internet connections. For those on higher speed connections, a setting of 16 works much better.

Several Arch-based distributions use rate-mirrors as part of their update scripts. Some use the default concurrency setting and some override it.

It would be nice to have a configuration file to set the concurrency parameter in so that these tools can be extended to allow end-users to specify their internet speeds. These tools could then be extended to support the pacman.conf parallel option as well. Here is an example:

Slow:
concurrency = 4
parallel = 2

Default:
concurrency = 8
parallel = 5

Fast:
concurrency = 16
parallel = 10

What are your thoughts on adding this feature into rate-mirrors?

Thanks.

rate-mirror doesn't work with Arch Linux mirrors

I noticed that rate-mirrors stopped working with Arch Linux mirrors.

❯ rate-mirrors arch 
# STARTED AT: 2023-06-28 10:54:44.256525209 +02:00
# ARGS: rate-mirrors arch
Error: error decoding response body: invalid value: integer `-7`, expected u64 at line 1 column 147252

With other mirrors, such as CachyOS, it works fine.

lucjan at cachyos ~ 10:55:31    
❯ rate-mirrors cachyos  
# STARTED AT: 2023-06-28 10:58:06.620794094 +02:00
# ARGS: rate-mirrors cachyos
# MIRRORS LEFT AFTER FILTERING: 8
# JUMP #1
# EXPLORING US
# VISITED US
# BLANK ITERATION
# COUNTRY JUMPING YIELDED TOO FEW MIRRORS (0), ADDING OTHERS TO UNLABELED
# 

# TESTING UNLABELED MIRRORS
# SpeedTestResult { speed: 22.47 MB/s; elapsed: 236.945192ms; connection_time: 283.587222ms }
# SpeedTestResult { speed: 21.31 MB/s; elapsed: 249.839234ms; connection_time: 531.024407ms }
# SpeedTestResult { speed: 6.16 MB/s; elapsed: 864.610634ms; connection_time: 531.429538ms }
# SpeedTestResult { speed: 263.06 KB/s; elapsed: 528.446122ms; connection_time: 969.480316ms }
# SpeedTestResult { speed: 1.63 MB/s; elapsed: 986.876291ms; connection_time: 497.492655ms }
# SpeedTestResult { speed: 856.12 KB/s; elapsed: 860.75954ms; connection_time: 639.258129ms }
# 

# RE-TESTING TOP MIRRORS
# SpeedTestResult { speed: 18.11 MB/s; elapsed: 294.07173ms; connection_time: 505.818539ms }
# SpeedTestResult { speed: 23.29 MB/s; elapsed: 228.647538ms; connection_time: 416.944545ms }
# SpeedTestResult { speed: 6.82 MB/s; elapsed: 780.537039ms; connection_time: 476.091246ms }
# SpeedTestResult { speed: 1.57 MB/s; elapsed: 1.168096586s; connection_time: 319.140648ms }
# SpeedTestResult { speed: 613.82 KB/s; elapsed: 818.574074ms; connection_time: 681.000557ms }
# ==== RESULTS (top re-tested) ====
#   1. SpeedTestResult { speed: 23.29 MB/s; elapsed: 228.647538ms; connection_time: 416.944545ms } -> https://mirror.cachyos.org/repo/
#   2. SpeedTestResult { speed: 18.11 MB/s; elapsed: 294.07173ms; connection_time: 505.818539ms } -> https://aur.cachyos.org/repo/
#   3. SpeedTestResult { speed: 6.82 MB/s; elapsed: 780.537039ms; connection_time: 476.091246ms } -> https://hun.cachyos.org/repo/
#   4. SpeedTestResult { speed: 1.57 MB/s; elapsed: 1.168096586s; connection_time: 319.140648ms } -> https://mirror.lesviallon.fr/cachy/repo/
#   5. SpeedTestResult { speed: 613.82 KB/s; elapsed: 818.574074ms; connection_time: 681.000557ms } -> https://mirror.albony.xyz/cachylinux/repo/
#   6. SpeedTestResult { speed: 263.06 KB/s; elapsed: 528.446122ms; connection_time: 969.480316ms } -> https://sg.cachyos.org/repo/
# FINISHED AT: 2023-06-28 10:58:14.444036494 +02:00
Server = https://mirror.cachyos.org/repo/$arch/$repo
Server = https://aur.cachyos.org/repo/$arch/$repo
Server = https://hun.cachyos.org/repo/$arch/$repo
Server = https://mirror.lesviallon.fr/cachy/repo/$arch/$repo
Server = https://mirror.albony.xyz/cachylinux/repo/$arch/$repo
Server = https://sg.cachyos.org/repo/$arch/$repo

You dun broke it

error: unexpected argument '--save' found

tip: a similar argument exists: '--save-to-file'

Twice --path-to-return

Hi,

I'm using the rate-mirrors for arch and chaotic mirrorslist with stdin (awesome!). However, I saw that --path-to-return parameter returns 'the term before $arch' twice. I don't know if I'm using correctly or if is a real issue.

This is an example of the command:

curl -s "https://archlinux.org/mirrorlist/?country=BR" | sed -e "s/^#Server = //" -e "/^#/d" -e "/^$/d" -e "s/\$repo\/os\/\$arch//g" | rate-mirrors stdin --path-to-test="community/os/x86_64/community.files" --path-to-return='$repo/os/$arch' --output-prefix="Server = " | sudo tee ~/example

And the output:

# STARTED AT: 2022-05-17 12:28:37.448740258 -03:00
# ARGS: rate-mirrors stdin --path-to-test=community/os/x86_64/community.files --path-to-return=$repo/os/$arch --output-prefix=Server = 
# MIRRORS LEFT AFTER FILTERING: 10
# JUMP #1
# EXPLORING US
# VISITED US
# BLANK ITERATION
# COUNTRY JUMPING YIELDED TOO FEW MIRRORS (0), ADDING OTHERS TO UNLABELED
# 

# TESTING UNLABELED MIRRORS
# SpeedTestResult { speed: 374.20 KB/s; elapsed: 1.230897955s; connection_time: 145.549254ms }
# SpeedTestResult { speed: 3.57 MB/s; elapsed: 1.390944385s; connection_time: 107.407297ms }
# SpeedTestResult { speed: 647.21 KB/s; elapsed: 1.3991738s; connection_time: 100.782783ms }
# SpeedTestResult { speed: 116.29 KB/s; elapsed: 1.038307777s; connection_time: 391.465037ms }
# SpeedTestResult { speed: 444.81 KB/s; elapsed: 1.304742522s; connection_time: 184.487418ms }
# SpeedTestResult { speed: 19.22 MB/s; elapsed: 1.375187845s; connection_time: 124.960557ms }
# 

# RE-TESTING TOP MIRRORS
# SpeedTestResult { speed: 20.40 MB/s; elapsed: 1.31985743s; connection_time: 160.257424ms }
# SpeedTestResult { speed: 12.97 MB/s; elapsed: 1.396621156s; connection_time: 103.172203ms }
# SpeedTestResult { speed: 1.26 MB/s; elapsed: 1.327425885s; connection_time: 168.803158ms }
# SpeedTestResult { speed: 670.04 KB/s; elapsed: 1.286572029s; connection_time: 204.588049ms }
# SpeedTestResult { speed: 12.71 MB/s; elapsed: 1.347824757s; connection_time: 149.093535ms }
# ==== RESULTS (top re-tested) ====
#   1. SpeedTestResult { speed: 20.40 MB/s; elapsed: 1.31985743s; connection_time: 160.257424ms } -> http://mirror.ufscar.br/archlinux/$repo/os/$arch
#   2. SpeedTestResult { speed: 12.97 MB/s; elapsed: 1.396621156s; connection_time: 103.172203ms } -> http://br.mirror.archlinux-br.org/$repo/os/$arch
#   3. SpeedTestResult { speed: 12.71 MB/s; elapsed: 1.347824757s; connection_time: 149.093535ms } -> http://archlinux.c3sl.ufpr.br/$repo/os/$arch
#   4. SpeedTestResult { speed: 1.26 MB/s; elapsed: 1.327425885s; connection_time: 168.803158ms } -> http://archlinux.pop-es.rnp.br/$repo/os/$arch
#   5. SpeedTestResult { speed: 670.04 KB/s; elapsed: 1.286572029s; connection_time: 204.588049ms } -> http://mirror.ufam.edu.br/archlinux/$repo/os/$arch
#   6. SpeedTestResult { speed: 116.29 KB/s; elapsed: 1.038307777s; connection_time: 391.465037ms } -> http://linorg.usp.br/archlinux/$repo/os/$arch
# FINISHED AT: 2022-05-17 12:28:47.213625410 -03:00
Server = http://mirror.ufscar.br/archlinux/$repo/os/$repo/os/$arch
Server = http://br.mirror.archlinux-br.org/$repo/os/$repo/os/$arch
Server = http://archlinux.c3sl.ufpr.br/$repo/os/$repo/os/$arch
Server = http://archlinux.pop-es.rnp.br/$repo/os/$repo/os/$arch
Server = http://mirror.ufam.edu.br/archlinux/$repo/os/$repo/os/$arch
Server = http://linorg.usp.br/archlinux/$repo/os/$repo/os/$arch

The results have "[...]$repo/os/$repo/os/$arch" in the end.

Thanks.

It doesn't compile with 'OPTIONS=(... lto)'

Arch Linux

#!/hint/bash
#
# /etc/makepkg.conf
#
....
#
CARCH="x86_64"
CHOST="x86_64-pc-linux-gnu"

#-- Compiler and Linker Flags
CFLAGS="-march=native -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection"
CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
RUSTFLAGS="-C opt-level=3 -C target-cpu=native"
MAKEFLAGS="-j$(getconf _NPROCESSORS_ONLN) --quiet"
#-- Debugging flags
DEBUG_CFLAGS="-g -fvar-tracking-assignments"
DEBUG_CXXFLAGS="-g -fvar-tracking-assignments"
...
BUILDENV=(!distcc color !ccache check !sign)
...
OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !debug lto)

If I compile rate-mirrors with lto enabled, it fails: https://gist.githubusercontent.com/simonbcn/1a933d7a76f32234be7d6b7d4fd60ab4/raw/75018fa4f006fccdbafcfa69dd60f02627cfb32e/gistfile1.txt

Warning at compile time

....
warning: field is never read: `active`
--> src/targets/archlinux.rs:24:5
|
24 |     active: bool,
|     ^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default

Auto Refresh Functionality Similar to reflector.timer

Hello,

Firstly, I'd like to express my appreciation for your project. It's been incredibly useful.

I have a question regarding the availability of an auto refresh feature. In particular, I'm interested in something akin to the reflector.timer functionality. Could you please inform me if such a feature exists in your project, or if there are plans to include it in the future?

Thanks in advance.

CachyOSv3 and v4 Mirrorlists

Hi! I was hoping it was possible to add flags for the CachyOS v3 and v4 mirrorlists. They use the same servers, with the only difference being the location of the repo, in .../repo/$archv3 or $archv4 instead of $arch. Currently I'm just going to

sed /s/$arch/$archv3 cachyos-v3-mirrorlist

but it would be nice if this is possible to conveniently implement.

Thanks

[Arch specific] Community repo has moved to Extra

The recent migration to git was accompanied with [community] repository merging with [extra] and ending up empty (iirc it's going to be retired sooner or later after some transition period).

Hence the default 'path-to-test' for the 'arch' profile - "community/os/x86_64/community.files" - is useless now.
Tested --path-to-test="extra/os/x86_64/extra.files" and it works, which probably should be a new default value.

Not sure whether Arch downstreams are gonna follow along w/ the new repo structure (they probably will), but that's a separate issue.

[HELP] rate-mirrors Yields 1 mirror that is not working

Output:

# STARTED AT: 2024-01-18 16:53:03.012019214 +07:00
# ARGS: rate-mirrors --save=/tmp/tmp.s9NL7nn0o3 arch --max-delay=2000
# FETCHED MIRRORS: 1166
# MIRRORS LEFT AFTER FILTERING: 1
# JUMP #1
# EXPLORING US
# VISITED US
#     + NEIGHBOR TH (by HubsFirst)
# [TH] FAILED TO CONNECT TO https://mirror.cyberbits.asia/archlinux/extra/os/x86_64/extra.files
# BLANK ITERATION
# COUNTRY JUMPING YIELDED TOO FEW MIRRORS (0), ADDING OTHERS TO UNLABELED
# 

# NO RESULTS TO RE-TEST
# ==== FAILED TO TEST SPEEDS, RETURNING UNTESTED MIRRORS ====
Server = https://mirror.cyberbits.asia/archlinux/$repo/os/$arch

I would like to know what is going on here ^^"

rate-mirrors not work in stdin

Hello everyone,

I am from India, recently i switch to blackarch linux so i need to update my system so i like to change my mirrors for faster connectivity speed and to avoid timeout errors.
so i fed mirrorlist via stdin but i got no output on screen but the syntax was correct one

:rate-mirrors stdin --path-to-test="blackarch-mirrorlist.backup" --comment-prefix="# " --path-to-return='$repo/os/$arch'

working directory: /etc/pacman.d

file:

Worldwide

Server = https://mirrors.fosshost.org/blackarch/$repo/os/$arch
Server = https://mirrors.fossho.st/blackarch/$repo/os/$arch

Australia

Server = http://blackarch.mirror.digitalpacific. … o/os/$arch

Austria

Server = http://mirror.easyname.at/blackarch/$repo/os/$arch
Server = ftp://mirror.easyname.at/blackarch/$repo/os/$arch

China

Server = https://mirror.sjtu.edu.cn/blackarch/$repo/os/$arch
Server = https://mirrors.tuna.tsinghua.edu.cn/bl … o/os/$arch
Server = https://mirrors.ustc.edu.cn/blackarch/$repo/os/$arch

Denmark

Server = https://mirrors.dotsrc.org/blackarch/$repo/os/$arch
Server = http://mirrors.dotsrc.org/blackarch/$repo/os/$arch
Server = ftp://mirrors.dotsrc.org/blackarch/$repo/os/$arch

Ecuador

Server = http://mirror.uta.edu.ec/blackarch/$repo/os/$arch
Server = https://mirror.uta.edu.ec/blackarch/$repo/os/$arch
Server = ftp://mirror.uta.edu.ec/blackarch/$repo/os/$arch
Server = http://mirror.cedia.org.ec/blackarch/$repo/os/$arch
Server = https://mirror.cedia.org.ec/blackarch/$repo/os/$arch

like this [ here i not mention entire output of file blackarch-mirrorlist..backup]

additional questions :
*)what is eps and eps check which ratio is best for faster downloads?
*)how to change entry country because i live in india, i want to explore near by country's to me?
*)by utilizing mirror how to avoid download timeout error? whether i can test rsync protocol

that's all my friend

Speed test panics when mirrorlist is empty

I tried filtering on only https-only mirrors (--protocol https), and noticed that when setting --entry-country BE, the speed-test errors out with

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/speed_test.rs:200:26

This is probably because the mirrorlist for https in Belgium is empty (which is wrong, but that's a different problem): https://archlinux.org/mirrorlist/?country=BE&protocol=https

My rust is not decent enough to make a PR, but I'd guess a "when !empty" or something needs to be added somewhere.

Manjaro mirror data file change (url and content)

The mirror manager project has been in public testing for a couple of months - I don't know the actual change into production - but a heads up is always nice

At some point in the near future expect Manjaro mirror data to change.

The format has changed slightly as can be deducted from https://mirror-manager.manjaro.org/status.json

Error

Getting Blank iteration though I have mirrors in my mirrolost file
contents of my mirrorlist are:

##
## Arch Linux repository mirrorlist
## Generated on 2021-05-23
##

## United Kingdom
Server = http://archlinux.uk.mirror.allworldit.com/archlinux/$repo/os/$arch
Server = https://archlinux.uk.mirror.allworldit.com/archlinux/$repo/os/$arch
Server = http://mirror.bytemark.co.uk/archlinux/$repo/os/$arch
Server = https://mirror.bytemark.co.uk/archlinux/$repo/os/$arch
Server = http://mirrors.gethosted.online/archlinux/$repo/os/$arch
Server = https://mirrors.gethosted.online/archlinux/$repo/os/$arch
Server = http://mirrors.manchester.m247.com/arch-linux/$repo/os/$arch
Server = http://mirrors.melbourne.co.uk/archlinux/$repo/os/$arch
Server = https://mirrors.melbourne.co.uk/archlinux/$repo/os/$arch
Server = http://www.mirrorservice.org/sites/ftp.archlinux.org/$repo/os/$arch
Server = https://www.mirrorservice.org/sites/ftp.archlinux.org/$repo/os/$arch
Server = http://mirror.netweaver.uk/archlinux/$repo/os/$arch
Server = https://mirror.netweaver.uk/archlinux/$repo/os/$arch
Server = http://lon.mirror.rackspace.com/archlinux/$repo/os/$arch
Server = https://lon.mirror.rackspace.com/archlinux/$repo/os/$arch
Server = http://arch.serverspace.co.uk/arch/$repo/os/$arch
Server = http://archlinux.mirrors.uk2.net/$repo/os/$arch
Server = http://mirrors.ukfast.co.uk/sites/archlinux.org/$repo/os/$arch
Server = https://mirrors.ukfast.co.uk/sites/archlinux.org/$repo/os/$arch

## United States
Server = http://mirrors.acm.wpi.edu/archlinux/$repo/os/$arch
Server = http://mirrors.advancedhosters.com/archlinux/$repo/os/$arch
Server = http://mirrors.aggregate.org/archlinux/$repo/os/$arch
Server = https://america.mirror.pkgbuild.com/$repo/os/$arch
Server = http://ca.us.mirror.archlinux-br.org/$repo/os/$arch
Server = http://il.us.mirror.archlinux-br.org/$repo/os/$arch
Server = http://archlinux.surlyjake.com/archlinux/$repo/os/$arch
Server = https://archlinux.surlyjake.com/archlinux/$repo/os/$arch
Server = http://mirror.arizona.edu/archlinux/$repo/os/$arch
Server = https://mirror.arizona.edu/archlinux/$repo/os/$arch
Server = http://arlm.tyzoid.com/$repo/os/$arch
Server = https://arlm.tyzoid.com/$repo/os/$arch
Server = https://mirror.ava.dev/archlinux/$repo/os/$arch
Server = http://mirrors.cat.pdx.edu/archlinux/$repo/os/$arch
Server = http://mirror.cc.columbia.edu/pub/linux/archlinux/$repo/os/$arch
Server = http://arch.mirror.constant.com/$repo/os/$arch
Server = https://arch.mirror.constant.com/$repo/os/$arch
Server = http://mirror.cs.pitt.edu/archlinux/$repo/os/$arch
Server = http://mirror.cs.vt.edu/pub/ArchLinux/$repo/os/$arch
Server = http://mirror.cybersecurity.nmt.edu/archlinux/$repo/os/$arch
Server = https://mirror.cybersecurity.nmt.edu/archlinux/$repo/os/$arch
Server = http://distro.ibiblio.org/archlinux/$repo/os/$arch
Server = http://mirror.es.its.nyu.edu/archlinux/$repo/os/$arch
Server = http://mirror.ette.biz/archlinux/$repo/os/$arch
Server = https://mirror.ette.biz/archlinux/$repo/os/$arch
Server = http://mirrors.gigenet.com/archlinux/$repo/os/$arch
Server = http://www.gtlib.gatech.edu/pub/archlinux/$repo/os/$arch
Server = http://mirror.hackingand.coffee/arch/$repo/os/$arch
Server = https://mirror.hackingand.coffee/arch/$repo/os/$arch
Server = https://mirror.hodgepodge.dev/archlinux/$repo/os/$arch
Server = http://mirror.hostup.org/archlinux/$repo/os/$arch
Server = https://mirror.hostup.org/archlinux/$repo/os/$arch
Server = http://arch.hu.fo/archlinux/$repo/os/$arch
Server = https://arch.hu.fo/archlinux/$repo/os/$arch
Server = http://repo.ialab.dsu.edu/archlinux/$repo/os/$arch
Server = https://repo.ialab.dsu.edu/archlinux/$repo/os/$arch
Server = http://mirrors.kernel.org/archlinux/$repo/os/$arch
Server = https://mirrors.kernel.org/archlinux/$repo/os/$arch
Server = http://mirror.dal10.us.leaseweb.net/archlinux/$repo/os/$arch
Server = http://mirror.mia11.us.leaseweb.net/archlinux/$repo/os/$arch
Server = http://mirror.sfo12.us.leaseweb.net/archlinux/$repo/os/$arch
Server = http://mirror.wdc1.us.leaseweb.net/archlinux/$repo/os/$arch
Server = https://mirror.dal10.us.leaseweb.net/archlinux/$repo/os/$arch
Server = https://mirror.mia11.us.leaseweb.net/archlinux/$repo/os/$arch
Server = https://mirror.sfo12.us.leaseweb.net/archlinux/$repo/os/$arch
Server = https://mirror.wdc1.us.leaseweb.net/archlinux/$repo/os/$arch
Server = http://mirrors.liquidweb.com/archlinux/$repo/os/$arch
Server = http://mirror.lty.me/archlinux/$repo/os/$arch
Server = https://mirror.lty.me/archlinux/$repo/os/$arch
Server = http://mirrors.lug.mtu.edu/archlinux/$repo/os/$arch
Server = https://mirrors.lug.mtu.edu/archlinux/$repo/os/$arch
Server = http://mirror.math.princeton.edu/pub/archlinux/$repo/os/$arch
Server = http://mirror.metrocast.net/archlinux/$repo/os/$arch
Server = http://mirror.kaminski.io/archlinux/$repo/os/$arch
Server = https://mirror.kaminski.io/archlinux/$repo/os/$arch
Server = http://iad.mirrors.misaka.one/archlinux/$repo/os/$arch
Server = https://iad.mirrors.misaka.one/archlinux/$repo/os/$arch
Server = http://repo.miserver.it.umich.edu/archlinux/$repo/os/$arch
Server = http://mirrors.mit.edu/archlinux/$repo/os/$arch
Server = https://mirrors.mit.edu/archlinux/$repo/os/$arch
Server = http://mirrors.ocf.berkeley.edu/archlinux/$repo/os/$arch
Server = https://mirrors.ocf.berkeley.edu/archlinux/$repo/os/$arch
Server = http://archmirror1.octyl.net/$repo/os/$arch
Server = https://archmirror1.octyl.net/$repo/os/$arch
Server = http://ftp.osuosl.org/pub/archlinux/$repo/os/$arch
Server = http://arch.mirrors.pair.com/$repo/os/$arch
Server = http://dfw.mirror.rackspace.com/archlinux/$repo/os/$arch
Server = http://iad.mirror.rackspace.com/archlinux/$repo/os/$arch
Server = http://ord.mirror.rackspace.com/archlinux/$repo/os/$arch
Server = https://dfw.mirror.rackspace.com/archlinux/$repo/os/$arch
Server = https://iad.mirror.rackspace.com/archlinux/$repo/os/$arch
Server = https://ord.mirror.rackspace.com/archlinux/$repo/os/$arch
Server = http://plug-mirror.rcac.purdue.edu/archlinux/$repo/os/$arch
Server = https://plug-mirror.rcac.purdue.edu/archlinux/$repo/os/$arch
Server = http://mirrors.rit.edu/archlinux/$repo/os/$arch
Server = https://mirrors.rit.edu/archlinux/$repo/os/$arch
Server = https://arch.rrig.gs/$repo/os/$arch
Server = http://mirrors.rutgers.edu/archlinux/$repo/os/$arch
Server = https://mirrors.rutgers.edu/archlinux/$repo/os/$arch
Server = http://mirror.siena.edu/archlinux/$repo/os/$arch
Server = http://mirrors.sonic.net/archlinux/$repo/os/$arch
Server = https://mirrors.sonic.net/archlinux/$repo/os/$arch
Server = http://arch.mirror.square-r00t.net/$repo/os/$arch
Server = https://arch.mirror.square-r00t.net/$repo/os/$arch
Server = http://mirror.stephen304.com/archlinux/$repo/os/$arch
Server = https://mirror.stephen304.com/archlinux/$repo/os/$arch
Server = http://ftp.sudhip.com/archlinux/$repo/os/$arch
Server = https://ftp.sudhip.com/archlinux/$repo/os/$arch
Server = http://mirror.pit.teraswitch.com/archlinux/$repo/os/$arch
Server = https://mirror.pit.teraswitch.com/archlinux/$repo/os/$arch
Server = http://mirror.umd.edu/archlinux/$repo/os/$arch
Server = http://mirror.vtti.vt.edu/archlinux/$repo/os/$arch
Server = http://mirrors.xmission.com/archlinux/$repo/os/$arch
Server = http://mirrors.xtom.com/archlinux/$repo/os/$arch
Server = https://mirrors.xtom.com/archlinux/$repo/os/$arch
Server = https://zxcvfdsa.com/arch/$repo/os/$arch



compiling: "warning: field is never read: `protocols`"

$ paru rate-mirrors
...
Compiling rate_mirrors v0.4.0 (/tmp/makepkg/rate-mirrors/src/rate-mirrors-0.5.0)
warning: field is never read: `protocols`
--> src/targets/manjaro.rs:35:5
|
35 |     protocols: Vec<Protocol>,
|     ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default

warning: `rate_mirrors` (bin "rate_mirrors") generated 1 warning
Finished release [optimized] target(s) in 51.51s
...

Support for different branches on Manjaro

Hey, would it be possible to add support for branches different than stable on Manjaro? Currently I'm manually editing the mirrorlist-file after running this tool to replace the stable urls with unstable ones.

BlackArch support

Hello! I like this project and thank you for your work! Is it possible to have support for BlackArch repository? It could be very important for Cyber Security Professionals.

rate-mirrors fails when mirror list times out

Hi, I just tried the command rate-mirrors --save=./mirrors arch --max-delay=21600 but it failed with the following output:
`

STARTED AT: 2021-11-21 00:03:10.670412668 +01:00

ARGS: rate-mirrors --save=./mirrors --entry-country DE arch --max-delay=3600

thread '' panicked at 'called Result::unwrap() on an Err value: reqwest::Error { kind: Request, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("www.archlinux.org")), port: None, path: "/mirrors/status/json/", query: None, fragment: None }, source: TimedOut }', src/targets/archlinux.rs:48:10
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
thread 'main' panicked at 'called Result::unwrap() on an Err value: Any { .. }', src/main.rs:131:26
`
This seems to be caused by the arch website having a timeout. I also could not reach the page using my browser.
It took me some time to figure out the reason for this so I thought an error message would be nice.
Thanks!

reuse runtime instead of spawning new ones in new Thread

main spawns a new thread to fetch the correct mirrors

rate-mirrors/src/main.rs

Lines 103 to 109 in dad9c23

let thread_handle = thread::spawn(move || {
let mirrors = match &config.target {
Target::Arch(target) => fetch_arch_mirrors(
Arc::clone(&config),
target.clone(),
mpsc::Sender::clone(&tx_progress),
),

This thread then spawns a Runtime to block on an async function

let runtime = tokio::runtime::Runtime::new().unwrap();

let response = runtime
.block_on(

Would it make sense to create a general Runtime instead to reuse in the functions that fetch mirrors instead? Or is this done by design?

Reusing the runtime would, for instance, make sense in fetch_arch_mirrors as the Runtime currently blocks twice there, negating the pros of using tokio there in the first place.

Not all options accepted

I just noticed that rate-mirror doesn't accept all available options from rate-mirrors --help.

E.g. rate-mirrors arch or rate-mirrors arch --max-delay=3600 work, but

rate-mirrors arch --protocol=https

produces the error:

error: Found argument '--protocol' which wasn't expected, or isn't valid in this context

Similarly,
rate-mirrors arch --entry-country=DE

produces the error:

error: Found argument '--entry-country' which wasn't expected, or isn't valid in this context

I haven't tested all available options but I can tell that --completion=1and max-delay=3600work.

run rate-mirrors archlinuxcn, return error

here is the error message

➜ ~ rate-mirrors archlinuxcn

STARTED AT: 2023-08-20 10:33:04.779973302 +08:00

ARGS: rate-mirrors archlinuxcn

Error: error sending request for url (https://raw.githubusercontent.com/archlinuxcn/mirrorlist-repo/master/archlinuxcn-mirrorlist): error trying to connect: tcp connect error: Connection refused (os error 111)

confirm I can open https://raw.githubusercontent.com/archlinuxcn/mirrorlist-repo/master/archlinuxcn-mirrorlist correctly by chromium

Support for Artix linux

Hi I really like this project and would love to use it for artix linux, too.
It there any chance support will be added?
I would implement it myself but I don't know rust...
Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.