anatol / pacoloco

Caching proxy server for Arch Linux pacman
MIT License
216 stars 30 forks source link

Fail to download #52

Closed machsix closed 1 year ago

machsix commented 1 year ago

pacolo.yml

repos:
  archlinux:
    urls:
    - https://mirrors.sonic.net/archlinux
    - https://mirrors.kernel.org/archlinux
    - https://mirror.sfo12.us.leaseweb.net/archlinux
    - https://mirror.fcix.net/archlinux
    - https://mirrors.xtom.com/archlinux
    - https://mirror.arizona.edu/archlinux
    - https://mirror.lty.me/archlinux
  arch4edu:
    url: https://mirrors.tuna.tsinghua.edu.cn/arch4edu
prefetch: # optional section, add it if you want to enable prefetching
  cron: 0 0 3 * * * * # standard cron expression (https://en.wikipedia.org/wiki/Cron#CRON_expression) to define how frequently prefetch, see https://github.com/gorhill/cronexpr#implementation for documentation.
  ttl_unaccessed_in_days: 30  # defaults to 30, set it to a higher value than the number of consecutive days you don't update your systems
  ttl_unupdated_in_days: 300 # defaults to 300, it deletes and stop prefetch packages which hadn't been either updated upstream or requested for ttl_unupdated_in_days.

/etc/pacman.conf

[arch4edu]
# Server = https://arch4edu.keybase.pub/$arch
# Server = https://mirrors.tuna.tsinghua.edu.cn/arch4edu/$arch
Server = http://10.1.0.2:9129/repo/arch4edu/$arch

Issue:

When I run sudo pacman -Sw visual-studio-code-bin, I got the error error: failed retrieving file 'visual-studio-code-bin-1.72.2-1-x86_64.pkg.tar.zst' from 10.1.0.2:9129 : The requested URL returned error: 404 . If I run curl http://10.1.0.2:9129/repo/arch4edu/x86_64 , I can get a correct list of packages. The journal shows

Oct 20 23:52:17 NAS pacoloco[115768]: pacoloco.go:138: open /var/cache/pacoloco/pkgs/arch4edu/visual-studio-code-bin-1.72.2-1-x86_64.pkg.tar.zst: no such file or directory
machsix commented 1 year ago

After some debugging, I found the error is the following

Request 1:GET /arch4edu/x86_64/visual-studio-code-bin-1.72.2-1-x86_64.pkg.tar.zst HTTP/1.1                                                                                                                                                                  

Host: mirrors.tuna.tsinghua.edu.cn                                                                                                                                                                                                                          

User-Agent: Go-http-client/1.1                                                                                                                                                                                                                              

Accept-Encoding: identity   

unable to download url http://mirrors.tuna.tsinghua.edu.cn/arch4edu/x86_64/visual-studio-code-bin-1.72.2-1-x86_64.pkg.tar.zst, status code is 403 

If I run a curl with the same header, I got this. photo_2022-10-24_23-59-16

The sever thinks "Go-client" as a mobile device and triggers a 403 error

I create a PR https://github.com/anatol/pacoloco/pull/53