mirror of https://gitlab.com/bashrc2/epicyon
Set host domain when getting actor
parent
ab7c2a9a66
commit
c2bc98d4de
|
@ -726,7 +726,7 @@ def _readLocalBoxPost(session, nickname: str, domain: str,
|
|||
if isPGPEncrypted(content):
|
||||
sayStr = 'Encrypted message. Please enter your passphrase.'
|
||||
_sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak)
|
||||
content = pgpDecrypt(content, actor)
|
||||
content = pgpDecrypt(domain, content, actor)
|
||||
if isPGPEncrypted(content):
|
||||
sayStr = 'Message could not be decrypted'
|
||||
_sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak)
|
||||
|
@ -837,7 +837,8 @@ def _desktopShowProfile(session, nickname: str, domain: str,
|
|||
isHttp = False
|
||||
if 'http://' in actor:
|
||||
isHttp = True
|
||||
actorJson, asHeader = getActorJson(actor, isHttp, False, False, True)
|
||||
actorJson, asHeader = \
|
||||
getActorJson(domain, actor, isHttp, False, False, True)
|
||||
|
||||
_desktopShowActor(baseDir, actorJson, translate,
|
||||
systemLanguage, screenreader, espeak)
|
||||
|
@ -855,7 +856,8 @@ def _desktopShowProfileFromHandle(session, nickname: str, domain: str,
|
|||
"""Shows the profile for a handle
|
||||
Returns the actor json
|
||||
"""
|
||||
actorJson, asHeader = getActorJson(handle, False, False, False, True)
|
||||
actorJson, asHeader = \
|
||||
getActorJson(domain, handle, False, False, False, True)
|
||||
|
||||
_desktopShowActor(baseDir, actorJson, translate,
|
||||
systemLanguage, screenreader, espeak)
|
||||
|
@ -1183,7 +1185,7 @@ def _desktopNewDMbase(session, toHandle: str,
|
|||
for after in range(randint(1, 16)):
|
||||
paddedMessage += ' '
|
||||
cipherText = \
|
||||
pgpEncryptToActor(paddedMessage, toHandle)
|
||||
pgpEncryptToActor(domain, paddedMessage, toHandle)
|
||||
if not cipherText:
|
||||
sayStr = \
|
||||
toHandle + ' has no PGP public key. ' + \
|
||||
|
|
|
@ -1632,7 +1632,7 @@ if args.migrations:
|
|||
sys.exit()
|
||||
|
||||
if args.actor:
|
||||
getActorJson(args.actor, args.http, args.gnunet, debug)
|
||||
getActorJson(args.domain, args.actor, args.http, args.gnunet, debug)
|
||||
sys.exit()
|
||||
|
||||
if args.followers:
|
||||
|
|
|
@ -1209,7 +1209,7 @@ def setPersonNotes(baseDir: str, nickname: str, domain: str,
|
|||
return True
|
||||
|
||||
|
||||
def getActorJson(handle: str, http: bool, gnunet: bool,
|
||||
def getActorJson(hostDomain: str, handle: str, http: bool, gnunet: bool,
|
||||
debug: bool, quiet=False) -> ({}, {}):
|
||||
"""Returns the actor json
|
||||
"""
|
||||
|
@ -1354,7 +1354,7 @@ def getActorJson(handle: str, http: bool, gnunet: bool,
|
|||
}
|
||||
personJson = \
|
||||
getJson(session, personUrl, asHeader, None,
|
||||
debug, __version__, httpPrefix, None, 20, quiet)
|
||||
debug, __version__, httpPrefix, hostDomain, 20, quiet)
|
||||
if personJson:
|
||||
if not quiet:
|
||||
pprint(personJson)
|
||||
|
|
13
pgp.py
13
pgp.py
|
@ -332,12 +332,13 @@ def _pgpEncrypt(content: str, recipientPubKey: str) -> str:
|
|||
return encryptResult
|
||||
|
||||
|
||||
def _getPGPPublicKeyFromActor(handle: str, actorJson=None) -> str:
|
||||
def _getPGPPublicKeyFromActor(domain: str, handle: str, actorJson=None) -> str:
|
||||
"""Searches tags on the actor to see if there is any PGP
|
||||
public key specified
|
||||
"""
|
||||
if not actorJson:
|
||||
actorJson, asHeader = getActorJson(handle, False, False, False, True)
|
||||
actorJson, asHeader = \
|
||||
getActorJson(domain, handle, False, False, False, True)
|
||||
if not actorJson:
|
||||
return None
|
||||
if not actorJson.get('attachment'):
|
||||
|
@ -369,18 +370,18 @@ def hasLocalPGPkey() -> bool:
|
|||
return False
|
||||
|
||||
|
||||
def pgpEncryptToActor(content: str, toHandle: str) -> str:
|
||||
def pgpEncryptToActor(domain: str, content: str, toHandle: str) -> str:
|
||||
"""PGP encrypt a message to the given actor or handle
|
||||
"""
|
||||
# get the actor and extract the pgp public key from it
|
||||
recipientPubKey = _getPGPPublicKeyFromActor(toHandle)
|
||||
recipientPubKey = _getPGPPublicKeyFromActor(domain, toHandle)
|
||||
if not recipientPubKey:
|
||||
return None
|
||||
# encrypt using the recipient public key
|
||||
return _pgpEncrypt(content, recipientPubKey)
|
||||
|
||||
|
||||
def pgpDecrypt(content: str, fromHandle: str) -> str:
|
||||
def pgpDecrypt(domain: str, content: str, fromHandle: str) -> str:
|
||||
""" Encrypt using your default pgp key to the given recipient
|
||||
fromHandle can be a handle or actor url
|
||||
"""
|
||||
|
@ -391,7 +392,7 @@ def pgpDecrypt(content: str, fromHandle: str) -> str:
|
|||
if containsPGPPublicKey(content):
|
||||
pubKey = extractPGPPublicKey(content)
|
||||
else:
|
||||
pubKey = _getPGPPublicKeyFromActor(content, fromHandle)
|
||||
pubKey = _getPGPPublicKeyFromActor(domain, content, fromHandle)
|
||||
if pubKey:
|
||||
_pgpImportPubKey(pubKey)
|
||||
|
||||
|
|
13
session.py
13
session.py
|
@ -113,18 +113,17 @@ def getJson(session, url: str, headers: {}, params: {}, debug: bool,
|
|||
if sessionHeaders2.get('Authorization'):
|
||||
sessionHeaders2['Authorization'] = 'REDACTED'
|
||||
if debug and not quiet:
|
||||
print('ERROR: getJson failed\nurl: ' + str(url) + ' ' +
|
||||
'headers: ' + str(sessionHeaders2) + ' ' +
|
||||
'params: ' + str(sessionParams))
|
||||
print(e)
|
||||
print('ERROR: getJson failed, url: ' + str(url) + ', ' +
|
||||
'headers: ' + str(sessionHeaders2) + ', ' +
|
||||
'params: ' + str(sessionParams) + ', ' + str(e))
|
||||
except ValueError as e:
|
||||
sessionHeaders2 = sessionHeaders.copy()
|
||||
if sessionHeaders2.get('Authorization'):
|
||||
sessionHeaders2['Authorization'] = 'REDACTED'
|
||||
if debug and not quiet:
|
||||
print('ERROR: getJson failed\nurl: ' + str(url) + ' ' +
|
||||
'headers: ' + str(sessionHeaders2) + ' ' +
|
||||
'params: ' + str(sessionParams) + ' ' + str(e))
|
||||
print('ERROR: getJson failed, url: ' + str(url) + ', ' +
|
||||
'headers: ' + str(sessionHeaders2) + ', ' +
|
||||
'params: ' + str(sessionParams) + ', ' + str(e))
|
||||
except SocketError as e:
|
||||
if not quiet:
|
||||
if e.errno == errno.ECONNRESET:
|
||||
|
|
|
@ -80,7 +80,7 @@ def htmlProfileAfterSearch(cssCache: {},
|
|||
elif httpPrefix == 'gnunet':
|
||||
gnunet = True
|
||||
profileJson, asHeader = \
|
||||
getActorJson(profileHandle, http, gnunet, debug, False)
|
||||
getActorJson(domain, profileHandle, http, gnunet, debug, False)
|
||||
if not profileJson:
|
||||
return None
|
||||
|
||||
|
|
Loading…
Reference in New Issue