* fix: prevent duplicate call link detection (#23)

Co-authored-by: Maksim <maksim@MacBook-Pro-Maksim.local>

* bot improvements (#25)

Co-authored-by: Maksim <maksim@MBP-Maksim.lan>

* headless vk video creator

* add scroll to logs

* allow peer reconnection

* add todo about topology changes, kick stale peer to prevent SFU topology

* unified relay for headless

* remove relay binaries, extend build-go.sh to build them

* refactor constants

* limit headless resource usage

* nuke everyone and yourself at sfu topology changes

* add headless for creator

* save bot enabled state

* increment release version

---------

Co-authored-by: Nevenuga <80585376+Nevenuga@users.noreply.github.com>
Co-authored-by: Maksim <maksim@MacBook-Pro-Maksim.local>
Co-authored-by: Maksim <maksim@MBP-Maksim.lan>
Co-authored-by: kulikov <user@Mac.lan>
This commit is contained in:
authored and GitHub committed 2026-04-02 22:52:56 +02:00
1 parent d6a98e84ee
commit c8e1ba444d
37 files changed
+2589 -133

No files matched your search

+155 -10
View File
@@ -1,9 +1,69 @@
const fetch = require('node-fetch');
function generateTabId(tabId) {
var hash = 0;
for (var i = 0; i < tabId.length; i++) {
hash = ((hash << 5) - hash) + tabId.charCodeAt(i);
hash = hash & hash;
}
return Math.abs(hash) % 10000;
}
function findTabById(tabsList, shortId) {
var targetId = parseInt(shortId, 10);
for (var i = 0; i < tabsList.length; i++) {
var t = tabsList[i];
if (generateTabId(t.id) === targetId) {
return t;
}
}
return null;
}
function createKeyboard() {
return {
one_time: false,
buttons: [
[
{ action: { type: 'text', label: '📞 VK DC', payload: JSON.stringify({ cmd: 'vk', mode: 'dc' }) } },
{ action: { type: 'text', label: '📹 VK Video', payload: JSON.stringify({ cmd: 'vk', mode: 'video' }) } }
],
[
{ action: { type: 'text', label: '📞 TM DC', payload: JSON.stringify({ cmd: 'tm', mode: 'dc' }) } },
{ action: { type: 'text', label: '📹 TM Video', payload: JSON.stringify({ cmd: 'tm', mode: 'video' }) } }
],
[
{ action: { type: 'text', label: '📋 Active Tabs', payload: JSON.stringify({ cmd: 'list' }) } }
]
]
};
}
function createListKeyboard(tabsList) {
var buttons = [];
for (var i = 0; i < tabsList.length; i++) {
var t = tabsList[i];
var shortId = generateTabId(t.id);
var paddedId = ('000' + shortId).slice(-4);
var prefix = t.isBot ? 'bot' : 'user';
var status = t.callStatus === 'active' ? '🟢' : '⚪';
buttons.push([
{ action: { type: 'text', label: prefix + ' ' + t.platform + ' ' + t.mode + ' ' + paddedId + ' ' + status, payload: JSON.stringify({ cmd: 'close', id: t.id }) } }
]);
}
buttons.push([{ action: { type: 'text', label: '◀️ Back', payload: JSON.stringify({ cmd: 'menu' }) } }]);
return {
one_time: false,
buttons: buttons
};
}
class BotManager {
constructor(settings, onCreateTab) {
constructor(settings, onCreateTab, onGetTabs, onCloseTab) {
this.settings = settings;
this.onCreateTab = onCreateTab;
this.onGetTabs = onGetTabs;
this.onCloseTab = onCloseTab;
this.baseUrl = 'https://api.vk.com/method';
this.ts = null;
this.key = null;
@@ -80,22 +140,70 @@ class BotManager {
async handleUpdate(update) {
if (update.type === 'message_new') {
const message = update.object.message;
const text = message.text || '';
var text = (message.text || '').trim();
const fromId = message.from_id;
const peerId = message.peer_id;
var payload = null;
if (message.payload) {
try {
payload = JSON.parse(message.payload);
console.log('[BOT] Payload from button:', payload);
} catch (e) {
console.log('[BOT] Failed to parse payload:', message.payload);
}
}
console.log('[BOT] Message from', fromId, ':', text, 'payload:', payload);
if (this.settings.userId && fromId.toString() !== this.settings.userId.toString()) {
return;
}
console.log('[BOT] Message from', fromId, ':', text);
if (text === '/start' || text === 'start') {
await this.showMenu(peerId);
return;
}
if (payload && payload.cmd) {
if (payload.cmd === 'list') {
await this.showList(peerId);
return;
} else if (payload.cmd === 'menu') {
await this.showMenu(peerId);
return;
} else if (payload.cmd === 'close') {
if (payload.id) {
var tabsList = this.onGetTabs ? this.onGetTabs() : [];
var foundTab = null;
for (var i = 0; i < tabsList.length; i++) {
if (tabsList[i].id === payload.id) {
foundTab = tabsList[i];
break;
}
}
if (foundTab && this.onCloseTab) {
var shortId = generateTabId(foundTab.id);
var paddedId = ('000' + shortId).slice(-4);
this.onCloseTab(foundTab.id);
await this.sendMessage(peerId, foundTab.platform + ' ' + foundTab.mode + ' ' + paddedId + ' closed', createKeyboard());
return;
}
}
return;
} else if (payload.cmd === 'vk') {
text = '/vk' + (payload.mode === 'video' ? ' video' : '');
} else if (payload.cmd === 'tm') {
text = '/tm' + (payload.mode === 'video' ? ' video' : '');
}
}
if (text.startsWith('/vk')) {
const mode = text.includes('video') ? 'pion-video' : 'dc';
console.log('[BOT] Creating VK tab with mode:', mode);
this.onCreateTab({ mode: mode, peerId: peerId, platform: 'vk' });
await this.sendMessage(peerId, 'Creating VK call (' + (mode === 'dc' ? 'DC' : 'Video') + ')...');
await this.sendMessage(peerId, 'Creating VK call (' + (mode === 'dc' ? 'DC' : 'Video') + ')', createKeyboard());
}
if (text.startsWith('/tm')) {
@@ -104,23 +212,60 @@ class BotManager {
this.onCreateTab({ mode: mode, peerId: peerId, platform: 'telemost' });
await this.sendMessage(peerId, 'Creating Telemost call (' + (mode === 'dc' ? 'DC' : 'Video') + ')...');
await this.sendMessage(peerId, 'Creating Telemost call (' + (mode === 'dc' ? 'DC' : 'Video') + ')', createKeyboard());
}
if (text === '/list') {
await this.showList(peerId);
}
if (text.startsWith('/close ')) {
var parts = text.split(' ');
var targetShortId = parts[1];
console.log('[BOT] Close request for ID:', targetShortId, 'from peer:', peerId);
var tabsList = this.onGetTabs ? this.onGetTabs() : [];
var foundTab = findTabById(tabsList, targetShortId);
if (!foundTab) {
await this.sendMessage(peerId, 'Tab ' + targetShortId + ' not found', createKeyboard());
} else if (this.onCloseTab) {
this.onCloseTab(foundTab.id);
await this.sendMessage(peerId, foundTab.platform + ' ' + foundTab.mode + ' ' + targetShortId + ' closed', createKeyboard());
}
}
}
}
async sendMessage(peerId, text) {
async sendMessage(peerId, text, keyboard = null) {
try {
await this.api('messages.send', {
var params = {
peer_id: peerId,
message: text,
random_id: Math.floor(Math.random() * 1e9)
});
};
if (keyboard) {
params.keyboard = JSON.stringify(keyboard);
}
await this.api('messages.send', params);
console.log('[BOT] Sent message to', peerId);
} catch (err) {
console.error('[BOT] Send message error:', err.message);
}
}
async showMenu(peerId) {
await this.sendMessage(peerId, '🤖 Select mode:', createKeyboard());
}
async showList(peerId) {
var tabsList = this.onGetTabs ? this.onGetTabs() : [];
if (tabsList.length === 0) {
await this.sendMessage(peerId, 'No active tabs', createKeyboard());
} else {
await this.sendMessage(peerId, 'Select tab to close:', createListKeyboard(tabsList));
}
}
}
module.exports = BotManager;
+24
View File
@@ -0,0 +1,24 @@
(function() {
if (window.__callCheckerStarted) return;
window.__callCheckerStarted = true;
var tabId = window.__CALL_CHECKER_TAB_ID || 'unknown';
console.log('[CALL_STATUS] Checker started for ' + tabId);
const checkCallStatus = () => {
var vkBtn = document.querySelector('button[data-testid="calls_call_footer_button_leave_call"]') ||
document.querySelector('[data-testid="calls_call_footer_button_leave_call"]');
var tmBtn = document.querySelector('[data-testid="end-call-alt-button"]') ||
document.querySelector('button[data-testid="end-call-alt-button"]');
var status = (vkBtn || tmBtn) ? 'active' : 'inactive';
console.log('[CALL_STATUS] ' + tabId + ':' + status);
};
setTimeout(function() {
checkCallStatus();
setInterval(checkCallStatus, 10000);
}, 10000);
})();
+129 -13
View File
@@ -61,6 +61,7 @@ body { font-family: -apple-system, sans-serif; background: #1a1a1a; color: #e0e0
<div class="tab-add" onclick="addTab()" title="New tab">+</div>
</div>
<div class="tab-bar-actions">
<div class="tab-settings" onclick="copyCookies()" title="Export VK cookies to cookies.json for headless mode" style="cursor:pointer">Export Cookies</div>
<div class="tab-settings" onclick="openSettings()" title="Settings">Settings</div>
<div class="tab-bot" id="tabBot" onclick="toggleBot()">Bot: Off</div>
</div>
@@ -68,6 +69,7 @@ body { font-family: -apple-system, sans-serif; background: #1a1a1a; color: #e0e0
<div class="toolbar" id="toolbar" style="display:none">
<button class="btn-vk" onclick="loadURL('https://vk.com/im')">VK</button>
<button class="btn-telemost" onclick="loadURL('https://telemost.yandex.ru/')">Telemost</button>
<button class="btn-vk" onclick="startHeadlessVK()" style="opacity:0.8">Headless VK</button>
<span style="margin-left:auto;font-size:11px;color:#888">Tunnel:</span>
<select id="modeSelect" style="padding:2px 6px;border:1px solid #555;border-radius:6px;font-size:11px;cursor:pointer;font-weight:500;background:#333;color:#e0e0e0;outline:none" onchange="onModeChange(this.value)">
<option value="dc">DC</option>
@@ -80,6 +82,17 @@ body { font-family: -apple-system, sans-serif; background: #1a1a1a; color: #e0e0
<h1>Whitelist Bypass - Creator</h1>
<p>Click + to add a tab</p>
</div>
<div class="headless-info" id="headlessInfo" style="display:none;padding:24px;color:#e0e0e0;font-family:monospace;font-size:14px">
<div style="font-size:18px;font-weight:bold;margin-bottom:16px">Headless VK</div>
<div id="headlessStatus" style="color:#888">Starting...</div>
<div id="headlessCallInfo" style="margin-top:16px;display:none">
<div style="margin-bottom:8px"><span style="color:#888">Join link:</span> <a id="headlessJoinLink" href="#" style="color:#4fc3f7;cursor:pointer" onclick="copyToClipboard(this.textContent)"></a></div>
<div style="margin-bottom:8px"><span style="color:#888">Short:</span> <a id="headlessShortLink" href="#" style="color:#4fc3f7;cursor:pointer" onclick="copyToClipboard(this.textContent)"></a></div>
<div style="margin-bottom:8px"><span style="color:#888">TURN:</span> <span id="headlessTurn"></span></div>
<div style="margin-bottom:8px"><span style="color:#888">Protocol:</span> <span id="headlessProtocol"></span></div>
</div>
<div id="headlessTunnel" style="margin-top:16px;display:none;color:#4caf50;font-weight:bold;font-size:16px">TUNNEL CONNECTED</div>
</div>
</div>
<div class="logs" id="logsPanel" style="display:none">
<div class="log-panel">
@@ -129,11 +142,27 @@ function closeError() {
window.bridge.onBotError(function(msg) {
showError(msg);
botRunning = false;
localStorage.setItem('botEnabled', 'false');
var btn = document.getElementById('tabBot');
btn.textContent = 'Bot: Off';
btn.classList.remove('running');
});
function copyCookies() {
window.bridge.getCookies('.vk.com').then(function(cookies) {
if (!cookies.length) {
showError('No VK cookies found.\nPlease log into VK first.');
return;
}
var simple = cookies.map(function(c) { return { name: c.name, value: c.value }; });
var blob = new Blob([JSON.stringify(simple, null, 2)], { type: 'application/json' });
var link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'cookies.json';
link.click();
});
}
var tabsState = {}; // tabId -> { wv, mode, relayLogs, hookLogs }
var activeTabId = null;
var nextTabId = 1;
@@ -142,6 +171,14 @@ var botRunning = false;
var savedSettings = localStorage.getItem('botSettings');
var botSettings = savedSettings ? JSON.parse(savedSettings) : { token: '', groupId: '', userId: '' };
if (localStorage.getItem('botEnabled') === 'true' && botSettings.token && botSettings.groupId) {
botRunning = true;
var btn = document.getElementById('tabBot');
btn.textContent = 'Bot: On';
btn.classList.add('running');
window.bridge.startBot(botSettings);
}
function openSettings() {
document.getElementById('settingsPopup').classList.add('visible');
document.getElementById('vkToken').value = botSettings.token;
@@ -168,6 +205,7 @@ function toggleBot() {
return;
}
botRunning = !botRunning;
localStorage.setItem('botEnabled', botRunning ? 'true' : 'false');
var btn = document.getElementById('tabBot');
if (botRunning) {
btn.textContent = 'Bot: On';
@@ -182,12 +220,20 @@ function toggleBot() {
function addTab() {
var tabId = 'tab-' + (nextTabId++);
tabsState[tabId] = { wv: null, url: '', mode: 'dc', relayLogs: '', hookLogs: '', name: '' };
tabsState[tabId] = { wv: null, url: '', mode: 'dc', relayLogs: '', hookLogs: '', name: '', isBot: false };
window.bridge.startRelay(tabId);
renderTabs();
selectTab(tabId);
}
function startHeadlessVK() {
var tabId = 'tab-' + (nextTabId++);
tabsState[tabId] = { wv: null, url: '', mode: 'headless-vk', relayLogs: '', hookLogs: '', name: 'Headless VK', isBot: false, headless: true };
window.bridge.startHeadless(tabId);
renderTabs();
selectTab(tabId);
}
function closeTab(tabId, e) {
if (e) e.stopPropagation();
var t = tabsState[tabId];
@@ -262,7 +308,6 @@ function renderContent() {
var welcome = document.getElementById('welcome');
var toolbar = document.getElementById('toolbar');
var logsPanel = document.getElementById('logsPanel');
// Hide all webviews
var wvs = content.querySelectorAll('webview');
for (var i = 0; i < wvs.length; i++) wvs[i].classList.add('hidden');
@@ -273,14 +318,33 @@ function renderContent() {
return;
}
welcome.style.display = 'none';
toolbar.style.display = 'flex';
logsPanel.style.display = 'flex';
var t = tabsState[activeTabId];
document.getElementById('modeSelect').value = t.mode;
var headlessInfo = document.getElementById('headlessInfo');
if (t.headless) {
toolbar.style.display = 'none';
headlessInfo.style.display = 'block';
document.getElementById('headlessStatus').textContent = t.headlessStatus || 'Starting...';
var ci = t.callInfo;
if (ci) {
document.getElementById('headlessCallInfo').style.display = 'block';
document.getElementById('headlessJoinLink').textContent = ci.joinLink || '';
document.getElementById('headlessShortLink').textContent = ci.shortLink || '';
document.getElementById('headlessTurn').textContent = ci.turn || '';
document.getElementById('headlessProtocol').textContent = ci.protocol || '';
} else {
document.getElementById('headlessCallInfo').style.display = 'none';
}
document.getElementById('headlessTunnel').style.display = t.tunnelConnected ? 'block' : 'none';
} else {
toolbar.style.display = 'flex';
headlessInfo.style.display = 'none';
document.getElementById('modeSelect').value = t.mode;
if (t.wv) t.wv.classList.remove('hidden');
}
document.getElementById('relayLog').textContent = t.relayLogs || '';
document.getElementById('hookLog').textContent = t.hookLogs || '';
if (t.wv) t.wv.classList.remove('hidden');
scrollLogs();
}
@@ -313,7 +377,17 @@ function loadURL(url) {
window.bridge.getHookCode(tabId, wv.getURL()).then(function(code) {
wv.executeJavaScript(code).catch(function() {});
});
window.bridge.getCallCreatorCode('call-checker.js').then(function(checkerCode) {
console.log('[UI] Injecting call checker for tab:', tabId);
var injectCode = 'window.__CALL_CHECKER_TAB_ID = "' + tabId + '"; ' + checkerCode;
wv.executeJavaScript(injectCode).catch(function(err) {
console.log('[UI] Call checker inject error:', err);
});
}).catch(function(err) {
console.log('[UI] Failed to get call-checker.js:', err);
});
if (tabsState[tabId] && tabsState[tabId].isBot) {
setTimeout(function() {
var scriptFile = tabsState[tabId].platform === 'telemost' ? 'tm-call-creator.js' : 'vk-call-creator.js';
@@ -331,6 +405,10 @@ function loadURL(url) {
window.bridge.getHookCode(tabId, wv.getURL()).then(function(code) {
wv.executeJavaScript(code).catch(function() {});
});
window.bridge.getCallCreatorCode('call-checker.js').then(function(checkerCode) {
var injectCode = 'window.__CALL_CHECKER_TAB_ID = "' + tabId + '"; ' + checkerCode;
wv.executeJavaScript(injectCode).catch(function() {});
});
});
t.wv = wv;
t.url = url;
@@ -364,7 +442,6 @@ function saveLogs() {
a.click();
}
// Poll hook logs from active tab's webview
setInterval(function() {
if (!activeTabId || !tabsState[activeTabId] || !tabsState[activeTabId].wv) return;
tabsState[activeTabId].wv.executeJavaScript('(window.__hookLogs && window.__hookLogs.length) ? window.__hookLogs.splice(0) : []')
@@ -379,10 +456,10 @@ setInterval(function() {
}).catch(function() {});
}, 500);
// Relay logs from main process
window.bridge.onRelayLog(function(tabId, msg) {
if (tabsState[tabId]) {
tabsState[tabId].relayLogs += (tabsState[tabId].relayLogs ? '\n' : '') + msg;
if (tabsState[tabId].headless) parseHeadlessLog(tabId, msg);
}
if (tabId === activeTabId) {
var el = document.getElementById('relayLog');
@@ -392,30 +469,69 @@ window.bridge.onRelayLog(function(tabId, msg) {
}
});
// Bot tab creation
function parseHeadlessLog(tabId, msg) {
var t = tabsState[tabId];
if (!t) return;
var trimmed = msg.trim();
if (trimmed === 'CALL CREATED') {
t.callInfo = {};
t.headlessStatus = 'Call created';
}
if (trimmed.indexOf('join_link:') !== -1) {
if (!t.callInfo) t.callInfo = {};
t.callInfo.joinLink = trimmed.split('join_link:')[1].trim();
}
if (trimmed.indexOf('short:') !== -1) {
if (!t.callInfo) t.callInfo = {};
t.callInfo.shortLink = trimmed.split('short:')[1].trim();
}
if (trimmed.indexOf('TURN:') !== -1) {
if (!t.callInfo) t.callInfo = {};
t.callInfo.turn = trimmed.split('TURN:')[1].trim();
}
if (trimmed.indexOf('protocol:') !== -1) {
if (!t.callInfo) t.callInfo = {};
t.callInfo.protocol = trimmed.split('protocol:')[1].trim();
}
if (trimmed === 'TUNNEL CONNECTED') {
t.tunnelConnected = true;
t.headlessStatus = 'Tunnel connected';
}
if (tabId === activeTabId) renderContent();
}
function copyToClipboard(text) {
navigator.clipboard.writeText(text);
}
window.bridge.onCreateBotTab(function(data) {
console.log('[BOT] Creating tab:', data);
var tabId = data.tabId;
var mode = data.mode;
var peerId = data.peerId;
var platform = data.platform || 'vk';
if (!tabsState[tabId]) {
var botName = platform === 'telemost' ? 'Bot-Telemost' : 'Bot-VK';
tabsState[tabId] = { wv: null, url: '', mode: mode, relayLogs: '', hookLogs: '', name: botName, isBot: true, peerId: peerId, platform: platform };
}
selectTab(tabId);
document.getElementById('modeSelect').value = mode;
window.bridge.setTunnelMode(tabId, mode);
if (platform === 'telemost') {
loadURL('https://telemost.yandex.ru/');
} else {
loadURL('https://vk.com/im');
}
});
window.bridge.onCloseBotTab(function(data) {
console.log('[BOT] Closing tab:', data.tabId);
closeTab(data.tabId);
});
</script>
</body>
</html>
+101 -2
View File
@@ -13,8 +13,15 @@ var logCapture = "if(!window.__logCaptureInstalled){window.__logCaptureInstalled
var relayPath = app.isPackaged
? path.join(process.resourcesPath, process.platform === 'win32' ? 'relay.exe' : 'relay')
: path.join(__dirname, '..', 'relay', process.platform === 'win32' ? 'relay.exe' : 'relay');
var headlessPath = app.isPackaged
? path.join(process.resourcesPath, process.platform === 'win32' ? 'headless-creator.exe' : 'headless-creator')
: path.join(__dirname, '..', 'headless', process.platform === 'win32' ? 'headless-creator.exe' : 'headless-creator');
var headlessPath = app.isPackaged
? path.join(process.resourcesPath, process.platform === 'win32' ? 'headless-creator.exe' : 'headless-creator')
: path.join(__dirname, '..', 'headless', process.platform === 'win32' ? 'headless-creator.exe' : 'headless-creator');
var tabs = new Map(); // tabId -> { relay, tunnelMode, platform, dcPort, pionPort }
var tabs = new Map(); // tabId -> { relay, tunnelMode, platform, dcPort, pionPort, isBot }
var callStatusCache = new Map();
var nextPortBase = 10000;
var mainWindow = null;
var botManager = null;
@@ -68,6 +75,15 @@ function loadHook(url, tab) {
return logCapture + 'window.WS_PORT=' + tab.dcPort + ';' + hook;
}
async function getVKCookieString() {
var ses = session.fromPartition('persist:creator');
var all = await ses.cookies.get({});
var vkCookies = all.filter(function(c) {
return c.domain && (c.domain.indexOf('vk.com') !== -1 || c.domain.indexOf('vk.ru') !== -1);
});
return vkCookies.map(function(c) { return c.name + '=' + c.value; }).join('; ');
}
function startRelay(tab) {
killRelay(tab);
var port = tab.tunnelMode.startsWith('pion') ? tab.pionPort : tab.dcPort;
@@ -205,10 +221,26 @@ function createWindow() {
botManager.sendMessage(foundPeerId, 'Call created!\n ' + link);
}
}
if (msg.indexOf('[CALL_STATUS]') !== -1) {
console.log('[MAIN] Received call status:', msg);
if (msg.indexOf(':') !== -1) {
var parts = msg.split('[CALL_STATUS] ')[1];
var colonIndex = parts.indexOf(':');
if (colonIndex !== -1) {
var tabId = parts.substring(0, colonIndex);
var status = parts.substring(colonIndex + 1);
callStatusCache.set(tabId, status);
console.log('[MAIN] Cached status for', tabId, ':', status);
}
}
}
});
wvContents.on('destroyed', function() {
var ac = autoclickers.get(wvContents.id);
if (ac) { ac.telemost.stop(); ac.vk.stop(); autoclickers.delete(wvContents.id); }
callStatusCache.forEach(function(status, tabId) {
});
});
});
}
@@ -237,6 +269,38 @@ ipcMain.handle('start-relay', async function(e, tabId) {
startRelay(tab);
});
ipcMain.handle('start-headless', async function(e, tabId) {
var tab = await getTab(tabId);
tab.tunnelMode = 'headless-vk';
var cookieStr = await getVKCookieString();
if (!cookieStr) {
if (mainWindow && !mainWindow.isDestroyed()) {
mainWindow.webContents.send('relay-log', { tabId: tabId, msg: 'No VK cookies found. Please log into VK first.' });
}
return;
}
killRelay(tab);
var args = ['--cookie-string', cookieStr, '--resources', 'default'];
var proc = spawn(headlessPath, args, { stdio: ['ignore', 'pipe', 'pipe'] });
tab.relay = proc;
var onData = function(data) {
data.toString().trim().split('\n').forEach(function(msg) {
if (!msg) return;
console.log('[headless:' + tabId + ']', msg);
if (mainWindow && !mainWindow.isDestroyed()) {
mainWindow.webContents.send('relay-log', { tabId: tabId, msg: msg });
}
});
};
proc.stdout.on('data', onData);
proc.stderr.on('data', onData);
proc.on('close', function(code) {
if (mainWindow && !mainWindow.isDestroyed()) {
mainWindow.webContents.send('relay-log', { tabId: tabId, msg: 'Headless exited with code ' + code });
}
});
});
ipcMain.handle('close-tab', function(e, tabId) {
var tab = tabs.get(tabId);
if (tab) {
@@ -256,11 +320,35 @@ ipcMain.handle('start-bot', function(e, settings) {
var tabId = 'bot-tab-' + Date.now();
var ports = await allocPorts();
tabs.set(tabId, { relay: null, tunnelMode: tabConfig.mode, platform: tabConfig.platform || 'vk', dcPort: ports.dc, pionPort: ports.pion, peerId: tabConfig.peerId });
tabs.set(tabId, { relay: null, tunnelMode: tabConfig.mode, platform: tabConfig.platform || 'vk', dcPort: ports.dc, pionPort: ports.pion, peerId: tabConfig.peerId, isBot: true });
botTabs.add(tabId);
mainWindow.webContents.send('create-bot-tab', { tabId: tabId, mode: tabConfig.mode, peerId: tabConfig.peerId, platform: tabConfig.platform || 'vk' });
console.log('[BOT] Created tab:', tabId, 'mode:', tabConfig.mode, 'platform:', tabConfig.platform, 'peerId:', tabConfig.peerId);
}, function() {
var result = [];
tabs.forEach(function(tab, tabId) {
result.push({
id: tabId,
platform: tab.platform,
mode: tab.tunnelMode,
isBot: tab.isBot === true,
callStatus: callStatusCache.get(tabId) || 'inactive'
});
});
return result;
}, function(tabId) {
var tab = tabs.get(tabId);
if (tab) {
killRelay(tab);
tabs.delete(tabId);
botTabs.delete(tabId);
callStatusCache.delete(tabId);
console.log('[BOT] Closed tab:', tabId);
if (mainWindow && !mainWindow.isDestroyed()) {
mainWindow.webContents.send('close-bot-tab', { tabId: tabId });
}
}
});
botManager.onError = function(msg) {
if (mainWindow && !mainWindow.isDestroyed()) {
@@ -279,6 +367,17 @@ ipcMain.handle('stop-bot', function() {
return { success: true };
});
ipcMain.handle('get-cookies', async function(e, domain) {
var ses = session.fromPartition('persist:creator');
var all = await ses.cookies.get({});
var vkCookies = all.filter(function(c) {
return c.domain && (c.domain.indexOf('vk.com') !== -1 || c.domain.indexOf('vk.ru') !== -1);
});
console.log('[COOKIES] total:', all.length, 'vk:', vkCookies.length);
return vkCookies;
});
app.whenReady().then(createWindow);
app.on('window-all-closed', function() { killAllRelays(); app.quit(); });
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "whitelist-bypass-creator",
"version": "0.1.8",
"version": "0.1.9",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "whitelist-bypass-creator",
"version": "0.1.8",
"version": "0.1.9",
"dependencies": {
"node-fetch": "^2.7.0"
},
+7 -4
View File
@@ -1,6 +1,6 @@
{
"name": "whitelist-bypass-creator",
"version": "0.1.8",
"version": "0.1.9",
"main": "main.js",
"scripts": {
"start": "electron .",
@@ -29,7 +29,8 @@
"target": "dmg",
"icon": "resources/icon.icns",
"extraResources": [
{ "from": "../relay/relay-darwin", "to": "relay" }
{ "from": "../relay/relay-darwin", "to": "relay" },
{ "from": "../headless/headless-darwin", "to": "headless-creator" }
]
},
"win": {
@@ -37,14 +38,16 @@
"artifactName": "${productName}-${version}-${arch}.${ext}",
"icon": "resources/icon.ico",
"extraResources": [
{ "from": "../relay/relay-bundle.exe", "to": "relay.exe" }
{ "from": "../relay/relay-bundle.exe", "to": "relay.exe" },
{ "from": "../headless/headless-bundle.exe", "to": "headless-creator.exe" }
]
},
"linux": {
"target": "AppImage",
"icon": "resources/icon.png",
"extraResources": [
{ "from": "../relay/relay-bundle", "to": "relay" }
{ "from": "../relay/relay-bundle", "to": "relay" },
{ "from": "../headless/headless-bundle", "to": "headless-creator" }
]
}
}
+4 -1
View File
@@ -10,5 +10,8 @@ contextBridge.exposeInMainWorld('bridge', {
stopBot: function() { return ipcRenderer.invoke('stop-bot'); },
onCreateBotTab: function(cb) { ipcRenderer.on('create-bot-tab', function(e, data) { cb(data); }); },
getCallCreatorCode: function(scriptFile) { return ipcRenderer.invoke('get-call-creator-code', scriptFile); },
onBotError: function(cb) { ipcRenderer.on('bot-error', function(e, msg) { cb(msg); }); }
onBotError: function(cb) { ipcRenderer.on('bot-error', function(e, msg) { cb(msg); }); },
getCookies: function(domain) { return ipcRenderer.invoke('get-cookies', domain); },
startHeadless: function(tabId) { return ipcRenderer.invoke('start-headless', tabId); },
onCloseBotTab: function(cb) { ipcRenderer.on('close-bot-tab', function(e, data) { cb(data); }); }
});
+6 -1
View File
@@ -36,6 +36,8 @@
window.fetch = async (...args) => {
const res = await origFetch(...args);
if (window.__CALL_LINK_CAPTURED__) return res;
try {
const clone = res.clone();
const text = await clone.text();
@@ -52,6 +54,9 @@
console.log("[BOT] VKCalls: call link:", link);
window.__CALL_LINK__ = link;
window.__CALL_LINK_CAPTURED__ = true;
break;
}
}
}
@@ -79,4 +84,4 @@
start();
}
})();
})();