forked from indymedia/epicyon
Support for gnunet
parent
35438c0fc8
commit
bee0d99ce6
|
@ -137,6 +137,7 @@ def addWebLinks(content: str) -> str:
|
|||
if w.startswith('https://') or \
|
||||
w.startswith('http://') or \
|
||||
w.startswith('i2p://') or \
|
||||
w.startswith('gnunet://') or \
|
||||
w.startswith('gemini://') or \
|
||||
w.startswith('gopher://') or \
|
||||
w.startswith('hyper://') or \
|
||||
|
@ -151,6 +152,8 @@ def addWebLinks(content: str) -> str:
|
|||
markup += '<span class="invisible">http://</span>'
|
||||
elif w.startswith('i2p://'):
|
||||
markup += '<span class="invisible">i2p://</span>'
|
||||
elif w.startswith('gnunet://'):
|
||||
markup += '<span class="invisible">gnunet://</span>'
|
||||
elif w.startswith('dat://'):
|
||||
markup += '<span class="invisible">dat://</span>'
|
||||
elif w.startswith('hyper://'):
|
||||
|
@ -161,6 +164,7 @@ def addWebLinks(content: str) -> str:
|
|||
markup += '<span class="invisible">gopher://</span>'
|
||||
linkText = w.replace('https://', '').replace('http://', '')
|
||||
linkText = linkText.replace('dat://', '').replace('i2p://', '')
|
||||
linkText = linkText.replace('gnunet://', '')
|
||||
linkText = linkText.replace('hyper://', '')
|
||||
linkText = linkText.replace('gemini://', '')
|
||||
linkText = linkText.replace('gopher://', '')
|
||||
|
@ -421,6 +425,8 @@ def removeLongWords(content: str, maxWordLength: int,
|
|||
continue
|
||||
elif 'i2p:' in wordStr:
|
||||
continue
|
||||
elif 'gnunet:' in wordStr:
|
||||
continue
|
||||
elif 'dat:' in wordStr:
|
||||
continue
|
||||
elif 'hyper:' in wordStr:
|
||||
|
@ -552,6 +558,7 @@ def getMentionsFromHtml(htmlText: str,
|
|||
continue
|
||||
actorStr = mentionStr.split('"')[0]
|
||||
if actorStr.startswith('http') or \
|
||||
actorStr.startswith('gnunet') or \
|
||||
actorStr.startswith('i2p') or \
|
||||
actorStr.startswith('hyper') or \
|
||||
actorStr.startswith('dat:'):
|
||||
|
|
12
epicyon.py
12
epicyon.py
|
@ -172,6 +172,9 @@ parser.add_argument("--instanceOnlySkillsSearch", type=str2bool, nargs='?',
|
|||
parser.add_argument("--http", type=str2bool, nargs='?',
|
||||
const=True, default=False,
|
||||
help="Use http only")
|
||||
parser.add_argument("--gnunet", type=str2bool, nargs='?',
|
||||
const=True, default=False,
|
||||
help="Use gnunet protocol only")
|
||||
parser.add_argument("--dat", type=str2bool, nargs='?',
|
||||
const=True, default=False,
|
||||
help="Use dat protocol only")
|
||||
|
@ -391,6 +394,8 @@ if args.posts:
|
|||
proxyType = 'tor'
|
||||
elif args.i2p or domain.endswith('.i2p'):
|
||||
proxyType = 'i2p'
|
||||
elif args.gnunet:
|
||||
proxyType = 'gnunet'
|
||||
getPublicPostsOfPerson(baseDir, nickname, domain, False, True,
|
||||
proxyType, args.port, httpPrefix, debug,
|
||||
__version__)
|
||||
|
@ -409,6 +414,8 @@ if args.postsraw:
|
|||
proxyType = 'tor'
|
||||
elif args.i2p or domain.endswith('.i2p'):
|
||||
proxyType = 'i2p'
|
||||
elif args.gnunet:
|
||||
proxyType = 'gnunet'
|
||||
getPublicPostsOfPerson(baseDir, nickname, domain, False, False,
|
||||
proxyType, args.port, httpPrefix, debug,
|
||||
__version__)
|
||||
|
@ -603,6 +610,8 @@ if args.tor or domain.endswith('.onion'):
|
|||
proxyType = 'tor'
|
||||
elif args.i2p or domain.endswith('.i2p'):
|
||||
proxyType = 'i2p'
|
||||
elif args.gnunet:
|
||||
proxyType = 'gnunet'
|
||||
|
||||
if args.approve:
|
||||
if not args.nickname:
|
||||
|
@ -1012,6 +1021,8 @@ if args.proxyPort:
|
|||
ocapAlways = False
|
||||
if args.ocap:
|
||||
ocapAlways = args.ocap
|
||||
if args.gnunet:
|
||||
httpPrefix = 'gnunet'
|
||||
if args.dat:
|
||||
httpPrefix = 'dat'
|
||||
if args.hyper:
|
||||
|
@ -1028,6 +1039,7 @@ if args.actor:
|
|||
# format: https://domain/@nick
|
||||
args.actor = args.actor.replace('https://', '')
|
||||
args.actor = args.actor.replace('http://', '')
|
||||
args.actor = args.actor.replace('gnunet://', '')
|
||||
args.actor = args.actor.replace('dat://', '')
|
||||
args.actor = args.actor.replace('hyper://', '')
|
||||
args.actor = args.actor.replace('i2p://', '')
|
||||
|
|
1
inbox.py
1
inbox.py
|
@ -1364,6 +1364,7 @@ def receiveAnnounce(recentPostsCache: {},
|
|||
messageJson['object'].replace('https://', '')
|
||||
objectDomain = objectDomain.replace('http://', '')
|
||||
objectDomain = objectDomain.replace('i2p://', '')
|
||||
objectDomain = objectDomain.replace('gnunet://', '')
|
||||
objectDomain = objectDomain.replace('dat://', '')
|
||||
objectDomain = objectDomain.replace('hyper://', '')
|
||||
if '/' in objectDomain:
|
||||
|
|
|
@ -31,6 +31,10 @@ def createSession(proxyType: str):
|
|||
session.proxies = {}
|
||||
session.proxies['http'] = 'socks5h://localhost:4447'
|
||||
session.proxies['https'] = 'socks5h://localhost:4447'
|
||||
elif proxyType == 'gnunet':
|
||||
session.proxies = {}
|
||||
session.proxies['http'] = 'socks5h://localhost:7777'
|
||||
session.proxies['https'] = 'socks5h://localhost:7777'
|
||||
return session
|
||||
|
||||
|
||||
|
@ -59,7 +63,7 @@ def getJson(session, url: str, headers: {}, params: {},
|
|||
except Exception as e:
|
||||
print('ERROR: getJson failed\nurl: ' + str(url) + '\n' +
|
||||
'headers: ' + str(sessionHeaders) + '\n' +
|
||||
'params: ' + str(sessionParams))
|
||||
'params: ' + str(sessionParams) + '\n')
|
||||
print(e)
|
||||
return None
|
||||
|
||||
|
|
4
utils.py
4
utils.py
|
@ -232,22 +232,26 @@ def getDomainFromActor(actor: str) -> (str, int):
|
|||
domain = actor.split('/profile/')[0].replace('https://', '')
|
||||
domain = domain.replace('http://', '').replace('i2p://', '')
|
||||
domain = domain.replace('dat://', '').replace('hyper://', '')
|
||||
domain = domain.replace('gnunet://', '')
|
||||
else:
|
||||
if '/channel/' in actor:
|
||||
domain = actor.split('/channel/')[0].replace('https://', '')
|
||||
domain = domain.replace('http://', '').replace('i2p://', '')
|
||||
domain = domain.replace('dat://', '').replace('hyper://', '')
|
||||
domain = domain.replace('gnunet://', '')
|
||||
else:
|
||||
if '/users/' not in actor:
|
||||
domain = actor.replace('https://', '').replace('http://', '')
|
||||
domain = domain.replace('i2p://', '')
|
||||
domain = domain.replace('dat://', '').replace('hyper://', '')
|
||||
domain = domain.replace('gnunet://', '')
|
||||
if '/' in actor:
|
||||
domain = domain.split('/')[0]
|
||||
else:
|
||||
domain = actor.split('/users/')[0].replace('https://', '')
|
||||
domain = domain.replace('http://', '').replace('i2p://', '')
|
||||
domain = domain.replace('dat://', '').replace('hyper://', '')
|
||||
domain = domain.replace('gnunet://', '')
|
||||
if ':' in domain:
|
||||
portStr = domain.split(':')[1]
|
||||
if not portStr.isdigit():
|
||||
|
|
|
@ -29,6 +29,7 @@ def parseHandle(handle: str) -> (str, str):
|
|||
handleStr = handle.replace('https://', '').replace('http://', '')
|
||||
handleStr = handleStr.replace('dat://', '').replace('hyper://', '')
|
||||
handleStr = handleStr.replace('i2p://', '')
|
||||
handleStr = handleStr.replace('gnunet://', '')
|
||||
if '/@' in handle:
|
||||
domain, nickname = handleStr.split('/@')
|
||||
else:
|
||||
|
|
|
@ -102,6 +102,7 @@ def getBlogAddress(actorJson: {}) -> str:
|
|||
propertyValue['value'] = propertyValue['value'].strip()
|
||||
if not (propertyValue['value'].startswith('https://') or
|
||||
propertyValue['value'].startswith('http://') or
|
||||
propertyValue['value'].startswith('gnunet://') or
|
||||
propertyValue['value'].startswith('dat://') or
|
||||
propertyValue['value'].startswith('hyper://') or
|
||||
propertyValue['value'].startswith('i2p://')):
|
||||
|
@ -138,6 +139,7 @@ def setBlogAddress(actorJson: {}, blogAddress: str) -> None:
|
|||
|
||||
if not (blogAddress.startswith('https://') or
|
||||
blogAddress.startswith('http://') or
|
||||
blogAddress.startswith('gnunet://') or
|
||||
blogAddress.startswith('dat://') or
|
||||
blogAddress.startswith('hyper://') or
|
||||
blogAddress.startswith('i2p://')):
|
||||
|
@ -2800,6 +2802,7 @@ def addEmbeddedAudio(translate: {}, content: str) -> str:
|
|||
|
||||
if not (w.startswith('http') or w.startswith('dat:') or
|
||||
w.startswith('hyper:') or w.startswith('i2p:') or
|
||||
w.startswith('gnunet:') or
|
||||
'/' in w):
|
||||
continue
|
||||
url = w
|
||||
|
@ -2846,6 +2849,7 @@ def addEmbeddedVideo(translate: {}, content: str,
|
|||
continue
|
||||
if not (w.startswith('http') or w.startswith('dat:') or
|
||||
w.startswith('hyper:') or w.startswith('i2p:') or
|
||||
w.startswith('gnunet:') or
|
||||
'/' in w):
|
||||
continue
|
||||
url = w
|
||||
|
@ -3992,6 +3996,7 @@ def individualPostAsHtml(recentPostsCache: {}, maxRecentPosts: int,
|
|||
postDomain = postDomain.replace('https://', '')
|
||||
postDomain = postDomain.replace('http://', '')
|
||||
postDomain = postDomain.replace('hyper://', '')
|
||||
postDomain = postDomain.replace('gnunet://', '')
|
||||
postDomain = postDomain.replace('dat://', '')
|
||||
postDomain = postDomain.replace('i2p://', '')
|
||||
if '/' in postDomain:
|
||||
|
|
Loading…
Reference in New Issue