add blink to desktop joiner
This commit is contained in:
1 parent
3eb46f6ebf
commit
558bb4438f
11 files changed
+366
-26
No files matched your search
@@ -4,9 +4,15 @@ export const IPC = {
|
||||
LOG: 'joiner:log',
|
||||
STATUS: 'joiner:status',
|
||||
RUNNING: 'joiner:running',
|
||||
LOGIN_LINK: 'joiner:login-link',
|
||||
} as const;
|
||||
|
||||
export type JoinerPlatform = 'wbstream' | 'telemost' | 'vk' | 'dion' | 'bitrix';
|
||||
export type JoinerPlatform = 'wbstream' | 'telemost' | 'vk' | 'dion' | 'bitrix' | 'blink';
|
||||
|
||||
export interface LoginLink {
|
||||
link: string;
|
||||
qr: string;
|
||||
}
|
||||
|
||||
export interface JoinerSettings {
|
||||
platform: JoinerPlatform;
|
||||
|
||||
@@ -2,6 +2,7 @@ import { app, BrowserWindow, ipcMain } from 'electron';
|
||||
import { spawn, ChildProcess } from 'node:child_process';
|
||||
import { existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import * as QRCode from 'qrcode';
|
||||
import { IPC, JoinerSettings } from '../constants';
|
||||
|
||||
// Single global joiner process. We never run two tunnels at once: the
|
||||
@@ -40,6 +41,17 @@ function closeCaptchaWindow() {
|
||||
captchaWindow = null;
|
||||
}
|
||||
|
||||
async function showLoginLink(link: string) {
|
||||
send(IPC.STATUS, 'waiting for login');
|
||||
try {
|
||||
const qr = await QRCode.toDataURL(link, { errorCorrectionLevel: 'M', margin: 1, scale: 6 });
|
||||
send(IPC.LOGIN_LINK, { link, qr });
|
||||
} catch (err) {
|
||||
send(IPC.LOG, `[main] login QR failed: ${(err as Error).message}\n`);
|
||||
send(IPC.LOGIN_LINK, { link, qr: '' });
|
||||
}
|
||||
}
|
||||
|
||||
function resolveJoinerExe(): string {
|
||||
// When packaged, electron-builder copies the backend binary into
|
||||
// resources/ under the OS-appropriate name. In dev, fall back to
|
||||
@@ -119,10 +131,10 @@ function spawnJoiner(settings: JoinerSettings): { ok: boolean; error?: string }
|
||||
if (settings.socksUser) args.push('--socks-user', settings.socksUser);
|
||||
if (settings.socksPass) args.push('--socks-pass', settings.socksPass);
|
||||
if (noTun) args.push('--no-tun');
|
||||
if (settings.dualTrack && (settings.platform === 'vk' || settings.platform === 'wbstream' || settings.platform === 'bitrix')) {
|
||||
if (settings.dualTrack && (settings.platform === 'vk' || settings.platform === 'wbstream' || settings.platform === 'bitrix' || settings.platform === 'blink')) {
|
||||
args.push('--dual-track');
|
||||
}
|
||||
if (settings.reliable && (settings.platform === 'wbstream' || settings.platform === 'bitrix' || settings.platform === 'telemost')) {
|
||||
if (settings.reliable && (settings.platform === 'wbstream' || settings.platform === 'bitrix' || settings.platform === 'telemost' || settings.platform === 'blink')) {
|
||||
args.push('--reliable');
|
||||
}
|
||||
|
||||
@@ -160,11 +172,19 @@ function spawnJoiner(settings: JoinerSettings): { ok: boolean; error?: string }
|
||||
} else if (captchaWindow && /captcha solved|Auth complete|TUNNEL/i.test(text)) {
|
||||
closeCaptchaWindow();
|
||||
}
|
||||
const loginMatch = text.match(/STATUS:LOGIN_LINK:(\S+)/);
|
||||
if (loginMatch) {
|
||||
showLoginLink(loginMatch[1]);
|
||||
} else if (text.includes('[login] approved')) {
|
||||
send(IPC.LOGIN_LINK, null);
|
||||
send(IPC.STATUS, 'starting');
|
||||
}
|
||||
};
|
||||
joinerProcess.stdout?.on('data', (b: Buffer) => handleOutput(b.toString()));
|
||||
joinerProcess.stderr?.on('data', (b: Buffer) => handleOutput(b.toString()));
|
||||
joinerProcess.on('exit', (code, signal) => {
|
||||
closeCaptchaWindow();
|
||||
send(IPC.LOGIN_LINK, null);
|
||||
send(IPC.LOG, `\n[main] joiner exited code=${code} signal=${signal}\n`);
|
||||
send(IPC.STATUS, 'stopped');
|
||||
send(IPC.RUNNING, false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { contextBridge, ipcRenderer } from 'electron';
|
||||
import { IPC, JoinerSettings } from '../constants';
|
||||
import { IPC, JoinerSettings, LoginLink } from '../constants';
|
||||
|
||||
contextBridge.exposeInMainWorld('bridge', {
|
||||
start: (settings: JoinerSettings) => ipcRenderer.invoke(IPC.START, settings),
|
||||
@@ -13,4 +13,7 @@ contextBridge.exposeInMainWorld('bridge', {
|
||||
onRunning(cb: (running: boolean) => void) {
|
||||
ipcRenderer.on(IPC.RUNNING, (_e, v) => cb(v));
|
||||
},
|
||||
onLoginLink(cb: (login: LoginLink | null) => void) {
|
||||
ipcRenderer.on(IPC.LOGIN_LINK, (_e, login) => cb(login));
|
||||
},
|
||||
});
|
||||
@@ -1,4 +1,5 @@
|
||||
type JoinerPlatform = 'wbstream' | 'telemost' | 'vk' | 'dion' | 'bitrix';
|
||||
type JoinerPlatform = import('../constants').JoinerPlatform;
|
||||
type LoginLink = import('../constants').LoginLink;
|
||||
|
||||
function detectPlatform(url: string): JoinerPlatform | null {
|
||||
const u = url.toLowerCase();
|
||||
@@ -7,6 +8,7 @@ function detectPlatform(url: string): JoinerPlatform | null {
|
||||
if (u.includes('telemost.yandex')) return 'telemost';
|
||||
if (u.includes('dion://') || u.includes('dion.vc')) return 'dion';
|
||||
if (u.includes('bitrix24') && u.includes('/video/')) return 'bitrix';
|
||||
if (u.includes('blink://') || (u.includes('blinkmap.com') && u.includes('/join/'))) return 'blink';
|
||||
return 'vk';
|
||||
}
|
||||
|
||||
@@ -17,6 +19,7 @@ function platformLabel(p: JoinerPlatform | null): string {
|
||||
case 'vk': return 'VK';
|
||||
case 'dion': return 'DION';
|
||||
case 'bitrix': return 'Bitrix';
|
||||
case 'blink': return 'Blink';
|
||||
default: return '-';
|
||||
}
|
||||
}
|
||||
@@ -27,6 +30,7 @@ interface Bridge {
|
||||
onLog(cb: (text: string) => void): void;
|
||||
onStatus(cb: (status: string) => void): void;
|
||||
onRunning(cb: (running: boolean) => void): void;
|
||||
onLoginLink(cb: (login: LoginLink | null) => void): void;
|
||||
}
|
||||
declare const bridge: Bridge;
|
||||
|
||||
@@ -41,6 +45,10 @@ const stopBtn = $('stop') as HTMLButtonElement;
|
||||
const downloadLogsBtn = $('downloadLogs') as HTMLImageElement;
|
||||
const platformHint = $('platformHint');
|
||||
const linkInput = input('link');
|
||||
const loginCard = $('loginCard');
|
||||
const loginQr = $('loginQr') as HTMLImageElement;
|
||||
const loginLinkEl = $('loginLink');
|
||||
const copyLoginLinkBtn = $('copyLoginLink') as HTMLButtonElement;
|
||||
|
||||
stopBtn.disabled = true;
|
||||
|
||||
@@ -85,6 +93,17 @@ bridge.onRunning((running) => {
|
||||
startBtn.disabled = running;
|
||||
stopBtn.disabled = !running;
|
||||
});
|
||||
bridge.onLoginLink((login) => {
|
||||
loginCard.hidden = !login;
|
||||
if (!login) return;
|
||||
loginQr.src = login.qr;
|
||||
loginQr.hidden = !login.qr;
|
||||
loginLinkEl.textContent = login.link;
|
||||
});
|
||||
|
||||
copyLoginLinkBtn.addEventListener('click', () => {
|
||||
navigator.clipboard.writeText(loginLinkEl.textContent || '');
|
||||
});
|
||||
|
||||
startBtn.addEventListener('click', async () => {
|
||||
appendLog('\n[ui] starting joiner...\n');
|
||||
|
||||
Reference in new issue
Block a user