2
0
mirror of https://github.com/ComradCollective/Comrad synced 2024-11-16 00:12:48 +00:00
Comrad/comrad/constants.py

399 lines
10 KiB
Python
Raw Normal View History

2020-09-05 16:26:37 +00:00
# addresses
2020-09-29 13:16:50 +00:00
COMRAD_ONION = 'u7spnj3dmwumzoa4.onion'
COMRAD_ONION2 = 'rwg4zcnpwshv4laq.onion'
COMRAD_URL = '68.66.241.111' #COMRAD_ONION
2020-09-05 19:00:29 +00:00
2020-09-29 13:16:50 +00:00
OPERATOR_API_URL_TOR = f'http://{COMRAD_ONION}/op/'
OPERATOR_API_URL_CLEARNET = f'http://{COMRAD_URL}/op/'
2020-09-05 16:26:37 +00:00
2020-09-22 14:02:00 +00:00
OPERATOR_API_URL = OPERATOR_API_URL_TOR
2020-09-05 16:26:37 +00:00
# paths
import os
2020-09-14 17:50:03 +00:00
PATH_USER_HOME = os.path.join(os.path.expanduser('~'))
2020-09-29 13:16:50 +00:00
PATH_COMRAD = os.path.abspath(os.path.join(os.path.expanduser('~'),'comrad','data'))
PATH_COMRAD_KEYS = os.path.join(PATH_COMRAD,'.keys')
PATH_COMRAD_DATA = os.path.join(PATH_COMRAD,'.data')
PATH_COMRAD_LIB = os.path.abspath(os.path.join(os.path.expanduser('~'),'comrad','lib'))
2020-09-08 07:13:48 +00:00
2020-09-29 13:16:50 +00:00
PATH_CRYPT_OP_KEYS = os.path.join(PATH_COMRAD_KEYS,'.op.db.keys.crypt')
PATH_CRYPT_OP_DATA = os.path.join(PATH_COMRAD_DATA,'.op.db.data.crypt')
2020-09-20 19:34:45 +00:00
2020-09-29 13:16:50 +00:00
# PATH_CRYPT_CA_KEYS = os.path.join(PATH_COMRAD_KEYS,'.ca.db.keys.crypt')
# PATH_CRYPT_CA_DATA = os.path.join(PATH_COMRAD_DATA,'.ca.db.data.encr')
2020-09-06 19:24:36 +00:00
PATH_CRYPT_CA_KEYS = PATH_CRYPT_OP_KEYS
PATH_CRYPT_CA_DATA = PATH_CRYPT_OP_DATA
2020-09-29 13:16:50 +00:00
PATH_QRCODES = os.path.join(PATH_COMRAD,'contacts')
# PATH_SECRETS = os.path.join(PATH_COMRAD,'.secrets')
2020-09-14 19:35:40 +00:00
PATH_SECRETS = PATH_SUPER_SECRETS = os.path.join(PATH_USER_HOME,'.secrets')
2020-09-29 13:09:56 +00:00
PATH_SUPER_SECRET_OP_KEY = os.path.join(PATH_SUPER_SECRETS,'.comrad.op.key')
2020-09-12 20:46:49 +00:00
2020-09-29 13:16:50 +00:00
PATH_MAPS = os.path.join(PATH_COMRAD,'maps')
2020-09-20 19:34:45 +00:00
2020-09-29 13:16:50 +00:00
PATH_LOG_OUTPUT = os.path.join(PATH_COMRAD,'logs')
2020-09-16 08:30:07 +00:00
2020-09-29 13:16:50 +00:00
for x in [PATH_COMRAD,PATH_COMRAD_DATA,PATH_COMRAD_KEYS,PATH_QRCODES,PATH_SECRETS,PATH_SUPER_SECRETS,PATH_LOG_OUTPUT]:
2020-09-08 07:13:48 +00:00
if not os.path.exists(x):
os.makedirs(x)
2020-09-05 16:26:37 +00:00
2020-09-10 09:00:11 +00:00
CRYPT_USE_SECRET = True
2020-09-12 20:46:49 +00:00
PATH_CRYPT_SECRET = os.path.join(PATH_SECRETS,'.salt')
PATH_CRYPT_SECRET_KEY = os.path.join(PATH_SECRETS,'.key')
2020-09-10 09:00:11 +00:00
2020-09-05 16:26:37 +00:00
# etc
BSEP=b'||||||||||'
BSEP2=b'@@@@@@@@@@'
BSEP3=b'##########'
2020-09-05 22:06:48 +00:00
2020-09-12 18:18:37 +00:00
OPERATOR_NAME = 'Operator'
TELEPHONE_NAME = 'Telephone'
2020-09-29 13:09:56 +00:00
WORLD_NAME = 'comrads'
PATH_REPO = os.path.abspath(
os.path.join(
os.path.dirname(__file__),
'..'
)
)
2020-09-29 13:09:56 +00:00
PATH_GUI = os.path.join(PATH_REPO,'comrad','app')
PATH_GUI_ASSETS = os.path.join(PATH_GUI,'assets')
2020-09-27 11:32:23 +00:00
PATH_DEFAULT_AVATAR = os.path.join(PATH_GUI_ASSETS,'avatars','britney2.jpg')
PATH_REPO = PATH_APP = os.path.abspath(os.path.dirname(__file__))
2020-09-29 13:09:56 +00:00
# PATH_APP = os.path.join(PATH_REPO,'comrad')
# PATH_BUILTIN_KEYCHAINS_ENCR = os.path.join(PATH_APP,'.builtin.keychains.encr')
PATH_BUILTIN_KEYCHAIN = os.path.join(PATH_APP,'.builtin.keys')
PATH_OMEGA_KEY = os.path.join(PATH_APP,'.omega.key')
# PATH_BUILTIN_KEYCHAINS_DECR = os.path.join(PATH_APP,'.builtin.keychains.decr')
PATH_GUI = os.path.join(PATH_APP, )
2020-09-05 22:06:48 +00:00
2020-09-05 16:26:37 +00:00
# key names
KEYNAMES = [
'pubkey','privkey','adminkey',
'pubkey_encr','privkey_encr','adminkey_encr',
'pubkey_decr','privkey_decr','adminkey_decr',
'pubkey_encr_encr','privkey_encr_encr','adminkey_encr_encr',
'pubkey_encr_decr','privkey_encr_decr','adminkey_encr_decr',
'pubkey_decr_encr','privkey_decr_encr','adminkey_decr_encr',
'pubkey_decr_decr','privkey_decr_decr','adminkey_decr_decr'
]
2020-09-05 21:11:42 +00:00
2020-09-06 13:07:27 +00:00
OPERATOR_INTERCEPT_MESSAGE = "If you'd like to make a call, please hang up and try again. If you need help, hang up, and then dial your operator."
# KEYMAKER_DEFAULT_KEYS_TO_SAVE = ['pubkey_encr', 'privkey_encr', 'adminkey_encr']
2020-09-06 15:14:55 +00:00
# KEYMAKER_DEFAULT_KEYS_TO_RETURN = ['pubkey_decr_encr', 'privkey_decr_encr', 'adminkey_decr_encr']
# defaults oriented to Callers
2020-09-08 09:14:42 +00:00
# kept on server
KEYMAKER_DEFAULT_KEYS_TO_SAVE_ON_SERVER = ['pubkey'] # stored under QR URI
# kept on client
2020-09-10 14:20:08 +00:00
KEYMAKER_DEFAULT_KEYS_TO_SAVE_ON_CLIENT = ['privkey_encr','privkey_decr']
2020-09-08 09:14:42 +00:00
#'pubkey' # as QR
2020-09-10 14:20:08 +00:00
# 'privkey_encr',
# 'adminkey_encr',
# 'privkey_decr'],
2020-09-09 15:41:55 +00:00
#'privkey_decr_encr',
#'privkey_decr_decr',
2020-09-10 14:20:08 +00:00
# 'adminkey_decr_encr',
# 'adminkey_decr_decr']
2020-09-10 14:20:08 +00:00
# KEYMAKER_DEFAULT_KEYS_TO_GEN = ['pubkey','privkey','adminkey',
# 'pubkey_decr','privkey_decr', 'adminkey_decr']
2020-09-10 14:21:04 +00:00
KEYMAKER_DEFAULT_KEYS_TO_GEN = ['pubkey','privkey']
2020-09-08 09:17:09 +00:00
KEYMAKER_DEFAULT_KEYS_TO_GEN += KEYMAKER_DEFAULT_KEYS_TO_SAVE_ON_SERVER
KEYMAKER_DEFAULT_KEYS_TO_GEN += KEYMAKER_DEFAULT_KEYS_TO_SAVE_ON_CLIENT
2020-09-06 15:14:55 +00:00
KEYMAKER_DEFAULT_KEYS_TO_GEN = list(set(KEYMAKER_DEFAULT_KEYS_TO_GEN))
KEYMAKER_DEFAULT_KEYS_TO_GEN.sort(key=lambda x: x.count('_'))
2020-09-06 14:45:40 +00:00
2020-09-09 18:31:36 +00:00
# print('KEYMAKER_DEFAULT_KEYS_TO_SAVE_ON_SERVER',KEYMAKER_DEFAULT_KEYS_TO_SAVE_ON_SERVER)
# print('KEYMAKER_DEFAULT_KEYS_TO_SAVE_ON_CLIENT',KEYMAKER_DEFAULT_KEYS_TO_SAVE_ON_CLIENT)
# print('KEYMAKER_DEFAULT_KEYS_TO_GEN',KEYMAKER_DEFAULT_KEYS_TO_GEN)
2020-09-06 13:07:27 +00:00
KEY_TYPE_ASYMMETRIC_PUBKEY = 'asymmetric_pubkey'
KEY_TYPE_ASYMMETRIC_PRIVKEY = 'asymmetric_privkey'
KEY_TYPE_SYMMETRIC_WITHOUT_PASSPHRASE = 'symmetric_key_without_passphrase'
KEY_TYPE_SYMMETRIC_WITH_PASSPHRASE = 'symmetric_key_with_passphrase'
ENCRYPTED_KEY = 'encrypted_key'
2020-09-12 14:32:03 +00:00
KEYMAKER_DEFAULT_ALL_KEY_NAMES = KEYNAMES
2020-09-13 14:25:41 +00:00
WHY_MSG = 'password: '#What is the password of memory for this account? '
2020-09-06 15:47:45 +00:00
2020-09-07 16:26:03 +00:00
TELEPHONE_KEYCHAIN = None
OPERATOR_KEYCHAIN = None
2020-09-10 09:54:47 +00:00
WORLD_KEYCHAIN = None
2020-09-07 17:11:52 +00:00
OMEGA_KEY = None
OPERATOR = None
TELEPHONE = None
2020-09-29 13:09:56 +00:00
PATH_OPERATOR_WEB_KEYS_FILE = f'/home/ryan/www/website-comrad/pub'
2020-09-29 13:16:50 +00:00
PATH_OPERATOR_WEB_KEYS_URL = f'http://{COMRAD_URL}/pub'
2020-09-29 13:09:56 +00:00
# PATH_OPERATOR_WEB_CONTACTS_DIR = '/home/ryan/www/website-comrad/.contacts'
2020-09-29 13:16:50 +00:00
# PATH_OPERATOR_WEB_CONTACT_OP_URL = f'http://{COMRAD_URL}/.contacts/TheOperator.png'
# PATH_OPERATOR_WEB_CONTACT_PH_URL = f'http://{COMRAD_URL}/.contacts/TheTelephone.png'
2020-09-07 17:27:46 +00:00
# dangerous! leave on only if absolutely necessary for initial dev
2020-09-08 07:20:42 +00:00
ALLOW_CLEARNET = True
2020-09-10 21:32:59 +00:00
DEBUG_DEFAULT_PASSPHRASE = None # 'all your base are belong to us'
2020-09-09 10:58:00 +00:00
2020-09-12 18:18:37 +00:00
ROUTE_KEYNAME = 'request'
2020-09-10 11:12:29 +00:00
2020-09-10 12:52:07 +00:00
2020-09-10 15:28:54 +00:00
OPERATOR_INTRO = 'Hello, this is the Operator speaking. '
VISIBILITY_TYPE_PUBLIC = 'VISIBILITY_TYPE_PUBLIC' # visible to the world
VISIBILITY_TYPE_SEMIPUBLIC = 'VISIBILITY_TYPE_SEMIPUBLIC' # visible to the world
VISIBILITY_TYPE_PRIVATE = 'VISIBILITY_TYPE_PRIVATE' # visible to the world
DEFAULT_USER_SETTINGS = {
'visibility':VISIBILITY_TYPE_SEMIPUBLIC
2020-09-10 17:54:49 +00:00
}
2020-09-15 08:51:52 +00:00
import os
2020-09-14 21:01:30 +00:00
SHOW_LOG = 1
2020-09-12 07:55:23 +00:00
SHOW_STATUS = 0
2020-09-14 11:52:56 +00:00
PAUSE_LOGGER = 0
CLEAR_LOGGER = 0
2020-09-10 21:32:59 +00:00
2020-09-16 08:30:07 +00:00
SAVE_LOGS = 1
2020-09-29 13:16:50 +00:00
CLI_TITLE = 'COMRAD'
2020-09-11 14:35:47 +00:00
CLI_FONT = 'clr5x6'#'colossal'
2020-09-16 10:23:18 +00:00
CLI_WIDTH = STATUS_LINE_WIDTH = 60
2020-09-20 12:43:34 +00:00
CLI_HEIGHT = 30
2020-09-12 07:55:23 +00:00
2020-09-18 07:51:53 +00:00
MAX_POST_LEN = 1000
2020-09-22 13:36:20 +00:00
MAX_MSG_LEN = 1000
2020-09-22 13:47:55 +00:00
import os,logging
2020-09-29 13:16:50 +00:00
if not 'COMRAD_SHOW_LOG' in os.environ or not os.environ['COMRAD_SHOW_LOG'] or os.environ['COMRAD_SHOW_LOG']=='0':
2020-09-22 13:36:20 +00:00
logger = logging.getLogger()
2020-09-22 15:09:25 +00:00
logger.propagate = False
2020-09-29 13:16:50 +00:00
if not 'COMRAD_USE_TOR' in os.environ or not os.environ['COMRAD_USE_TOR']:
COMRAD_USE_TOR = os.environ['COMRAD_USE_TOR'] = '1'
if not 'COMRAD_USE_CLEARNET' in os.environ or not os.environ['COMRAD_USE_CLEARNET']:
COMRAD_USE_CLEARNET = os.environ['COMRAD_USE_CLEARNET'] = '0'
2020-09-23 12:14:12 +00:00
2020-09-24 10:40:48 +00:00
FONT_PATH = os.path.join(PATH_GUI_ASSETS,'font.otf')
#from p2p_api import
PORT_LISTEN = 5969
# NODES_PRIME = [("128.232.229.63",8467), ("68.66.241.111",8467)]
NODES_PRIME = [("128.232.229.63",8467)]
DEFAULT_URI='/login/'
import random,platform
HORIZONTAL = True # random.choice([True,True,True,False])
FACTOR=1
WINDOW_SIZE = (1136*FACTOR,640*FACTOR) if HORIZONTAL else (640*FACTOR,1136*FACTOR)
PLAYING_CARDS = (2.5,3.5)
ASPECT_RATIO = PLAYING_CARDS[0]/PLAYING_CARDS[1]
ASPECT_RATIO = 1/ASPECT_RATIO
HEIGHT = 850
if platform.platform().startswith('Linux'):
HEIGHT *= 1.25
WINDOW_SIZE=int(HEIGHT),int(HEIGHT * ASPECT_RATIO)
BG_IMG='assets/bg-brown.png'
grass=(201,203,163)
russiangreen = (109,140,96)
huntergreen = (67,92,61)
kombugreen = (49,67,45)
pinetreegreen = (29,40,27)
junglegreen = (15, 21, 14)
browncoffee=(77, 42, 34)
rootbeer=(38, 7, 1)
blackbean=(61, 12, 2)
burntumber=(132, 55, 34)
brownsugar=(175, 110, 81)
antiquebrass= (198, 144, 118)
royalbrown=(94, 55, 46)
bole=(113, 65, 55)
liver= (110, 56, 31)
bistre=(58, 33, 14)
bistre2=(43, 21, 7)
skin1=(89, 47, 42)
skin2=(80, 51, 53)
skin3=(40, 24, 26)
grullo=177, 158, 141
smokyblack=33, 14, 0
liverchestnut=148, 120, 96
ashgray=196, 199, 188
livchestnut2=156, 106, 73
beaver=165, 134, 110
rawumber=120, 95, 74
persianred=202,52,51
vermillion=126,25,27
indianred=205,92,92
barnred=124,10,2
maroon=128,0,0
bloodred=98, 23, 8
rust=188, 57, 8
darksienna=34, 9, 1
yellowcrayola=246, 170, 28
darkred=148, 27, 12
rosewood=94, 11, 21
redviolet=144, 50, 61
bone=217, 202, 179
bronze=188, 128, 52
shadow=140, 122, 107
orangered=194, 3, 3
dutchwhite=229,219,181
# black=(0,0,0)
black=15, 15, 15 #5, 8, 13
eerieblack=23, 22, 20
bistre=58, 38, 24
tuscanred=117, 64, 67
grullo2=154, 136, 115
blackolive=55, 66, 61
dogreen=103, 116, 35
sage=187, 193, 145
alabaster2 = 241, 236, 226
coyotebrown = 138, 93, 61
vandykebrown = 90, 62, 41
darksienna2=55, 6, 23
xiketic=3, 7, 30
rossacorsa=208, 0, 0
raisinblack=38, 34, 34
coffee2=67, 58, 58
rufusred=171, 4, 4
darksienna3=56, 22, 13
black2=0, 20, 39
xanadu=112, 141, 129
jasmine=244, 213, 141
ioe=191, 6, 3
dred=141, 8, 1
caputmort1=74, 36, 25
# SCHEME = 'lgreen'
# SCHEME = 'bronze'
SCHEME = 'dark'
# light green theme?
if SCHEME=='lgreen':
COLOR_TOOLBAR= huntergreen #bone #smokyblack #5,5,5 #russiangreen #pinetreegreen #kombugreen #(12,5,5) #russiangreen
COLOR_BG = grass # russiangreen #(0,73,54)
COLOR_LOGO = coyotebrown # grass#russiangreen #(0,0,0) #(0,0,0) #(151,177,140) #(132,162,118) #(109,140,106)
COLOR_TEXT = black #(255,245,200) #(0,0,0,1) #(241,233,203) #COLOR_ICON #(207,219,204) #(239,235,206) # (194,211,187) # (171,189,163) # (222,224,198) # COLOR_LOGO #(223, 223, 212)
COLOR_CARD = bone #(67,92,61) #(12,9,10)
COLOR_CARD_BORDER = COLOR_CARD
COLOR_ICON=COLOR_LOGO
elif SCHEME=='bronze':
COLOR_TOOLBAR= junglegreen
COLOR_BG = bronze
COLOR_LOGO = rufusred #yellowcrayola #0,0,0
COLOR_TEXT = black
COLOR_CARD = bone
COLOR_CARD_BORDER = COLOR_CARD
COLOR_ICON=COLOR_LOGO
else:
# COLOR_TOOLBAR= black
# COLOR_TOOLBAR=bronze
# COLOR_LOGO = black #bronze #0,0,0
# COLOR_BG = black
COLOR_BG=bistre
COLOR_TOOLBAR=black
COLOR_LOGO=bronze
COLOR_TEXT = black
COLOR_CARD = bone
COLOR_CARD_BORDER = COLOR_CARD
COLOR_ICON=COLOR_LOGO
COLOR_ACCENT = huntergreen
COLOR_INACTIVE = COLOR_CARD
COLOR_ACTIVE = russiangreen
ALL_COLORS = list({v for (k,v) in globals().items() if type(v)==tuple and len(v)==3})