mirror of https://gitlab.com/bashrc2/epicyon
Make the display of account and version info within nodeinfo metadata opt-in
parent
4cd6710ca9
commit
fc6e85b6ca
15
daemon.py
15
daemon.py
|
@ -971,9 +971,15 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
return False
|
return False
|
||||||
if self.server.debug:
|
if self.server.debug:
|
||||||
print('DEBUG: nodeinfo ' + self.path)
|
print('DEBUG: nodeinfo ' + self.path)
|
||||||
|
|
||||||
|
nodeInfoVersion = self.server.projectVersion
|
||||||
|
if not self.server.showNodeInfoVersion:
|
||||||
|
nodeInfoVersion = '0.0.0'
|
||||||
|
|
||||||
info = metaDataNodeInfo(self.server.baseDir,
|
info = metaDataNodeInfo(self.server.baseDir,
|
||||||
self.server.registration,
|
self.server.registration,
|
||||||
self.server.projectVersion)
|
nodeInfoVersion,
|
||||||
|
self.server.showNodeInfoAccounts)
|
||||||
if info:
|
if info:
|
||||||
msg = json.dumps(info).encode('utf-8')
|
msg = json.dumps(info).encode('utf-8')
|
||||||
msglen = len(msg)
|
msglen = len(msg)
|
||||||
|
@ -14743,7 +14749,9 @@ def loadTokens(baseDir: str, tokensDict: {}, tokensLookup: {}) -> None:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
def runDaemon(brochMode: bool,
|
def runDaemon(showNodeInfoAccounts: bool,
|
||||||
|
showNodeInfoVersion: bool,
|
||||||
|
brochMode: bool,
|
||||||
verifyAllSignatures: bool,
|
verifyAllSignatures: bool,
|
||||||
sendThreadsTimeoutMins: int,
|
sendThreadsTimeoutMins: int,
|
||||||
dormantMonths: int,
|
dormantMonths: int,
|
||||||
|
@ -14812,6 +14820,9 @@ def runDaemon(brochMode: bool,
|
||||||
print('serverAddress: ' + str(serverAddress))
|
print('serverAddress: ' + str(serverAddress))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
httpd.showNodeInfoAccounts = showNodeInfoAccounts
|
||||||
|
httpd.showNodeInfoVersion = showNodeInfoVersion
|
||||||
|
|
||||||
# ASCII/ANSI text banner used in shell browsers, such as Lynx
|
# ASCII/ANSI text banner used in shell browsers, such as Lynx
|
||||||
httpd.textModeBanner = getTextModeBanner(baseDir)
|
httpd.textModeBanner = getTextModeBanner(baseDir)
|
||||||
|
|
||||||
|
|
24
epicyon.py
24
epicyon.py
|
@ -322,6 +322,16 @@ parser.add_argument("--brochMode",
|
||||||
type=str2bool, nargs='?',
|
type=str2bool, nargs='?',
|
||||||
const=True, default=False,
|
const=True, default=False,
|
||||||
help="Enable broch mode")
|
help="Enable broch mode")
|
||||||
|
parser.add_argument("--nodeinfoaccounts",
|
||||||
|
dest='showNodeInfoAccounts',
|
||||||
|
type=str2bool, nargs='?',
|
||||||
|
const=True, default=False,
|
||||||
|
help="Show numbers of accounts within nodeinfo metadata")
|
||||||
|
parser.add_argument("--nodeinfoversion",
|
||||||
|
dest='showNodeInfoVersion',
|
||||||
|
type=str2bool, nargs='?',
|
||||||
|
const=True, default=False,
|
||||||
|
help="Show version number within nodeinfo metadata")
|
||||||
parser.add_argument("--noKeyPress",
|
parser.add_argument("--noKeyPress",
|
||||||
dest='noKeyPress',
|
dest='noKeyPress',
|
||||||
type=str2bool, nargs='?',
|
type=str2bool, nargs='?',
|
||||||
|
@ -2600,6 +2610,16 @@ brochMode = \
|
||||||
if brochMode is not None:
|
if brochMode is not None:
|
||||||
args.brochMode = bool(brochMode)
|
args.brochMode = bool(brochMode)
|
||||||
|
|
||||||
|
showNodeInfoAccounts = \
|
||||||
|
getConfigParam(baseDir, 'showNodeInfoAccounts')
|
||||||
|
if showNodeInfoAccounts is not None:
|
||||||
|
args.showNodeInfoAccounts = bool(showNodeInfoAccounts)
|
||||||
|
|
||||||
|
showNodeInfoVersion = \
|
||||||
|
getConfigParam(baseDir, 'showNodeInfoVersion')
|
||||||
|
if showNodeInfoVersion is not None:
|
||||||
|
args.showNodeInfoVersion = bool(showNodeInfoVersion)
|
||||||
|
|
||||||
YTDomain = getConfigParam(baseDir, 'youtubedomain')
|
YTDomain = getConfigParam(baseDir, 'youtubedomain')
|
||||||
if YTDomain:
|
if YTDomain:
|
||||||
if '://' in YTDomain:
|
if '://' in YTDomain:
|
||||||
|
@ -2614,7 +2634,9 @@ if setTheme(baseDir, themeName, domain,
|
||||||
print('Theme set to ' + themeName)
|
print('Theme set to ' + themeName)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
runDaemon(args.brochMode,
|
runDaemon(args.showNodeInfoAccounts,
|
||||||
|
args.showNodeInfoVersion,
|
||||||
|
args.brochMode,
|
||||||
args.verifyAllSignatures,
|
args.verifyAllSignatures,
|
||||||
args.sendThreadsTimeoutMins,
|
args.sendThreadsTimeoutMins,
|
||||||
args.dormantMonths,
|
args.dormantMonths,
|
||||||
|
|
23
metadata.py
23
metadata.py
|
@ -12,12 +12,27 @@ from utils import noOfAccounts
|
||||||
from utils import noOfActiveAccountsMonthly
|
from utils import noOfActiveAccountsMonthly
|
||||||
|
|
||||||
|
|
||||||
def metaDataNodeInfo(baseDir: str, registration: bool, version: str) -> {}:
|
def metaDataNodeInfo(baseDir: str, registration: bool, version: str,
|
||||||
|
showAccounts: bool) -> {}:
|
||||||
""" /nodeinfo/2.0 endpoint
|
""" /nodeinfo/2.0 endpoint
|
||||||
|
Also see https://socialhub.activitypub.rocks/t/
|
||||||
|
fep-f1d5-nodeinfo-in-fediverse-software/1190/4
|
||||||
|
|
||||||
|
Note that there are security considerations with this. If an adversary
|
||||||
|
sees a lot of accounts and "local" posts then the instance may be
|
||||||
|
considered a higher priority target.
|
||||||
|
Also exposure of the version number and number of accounts could be
|
||||||
|
sensitive
|
||||||
"""
|
"""
|
||||||
activeAccounts = noOfAccounts(baseDir)
|
if showAccounts:
|
||||||
activeAccountsMonthly = noOfActiveAccountsMonthly(baseDir, 1)
|
activeAccounts = noOfAccounts(baseDir)
|
||||||
activeAccountsHalfYear = noOfActiveAccountsMonthly(baseDir, 6)
|
activeAccountsMonthly = noOfActiveAccountsMonthly(baseDir, 1)
|
||||||
|
activeAccountsHalfYear = noOfActiveAccountsMonthly(baseDir, 6)
|
||||||
|
else:
|
||||||
|
activeAccounts = 1
|
||||||
|
activeAccountsMonthly = 1
|
||||||
|
activeAccountsHalfYear = 1
|
||||||
|
|
||||||
nodeinfo = {
|
nodeinfo = {
|
||||||
'openRegistrations': registration,
|
'openRegistrations': registration,
|
||||||
'protocols': ['activitypub'],
|
'protocols': ['activitypub'],
|
||||||
|
|
18
tests.py
18
tests.py
|
@ -504,8 +504,12 @@ def createServerAlice(path: str, domain: str, port: int,
|
||||||
maxFollowers = 10
|
maxFollowers = 10
|
||||||
verifyAllSignatures = True
|
verifyAllSignatures = True
|
||||||
brochMode = False
|
brochMode = False
|
||||||
|
showNodeInfoAccounts = True
|
||||||
|
showNodeInfoVersion = True
|
||||||
print('Server running: Alice')
|
print('Server running: Alice')
|
||||||
runDaemon(brochMode,
|
runDaemon(showNodeInfoAccounts,
|
||||||
|
showNodeInfoVersion,
|
||||||
|
brochMode,
|
||||||
verifyAllSignatures,
|
verifyAllSignatures,
|
||||||
sendThreadsTimeoutMins,
|
sendThreadsTimeoutMins,
|
||||||
dormantMonths, maxNewswirePosts,
|
dormantMonths, maxNewswirePosts,
|
||||||
|
@ -601,8 +605,12 @@ def createServerBob(path: str, domain: str, port: int,
|
||||||
maxFollowers = 10
|
maxFollowers = 10
|
||||||
verifyAllSignatures = True
|
verifyAllSignatures = True
|
||||||
brochMode = False
|
brochMode = False
|
||||||
|
showNodeInfoAccounts = True
|
||||||
|
showNodeInfoVersion = True
|
||||||
print('Server running: Bob')
|
print('Server running: Bob')
|
||||||
runDaemon(brochMode,
|
runDaemon(showNodeInfoAccounts,
|
||||||
|
showNodeInfoVersion,
|
||||||
|
brochMode,
|
||||||
verifyAllSignatures,
|
verifyAllSignatures,
|
||||||
sendThreadsTimeoutMins,
|
sendThreadsTimeoutMins,
|
||||||
dormantMonths, maxNewswirePosts,
|
dormantMonths, maxNewswirePosts,
|
||||||
|
@ -652,8 +660,12 @@ def createServerEve(path: str, domain: str, port: int, federationList: [],
|
||||||
maxFollowers = 10
|
maxFollowers = 10
|
||||||
verifyAllSignatures = True
|
verifyAllSignatures = True
|
||||||
brochMode = False
|
brochMode = False
|
||||||
|
showNodeInfoAccounts = True
|
||||||
|
showNodeInfoVersion = True
|
||||||
print('Server running: Eve')
|
print('Server running: Eve')
|
||||||
runDaemon(brochMode,
|
runDaemon(showNodeInfoAccounts,
|
||||||
|
showNodeInfoVersion,
|
||||||
|
brochMode,
|
||||||
verifyAllSignatures,
|
verifyAllSignatures,
|
||||||
sendThreadsTimeoutMins,
|
sendThreadsTimeoutMins,
|
||||||
dormantMonths, maxNewswirePosts,
|
dormantMonths, maxNewswirePosts,
|
||||||
|
|
Loading…
Reference in New Issue