Merge branch 'main' of ssh://code.freedombone.net:2222/bashrc/epicyon into main

main
Bob Mottram 2021-03-14 21:08:43 +00:00
commit 48265fd9c0
28 changed files with 250 additions and 153 deletions

View File

@ -219,7 +219,7 @@ def sendAnnounceViaServer(baseDir: str, session,
# lookup the inbox for the To handle
wfRequest = webfingerHandle(session, handle, httpPrefix,
cachedWebfingers,
fromDomain, projectVersion)
fromDomain, projectVersion, debug)
if not wfRequest:
if debug:
print('DEBUG: announce webfinger failed for ' + handle)

View File

@ -105,7 +105,7 @@ def sendAvailabilityViaServer(baseDir: str, session,
# lookup the inbox for the To handle
wfRequest = webfingerHandle(session, handle, httpPrefix,
cachedWebfingers,
domain, projectVersion)
domain, projectVersion, debug)
if not wfRequest:
if debug:
print('DEBUG: announce webfinger failed for ' + handle)

View File

@ -1248,6 +1248,9 @@ class PubServer(BaseHTTPRequestHandler):
headersDict['Date'] = self.headers['Date']
if self.headers.get('digest'):
headersDict['digest'] = self.headers['digest']
if self.headers.get('Collection-Synchronization'):
headersDict['Collection-Synchronization'] = \
self.headers['Collection-Synchronization']
if self.headers.get('Content-type'):
headersDict['Content-type'] = self.headers['Content-type']
if self.headers.get('Content-Length'):
@ -1330,8 +1333,9 @@ class PubServer(BaseHTTPRequestHandler):
return True
elif self.path.endswith('/' + nickname):
return True
print('AUTH: nickname ' + nickname +
' was not found in path ' + self.path)
if self.server.debug:
print('AUTH: nickname ' + nickname +
' was not found in path ' + self.path)
return False
print('AUTH: epicyon cookie ' +
'authorization failed, header=' +
@ -1376,7 +1380,7 @@ class PubServer(BaseHTTPRequestHandler):
if GETtimings.get(prevGetId):
timeDiff = int(timeDiff - int(GETtimings[prevGetId]))
GETtimings[currGetId] = str(timeDiff)
if logEvent:
if logEvent and self.server.debug:
print('GET TIMING ' + currGetId + ' = ' + str(timeDiff))
def _benchmarkPOSTtimings(self, POSTstartTime, POSTtimings: [],
@ -1394,7 +1398,8 @@ class PubServer(BaseHTTPRequestHandler):
if logEvent:
ctr = 1
for timeDiff in POSTtimings:
print('POST TIMING|' + str(ctr) + '|' + timeDiff)
if self.server.debug:
print('POST TIMING|' + str(ctr) + '|' + timeDiff)
ctr += 1
def _pathContainsBlogLink(self, baseDir: str,
@ -7348,6 +7353,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.peertubeInstances,
self.server.allowLocalNetworkAccess,
self.server.textModeBanner,
self.server.debug,
actorJson['roles'],
None, None)
msg = msg.encode('utf-8')
@ -7436,6 +7442,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.peertubeInstances,
allowLocalNetworkAccess,
self.server.textModeBanner,
self.server.debug,
actorJson['skills'],
None, None)
msg = msg.encode('utf-8')
@ -9240,6 +9247,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.peertubeInstances,
self.server.allowLocalNetworkAccess,
self.server.textModeBanner,
self.server.debug,
shares,
pageNumber, sharesPerPage)
msg = msg.encode('utf-8')
@ -9338,6 +9346,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.peertubeInstances,
self.server.allowLocalNetworkAccess,
self.server.textModeBanner,
self.server.debug,
following,
pageNumber,
followsPerPage).encode('utf-8')
@ -9436,6 +9445,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.peertubeInstances,
self.server.allowLocalNetworkAccess,
self.server.textModeBanner,
self.server.debug,
followers,
pageNumber,
followsPerPage).encode('utf-8')
@ -9557,6 +9567,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.peertubeInstances,
self.server.allowLocalNetworkAccess,
self.server.textModeBanner,
self.server.debug,
None, None).encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
@ -13634,7 +13645,7 @@ class PubServer(BaseHTTPRequestHandler):
# check authorization
authorized = self._isAuthorized()
if not authorized:
if not authorized and self.server.debug:
print('POST Not authorized')
print(str(self.headers))
@ -13931,7 +13942,8 @@ class PubServer(BaseHTTPRequestHandler):
"editblogpost", "newreminder", "newevent")
for currPostType in postTypes:
if not authorized:
print('POST was not authorized')
if self.server.debug:
print('POST was not authorized')
break
postRedirect = self.server.defaultTimeline
@ -14233,7 +14245,8 @@ class PubServer(BaseHTTPRequestHandler):
return
else:
if self.path == '/sharedInbox' or self.path == '/inbox':
print('DEBUG: POST to shared inbox')
if self.server.debug:
print('DEBUG: POST to shared inbox')
queueStatus = \
self._updateInboxQueue('inbox', messageJson, messageBytes)
if queueStatus >= 0 and queueStatus <= 3:

View File

@ -55,7 +55,7 @@ def sendDeleteViaServer(baseDir: str, session,
# lookup the inbox for the To handle
wfRequest = \
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
fromDomain, projectVersion)
fromDomain, projectVersion, debug)
if not wfRequest:
if debug:
print('DEBUG: announce webfinger failed for ' + handle)

View File

