update dxcluster sources

pull/27/head
accius 2 months ago
parent 4e8134e44d
commit 9dab93ca06

@ -2596,16 +2596,18 @@
> >
<option value="auto">Auto (Best Available)</option> <option value="auto">Auto (Best Available)</option>
<option value="hamqth">HamQTH</option> <option value="hamqth">HamQTH</option>
<option value="iu1bow">IU1BOW DX Spider</option>
<option value="spothole">Spothole</option>
<option value="dxheat">DXHeat</option> <option value="dxheat">DXHeat</option>
<option value="dxsummit">DX Summit</option> <option value="dxsummit">DX Summit</option>
<option value="dxspider">DX Spider (G6NHU)</option>
</select> </select>
<p style={{ fontSize: '12px', color: 'var(--text-muted)', marginTop: '8px' }}> <p style={{ fontSize: '12px', color: 'var(--text-muted)', marginTop: '8px' }}>
{dxClusterSource === 'auto' && '→ Automatically selects the best available source'} {dxClusterSource === 'auto' && '→ Automatically selects the best available source'}
{dxClusterSource === 'hamqth' && '→ HamQTH.com DX Cluster feed'} {dxClusterSource === 'hamqth' && '→ HamQTH.com DX Cluster CSV feed'}
{dxClusterSource === 'iu1bow' && '→ IU1BOW.it Spiderweb cluster (HTTP API)'}
{dxClusterSource === 'spothole' && '→ Spothole.app aggregated DX cluster'}
{dxClusterSource === 'dxheat' && '→ DXHeat.com real-time cluster'} {dxClusterSource === 'dxheat' && '→ DXHeat.com real-time cluster'}
{dxClusterSource === 'dxsummit' && '→ DXSummit.fi cluster (may be slow)'} {dxClusterSource === 'dxsummit' && '→ DXSummit.fi cluster (may be slow)'}
{dxClusterSource === 'dxspider' && '→ G6NHU-2 DX Spider node (dxspider.co.uk)'}
</p> </p>
</div> </div>

