create daemon

This commit is contained in:
Your Name
2025-09-29 07:21:46 -04:00
parent 955090b079
commit 69514943a9
1341 changed files with 181418 additions and 0 deletions

View File

@@ -49,6 +49,7 @@
<div><strong>Info Status:</strong> <span id="thrower-info-status">Loading...</span></div>
<div><strong>Last Updated:</strong> <span id="thrower-info-updated">Never</span></div>
<div><strong>Refresh Rate:</strong> <span id="thrower-info-refresh">300 seconds</span></div>
<div><strong>Maximum Delay:</strong> <span id="thrower-max-delay">86460 seconds</span></div>
</div>
</div>
@@ -153,6 +154,10 @@
<label for="edit-refresh-rate">Refresh Rate (seconds):</label>
<input type="number" id="edit-refresh-rate" placeholder="300" value="300" min="10" max="3600">
</div>
<div class="input-group">
<label for="edit-max-delay">Maximum Delay (seconds):</label>
<input type="number" id="edit-max-delay" placeholder="86460" value="86460" min="1" max="86460">
</div>
<div class="input-group">
<label for="edit-thrower-content">Additional Content (optional):</label>
<textarea id="edit-thrower-content" rows="2"
@@ -1128,6 +1133,7 @@
privacyPolicy: '',
termsOfService: '',
refreshRate: 300,
maxDelay: 86460,
content: event.content || ''
};
@@ -1145,6 +1151,7 @@
else if (tag[0] === 'privacy_policy') currentThrowerInfo.privacyPolicy = tag[1] || '';
else if (tag[0] === 'terms_of_service') currentThrowerInfo.termsOfService = tag[1] || '';
else if (tag[0] === 'refresh_rate') currentThrowerInfo.refreshRate = parseInt(tag[1]) || 300;
else if (tag[0] === 'max_delay') currentThrowerInfo.maxDelay = parseInt(tag[1]) || 86460;
});
lastThrowerInfoPublish = event.created_at;
@@ -1164,6 +1171,7 @@
privacyPolicy: '',
termsOfService: '',
refreshRate: 300,
maxDelay: 86460,
content: ''
};
displayThrowerInfo(currentThrowerInfo);
@@ -1179,6 +1187,7 @@
function displayThrowerInfo(info) {
document.getElementById('thrower-info-status').textContent = 'Loaded';
document.getElementById('thrower-info-refresh').textContent = `${info.refreshRate} seconds`;
document.getElementById('thrower-max-delay').textContent = `${info.maxDelay} seconds`;
if (lastThrowerInfoPublish) {
const lastUpdate = new Date(lastThrowerInfoPublish * 1000);
@@ -1209,6 +1218,7 @@
document.getElementById('edit-privacy-policy').value = currentThrowerInfo.privacyPolicy || '';
document.getElementById('edit-terms-service').value = currentThrowerInfo.termsOfService || '';
document.getElementById('edit-refresh-rate').value = currentThrowerInfo.refreshRate || 300;
document.getElementById('edit-max-delay').value = currentThrowerInfo.maxDelay || 86460;
document.getElementById('edit-thrower-content').value = currentThrowerInfo.content || '';
}
@@ -1233,6 +1243,7 @@
const privacyPolicy = document.getElementById('edit-privacy-policy').value.trim();
const termsOfService = document.getElementById('edit-terms-service').value.trim();
const refreshRate = parseInt(document.getElementById('edit-refresh-rate').value) || 300;
const maxDelay = parseInt(document.getElementById('edit-max-delay').value) || 86460;
const content = document.getElementById('edit-thrower-content').value.trim();
try {
@@ -1251,6 +1262,7 @@
if (privacyPolicy) tags.push(['privacy_policy', privacyPolicy]);
if (termsOfService) tags.push(['terms_of_service', termsOfService]);
tags.push(['refresh_rate', refreshRate.toString()]);
tags.push(['max_delay', maxDelay.toString()]);
const eventTemplate = {
kind: 12222,
@@ -1319,6 +1331,7 @@
privacyPolicy,
termsOfService,
refreshRate,
maxDelay,
content
};
@@ -1401,6 +1414,7 @@
if (currentThrowerInfo.privacyPolicy) tags.push(['privacy_policy', currentThrowerInfo.privacyPolicy]);
if (currentThrowerInfo.termsOfService) tags.push(['terms_of_service', currentThrowerInfo.termsOfService]);
tags.push(['refresh_rate', currentThrowerInfo.refreshRate.toString()]);
tags.push(['max_delay', currentThrowerInfo.maxDelay.toString()]);
const eventTemplate = {
kind: 12222,
@@ -1838,6 +1852,14 @@
if (!Array.isArray(routing.relays) || routing.relays.length === 0) return false;
if (typeof routing.delay !== 'number' || routing.delay < 0) return false;
if (!routing.audit || typeof routing.audit !== 'string') return false;
// Check maximum delay constraint
const maxDelay = currentThrowerInfo.maxDelay || 86460;
if (routing.delay > maxDelay) {
addLogEntry('error', `Routing delay ${routing.delay}s exceeds maximum allowed delay ${maxDelay}s - rejecting event`);
return false;
}
return true;
}