@ -295,6 +295,11 @@ parser.add_argument("--brochMode",
type=str2bool, nargs='?',
const=True, default=False,
help="Enable broch mode")
parser.add_argument("--noKeyPress",
dest='noKeyPress',
type=str2bool, nargs='?',
const=True, default=False,
help="Notification daemon does not wait for keypresses")
parser.add_argument("--noapproval", type=str2bool, nargs='?',
const=True, default=False,
help="Allow followers without approval")
@ -509,6 +514,9 @@ args = parser.parse_args()
debug = False
if args.debug:
debug = True
else:
if os.path.isfile('debug'):
debug = True
if args.tests:
runAllTests()
@ -723,7 +731,7 @@ if args.json:
'Accept': 'application/ld+json; profile="' + profileStr + '"'
}
testJson = getJson(session, args.json, asHeader, None,
__version__, httpPrefix, None)
debug, __version__, httpPrefix, None)
pprint(testJson)
sys.exit()
@ -1472,7 +1480,7 @@ if args.followers:
handle = nickname + '@' + domain
wfRequest = webfingerHandle(session, handle,
httpPrefix, cachedWebfingers,
None, __version__)
None, __version__, debug)
if not wfRequest:
print('Unable to webfinger ' + handle)
sys.exit()
@ -1857,6 +1865,7 @@ if args.notifications:
args.screenreader, args.language,
args.notificationSounds,
args.notificationType,
args.noKeyPress,
args.debug)
sys.exit()

View File

@ -989,7 +989,7 @@ def sendFollowRequestViaServer(baseDir: str, session,
# lookup the inbox for the To handle
wfRequest = \
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
fromDomain, projectVersion)
fromDomain, projectVersion, debug)
if not wfRequest:
if debug:
print('DEBUG: announce webfinger failed for ' + handle)
@ -1078,7 +1078,7 @@ def sendUnfollowRequestViaServer(baseDir: str, session,
# lookup the inbox for the To handle
wfRequest = \
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
fromDomain, projectVersion)
fromDomain, projectVersion, debug)
if not wfRequest:
if debug:
print('DEBUG: announce webfinger failed for ' + handle)

View File

