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