allow public holesail keys
This commit is contained in:
@@ -5,6 +5,7 @@ const { logDebug, logInfo, logError, logWarn } = require('../../infrastructure/l
|
|||||||
const { checkPortResponsive, parseMinutesToMs } = require('../../infrastructure/utils');
|
const { checkPortResponsive, parseMinutesToMs } = require('../../infrastructure/utils');
|
||||||
const { checkPortAvailability, freePort } = require('../../maintenance/cleanup');
|
const { checkPortAvailability, freePort } = require('../../maintenance/cleanup');
|
||||||
const { trackHolesailEvent } = require('../../maintenance/metrics');
|
const { trackHolesailEvent } = require('../../maintenance/metrics');
|
||||||
|
const { isSecureHolesailKey } = require('../../infrastructure/utils');
|
||||||
|
|
||||||
// Start Holesail client
|
// Start Holesail client
|
||||||
async function startHolesailClient(domain, hash, ip, port, persistent = false) {
|
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}`);
|
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({
|
const holesail = new Holesail({
|
||||||
client: true,
|
client: true,
|
||||||
key: hash,
|
key: hash,
|
||||||
port: port,
|
port: port,
|
||||||
host: ip,
|
host: ip,
|
||||||
|
secure: secure,
|
||||||
log: false
|
log: false
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ const { logDebug, logError, logInfo, logWarn } = require('../../infrastructure/l
|
|||||||
const { ensurePortFree } = require('./port-management');
|
const { ensurePortFree } = require('./port-management');
|
||||||
const { startHolesailClient } = require('./admin-holesail');
|
const { startHolesailClient } = require('./admin-holesail');
|
||||||
const { broadcast } = require('./websocket');
|
const { broadcast } = require('./websocket');
|
||||||
|
const { isSecureHolesailKey } = require('../../infrastructure/utils');
|
||||||
|
|
||||||
const holesailClientsFile = process.env.HOLESAIL_CLIENTS_FILE || './cache/holesail_clients.json';
|
const holesailClientsFile = process.env.HOLESAIL_CLIENTS_FILE || './cache/holesail_clients.json';
|
||||||
|
|
||||||
@@ -191,11 +192,15 @@ async function startForkedHolesailClient(id, opts) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const ip = state.domainToIPMap.get(opts.domain);
|
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 = {
|
const childOpts = {
|
||||||
client: true,
|
client: true,
|
||||||
key: opts.key,
|
key: opts.key,
|
||||||
port: opts.port,
|
port: opts.port,
|
||||||
host: ip,
|
host: ip,
|
||||||
|
secure: secure,
|
||||||
log: false,
|
log: false,
|
||||||
protocol: opts.protocol || 'tcp'
|
protocol: opts.protocol || 'tcp'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ const { createInterfaceForDomain } = require('../networking/virtual_interfaces')
|
|||||||
const { ensurePortFree } = require('./port-management');
|
const { ensurePortFree } = require('./port-management');
|
||||||
const { startHolesailClient } = require('./admin-holesail');
|
const { startHolesailClient } = require('./admin-holesail');
|
||||||
const { broadcast } = require('./websocket');
|
const { broadcast } = require('./websocket');
|
||||||
|
const { isSecureHolesailKey } = require('../infrastructure/utils');
|
||||||
|
|
||||||
const holesailClientsFile = process.env.HOLESAIL_CLIENTS_FILE || './cache/holesail_clients.json';
|
const holesailClientsFile = process.env.HOLESAIL_CLIENTS_FILE || './cache/holesail_clients.json';
|
||||||
|
|
||||||
@@ -54,11 +55,15 @@ async function startForkedHolesailClient(id, opts) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const ip = state.domainToIPMap.get(opts.domain);
|
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 = {
|
const childOpts = {
|
||||||
client: true,
|
client: true,
|
||||||
key: opts.key,
|
key: opts.key,
|
||||||
port: opts.port,
|
port: opts.port,
|
||||||
host: ip,
|
host: ip,
|
||||||
|
secure: secure,
|
||||||
log: false,
|
log: false,
|
||||||
protocol: opts.protocol || 'tcp'
|
protocol: opts.protocol || 'tcp'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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 = {
|
module.exports = {
|
||||||
checkPortResponsive,
|
checkPortResponsive,
|
||||||
checkPublicDNS,
|
checkPublicDNS,
|
||||||
@@ -383,5 +395,6 @@ module.exports = {
|
|||||||
secondsToMs,
|
secondsToMs,
|
||||||
minutesToMs,
|
minutesToMs,
|
||||||
loadOrCreateKeypair,
|
loadOrCreateKeypair,
|
||||||
getPersistentPublicKey
|
getPersistentPublicKey,
|
||||||
|
isSecureHolesailKey
|
||||||
};
|
};
|
||||||
@@ -10,6 +10,7 @@ const { checkPortAvailability, freePort } = require('../maintenance/cleanup');
|
|||||||
const { trackHolesailEvent } = require('../maintenance/metrics');
|
const { trackHolesailEvent } = require('../maintenance/metrics');
|
||||||
const { retryWithBackoff } = require('../infrastructure/async_errors');
|
const { retryWithBackoff } = require('../infrastructure/async_errors');
|
||||||
const { getCircuitBreaker } = require('../infrastructure/circuit_breaker');
|
const { getCircuitBreaker } = require('../infrastructure/circuit_breaker');
|
||||||
|
const { isSecureHolesailKey } = require('../infrastructure/utils');
|
||||||
|
|
||||||
// Cleanup connection resources
|
// Cleanup connection resources
|
||||||
async function cleanupConnection(key, domain, hash, ip, port, shouldRestart = false) {
|
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
|
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({
|
const holesail = new Holesail({
|
||||||
client: true,
|
client: true,
|
||||||
key: hash,
|
key: hash,
|
||||||
port: port,
|
port: port,
|
||||||
host: ip,
|
host: ip,
|
||||||
|
secure: secure,
|
||||||
log: false
|
log: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "File Drop",
|
"name": "File Drop",
|
||||||
"version": "1.0.4",
|
"version": "1.0.4",
|
||||||
"domain": "file.drop",
|
"domain": "file.drop",
|
||||||
"enabled": false,
|
"enabled": true,
|
||||||
"description": "Temporary 24-hour file storage with shareable links",
|
"description": "Temporary 24-hour file storage with shareable links",
|
||||||
"author": "P2NS",
|
"author": "P2NS",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const crypto = require('crypto');
|
|||||||
const process = require('process');
|
const process = require('process');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
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
|
// Configuration
|
||||||
@@ -367,11 +367,15 @@ async function startHolesailClient(domain, hash, ip, persistent = false) {
|
|||||||
try {
|
try {
|
||||||
logInfo('Holesail', `Starting Holesail client for domain: ${domain}`, { domain, hash, ip, port });
|
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({
|
const holesail = new Holesail({
|
||||||
client: true,
|
client: true,
|
||||||
key: hash,
|
key: hash,
|
||||||
port: port,
|
port: port,
|
||||||
host: ip,
|
host: ip,
|
||||||
|
secure: secure,
|
||||||
log: false
|
log: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user