2
0
mirror of https://github.com/ComradCollective/Comrad synced 2024-11-03 23:15:33 +00:00
This commit is contained in:
quadrismegistus 2020-09-22 15:02:00 +01:00
parent 91918d1b12
commit 0bf726fd1f
6 changed files with 33 additions and 6 deletions

View File

@ -9,7 +9,7 @@ export KOMRADE_SHOW_LOG=0
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
path=`realpath "$SCRIPTPATH/../komrade/app/main.py"`
pathvenv=`realpath "$SCRIPTPATH/../../venv/bin/activate"`
pathvenv=`realpath "$SCRIPTPATH/../venv/bin/activate"`
source $pathvenv
python "$path" $*

View File

@ -6,7 +6,9 @@ export KOMRADE_SHOW_LOG=0
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
path=`realpath "$SCRIPTPATH/../komrade/cli/cli.py"`
pathvenv=`realpath "$SCRIPTPATH/../../venv/bin/activate"`
pathvenv=`realpath "$SCRIPTPATH/../venv/bin/activate"`
echo $path
echo $pathvenv
source $pathvenv
python "$path" $*

View File

@ -8,7 +8,7 @@ export KOMRADE_SHOW_LOG=1
# get virtualenv going
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
path=`realpath "$SCRIPTPATH/../komrade/backend/switchboard.py"`
pathvenv=`realpath "$SCRIPTPATH/../../venv/bin/activate"`
pathvenv=`realpath "$SCRIPTPATH/../venv/bin/activate"`
source $pathvenv
# run op forever

View File

@ -25,6 +25,19 @@ class TheTelephone(Operator):
self.log(f'Starting up with callbacks: {self._callbacks}')
@property
def api_url(self):
#if 'KOMRADE_OPERATOR_API_URL' in os.environ and os.environ['KOMRADE_OPERATOR_API_URL']:
# return os.environ
#os.environ['KOMRADE_OPERATOR_API_URL'] = OPERATOR_API_URL_TOR
if 'KOMRADE_USE_TOR' in os.environ and os.environ['KOMRADE_USE_TOR']=='1':
return OPERATOR_API_URL_TOR
elif 'KOMRADE_USE_CLEARNET' in os.environ and os.environ['KOMRADE_USE_CLEARNET']=='1':
return OPERATOR_API_URL_CLEARNET
else:
return OPERATOR_API_URL
def send_and_receive(self,msg_d,**y):
# self.log('send and receive got incoming msg:',msg_d)
@ -48,7 +61,10 @@ class TheTelephone(Operator):
msg_b64_str_esc = msg_b64_str.replace('/','_')
# dial the operator
URL = OPERATOR_API_URL + msg_b64_str_esc + '/'
URL = self.api_url + msg_b64_str_esc + '/'
self.log("DIALING THE OPERATOR:",URL)
phonecall=self.komrade_request(URL)
if phonecall.status_code!=200:

View File

@ -37,7 +37,9 @@ class CLI(Logger):
'verbose':'show/hide log output',
'post':'post to world',
'feed':'fetch posts',
'exit':'exit komrade'
'exit':'exit komrade',
'clearnet':'switch to clearnet',
'tor':'switch to tor',
}
def __init__(self,name='',cmd='',persona=None):
@ -167,6 +169,13 @@ class CLI(Logger):
tot=self.komrade.num_msgs
)
def clearnet(self):
os.environ['KOMRADE_USE_CLEARNET'] = '1'
os.environ['KOMRADE_USE_TOR'] = '0'
def tor(self):
os.environ['KOMRADE_USE_CLEARNET'] = '0'
os.environ['KOMRADE_USE_TOR'] = '1'
def help(self,*x,**y):
clear_screen()

View File

@ -7,7 +7,7 @@ KOMRADE_URL = '68.66.241.111' #KOMRADE_ONION
OPERATOR_API_URL_TOR = f'http://{KOMRADE_ONION}/op/'
OPERATOR_API_URL_CLEARNET = f'http://{KOMRADE_URL}/op/'
OPERATOR_API_URL = OPERATOR_API_URL_CLEARNET
OPERATOR_API_URL = OPERATOR_API_URL_TOR
# paths
import os