Joiner desktop windows (#89)
* base classes/logic from a playground * fix sandbox * add vk support
This commit is contained in:
1 parent
1308361eb6
commit
30ed29a161
34 files changed
+7056
No files matched your search
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Builds the user-facing Electron joiner app for Windows, following the
|
||||
# same per-arch bundle pattern as build-creator.sh. Output is the NSIS
|
||||
# installer in prebuilts/ (via electron-builder's directories.output).
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")" && pwd)"
|
||||
JOINER_GO_DIR="$ROOT/joiner-desktop-app/windows-joiner"
|
||||
ELECTRON_DIR="$ROOT/joiner-desktop-app"
|
||||
|
||||
echo "=== Building Go backend ==="
|
||||
"$ROOT/build-windows-joiner.sh"
|
||||
|
||||
cd "$ELECTRON_DIR"
|
||||
if [ ! -d node_modules/typescript ]; then
|
||||
echo "[npm] installing dev deps"
|
||||
npm install
|
||||
fi
|
||||
npx tsc
|
||||
|
||||
cleanup_bundle() {
|
||||
rm -f "$JOINER_GO_DIR/windows-joiner-bundle.exe" \
|
||||
"$JOINER_GO_DIR/wintun-bundle.dll"
|
||||
}
|
||||
trap cleanup_bundle EXIT
|
||||
|
||||
for pair in "x64 --x64" "ia32 --ia32" "arm64 --arm64"; do
|
||||
arch="${pair% *}"
|
||||
flag="${pair#* }"
|
||||
echo ""
|
||||
echo "--- Windows $arch ---"
|
||||
cp "$JOINER_GO_DIR/windows-joiner-$arch.exe" "$JOINER_GO_DIR/windows-joiner-bundle.exe"
|
||||
cp "$JOINER_GO_DIR/wintun-$arch.dll" "$JOINER_GO_DIR/wintun-bundle.dll"
|
||||
npx electron-builder --win $flag --publish never
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "=== Done ==="
|
||||
ls -lh "$ROOT/prebuilts"/WhitelistBypass*.exe 2>/dev/null || true
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Builds the Windows joiner Go binary and fetches wintun.dll, next to
|
||||
# the Go source in joiner-desktop-app/windows-joiner/. Nothing is
|
||||
# written to prebuilts/. Run ./build-joiner-app.sh afterwards to
|
||||
# produce the Electron installer.
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")" && pwd)"
|
||||
JOINER_GO_DIR="$ROOT/joiner-desktop-app/windows-joiner"
|
||||
WINTUN_VERSION="0.14.1"
|
||||
WINTUN_URL="https://www.wintun.net/builds/wintun-${WINTUN_VERSION}.zip"
|
||||
|
||||
build_arch() {
|
||||
GOARCH_GO="$1"
|
||||
OUT_TAG="$2"
|
||||
WINTUN_ARCH="$3"
|
||||
echo ""
|
||||
echo "=== Building windows-joiner ($OUT_TAG / GOARCH=$GOARCH_GO) ==="
|
||||
cd "$JOINER_GO_DIR"
|
||||
GOOS=windows GOARCH="$GOARCH_GO" go build \
|
||||
-trimpath -ldflags="-s -w" \
|
||||
-o "$JOINER_GO_DIR/windows-joiner-$OUT_TAG.exe" .
|
||||
ls -lh "$JOINER_GO_DIR/windows-joiner-$OUT_TAG.exe"
|
||||
|
||||
if [ ! -f "$JOINER_GO_DIR/wintun-$OUT_TAG.dll" ]; then
|
||||
if [ ! -f "$JOINER_GO_DIR/wintun.zip" ]; then
|
||||
echo "[wintun] downloading $WINTUN_URL"
|
||||
curl -L -o "$JOINER_GO_DIR/wintun.zip" "$WINTUN_URL"
|
||||
fi
|
||||
echo "[wintun] extracting $WINTUN_ARCH"
|
||||
unzip -o -j "$JOINER_GO_DIR/wintun.zip" "wintun/bin/$WINTUN_ARCH/wintun.dll" \
|
||||
-d "$JOINER_GO_DIR" >/dev/null
|
||||
mv "$JOINER_GO_DIR/wintun.dll" "$JOINER_GO_DIR/wintun-$OUT_TAG.dll"
|
||||
fi
|
||||
ls -lh "$JOINER_GO_DIR/wintun-$OUT_TAG.dll"
|
||||
}
|
||||
|
||||
build_arch amd64 x64 amd64
|
||||
build_arch arm64 arm64 arm64
|
||||
build_arch 386 ia32 x86
|
||||
|
||||
rm -f "$JOINER_GO_DIR/wintun.zip"
|
||||
|
||||
echo ""
|
||||
echo "=== Done ==="
|
||||
ls -lh "$JOINER_GO_DIR"/windows-joiner-*.exe "$JOINER_GO_DIR"/wintun-*.dll
|
||||
@@ -0,0 +1,2 @@
|
||||
node_modules/
|
||||
dist/
|
||||
@@ -0,0 +1,88 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'" />
|
||||
<title>WhitelistBypass Joiner</title>
|
||||
<link rel="stylesheet" href="styles/app.css" />
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>WhitelistBypass Joiner</h1>
|
||||
<div class="status" id="status" data-state="idle">idle</div>
|
||||
</header>
|
||||
<main>
|
||||
<section class="form">
|
||||
<label>
|
||||
Join link
|
||||
<input id="link" type="text" placeholder="Paste call link" />
|
||||
<span class="hint" id="platformHint">Detected platform: -</span>
|
||||
</label>
|
||||
<label>
|
||||
Display name
|
||||
<input id="name" type="text" value="Joiner" />
|
||||
</label>
|
||||
<div class="row">
|
||||
<label>
|
||||
SOCKS5 port
|
||||
<input id="socksPort" type="number" value="1080" min="1" max="65535" />
|
||||
</label>
|
||||
<label>
|
||||
DNS
|
||||
<input id="dns" type="text" value="1.1.1.1,8.8.8.8" />
|
||||
</label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>
|
||||
SOCKS5 user
|
||||
<input id="socksUser" type="text" />
|
||||
</label>
|
||||
<label>
|
||||
SOCKS5 password
|
||||
<input id="socksPass" type="password" />
|
||||
</label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>
|
||||
Tunnel mode
|
||||
<select id="tunnelMode">
|
||||
<option value="video" selected>Video (VP8)</option>
|
||||
<option value="dc">DataChannel</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
Resources
|
||||
<select id="resources">
|
||||
<option value="moderate">Moderate</option>
|
||||
<option value="default" selected>Default</option>
|
||||
<option value="unlimited">Unlimited</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>
|
||||
VP8 FPS
|
||||
<input id="vp8Fps" type="number" value="24" min="1" max="60" />
|
||||
</label>
|
||||
<label>
|
||||
VP8 batch
|
||||
<input id="vp8Batch" type="number" value="30" min="1" max="200" />
|
||||
</label>
|
||||
</div>
|
||||
<label class="check">
|
||||
<input id="noTun" type="checkbox" />
|
||||
SOCKS5 only (do not bring up wintun adapter)
|
||||
</label>
|
||||
<div class="actions">
|
||||
<button id="start">Start</button>
|
||||
<button id="stop">Stop</button>
|
||||
</div>
|
||||
</section>
|
||||
<section class="log-wrap">
|
||||
<h2>Log</h2>
|
||||
<pre id="log"></pre>
|
||||
</section>
|
||||
</main>
|
||||
<script src="dist/renderer/index.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Generated
+5289
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "whitelist-bypass-joiner",
|
||||
"version": "0.3.1",
|
||||
"main": "dist/main/index.js",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"start": "tsc && electron .",
|
||||
"start:dev": "electron ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.0.0",
|
||||
"electron": "^33.0.0",
|
||||
"electron-builder": "^25.0.0",
|
||||
"typescript": "^5.6.0"
|
||||
},
|
||||
"build": {
|
||||
"appId": "whitelist.bypass.joiner",
|
||||
"productName": "WhitelistBypass Joiner",
|
||||
"directories": {
|
||||
"output": "../prebuilts"
|
||||
},
|
||||
"files": [
|
||||
"dist/**/*",
|
||||
"index.html",
|
||||
"styles/**/*",
|
||||
"resources/**/*"
|
||||
],
|
||||
"win": {
|
||||
"target": "portable",
|
||||
"artifactName": "${productName}-${version}-${arch}.${ext}",
|
||||
"icon": "resources/icon.ico",
|
||||
"requestedExecutionLevel": "requireAdministrator",
|
||||
"extraResources": [
|
||||
{
|
||||
"from": "windows-joiner/windows-joiner-bundle.exe",
|
||||
"to": "windows-joiner.exe"
|
||||
},
|
||||
{
|
||||
"from": "windows-joiner/wintun-bundle.dll",
|
||||
"to": "wintun.dll"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 90 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 236 KiB |
@@ -0,0 +1,24 @@
|
||||
export const IPC = {
|
||||
START: 'joiner:start',
|
||||
STOP: 'joiner:stop',
|
||||
LOG: 'joiner:log',
|
||||
STATUS: 'joiner:status',
|
||||
RUNNING: 'joiner:running',
|
||||
} as const;
|
||||
|
||||
export type JoinerPlatform = 'wbstream' | 'telemost' | 'vk';
|
||||
|
||||
export interface JoinerSettings {
|
||||
platform: JoinerPlatform;
|
||||
link: string;
|
||||
displayName: string;
|
||||
socksPort: number;
|
||||
socksUser: string;
|
||||
socksPass: string;
|
||||
tunnelMode: 'video' | 'dc';
|
||||
vp8Fps: number;
|
||||
vp8Batch: number;
|
||||
resources: 'moderate' | 'default' | 'unlimited';
|
||||
dns: string;
|
||||
noTun: boolean;
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
import { app, BrowserWindow, ipcMain } from 'electron';
|
||||
import { spawn, ChildProcess } from 'node:child_process';
|
||||
import { existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { IPC, JoinerSettings } from '../constants';
|
||||
|
||||
// Single global joiner process. We never run two tunnels at once: the
|
||||
// wintun adapter and the route table are exclusive resources.
|
||||
let joinerProcess: ChildProcess | null = null;
|
||||
let mainWindow: BrowserWindow | null = null;
|
||||
let captchaWindow: BrowserWindow | null = null;
|
||||
|
||||
function openCaptchaWindow(url: string) {
|
||||
if (captchaWindow && !captchaWindow.isDestroyed()) {
|
||||
captchaWindow.loadURL(url);
|
||||
captchaWindow.focus();
|
||||
return;
|
||||
}
|
||||
captchaWindow = new BrowserWindow({
|
||||
width: 520,
|
||||
height: 640,
|
||||
title: 'Solve the captcha',
|
||||
parent: mainWindow ?? undefined,
|
||||
autoHideMenuBar: true,
|
||||
webPreferences: { contextIsolation: true, nodeIntegration: false, sandbox: true },
|
||||
});
|
||||
captchaWindow.loadURL(url);
|
||||
captchaWindow.on('closed', () => { captchaWindow = null; });
|
||||
}
|
||||
|
||||
function closeCaptchaWindow() {
|
||||
if (captchaWindow && !captchaWindow.isDestroyed()) {
|
||||
captchaWindow.close();
|
||||
}
|
||||
captchaWindow = null;
|
||||
}
|
||||
|
||||
function resolveJoinerExe(): string {
|
||||
// When packaged, electron-builder copies windows-joiner.exe into
|
||||
// resources/. In dev, look next to the source binary.
|
||||
const packaged = join(process.resourcesPath || '', 'windows-joiner.exe');
|
||||
if (existsSync(packaged)) return packaged;
|
||||
const fallback = join(__dirname, '..', '..', '..', 'prebuilts', 'windows-joiner-x64.exe');
|
||||
return fallback;
|
||||
}
|
||||
|
||||
function send(channel: string, payload: unknown) {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send(channel, payload);
|
||||
}
|
||||
}
|
||||
|
||||
function createWindow() {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 900,
|
||||
height: 600,
|
||||
title: 'WhitelistBypass Joiner',
|
||||
icon: join(__dirname, '..', '..', 'resources', 'icon.png'),
|
||||
webPreferences: {
|
||||
preload: join(__dirname, '..', 'preload', 'index.js'),
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false,
|
||||
sandbox: false,
|
||||
},
|
||||
});
|
||||
mainWindow.setMenuBarVisibility(false);
|
||||
mainWindow.loadFile(join(__dirname, '..', '..', 'index.html'));
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow();
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
||||
});
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
stopJoiner();
|
||||
if (process.platform !== 'darwin') app.quit();
|
||||
});
|
||||
|
||||
ipcMain.handle(IPC.START, async (_e, settings: JoinerSettings) => {
|
||||
if (joinerProcess) {
|
||||
return { ok: false, error: 'joiner already running' };
|
||||
}
|
||||
const exe = resolveJoinerExe();
|
||||
if (!existsSync(exe)) {
|
||||
return { ok: false, error: `windows-joiner.exe not found at ${exe}` };
|
||||
}
|
||||
const args = [
|
||||
'--platform', settings.platform,
|
||||
'--link', settings.link,
|
||||
'--name', settings.displayName,
|
||||
'--socks-port', String(settings.socksPort),
|
||||
'--tunnel-mode', settings.tunnelMode,
|
||||
'--vp8-fps', String(settings.vp8Fps),
|
||||
'--vp8-batch', String(settings.vp8Batch),
|
||||
'--resources', settings.resources,
|
||||
'--dns', settings.dns,
|
||||
];
|
||||
if (settings.socksUser) args.push('--socks-user', settings.socksUser);
|
||||
if (settings.socksPass) args.push('--socks-pass', settings.socksPass);
|
||||
if (settings.noTun) args.push('--no-tun');
|
||||
|
||||
const commandLine = [exe, ...args].map((s) => (/\s/.test(s) ? `"${s}"` : s)).join(' ');
|
||||
send(IPC.LOG, `[main] spawning: ${commandLine}\n`);
|
||||
try {
|
||||
joinerProcess = spawn(exe, args, { windowsHide: true });
|
||||
} catch (err) {
|
||||
return { ok: false, error: `spawn failed: ${(err as Error).message}` };
|
||||
}
|
||||
send(IPC.RUNNING, true);
|
||||
send(IPC.STATUS, 'starting');
|
||||
|
||||
joinerProcess.on('error', (err) => {
|
||||
send(IPC.LOG, `[main] spawn error: ${err.message}\n`);
|
||||
send(IPC.STATUS, 'stopped');
|
||||
send(IPC.RUNNING, false);
|
||||
joinerProcess = null;
|
||||
});
|
||||
const handleOutput = (text: string) => {
|
||||
send(IPC.LOG, text);
|
||||
if (text.includes('TUNNEL ACTIVE')) send(IPC.STATUS, 'active');
|
||||
if (text.includes('TUNNEL CONNECTED')) send(IPC.STATUS, 'connected');
|
||||
const captchaMatch = text.match(/STATUS:CAPTCHA:(\S+)/);
|
||||
if (captchaMatch) {
|
||||
openCaptchaWindow(captchaMatch[1]);
|
||||
} else if (captchaWindow && /captcha solved|Auth complete|TUNNEL/i.test(text)) {
|
||||
closeCaptchaWindow();
|
||||
}
|
||||
};
|
||||
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.LOG, `\n[main] joiner exited code=${code} signal=${signal}\n`);
|
||||
send(IPC.STATUS, 'stopped');
|
||||
send(IPC.RUNNING, false);
|
||||
joinerProcess = null;
|
||||
});
|
||||
return { ok: true };
|
||||
});
|
||||
|
||||
ipcMain.handle(IPC.STOP, async () => {
|
||||
stopJoiner();
|
||||
return { ok: true };
|
||||
});
|
||||
|
||||
function stopJoiner() {
|
||||
closeCaptchaWindow();
|
||||
if (!joinerProcess) return;
|
||||
try {
|
||||
// SIGTERM on Windows ends up as TerminateProcess for the child.
|
||||
// The Go binary registers a signal handler for SIGTERM which
|
||||
// triggers Tunnel.Stop and tears down routes cleanly.
|
||||
joinerProcess.kill('SIGTERM');
|
||||
} catch {}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { contextBridge, ipcRenderer } from 'electron';
|
||||
import { IPC, JoinerSettings } from '../constants';
|
||||
|
||||
contextBridge.exposeInMainWorld('bridge', {
|
||||
start: (settings: JoinerSettings) => ipcRenderer.invoke(IPC.START, settings),
|
||||
stop: () => ipcRenderer.invoke(IPC.STOP),
|
||||
onLog(cb: (text: string) => void) {
|
||||
ipcRenderer.on(IPC.LOG, (_e, text) => cb(text));
|
||||
},
|
||||
onStatus(cb: (status: string) => void) {
|
||||
ipcRenderer.on(IPC.STATUS, (_e, status) => cb(status));
|
||||
},
|
||||
onRunning(cb: (running: boolean) => void) {
|
||||
ipcRenderer.on(IPC.RUNNING, (_e, v) => cb(v));
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,98 @@
|
||||
type JoinerPlatform = 'wbstream' | 'telemost' | 'vk';
|
||||
|
||||
function detectPlatform(url: string): JoinerPlatform | null {
|
||||
const u = url.toLowerCase();
|
||||
if (!u) return null;
|
||||
if (u.includes('wbstream://') || u.includes('stream.wb.ru')) return 'wbstream';
|
||||
if (u.includes('telemost.yandex')) return 'telemost';
|
||||
return 'vk';
|
||||
}
|
||||
|
||||
function platformLabel(p: JoinerPlatform | null): string {
|
||||
switch (p) {
|
||||
case 'wbstream': return 'WB Stream';
|
||||
case 'telemost': return 'Telemost';
|
||||
case 'vk': return 'VK';
|
||||
default: return '-';
|
||||
}
|
||||
}
|
||||
|
||||
interface Bridge {
|
||||
start(settings: any): Promise<{ ok: boolean; error?: string }>;
|
||||
stop(): Promise<{ ok: boolean }>;
|
||||
onLog(cb: (text: string) => void): void;
|
||||
onStatus(cb: (status: string) => void): void;
|
||||
onRunning(cb: (running: boolean) => void): void;
|
||||
}
|
||||
declare const bridge: Bridge;
|
||||
|
||||
const $ = (id: string) => document.getElementById(id) as HTMLElement;
|
||||
const input = (id: string) => document.getElementById(id) as HTMLInputElement;
|
||||
const select = (id: string) => document.getElementById(id) as HTMLSelectElement;
|
||||
|
||||
const logEl = $('log') as HTMLPreElement;
|
||||
const statusEl = $('status');
|
||||
const startBtn = $('start') as HTMLButtonElement;
|
||||
const stopBtn = $('stop') as HTMLButtonElement;
|
||||
const platformHint = $('platformHint');
|
||||
const linkInput = input('link');
|
||||
|
||||
stopBtn.disabled = true;
|
||||
|
||||
function refreshPlatformHint() {
|
||||
const p = detectPlatform(linkInput.value.trim());
|
||||
platformHint.textContent = `Detected platform: ${platformLabel(p)}`;
|
||||
platformHint.dataset.detected = p ?? '';
|
||||
}
|
||||
linkInput.addEventListener('input', refreshPlatformHint);
|
||||
refreshPlatformHint();
|
||||
|
||||
function appendLog(text: string) {
|
||||
logEl.textContent += text;
|
||||
logEl.scrollTop = logEl.scrollHeight;
|
||||
}
|
||||
|
||||
bridge.onLog((text) => appendLog(text));
|
||||
bridge.onStatus((s) => {
|
||||
statusEl.textContent = s;
|
||||
statusEl.dataset.state = s;
|
||||
});
|
||||
bridge.onRunning((running) => {
|
||||
startBtn.disabled = running;
|
||||
stopBtn.disabled = !running;
|
||||
});
|
||||
|
||||
startBtn.addEventListener('click', async () => {
|
||||
appendLog('\n[ui] starting joiner...\n');
|
||||
const link = linkInput.value.trim();
|
||||
if (!link) {
|
||||
appendLog('[ui] link is required\n');
|
||||
return;
|
||||
}
|
||||
const platform = detectPlatform(link);
|
||||
if (!platform) {
|
||||
appendLog('[ui] link does not look like a WB Stream or Telemost call\n');
|
||||
return;
|
||||
}
|
||||
const settings = {
|
||||
platform,
|
||||
link,
|
||||
displayName: input('name').value.trim() || 'Joiner',
|
||||
socksPort: parseInt(input('socksPort').value, 10) || 1080,
|
||||
socksUser: input('socksUser').value,
|
||||
socksPass: input('socksPass').value,
|
||||
tunnelMode: select('tunnelMode').value,
|
||||
vp8Fps: parseInt(input('vp8Fps').value, 10) || 24,
|
||||
vp8Batch: parseInt(input('vp8Batch').value, 10) || 30,
|
||||
resources: select('resources').value,
|
||||
dns: input('dns').value.trim() || '1.1.1.1,8.8.8.8',
|
||||
noTun: input('noTun').checked,
|
||||
};
|
||||
const r = await bridge.start(settings);
|
||||
if (!r.ok) appendLog(`[ui] start failed: ${r.error}\n`);
|
||||
});
|
||||
|
||||
stopBtn.addEventListener('click', async () => {
|
||||
appendLog('\n[ui] stopping joiner...\n');
|
||||
await bridge.stop();
|
||||
});
|
||||
@@ -0,0 +1,56 @@
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
--bg: #1a1b1f;
|
||||
--bg-elev: #23252b;
|
||||
--fg: #e6e8ea;
|
||||
--muted: #8a8f99;
|
||||
--accent: #4f88ff;
|
||||
--danger: #c8472b;
|
||||
--ok: #36a36a;
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
html, body {
|
||||
margin: 0; height: 100%;
|
||||
font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
||||
background: var(--bg); color: var(--fg);
|
||||
}
|
||||
body { display: flex; flex-direction: column; }
|
||||
header {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
padding: 10px 16px; border-bottom: 1px solid #2c2e35;
|
||||
}
|
||||
h1 { font-size: 14px; margin: 0; }
|
||||
.status {
|
||||
font-size: 12px; padding: 3px 10px; border-radius: 10px;
|
||||
background: #2c2e35; color: var(--muted);
|
||||
}
|
||||
.status[data-state="active"], .status[data-state="connected"] { background: var(--ok); color: #fff; }
|
||||
.status[data-state="stopped"] { background: #4a3030; color: #ffb4a8; }
|
||||
main { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px; min-height: 0; }
|
||||
section.form { display: flex; flex-direction: column; gap: 10px; }
|
||||
section.log-wrap { display: flex; flex-direction: column; min-height: 0; }
|
||||
section.log-wrap h2 { font-size: 12px; margin: 0 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
|
||||
pre#log {
|
||||
flex: 1; margin: 0; padding: 10px; background: var(--bg-elev);
|
||||
border: 1px solid #2c2e35; border-radius: 6px;
|
||||
font: 11.5px/1.5 "SF Mono", Menlo, Consolas, monospace;
|
||||
color: #c5c8cf; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
|
||||
}
|
||||
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
|
||||
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--fg); }
|
||||
.hint { font-size: 11px; color: var(--muted); }
|
||||
.hint[data-detected="wbstream"], .hint[data-detected="telemost"] { color: var(--ok); }
|
||||
input, select {
|
||||
font-size: 13px; padding: 6px 8px;
|
||||
background: var(--bg-elev); color: var(--fg);
|
||||
border: 1px solid #2c2e35; border-radius: 4px;
|
||||
}
|
||||
input:focus, select:focus { outline: none; border-color: var(--accent); }
|
||||
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
|
||||
.actions { display: flex; gap: 8px; margin-top: 6px; }
|
||||
button {
|
||||
flex: 1; padding: 8px 12px; border: none; border-radius: 4px;
|
||||
background: var(--accent); color: #fff; font-weight: 500; cursor: pointer;
|
||||
}
|
||||
button#stop { background: var(--danger); }
|
||||
button:disabled { opacity: 0.4; cursor: not-allowed; }
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "commonjs",
|
||||
"lib": ["ESNext", "DOM"],
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"declaration": false,
|
||||
"sourceMap": true
|
||||
},
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["node_modules", "dist", "windows-joiner"]
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
windows-joiner-*.exe
|
||||
windows-joiner-bundle.exe
|
||||
wintun-*.dll
|
||||
wintun-bundle.dll
|
||||
wintun.zip
|
||||
@@ -0,0 +1,49 @@
|
||||
module windows-joiner
|
||||
|
||||
go 1.26.1
|
||||
|
||||
require whitelist-bypass/relay v0.0.0
|
||||
|
||||
require (
|
||||
github.com/ajg/form v1.5.1 // indirect
|
||||
github.com/docker/go-units v0.5.0 // indirect
|
||||
github.com/go-chi/chi/v5 v5.2.1 // indirect
|
||||
github.com/go-chi/cors v1.2.1 // indirect
|
||||
github.com/go-chi/render v1.0.3 // indirect
|
||||
github.com/go-gost/relay v0.5.0 // indirect
|
||||
github.com/google/btree v1.1.3 // indirect
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/gorilla/schema v1.4.1 // indirect
|
||||
github.com/gorilla/websocket v1.5.3 // indirect
|
||||
github.com/pion/datachannel v1.6.0 // indirect
|
||||
github.com/pion/dtls/v3 v3.1.2 // indirect
|
||||
github.com/pion/ice/v4 v4.2.1 // indirect
|
||||
github.com/pion/interceptor v0.1.44 // indirect
|
||||
github.com/pion/logging v0.2.4 // indirect
|
||||
github.com/pion/mdns/v2 v2.1.0 // indirect
|
||||
github.com/pion/randutil v0.1.0 // indirect
|
||||
github.com/pion/rtcp v1.2.16 // indirect
|
||||
github.com/pion/rtp v1.10.1 // indirect
|
||||
github.com/pion/sctp v1.9.2 // indirect
|
||||
github.com/pion/sdp/v3 v3.0.18 // indirect
|
||||
github.com/pion/srtp/v3 v3.0.10 // indirect
|
||||
github.com/pion/stun/v3 v3.1.1 // indirect
|
||||
github.com/pion/transport/v4 v4.0.1 // indirect
|
||||
github.com/pion/turn/v4 v4.1.4 // indirect
|
||||
github.com/pion/webrtc/v4 v4.2.9 // indirect
|
||||
github.com/wlynxg/anet v0.0.5 // indirect
|
||||
github.com/xjasonlyu/tun2socks/v2 v2.6.0 // indirect
|
||||
go.uber.org/atomic v1.11.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.27.0 // indirect
|
||||
golang.org/x/crypto v0.49.0 // indirect
|
||||
golang.org/x/net v0.52.0 // indirect
|
||||
golang.org/x/sys v0.42.0 // indirect
|
||||
golang.org/x/time v0.11.0 // indirect
|
||||
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
|
||||
golang.zx2c4.com/wireguard v0.0.0-20250521234502-f333402bd9cb // indirect
|
||||
gvisor.dev/gvisor v0.0.0-20250523182742-eede7a881b20 // indirect
|
||||
)
|
||||
|
||||
replace whitelist-bypass/relay => ../../relay
|
||||
@@ -0,0 +1,90 @@
|
||||
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
|
||||
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
|
||||
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/go-chi/chi/v5 v5.2.1 h1:KOIHODQj58PmL80G2Eak4WdvUzjSJSm0vG72crDCqb8=
|
||||
github.com/go-chi/chi/v5 v5.2.1/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops=
|
||||
github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4=
|
||||
github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
|
||||
github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
|
||||
github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0=
|
||||
github.com/go-gost/relay v0.5.0 h1:JG1tgy/KWiVXS0ukuVXvbM0kbYuJTWxYpJ5JwzsCf/c=
|
||||
github.com/go-gost/relay v0.5.0/go.mod h1:lcX+23LCQ3khIeASBo+tJ/WbwXFO32/N5YN6ucuYTG8=
|
||||
github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg=
|
||||
github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/schema v1.4.1 h1:jUg5hUjCSDZpNGLuXQOgIWGdlgrIdYvgQ0wZtdK1M3E=
|
||||
github.com/gorilla/schema v1.4.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM=
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/pion/datachannel v1.6.0 h1:XecBlj+cvsxhAMZWFfFcPyUaDZtd7IJvrXqlXD/53i0=
|
||||
github.com/pion/datachannel v1.6.0/go.mod h1:ur+wzYF8mWdC+Mkis5Thosk+u/VOL287apDNEbFpsIk=
|
||||
github.com/pion/dtls/v3 v3.1.2 h1:gqEdOUXLtCGW+afsBLO0LtDD8GnuBBjEy6HRtyofZTc=
|
||||
github.com/pion/dtls/v3 v3.1.2/go.mod h1:Hw/igcX4pdY69z1Hgv5x7wJFrUkdgHwAn/Q/uo7YHRo=
|
||||
github.com/pion/ice/v4 v4.2.1 h1:XPRYXaLiFq3LFDG7a7bMrmr3mFr27G/gtXN3v/TVfxY=
|
||||
github.com/pion/ice/v4 v4.2.1/go.mod h1:2quLV1S5v1tAx3VvAJaH//KGitRXvo4RKlX6D3tnN+c=
|
||||
github.com/pion/interceptor v0.1.44 h1:sNlZwM8dWXU9JQAkJh8xrarC0Etn8Oolcniukmuy0/I=
|
||||
github.com/pion/interceptor v0.1.44/go.mod h1:4atVlBkcgXuUP+ykQF0qOCGU2j7pQzX2ofvPRFsY5RY=
|
||||
github.com/pion/logging v0.2.4 h1:tTew+7cmQ+Mc1pTBLKH2puKsOvhm32dROumOZ655zB8=
|
||||
github.com/pion/logging v0.2.4/go.mod h1:DffhXTKYdNZU+KtJ5pyQDjvOAh/GsNSyv1lbkFbe3so=
|
||||
github.com/pion/mdns/v2 v2.1.0 h1:3IJ9+Xio6tWYjhN6WwuY142P/1jA0D5ERaIqawg/fOY=
|
||||
github.com/pion/mdns/v2 v2.1.0/go.mod h1:pcez23GdynwcfRU1977qKU0mDxSeucttSHbCSfFOd9A=
|
||||
github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
|
||||
github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8=
|
||||
github.com/pion/rtcp v1.2.16 h1:fk1B1dNW4hsI78XUCljZJlC4kZOPk67mNRuQ0fcEkSo=
|
||||
github.com/pion/rtcp v1.2.16/go.mod h1:/as7VKfYbs5NIb4h6muQ35kQF/J0ZVNz2Z3xKoCBYOo=
|
||||
github.com/pion/rtp v1.10.1 h1:xP1prZcCTUuhO2c83XtxyOHJteISg6o8iPsE2acaMtA=
|
||||
github.com/pion/rtp v1.10.1/go.mod h1:rF5nS1GqbR7H/TCpKwylzeq6yDM+MM6k+On5EgeThEM=
|
||||
github.com/pion/sctp v1.9.2 h1:HxsOzEV9pWoeggv7T5kewVkstFNcGvhMPx0GvUOUQXo=
|
||||
github.com/pion/sctp v1.9.2/go.mod h1:OTOlsQ5EDQ6mQ0z4MUGXt2CgQmKyafBEXhUVqLRB6G8=
|
||||
github.com/pion/sdp/v3 v3.0.18 h1:l0bAXazKHpepazVdp+tPYnrsy9dfh7ZbT8DxesH5ZnI=
|
||||
github.com/pion/sdp/v3 v3.0.18/go.mod h1:ZREGo6A9ZygQ9XkqAj5xYCQtQpif0i6Pa81HOiAdqQ8=
|
||||
github.com/pion/srtp/v3 v3.0.10 h1:tFirkpBb3XccP5VEXLi50GqXhv5SKPxqrdlhDCJlZrQ=
|
||||
github.com/pion/srtp/v3 v3.0.10/go.mod h1:3mOTIB0cq9qlbn59V4ozvv9ClW/BSEbRp4cY0VtaR7M=
|
||||
github.com/pion/stun/v3 v3.1.1 h1:CkQxveJ4xGQjulGSROXbXq94TAWu8gIX2dT+ePhUkqw=
|
||||
github.com/pion/stun/v3 v3.1.1/go.mod h1:qC1DfmcCTQjl9PBaMa5wSn3x9IPmKxSdcCsxBcDBndM=
|
||||
github.com/pion/transport/v3 v3.1.1 h1:Tr684+fnnKlhPceU+ICdrw6KKkTms+5qHMgw6bIkYOM=
|
||||
github.com/pion/transport/v3 v3.1.1/go.mod h1:+c2eewC5WJQHiAA46fkMMzoYZSuGzA/7E2FPrOYHctQ=
|
||||
github.com/pion/transport/v4 v4.0.1 h1:sdROELU6BZ63Ab7FrOLn13M6YdJLY20wldXW2Cu2k8o=
|
||||
github.com/pion/transport/v4 v4.0.1/go.mod h1:nEuEA4AD5lPdcIegQDpVLgNoDGreqM/YqmEx3ovP4jM=
|
||||
github.com/pion/turn/v4 v4.1.4 h1:EU11yMXKIsK43FhcUnjLlrhE4nboHZq+TXBIi3QpcxQ=
|
||||
github.com/pion/turn/v4 v4.1.4/go.mod h1:ES1DXVFKnOhuDkqn9hn5VJlSWmZPaRJLyBXoOeO/BmQ=
|
||||
github.com/pion/webrtc/v4 v4.2.9 h1:DZIh1HAhPIL3RvwEDFsmL5hfPSLEpxsQk9/Jir2vkJE=
|
||||
github.com/pion/webrtc/v4 v4.2.9/go.mod h1:9EmLZve0H76eTzf8v2FmchZ6tcBXtDgpfTEu+drW6SY=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/wlynxg/anet v0.0.5 h1:J3VJGi1gvo0JwZ/P1/Yc/8p63SoW98B5dHkYDmpgvvU=
|
||||
github.com/wlynxg/anet v0.0.5/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
|
||||
github.com/xjasonlyu/tun2socks/v2 v2.6.0 h1:gI9saJT3XgH4e6v9jBuHRLwK7l3aN9YFWec/SsDTDx4=
|
||||
github.com/xjasonlyu/tun2socks/v2 v2.6.0/go.mod h1:35AwqxIxnMkfBfT0UJ1Lku7PZm2ZiZJ8sxHyp0gt1yw=
|
||||
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
|
||||
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4=
|
||||
golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA=
|
||||
golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0=
|
||||
golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw=
|
||||
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
|
||||
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0=
|
||||
golang.org/x/time v0.11.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
|
||||
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeunTOisW56dUokqW/FOteYJJ/yg=
|
||||
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI=
|
||||
golang.zx2c4.com/wireguard v0.0.0-20250521234502-f333402bd9cb h1:whnFRlWMcXI9d+ZbWg+4sHnLp52d5yiIPUxMBSt4X9A=
|
||||
golang.zx2c4.com/wireguard v0.0.0-20250521234502-f333402bd9cb/go.mod h1:rpwXGsirqLqN2L0JDJQlwOboGHmptD5ZD6T2VmcqhTw=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gvisor.dev/gvisor v0.0.0-20250523182742-eede7a881b20 h1:0DxLu8hxI1OGp1qVRPqNd+2k1a7hMNUNqbZG0IrtKlM=
|
||||
gvisor.dev/gvisor v0.0.0-20250523182742-eede7a881b20/go.mod h1:3r5CMtNQMKIvBlrmM9xWUNamjKBYPOWyXOjmg5Kts3g=
|
||||
@@ -0,0 +1,394 @@
|
||||
// Command windows-joiner is the engine behind the Windows joiner GUI.
|
||||
// It runs a headless WB Stream or Telemost joiner exactly like the
|
||||
// Linux CLIs in headless/{wbstream,telemost}-joiner, but additionally
|
||||
// brings up a wintun adapter so every IP packet on the host is steered
|
||||
// through the resulting SOCKS5 proxy.
|
||||
//
|
||||
// It must run with administrator rights (the embedded manifest asks
|
||||
// for them); creating wintun adapters and editing the route table
|
||||
// both require elevation.
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
joinerCommon "whitelist-bypass/relay/pion/headless-joiner-common"
|
||||
"whitelist-bypass/relay/common"
|
||||
"whitelist-bypass/relay/pion"
|
||||
"whitelist-bypass/relay/tunnel"
|
||||
"whitelist-bypass/relay/wbstream"
|
||||
"whitelist-bypass/relay/wintunnel"
|
||||
)
|
||||
|
||||
type statusEmitter struct{}
|
||||
|
||||
func (statusEmitter) EmitStatus(status string) {
|
||||
log.Printf("[status] %s", status)
|
||||
// CAPTCHA:url is fired by the VK auth path when an interactive
|
||||
// captcha is required. The Electron wrapper watches stdout for
|
||||
// this exact prefix and opens a BrowserWindow at the URL.
|
||||
if strings.HasPrefix(status, "CAPTCHA:") {
|
||||
fmt.Printf("STATUS:%s\n", status)
|
||||
}
|
||||
}
|
||||
func (statusEmitter) EmitStatusError(msg string) { log.Printf("[status] ERROR: %s", msg) }
|
||||
|
||||
type fileCacheStore struct{ dir string }
|
||||
|
||||
func newFileCacheStore() *fileCacheStore {
|
||||
dir, _ := os.UserCacheDir()
|
||||
if dir == "" {
|
||||
dir = os.TempDir()
|
||||
}
|
||||
cacheDir := filepath.Join(dir, "whitelist-bypass")
|
||||
os.MkdirAll(cacheDir, 0755)
|
||||
return &fileCacheStore{dir: cacheDir}
|
||||
}
|
||||
|
||||
func (c *fileCacheStore) Save(key, value string) {
|
||||
os.WriteFile(filepath.Join(c.dir, key), []byte(value), 0644)
|
||||
}
|
||||
|
||||
func (c *fileCacheStore) Load(key string) string {
|
||||
data, err := os.ReadFile(filepath.Join(c.dir, key))
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return string(data)
|
||||
}
|
||||
|
||||
const (
|
||||
tunAdapter = "WhitelistBypass"
|
||||
tunIP = "10.99.0.2"
|
||||
tunMask = "255.255.255.0"
|
||||
tunPeer = "10.99.0.1"
|
||||
tunMTU = 1500
|
||||
)
|
||||
|
||||
func main() {
|
||||
platform := flag.String("platform", "", "wbstream | telemost | vk (required)")
|
||||
link := flag.String("link", "", "WB Stream room link, Telemost join URI, or VK call link (required)")
|
||||
displayName := flag.String("name", "Joiner", "display name in the room")
|
||||
socksPort := flag.Int("socks-port", 1080, "local SOCKS5 port")
|
||||
socksUser := flag.String("socks-user", "", "optional SOCKS5 username")
|
||||
socksPass := flag.String("socks-pass", "", "optional SOCKS5 password")
|
||||
resources := flag.String("resources", "default", "moderate | default | unlimited")
|
||||
tunnelMode := flag.String("tunnel-mode", "video", "tunnel mode for WB Stream: video | dc")
|
||||
vp8FPS := flag.Int("vp8-fps", 24, "VP8 frame rate")
|
||||
vp8Batch := flag.Int("vp8-batch", 30, "VP8 batch multiplier")
|
||||
dns := flag.String("dns", "1.1.1.1,8.8.8.8", "comma-separated DNS servers for the tunnel adapter")
|
||||
noTun := flag.Bool("no-tun", false, "expose SOCKS5 only, do not bring up the wintun adapter")
|
||||
flag.Parse()
|
||||
|
||||
if *platform == "" || *link == "" {
|
||||
log.Fatal("--platform and --link are required")
|
||||
}
|
||||
|
||||
switch *resources {
|
||||
case "moderate":
|
||||
debug.SetMemoryLimit(64 << 20)
|
||||
case "default":
|
||||
debug.SetMemoryLimit(128 << 20)
|
||||
case "unlimited":
|
||||
debug.SetMemoryLimit(256 << 20)
|
||||
default:
|
||||
log.Fatalf("[config] unknown resources mode: %s", *resources)
|
||||
}
|
||||
common.MaskingEnabled = true
|
||||
|
||||
// One wintunnel.Tunnel covers both platforms. Created up-front so
|
||||
// signaling-host bypass routes can be installed before any platform
|
||||
// code touches the network.
|
||||
var tun *wintunnel.Tunnel
|
||||
if !*noTun {
|
||||
cfg := wintunnel.Config{
|
||||
AdapterName: tunAdapter,
|
||||
TunnelIP: tunIP,
|
||||
TunnelMask: tunMask,
|
||||
TunnelPeer: tunPeer,
|
||||
MTU: tunMTU,
|
||||
DNSServers: splitCSV(*dns),
|
||||
SocksHost: "127.0.0.1",
|
||||
SocksPort: *socksPort,
|
||||
SocksUser: *socksUser,
|
||||
SocksPass: *socksPass,
|
||||
LogFn: log.Printf,
|
||||
}
|
||||
var err error
|
||||
tun, err = wintunnel.New(cfg)
|
||||
if err != nil {
|
||||
log.Fatalf("[wintunnel] init: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Add bypass routes for the signaling hosts before any traffic
|
||||
// from the joiner reaches them. These are needed even before
|
||||
// engine.Start, because the joiner opens its WebSocket as soon
|
||||
// as we call Start() below.
|
||||
bypassHosts := signalingHosts(*platform, *link)
|
||||
preResolved := map[string][]net.IP{}
|
||||
for _, h := range bypassHosts {
|
||||
ips, err := net.LookupIP(h)
|
||||
if err != nil {
|
||||
log.Printf("[bypass] resolve %s: %v (will rely on candidate hook)", h, err)
|
||||
continue
|
||||
}
|
||||
preResolved[h] = ips
|
||||
log.Printf("[bypass] %s -> %v (pre-tun)", h, ips)
|
||||
}
|
||||
|
||||
sig := make(chan os.Signal, 1)
|
||||
signal.Notify(sig, os.Interrupt, syscall.SIGTERM)
|
||||
|
||||
tunReady := make(chan struct{})
|
||||
var tunOnce sync.Once
|
||||
bringUpTun := func() {
|
||||
tunOnce.Do(func() {
|
||||
if tun == nil {
|
||||
close(tunReady)
|
||||
return
|
||||
}
|
||||
if err := tun.Start(); err != nil {
|
||||
log.Fatalf("[wintunnel] start: %v", err)
|
||||
}
|
||||
// Now that the tunnel knows the original gateway,
|
||||
// pin /32 bypass routes for the signaling hosts.
|
||||
for host, ips := range preResolved {
|
||||
for _, ip := range ips {
|
||||
if err := tun.AddBypassIP(ip); err != nil {
|
||||
log.Printf("[bypass] %s ip %s: %v", host, ip, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Printf("\n TUNNEL ACTIVE on adapter %q (DNS=%s)\n all traffic now egresses via %s\n\n",
|
||||
tunAdapter, *dns, *platform)
|
||||
close(tunReady)
|
||||
})
|
||||
}
|
||||
|
||||
addCandidate := func(target int, candidateOrSDP string) {
|
||||
if tun == nil {
|
||||
return
|
||||
}
|
||||
if err := tun.AddBypassFromCandidate(candidateOrSDP); err != nil {
|
||||
log.Printf("[bypass] candidate: %v", err)
|
||||
}
|
||||
// SDP path: scan every candidate line in the blob
|
||||
if strings.Contains(candidateOrSDP, "a=candidate:") {
|
||||
for _, line := range strings.Split(candidateOrSDP, "\n") {
|
||||
line = strings.TrimRight(line, "\r")
|
||||
if strings.HasPrefix(line, "a=candidate:") {
|
||||
if err := tun.AddBypassFromCandidate(line); err != nil {
|
||||
log.Printf("[bypass] sdp candidate: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onConnected := func(t tunnel.DataTunnel) {
|
||||
readBuf := common.VP8BufSize
|
||||
if _, ok := t.(*tunnel.DCTunnel); ok {
|
||||
readBuf = common.DCBufSize
|
||||
}
|
||||
bridge := tunnel.NewRelayBridgeWithAuth(t, "joiner", readBuf, log.Printf, *socksUser, *socksPass)
|
||||
bridge.MarkReady()
|
||||
addr := fmt.Sprintf("127.0.0.1:%d", *socksPort)
|
||||
go func() {
|
||||
if err := bridge.ListenSOCKS(addr); err != nil {
|
||||
log.Printf("[socks] listen: %v", err)
|
||||
}
|
||||
}()
|
||||
log.Printf("[socks] listening on %s", addr)
|
||||
// SOCKS5 is up; bring up wintun so the OS starts steering
|
||||
// traffic into it. Doing this after the joiner has connected
|
||||
// also means we already have remote candidates and bypass
|
||||
// routes are in place.
|
||||
bringUpTun()
|
||||
}
|
||||
|
||||
switch strings.ToLower(*platform) {
|
||||
case "wbstream", "wb":
|
||||
runWBStream(*link, *displayName, *tunnelMode, *vp8FPS, *vp8Batch,
|
||||
onConnected, addCandidate)
|
||||
case "telemost", "tm":
|
||||
runTelemost(*link, *displayName, *vp8FPS, *vp8Batch,
|
||||
onConnected, addCandidate)
|
||||
case "vk":
|
||||
runVK(*link, *displayName, *tunnelMode, *vp8FPS, *vp8Batch,
|
||||
onConnected, addCandidate)
|
||||
default:
|
||||
log.Fatalf("[config] unknown --platform %q", *platform)
|
||||
}
|
||||
|
||||
<-sig
|
||||
log.Printf("[main] shutting down")
|
||||
if tun != nil {
|
||||
tun.Stop()
|
||||
}
|
||||
// Give in-flight goroutines a beat to drain before the process exits.
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
}
|
||||
|
||||
func splitCSV(s string) []string {
|
||||
var out []string
|
||||
for _, p := range strings.Split(s, ",") {
|
||||
p = strings.TrimSpace(p)
|
||||
if p != "" {
|
||||
out = append(out, p)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func signalingHosts(platform, link string) []string {
|
||||
switch strings.ToLower(platform) {
|
||||
case "wbstream", "wb":
|
||||
return []string{"stream.wb.ru", "wbstream01-el.wb.ru"}
|
||||
case "telemost", "tm":
|
||||
hosts := []string{"telemost.yandex.ru", "telemost-api.yandex.ru"}
|
||||
if u, err := url.Parse(strings.TrimSpace(link)); err == nil && u.Host != "" {
|
||||
hosts = append(hosts, u.Host)
|
||||
}
|
||||
return hosts
|
||||
case "vk":
|
||||
hosts := []string{"vk.com", "login.vk.com", "api.vk.com", "ok.ru", "cloud-api.yandex.ru"}
|
||||
if u, err := url.Parse(strings.TrimSpace(link)); err == nil && u.Host != "" {
|
||||
hosts = append(hosts, u.Host)
|
||||
}
|
||||
return hosts
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func runWBStream(link, name, mode string, fps, batch int,
|
||||
onConnected func(tunnel.DataTunnel),
|
||||
onCandidate func(int, string),
|
||||
) {
|
||||
id := strings.TrimPrefix(strings.TrimSpace(link), "wbstream://")
|
||||
roomID, roomToken, _, err := wbstream.AuthAndGetToken(nil, id, name)
|
||||
if err != nil {
|
||||
log.Fatalf("[wb] auth: %v", err)
|
||||
}
|
||||
log.Printf("[wb] room=%s mode=%s", roomID, mode)
|
||||
|
||||
obf, err := tunnel.NewTunnelObfuscator(tunnel.DeriveSecretFromJoinLink(roomID))
|
||||
if err != nil {
|
||||
log.Fatalf("[wb] obfuscator: %v", err)
|
||||
}
|
||||
|
||||
sess := wbstream.NewSession(wbstream.SessionConfig{
|
||||
RoomToken: roomToken,
|
||||
DisplayName: name,
|
||||
TunnelMode: mode,
|
||||
Obfuscator: obf,
|
||||
LogFn: log.Printf,
|
||||
VP8FPS: fps,
|
||||
VP8Batch: batch,
|
||||
})
|
||||
sess.OnConnected = onConnected
|
||||
sess.OnRemoteCandidate = onCandidate
|
||||
|
||||
if err := sess.Start(); err != nil {
|
||||
log.Fatalf("[wb] session: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func runTelemost(link, name string, fps, batch int,
|
||||
onConnected func(tunnel.DataTunnel),
|
||||
onCandidate func(int, string),
|
||||
) {
|
||||
inner := joinerCommon.NewTelemostHeadlessJoiner(
|
||||
log.Printf,
|
||||
resolveHostname,
|
||||
statusEmitter{},
|
||||
nil,
|
||||
pion.AddTunnelTracks,
|
||||
pion.ReadTrack,
|
||||
)
|
||||
inner.OnConnected = onConnected
|
||||
inner.OnRemoteCandidate = onCandidate
|
||||
|
||||
params, _ := json.Marshal(struct {
|
||||
JoinLink string `json:"joinLink"`
|
||||
DisplayName string `json:"displayName"`
|
||||
VP8FPS int `json:"vp8Fps"`
|
||||
VP8Batch int `json:"vp8Batch"`
|
||||
}{
|
||||
JoinLink: strings.TrimSpace(link),
|
||||
DisplayName: name,
|
||||
VP8FPS: fps,
|
||||
VP8Batch: batch,
|
||||
})
|
||||
go inner.RunWithParams(string(params))
|
||||
}
|
||||
|
||||
func runVK(link, name, mode string, fps, batch int,
|
||||
onConnected func(tunnel.DataTunnel),
|
||||
onCandidate func(int, string),
|
||||
) {
|
||||
emitter := statusEmitter{}
|
||||
statusFn := func(s string) { emitter.EmitStatus(s) }
|
||||
|
||||
authJSON, err := joinerCommon.RunVKAuth(strings.TrimSpace(link), name,
|
||||
log.Printf, statusFn, newFileCacheStore(), resolveHostname)
|
||||
if err != nil {
|
||||
log.Fatalf("[vk] auth: %v", err)
|
||||
}
|
||||
|
||||
var authParams map[string]interface{}
|
||||
if json.Unmarshal([]byte(authJSON), &authParams) != nil {
|
||||
log.Fatalf("[vk] auth response not JSON: %s", authJSON)
|
||||
}
|
||||
authParams["tunnelMode"] = mode
|
||||
authParams["vp8Fps"] = fps
|
||||
authParams["vp8Batch"] = batch
|
||||
patched, err := json.Marshal(authParams)
|
||||
if err != nil {
|
||||
log.Fatalf("[vk] auth marshal: %v", err)
|
||||
}
|
||||
|
||||
inner := joinerCommon.NewVKHeadlessJoiner(
|
||||
log.Printf,
|
||||
resolveHostname,
|
||||
emitter,
|
||||
nil,
|
||||
pion.AddTunnelTracks,
|
||||
pion.ReadTrack,
|
||||
)
|
||||
inner.OnConnected = onConnected
|
||||
inner.OnRemoteCandidate = onCandidate
|
||||
go inner.RunWithParams(string(patched))
|
||||
}
|
||||
|
||||
func resolveHostname(hostname string) (string, error) {
|
||||
if ip := net.ParseIP(hostname); ip != nil {
|
||||
return hostname, nil
|
||||
}
|
||||
ips, err := net.LookupIP(hostname)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
for _, ip := range ips {
|
||||
if v4 := ip.To4(); v4 != nil {
|
||||
return v4.String(), nil
|
||||
}
|
||||
}
|
||||
for _, ip := range ips {
|
||||
return ip.String(), nil
|
||||
}
|
||||
return "", fmt.Errorf("no IPs for %s", hostname)
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="whitelist.bypass.windows-joiner"
|
||||
version="1.0.0.0"
|
||||
processorArchitecture="*"/>
|
||||
<description>Whitelist Bypass Windows Joiner</description>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- Windows 10/11 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||
</application>
|
||||
</compatibility>
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
</assembly>
|
||||
@@ -18,6 +18,10 @@ echo ""
|
||||
echo "=== Building Linux headless joiners ==="
|
||||
"$ROOT/build-joiners.sh"
|
||||
|
||||
echo ""
|
||||
echo "=== Building Windows joiner (Go binary + wintun.dll) ==="
|
||||
"$ROOT/build-windows-joiner.sh"
|
||||
|
||||
echo ""
|
||||
echo "=== Building Linux headless-vk-bot ==="
|
||||
"$ROOT/build-bot.sh"
|
||||
|
||||
@@ -77,6 +77,15 @@ type Client struct {
|
||||
OnDataChannel func(*webrtc.DataChannel)
|
||||
OnPubConnected func()
|
||||
OnParticipantUpdate func([]ParticipantInfo)
|
||||
// OnRemoteCandidate fires once for every trickle ICE candidate
|
||||
// arriving from the SFU. Used by the Windows joiner to install
|
||||
// /32 bypass routes so the joiner's own media flows stay on the
|
||||
// physical NIC instead of recursing through the tunnel.
|
||||
OnRemoteCandidate func(target int, candidate webrtc.ICECandidateInit)
|
||||
// OnRemoteSDP fires when the SFU sends an SDP offer or answer.
|
||||
// The SDP itself can carry candidates inline; the Windows joiner
|
||||
// uses this to bypass them before any media starts flowing.
|
||||
OnRemoteSDP func(target int, sdpType, sdp string)
|
||||
}
|
||||
|
||||
func NewClient(cfg Config) *Client {
|
||||
@@ -362,6 +371,9 @@ func (c *Client) handleSignal(data []byte) {
|
||||
}
|
||||
|
||||
func (c *Client) applyPubAnswer(sdp string) {
|
||||
if c.OnRemoteSDP != nil {
|
||||
c.OnRemoteSDP(TargetPublisher, "answer", sdp)
|
||||
}
|
||||
c.pubMu.Lock()
|
||||
defer c.pubMu.Unlock()
|
||||
if c.pubPC == nil {
|
||||
@@ -375,6 +387,9 @@ func (c *Client) applyPubAnswer(sdp string) {
|
||||
}
|
||||
|
||||
func (c *Client) applySubOfferAndAnswer(sdp string) {
|
||||
if c.OnRemoteSDP != nil {
|
||||
c.OnRemoteSDP(TargetSubscriber, "offer", sdp)
|
||||
}
|
||||
c.subMu.Lock()
|
||||
defer c.subMu.Unlock()
|
||||
if c.subPC == nil {
|
||||
@@ -408,6 +423,9 @@ func (c *Client) applyRemoteTrickle(m trickleMsg) {
|
||||
c.logFn("[lk] decode trickle candidate: %v", err)
|
||||
return
|
||||
}
|
||||
if c.OnRemoteCandidate != nil {
|
||||
c.OnRemoteCandidate(m.Target, ic)
|
||||
}
|
||||
switch m.Target {
|
||||
case TargetPublisher:
|
||||
c.pubMu.Lock()
|
||||
|
||||
@@ -29,6 +29,12 @@ const (
|
||||
type TelemostHeadlessJoiner struct {
|
||||
logFn func(string, ...any)
|
||||
OnConnected func(tunnel.DataTunnel)
|
||||
// OnRemoteCandidate is fired for every trickle ICE candidate the
|
||||
// Telemost SFU sends, and once per incoming SDP (target=-1) so
|
||||
// callers can extract any candidates carried inline. The Windows
|
||||
// joiner uses these to install /32 bypass routes before the
|
||||
// candidate is added to Pion's PeerConnection.
|
||||
OnRemoteCandidate func(target int, candidateOrSDP string)
|
||||
ResolveFn ResolveFunc
|
||||
Status StatusEmitter
|
||||
PCConfig PeerConnectionConfigurer
|
||||
@@ -442,6 +448,9 @@ func (j *TelemostHeadlessJoiner) handlePubAnswer(sdp string) {
|
||||
if j.pubPC == nil {
|
||||
return
|
||||
}
|
||||
if j.OnRemoteCandidate != nil {
|
||||
j.OnRemoteCandidate(-1, sdp)
|
||||
}
|
||||
err := j.pubPC.SetRemoteDescription(webrtc.SessionDescription{
|
||||
Type: webrtc.SDPTypeAnswer,
|
||||
SDP: sdp,
|
||||
@@ -476,6 +485,9 @@ func (j *TelemostHeadlessJoiner) handleSubOffer(sdp string, pcSeq int) {
|
||||
j.logFn("telemost-joiner: sub PC not ready for offer")
|
||||
return
|
||||
}
|
||||
if j.OnRemoteCandidate != nil {
|
||||
j.OnRemoteCandidate(-1, sdp)
|
||||
}
|
||||
|
||||
err := j.subPC.SetRemoteDescription(webrtc.SessionDescription{
|
||||
Type: webrtc.SDPTypeOffer,
|
||||
@@ -553,6 +565,14 @@ func (j *TelemostHeadlessJoiner) handleMessage(raw []byte) {
|
||||
idx := uint16(sdpIdx)
|
||||
cand := webrtc.ICECandidateInit{Candidate: candidate, SDPMid: &sdpMid, SDPMLineIndex: &idx}
|
||||
|
||||
if j.OnRemoteCandidate != nil {
|
||||
tgt := 1
|
||||
if target == "SUBSCRIBER" {
|
||||
tgt = 0
|
||||
}
|
||||
j.OnRemoteCandidate(tgt, candidate)
|
||||
}
|
||||
|
||||
if target == "SUBSCRIBER" {
|
||||
if j.subRemoteSet {
|
||||
j.subPC.AddICECandidate(cand)
|
||||
|
||||
@@ -47,6 +47,12 @@ type VKJoinResponse struct {
|
||||
type VKHeadlessJoiner struct {
|
||||
logFn func(string, ...any)
|
||||
OnConnected func(tunnel.DataTunnel)
|
||||
// OnRemoteCandidate is fired for every trickle ICE candidate the
|
||||
// VK SFU sends and once per incoming SDP (target=-1) so the caller
|
||||
// can extract any candidates carried inline. The Windows joiner
|
||||
// uses this to install /32 bypass routes before the candidate
|
||||
// reaches Pion.
|
||||
OnRemoteCandidate func(target int, candidateOrSDP string)
|
||||
ResolveFn ResolveFunc
|
||||
Status StatusEmitter
|
||||
PCConfig PeerConnectionConfigurer
|
||||
@@ -520,6 +526,9 @@ func (h *VKHeadlessJoiner) onTransmittedData(data map[string]interface{}) {
|
||||
candidateJSON, _ := json.Marshal(candidate)
|
||||
var candidateInit webrtc.ICECandidateInit
|
||||
json.Unmarshal(candidateJSON, &candidateInit)
|
||||
if h.OnRemoteCandidate != nil {
|
||||
h.OnRemoteCandidate(0, candidateInit.Candidate)
|
||||
}
|
||||
if h.remoteSet {
|
||||
h.pc.AddICECandidate(candidateInit)
|
||||
} else {
|
||||
@@ -530,6 +539,9 @@ func (h *VKHeadlessJoiner) onTransmittedData(data map[string]interface{}) {
|
||||
if sdp, ok := data["sdp"].(map[string]interface{}); ok {
|
||||
sdpType, _ := sdp["type"].(string)
|
||||
sdpStr, _ := sdp["sdp"].(string)
|
||||
if h.OnRemoteCandidate != nil {
|
||||
h.OnRemoteCandidate(-1, sdpStr)
|
||||
}
|
||||
h.logFn("headless: remote SDP: %s", sdpType)
|
||||
|
||||
if sdpType == "answer" {
|
||||
|
||||
@@ -66,6 +66,11 @@ type Session struct {
|
||||
|
||||
OnConnected func(tunnel.DataTunnel)
|
||||
OnPeerRestart func()
|
||||
// OnRemoteCandidate is forwarded from the underlying LiveKit client.
|
||||
// It fires for every trickle ICE candidate sent by the SFU, plus
|
||||
// once with target=-1 for every SDP description (carrying inline
|
||||
// candidates) before the description is applied to Pion.
|
||||
OnRemoteCandidate func(target int, candidateOrSDP string)
|
||||
}
|
||||
|
||||
func NewSession(cfg SessionConfig) *Session {
|
||||
@@ -95,6 +100,16 @@ func (s *Session) Start() error {
|
||||
if s.cfg.AccessToken != "" && s.cfg.RoomID != "" {
|
||||
s.lk.OnParticipantUpdate = s.onParticipantUpdate
|
||||
}
|
||||
s.lk.OnRemoteCandidate = func(target int, ic webrtc.ICECandidateInit) {
|
||||
if s.OnRemoteCandidate != nil {
|
||||
s.OnRemoteCandidate(target, ic.Candidate)
|
||||
}
|
||||
}
|
||||
s.lk.OnRemoteSDP = func(target int, _, sdp string) {
|
||||
if s.OnRemoteCandidate != nil {
|
||||
s.OnRemoteCandidate(-1, sdp)
|
||||
}
|
||||
}
|
||||
|
||||
if err := s.lk.Connect(); err != nil {
|
||||
return err
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
//go:build windows
|
||||
|
||||
package wintunnel
|
||||
|
||||
import (
|
||||
"net"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// extractCandidateIPs pulls every IPv4 literal out of one SDP candidate
|
||||
// line. ICE candidates look like
|
||||
//
|
||||
// candidate:1 1 udp 2122260223 18.197.224.5 49555 typ host
|
||||
// candidate:2 1 udp 1686052607 203.0.113.5 49555 typ srflx raddr 192.168.1.2 rport 50000
|
||||
//
|
||||
// We bypass every IP on the line because, at this point, we don't know
|
||||
// which one Pion will end up using. A handful of extra /32 host routes
|
||||
// is cheap.
|
||||
func extractCandidateIPs(line string) []net.IP {
|
||||
if line == "" {
|
||||
return nil
|
||||
}
|
||||
if strings.HasPrefix(line, "a=") {
|
||||
line = line[2:]
|
||||
}
|
||||
if !strings.HasPrefix(line, "candidate:") {
|
||||
return nil
|
||||
}
|
||||
parts := strings.Fields(line)
|
||||
var out []net.IP
|
||||
for i := 0; i < len(parts); i++ {
|
||||
ip := net.ParseIP(parts[i])
|
||||
if ip == nil {
|
||||
continue
|
||||
}
|
||||
v4 := ip.To4()
|
||||
if v4 == nil {
|
||||
continue
|
||||
}
|
||||
if v4.IsLoopback() || v4.IsLinkLocalUnicast() {
|
||||
continue
|
||||
}
|
||||
out = append(out, v4)
|
||||
}
|
||||
return dedupIPs(out)
|
||||
}
|
||||
|
||||
func dedupIPs(ips []net.IP) []net.IP {
|
||||
if len(ips) <= 1 {
|
||||
return ips
|
||||
}
|
||||
seen := make(map[string]struct{}, len(ips))
|
||||
out := ips[:0]
|
||||
for _, ip := range ips {
|
||||
k := ip.String()
|
||||
if _, ok := seen[k]; ok {
|
||||
continue
|
||||
}
|
||||
seen[k] = struct{}{}
|
||||
out = append(out, ip)
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Package wintunnel brings up a wintun adapter on Windows, configures
|
||||
// system-wide routing through it, and runs xjasonlyu/tun2socks as the
|
||||
// engine that forwards every IP packet to a local SOCKS5 proxy.
|
||||
//
|
||||
// The package is the Windows counterpart to relay/androidbind. Android
|
||||
// uses a VpnService fd plus addDisallowedApplication for the joiner's
|
||||
// own traffic; on Windows there is no per-process exclusion, so the
|
||||
// joiner's signaling and SFU media flows are kept off the tunnel by
|
||||
// installing /32 bypass routes through the original default gateway.
|
||||
//
|
||||
// All real work is in wintunnel_windows.go; the !windows build is a
|
||||
// stub so the relay module still compiles on macOS and Linux.
|
||||
package wintunnel
|
||||
@@ -0,0 +1,17 @@
|
||||
//go:build windows
|
||||
|
||||
package wintunnel
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// hideConsole sets CREATE_NO_WINDOW so netsh/route/powershell helpers
|
||||
// do not flash a cmd window when the joiner runs under Electron.
|
||||
func hideConsole(cmd *exec.Cmd) {
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
HideWindow: true,
|
||||
CreationFlags: 0x08000000, // CREATE_NO_WINDOW
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
//go:build windows
|
||||
|
||||
package wintunnel
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// runHidden invokes a command with no console window. All wintunnel
|
||||
// helpers use netsh / route / powershell here; subprocess parsing
|
||||
// avoids pulling in winipcfg-style cgo or large Go bindings.
|
||||
func runHidden(name string, args ...string) ([]byte, error) {
|
||||
cmd := exec.Command(name, args...)
|
||||
hideConsole(cmd)
|
||||
var out, errBuf bytes.Buffer
|
||||
cmd.Stdout = &out
|
||||
cmd.Stderr = &errBuf
|
||||
if err := cmd.Run(); err != nil {
|
||||
return out.Bytes(), fmt.Errorf("%s %s: %w (%s)",
|
||||
name, strings.Join(args, " "), err, strings.TrimSpace(errBuf.String()))
|
||||
}
|
||||
return out.Bytes(), nil
|
||||
}
|
||||
|
||||
// setAdapterIP gives the wintun adapter its tunnel IP.
|
||||
func setAdapterIP(adapter, ipStr, mask string) error {
|
||||
_, err := runHidden("netsh", "interface", "ipv4", "set", "address",
|
||||
"name="+adapter, "static", ipStr, mask)
|
||||
return err
|
||||
}
|
||||
|
||||
// setAdapterMTU sets the wintun adapter's MTU. netsh accepts this on
|
||||
// any IPv4-capable interface, including wintun.
|
||||
func setAdapterMTU(adapter string, mtu int) error {
|
||||
_, err := runHidden("netsh", "interface", "ipv4", "set", "subinterface",
|
||||
adapter, "mtu="+strconv.Itoa(mtu), "store=active")
|
||||
return err
|
||||
}
|
||||
|
||||
// setAdapterDNS pins resolvers onto the wintun adapter. Windows picks
|
||||
// resolvers per interface based on the routing decision, so this is
|
||||
// what makes DNS lookups from non-bypassed apps go through the tunnel.
|
||||
func setAdapterDNS(adapter string, servers []string) error {
|
||||
if len(servers) == 0 {
|
||||
return nil
|
||||
}
|
||||
if _, err := runHidden("netsh", "interface", "ipv4", "set", "dnsservers",
|
||||
"name="+adapter, "static", servers[0], "primary", "validate=no"); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, s := range servers[1:] {
|
||||
if _, err := runHidden("netsh", "interface", "ipv4", "add", "dnsservers",
|
||||
"name="+adapter, s, "validate=no"); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// addRouteViaAdapter installs a prefix route bound to the wintun
|
||||
// adapter. The nexthop must be on-link (typically TunnelPeer).
|
||||
func addRouteViaAdapter(prefix, adapter, nexthop string, metric int) error {
|
||||
_, err := runHidden("netsh", "interface", "ipv4", "add", "route",
|
||||
"prefix="+prefix, "interface="+adapter,
|
||||
"nexthop="+nexthop, "metric="+strconv.Itoa(metric),
|
||||
"store=active")
|
||||
return err
|
||||
}
|
||||
|
||||
func deleteRouteByPrefix(prefix, adapter string) error {
|
||||
_, err := runHidden("netsh", "interface", "ipv4", "delete", "route",
|
||||
"prefix="+prefix, "interface="+adapter)
|
||||
return err
|
||||
}
|
||||
|
||||
// addHostRoute installs a /32 route for ip via the given gateway. Used
|
||||
// for the joiner's signaling + SFU bypasses.
|
||||
func addHostRoute(ip, gateway string, metric int) error {
|
||||
_, err := runHidden("route", "-p", "ADD", ip,
|
||||
"MASK", "255.255.255.255", gateway,
|
||||
"METRIC", strconv.Itoa(metric))
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
// retry without persistence in case -p is rejected on this host
|
||||
_, err = runHidden("route", "ADD", ip,
|
||||
"MASK", "255.255.255.255", gateway,
|
||||
"METRIC", strconv.Itoa(metric))
|
||||
return err
|
||||
}
|
||||
|
||||
func deleteHostRoute(ip string) error {
|
||||
_, err := runHidden("route", "DELETE", ip)
|
||||
return err
|
||||
}
|
||||
|
||||
// adapterIPv4Index returns the InterfaceIndex of the wintun adapter
|
||||
// once netsh has assigned an IP to it. Best-effort; used only for logs.
|
||||
func adapterIPv4Index(adapter string) (uint32, error) {
|
||||
out, err := runHidden("powershell", "-NoProfile", "-Command",
|
||||
"(Get-NetAdapter -Name '"+adapter+"' -ErrorAction Stop).ifIndex")
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
v, err := strconv.ParseUint(strings.TrimSpace(string(out)), 10, 32)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return uint32(v), nil
|
||||
}
|
||||
|
||||
// defaultIPv4Gateway picks the active default route, excluding any
|
||||
// route that already points through our future wintun adapter. The
|
||||
// returned alias is the InterfaceAlias of that route's interface,
|
||||
// useful for logging.
|
||||
type psRoute struct {
|
||||
NextHop string `json:"NextHop"`
|
||||
InterfaceAlias string `json:"InterfaceAlias"`
|
||||
RouteMetric int `json:"RouteMetric"`
|
||||
}
|
||||
|
||||
func defaultIPv4Gateway() (gateway, alias string, err error) {
|
||||
out, err := runHidden("powershell", "-NoProfile", "-Command",
|
||||
"Get-NetRoute -DestinationPrefix '0.0.0.0/0' -AddressFamily IPv4 -ErrorAction Stop "+
|
||||
"| Sort-Object -Property RouteMetric "+
|
||||
"| Select-Object NextHop,InterfaceAlias,RouteMetric "+
|
||||
"| ConvertTo-Json -Compress")
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
body := bytes.TrimSpace(out)
|
||||
if len(body) == 0 {
|
||||
return "", "", fmt.Errorf("no default route on this host")
|
||||
}
|
||||
if body[0] == '{' {
|
||||
body = append([]byte{'['}, append(body, ']')...)
|
||||
}
|
||||
var rows []psRoute
|
||||
if err := json.Unmarshal(body, &rows); err != nil {
|
||||
return "", "", fmt.Errorf("parse Get-NetRoute output: %w", err)
|
||||
}
|
||||
for _, r := range rows {
|
||||
if r.NextHop == "" || r.NextHop == "0.0.0.0" {
|
||||
continue
|
||||
}
|
||||
if ip := net.ParseIP(r.NextHop); ip == nil {
|
||||
continue
|
||||
}
|
||||
return r.NextHop, r.InterfaceAlias, nil
|
||||
}
|
||||
return "", "", fmt.Errorf("no usable default route (out=%s)", string(out))
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
//go:build !windows
|
||||
|
||||
package wintunnel
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
)
|
||||
|
||||
var errUnsupported = errors.New("wintunnel: only supported on windows")
|
||||
|
||||
type Config struct {
|
||||
AdapterName string
|
||||
TunnelIP string
|
||||
TunnelMask string
|
||||
TunnelPeer string
|
||||
MTU int
|
||||
DNSServers []string
|
||||
SocksHost string
|
||||
SocksPort int
|
||||
SocksUser string
|
||||
SocksPass string
|
||||
LogFn func(format string, args ...any)
|
||||
}
|
||||
|
||||
type Tunnel struct{}
|
||||
|
||||
func New(_ Config) (*Tunnel, error) { return nil, errUnsupported }
|
||||
func (*Tunnel) Start() error { return errUnsupported }
|
||||
func (*Tunnel) Stop() {}
|
||||
func (*Tunnel) AddBypassIP(_ net.IP) error { return errUnsupported }
|
||||
func (*Tunnel) AddBypassHost(_ string) ([]net.IP, error) {
|
||||
return nil, errUnsupported
|
||||
}
|
||||
func (*Tunnel) AddBypassFromCandidate(_ string) error { return errUnsupported }
|
||||
@@ -0,0 +1,255 @@
|
||||
//go:build windows
|
||||
|
||||
package wintunnel
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"sync"
|
||||
|
||||
"github.com/xjasonlyu/tun2socks/v2/engine"
|
||||
)
|
||||
|
||||
// Config describes one wintun adapter and the SOCKS5 endpoint that
|
||||
// tun2socks should forward traffic to.
|
||||
type Config struct {
|
||||
// AdapterName is the wintun adapter name shown in Windows. Must be unique.
|
||||
AdapterName string
|
||||
// TunnelIP is the local address assigned to the adapter (e.g. 10.99.0.2).
|
||||
TunnelIP string
|
||||
// TunnelMask is the subnet mask as dotted-quad (e.g. 255.255.255.0).
|
||||
TunnelMask string
|
||||
// TunnelPeer is the on-link next-hop used by the default routes
|
||||
// installed on the wintun adapter (e.g. 10.99.0.1). It does not need
|
||||
// to answer; wintun is point-to-point so Windows does not ARP for it.
|
||||
TunnelPeer string
|
||||
// MTU for the wintun adapter. 1500 is fine for most networks.
|
||||
MTU int
|
||||
// DNSServers is the list of resolvers to assign to the adapter.
|
||||
DNSServers []string
|
||||
// SocksHost / SocksPort / SocksUser / SocksPass: the local SOCKS5
|
||||
// proxy that the headless joiner is running. tun2socks dials this
|
||||
// for every captured TCP/UDP flow.
|
||||
SocksHost string
|
||||
SocksPort int
|
||||
SocksUser string
|
||||
SocksPass string
|
||||
LogFn func(format string, args ...any)
|
||||
}
|
||||
|
||||
// Tunnel owns one wintun adapter and the tun2socks engine instance
|
||||
// driving it. Call New + Start to bring it up, Stop to tear it down.
|
||||
type Tunnel struct {
|
||||
cfg Config
|
||||
log func(string, ...any)
|
||||
|
||||
mu sync.Mutex
|
||||
started bool
|
||||
stopped bool
|
||||
bypass map[string]struct{} // /32 routes we installed for bypass
|
||||
origGateway string
|
||||
origIfAlias string
|
||||
tunIfIndex uint32
|
||||
}
|
||||
|
||||
// New validates a Config and returns a Tunnel ready to Start.
|
||||
func New(cfg Config) (*Tunnel, error) {
|
||||
if cfg.AdapterName == "" {
|
||||
return nil, errors.New("wintunnel: AdapterName required")
|
||||
}
|
||||
if cfg.TunnelIP == "" || cfg.TunnelMask == "" || cfg.TunnelPeer == "" {
|
||||
return nil, errors.New("wintunnel: TunnelIP, TunnelMask and TunnelPeer required")
|
||||
}
|
||||
if cfg.MTU <= 0 {
|
||||
cfg.MTU = 1500
|
||||
}
|
||||
if cfg.SocksHost == "" {
|
||||
cfg.SocksHost = "127.0.0.1"
|
||||
}
|
||||
if cfg.SocksPort <= 0 {
|
||||
return nil, errors.New("wintunnel: SocksPort required")
|
||||
}
|
||||
if cfg.LogFn == nil {
|
||||
cfg.LogFn = log.Printf
|
||||
}
|
||||
if len(cfg.DNSServers) == 0 {
|
||||
cfg.DNSServers = []string{"1.1.1.1", "8.8.8.8"}
|
||||
}
|
||||
return &Tunnel{
|
||||
cfg: cfg,
|
||||
log: cfg.LogFn,
|
||||
bypass: make(map[string]struct{}),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Start brings up the wintun adapter, captures the original default
|
||||
// gateway so subsequent AddBypass* calls can pin /32 routes to it,
|
||||
// configures the adapter, installs the split default route through
|
||||
// the tunnel, and starts the tun2socks engine. After Start returns,
|
||||
// every packet leaving the OS that does not match a bypass route
|
||||
// will be steered through SOCKS5.
|
||||
func (t *Tunnel) Start() error {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
if t.started {
|
||||
return errors.New("wintunnel: already started")
|
||||
}
|
||||
|
||||
gw, alias, err := defaultIPv4Gateway()
|
||||
if err != nil {
|
||||
return fmt.Errorf("wintunnel: read default gateway: %w", err)
|
||||
}
|
||||
t.origGateway = gw
|
||||
t.origIfAlias = alias
|
||||
t.log("[wintunnel] original default gateway %s via %q", gw, alias)
|
||||
|
||||
proxy := fmt.Sprintf("socks5://%s:%d", t.cfg.SocksHost, t.cfg.SocksPort)
|
||||
if t.cfg.SocksUser != "" {
|
||||
proxy = fmt.Sprintf("socks5://%s:%s@%s:%d",
|
||||
t.cfg.SocksUser, t.cfg.SocksPass, t.cfg.SocksHost, t.cfg.SocksPort)
|
||||
}
|
||||
key := &engine.Key{
|
||||
Proxy: proxy,
|
||||
Device: "tun://" + t.cfg.AdapterName,
|
||||
MTU: t.cfg.MTU,
|
||||
}
|
||||
t.log("[wintunnel] starting tun2socks engine adapter=%s mtu=%d proxy=%s",
|
||||
t.cfg.AdapterName, t.cfg.MTU, proxy)
|
||||
engine.Insert(key)
|
||||
engine.Start()
|
||||
|
||||
// adapter exists now; configure IP/MTU/DNS, install default routes
|
||||
if err := setAdapterIP(t.cfg.AdapterName, t.cfg.TunnelIP, t.cfg.TunnelMask); err != nil {
|
||||
engine.Stop()
|
||||
return fmt.Errorf("wintunnel: set adapter ip: %w", err)
|
||||
}
|
||||
if err := setAdapterMTU(t.cfg.AdapterName, t.cfg.MTU); err != nil {
|
||||
// non-fatal: log and continue
|
||||
t.log("[wintunnel] set mtu failed (continuing): %v", err)
|
||||
}
|
||||
if err := setAdapterDNS(t.cfg.AdapterName, t.cfg.DNSServers); err != nil {
|
||||
t.log("[wintunnel] set dns failed (continuing): %v", err)
|
||||
}
|
||||
idx, err := adapterIPv4Index(t.cfg.AdapterName)
|
||||
if err == nil {
|
||||
t.tunIfIndex = idx
|
||||
}
|
||||
|
||||
for _, prefix := range []string{"0.0.0.0/1", "128.0.0.0/1"} {
|
||||
if err := addRouteViaAdapter(prefix, t.cfg.AdapterName, t.cfg.TunnelPeer, 2); err != nil {
|
||||
t.log("[wintunnel] add default-half %s failed: %v", prefix, err)
|
||||
}
|
||||
}
|
||||
|
||||
t.started = true
|
||||
t.log("[wintunnel] up: adapter=%s ip=%s/%s peer=%s",
|
||||
t.cfg.AdapterName, t.cfg.TunnelIP, t.cfg.TunnelMask, t.cfg.TunnelPeer)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Stop removes every route we installed and shuts the wintun adapter
|
||||
// down. Safe to call from multiple goroutines and idempotent.
|
||||
func (t *Tunnel) Stop() {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
if !t.started || t.stopped {
|
||||
return
|
||||
}
|
||||
t.stopped = true
|
||||
|
||||
for ip := range t.bypass {
|
||||
if err := deleteHostRoute(ip); err != nil {
|
||||
t.log("[wintunnel] remove bypass route %s: %v", ip, err)
|
||||
}
|
||||
}
|
||||
t.bypass = nil
|
||||
|
||||
for _, prefix := range []string{"0.0.0.0/1", "128.0.0.0/1"} {
|
||||
if err := deleteRouteByPrefix(prefix, t.cfg.AdapterName); err != nil {
|
||||
t.log("[wintunnel] remove default-half %s: %v", prefix, err)
|
||||
}
|
||||
}
|
||||
|
||||
engine.Stop()
|
||||
t.log("[wintunnel] down")
|
||||
}
|
||||
|
||||
// AddBypassIP installs a /32 route for ip via the original default
|
||||
// gateway. Used so the joiner's own connections to signaling and SFU
|
||||
// hosts skip the tunnel and reach the real network directly.
|
||||
func (t *Tunnel) AddBypassIP(ip net.IP) error {
|
||||
if ip == nil {
|
||||
return errors.New("wintunnel: nil IP")
|
||||
}
|
||||
v4 := ip.To4()
|
||||
if v4 == nil {
|
||||
// IPv6 bypass is out of scope: the joiner negotiates v4 hosts
|
||||
return nil
|
||||
}
|
||||
addr := v4.String()
|
||||
t.mu.Lock()
|
||||
if _, dup := t.bypass[addr]; dup {
|
||||
t.mu.Unlock()
|
||||
return nil
|
||||
}
|
||||
gw := t.origGateway
|
||||
t.mu.Unlock()
|
||||
if gw == "" {
|
||||
return errors.New("wintunnel: original gateway unknown, start the tunnel first")
|
||||
}
|
||||
if err := addHostRoute(addr, gw, 1); err != nil {
|
||||
return fmt.Errorf("wintunnel: add bypass %s via %s: %w", addr, gw, err)
|
||||
}
|
||||
t.mu.Lock()
|
||||
t.bypass[addr] = struct{}{}
|
||||
t.mu.Unlock()
|
||||
t.log("[wintunnel] bypass %s -> %s", addr, gw)
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddBypassHost resolves hostname (system resolver, no tunnel) and
|
||||
// installs a /32 bypass route for every returned A record. The
|
||||
// resolved IPs are returned so callers can wire them into other
|
||||
// settings, e.g. a Pion ResolveICEHost callback.
|
||||
func (t *Tunnel) AddBypassHost(hostname string) ([]net.IP, error) {
|
||||
if ip := net.ParseIP(hostname); ip != nil {
|
||||
return []net.IP{ip}, t.AddBypassIP(ip)
|
||||
}
|
||||
ips, err := net.LookupIP(hostname)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("wintunnel: resolve %s: %w", hostname, err)
|
||||
}
|
||||
out := make([]net.IP, 0, len(ips))
|
||||
for _, ip := range ips {
|
||||
if v4 := ip.To4(); v4 != nil {
|
||||
if addErr := t.AddBypassIP(v4); addErr != nil {
|
||||
t.log("[wintunnel] bypass host %s ip %s: %v", hostname, v4, addErr)
|
||||
continue
|
||||
}
|
||||
out = append(out, v4)
|
||||
}
|
||||
}
|
||||
if len(out) == 0 {
|
||||
return nil, fmt.Errorf("wintunnel: no v4 addresses for %s", hostname)
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// AddBypassFromCandidate parses an SDP candidate line ("candidate:..."
|
||||
// or "a=candidate:...") and bypasses every IPv4 address found in it.
|
||||
// Both the relay address and the rel-addr (TURN reflexive) are honored.
|
||||
func (t *Tunnel) AddBypassFromCandidate(candidate string) error {
|
||||
ips := extractCandidateIPs(candidate)
|
||||
if len(ips) == 0 {
|
||||
return nil
|
||||
}
|
||||
var firstErr error
|
||||
for _, ip := range ips {
|
||||
if err := t.AddBypassIP(ip); err != nil && firstErr == nil {
|
||||
firstErr = err
|
||||
}
|
||||
}
|
||||
return firstErr
|
||||
}
|
||||
Reference in new issue
Block a user