mirror of
http://gitea.phreedom.club/localhost_frssoft/pleroma-cli
synced 2024-11-22 02:01:27 +00:00
Support i2p instances and onion (not tested onion)
This commit is contained in:
parent
29faa6e72d
commit
fb20b6c0ed
|
@ -1,5 +1,7 @@
|
||||||
{
|
{
|
||||||
"instance": "soc.phreedom.club",
|
"instance": "soc.phreedom.club",
|
||||||
|
"i2p_http_proxy_addr": "http://127.0.0.1:4444",
|
||||||
|
"tor_proxy_addr": "socks5://127.0.0.1:9050",
|
||||||
"max_statuses": 40,
|
"max_statuses": 40,
|
||||||
"per_status_mode": false,
|
"per_status_mode": false,
|
||||||
"enabled_nsfw": true,
|
"enabled_nsfw": true,
|
||||||
|
|
|
@ -2,8 +2,18 @@
|
||||||
|
|
||||||
instance=$(jj -i config.json instance)
|
instance=$(jj -i config.json instance)
|
||||||
alias default_auth_browser=links
|
alias default_auth_browser=links
|
||||||
instance_point="https://$instance/api/v1"
|
if [ $(echo "$instance" | grep -q 'i2p$' ; echo $?) -eq 0 ]; then
|
||||||
instance_point_pleroma="https://$instance/api/pleroma"
|
default_connect_protocol='http'
|
||||||
|
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)
|
||||||
|
else
|
||||||
|
default_connect_protocol='https'
|
||||||
|
proxy=''
|
||||||
|
fi
|
||||||
|
instance_point="$default_connect_protocol://$instance/api/v1"
|
||||||
|
instance_point_pleroma="$default_connect_protocol://$instance/api/pleroma"
|
||||||
instance_hist='instance.hist'
|
instance_hist='instance.hist'
|
||||||
enabled_nsfw=$(jj -i config.json enabled_nsfw)
|
enabled_nsfw=$(jj -i config.json enabled_nsfw)
|
||||||
hide_reblogs=$(jj -i config.json hide_reblogs)
|
hide_reblogs=$(jj -i config.json hide_reblogs)
|
||||||
|
@ -27,17 +37,17 @@ echo "Instance: $instance"
|
||||||
if [ -n "$auth" ]; then
|
if [ -n "$auth" ]; then
|
||||||
default_curl_opt()
|
default_curl_opt()
|
||||||
{
|
{
|
||||||
curl -s --compressed -H "Authorization: Bearer $auth" "$@"
|
curl --proxy "$proxy" -s --compressed -H "Authorization: Bearer $auth" "$@"
|
||||||
}
|
}
|
||||||
post_request()
|
post_request()
|
||||||
{
|
{
|
||||||
curl -s --compressed -X POST -H "Authorization: Bearer $auth" "$@"
|
curl --proxy "$proxy" -s --compressed -X POST -H "Authorization: Bearer $auth" "$@"
|
||||||
}
|
}
|
||||||
echo '+Authorized account+'
|
echo '+Authorized account+'
|
||||||
else
|
else
|
||||||
default_curl_opt()
|
default_curl_opt()
|
||||||
{
|
{
|
||||||
curl -s --compressed "$1"
|
curl --proxy "$proxy" -s --compressed "$1"
|
||||||
}
|
}
|
||||||
echo 'Please make auth and restart'
|
echo 'Please make auth and restart'
|
||||||
fi
|
fi
|
||||||
|
@ -831,8 +841,18 @@ case $main_menu in
|
||||||
if [ $empty -eq 0 ]; then
|
if [ $empty -eq 0 ]; then
|
||||||
echo "$instance" >> $instance_hist
|
echo "$instance" >> $instance_hist
|
||||||
cat $instance_hist | sort | uniq | tee $instance_hist 1>>/dev/null
|
cat $instance_hist | sort | uniq | tee $instance_hist 1>>/dev/null
|
||||||
export instance
|
if [ $(echo "$instance" | grep -q 'i2p$'; echo $?) -eq 0 ]; then
|
||||||
export instance_point="https://$instance/api/v1"
|
default_connect_protocol='http'
|
||||||
|
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)
|
||||||
|
else
|
||||||
|
default_connect_protocol='https'
|
||||||
|
proxy=
|
||||||
|
fi
|
||||||
|
instance_point="$default_connect_protocol://$instance/api/v1"
|
||||||
|
instance_point_pleroma="$default_connect_protocol://$instance/api/pleroma"
|
||||||
conf_instance_state=$(echo 'Permanent\nTemporaly' | fzy)
|
conf_instance_state=$(echo 'Permanent\nTemporaly' | fzy)
|
||||||
if [ "$conf_instance_state" = 'Permanent' ]; then
|
if [ "$conf_instance_state" = 'Permanent' ]; then
|
||||||
jj -i config.json instance -v "$instance" -o config.json
|
jj -i config.json instance -v "$instance" -o config.json
|
||||||
|
@ -845,17 +865,17 @@ case $main_menu in
|
||||||
if [ -n "$auth" ]; then
|
if [ -n "$auth" ]; then
|
||||||
default_curl_opt()
|
default_curl_opt()
|
||||||
{
|
{
|
||||||
curl -s --compressed -H "Authorization: Bearer $auth" "$@"
|
curl --proxy "$proxy" -s --compressed -H "Authorization: Bearer $auth" "$@"
|
||||||
}
|
}
|
||||||
post_request()
|
post_request()
|
||||||
{
|
{
|
||||||
curl -s --compressed -X POST -H "Authorization: Bearer $auth" "$@"
|
curl --proxy "$proxy" -s --compressed -X POST -H "Authorization: Bearer $auth" "$@"
|
||||||
}
|
}
|
||||||
echo '+Authorized account+'
|
echo '+Authorized account+'
|
||||||
else
|
else
|
||||||
default_curl_opt()
|
default_curl_opt()
|
||||||
{
|
{
|
||||||
curl -s --compressed "$1"
|
curl --proxy "$proxy" -s --compressed "$1"
|
||||||
}
|
}
|
||||||
echo 'Please make auth and restart'
|
echo 'Please make auth and restart'
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue