Proxy support global main proxy; Update README.md

This commit is contained in:
localhost_frssoft 2022-05-03 20:47:15 +03:00
parent 5c08b9de1a
commit eb5a57dd35
3 changed files with 30 additions and 8 deletions

View file

@ -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/)

View file

@ -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,

View file

@ -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=