Skip to content

Instantly share code, notes, and snippets.

@p34eu
Last active April 24, 2026 06:43
Show Gist options
  • Select an option

  • Save p34eu/328b10a7a5785c73e41a8cd6e6ab8d55 to your computer and use it in GitHub Desktop.

Select an option

Save p34eu/328b10a7a5785c73e41a8cd6e6ab8d55 to your computer and use it in GitHub Desktop.
UDP relay listener/sender for Adif QSO to HTTP server for JTDX
const dgram = require("dgram");
const axios = require("axios");
const UDP_PORT = 2237;
const LARAVEL_URL = "https://................./adif"; // Sanctum API endpoint
const SANCTUM_TOKEN = "...........................";
const server = dgram.createSocket("udp4");
server.on("message", async (msg) => {
const text = msg.toString("utf8");
if (text.includes("<EOR>") || text.includes("<eor>")) {
const adifMatch = text.match(/(<adif_ver[\s\S]*<EOR>)/i) || text.match(/(<EOH>[\s\S]*<EOR>)/i);
if (adifMatch) {
const cleanAdif = adifMatch[1].trim();
console.log("\n📡 --- QSO ---");
console.log(cleanAdif);
try {
const response = await axios.post(LARAVEL_URL,
{
adif: cleanAdif // Изпращаме го като JSON обект с ключ adif
},
{
headers: {
'Authorization': `Bearer ${SANCTUM_TOKEN}`,
'Content-Type': 'application/json',
'Accept': 'application/json'
}
}
);
console.log("Отговор от сървъра:", response.data);
} catch (error) {
console.error("Грешка при изпращане:");
if (error.response) {
console.error("HTTP Статус:", error.response.status);
console.error("Отговор:", error.response.data);
} else {
console.error(error.message);
}
}
console.log("-----------------------------\n");
}
}
});
server.bind(UDP_PORT, () => {
console.log(`ready to accept new qso vua UDP on port ${UDP_PORT}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment