Created
April 7, 2026 08:34
-
-
Save maanimis/891e798c15b0043d8423b5dc796a4dc2 to your computer and use it in GitHub Desktop.
set proxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| این تیکه کد رو بزارید داخل فایل: | |
| ~/.bashrc | |
| اگر از zsh استفاده میکنید: | |
| ~/.zshrc | |
| بعدش ترمینالو باز و بسته کنید این کامند رو بزنید تا نحوه استفادشو بگه: | |
| set_proxy | |
| مثلا: | |
| set_proxy 2080 | |
| دیفالت رو ساکس۵ ست میکنه اگه تایپ دیگه میخواید پارامتر دوم بهش بدید مثلا http | |
| برای تست اینکه کار میکنه یا نه: | |
| curl -v https://api.ipify.org | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set_proxy() { | |
| if [ -z "$1" ]; then | |
| echo "Usage: set_proxy <port> [type]" | |
| return 1 | |
| fi | |
| if ! [[ "$1" =~ ^[0-9]+$ ]]; then | |
| echo "Error: Port must be a number" | |
| return 1 | |
| fi | |
| local PORT=$1 | |
| local TYPE=${2:-socks5h} | |
| local PROXY="${TYPE}://127.0.0.1:${PORT}" | |
| export HTTP_PROXY="$PROXY" | |
| export HTTPS_PROXY="$PROXY" | |
| export ALL_PROXY="$PROXY" | |
| export http_proxy="$PROXY" | |
| export https_proxy="$PROXY" | |
| export all_proxy="$PROXY" | |
| echo "Proxy set: $PROXY (HTTP, HTTPS, ALL)" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment