Merge branch 'main' of ssh://code.freedombone.net:2222/bashrc/epicyon

main
Bob Mottram 2021-01-05 13:37:09 +00:00
commit bd8085137d
20 changed files with 113 additions and 36 deletions

View File

@ -4274,11 +4274,25 @@ class PubServer(BaseHTTPRequestHandler):
actorJson['summary'] = '' actorJson['summary'] = ''
actorChanged = True actorChanged = True
# change moderators list adminNickname = \
if fields.get('moderators'): getConfigParam(baseDir, 'admin')
adminNickname = \
getConfigParam(baseDir, 'admin') if adminNickname:
if adminNickname: # whether to require jsonld signatures
# on all incoming posts
if path.startswith('/users/' +
adminNickname + '/'):
verifyAllSignatures = False
if fields.get('verifyallsignatures'):
if fields['verifyallsignatures'] == 'on':
verifyAllSignatures = True
self.server.verifyAllSignatures = \
verifyAllSignatures
setConfigParam(baseDir, "verifyAllSignatures",
verifyAllSignatures)
# change moderators list
if fields.get('moderators'):
if path.startswith('/users/' + if path.startswith('/users/' +
adminNickname + '/'): adminNickname + '/'):
moderatorsFile = \ moderatorsFile = \
@ -4334,11 +4348,8 @@ class PubServer(BaseHTTPRequestHandler):
'instance', 'instance',
'moderator') 'moderator')
# change site editors list # change site editors list
if fields.get('editors'): if fields.get('editors'):
adminNickname = \
getConfigParam(baseDir, 'admin')
if adminNickname:
if path.startswith('/users/' + if path.startswith('/users/' +
adminNickname + '/'): adminNickname + '/'):
editorsFile = \ editorsFile = \
@ -13400,7 +13411,8 @@ def loadTokens(baseDir: str, tokensDict: {}, tokensLookup: {}) -> None:
break break
def runDaemon(sendThreadsTimeoutMins: int, def runDaemon(verifyAllSignatures: bool,
sendThreadsTimeoutMins: int,
dormantMonths: int, dormantMonths: int,
maxNewswirePosts: int, maxNewswirePosts: int,
allowLocalNetworkAccess: bool, allowLocalNetworkAccess: bool,
@ -13480,6 +13492,9 @@ def runDaemon(sendThreadsTimeoutMins: int,
# maximum number of posts to appear in the newswire on the right column # maximum number of posts to appear in the newswire on the right column
httpd.maxNewswirePosts = maxNewswirePosts httpd.maxNewswirePosts = maxNewswirePosts
# whether to require that all incoming posts have valid jsonld signatures
httpd.verifyAllSignatures = verifyAllSignatures
# This counter is used to update the list of blocked domains in memory. # This counter is used to update the list of blocked domains in memory.
# It helps to avoid touching the disk and so improves flooding resistance # It helps to avoid touching the disk and so improves flooding resistance
httpd.blocklistUpdateCtr = 0 httpd.blocklistUpdateCtr = 0
@ -13749,7 +13764,8 @@ def runDaemon(sendThreadsTimeoutMins: int,
httpd.showPublishedDateOnly, httpd.showPublishedDateOnly,
httpd.maxFollowers, httpd.maxFollowers,
httpd.allowLocalNetworkAccess, httpd.allowLocalNetworkAccess,
httpd.peertubeInstances), daemon=True) httpd.peertubeInstances,
verifyAllSignatures), daemon=True)
print('Creating scheduled post thread') print('Creating scheduled post thread')
httpd.thrPostSchedule = \ httpd.thrPostSchedule = \

View File