@ -265,6 +265,10 @@ def verifyPostHeaders(httpPrefix: str, publicKeyPem: str, headers: dict,
if debug:
print('DEBUG: verifyPostHeaders ' + method)
print('verifyPostHeaders publicKeyPem: ' + str(publicKeyPem))
print('verifyPostHeaders headers: ' + str(headers))
print('verifyPostHeaders messageBodyJsonStr: ' +
str(messageBodyJsonStr))
pubkey = load_pem_public_key(publicKeyPem.encode('utf-8'),
backend=default_backend())
@ -353,7 +357,24 @@ def verifyPostHeaders(httpPrefix: str, publicKeyPem: str, headers: dict,
signedHeaderList.append(
f'{signedHeader}: {headers[signedHeader]}')
else:
signedHeaderCap = signedHeader.capitalize()
if '-' in signedHeader:
# capitalise with dashes
# my-header becomes My-Header
headerParts = signedHeader.split('-')
signedHeaderCap = None
for part in headerParts:
if signedHeaderCap:
signedHeaderCap += '-' + part.capitalize()
else:
signedHeaderCap = part.capitalize()
else:
# header becomes Header
signedHeaderCap = signedHeader.capitalize()
if debug:
print('signedHeaderCap: ' + signedHeaderCap)
# if this is the date header then check it is recent
if signedHeaderCap == 'Date':
if not _verifyRecentSignature(headers[signedHeaderCap]):
if debug:
@ -361,9 +382,17 @@ def verifyPostHeaders(httpPrefix: str, publicKeyPem: str, headers: dict,
'verifyPostHeaders date is not recent ' +
headers[signedHeader])
return False
# add the capitalised header
if headers.get(signedHeaderCap):
signedHeaderList.append(
f'{signedHeader}: {headers[signedHeaderCap]}')
elif '-' in signedHeader:
# my-header becomes My-header
signedHeaderCap = signedHeader.capitalize()
if headers.get(signedHeaderCap):
signedHeaderList.append(
f'{signedHeader}: {headers[signedHeaderCap]}')
if debug:
print('DEBUG: signedHeaderList: ' + str(signedHeaderList))

View File

@ -253,8 +253,8 @@ def getPersonPubKey(baseDir: str, session, personUrl: str,
'Accept': 'application/activity+json; profile="' + profileStr + '"'
}
personJson = \
getJson(session, personUrl, asHeader, None, projectVersion,
httpPrefix, personDomain)
getJson(session, personUrl, asHeader, None, debug,
projectVersion, httpPrefix, personDomain)
if not personJson:
return None
pubKey = None
@ -395,9 +395,10 @@ def savePostToInboxQueue(baseDir: str, httpPrefix: str,
replyDomain, replyPort = \
getDomainFromActor(inReplyTo)
if isBlockedDomain(baseDir, replyDomain):
print('WARN: post contains reply from ' +
str(actor) +
' to a blocked domain: ' + replyDomain)
if debug:
print('WARN: post contains reply from ' +
str(actor) +
' to a blocked domain: ' + replyDomain)
return None
else:
replyNickname = \
@ -405,16 +406,18 @@ def savePostToInboxQueue(baseDir: str, httpPrefix: str,
if replyNickname and replyDomain:
if isBlocked(baseDir, nickname, domain,
replyNickname, replyDomain):
print('WARN: post contains reply from ' +
str(actor) +
' to a blocked account: ' +
replyNickname + '@' + replyDomain)
if debug:
print('WARN: post contains reply from ' +
str(actor) +
' to a blocked account: ' +
replyNickname + '@' + replyDomain)
return None
if postJsonObject['object'].get('content'):
if isinstance(postJsonObject['object']['content'], str):
if isFiltered(baseDir, nickname, domain,
postJsonObject['object']['content']):
print('WARN: post was filtered out due to content')
if debug:
print('WARN: post was filtered out due to content')
return None
originalPostId = None
if postJsonObject.get('id'):
@ -758,8 +761,9 @@ def _personReceiveUpdate(baseDir: str,
debug: bool) -> bool:
"""Changes an actor. eg: avatar or display name change
"""
print('Receiving actor update for ' + personJson['url'] +
' ' + str(personJson))
if debug:
print('Receiving actor update for ' + personJson['url'] +
' ' + str(personJson))
domainFull = getFullDomain(domain, port)
updateDomainFull = getFullDomain(updateDomain, updatePort)
usersPaths = ('users', 'profile', 'channel', 'accounts', 'u')
@ -814,7 +818,8 @@ def _personReceiveUpdate(baseDir: str,
personCache, True)
# save to cache on file
if saveJson(personJson, actorFilename):
print('actor updated for ' + personJson['id'])
if debug:
print('actor updated for ' + personJson['id'])
# remove avatar if it exists so that it will be refreshed later
# when a timeline is constructed
@ -901,7 +906,9 @@ def _receiveUpdate(recentPostsCache: {}, session, baseDir: str,
if messageJson['type'] == 'Person':
if messageJson.get('url') and messageJson.get('id'):
print('Request to update actor unwrapped: ' + str(messageJson))
if debug:
print('Request to update actor unwrapped: ' +
str(messageJson))
updateNickname = getNicknameFromActor(messageJson['id'])
if updateNickname:
updateDomain, updatePort = \
@ -922,7 +929,8 @@ def _receiveUpdate(recentPostsCache: {}, session, baseDir: str,
messageJson['object']['type'] == 'Service':
if messageJson['object'].get('url') and \
messageJson['object'].get('id'):
print('Request to update actor: ' + str(messageJson))
if debug:
print('Request to update actor: ' + str(messageJson))
updateNickname = getNicknameFromActor(messageJson['actor'])
if updateNickname:
updateDomain, updatePort = \
@ -1376,7 +1384,7 @@ def _receiveAnnounce(recentPostsCache: {},
__version__, translate,
YTReplacementDomain,
allowLocalNetworkAccess,
recentPostsCache)
recentPostsCache, debug)
if not postJsonObject:
notInOnion = True
if onionDomain:
@ -1432,8 +1440,9 @@ def _receiveAnnounce(recentPostsCache: {},
__version__, httpPrefix,
domain, onionDomain)
if pubKey:
print('DEBUG: public key obtained for announce: ' +
lookupActor)
if debug:
print('DEBUG: public key obtained for announce: ' +
lookupActor)
break
if debug:
@ -1602,7 +1611,7 @@ def _estimateNumberOfEmoji(content: str) -> int:
def _validPostContent(baseDir: str, nickname: str, domain: str,
messageJson: {}, maxMentions: int, maxEmoji: int,
allowLocalNetworkAccess: bool) -> bool:
allowLocalNetworkAccess: bool, debug: bool) -> bool:
"""Is the content of a received post valid?
Check for bad html
Check for hellthreads
@ -1621,7 +1630,7 @@ def _validPostContent(baseDir: str, nickname: str, domain: str,
return False
if 'Z' not in messageJson['object']['published']:
return False
if not validPostDate(messageJson['object']['published']):
if not validPostDate(messageJson['object']['published'], 90, debug):
return False
if messageJson['object'].get('summary'):
@ -1687,7 +1696,8 @@ def _validPostContent(baseDir: str, nickname: str, domain: str,
print('REJECT: reply to post which does not ' +
'allow comments: ' + originalPostId)
return False
print('ACCEPT: post content is valid')
if debug:
print('ACCEPT: post content is valid')
return True
@ -1729,7 +1739,8 @@ def _obtainAvatarForReplyPost(session, baseDir: str, httpPrefix: str,
__version__, httpPrefix,
domain, onionDomain)
if pubKey:
print('DEBUG: public key obtained for reply: ' + lookupActor)
if debug:
print('DEBUG: public key obtained for reply: ' + lookupActor)
break
if debug:
@ -2299,7 +2310,7 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
nickname = handle.split('@')[0]
if _validPostContent(baseDir, nickname, domain,
postJsonObject, maxMentions, maxEmoji,
allowLocalNetworkAccess):
allowLocalNetworkAccess, debug):
if postJsonObject.get('object'):
jsonObj = postJsonObject['object']
@ -2465,7 +2476,7 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
nickname, domain, postJsonObject,
translate, YTReplacementDomain,
allowLocalNetworkAccess,
recentPostsCache):
recentPostsCache, debug):
# media index will be updated
updateIndexList.append('tlmedia')
if isBlogPost(postJsonObject):
@ -2702,7 +2713,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
queue.pop(0)
continue
print('Loading queue item ' + queueFilename)
if debug:
print('Loading queue item ' + queueFilename)
# Load the queue json
queueJson = loadJson(queueFilename, 1)
@ -2829,7 +2841,7 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
if accountMaxPostsPerDay > 0 or domainMaxPostsPerDay > 0:
pprint(quotasDaily)
if queueJson.get('actor'):
if debug and queueJson.get('actor'):
print('Obtaining public key for actor ' + queueJson['actor'])
# Try a few times to obtain the public key
@ -2866,7 +2878,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
time.sleep(1)
if not pubKey:
print('Queue: public key could not be obtained from ' + keyId)
if debug:
print('Queue: public key could not be obtained from ' + keyId)
if os.path.isfile(queueFilename):
os.remove(queueFilename)
if len(queue) > 0:
@ -2888,8 +2901,7 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
debug):
httpSignatureFailed = True
print('Queue: Header signature check failed')
if debug:
pprint(queueJson['httpHeaders'])
pprint(queueJson['httpHeaders'])
else:
if debug:
print('DEBUG: http header signature check success')
@ -3041,7 +3053,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
federationList,
queueJson['postNickname'],
debug):
print('Queue: Update accepted from ' + keyId)
if debug:
print('Queue: Update accepted from ' + keyId)
if os.path.isfile(queueFilename):
os.remove(queueFilename)
if len(queue) > 0:
@ -3054,8 +3067,9 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
httpPrefix, domain, port, debug)
if len(recipientsDict.items()) == 0 and \
len(recipientsDictFollowers.items()) == 0:
print('Queue: no recipients were resolved ' +
'for post arriving in inbox')
if debug:
print('Queue: no recipients were resolved ' +
'for post arriving in inbox')
if os.path.isfile(queueFilename):
os.remove(queueFilename)
if len(queue) > 0:
@ -3123,8 +3137,7 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
themeName)
if debug:
pprint(queueJson['post'])
print('Queue: Queue post accepted')
print('Queue: Queue post accepted')
if os.path.isfile(queueFilename):
os.remove(queueFilename)
if len(queue) > 0:

View File

@ -78,7 +78,7 @@ fi
echo '';
echo '[Service]';
echo "WorkingDirectory=${HOME}/.epicyon";
echo "ExecStart=/usr/bin/python3 epicyon.py --notifyType $notificationType --notify $HANDLE --password \"$PASSWORD\"";
echo "ExecStart=/usr/bin/python3 epicyon.py --noKeyPress --notifyType $notificationType --notify $HANDLE --password \"$PASSWORD\"";
echo 'Type=oneshot';
echo 'RemainAfterExit=yes';
echo '';

View File

@ -167,7 +167,7 @@ def sendLikeViaServer(baseDir: str, session,
# lookup the inbox for the To handle
wfRequest = webfingerHandle(session, handle, httpPrefix,
cachedWebfingers,
fromDomain, projectVersion)
fromDomain, projectVersion, debug)
if not wfRequest:
if debug:
print('DEBUG: announce webfinger failed for ' + handle)
@ -248,7 +248,7 @@ def sendUndoLikeViaServer(baseDir: str, session,
# lookup the inbox for the To handle
wfRequest = webfingerHandle(session, handle, httpPrefix,
cachedWebfingers,
fromDomain, projectVersion)
fromDomain, projectVersion, debug)
if not wfRequest:
if debug:
print('DEBUG: announce webfinger failed for ' + handle)

View File

@ -56,7 +56,7 @@ def _updateMovedHandle(baseDir: str, nickname: str, domain: str,
handle = handle[1:]
wfRequest = webfingerHandle(session, handle,
httpPrefix, cachedWebfingers,
None, __version__)
None, __version__, debug)
if not wfRequest:
print('updateMovedHandle unable to webfinger ' + handle)
return ctr
@ -76,7 +76,7 @@ def _updateMovedHandle(baseDir: str, nickname: str, domain: str,
'Accept': 'application/activity+json; profile="' + profileStr + '"'
}
if not personUrl:
personUrl = getUserUrl(wfRequest)
personUrl = getUserUrl(wfRequest, 0, debug)
if not personUrl:
return ctr
@ -85,8 +85,8 @@ def _updateMovedHandle(baseDir: str, nickname: str, domain: str,
'Accept': 'application/ld+json; profile="' + profileStr + '"'
}
personJson = \
getJson(session, personUrl, asHeader, None, __version__,
httpPrefix, None)
getJson(session, personUrl, asHeader, None,
debug, __version__, httpPrefix, None)
if not personJson:
return ctr
if not personJson.get('movedTo'):

View File

@ -144,11 +144,11 @@ def _addNewswireDictEntry(baseDir: str, domain: str,
]
def _validFeedDate(pubDate: str) -> bool:
def _validFeedDate(pubDate: str, debug=False) -> bool:
# convert from YY-MM-DD HH:MM:SS+00:00 to
# YY-MM-DDTHH:MM:SSZ
postDate = pubDate.replace(' ', 'T').replace('+00:00', 'Z')
return validPostDate(postDate, 90)
return validPostDate(postDate, 90, debug)
def parseFeedDate(pubDate: str) -> str:

View File

@ -574,6 +574,7 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
systemLanguage: str,
notificationSounds: bool,
notificationType: str,
noKeyPress: bool,
debug: bool) -> None:
"""Runs the notifications and screen reader client,
which announces new inbox items
@ -772,7 +773,10 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
prevSay = speakerJson['say']
# wait for a while, or until a key is pressed
keyPress = _waitForKeypress(30, debug)
if noKeyPress:
time.sleep(10)
else:
keyPress = _waitForKeypress(30, debug)
if keyPress:
if keyPress.startswith('/'):
keyPress = keyPress[1:]

View File

@ -272,7 +272,7 @@ def postMessageToOutbox(session, translate: {},
messageJson,
translate, YTReplacementDomain,
allowLocalNetworkAccess,
recentPostsCache):
recentPostsCache, debug):
inboxUpdateIndex('tlmedia', baseDir,
postToNickname + '@' + domain,
savedFilename, debug)

View File

@ -1102,7 +1102,8 @@ def setPersonNotes(baseDir: str, nickname: str, domain: str,
return True
def getActorJson(handle: str, http: bool, gnunet: bool, quiet=False) -> {}:
def getActorJson(handle: str, http: bool, gnunet: bool,
debug: bool, quiet=False) -> {}:
"""Returns the actor json
"""
originalActor = handle
@ -1175,7 +1176,7 @@ def getActorJson(handle: str, http: bool, gnunet: bool, quiet=False) -> {}:
handle = nickname + '@' + domain
wfRequest = webfingerHandle(session, handle,
httpPrefix, cachedWebfingers,
None, __version__)
None, __version__, debug)
if not wfRequest:
if not quiet:
print('Unable to webfinger ' + handle)
@ -1203,7 +1204,7 @@ def getActorJson(handle: str, http: bool, gnunet: bool, quiet=False) -> {}:
'Accept': 'application/activity+json; profile="' + profileStr + '"'
}
if not personUrl:
personUrl = getUserUrl(wfRequest)
personUrl = getUserUrl(wfRequest, 0, debug)
if nickname == domain:
personUrl = personUrl.replace('/users/', '/actor/')
personUrl = personUrl.replace('/accounts/', '/actor/')
@ -1224,8 +1225,8 @@ def getActorJson(handle: str, http: bool, gnunet: bool, quiet=False) -> {}:
}
personJson = \
getJson(session, personUrl, asHeader, None, __version__,
httpPrefix, None, 20, quiet)
getJson(session, personUrl, asHeader, None,
debug, __version__, httpPrefix, None, 20, quiet)
if personJson:
if not quiet:
pprint(personJson)
@ -1236,7 +1237,7 @@ def getActorJson(handle: str, http: bool, gnunet: bool, quiet=False) -> {}:
}
personJson = \
getJson(session, personUrl, asHeader, None,
__version__, httpPrefix, None)
debug, __version__, httpPrefix, None)
if not quiet:
if personJson:
pprint(personJson)

View File

@ -148,7 +148,7 @@ def _cleanHtml(rawHtml: str) -> str:
return html.unescape(text)
def getUserUrl(wfRequest: {}, sourceId=0) -> str:
def getUserUrl(wfRequest: {}, sourceId=0, debug=False) -> str:
"""Gets the actor url from a webfinger request
"""
if not wfRequest.get('links'):
@ -166,7 +166,7 @@ def getUserUrl(wfRequest: {}, sourceId=0) -> str:
if link['type'] != 'application/activity+json':
continue
if '/@' not in link['href']:
if not hasUsersPath(link['href']):
if debug and not hasUsersPath(link['href']):
print('getUserUrl webfinger activity+json ' +
'contains single user instance actor ' +
str(sourceId) + ' ' + str(link))
@ -183,7 +183,7 @@ def parseUserFeed(session, feedUrl: str, asHeader: {},
return None
feedJson = getJson(session, feedUrl, asHeader, None,
projectVersion, httpPrefix, domain)
False, projectVersion, httpPrefix, domain)
if not feedJson:
return None
@ -220,6 +220,7 @@ def getPersonBox(baseDir: str, session, wfRequest: {},
nickname: str, domain: str,
boxName='inbox',
sourceId=0) -> (str, str, str, str, str, str, str, str):
debug = False
profileStr = 'https://www.w3.org/ns/activitystreams'
asHeader = {
'Accept': 'application/activity+json; profile="' + profileStr + '"'
@ -229,7 +230,7 @@ def getPersonBox(baseDir: str, session, wfRequest: {},
return None, None, None, None, None, None, None
if not wfRequest.get('errors'):
personUrl = getUserUrl(wfRequest, sourceId)
personUrl = getUserUrl(wfRequest, sourceId, debug)
else:
if nickname == 'dev':
# try single user instance
@ -250,13 +251,13 @@ def getPersonBox(baseDir: str, session, wfRequest: {},
'Accept': 'application/ld+json; profile="' + profileStr + '"'
}
personJson = getJson(session, personUrl, asHeader, None,
projectVersion, httpPrefix, domain)
debug, projectVersion, httpPrefix, domain)
if not personJson:
asHeader = {
'Accept': 'application/ld+json; profile="' + profileStr + '"'
}
personJson = getJson(session, personUrl, asHeader, None,
projectVersion, httpPrefix, domain)
debug, projectVersion, httpPrefix, domain)
if not personJson:
print('Unable to get actor')
return None, None, None, None, None, None, None
@ -1935,7 +1936,7 @@ def sendPost(projectVersion: str,
# lookup the inbox for the To handle
wfRequest = webfingerHandle(session, handle, httpPrefix,
cachedWebfingers,
domain, projectVersion)
domain, projectVersion, debug)
if not wfRequest:
return 1
if not isinstance(wfRequest, dict):
@ -2052,7 +2053,7 @@ def sendPostViaServer(projectVersion: str,
# lookup the inbox for the To handle
wfRequest = \
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
fromDomain, projectVersion)
fromDomain, projectVersion, debug)
if not wfRequest:
if debug:
print('DEBUG: webfinger failed for ' + handle)
@ -2249,7 +2250,7 @@ def sendSignedJson(postJsonObject: {}, session, baseDir: str,
# lookup the inbox for the To handle
wfRequest = webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
domain, projectVersion)
domain, projectVersion, debug)
if not wfRequest:
if debug:
print('DEBUG: webfinger for ' + handle + ' failed')
@ -2538,7 +2539,8 @@ def sendToNamedAddresses(session, baseDir: str,
personCache, debug, projectVersion)
def _hasSharedInbox(session, httpPrefix: str, domain: str) -> bool:
def _hasSharedInbox(session, httpPrefix: str, domain: str,
debug: bool) -> bool:
"""Returns true if the given domain has a shared inbox
This tries the new and the old way of webfingering the shared inbox
"""
@ -2547,9 +2549,8 @@ def _hasSharedInbox(session, httpPrefix: str, domain: str) -> bool:
'inbox@' + domain
]
for handle in tryHandles:
wfRequest = webfingerHandle(session, handle,
httpPrefix, {},
None, __version__)
wfRequest = webfingerHandle(session, handle, httpPrefix, {},
None, __version__, debug)
if wfRequest:
if isinstance(wfRequest, dict):
if not wfRequest.get('errors'):
@ -2634,7 +2635,8 @@ def sendToFollowers(session, baseDir: str,
print('Sending post to followers domain is active: ' +
followerDomainUrl)
withSharedInbox = _hasSharedInbox(session, httpPrefix, followerDomain)
withSharedInbox = _hasSharedInbox(session, httpPrefix,
followerDomain, debug)
if debug:
if withSharedInbox:
print(followerDomain + ' has shared inbox')
@ -2926,7 +2928,7 @@ def isImageMedia(session, baseDir: str, httpPrefix: str,
postJsonObject: {}, translate: {},
YTReplacementDomain: str,
allowLocalNetworkAccess: bool,
recentPostsCache: {}) -> bool:
recentPostsCache: {}, debug: bool) -> bool:
"""Returns true if the given post has attached image media
"""
if postJsonObject['type'] == 'Announce':
@ -2936,7 +2938,7 @@ def isImageMedia(session, baseDir: str, httpPrefix: str,
__version__, translate,
YTReplacementDomain,
allowLocalNetworkAccess,
recentPostsCache)
recentPostsCache, debug)
if postJsonAnnounce:
postJsonObject = postJsonAnnounce
if postJsonObject['type'] != 'Create':
@ -3463,7 +3465,7 @@ def getPublicPostsOfPerson(baseDir: str, nickname: str, domain: str,
handle = httpPrefix + "://" + domainFull + "/@" + nickname
wfRequest = \
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
domain, projectVersion)
domain, projectVersion, debug)
if not wfRequest:
sys.exit()
if not isinstance(wfRequest, dict):
@ -3505,7 +3507,7 @@ def getPublicPostDomains(session, baseDir: str, nickname: str, domain: str,
handle = httpPrefix + "://" + domainFull + "/@" + nickname
wfRequest = \
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
domain, projectVersion)
domain, projectVersion, debug)
if not wfRequest:
return domainList
if not isinstance(wfRequest, dict):
@ -3536,7 +3538,7 @@ def getPublicPostDomains(session, baseDir: str, nickname: str, domain: str,
def downloadFollowCollection(followType: str,
session, httpPrefix,
actor: str, pageNumber=1,
noOfPages=1) -> []:
noOfPages=1, debug=False) -> []:
"""Returns a list of following/followers for the given actor
by downloading the json for their following/followers collection
"""
@ -3553,8 +3555,8 @@ def downloadFollowCollection(followType: str,
for pageCtr in range(noOfPages):
url = actor + '/' + followType + '?page=' + str(pageNumber + pageCtr)
followersJson = \
getJson(session, url, sessionHeaders, None, __version__,
httpPrefix, None)
getJson(session, url, sessionHeaders, None,
debug, __version__, httpPrefix, None)
if followersJson:
if followersJson.get('orderedItems'):
for followerActor in followersJson['orderedItems']:
@ -3585,7 +3587,7 @@ def getPublicPostInfo(session, baseDir: str, nickname: str, domain: str,
handle = httpPrefix + "://" + domainFull + "/@" + nickname
wfRequest = \
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
domain, projectVersion)
domain, projectVersion, debug)
if not wfRequest:
return {}
if not isinstance(wfRequest, dict):
@ -3841,7 +3843,7 @@ def downloadAnnounce(session, baseDir: str, httpPrefix: str,
postJsonObject: {}, projectVersion: str,
translate: {}, YTReplacementDomain: str,
allowLocalNetworkAccess: bool,
recentPostsCache: {}) -> {}:
recentPostsCache: {}, debug: bool) -> {}:
"""Download the post referenced by an announce
"""
if not postJsonObject.get('object'):
@ -3865,8 +3867,9 @@ def downloadAnnounce(session, baseDir: str, httpPrefix: str,
return None
if os.path.isfile(announceFilename):
print('Reading cached Announce content for ' +
postJsonObject['object'])
if debug:
print('Reading cached Announce content for ' +
postJsonObject['object'])
postJsonObject = loadJson(announceFilename)
if postJsonObject:
return postJsonObject
@ -3906,10 +3909,12 @@ def downloadAnnounce(session, baseDir: str, httpPrefix: str,
print('Announce download blocked object: ' +
str(postJsonObject['object']))
return None
print('Downloading Announce content for ' + postJsonObject['object'])
if debug:
print('Downloading Announce content for ' +
postJsonObject['object'])
announcedJson = \
getJson(session, postJsonObject['object'], asHeader,
None, projectVersion, httpPrefix, domain)
None, debug, projectVersion, httpPrefix, domain)
if not announcedJson:
return None
@ -3958,7 +3963,7 @@ def downloadAnnounce(session, baseDir: str, httpPrefix: str,
baseDir, nickname, domain, postId,
recentPostsCache)
return None
if not validPostDate(announcedJson['published']):
if not validPostDate(announcedJson['published'], 90, debug):
_rejectAnnounce(announceFilename,
baseDir, nickname, domain, postId,
recentPostsCache)
@ -4148,7 +4153,7 @@ def sendBlockViaServer(baseDir: str, session,
# lookup the inbox for the To handle
wfRequest = webfingerHandle(session, handle, httpPrefix,
cachedWebfingers,
fromDomain, projectVersion)
fromDomain, projectVersion, debug)
if not wfRequest:
if debug:
print('DEBUG: announce webfinger failed for ' + handle)
@ -4232,7 +4237,7 @@ def sendUndoBlockViaServer(baseDir: str, session,
# lookup the inbox for the To handle
wfRequest = webfingerHandle(session, handle, httpPrefix,
cachedWebfingers,
fromDomain, projectVersion)
fromDomain, projectVersion, debug)
if not wfRequest:
if debug:
print('DEBUG: announce webfinger failed for ' + handle)

View File

@ -2378,8 +2378,13 @@ class JsonLdProcessor(object):
# hash bnode paths
path_namer = UniqueNamer('_:b')
path_namer.get_name(bnode)
results.append(self._hash_paths(
bnode, bnodes, namer, path_namer))
try:
bnode_path = self._hash_paths(
bnode, bnodes, namer, path_namer)
results.append(bnode_path)
except BaseException:
print('WARN: jsonld bnode_path failed')
pass
# name bnodes in hash order
cmp_hashes = cmp_to_key(lambda x, y: cmp(x['hash'], y['hash']))

View File

@ -310,7 +310,7 @@ def sendRoleViaServer(baseDir: str, session,
# lookup the inbox for the To handle
wfRequest = webfingerHandle(session, handle, httpPrefix,
cachedWebfingers,
delegatorDomain, projectVersion)
delegatorDomain, projectVersion, debug)
if not wfRequest:
if debug:
print('DEBUG: announce webfinger failed for ' + handle)

View File

@ -84,12 +84,13 @@ def urlExists(session, url: str, timeoutSec=3,
return False
def getJson(session, url: str, headers: {}, params: {},
def getJson(session, url: str, headers: {}, params: {}, debug: bool,
version='1.2.0', httpPrefix='https',
domain='testdomain', timeoutSec=20, quiet=False) -> {}:
if not isinstance(url, str):
print('url: ' + str(url))
print('ERROR: getJson failed, url should be a string')
if debug and not quiet:
print('url: ' + str(url))
print('ERROR: getJson failed, url should be a string')
return None
sessionParams = {}
sessionHeaders = {}
@ -113,7 +114,7 @@ def getJson(session, url: str, headers: {}, params: {},
sessionHeaders2 = sessionHeaders.copy()
if sessionHeaders2.get('Authorization'):
sessionHeaders2['Authorization'] = 'REDACTED'
if not quiet:
if debug and not quiet:
print('ERROR: getJson failed\nurl: ' + str(url) + ' ' +
'headers: ' + str(sessionHeaders2) + ' ' +
'params: ' + str(sessionParams))
@ -122,7 +123,7 @@ def getJson(session, url: str, headers: {}, params: {},
sessionHeaders2 = sessionHeaders.copy()
if sessionHeaders2.get('Authorization'):
sessionHeaders2['Authorization'] = 'REDACTED'
if not quiet:
if debug and not quiet:
print('ERROR: getJson failed\nurl: ' + str(url) + ' ' +
'headers: ' + str(sessionHeaders2) + ' ' +
'params: ' + str(sessionParams) + ' ')

View File

@ -358,7 +358,7 @@ def sendShareViaServer(baseDir, session,
wfRequest = \
webfingerHandle(session, handle, httpPrefix,
cachedWebfingers,
fromDomain, projectVersion)
fromDomain, projectVersion, debug)
if not wfRequest:
if debug:
print('DEBUG: announce webfinger failed for ' + handle)
@ -457,7 +457,7 @@ def sendUndoShareViaServer(baseDir: str, session,
# lookup the inbox for the To handle
wfRequest = \
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
fromDomain, projectVersion)
fromDomain, projectVersion, debug)
if not wfRequest:
if debug:
print('DEBUG: announce webfinger failed for ' + handle)

View File

@ -123,7 +123,7 @@ def sendSkillViaServer(baseDir: str, session, nickname: str, password: str,
wfRequest = \
webfingerHandle(session, handle, httpPrefix,
cachedWebfingers,
domain, projectVersion)
domain, projectVersion, debug)
if not wfRequest:
if debug:
print('DEBUG: announce webfinger failed for ' + handle)

View File

@ -52,7 +52,7 @@ def instancesGraph(baseDir: str, handles: str,
wfRequest = \
webfingerHandle(session, handle, httpPrefix,
cachedWebfingers,
domain, projectVersion)
domain, projectVersion, debug)
if not wfRequest:
return dotGraphStr + '}\n'
if not isinstance(wfRequest, dict):

View File

@ -279,7 +279,7 @@ def getSpeakerFromServer(baseDir: str, session,
domainFull + '/users/' + nickname + '/speaker'
speakerJson = \
getJson(session, url, headers, None,
getJson(session, url, headers, None, debug,
__version__, httpPrefix, domain, 20, True)
return speakerJson

View File

@ -100,7 +100,7 @@ def hasUsersPath(pathStr: str) -> bool:
return False
def validPostDate(published: str, maxAgeDays=90) -> bool:
def validPostDate(published: str, maxAgeDays=90, debug=False) -> bool:
"""Returns true if the published date is recent and is not in the future
"""
baselineTime = datetime.datetime(1970, 1, 1)
@ -118,11 +118,13 @@ def validPostDate(published: str, maxAgeDays=90) -> bool:
postDaysSinceEpoch = daysDiff.days
if postDaysSinceEpoch > nowDaysSinceEpoch:
print("Inbox post has a published date in the future!")
if debug:
print("Inbox post has a published date in the future!")
return False
if nowDaysSinceEpoch - postDaysSinceEpoch >= maxAgeDays:
print("Inbox post is not recent enough")
if debug:
print("Inbox post is not recent enough")
return False
return True

View File

@ -1223,7 +1223,7 @@ def individualPostAsHtml(allowDownloads: bool,
postActorWf = \
webfingerHandle(session, postActorHandle, httpPrefix,
cachedWebfingers,
domain, __version__)
domain, __version__, False)
avatarUrl2 = None
displayName = None
@ -1292,7 +1292,7 @@ def individualPostAsHtml(allowDownloads: bool,
projectVersion, translate,
YTReplacementDomain,
allowLocalNetworkAccess,
recentPostsCache)
recentPostsCache, False)
if not postJsonAnnounce:
# if the announce could not be downloaded then mark it as rejected
rejectPostId(baseDir, nickname, domain, postJsonObject['id'],

View File

@ -75,12 +75,14 @@ def htmlProfileAfterSearch(cssCache: {},
searchDomain, searchPort = getDomainFromActor(profileHandle)
else:
if '@' not in profileHandle:
print('DEBUG: no @ in ' + profileHandle)
if debug:
print('DEBUG: no @ in ' + profileHandle)
return None
if profileHandle.startswith('@'):
profileHandle = profileHandle[1:]
if '@' not in profileHandle:
print('DEBUG: no @ in ' + profileHandle)
if debug:
print('DEBUG: no @ in ' + profileHandle)
return None
searchNickname = profileHandle.split('@')[0]
searchDomain = profileHandle.split('@')[1]
@ -91,17 +93,21 @@ def htmlProfileAfterSearch(cssCache: {},
searchPort = int(searchPortStr)
searchDomain = searchDomain.split(':')[0]
if searchPort:
print('DEBUG: Search for handle ' +
str(searchNickname) + '@' + str(searchDomain) + ':' +
str(searchPort))
if debug:
print('DEBUG: Search for handle ' +
str(searchNickname) + '@' + str(searchDomain) + ':' +
str(searchPort))
else:
print('DEBUG: Search for handle ' +
str(searchNickname) + '@' + str(searchDomain))
if debug:
print('DEBUG: Search for handle ' +
str(searchNickname) + '@' + str(searchDomain))
if not searchNickname:
print('DEBUG: No nickname found in ' + profileHandle)
if debug:
print('DEBUG: No nickname found in ' + profileHandle)
return None
if not searchDomain:
print('DEBUG: No domain found in ' + profileHandle)
if debug:
print('DEBUG: No domain found in ' + profileHandle)
return None
searchDomainFull = getFullDomain(searchDomain, searchPort)
@ -115,19 +121,21 @@ def htmlProfileAfterSearch(cssCache: {},
webfingerHandle(session,
searchNickname + '@' + searchDomainFull,
httpPrefix, cachedWebfingers,
domain, projectVersion)
domain, projectVersion, debug)
if not wf:
print('DEBUG: Unable to webfinger ' +
searchNickname + '@' + searchDomainFull)
print('DEBUG: cachedWebfingers ' + str(cachedWebfingers))
print('DEBUG: httpPrefix ' + httpPrefix)
print('DEBUG: domain ' + domain)
if debug:
print('DEBUG: Unable to webfinger ' +
searchNickname + '@' + searchDomainFull)
print('DEBUG: cachedWebfingers ' + str(cachedWebfingers))
print('DEBUG: httpPrefix ' + httpPrefix)
print('DEBUG: domain ' + domain)
return None
if not isinstance(wf, dict):
print('WARN: Webfinger search for ' +
searchNickname + '@' + searchDomainFull +
' did not return a dict. ' +
str(wf))
if debug:
print('WARN: Webfinger search for ' +
searchNickname + '@' + searchDomainFull +
' did not return a dict. ' +
str(wf))
return None
personUrl = None
@ -140,7 +148,7 @@ def htmlProfileAfterSearch(cssCache: {},
'Accept': 'application/activity+json; profile="' + profileStr + '"'
}
if not personUrl:
personUrl = getUserUrl(wf)
personUrl = getUserUrl(wf, 0, debug)
if not personUrl:
# try single user instance
asHeader = {
@ -148,14 +156,14 @@ def htmlProfileAfterSearch(cssCache: {},
}
personUrl = httpPrefix + '://' + searchDomainFull
profileJson = \
getJson(session, personUrl, asHeader, None,
getJson(session, personUrl, asHeader, None, debug,
projectVersion, httpPrefix, domain)
if not profileJson:
asHeader = {
'Accept': 'application/ld+json; profile="' + profileStr + '"'
}
profileJson = \
getJson(session, personUrl, asHeader, None,
getJson(session, personUrl, asHeader, None, debug,
projectVersion, httpPrefix, domain)
if not profileJson:
print('DEBUG: No actor returned from ' + personUrl)
@ -481,6 +489,7 @@ def htmlProfile(rssIconAtTop: bool,
peertubeInstances: [],
allowLocalNetworkAccess: bool,
textModeBanner: str,
debug: bool,
extraJson=None, pageNumber=None,
maxItemsPerPage=None) -> str:
"""Show the profile page as html
@ -816,7 +825,7 @@ def htmlProfile(rssIconAtTop: bool,
cachedWebfingers, personCache, extraJson,
projectVersion, ["unfollow"], selected,
usersPath, pageNumber, maxItemsPerPage,
dormantMonths)
dormantMonths, debug)
elif selected == 'followers':
profileStr += \
_htmlProfileFollowing(translate, baseDir, httpPrefix,
@ -825,7 +834,7 @@ def htmlProfile(rssIconAtTop: bool,
cachedWebfingers, personCache, extraJson,
projectVersion, ["block"],
selected, usersPath, pageNumber,
maxItemsPerPage, dormantMonths)
maxItemsPerPage, dormantMonths, debug)
elif selected == 'roles':
profileStr += \
_htmlProfileRoles(translate, nickname, domainFull,
@ -920,7 +929,7 @@ def _htmlProfileFollowing(translate: {}, baseDir: str, httpPrefix: str,
feedName: str, actor: str,
pageNumber: int,
maxItemsPerPage: int,
dormantMonths: int) -> str:
dormantMonths: int, debug: bool) -> str:
"""Shows following on the profile screen
"""
profileStr = ''
@ -952,7 +961,7 @@ def _htmlProfileFollowing(translate: {}, baseDir: str, httpPrefix: str,
domain, followingActor,
authorized, nickname,
httpPrefix, projectVersion, dormant,
buttons)
debug, buttons)
if authorized and maxItemsPerPage and pageNumber:
if len(followingJson['orderedItems']) >= maxItemsPerPage:
@ -1801,6 +1810,7 @@ def _individualFollowAsHtml(translate: {},
httpPrefix: str,
projectVersion: str,
dormant: bool,
debug: bool,
buttons=[]) -> str:
"""An individual follow entry on the profile screen
"""
@ -1817,7 +1827,7 @@ def _individualFollowAsHtml(translate: {},
followUrlWf = \
webfingerHandle(session, followUrlHandle, httpPrefix,
cachedWebfingers,
domain, __version__)
domain, __version__, debug)
(inboxUrl, pubKeyId, pubKey,
fromPersonId, sharedInbox,

View File

@ -441,7 +441,7 @@ def setBlogAddress(actorJson: {}, blogAddress: str) -> None:
def updateAvatarImageCache(session, baseDir: str, httpPrefix: str,
actor: str, avatarUrl: str,
personCache: {}, allowDownloads: bool,
force=False) -> str:
force=False, debug=False) -> str:
"""Updates the cached avatar for the given actor
"""
if not avatarUrl:
@ -502,8 +502,8 @@ def updateAvatarImageCache(session, baseDir: str, httpPrefix: str,
'Accept': 'application/ld+json; profile="' + prof + '"'
}
personJson = \
getJson(session, actor, sessionHeaders, None, __version__,
httpPrefix, None)
getJson(session, actor, sessionHeaders, None,
debug, __version__, httpPrefix, None)
if personJson:
if not personJson.get('id'):
return None

View File

@ -40,11 +40,13 @@ def _parseHandle(handle: str) -> (str, str):
def webfingerHandle(session, handle: str, httpPrefix: str,
cachedWebfingers: {},
fromDomain: str, projectVersion: str) -> {}:
fromDomain: str, projectVersion: str,
debug: bool) -> {}:
"""Gets webfinger result for the given ActivityPub handle
"""
if not session:
print('WARN: No session specified for webfingerHandle')
if debug:
print('WARN: No session specified for webfingerHandle')
return None
nickname, domain = _parseHandle(handle)
@ -60,7 +62,8 @@ def webfingerHandle(session, handle: str, httpPrefix: str,
wf = getWebfingerFromCache(nickname + '@' + wfDomain,
cachedWebfingers)
if wf:
print('Webfinger from cache: ' + str(wf))
if debug:
print('Webfinger from cache: ' + str(wf))
return wf
url = '{}://{}/.well-known/webfinger'.format(httpPrefix, domain)
par = {
@ -71,7 +74,8 @@ def webfingerHandle(session, handle: str, httpPrefix: str,
}
try:
result = \
getJson(session, url, hdr, par, projectVersion,
getJson(session, url, hdr, par,
debug, projectVersion,
httpPrefix, fromDomain)
except Exception as e:
print(e)
@ -81,11 +85,12 @@ def webfingerHandle(session, handle: str, httpPrefix: str,
storeWebfingerInCache(nickname + '@' + wfDomain,
result, cachedWebfingers)
else:
print("WARN: Unable to webfinger " + url + ' ' +
'nickname: ' + str(nickname) + ' ' +
'domain: ' + str(wfDomain) + ' ' +
'headers: ' + str(hdr) + ' ' +
'params: ' + str(par))
if debug:
print("WARN: Unable to webfinger " + url + ' ' +
'nickname: ' + str(nickname) + ' ' +
'domain: ' + str(wfDomain) + ' ' +
'headers: ' + str(hdr) + ' ' +
'params: ' + str(par))
return result