forked from indymedia/epicyon
Handling of i2p secondary domains
parent
cb0ffaeb40
commit
7a22130837
|
@ -792,6 +792,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.domain,
|
||||
self.server.domainFull,
|
||||
self.server.onionDomain,
|
||||
self.server.i2pDomain,
|
||||
self.server.port,
|
||||
self.server.recentPostsCache,
|
||||
self.server.followersThreads,
|
||||
|
@ -7766,7 +7767,7 @@ def runDaemon(blogsInstance: bool, mediaInstance: bool,
|
|||
baseDir, httpPrefix, httpd.sendThreads,
|
||||
httpd.postLog, httpd.cachedWebfingers,
|
||||
httpd.personCache, httpd.inboxQueue,
|
||||
domain, onionDomain, port, useTor,
|
||||
domain, onionDomain, i2pDomain, port, useTor,
|
||||
httpd.federationList,
|
||||
httpd.ocapAlways, maxReplies,
|
||||
domainMaxPostsPerDay, accountMaxPostsPerDay,
|
||||
|
|
36
follow.py
36
follow.py
|
@ -464,11 +464,16 @@ def noOfFollowRequests(baseDir: str,
|
|||
ctr = 0
|
||||
with open(approveFollowsFilename, "r") as f:
|
||||
lines = f.readlines()
|
||||
if followType != "onion":
|
||||
if followType == "onion":
|
||||
for fileLine in lines:
|
||||
if '.onion' in fileLine:
|
||||
ctr += 1
|
||||
elif followType == "i2p":
|
||||
for fileLine in lines:
|
||||
if '.i2p' in fileLine:
|
||||
ctr += 1
|
||||
else:
|
||||
return len(lines)
|
||||
for fileLine in lines:
|
||||
if '.onion' in fileLine:
|
||||
ctr += 1
|
||||
return ctr
|
||||
|
||||
|
||||
|
@ -618,20 +623,27 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str,
|
|||
if followApprovalRequired(baseDir, nicknameToFollow,
|
||||
domainToFollow, debug, approveHandle):
|
||||
print('Follow approval is required')
|
||||
if not domain.endswith('.onion'):
|
||||
if noOfFollowRequests(baseDir,
|
||||
nicknameToFollow, domainToFollow,
|
||||
nickname, domain, fromPort,
|
||||
'') > 10:
|
||||
print('Too many follow requests')
|
||||
return False
|
||||
else:
|
||||
if domain.endswith('.onion'):
|
||||
if noOfFollowRequests(baseDir,
|
||||
nicknameToFollow, domainToFollow,
|
||||
nickname, domain, fromPort,
|
||||
'onion') > 5:
|
||||
print('Too many follow requests from onion addresses')
|
||||
return False
|
||||
elif domain.endswith('.i2p'):
|
||||
if noOfFollowRequests(baseDir,
|
||||
nicknameToFollow, domainToFollow,
|
||||
nickname, domain, fromPort,
|
||||
'i2p') > 5:
|
||||
print('Too many follow requests from i2p addresses')
|
||||
return False
|
||||
else:
|
||||
if noOfFollowRequests(baseDir,
|
||||
nicknameToFollow, domainToFollow,
|
||||
nickname, domain, fromPort,
|
||||
'') > 10:
|
||||
print('Too many follow requests')
|
||||
return False
|
||||
|
||||
print('Storing follow request for approval')
|
||||
return storeFollowRequest(baseDir,
|
||||
|
|
15
inbox.py
15
inbox.py
|
@ -1935,7 +1935,8 @@ def inboxAfterCapabilities(recentPostsCache: {}, maxRecentPosts: int,
|
|||
session, keyId: str, handle: str, messageJson: {},
|
||||
baseDir: str, httpPrefix: str, sendThreads: [],
|
||||
postLog: [], cachedWebfingers: {}, personCache: {},
|
||||
queue: [], domain: str, onionDomain: str,
|
||||
queue: [], domain: str,
|
||||
onionDomain: str, i2pDomain: str,
|
||||
port: int, useTor: bool,
|
||||
federationList: [], ocapAlways: bool, debug: bool,
|
||||
acceptedCaps: [],
|
||||
|
@ -2108,7 +2109,8 @@ def inboxAfterCapabilities(recentPostsCache: {}, maxRecentPosts: int,
|
|||
# send out an update
|
||||
questionJson['type'] = 'Update'
|
||||
sendToFollowersThread(session, baseDir,
|
||||
nickname, domain, onionDomain, port,
|
||||
nickname, domain,
|
||||
onionDomain, i2pDomain, port,
|
||||
httpPrefix, federationList,
|
||||
sendThreads, postLog,
|
||||
cachedWebfingers, personCache,
|
||||
|
@ -2285,7 +2287,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
|||
projectVersion: str,
|
||||
baseDir: str, httpPrefix: str, sendThreads: [], postLog: [],
|
||||
cachedWebfingers: {}, personCache: {}, queue: [],
|
||||
domain: str, onionDomain: str, port: int, useTor: bool,
|
||||
domain: str,
|
||||
onionDomain: str, i2pDomain: str, port: int, useTor: bool,
|
||||
federationList: [],
|
||||
ocapAlways: bool, maxReplies: int,
|
||||
domainMaxPostsPerDay: int, accountMaxPostsPerDay: int,
|
||||
|
@ -2698,7 +2701,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
|||
sendThreads, postLog,
|
||||
cachedWebfingers,
|
||||
personCache, queue,
|
||||
domain, onionDomain,
|
||||
domain,
|
||||
onionDomain, i2pDomain,
|
||||
port, useTor,
|
||||
federationList, ocapAlways,
|
||||
debug, acceptedCaps,
|
||||
|
@ -2720,7 +2724,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
|
|||
sendThreads, postLog,
|
||||
cachedWebfingers,
|
||||
personCache, queue,
|
||||
domain, onionDomain,
|
||||
domain,
|
||||
onionDomain, i2pDomain,
|
||||
port, useTor,
|
||||
federationList, ocapAlways,
|
||||
debug, acceptedCaps,
|
||||
|
|
|
@ -37,7 +37,8 @@ from shares import outboxUndoShareUpload
|
|||
|
||||
def postMessageToOutbox(messageJson: {}, postToNickname: str,
|
||||
server, baseDir: str, httpPrefix: str,
|
||||
domain: str, domainFull: str, onionDomain: str,
|
||||
domain: str, domainFull: str,
|
||||
onionDomain: str, i2pDomain: str,
|
||||
port: int,
|
||||
recentPostsCache: {}, followersThreads: [],
|
||||
federationList: [], sendThreads: [],
|
||||
|
@ -239,7 +240,7 @@ def postMessageToOutbox(messageJson: {}, postToNickname: str,
|
|||
sendToFollowersThread(server.session,
|
||||
baseDir,
|
||||
postToNickname,
|
||||
domain, onionDomain,
|
||||
domain, onionDomain, i2pDomain,
|
||||
port, httpPrefix,
|
||||
federationList,
|
||||
sendThreads,
|
||||
|
@ -335,7 +336,7 @@ def postMessageToOutbox(messageJson: {}, postToNickname: str,
|
|||
postToNickname + '@' + domain + ':' + str(port))
|
||||
sendToNamedAddresses(server.session, baseDir,
|
||||
postToNickname,
|
||||
domain, onionDomain, port,
|
||||
domain, onionDomain, i2pDomain, port,
|
||||
httpPrefix,
|
||||
federationList,
|
||||
sendThreads,
|
||||
|
|
22
posts.py
22
posts.py
|
@ -1630,6 +1630,8 @@ def sendSignedJson(postJsonObject: {}, session, baseDir: str,
|
|||
|
||||
if toDomain.endswith('.onion'):
|
||||
httpPrefix = 'http'
|
||||
elif toDomain.endswith('.i2p'):
|
||||
httpPrefix = 'i2p'
|
||||
|
||||
# sharedInbox = False
|
||||
if toNickname == 'inbox':
|
||||
|
@ -1809,7 +1811,8 @@ def addToField(activityType: str, postJsonObject: {},
|
|||
|
||||
def sendToNamedAddresses(session, baseDir: str,
|
||||
nickname: str,
|
||||
domain: str, onionDomain: str, port: int,
|
||||
domain: str,
|
||||
onionDomain: str, i2pDomain: str, port: int,
|
||||
httpPrefix: str, federationList: [],
|
||||
sendThreads: [], postLog: [],
|
||||
cachedWebfingers: {}, personCache: {},
|
||||
|
@ -1928,6 +1931,10 @@ def sendToNamedAddresses(session, baseDir: str,
|
|||
if toDomain.endswith('.onion'):
|
||||
fromDomain = onionDomain
|
||||
fromHttpPrefix = 'http'
|
||||
elif i2pDomain:
|
||||
if toDomain.endswith('.i2p'):
|
||||
fromDomain = i2pDomain
|
||||
fromHttpPrefix = 'i2p'
|
||||
cc = []
|
||||
sendSignedJson(postJsonObject, session, baseDir,
|
||||
nickname, fromDomain, port,
|
||||
|
@ -1952,7 +1959,8 @@ def hasSharedInbox(session, httpPrefix: str, domain: str) -> bool:
|
|||
|
||||
def sendToFollowers(session, baseDir: str,
|
||||
nickname: str,
|
||||
domain: str, onionDomain: str, port: int,
|
||||
domain: str,
|
||||
onionDomain: str, i2pDomain: str, port: int,
|
||||
httpPrefix: str, federationList: [],
|
||||
sendThreads: [], postLog: [],
|
||||
cachedWebfingers: {}, personCache: {},
|
||||
|
@ -2012,6 +2020,10 @@ def sendToFollowers(session, baseDir: str,
|
|||
if toDomain.endswith('.onion'):
|
||||
fromDomain = onionDomain
|
||||
fromHttpPrefix = 'http'
|
||||
elif i2pDomain:
|
||||
if toDomain.endswith('.i2p'):
|
||||
fromDomain = i2pDomain
|
||||
fromHttpPrefix = 'i2p'
|
||||
|
||||
if withSharedInbox:
|
||||
toNickname = followerHandles[index].split('@')[0]
|
||||
|
@ -2079,7 +2091,8 @@ def sendToFollowers(session, baseDir: str,
|
|||
|
||||
def sendToFollowersThread(session, baseDir: str,
|
||||
nickname: str,
|
||||
domain: str, onionDomain: str, port: int,
|
||||
domain: str,
|
||||
onionDomain: str, i2pDomain: str, port: int,
|
||||
httpPrefix: str, federationList: [],
|
||||
sendThreads: [], postLog: [],
|
||||
cachedWebfingers: {}, personCache: {},
|
||||
|
@ -2090,7 +2103,8 @@ def sendToFollowersThread(session, baseDir: str,
|
|||
sendThread = \
|
||||
threadWithTrace(target=sendToFollowers,
|
||||
args=(session, baseDir,
|
||||
nickname, domain, onionDomain, port,
|
||||
nickname, domain,
|
||||
onionDomain, i2pDomain, port,
|
||||
httpPrefix, federationList,
|
||||
sendThreads, postLog,
|
||||
cachedWebfingers, personCache,
|
||||
|
|
|
@ -91,6 +91,7 @@ def updatePostSchedule(baseDir: str, handle: str, httpd,
|
|||
httpd.domain,
|
||||
httpd.domainFull,
|
||||
httpd.onionDomain,
|
||||
httpd.i2pDomain,
|
||||
httpd.port,
|
||||
httpd.recentPostsCache,
|
||||
httpd.followersThreads,
|
||||
|
|
Loading…
Reference in New Issue