@ -267,6 +267,12 @@ parser.add_argument("--allowLocalNetworkAccess",
help="Whether to allow access to local network " + help="Whether to allow access to local network " +
"addresses. This might be useful when deploying in " + "addresses. This might be useful when deploying in " +
"a mesh network") "a mesh network")
parser.add_argument("--verifyAllSignatures",
dest='verifyAllSignatures',
type=str2bool, nargs='?',
const=True, default=False,
help="Whether to require that all incoming " +
"posts have valid jsonld signatures")
parser.add_argument("--noapproval", type=str2bool, nargs='?', parser.add_argument("--noapproval", type=str2bool, nargs='?',
const=True, default=False, const=True, default=False,
help="Allow followers without approval") help="Allow followers without approval")
@ -2119,6 +2125,11 @@ allowLocalNetworkAccess = \
if allowLocalNetworkAccess is not None: if allowLocalNetworkAccess is not None:
args.allowLocalNetworkAccess = bool(allowLocalNetworkAccess) args.allowLocalNetworkAccess = bool(allowLocalNetworkAccess)
verifyAllSignatures = \
getConfigParam(baseDir, 'verifyAllSignatures')
if verifyAllSignatures is not None:
args.verifyAllSignatures = bool(verifyAllSignatures)
YTDomain = getConfigParam(baseDir, 'youtubedomain') YTDomain = getConfigParam(baseDir, 'youtubedomain')
if YTDomain: if YTDomain:
if '://' in YTDomain: if '://' in YTDomain:
@ -2132,7 +2143,8 @@ if setTheme(baseDir, themeName, domain, args.allowLocalNetworkAccess):
print('Theme set to ' + themeName) print('Theme set to ' + themeName)
if __name__ == "__main__": if __name__ == "__main__":
runDaemon(args.sendThreadsTimeoutMins, runDaemon(args.verifyAllSignatures,
args.sendThreadsTimeoutMins,
args.dormantMonths, args.dormantMonths,
args.maxNewswirePosts, args.maxNewswirePosts,
args.allowLocalNetworkAccess, args.allowLocalNetworkAccess,

View File

@ -11,6 +11,7 @@ import os
import datetime import datetime
import time import time
from linked_data_sig import verifyJsonSignature from linked_data_sig import verifyJsonSignature
from utils import getConfigParam
from utils import hasUsersPath from utils import hasUsersPath
from utils import validPostDate from utils import validPostDate
from utils import getFullDomain from utils import getFullDomain
@ -2447,7 +2448,8 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
YTReplacementDomain: str, YTReplacementDomain: str,
showPublishedDateOnly: bool, showPublishedDateOnly: bool,
maxFollowers: int, allowLocalNetworkAccess: bool, maxFollowers: int, allowLocalNetworkAccess: bool,
peertubeInstances: []) -> None: peertubeInstances: [],
verifyAllSignatures: bool) -> None:
"""Processes received items and moves them to the appropriate """Processes received items and moves them to the appropriate
directories directories
""" """
@ -2535,19 +2537,24 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
continue continue
# clear the daily quotas for maximum numbers of received posts # clear the daily quotas for maximum numbers of received posts
if currTime-quotasLastUpdateDaily > 60 * 60 * 24: if currTime - quotasLastUpdateDaily > 60 * 60 * 24:
quotasDaily = { quotasDaily = {
'domains': {}, 'domains': {},
'accounts': {} 'accounts': {}
} }
quotasLastUpdateDaily = currTime quotasLastUpdateDaily = currTime
# clear the per minute quotas for maximum numbers of received posts if currTime - quotasLastUpdatePerMin > 60:
if currTime-quotasLastUpdatePerMin > 60: # clear the per minute quotas for maximum numbers of received posts
quotasPerMin = { quotasPerMin = {
'domains': {}, 'domains': {},
'accounts': {} 'accounts': {}
} }
# also check if the json signature enforcement has changed
verifyAllSigs = getConfigParam(baseDir, "verifyAllSignatures")
if verifyAllSigs is not None:
verifyAllSignatures = verifyAllSigs
# change the last time that this was done
quotasLastUpdatePerMin = currTime quotasLastUpdatePerMin = currTime
# limit the number of posts which can arrive per domain per day # limit the number of posts which can arrive per domain per day
@ -2716,7 +2723,18 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int,
if jwebsig.get('type') and jwebsig.get('signatureValue'): if jwebsig.get('type') and jwebsig.get('signatureValue'):
if jwebsig['type'] == 'RsaSignature2017': if jwebsig['type'] == 'RsaSignature2017':
checkJsonSignature = True checkJsonSignature = True
if checkJsonSignature:
# strict enforcement of json signatures
if verifyAllSignatures and \
not checkJsonSignature:
print('inbox post does not have a jsonld signature ' + keyId)
if os.path.isfile(queueFilename):
os.remove(queueFilename)
if len(queue) > 0:
queue.pop(0)
continue
if checkJsonSignature and verifyAllSignatures:
# use the original json message received, not one which may have # use the original json message received, not one which may have
# been modified along the way # been modified along the way
if not verifyJsonSignature(queueJson['original'], pubKey): if not verifyJsonSignature(queueJson['original'], pubKey):

