forked from indymedia/epicyon
Include port in webfinger
parent
b3375c175e
commit
8411b44721
|
@ -390,7 +390,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# get an individual post from the path /@nickname/statusnumber
|
# get an individual post from the path /@nickname/statusnumber
|
||||||
if '/@' in self.path:
|
if '/@' in self.path:
|
||||||
namedStatus=self.path.split('/@')[1]
|
namedStatus=self.path.split('/@')[1]
|
||||||
if '/' in namedStatus:
|
if '/' not in namedStatus:
|
||||||
|
# show actor
|
||||||
|
nickname=namedStatus
|
||||||
|
else:
|
||||||
postSections=namedStatus.split('/')
|
postSections=namedStatus.split('/')
|
||||||
if len(postSections)==2:
|
if len(postSections)==2:
|
||||||
nickname=postSections[0]
|
nickname=postSections[0]
|
||||||
|
|
12
epicyon.py
12
epicyon.py
|
@ -243,13 +243,17 @@ if args.testsnetwork:
|
||||||
testClientToServer()
|
testClientToServer()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
httpPrefix='https'
|
||||||
|
if args.http:
|
||||||
|
httpPrefix='http'
|
||||||
|
|
||||||
if args.posts:
|
if args.posts:
|
||||||
if '@' not in args.posts:
|
if '@' not in args.posts:
|
||||||
print('Syntax: --posts nickname@domain')
|
print('Syntax: --posts nickname@domain')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
nickname=args.posts.split('@')[0]
|
nickname=args.posts.split('@')[0]
|
||||||
domain=args.posts.split('@')[1]
|
domain=args.posts.split('@')[1]
|
||||||
getPublicPostsOfPerson(nickname,domain,False,True)
|
getPublicPostsOfPerson(nickname,domain,False,True,args.tor,args.port,httpPrefix)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
if args.postsraw:
|
if args.postsraw:
|
||||||
|
@ -258,7 +262,7 @@ if args.postsraw:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
nickname=args.postsraw.split('@')[0]
|
nickname=args.postsraw.split('@')[0]
|
||||||
domain=args.postsraw.split('@')[1]
|
domain=args.postsraw.split('@')[1]
|
||||||
getPublicPostsOfPerson(nickname,domain,True,False)
|
getPublicPostsOfPerson(nickname,domain,False,False,args.tor,args.port,httpPrefix)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
baseDir=args.baseDir
|
baseDir=args.baseDir
|
||||||
|
@ -284,10 +288,6 @@ nickname=None
|
||||||
if args.nickname:
|
if args.nickname:
|
||||||
nickname=nickname
|
nickname=nickname
|
||||||
|
|
||||||
httpPrefix='https'
|
|
||||||
if args.http:
|
|
||||||
httpPrefix='http'
|
|
||||||
|
|
||||||
federationList=[]
|
federationList=[]
|
||||||
if args.federationList:
|
if args.federationList:
|
||||||
if len(args.federationList)==1:
|
if len(args.federationList)==1:
|
||||||
|
|
15
posts.py
15
posts.py
|
@ -1262,23 +1262,27 @@ def archivePostsForPerson(httpPrefix: str,nickname: str,domain: str,baseDir: str
|
||||||
break
|
break
|
||||||
|
|
||||||
def getPublicPostsOfPerson(nickname: str,domain: str, \
|
def getPublicPostsOfPerson(nickname: str,domain: str, \
|
||||||
raw: bool,simple: bool) -> None:
|
raw: bool,simple: bool,useTor: bool, \
|
||||||
|
port: int,httpPrefix: str) -> None:
|
||||||
""" This is really just for test purposes
|
""" This is really just for test purposes
|
||||||
"""
|
"""
|
||||||
useTor=True
|
print("Test1")
|
||||||
port=443
|
|
||||||
session = createSession(domain,port,useTor)
|
session = createSession(domain,port,useTor)
|
||||||
personCache={}
|
personCache={}
|
||||||
cachedWebfingers={}
|
cachedWebfingers={}
|
||||||
federationList=[]
|
federationList=[]
|
||||||
|
|
||||||
httpPrefix='https'
|
domainFull=domain
|
||||||
handle=httpPrefix+"://"+domain+"/@"+nickname
|
if port!=80 and port!=443:
|
||||||
|
domainFull=domain+':'+str(port)
|
||||||
|
handle=httpPrefix+"://"+domainFull+"/@"+nickname
|
||||||
|
print("Test2 "+handle)
|
||||||
wfRequest = \
|
wfRequest = \
|
||||||
webfingerHandle(session,handle,httpPrefix,cachedWebfingers)
|
webfingerHandle(session,handle,httpPrefix,cachedWebfingers)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
print('Test3')
|
||||||
personUrl,pubKeyId,pubKey,personId,shaedInbox,capabilityAcquisition= \
|
personUrl,pubKeyId,pubKey,personId,shaedInbox,capabilityAcquisition= \
|
||||||
getPersonBox(session,wfRequest,personCache,'outbox')
|
getPersonBox(session,wfRequest,personCache,'outbox')
|
||||||
wfResult = json.dumps(wfRequest, indent=4, sort_keys=True)
|
wfResult = json.dumps(wfRequest, indent=4, sort_keys=True)
|
||||||
|
@ -1286,6 +1290,7 @@ def getPublicPostsOfPerson(nickname: str,domain: str, \
|
||||||
maxMentions=10
|
maxMentions=10
|
||||||
maxEmoji=10
|
maxEmoji=10
|
||||||
maxAttachments=5
|
maxAttachments=5
|
||||||
|
print('personUrl: '+personUrl)
|
||||||
userPosts = getPosts(session,personUrl,30,maxMentions,maxEmoji, \
|
userPosts = getPosts(session,personUrl,30,maxMentions,maxEmoji, \
|
||||||
maxAttachments,federationList, \
|
maxAttachments,federationList, \
|
||||||
personCache,raw,simple)
|
personCache,raw,simple)
|
||||||
|
|
|
@ -39,7 +39,10 @@ def getJson(session,url: str,headers: {},params: {}) -> {}:
|
||||||
result=session.get(url, headers=sessionHeaders, params=sessionParams)
|
result=session.get(url, headers=sessionHeaders, params=sessionParams)
|
||||||
return result.json()
|
return result.json()
|
||||||
except:
|
except:
|
||||||
pass
|
print('ERROR: getJson failed')
|
||||||
|
print('url: '+url)
|
||||||
|
print('headers: '+str(sessionHeaders))
|
||||||
|
print('params: '+str(sessionParams))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def postJson(session,postJsonObject: {},federationList: [],inboxUrl: str,headers: {},capability: str) -> str:
|
def postJson(session,postJsonObject: {},federationList: [],inboxUrl: str,headers: {},capability: str) -> str:
|
||||||
|
|
11
webfinger.py
11
webfinger.py
|
@ -35,13 +35,13 @@ def parseHandle(handle: str) -> (str,str):
|
||||||
|
|
||||||
return nickname, domain
|
return nickname, domain
|
||||||
|
|
||||||
|
|
||||||
def webfingerHandle(session,handle: str,httpPrefix: str,cachedWebfingers: {}) -> {}:
|
def webfingerHandle(session,handle: str,httpPrefix: str,cachedWebfingers: {}) -> {}:
|
||||||
if not session:
|
if not session:
|
||||||
print('WARN: No session specified for webfingerHandle')
|
print('WARN: No session specified for webfingerHandle')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
nickname, domain = parseHandle(handle)
|
nickname, domain = parseHandle(handle)
|
||||||
|
print('wfTest2 '+nickname+' '+domain)
|
||||||
if not nickname:
|
if not nickname:
|
||||||
return None
|
return None
|
||||||
wfDomain=domain
|
wfDomain=domain
|
||||||
|
@ -53,14 +53,13 @@ def webfingerHandle(session,handle: str,httpPrefix: str,cachedWebfingers: {}) ->
|
||||||
url = '{}://{}/.well-known/webfinger'.format(httpPrefix,domain)
|
url = '{}://{}/.well-known/webfinger'.format(httpPrefix,domain)
|
||||||
par = {'resource': 'acct:{}'.format(nickname+'@'+wfDomain)}
|
par = {'resource': 'acct:{}'.format(nickname+'@'+wfDomain)}
|
||||||
hdr = {'Accept': 'application/jrd+json'}
|
hdr = {'Accept': 'application/jrd+json'}
|
||||||
#print('webfinger url: '+url)
|
|
||||||
#print('webfinger par: '+str(par))
|
|
||||||
#print('webfinger hdr: '+str(hdr))
|
|
||||||
try:
|
try:
|
||||||
result = getJson(session, url, hdr, par)
|
result = getJson(session, url, hdr, par)
|
||||||
except:
|
except:
|
||||||
|
print("Unable to webfinger " + url)
|
||||||
|
print('headers: '+str(hdr))
|
||||||
|
print('params: '+str(par))
|
||||||
return None
|
return None
|
||||||
# print("Unable to webfinger " + url + ' ' + str(hdr) + ' ' + str(par))
|
|
||||||
storeWebfingerInCache(nickname+'@'+wfDomain,result,cachedWebfingers)
|
storeWebfingerInCache(nickname+'@'+wfDomain,result,cachedWebfingers)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue