diff --git a/.gitignore b/.gitignore index 34f7063..7ca9e17 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,7 @@ relay/mobile.aar relay/relay-* prebuilts/ +cookies.json +pion-light/ +headless/headless-creator +relay/relay diff --git a/README.md b/README.md index 30895cb..58e3a73 100644 --- a/README.md +++ b/README.md @@ -126,10 +126,12 @@ Download and run the Electron app from [GitHub Releases](../../releases). It bun 1. Open the app 2. Select tunnel mode (DC or Pion Video) -3. Click "VK Call" or "Telemost" -4. Log in, create a call +3. Click "VK" or "Telemost" +4. Log in, **create a new call** from the app 5. Copy the join link, send it to the joiner +**Important:** The call must be created from within the Creator app. Joining an existing call from the app will not work - the JS hooks must be present from the moment the call starts. + ### Joiner side (censored, Android) 1. Download and install `whitelist-bypass.apk` from [GitHub Releases](../../releases) @@ -189,6 +191,34 @@ The Go relay is split into platform-specific files: This allows cross-compiling the relay for macOS/Windows/Linux without CGo or Android NDK. +### Headless creator + +Pure Go creator that creates VK calls via API without a browser. No Electron, no JS hooks - Go Pion PeerConnection handles the DataChannel tunnel directly. + +```sh +# Build +cd headless && go build -o headless-creator . + +# Run +./headless-creator --cookies cookies.json [--peer-id ] [--resources ] +``` + +- `--cookies` - path to VK cookies exported as JSON (`[{"name":"..","value":".."},...]`). Use the "Export Cookies" button in the Creator app to get this file +- `--peer-id` - VK peer_id for the call (optional) +- `--resources` - resource mode (see below) + +**Resource modes:** + +| Mode | read-buf | max-dc-buf | mem-limit | Use case | +|---|---|---|---|---| +| `moderate` | 16KB | 1MB | 64MB | Low memory environments, VPS | +| `default` | 32KB | 4MB | 128MB | General use | +| `unlimited` | 64KB | 8MB | 256MB | Maximum throughput | + +- `read-buf` - TCP read buffer size. Smaller = more frequent backpressure checks, less bursty memory +- `max-dc-buf` - pauses TCP reads when DataChannel buffered amount exceeds this. Prevents SCTP pending queue from growing unbounded +- `mem-limit` - Go runtime soft memory limit (`debug.SetMemoryLimit`), makes GC more aggressive near the cap + ## License [MIT](LICENSE) diff --git a/android-app/app/build.gradle.kts b/android-app/app/build.gradle.kts index c4c5aa6..c1e7c3f 100644 --- a/android-app/app/build.gradle.kts +++ b/android-app/app/build.gradle.kts @@ -5,7 +5,7 @@ plugins { val versionMajor = 0 val versionMinor = 1 -val versionPatch = 8 +val versionPatch = 9 val versionBuild = System.getenv("BUILD_NUMBER")?.toIntOrNull() ?: 0 android { diff --git a/android-app/app/libs/mobile.aar b/android-app/app/libs/mobile.aar index 16eb683..99aceea 100644 Binary files a/android-app/app/libs/mobile.aar and b/android-app/app/libs/mobile.aar differ diff --git a/android-app/app/src/main/java/bypass/whitelist/ui/LogViewController.kt b/android-app/app/src/main/java/bypass/whitelist/ui/LogViewController.kt index 9a44138..9dbca46 100644 --- a/android-app/app/src/main/java/bypass/whitelist/ui/LogViewController.kt +++ b/android-app/app/src/main/java/bypass/whitelist/ui/LogViewController.kt @@ -1,6 +1,7 @@ package bypass.whitelist.ui import android.content.Intent +import android.text.method.ScrollingMovementMethod import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import androidx.core.content.FileProvider @@ -12,6 +13,10 @@ class LogViewController( private val logView: TextView, private val logWriter: LogWriter, ) { + init { + logView.movementMethod = ScrollingMovementMethod.getInstance() + } + fun append(msg: String) { val (line, evicted) = logWriter.append(msg) activity.runOnUiThread { diff --git a/android-app/app/src/main/jniLibs/arm64-v8a/librelay.so b/android-app/app/src/main/jniLibs/arm64-v8a/librelay.so index 0441d9a..cfedba3 100755 Binary files a/android-app/app/src/main/jniLibs/arm64-v8a/librelay.so and b/android-app/app/src/main/jniLibs/arm64-v8a/librelay.so differ diff --git a/android-app/app/src/main/jniLibs/armeabi-v7a/librelay.so b/android-app/app/src/main/jniLibs/armeabi-v7a/librelay.so index d07adcc..52ad0c5 100755 Binary files a/android-app/app/src/main/jniLibs/armeabi-v7a/librelay.so and b/android-app/app/src/main/jniLibs/armeabi-v7a/librelay.so differ diff --git a/build-creator.sh b/build-creator.sh index bc3b9aa..2f8611e 100755 --- a/build-creator.sh +++ b/build-creator.sh @@ -5,6 +5,8 @@ ROOT="$(cd "$(dirname "$0")" && pwd)" RELAY_DIR="$ROOT/relay" CREATOR_DIR="$ROOT/creator-app" +HEADLESS_DIR="$ROOT/headless" + echo "=== Building relay binaries ===" cd "$RELAY_DIR" @@ -26,6 +28,28 @@ GOOS=linux GOARCH=386 go build -o relay-linux-ia32 . ls -lh relay-darwin relay-windows-*.exe relay-linux-* +echo "" +echo "=== Building headless-creator ===" +cd "$HEADLESS_DIR" + +echo "macOS (universal)..." +GOOS=darwin GOARCH=amd64 go build -o headless-darwin-amd64 . +GOOS=darwin GOARCH=arm64 go build -o headless-darwin-arm64 . +lipo -create -output headless-darwin headless-darwin-amd64 headless-darwin-arm64 +rm headless-darwin-amd64 headless-darwin-arm64 + +echo "Windows x64..." +GOOS=windows GOARCH=amd64 go build -o headless-windows-x64.exe . +echo "Windows x86..." +GOOS=windows GOARCH=386 go build -o headless-windows-ia32.exe . + +echo "Linux x64..." +GOOS=linux GOARCH=amd64 go build -o headless-linux-x64 . +echo "Linux x86..." +GOOS=linux GOARCH=386 go build -o headless-linux-ia32 . + +ls -lh headless-darwin headless-windows-*.exe headless-linux-* + echo "" echo "=== Building Electron apps ===" cd "$CREATOR_DIR" @@ -40,22 +64,35 @@ npx electron-builder --mac echo "" echo "--- Windows x64 ---" cp "$RELAY_DIR/relay-windows-x64.exe" "$RELAY_DIR/relay-bundle.exe" +cp "$HEADLESS_DIR/headless-windows-x64.exe" "$HEADLESS_DIR/headless-bundle.exe" npx electron-builder --win --x64 # Windows x86 echo "" echo "--- Windows x86 ---" cp "$RELAY_DIR/relay-windows-ia32.exe" "$RELAY_DIR/relay-bundle.exe" +cp "$HEADLESS_DIR/headless-windows-ia32.exe" "$HEADLESS_DIR/headless-bundle.exe" npx electron-builder --win --ia32 # Linux x64 echo "" echo "--- Linux x64 ---" cp "$RELAY_DIR/relay-linux-x64" "$RELAY_DIR/relay-bundle" +cp "$HEADLESS_DIR/headless-linux-x64" "$HEADLESS_DIR/headless-bundle" npx electron-builder --linux --x64 -# Cleanup -rm -f "$RELAY_DIR/relay-bundle" "$RELAY_DIR/relay-bundle.exe" +# Copy standalone headless binaries to prebuilts +echo "" +echo "=== Copying headless binaries ===" +mkdir -p "$ROOT/prebuilts" +cp "$HEADLESS_DIR/headless-linux-x64" "$ROOT/prebuilts/headless-creator-linux-x64" +cp "$HEADLESS_DIR/headless-linux-ia32" "$ROOT/prebuilts/headless-creator-linux-ia32" + +# Cleanup build artifacts +rm -f "$RELAY_DIR"/relay-darwin "$RELAY_DIR"/relay-windows-*.exe "$RELAY_DIR"/relay-linux-* +rm -f "$RELAY_DIR"/relay-bundle "$RELAY_DIR"/relay-bundle.exe +rm -f "$HEADLESS_DIR"/headless-darwin "$HEADLESS_DIR"/headless-windows-*.exe "$HEADLESS_DIR"/headless-linux-* +rm -f "$HEADLESS_DIR"/headless-bundle "$HEADLESS_DIR"/headless-bundle.exe echo "" echo "=== Done ===" diff --git a/build-go.sh b/build-go.sh index 78bce7e..d334fd3 100755 --- a/build-go.sh +++ b/build-go.sh @@ -12,7 +12,8 @@ command -v gomobile >/dev/null || { echo "gomobile not found, run: go install go command -v gobind >/dev/null || { echo "gobind not found, run: go install golang.org/x/mobile/cmd/gobind@latest"; exit 1; } [ -d "$ANDROID_NDK_HOME" ] || { echo "NDK not found at $ANDROID_NDK_HOME"; exit 1; } -cd "$(dirname "$0")/relay" +ROOT="$(cd "$(dirname "$0")" && pwd)" +cd "$ROOT/relay" echo "Building gomobile .aar..." gomobile bind -v -target=android -androidapi 23 -o mobile.aar ./mobile/ 2>&1 @@ -34,3 +35,13 @@ cp ../hooks/video-vk.js ../android-app/app/src/main/assets/video-vk.js cp ../hooks/video-telemost.js ../android-app/app/src/main/assets/video-telemost.js echo "Done. .aar size: $(du -h mobile.aar | cut -f1)" + +echo "" +echo "Building desktop relay..." +go -C "$ROOT/relay" build -o relay . + +echo "Building headless-creator..." +go -C "$ROOT/headless" build -o headless-creator . + +echo "Done." +ls -lh "$ROOT/relay/relay" "$ROOT/headless/headless-creator" diff --git a/creator-app/bot-manager.js b/creator-app/bot-manager.js index 0337d98..e482226 100644 --- a/creator-app/bot-manager.js +++ b/creator-app/bot-manager.js @@ -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; diff --git a/creator-app/call-checker.js b/creator-app/call-checker.js new file mode 100644 index 0000000..0aa195c --- /dev/null +++ b/creator-app/call-checker.js @@ -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); +})(); diff --git a/creator-app/index.html b/creator-app/index.html index 3fb315c..ee96673 100644 --- a/creator-app/index.html +++ b/creator-app/index.html @@ -61,6 +61,7 @@ body { font-family: -apple-system, sans-serif; background: #1a1a1a; color: #e0e0
+
+
Export Cookies
Settings
Bot: Off
@@ -68,6 +69,7 @@ body { font-family: -apple-system, sans-serif; background: #1a1a1a; color: #e0e0