View File

@ -323,8 +323,10 @@ def createServerAlice(path: str, domain: str, port: int,
dormantMonths = 3 dormantMonths = 3
sendThreadsTimeoutMins = 30 sendThreadsTimeoutMins = 30
maxFollowers = 10 maxFollowers = 10
verifyAllSignatures = True
print('Server running: Alice') print('Server running: Alice')
runDaemon(sendThreadsTimeoutMins, runDaemon(verifyAllSignatures,
sendThreadsTimeoutMins,
dormantMonths, maxNewswirePosts, dormantMonths, maxNewswirePosts,
allowLocalNetworkAccess, allowLocalNetworkAccess,
2048, False, True, False, False, True, maxFollowers, 2048, False, True, False, False, True, maxFollowers,
@ -420,8 +422,10 @@ def createServerBob(path: str, domain: str, port: int,
dormantMonths = 3 dormantMonths = 3
sendThreadsTimeoutMins = 30 sendThreadsTimeoutMins = 30
maxFollowers = 10 maxFollowers = 10
verifyAllSignatures = True
print('Server running: Bob') print('Server running: Bob')
runDaemon(sendThreadsTimeoutMins, runDaemon(verifyAllSignatures,
sendThreadsTimeoutMins,
dormantMonths, maxNewswirePosts, dormantMonths, maxNewswirePosts,
allowLocalNetworkAccess, allowLocalNetworkAccess,
2048, False, True, False, False, True, maxFollowers, 2048, False, True, False, False, True, maxFollowers,
@ -467,8 +471,10 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
dormantMonths = 3 dormantMonths = 3
sendThreadsTimeoutMins = 30 sendThreadsTimeoutMins = 30
maxFollowers = 10 maxFollowers = 10
verifyAllSignatures = True
print('Server running: Eve') print('Server running: Eve')
runDaemon(sendThreadsTimeoutMins, runDaemon(verifyAllSignatures,
sendThreadsTimeoutMins,
dormantMonths, maxNewswirePosts, dormantMonths, maxNewswirePosts,
allowLocalNetworkAccess, allowLocalNetworkAccess,
2048, False, True, False, False, True, maxFollowers, 2048, False, True, False, False, True, maxFollowers,

View File

@ -350,5 +350,6 @@
"Show Accounts": "إظهار الحسابات", "Show Accounts": "إظهار الحسابات",
"Peertube Instances": "مثيلات Peertube", "Peertube Instances": "مثيلات Peertube",
"Show video previews for the following Peertube sites.": "إظهار معاينات الفيديو لمواقع Peertube التالية.", "Show video previews for the following Peertube sites.": "إظهار معاينات الفيديو لمواقع Peertube التالية.",
"Follows you": "يتبعك" "Follows you": "يتبعك",
"Verify all signatures": "تحقق من جميع التوقيعات"
} }

View File

@ -350,5 +350,6 @@
"Show Accounts": "Mostra comptes", "Show Accounts": "Mostra comptes",
"Peertube Instances": "Instàncies de Peertube", "Peertube Instances": "Instàncies de Peertube",
"Show video previews for the following Peertube sites.": "Mostra les previsualitzacions de vídeo dels següents llocs de Peertube.", "Show video previews for the following Peertube sites.": "Mostra les previsualitzacions de vídeo dels següents llocs de Peertube.",
"Follows you": "Et segueix" "Follows you": "Et segueix",
"Verify all signatures": "Verifiqueu totes les signatures"
} }

View File

@ -350,5 +350,6 @@
"Show Accounts": "Dangos Cyfrifon", "Show Accounts": "Dangos Cyfrifon",
"Peertube Instances": "Camau Peertube", "Peertube Instances": "Camau Peertube",
"Show video previews for the following Peertube sites.": "Dangos rhagolygon fideo ar gyfer y safleoedd Peertube canlynol.", "Show video previews for the following Peertube sites.": "Dangos rhagolygon fideo ar gyfer y safleoedd Peertube canlynol.",
"Follows you": "Yn eich dilyn chi" "Follows you": "Yn eich dilyn chi",
"Verify all signatures": "Gwirio pob llofnod"
} }

View File

@ -350,5 +350,6 @@
"Show Accounts": "Konten anzeigen", "Show Accounts": "Konten anzeigen",
"Peertube Instances": "Peertube-Instanzen", "Peertube Instances": "Peertube-Instanzen",
"Show video previews for the following Peertube sites.": "Zeigen Sie eine Videovorschau für die folgenden Peertube-Websites an.", "Show video previews for the following Peertube sites.": "Zeigen Sie eine Videovorschau für die folgenden Peertube-Websites an.",
"Follows you": "Folgt dir" "Follows you": "Folgt dir",
"Verify all signatures": "Überprüfen Sie alle Signaturen"
} }