@ -15,7 +15,6 @@ const express = require('express');
const cors = require('cors'); const cors = require('cors');
const path = require('path'); const path = require('path');
const fetch = require('node-fetch'); const fetch = require('node-fetch');
const net = require('net');
const app = express(); const app = express();
const PORT = process.env.PORT || 3000; const PORT = process.env.PORT || 3000;
@ -117,11 +116,10 @@ app.get('/api/hamqsl/conditions', async (req, res) => {
}); });
// DX Cluster proxy - fetches from selectable sources // DX Cluster proxy - fetches from selectable sources
// Query param: ?source=hamqth|dxheat|dxsummit|dxspider|auto (default: auto) // Query param: ?source=hamqth|dxheat|dxsummit|jo30|auto (default: auto)
// Cache for DX Spider telnet spots (to avoid too many connections) // Note: DX Spider (telnet) removed - doesn't work on hosted platforms
let dxSpiderCache = { spots: [], timestamp: 0 }; // Using HTTP-based APIs only for online compatibility
const DXSPIDER_CACHE_TTL = 60000; // 60 seconds cache
app.get('/api/dxcluster/spots', async (req, res) => { app.get('/api/dxcluster/spots', async (req, res) => {
const source = (req.query.source || 'auto').toLowerCase(); const source = (req.query.source || 'auto').toLowerCase();
@ -274,117 +272,111 @@ app.get('/api/dxcluster/spots', async (req, res) => {
return null; return null;
} }
// Helper function for DX Spider (G6NHU-2) via telnet // Helper function for IU1BOW Spiderweb (HTTP-based DX Spider web interface)
async function fetchDXSpider() { async function fetchIU1BOW() {
// Check cache first const controller = new AbortController();
if (Date.now() - dxSpiderCache.timestamp < DXSPIDER_CACHE_TTL && dxSpiderCache.spots.length > 0) { const timeout = setTimeout(() => controller.abort(), 8000);
console.log('[DX Cluster] DX Spider: returning', dxSpiderCache.spots.length, 'cached spots');
return dxSpiderCache.spots;
}
return new Promise((resolve) => {
const spots = [];
let buffer = '';
let gotSpots = false;
let loginSent = false;
let commandSent = false;
const client = new net.Socket();
client.setTimeout(12000);
client.connect(7300, 'dxspider.co.uk', () => { try {
console.log('[DX Cluster] DX Spider: connected'); const response = await fetch('https://www.iu1bow.it/spotlist', {
headers: {
'User-Agent': 'OpenHamClock/3.4',
'Accept': 'application/json'
},
signal: controller.signal
}); });
clearTimeout(timeout);
client.on('data', (data) => { if (response.ok) {
buffer += data.toString(); const data = await response.json();
// Wait for login prompt
if (!loginSent && (buffer.includes('login:') || buffer.includes('Please enter your call'))) {
loginSent = true;
// Send a guest login (GUEST or anonymous callsign)
client.write('GUEST\r\n');
return;
}
// Wait for prompt after login, then send command
if (loginSent && !commandSent && (buffer.includes('Hello') || buffer.includes('de ') || buffer.includes('>'))) {
commandSent = true;
// Request last 25 spots
setTimeout(() => {
client.write('sh/dx 25\r\n');
}, 500);
return;
}
// Parse DX spots from the output if (Array.isArray(data) && data.length > 0) {
// Format: DX de W3LPL: 14195.0 TI5/AA8HH FT8 -09 dB 1234Z const spots = data.slice(0, 25).map(spot => {
const lines = buffer.split('\n'); // IU1BOW format varies, common fields: freq, spotcall/dx_call, spotter, time, comment
for (const line of lines) { const freqVal = spot.freq || spot.frequency || 0;
if (line.includes('DX de ')) { const freqMhz = freqVal > 1000 ? (freqVal / 1000).toFixed(3) : String(freqVal).includes('.') ? String(freqVal) : (freqVal / 1000).toFixed(3);
const match = line.match(/DX de ([A-Z0-9\/\-]+):\s+(\d+\.?\d*)\s+([A-Z0-9\/\-]+)\s+(.+?)\s+(\d{4})Z/i); let time = '';
if (match) { if (spot.time) {
const spotter = match[1].replace(':', ''); // Time might be Unix timestamp or string
const freqKhz = parseFloat(match[2]); if (typeof spot.time === 'number') {
const dxCall = match[3]; const d = new Date(spot.time * 1000);
const comment = match[4].trim(); time = d.toISOString().substring(11, 16) + 'z';
const timeStr = match[5]; } else {
time = String(spot.time).substring(0, 5) + 'z';
if (!isNaN(freqKhz) && freqKhz > 0 && dxCall) {
const freqMhz = (freqKhz / 1000).toFixed(3);
const time = timeStr.substring(0, 2) + ':' + timeStr.substring(2, 4) + 'z';
// Avoid duplicates
if (!spots.find(s => s.call === dxCall && s.freq === freqMhz)) {
spots.push({
freq: freqMhz,
call: dxCall,
comment: comment,
time: time,
spotter: spotter,
source: 'DX Spider'
});
gotSpots = true;
}
} }
} }
} return {
} freq: freqMhz,
call: spot.spotcall || spot.dx_call || spot.dx || 'UNKNOWN',
// If we have enough spots or see end marker, close connection comment: spot.comment || spot.info || '',
if (spots.length >= 20 || buffer.includes('G6NHU-2 de GUEST')) { time: time,
client.write('bye\r\n'); spotter: spot.spotter || spot.de || '',
setTimeout(() => client.destroy(), 500); source: 'IU1BOW DX Spider'
};
});
console.log('[DX Cluster] IU1BOW:', spots.length, 'spots');
return spots;
} }
}); }
} catch (error) {
client.on('timeout', () => { clearTimeout(timeout);
console.log('[DX Cluster] DX Spider: timeout'); if (error.name !== 'AbortError') {
client.destroy(); console.error('[DX Cluster] IU1BOW error:', error.message);
}); }
}
return null;
}
client.on('error', (err) => { // Helper function for Spothole (aggregated DX cluster + xOTA spots)
console.error('[DX Cluster] DX Spider error:', err.message); async function fetchSpothole() {
client.destroy(); const controller = new AbortController();
}); const timeout = setTimeout(() => controller.abort(), 8000);
client.on('close', () => { try {
if (spots.length > 0) { // Spothole API endpoint - filter for DX cluster spots only
console.log('[DX Cluster] DX Spider:', spots.length, 'spots'); const response = await fetch('https://spothole.app/api/spots?sources=dxcluster&limit=25', {
dxSpiderCache = { spots: spots, timestamp: Date.now() }; headers: {
resolve(spots); 'User-Agent': 'OpenHamClock/3.4',
} else { 'Accept': 'application/json'
resolve(null); },
} signal: controller.signal
}); });
clearTimeout(timeout);
// Fallback timeout if (response.ok) {
setTimeout(() => { const data = await response.json();
if (!gotSpots) { const spotsList = data.spots || data;
client.destroy();
if (Array.isArray(spotsList) && spotsList.length > 0) {
const spots = spotsList.slice(0, 25).map(spot => {
// Spothole format: dx, frequency, mode, comment, de, time, etc.
const freqVal = spot.frequency || spot.freq || 0;
const freqMhz = freqVal > 1000 ? (freqVal / 1000).toFixed(3) : String(freqVal);
let time = '';
if (spot.time || spot.timestamp) {
const d = new Date(spot.time || spot.timestamp);
time = d.toISOString().substring(11, 16) + 'z';
}
return {
freq: freqMhz,
call: spot.dx || spot.call || spot.spotted || 'UNKNOWN',
comment: spot.comment || spot.info || spot.mode || '',
time: time,
spotter: spot.de || spot.spotter || '',
source: 'Spothole'
};
});
console.log('[DX Cluster] Spothole:', spots.length, 'spots');
return spots;
} }
}, 15000); }
}); } catch (error) {
clearTimeout(timeout);
if (error.name !== 'AbortError') {
console.error('[DX Cluster] Spothole error:', error.message);
}
}
return null;
} }
// Fetch based on selected source // Fetch based on selected source
@ -396,11 +388,15 @@ app.get('/api/dxcluster/spots', async (req, res) => {
spots = await fetchDXHeat(); spots = await fetchDXHeat();
} else if (source === 'dxsummit') { } else if (source === 'dxsummit') {
spots = await fetchDXSummit(); spots = await fetchDXSummit();
} else if (source === 'dxspider') { } else if (source === 'iu1bow') {
spots = await fetchDXSpider(); spots = await fetchIU1BOW();
} else if (source === 'spothole') {
spots = await fetchSpothole();
} else { } else {
// Auto mode - try sources in order // Auto mode - try sources in order (most reliable first)
spots = await fetchHamQTH(); spots = await fetchHamQTH();
if (!spots) spots = await fetchIU1BOW();
if (!spots) spots = await fetchSpothole();
if (!spots) spots = await fetchDXHeat(); if (!spots) spots = await fetchDXHeat();
if (!spots) spots = await fetchDXSummit(); if (!spots) spots = await fetchDXSummit();
} }
@ -412,10 +408,11 @@ app.get('/api/dxcluster/spots', async (req, res) => {
app.get('/api/dxcluster/sources', (req, res) => { app.get('/api/dxcluster/sources', (req, res) => {
res.json([ res.json([
{ id: 'auto', name: 'Auto (Best Available)', description: 'Automatically selects the best available source' }, { id: 'auto', name: 'Auto (Best Available)', description: 'Automatically selects the best available source' },
{ id: 'hamqth', name: 'HamQTH', description: 'HamQTH.com DX Cluster feed' }, { id: 'hamqth', name: 'HamQTH', description: 'HamQTH.com DX Cluster CSV feed' },
{ id: 'iu1bow', name: 'IU1BOW DX Spider', description: 'IU1BOW.it Spiderweb cluster (HTTP API)' },
{ id: 'spothole', name: 'Spothole', description: 'Spothole.app aggregated DX cluster' },
{ id: 'dxheat', name: 'DXHeat', description: 'DXHeat.com real-time cluster' }, { id: 'dxheat', name: 'DXHeat', description: 'DXHeat.com real-time cluster' },
{ id: 'dxsummit', name: 'DX Summit', description: 'DXSummit.fi cluster (may be slow)' }, { id: 'dxsummit', name: 'DX Summit', description: 'DXSummit.fi cluster (may be slow)' }
{ id: 'dxspider', name: 'DX Spider (G6NHU)', description: 'G6NHU-2 DX Spider node via telnet (dxspider.co.uk)' }
]); ]);
}); });

Loading…
Cancel
Save

Powered by TurnKey Linux.