From eb5a57dd35f760fa07a87adbd114f4d392cd75fb Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Tue, 3 May 2022 20:47:15 +0300 Subject: [PATCH] Proxy support global main proxy; Update README.md --- README.md | 16 ++++++++++++++++ config.json | 2 ++ pleroma-cli.sh | 20 ++++++++++++-------- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 57f01a4..254bc85 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,22 @@ Features: * Switch instance from public list in config.json or manual input. Also recent used instance list. * All others futures maybe working 50/50 +Note about proxy: +Proxy by default autodetect i2p and onion (not tested) instances address. +If provided main_proxy in config.json is disable i2p and onion instances autodetection. +Also: don't forget change connect_protocol_via_main_proxy if set http proxy or any proxy without support https. + +Note about auth: +i2p and onion instances may no support (or disabled) OAuth2. +Workaround: if instance have clearweb address, make auth and copy-paste token in .auth.json, example: +``` +{ + "your.authorized.instance": "xxx", + "abc123instance.i2p": "xxx", + "abc123instance.onion": "xxx" +} +``` + Depends: * [jj](http://gitea.phreedom.club/localhost_frssoft/jj) * [curl](https://curl.se/) diff --git a/config.json b/config.json index 78985ae..d68f71d 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,7 @@ { "instance": "soc.phreedom.club", + "main_proxy": "", + "connect_protocol_via_main_proxy": "https", "i2p_http_proxy_addr": "http://127.0.0.1:4444", "tor_proxy_addr": "socks5://127.0.0.1:9050", "max_statuses": 40, diff --git a/pleroma-cli.sh b/pleroma-cli.sh index e6c1b7f..dcb5339 100755 --- a/pleroma-cli.sh +++ b/pleroma-cli.sh @@ -5,18 +5,22 @@ alias default_auth_browser=links proxy_init() { - if [ $(echo "$instance" | grep -q 'i2p$' ; echo $?) -eq 0 ]; then + main_proxy=$(jj -i config.json main_proxy) + if [ -n "$main_proxy" ]; then + default_connect_protocol=$(jj -i config.json connect_protocol_via_main_proxy) + ALL_PROXY="$main_proxy" + elif [ $(echo "$instance" | grep -q 'i2p$' ; echo $?) -eq 0 ]; then default_connect_protocol='http' - proxy=$(jj -i config.json i2p_http_proxy_addr) + ALL_PROXY=$(jj -i config.json i2p_http_proxy_addr) elif [ $(echo "$instance" | grep -q 'onion$'; echo $?) -eq 0 ]; then default_connect_protocol='https' - proxy=$(jj -i config.json tor_proxy_addr) + ALL_PROXY=$(jj -i config.json tor_proxy_addr) else default_connect_protocol='https' - proxy='' + ALL_PROXY='' fi export default_connect_protocol - export proxy + export ALL_PROXY } proxy_init @@ -48,11 +52,11 @@ make_login() if [ -n "$auth" ]; then default_curl_opt() { - curl --proxy "$proxy" -s --compressed -H "Authorization: Bearer $auth" "$@" + curl -s --compressed -H "Authorization: Bearer $auth" "$@" } post_request() { - curl --proxy "$proxy" -s --compressed -X POST -H "Authorization: Bearer $auth" "$@" + curl -s --compressed -X POST -H "Authorization: Bearer $auth" "$@" } echo '+Authorized account+' export default_curl_opt @@ -60,7 +64,7 @@ make_login() else default_curl_opt() { - curl --proxy "$proxy" -s --compressed "$1" + curl -s --compressed "$1" } export default_curl_opt export post_request=