Author: Eiko

Time: 2024-11-10 15:44:27 - 2024-11-10 16:13:10 (UTC)

Hogwarts Magical Internet Solutions

You might have trouble accessing github, which is crucial for things to work in your system like downloading packages, cloning repositories, etc. Here are some ways to access github in cn:

Use hosts file

Using our hosts file which updates and fetchs from a github repo, containing the latest github ip addresses. You can access it without going to github because our server fetches it hourly here.

For convenience, add the following function to your .bashrc or .zshrc:

function updateHosts() {
    wget -O hosts https://asukachan.com/repo/hosts
    sudo sed -i '/# GitHub Host Start/,/# GitHub Host End/d' /etc/hosts
    cat hosts | sudo tee -a /etc/hosts
    rm hosts
}

Then you can run updateHosts to update your hosts file very easily.

Use ssh proxy

See our article in our online notes on ssh.

Use VPN

For this one you need to install v2raya or clash-for-windows and purchase a VPN service. For them to be effective in the terminal, set the http_proxy, https_proxy or all_proxy environment variables to the proxy address and port. For example:

export http_proxy="http://your_proxy_server_http:port_http"
export all_proxy="socks5://your_proxy_server_socks:port_socks"

In fact I do not recommend setting them permanently as you don’t want everything to go through proxy. Add the following alias instead, to enable proxy easily and optionally by typing prx.

alias prx="export http_proxy=...; export all_proxy=..."

Cannot Install yay Solutions

The lack of magical internet can also result in the failure of installing yay, because yay defaults to download through proxy.golang.org, which is also blocked in cn. We have figured out several solutions:

  • Use VPN or ssh proxy, it can solve everything if connection quality is good.

  • set GOPROXY=https://goproxy.cn in your enviroment variables, for example putting

    export GOPROXY=https://goproxy.cn

    in your ~/.bashrc file.

  • Download files through our server, I have put the compiled yay and yay-debug package under the /opt/yay directory, currently you can consider scp to get them and use pacman -U <filename> to install them, without compiling or downloading through blocked websites.