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