mirror of https://gitlab.com/bashrc2/epicyon
Support hypercore protocol
parent
1fc769b217
commit
4608678cae
|
@ -138,6 +138,7 @@ def addWebLinks(content: str) -> str:
|
||||||
w.startswith('i2p://') or \
|
w.startswith('i2p://') or \
|
||||||
w.startswith('gemini://') or \
|
w.startswith('gemini://') or \
|
||||||
w.startswith('gopher://') or \
|
w.startswith('gopher://') or \
|
||||||
|
w.startswith('hyper://') or \
|
||||||
w.startswith('dat://'):
|
w.startswith('dat://'):
|
||||||
if w.endswith('.') or w.endswith(';'):
|
if w.endswith('.') or w.endswith(';'):
|
||||||
w = w[:-1]
|
w = w[:-1]
|
||||||
|
@ -151,12 +152,15 @@ def addWebLinks(content: str) -> str:
|
||||||
markup += '<span class="invisible">i2p://</span>'
|
markup += '<span class="invisible">i2p://</span>'
|
||||||
elif w.startswith('dat://'):
|
elif w.startswith('dat://'):
|
||||||
markup += '<span class="invisible">dat://</span>'
|
markup += '<span class="invisible">dat://</span>'
|
||||||
|
elif w.startswith('hyper://'):
|
||||||
|
markup += '<span class="invisible">hyper://</span>'
|
||||||
elif w.startswith('gemini://'):
|
elif w.startswith('gemini://'):
|
||||||
markup += '<span class="invisible">gemini://</span>'
|
markup += '<span class="invisible">gemini://</span>'
|
||||||
elif w.startswith('gopher://'):
|
elif w.startswith('gopher://'):
|
||||||
markup += '<span class="invisible">gopher://</span>'
|
markup += '<span class="invisible">gopher://</span>'
|
||||||
linkText = w.replace('https://', '').replace('http://', '')
|
linkText = w.replace('https://', '').replace('http://', '')
|
||||||
linkText = linkText.replace('dat://', '').replace('i2p://', '')
|
linkText = linkText.replace('dat://', '').replace('i2p://', '')
|
||||||
|
linkText = linkText.replace('hyper://', '')
|
||||||
linkText = linkText.replace('gemini://', '')
|
linkText = linkText.replace('gemini://', '')
|
||||||
linkText = linkText.replace('gopher://', '')
|
linkText = linkText.replace('gopher://', '')
|
||||||
# prevent links from becoming too long
|
# prevent links from becoming too long
|
||||||
|
@ -415,6 +419,10 @@ def removeLongWords(content: str, maxWordLength: int,
|
||||||
continue
|
continue
|
||||||
elif 'dat:' in wordStr:
|
elif 'dat:' in wordStr:
|
||||||
continue
|
continue
|
||||||
|
elif 'hyper:' in wordStr:
|
||||||
|
continue
|
||||||
|
elif 'briar:' in wordStr:
|
||||||
|
continue
|
||||||
if '<' in wordStr:
|
if '<' in wordStr:
|
||||||
replaceWord = wordStr.split('<', 1)[0]
|
replaceWord = wordStr.split('<', 1)[0]
|
||||||
content = content.replace(wordStr, replaceWord)
|
content = content.replace(wordStr, replaceWord)
|
||||||
|
@ -540,6 +548,7 @@ def getMentionsFromHtml(htmlText: str,
|
||||||
actorStr = mentionStr.split('"')[0]
|
actorStr = mentionStr.split('"')[0]
|
||||||
if actorStr.startswith('http') or \
|
if actorStr.startswith('http') or \
|
||||||
actorStr.startswith('i2p') or \
|
actorStr.startswith('i2p') or \
|
||||||
|
actorStr.startswith('hyper') or \
|
||||||
actorStr.startswith('dat:'):
|
actorStr.startswith('dat:'):
|
||||||
if actorStr not in mentions:
|
if actorStr not in mentions:
|
||||||
mentions.append(actorStr)
|
mentions.append(actorStr)
|
||||||
|
|
|
@ -171,6 +171,9 @@ parser.add_argument("--http", type=str2bool, nargs='?',
|
||||||
parser.add_argument("--dat", type=str2bool, nargs='?',
|
parser.add_argument("--dat", type=str2bool, nargs='?',
|
||||||
const=True, default=False,
|
const=True, default=False,
|
||||||
help="Use dat protocol only")
|
help="Use dat protocol only")
|
||||||
|
parser.add_argument("--hyper", type=str2bool, nargs='?',
|
||||||
|
const=True, default=False,
|
||||||
|
help="Use hypercore protocol only")
|
||||||
parser.add_argument("--i2p", type=str2bool, nargs='?',
|
parser.add_argument("--i2p", type=str2bool, nargs='?',
|
||||||
const=True, default=False,
|
const=True, default=False,
|
||||||
help="Use i2p protocol only")
|
help="Use i2p protocol only")
|
||||||
|
@ -977,6 +980,8 @@ if args.ocap:
|
||||||
ocapAlways = args.ocap
|
ocapAlways = args.ocap
|
||||||
if args.dat:
|
if args.dat:
|
||||||
httpPrefix = 'dat'
|
httpPrefix = 'dat'
|
||||||
|
if args.hyper:
|
||||||
|
httpPrefix = 'hyper'
|
||||||
if args.i2p:
|
if args.i2p:
|
||||||
httpPrefix = 'i2p'
|
httpPrefix = 'i2p'
|
||||||
|
|
||||||
|
@ -990,6 +995,7 @@ if args.actor:
|
||||||
args.actor = args.actor.replace('https://', '')
|
args.actor = args.actor.replace('https://', '')
|
||||||
args.actor = args.actor.replace('http://', '')
|
args.actor = args.actor.replace('http://', '')
|
||||||
args.actor = args.actor.replace('dat://', '')
|
args.actor = args.actor.replace('dat://', '')
|
||||||
|
args.actor = args.actor.replace('hyper://', '')
|
||||||
args.actor = args.actor.replace('i2p://', '')
|
args.actor = args.actor.replace('i2p://', '')
|
||||||
args.actor = args.actor.replace('/@', '/users/')
|
args.actor = args.actor.replace('/@', '/users/')
|
||||||
if '/users/' not in args.actor and \
|
if '/users/' not in args.actor and \
|
||||||
|
|
|
@ -461,8 +461,8 @@ def noOfFollowRequests(baseDir: str,
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
if followType != "onion":
|
if followType != "onion":
|
||||||
return len(lines)
|
return len(lines)
|
||||||
for l in lines:
|
for fileLine in lines:
|
||||||
if '.onion' in l:
|
if '.onion' in fileLine:
|
||||||
ctr += 1
|
ctr += 1
|
||||||
return ctr
|
return ctr
|
||||||
|
|
||||||
|
|
1
inbox.py
1
inbox.py
|
@ -1361,6 +1361,7 @@ def receiveAnnounce(recentPostsCache: {},
|
||||||
objectDomain = objectDomain.replace('http://', '')
|
objectDomain = objectDomain.replace('http://', '')
|
||||||
objectDomain = objectDomain.replace('i2p://', '')
|
objectDomain = objectDomain.replace('i2p://', '')
|
||||||
objectDomain = objectDomain.replace('dat://', '')
|
objectDomain = objectDomain.replace('dat://', '')
|
||||||
|
objectDomain = objectDomain.replace('hyper://', '')
|
||||||
if '/' in objectDomain:
|
if '/' in objectDomain:
|
||||||
objectDomain = objectDomain.split('/')[0]
|
objectDomain = objectDomain.split('/')[0]
|
||||||
if isBlockedDomain(baseDir, objectDomain):
|
if isBlockedDomain(baseDir, objectDomain):
|
||||||
|
|
15
utils.py
15
utils.py
|
@ -230,22 +230,23 @@ def getDomainFromActor(actor: str) -> (str, int):
|
||||||
if '/profile/' in actor:
|
if '/profile/' in actor:
|
||||||
domain = actor.split('/profile/')[0].replace('https://', '')
|
domain = actor.split('/profile/')[0].replace('https://', '')
|
||||||
domain = domain.replace('http://', '').replace('i2p://', '')
|
domain = domain.replace('http://', '').replace('i2p://', '')
|
||||||
domain = domain.replace('dat://', '')
|
domain = domain.replace('dat://', '').replace('hyper://', '')
|
||||||
else:
|
else:
|
||||||
if '/channel/' in actor:
|
if '/channel/' in actor:
|
||||||
domain = actor.split('/channel/')[0].replace('https://', '')
|
domain = actor.split('/channel/')[0].replace('https://', '')
|
||||||
domain = domain.replace('http://', '').replace('i2p://', '')
|
domain = domain.replace('http://', '').replace('i2p://', '')
|
||||||
domain = domain.replace('dat://', '')
|
domain = domain.replace('dat://', '').replace('hyper://', '')
|
||||||
else:
|
else:
|
||||||
if '/users/' not in actor:
|
if '/users/' not in actor:
|
||||||
domain = actor.replace('https://', '').replace('http://', '')
|
domain = actor.replace('https://', '').replace('http://', '')
|
||||||
domain = domain.replace('i2p://', '').replace('dat://', '')
|
domain = domain.replace('i2p://', '')
|
||||||
|
domain = domain.replace('dat://', '').replace('hyper://', '')
|
||||||
if '/' in actor:
|
if '/' in actor:
|
||||||
domain = domain.split('/')[0]
|
domain = domain.split('/')[0]
|
||||||
else:
|
else:
|
||||||
domain = actor.split('/users/')[0].replace('https://', '')
|
domain = actor.split('/users/')[0].replace('https://', '')
|
||||||
domain = domain.replace('http://', '').replace('i2p://', '')
|
domain = domain.replace('http://', '').replace('i2p://', '')
|
||||||
domain = domain.replace('dat://', '')
|
domain = domain.replace('dat://', '').replace('hyper://', '')
|
||||||
if ':' in domain:
|
if ':' in domain:
|
||||||
portStr = domain.split(':')[1]
|
portStr = domain.split(':')[1]
|
||||||
if not portStr.isdigit():
|
if not portStr.isdigit():
|
||||||
|
@ -481,10 +482,10 @@ def deletePost(baseDir: str, httpPrefix: str,
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
if lines:
|
if lines:
|
||||||
newlines = ''
|
newlines = ''
|
||||||
for l in lines:
|
for fileLine in lines:
|
||||||
if postId in l:
|
if postId in fileLine:
|
||||||
continue
|
continue
|
||||||
newlines += l
|
newlines += fileLine
|
||||||
if not newlines.strip():
|
if not newlines.strip():
|
||||||
# if there are no lines then remove the
|
# if there are no lines then remove the
|
||||||
# hashtag file
|
# hashtag file
|
||||||
|
|
|
@ -27,7 +27,8 @@ def parseHandle(handle: str) -> (str, str):
|
||||||
if '.' not in handle:
|
if '.' not in handle:
|
||||||
return None, None
|
return None, None
|
||||||
handleStr = handle.replace('https://', '').replace('http://', '')
|
handleStr = handle.replace('https://', '').replace('http://', '')
|
||||||
handleStr = handleStr.replace('dat://', '').replace('i2p://', '')
|
handleStr = handleStr.replace('dat://', '').replace('hyper://', '')
|
||||||
|
handleStr = handleStr.replace('i2p://', '')
|
||||||
if '/@' in handle:
|
if '/@' in handle:
|
||||||
domain, nickname = handleStr.split('/@')
|
domain, nickname = handleStr.split('/@')
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -92,6 +92,7 @@ def getBlogAddress(actorJson: {}) -> str:
|
||||||
if not (propertyValue['value'].startswith('https://') or
|
if not (propertyValue['value'].startswith('https://') or
|
||||||
propertyValue['value'].startswith('http://') or
|
propertyValue['value'].startswith('http://') or
|
||||||
propertyValue['value'].startswith('dat://') or
|
propertyValue['value'].startswith('dat://') or
|
||||||
|
propertyValue['value'].startswith('hyper://') or
|
||||||
propertyValue['value'].startswith('i2p://')):
|
propertyValue['value'].startswith('i2p://')):
|
||||||
continue
|
continue
|
||||||
if '.' not in propertyValue['value']:
|
if '.' not in propertyValue['value']:
|
||||||
|
@ -127,6 +128,7 @@ def setBlogAddress(actorJson: {}, blogAddress: str) -> None:
|
||||||
if not (blogAddress.startswith('https://') or
|
if not (blogAddress.startswith('https://') or
|
||||||
blogAddress.startswith('http://') or
|
blogAddress.startswith('http://') or
|
||||||
blogAddress.startswith('dat://') or
|
blogAddress.startswith('dat://') or
|
||||||
|
blogAddress.startswith('hyper://') or
|
||||||
blogAddress.startswith('i2p://')):
|
blogAddress.startswith('i2p://')):
|
||||||
return
|
return
|
||||||
if '.' not in blogAddress:
|
if '.' not in blogAddress:
|
||||||
|
@ -2764,7 +2766,8 @@ def addEmbeddedAudio(translate: {}, content: str) -> str:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not (w.startswith('http') or w.startswith('dat:') or
|
if not (w.startswith('http') or w.startswith('dat:') or
|
||||||
w.startswith('i2p:') or '/' in w):
|
w.startswith('hyper:') or w.startswith('i2p:') or
|
||||||
|
'/' in w):
|
||||||
continue
|
continue
|
||||||
url = w
|
url = w
|
||||||
content += '<center><audio controls>'
|
content += '<center><audio controls>'
|
||||||
|
@ -2809,7 +2812,8 @@ def addEmbeddedVideo(translate: {}, content: str,
|
||||||
if not w.endswith(extension):
|
if not w.endswith(extension):
|
||||||
continue
|
continue
|
||||||
if not (w.startswith('http') or w.startswith('dat:') or
|
if not (w.startswith('http') or w.startswith('dat:') or
|
||||||
w.startswith('i2p:') or '/' in w):
|
w.startswith('hyper:') or w.startswith('i2p:') or
|
||||||
|
'/' in w):
|
||||||
continue
|
continue
|
||||||
url = w
|
url = w
|
||||||
content += \
|
content += \
|
||||||
|
@ -3945,6 +3949,7 @@ def individualPostAsHtml(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
postJsonObject['object']['inReplyTo']
|
postJsonObject['object']['inReplyTo']
|
||||||
postDomain = postDomain.replace('https://', '')
|
postDomain = postDomain.replace('https://', '')
|
||||||
postDomain = postDomain.replace('http://', '')
|
postDomain = postDomain.replace('http://', '')
|
||||||
|
postDomain = postDomain.replace('hyper://', '')
|
||||||
postDomain = postDomain.replace('dat://', '')
|
postDomain = postDomain.replace('dat://', '')
|
||||||
postDomain = postDomain.replace('i2p://', '')
|
postDomain = postDomain.replace('i2p://', '')
|
||||||
if '/' in postDomain:
|
if '/' in postDomain:
|
||||||
|
@ -4099,7 +4104,7 @@ def individualPostAsHtml(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
postHtml = galleryStr
|
postHtml = galleryStr
|
||||||
|
|
||||||
if not showPublicOnly and storeToCache and \
|
if not showPublicOnly and storeToCache and \
|
||||||
boxName != 'tlmedia'and boxName != 'tlbookmarks':
|
boxName != 'tlmedia' and boxName != 'tlbookmarks':
|
||||||
saveIndividualPostAsHtmlToCache(baseDir, nickname, domain,
|
saveIndividualPostAsHtmlToCache(baseDir, nickname, domain,
|
||||||
postJsonObject, postHtml)
|
postJsonObject, postHtml)
|
||||||
updateRecentPostsCache(recentPostsCache, maxRecentPosts,
|
updateRecentPostsCache(recentPostsCache, maxRecentPosts,
|
||||||
|
|
Loading…
Reference in New Issue