开代理时bash中yay发生错误

日志

-> 1 error occurred: 
        * request failed: Get "https://aur.archlinux.org/rpc?arg%5B%5D=obs-studio-tytan652&type=info&v=5": proxyconnect tcp: EOF 
 
 
 -> 查找 AUR 软件包失败: obs-studio-tytan652:1 error occurred: 
        * request failed: Get "https://aur.archlinux.org/rpc?arg=obs-studio-tytan652&by=provides&type=search&v=5": proxyconnect tcp: EOF 
 
 
 -> 找不到 AUR 包 obs-studio-tytan652 
 今日无事可做U
 

浏览器可以正常使用

yay不走系统代理

没开系统代理啊

在bash设置了https_proxy

这个也不吃的

但是不用代理从github和外国源下载不大可能

而且神奇的是之前开代理后不能下的aur马上就能下了,所以我认为yay是可以用代理的

那你加油(

直接开tun模式好了

改一下makepkg就行,自己写个脚本代理github到代理站,
在这个脚本里面写环境变应该能吃http_proxy了

> cat --pager=0 /home/fake_axel_for_makepkg.sh
─────┬──────────────────────────────────────────────────────────────────────────────
     │ File: /home/fake_axel_for_makepkg.sh
─────┼──────────────────────────────────────────────────────────────────────────────
   1 │ #!/bin/bash
   2 │
   3 │ domin=$(echo "$2" | cut -f3 -d'/')
   4 │ others=$(echo "$2" | cut -f4- -d'/')
   5 │ USER_AGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHT
     │ ML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
   6 │
   7 │ case "$domin" in
   8 │     "github.com" | "raw.githubusercontent.com")
   9 │         if [[ "$domin" == "github.com" ]]; then
  10 │             mirrors=(
  11 │                 "https://gh-proxy.org/https://github.com/%s"
  12 │                 # "https://gitclone.com/%s"
  13 │                 "https://kkgithub.com/%s"
  14 │                 # "https://wget.la/https://github.com/%s"
  15 │                 "https://ghfast.top/https://github.com/%s"
  16 │                 "https://githubfast.com/%s"
  17 │             )
  18 │         else
  19 │             mirrors=(
  20 │                 "https://hk.gh-proxy.com/https://raw.githubusercontent.com/%s
     │ "
  21 │                 "https://ghproxy.net/https://raw.githubusercontent.com/%s"
  22 │                 "https://ghfast.top/https://raw.githubusercontent.com/%s"
  23 │                 # "https://githubfast.com/https://raw.githubusercontent.com/%
     │ s"
  24 │             )
  25 │         fi
  26 │         path="$others"
  27 │         fastest_url=""
  28 │         min_time=99999
  29 │
  30 │         for mirror_format in "${mirrors[@]}"; do
  31 │             mirror_url=$(printf "$mirror_format" "$path")
  32 │             echo -n "Testing $mirror_url ..."
  33 │
  34 │             # 使用GET请求测试(下载前1字节验证有效性)
  35 │             response=$(curl -L -s -o /dev/null \
  36 │                      --connect-timeout 5 \
  37 │                      --max-time 10 \
  38 │                      -k \
  39 │                      -w '%{http_code} %{time_total} %{size_download}' \
  40 │                      -H 'User-Agent: Mozilla/5.0' \
  41 │                      --range 0-0 \
  42 │                      "$mirror_url" 2>/dev/null)
  43 │
  44 │             http_code=$(echo "$response" | awk '{print $1}')
  45 │             time=$(echo "$response" | awk '{print $2}')
  46 │             downloaded_size=$(echo "$response" | awk '{print $3}')
  47 │
  48 │             # 显示状态码和响应时间
  49 │             echo -n " [HTTP:$http_code]"
  50 │             [[ -n "$time" ]] && echo " [TIME:${time}s]" || echo " [TIMEOUT]"
  51 │
  52 │             # 增强有效性检查:状态码200/206 + 实际下载字节 > 0
  53 │             if [[ "$http_code" =~ ^(200|206)$ && -n "$time" && "$downloaded_s
     │ ize" -gt 0 ]]; then
  54 │                 if (( $(echo "$time < $min_time" | bc -l) )); then
  55 │                     min_time=$time
  56 │                     fastest_url="$mirror_url"
  57 │                 fi
  58 │             fi
  59 │         done
  60 │
  61 │         if [ -n "$fastest_url" ]; then
  62 │             url="$fastest_url"
  63 │             echo "Selected fastest mirror: $url (Time: $min_time seconds)"
  64 │         else
  65 │             url="$2"
  66 │             echo "WARNING: All mirrors failed, falling back to original URL"
  67 │         fi
  68 │         ;;
  69 │     *)
  70 │         url="$2"
  71 │         ;;
  72 │ esac
  73 │
  74 │ echo "Downloading from $url"
  75 │ /usr/bin/axel -n 10 -a -o "$1" -H "User-Agent: $USER_AGENT" "$url" || {
  76 │     echo "ERROR: Axel download failed, trying fallback to curl..."
  77 │     curl -# -A "$USER_AGENT"  -L -k -o "$1" "$url"
  78 │ }
─────┴──────────────────────────────────────────────────────────────────────────────

~
> cat -r 14:20 /etc/makepkg.conf
─────┬──────────────────────────────────────────────────────────────────────────────
     │ File: /etc/makepkg.conf
─────┼──────────────────────────────────────────────────────────────────────────────
  14 │ DLAGENTS=('file::/usr/bin/curl -qgC - -o %o %u'
  15 │           'ftp::/usr/bin/curl -qgfC - --ftp-pasv --retry 3 --retry-delay 3 -o
     │  %o %u'
  16 │           'http::/usr/bin/curl -qgb "" -fLC - --retry 3 --retry-delay 3 -o %o
     │  %u'
  17 │           #'https::/usr/bin/curl -qgb "" -fLC - --retry 3 --retry-delay 3 -o
     │ %o %u'
  18 │           'https::/home/fake_axel_for_makepkg.sh %o %u'
  19 │           'rsync::/usr/bin/rsync --no-motd -z %u %o'
  20 │           'scp::/usr/bin/scp -C %u %o')
─────┴──────────────────────────────────────────────────────────────────────────────

1 Like