View File

@ -350,5 +350,6 @@
"Show Accounts": "Show Accounts", "Show Accounts": "Show Accounts",
"Peertube Instances": "Peertube Instances", "Peertube Instances": "Peertube Instances",
"Show video previews for the following Peertube sites.": "Show video previews for the following Peertube sites.", "Show video previews for the following Peertube sites.": "Show video previews for the following Peertube sites.",
"Follows you": "Follows you" "Follows you": "Follows you",
"Verify all signatures": "Verify all signatures"
} }

View File

@ -350,5 +350,6 @@
"Show Accounts": "Mostrar cuentas", "Show Accounts": "Mostrar cuentas",
"Peertube Instances": "Instancias de Peertube", "Peertube Instances": "Instancias de Peertube",
"Show video previews for the following Peertube sites.": "Muestre vistas previas de video para los siguientes sitios de Peertube.", "Show video previews for the following Peertube sites.": "Muestre vistas previas de video para los siguientes sitios de Peertube.",
"Follows you": "Te sigue" "Follows you": "Te sigue",
"Verify all signatures": "Verificar todas las firmas"
} }

View File

@ -350,5 +350,6 @@
"Show Accounts": "Afficher les comptes", "Show Accounts": "Afficher les comptes",
"Peertube Instances": "Instances Peertube", "Peertube Instances": "Instances Peertube",
"Show video previews for the following Peertube sites.": "Afficher des aperçus vidéo pour les sites Peertube suivants.", "Show video previews for the following Peertube sites.": "Afficher des aperçus vidéo pour les sites Peertube suivants.",
"Follows you": "Vous suit" "Follows you": "Vous suit",
"Verify all signatures": "Vérifier toutes les signatures"
} }

View File

@ -350,5 +350,6 @@
"Show Accounts": "Taispeáin Cuntais", "Show Accounts": "Taispeáin Cuntais",
"Peertube Instances": "Imeachtaí Peertube", "Peertube Instances": "Imeachtaí Peertube",
"Show video previews for the following Peertube sites.": "Taispeáin réamhamharcanna físe do na suíomhanna Peertube seo a leanas.", "Show video previews for the following Peertube sites.": "Taispeáin réamhamharcanna físe do na suíomhanna Peertube seo a leanas.",
"Follows you": "Leanann tú" "Follows you": "Leanann tú",
"Verify all signatures": "Fíoraigh gach síniú"
} }

View File

@ -350,5 +350,6 @@
"Show Accounts": "खाते दिखाएं", "Show Accounts": "खाते दिखाएं",
"Peertube Instances": "Peertube उदाहरण", "Peertube Instances": "Peertube उदाहरण",
"Show video previews for the following Peertube sites.": "निम्नलिखित Peertube साइटों के लिए वीडियो पूर्वावलोकन दिखाएं।", "Show video previews for the following Peertube sites.": "निम्नलिखित Peertube साइटों के लिए वीडियो पूर्वावलोकन दिखाएं।",
"Follows you": "आपका पीछा करता है" "Follows you": "आपका पीछा करता है",
"Verify all signatures": "सभी हस्ताक्षर सत्यापित करें"
} }

View File

