allow public holesail keys

This commit is contained in:
Raven Scott
2025-12-20 17:03:20 -05:00
parent a2cdd0497d
commit 14cd0d98dd
7 changed files with 45 additions and 7 deletions
@@ -5,6 +5,7 @@ const { logDebug, logInfo, logError, logWarn } = require('../../infrastructure/l
const { checkPortResponsive, parseMinutesToMs } = require('../../infrastructure/utils');
const { checkPortAvailability, freePort } = require('../../maintenance/cleanup');
const { trackHolesailEvent } = require('../../maintenance/metrics');
const { isSecureHolesailKey } = require('../../infrastructure/utils');
// Start Holesail client
async function startHolesailClient(domain, hash, ip, port, persistent = false) {
@@ -33,11 +34,16 @@ async function startHolesailClient(domain, hash, ip, port, persistent = false) {
}
logInfo('Holesail', `Successfully freed port ${port} on ${ip}`);
}
const secure = isSecureHolesailKey(hash);
logInfo('Holesail', `Creating Holesail client for ${domain} with secure=${secure} (key starts with: ${hash.substring(0, 10)}...)`);
const holesail = new Holesail({
client: true,
key: hash,
port: port,
host: ip,
secure: secure,
log: false
});
try {
@@ -8,6 +8,7 @@ const { logDebug, logError, logInfo, logWarn } = require('../../infrastructure/l
const { ensurePortFree } = require('./port-management');
const { startHolesailClient } = require('./admin-holesail');
const { broadcast } = require('./websocket');
const { isSecureHolesailKey } = require('../../infrastructure/utils');
const holesailClientsFile = process.env.HOLESAIL_CLIENTS_FILE || './cache/holesail_clients.json';
@@ -191,11 +192,15 @@ async function startForkedHolesailClient(id, opts) {
return;
}
const ip = state.domainToIPMap.get(opts.domain);
const secure = isSecureHolesailKey(opts.key);
logDebug('Holesail', `Creating forked Holesail client for ${opts.domain} with secure=${secure} (key starts with: ${opts.key.substring(0, 10)}...)`);
const childOpts = {
client: true,
key: opts.key,
port: opts.port,
host: ip,
secure: secure,
log: false,
protocol: opts.protocol || 'tcp'
};
+5
View File
@@ -7,6 +7,7 @@ const { createInterfaceForDomain } = require('../networking/virtual_interfaces')
const { ensurePortFree } = require('./port-management');
const { startHolesailClient } = require('./admin-holesail');
const { broadcast } = require('./websocket');
const { isSecureHolesailKey } = require('../infrastructure/utils');
const holesailClientsFile = process.env.HOLESAIL_CLIENTS_FILE || './cache/holesail_clients.json';
@@ -54,11 +55,15 @@ async function startForkedHolesailClient(id, opts) {
return;
}
const ip = state.domainToIPMap.get(opts.domain);
const secure = isSecureHolesailKey(opts.key);
logDebug('Holesail', `Creating forked Holesail client for ${opts.domain} with secure=${secure} (key starts with: ${opts.key.substring(0, 10)}...)`);
const childOpts = {
client: true,
key: opts.key,
port: opts.port,
host: ip,
secure: secure,
log: false,
protocol: opts.protocol || 'tcp'
};
+14 -1
View File
@@ -373,6 +373,18 @@ async function loadOrCreateKeypair() {
}
}
/**
* Detect if a Holesail key requires secure option
* @param {string} hash - Holesail key/hash
* @returns {boolean} - True if secure option should be enabled
*/
function isSecureHolesailKey(hash) {
if (!hash || typeof hash !== 'string') return false;
// hs://s000 = secure option should be true
// hs://0000 = secure option should be false
return hash.startsWith('hs://s000');
}
module.exports = {
checkPortResponsive,
checkPublicDNS,
@@ -383,5 +395,6 @@ module.exports = {
secondsToMs,
minutesToMs,
loadOrCreateKeypair,
getPersistentPublicKey
getPersistentPublicKey,
isSecureHolesailKey
};
+5
View File
@@ -10,6 +10,7 @@ const { checkPortAvailability, freePort } = require('../maintenance/cleanup');
const { trackHolesailEvent } = require('../maintenance/metrics');
const { retryWithBackoff } = require('../infrastructure/async_errors');
const { getCircuitBreaker } = require('../infrastructure/circuit_breaker');
const { isSecureHolesailKey } = require('../infrastructure/utils');
// Cleanup connection resources
async function cleanupConnection(key, domain, hash, ip, port, shouldRestart = false) {
@@ -104,11 +105,15 @@ async function startHolesailClient(domain, hash, ip, port, persistent = false) {
resetTimeout: secondsToMs(30) // 30 seconds
});
const secure = isSecureHolesailKey(hash);
logInfo('Holesail', `Creating Holesail client for ${domain} with secure=${secure} (key starts with: ${hash.substring(0, 10)}...)`);
const holesail = new Holesail({
client: true,
key: hash,
port: port,
host: ip,
secure: secure,
log: false
});
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "File Drop",
"version": "1.0.4",
"domain": "file.drop",
"enabled": false,
"enabled": true,
"description": "Temporary 24-hour file storage with shareable links",
"author": "P2NS",
"license": "MIT",
+5 -1
View File
@@ -13,7 +13,7 @@ const crypto = require('crypto');
const process = require('process');
const fs = require('fs');
const path = require('path');
const { parseMinutesToMs, parseSecondsToMs, secondsToMs, loadOrCreateKeypair, setupCache, getPersistentPublicKey } = require('../includes/infrastructure/utils');
const { parseMinutesToMs, parseSecondsToMs, secondsToMs, loadOrCreateKeypair, setupCache, getPersistentPublicKey, isSecureHolesailKey } = require('../includes/infrastructure/utils');
// ============================================================================
// Configuration
@@ -367,11 +367,15 @@ async function startHolesailClient(domain, hash, ip, persistent = false) {
try {
logInfo('Holesail', `Starting Holesail client for domain: ${domain}`, { domain, hash, ip, port });
const secure = isSecureHolesailKey(hash);
logInfo('Holesail', `Creating Holesail client for ${domain} with secure=${secure} (key starts with: ${hash.substring(0, 10)}...)`);
const holesail = new Holesail({
client: true,
key: hash,
port: port,
host: ip,
secure: secure,
log: false
});