@ -350,5 +350,6 @@
"Show Accounts": "Mostra account", "Show Accounts": "Mostra account",
"Peertube Instances": "Istanze di Peertube", "Peertube Instances": "Istanze di Peertube",
"Show video previews for the following Peertube sites.": "Mostra le anteprime dei video per i seguenti siti Peertube.", "Show video previews for the following Peertube sites.": "Mostra le anteprime dei video per i seguenti siti Peertube.",
"Follows you": "Ti segue" "Follows you": "Ti segue",
"Verify all signatures": "Verifica tutte le firme"
} }

View File

@ -350,5 +350,6 @@
"Show Accounts": "アカウントを表示する", "Show Accounts": "アカウントを表示する",
"Peertube Instances": "Peertubeインスタンス", "Peertube Instances": "Peertubeインスタンス",
"Show video previews for the following Peertube sites.": "次のPeertubeサイトのビデオプレビューを表示します。", "Show video previews for the following Peertube sites.": "次のPeertubeサイトのビデオプレビューを表示します。",
"Follows you": "あなたについていきます" "Follows you": "あなたについていきます",
"Verify all signatures": "すべての署名を確認する"
} }

View File

@ -346,5 +346,6 @@
"Show Accounts": "Show Accounts", "Show Accounts": "Show Accounts",
"Peertube Instances": "Peertube Instances", "Peertube Instances": "Peertube Instances",
"Show video previews for the following Peertube sites.": "Show video previews for the following Peertube sites.", "Show video previews for the following Peertube sites.": "Show video previews for the following Peertube sites.",
"Follows you": "Follows you" "Follows you": "Follows you",
"Verify all signatures": "Verify all signatures"
} }

View File

@ -350,5 +350,6 @@
"Show Accounts": "Mostrar contas", "Show Accounts": "Mostrar contas",
"Peertube Instances": "Instâncias Peertube", "Peertube Instances": "Instâncias Peertube",
"Show video previews for the following Peertube sites.": "Mostrar visualizações de vídeo para os seguintes sites Peertube.", "Show video previews for the following Peertube sites.": "Mostrar visualizações de vídeo para os seguintes sites Peertube.",
"Follows you": "Segue você" "Follows you": "Segue você",
"Verify all signatures": "Verifique todas as assinaturas"
} }

View File

@ -350,5 +350,6 @@
"Show Accounts": "Показать счета", "Show Accounts": "Показать счета",
"Peertube Instances": "Экземпляры Peertube", "Peertube Instances": "Экземпляры Peertube",
"Show video previews for the following Peertube sites.": "Показать превью видео для следующих сайтов Peertube.", "Show video previews for the following Peertube sites.": "Показать превью видео для следующих сайтов Peertube.",
"Follows you": "Следует за вами" "Follows you": "Следует за вами",
"Verify all signatures": "Проверить все подписи"
} }

View File

@ -350,5 +350,6 @@
"Show Accounts": "显示帐户", "Show Accounts": "显示帐户",
"Peertube Instances": "Peertube实例", "Peertube Instances": "Peertube实例",
"Show video previews for the following Peertube sites.": "显示以下Peertube网站的视频预览。", "Show video previews for the following Peertube sites.": "显示以下Peertube网站的视频预览。",
"Follows you": "跟着你" "Follows you": "跟着你",
"Verify all signatures": "验证所有签名"
} }

View File

@ -1106,6 +1106,16 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
instanceStr += \ instanceStr += \
' <input type="file" id="instanceLogo" name="instanceLogo"' ' <input type="file" id="instanceLogo" name="instanceLogo"'
instanceStr += ' accept="' + imageFormats + '">' instanceStr += ' accept="' + imageFormats + '">'
if getConfigParam(baseDir, "verifyAllSignatures"):
instanceStr += \
' <input type="checkbox" class="profilecheckbox" ' + \
'name="verifyallsignatures" checked> ' + \
translate['Verify all signatures'] + '<br>\n'
else:
instanceStr += \
' <input type="checkbox" class="profilecheckbox" ' + \
'name="verifyallsignatures"> ' + \
translate['Verify all signatures'] + '<br>\n'
instanceStr += '</div>' instanceStr += '</div>'
moderators = '' moderators = ''