reduce logs for non-debug runtime

This commit is contained in:
kulikov0 committed 2026-07-25 09:15:10 +02:00
1 parent 5103d87211
commit d66be97922
39 files changed
+182 -31

No files matched your search

Binary file not shown.
@@ -76,6 +76,7 @@ class RelayController(
return@Thread
}
try {
Androidbind.setDebug(Prefs.debug)
Androidbind.startJoiner(Ports.DC_WS, Prefs.socksPort, Prefs.socksHost, SocksAuth.user, SocksAuth.pass, cb)
} catch (e: Exception) {
if (isRunning) onLog("Relay error: ${e.message}")
@@ -99,7 +100,7 @@ class RelayController(
return@Thread
}
try {
val pb = ProcessBuilder(
val cmd = mutableListOf(
relayBin.absolutePath,
"--mode", relayMode,
"--ws-port", "${Ports.PION_SIGNALING}",
@@ -108,6 +109,8 @@ class RelayController(
"--socks-user", SocksAuth.user,
"--socks-pass", SocksAuth.pass
)
if (Prefs.debug) cmd.add("--debug")
val pb = ProcessBuilder(cmd)
pb.redirectErrorStream(true)
val proc = pb.start()
synchronized(this) { pionProcess = proc }
@@ -145,6 +145,9 @@ class SettingsScreenFragment : Fragment(R.layout.fragment_settings_screen) {
addSwitchRow(card, R.drawable.ic_setting_reconnect, getString(R.string.settings_row_reconnect), getString(R.string.settings_row_reconnect_sub), Prefs.connectOnStart) { checked ->
Prefs.connectOnStart = checked
}
addSwitchRow(card, R.drawable.ic_setting_debug, getString(R.string.settings_row_debug), getString(R.string.settings_row_debug_sub), Prefs.debug) { checked ->
Prefs.debug = checked
}
return section
}
@@ -67,6 +67,7 @@ object PrefsKeys {
const val VP8_BATCH = "vp8_batch"
const val DUAL_TRACK = "dual_track"
const val RELIABLE = "reliable"
const val DEBUG = "debug"
const val SAVED_DESTINATIONS = "saved_destinations"
const val ACTIVE_DESTINATION_ID = "active_destination_id"
const val THEME_MODE = "theme_mode"
@@ -123,6 +123,10 @@ object Prefs {
get() = prefs.getBoolean(PrefsKeys.RELIABLE, false)
set(value) = prefs.edit { putBoolean(PrefsKeys.RELIABLE, value) }
var debug: Boolean
get() = prefs.getBoolean(PrefsKeys.DEBUG, false)
set(value) = prefs.edit { putBoolean(PrefsKeys.DEBUG, value) }
var savedDestinations: List<CallConfig>
get() = CallConfig.listFromJson(prefs.getString(PrefsKeys.SAVED_DESTINATIONS, "") ?: "")
set(value) = prefs.edit { putString(PrefsKeys.SAVED_DESTINATIONS, CallConfig.listToJson(value)) }
@@ -0,0 +1,26 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M4,6 L20,6 C20.55,6 21,6.45 21,7 L21,17 C21,17.55 20.55,18 20,18 L4,18 C3.45,18 3,17.55 3,17 L3,7 C3,6.45 3.45,6 4,6 Z" />
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:strokeLineJoin="round"
android:fillColor="@android:color/transparent"
android:pathData="M7,10 L10,12.5 L7,15" />
<path
android:strokeColor="@android:color/white"
android:strokeWidth="1.8"
android:strokeLineCap="round"
android:fillColor="@android:color/transparent"
android:pathData="M13,15 L17,15" />
</vector>
@@ -114,6 +114,8 @@
<string name="settings_row_headless_sub">Skip the visible browser join</string>
<string name="settings_row_reconnect">Reconnect on app start</string>
<string name="settings_row_reconnect_sub">Restore the last session automatically</string>
<string name="settings_row_debug">Debug logging</string>
<string name="settings_row_debug_sub">Verbose relay logs for troubleshooting</string>
<string name="settings_toast_destinations_cleared">All calls removed</string>
<string name="settings_toast_reset_done">Settings reset</string>
+2
View File
@@ -94,6 +94,8 @@
<input type="text" id="upstreamUser" placeholder="optional">
<label for="upstreamPass">Password</label>
<input type="password" id="upstreamPass" placeholder="optional">
<h2>Logging</h2>
<label class="popup-check"><input type="checkbox" id="debugLogging"><span>Debug logging</span></label>
<h2>Clear cookies</h2>
<div class="clear-cookies-row">
<button type="button" class="btn-clear-cookies" data-platform="vk">VK</button>
+1
View File
@@ -59,6 +59,7 @@ export enum IPC {
START_BOT = 'start-bot',
STOP_BOT = 'stop-bot',
SET_UPSTREAM_PROXY = 'set-upstream-proxy',
SET_DEBUG_LOGGING = 'set-debug-logging',
CLEAR_COOKIES = 'clear-cookies',
EXPORT_COOKIES_ZIP = 'export-cookies-zip',
RELAY_LOG = 'relay-log',
+4
View File
@@ -90,6 +90,10 @@ export function registerIpcHandlers(tabManager: TabManager): void {
tabManager.setUpstreamProxy(proxy);
});
ipcMain.handle(IPC.SET_DEBUG_LOGGING, (_e, enabled: boolean) => {
tabManager.setDebugLogging(enabled);
});
ipcMain.handle(IPC.CLEAR_COOKIES, (_e, platform: string) => {
return tabManager.clearPlatformCookies(platform as Platform);
});
+7
View File
@@ -53,6 +53,7 @@ export class TabManager {
private headlessDionPath: string;
private hooksDir: string;
private upstreamProxy: UpstreamProxy = { socks: '', user: '', pass: '' };
private debugLogging = false;
constructor() {
this.relayPath = resolveResourcePath(
@@ -223,6 +224,10 @@ export class TabManager {
};
}
setDebugLogging(enabled: boolean): void {
this.debugLogging = enabled;
}
private appendUpstreamArgs(args: string[]): void {
if (!this.upstreamProxy.socks) return;
args.push('--upstream-socks', this.upstreamProxy.socks);
@@ -241,6 +246,7 @@ export class TabManager {
}
const relayArgs = ['--mode', relayMode, '--ws-port', String(port)];
this.appendUpstreamArgs(relayArgs);
if (this.debugLogging) relayArgs.push('--debug');
const proc = spawn(this.relayPath, relayArgs, {
stdio: ['ignore', 'pipe', 'pipe'],
});
@@ -371,6 +377,7 @@ export class TabManager {
if (flag) spawnArgs.push(flag, joinTarget);
}
this.appendUpstreamArgs(spawnArgs);
if (this.debugLogging) spawnArgs.push('--debug');
const proc = spawn(config.binaryPath, spawnArgs, {
stdio: ['ignore', 'pipe', 'pipe'],
});
+3
View File
@@ -26,6 +26,9 @@ import { IPC } from '../constants';
setUpstreamProxy(proxy: any) {
return ipcRenderer.invoke(IPC.SET_UPSTREAM_PROXY, proxy);
},
setDebugLogging(enabled: boolean) {
return ipcRenderer.invoke(IPC.SET_DEBUG_LOGGING, enabled);
},
clearCookies(platform: string) {
return ipcRenderer.invoke(IPC.CLEAR_COOKIES, platform);
},
+3
View File
@@ -89,6 +89,8 @@ function bindSettingsEvents(): void {
tm.upstreamProxy.user = (document.getElementById('upstreamUser') as HTMLInputElement).value.trim();
tm.upstreamProxy.pass = (document.getElementById('upstreamPass') as HTMLInputElement).value.trim();
tm.saveUpstreamProxy();
tm.debugLogging = (document.getElementById('debugLogging') as HTMLInputElement).checked;
tm.saveDebugLogging();
closeSettings();
});
document.querySelectorAll('.btn-clear-cookies').forEach((btn) => {
@@ -174,6 +176,7 @@ function openSettings(): void {
(document.getElementById('upstreamSocks') as HTMLInputElement).value = tm.upstreamProxy.socks;
(document.getElementById('upstreamUser') as HTMLInputElement).value = tm.upstreamProxy.user;
(document.getElementById('upstreamPass') as HTMLInputElement).value = tm.upstreamProxy.pass;
(document.getElementById('debugLogging') as HTMLInputElement).checked = tm.debugLogging;
document.getElementById('clearCookiesStatus')!.textContent = '';
}
+7
View File
@@ -20,6 +20,7 @@ export class RendererTabManager {
botRunning = false;
botSettings: BotSettings;
upstreamProxy: UpstreamProxy;
debugLogging: boolean;
private onRender: () => void;
constructor(onRender: () => void) {
@@ -32,6 +33,7 @@ export class RendererTabManager {
this.upstreamProxy = savedProxy
? JSON.parse(savedProxy)
: { socks: '', user: '', pass: '' };
this.debugLogging = localStorage.getItem('debugLogging') === 'true';
}
createTab(): string {
@@ -247,6 +249,11 @@ export class RendererTabManager {
window.bridge.setUpstreamProxy(this.upstreamProxy);
}
saveDebugLogging(): void {
localStorage.setItem('debugLogging', String(this.debugLogging));
window.bridge.setDebugLogging(this.debugLogging);
}
toggleBot(): void {
if (!this.botSettings.token || !this.botSettings.groupId) return;
this.botRunning = !this.botRunning;
+1
View File
@@ -151,6 +151,7 @@ export interface Bridge {
startBot(settings: BotSettings): Promise<void>;
stopBot(): Promise<void>;
setUpstreamProxy(proxy: UpstreamProxy): Promise<void>;
setDebugLogging(enabled: boolean): Promise<void>;
clearCookies(platform: string): Promise<number>;
onCreateBotTab(cb: (data: BotTabData) => void): void;
getCallCreatorCode(scriptFile: string): Promise<string>;
+26
View File
@@ -513,6 +513,9 @@ body {
border-radius: 12px;
padding: 24px;
width: 400px;
max-height: 90vh;
overflow-y: auto;
box-sizing: border-box;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
@@ -548,6 +551,29 @@ body {
border-color: #0077ff;
}
.popup .popup-check {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 16px;
cursor: pointer;
}
.popup .popup-check input[type="checkbox"] {
width: 16px;
height: 16px;
margin: 0;
padding: 0;
accent-color: #0077ff;
flex: none;
}
.popup .popup-check span {
font-size: 14px;
color: #e0e0e0;
font-weight: 500;
}
.popup-buttons {
display: flex;
gap: 8px;
+2 -1
View File
@@ -24,7 +24,9 @@ func main() {
socksUser := flag.String("socks-user", "", "SOCKS5 username (optional)")
socksPass := flag.String("socks-pass", "", "SOCKS5 password (optional)")
resources := flag.String("resources", "default", "resource mode: moderate, default, unlimited")
debugFlag := flag.Bool("debug", false, "verbose debug logging")
flag.Parse()
common.Debug = *debugFlag
var memLimit int64
switch *resources {
@@ -128,4 +130,3 @@ func main() {
}
}
}
+2
View File
@@ -25,7 +25,9 @@ func main() {
upstreamSocks := flag.String("upstream-socks", "", "route tunneled egress through this SOCKS5 proxy (host:port), e.g. a local VPN client")
upstreamUser := flag.String("upstream-user", "", "upstream SOCKS5 username")
upstreamPass := flag.String("upstream-pass", "", "upstream SOCKS5 password")
debugFlag := flag.Bool("debug", false, "verbose debug logging")
flag.Parse()
common.Debug = *debugFlag
var memLimit int64
switch *resources {
+2
View File
@@ -51,7 +51,9 @@ func main() {
resources := flag.String("resources", "default", "resource mode: moderate, default, unlimited")
vp8FPS := flag.Int("vp8-fps", 24, "VP8 frame rate")
vp8Batch := flag.Int("vp8-batch", 30, "VP8 batch multiplier")
debugFlag := flag.Bool("debug", false, "verbose debug logging")
flag.Parse()
common.Debug = *debugFlag
if *tmLink == "" {
log.Fatal("--tm-link is required")
+2
View File
@@ -891,7 +891,9 @@ func main() {
upstreamSocks := flag.String("upstream-socks", "", "route tunneled egress through this SOCKS5 proxy (host:port), e.g. a local VPN client")
upstreamUser := flag.String("upstream-user", "", "upstream SOCKS5 username")
upstreamPass := flag.String("upstream-pass", "", "upstream SOCKS5 password")
debugFlag := flag.Bool("debug", false, "verbose debug logging")
flag.Parse()
common.Debug = *debugFlag
var readBuf int
var memLimit int64
+2
View File
@@ -645,7 +645,9 @@ func main() {
upstreamSocks := flag.String("upstream-socks", "", "route tunneled egress through this SOCKS5 proxy (host:port), e.g. a local VPN client")
upstreamUser := flag.String("upstream-user", "", "upstream SOCKS5 username")
upstreamPass := flag.String("upstream-pass", "", "upstream SOCKS5 password")
debugFlag := flag.Bool("debug", false, "verbose debug logging")
flag.Parse()
common.Debug = *debugFlag
var readBuf int
var maxDCBuf uint64
+6 -2
View File
@@ -254,7 +254,9 @@ func (u *TunnelRelay) handleDCMessage(data []byte) {
if u.obf != nil {
pt, ok := u.obf.DecryptPayload(data)
if !ok {
log.Printf("[dc] decrypt failed, dropping %d bytes", len(data))
if common.Debug {
log.Printf("[dc] decrypt failed, dropping %d bytes", len(data))
}
return
}
data = pt
@@ -280,7 +282,9 @@ func (u *TunnelRelay) handleDCMessage(data []byte) {
select {
case dc.ch <- cp:
default:
log.Printf("[dc] conn %d write queue full, dropping %d bytes", connID, len(payload))
if common.Debug {
log.Printf("[dc] conn %d write queue full, dropping %d bytes", connID, len(payload))
}
}
}
case tunnel.MsgClose:
+2
View File
@@ -28,7 +28,9 @@ func main() {
vp8Batch := flag.Int("vp8-batch", 30, "VP8 batch multiplier (video mode only)")
dualTrack := flag.Bool("dual-track", false, "publish a second VP8 track as ScreenShare and shard outbound across both (video mode only)")
reliable := flag.Bool("reliable", false, "wrap the video tunnel with KCP reliability (video mode only)")
debugFlag := flag.Bool("debug", false, "verbose debug logging")
flag.Parse()
common.Debug = *debugFlag
if *roomFlag == "" {
log.Fatal("--room is required")
+2
View File
@@ -25,7 +25,9 @@ func main() {
upstreamSocks := flag.String("upstream-socks", "", "route tunneled egress through this SOCKS5 proxy (host:port), e.g. a local VPN client")
upstreamUser := flag.String("upstream-user", "", "upstream SOCKS5 username")
upstreamPass := flag.String("upstream-pass", "", "upstream SOCKS5 password")
debugFlag := flag.Bool("debug", false, "verbose debug logging")
flag.Parse()
common.Debug = *debugFlag
var readBuf int
var memLimit int64
@@ -13,6 +13,7 @@ enum DefaultsKeys {
static let vp8Batch = "vp8Batch"
static let dualTrack = "dualTrack"
static let reliable = "reliable"
static let debug = "debug"
}
enum VP8Defaults {
@@ -82,4 +83,9 @@ struct AppDefaults {
get { defaults.object(forKey: DefaultsKeys.reliable) as? Bool ?? false }
set { defaults.set(newValue, forKey: DefaultsKeys.reliable) }
}
static var debug: Bool {
get { defaults.object(forKey: DefaultsKeys.debug) as? Bool ?? false }
set { defaults.set(newValue, forKey: DefaultsKeys.debug) }
}
}
@@ -236,6 +236,7 @@ struct SettingsView: View {
Section(NSLocalizedString("settings_display", comment: "")) {
TextField(NSLocalizedString("hint_display_name", comment: ""), text: $proxyManager.displayName)
Toggle(NSLocalizedString("settings_show_logs", comment: ""), isOn: $proxyManager.showLogs)
Toggle(NSLocalizedString("settings_debug", comment: ""), isOn: $proxyManager.debug)
}
Section(NSLocalizedString("settings_vp8_pacing", comment: "")) {
@@ -25,6 +25,7 @@
"settings_auth_manual" = "Manual";
"settings_display" = "Display";
"settings_show_logs" = "Show Logs";
"settings_debug" = "Debug logging";
"settings_vp8_pacing" = "VP8 settings";
"settings_vp8_fps" = "FPS";
"settings_vp8_batch" = "Batch";
@@ -178,6 +178,7 @@ class ProxyManager: ObservableObject {
@Published var vp8Batch: Int = AppDefaults.vp8Batch { didSet { AppDefaults.vp8Batch = vp8Batch } }
@Published var dualTrack: Bool = AppDefaults.dualTrack { didSet { AppDefaults.dualTrack = dualTrack } }
@Published var reliable: Bool = AppDefaults.reliable { didSet { AppDefaults.reliable = reliable } }
@Published var debug: Bool = AppDefaults.debug { didSet { AppDefaults.debug = debug } }
private let autoSocksUser: String
private let autoSocksPass: String
@@ -295,6 +296,8 @@ class ProxyManager: ObservableObject {
showToast(NSLocalizedString("dc_mode_not_supported", comment: ""))
}
IosSetDebug(debug)
switch detectedPlatform {
case .telemost:
IosStartTelemostHeadless(socksPort, activeSocksUser, activeSocksPass, bridge)
+2
View File
@@ -123,6 +123,8 @@ var activeJoiner struct {
func ActiveWsPort() int { return activeJoiner.wsPort }
func ActiveSocksPort() int { return activeJoiner.socksPort }
func SetDebug(enabled bool) { common.Debug = enabled }
func StopJoiner() {
activeJoiner.Lock()
defer activeJoiner.Unlock()
+3
View File
@@ -0,0 +1,3 @@
package common
var Debug bool
+6 -2
View File
@@ -171,12 +171,16 @@ func (c *dcCreatorRelay) handleUDP(connID uint32, payload []byte) {
udpAddr, err := net.ResolveUDPAddr("udp", addr)
if err != nil {
log.Printf("dc-creator: UDP resolve %s failed: %s", common.MaskAddr(addr), common.MaskError(err))
if common.Debug {
log.Printf("dc-creator: UDP resolve %s failed: %s", common.MaskAddr(addr), common.MaskError(err))
}
return
}
conn, err := net.DialUDP("udp", nil, udpAddr)
if err != nil {
log.Printf("dc-creator: UDP dial %s failed: %s", common.MaskAddr(addr), common.MaskError(err))
if common.Debug {
log.Printf("dc-creator: UDP dial %s failed: %s", common.MaskAddr(addr), common.MaskError(err))
}
return
}
defer conn.Close()
+2
View File
@@ -32,7 +32,9 @@ func main() {
upstreamUser := flag.String("upstream-user", "", "upstream SOCKS5 username")
upstreamPass := flag.String("upstream-pass", "", "upstream SOCKS5 password")
flag.String("local-ip", "", "local IP address (unused, passed via hook)")
debugFlag := flag.Bool("debug", false, "verbose debug logging")
flag.Parse()
common.Debug = *debugFlag
if *mode == "" {
fmt.Fprintf(os.Stderr, "Usage: relay --mode dc-joiner|dc-creator|vk-video-joiner|vk-video-creator|telemost-video-joiner|telemost-video-creator\n")
+4 -2
View File
@@ -39,7 +39,7 @@ type iosStatusEmitter struct {
statusFn func(string)
}
func (e *iosStatusEmitter) EmitStatus(status string) { e.statusFn(status) }
func (e *iosStatusEmitter) EmitStatus(status string) { e.statusFn(status) }
func (e *iosStatusEmitter) EmitStatusError(msg string) { e.statusFn("ERROR:" + msg) }
type iosCacheStore struct {
@@ -47,7 +47,7 @@ type iosCacheStore struct {
}
func (c *iosCacheStore) Save(key string, value string) { c.callback.SaveCache(key, value) }
func (c *iosCacheStore) Load(key string) string { return c.callback.LoadCache(key) }
func (c *iosCacheStore) Load(key string) string { return c.callback.LoadCache(key) }
func makeOnConnected(socksPort int, socksUser, socksPass string, logFn func(string, ...any), callback HeadlessCallback) func(tunnel.DataTunnel) {
return func(tun tunnel.DataTunnel) {
@@ -117,6 +117,8 @@ func makeHelpers(callback HeadlessCallback) (func(string, ...any), joiner.Resolv
func init() {
}
func SetDebug(enabled bool) { common.Debug = enabled }
func StartWBStreamHeadless(socksPort int, socksUser, socksPass string, callback HeadlessCallback) {
StopHeadless()
+10 -7
View File
@@ -11,11 +11,12 @@ import (
"github.com/pion/datachannel"
"github.com/pion/webrtc/v4"
"whitelist-bypass/relay/common"
)
// Telemost chunk size
const chunkSize = 994
const dcStatsEnabled = false
type chunkBuf struct {
chunks [][]byte
@@ -160,7 +161,9 @@ func (t *DCTunnel) deliverMessage(data []byte) {
if t.obf != nil {
pt, ok := t.obf.DecryptPayload(data)
if !ok {
t.logFn("dctunnel: decrypt failed, dropping %d bytes", len(data))
if common.Debug {
t.logFn("dctunnel: decrypt failed, dropping %d bytes", len(data))
}
return
}
data = pt
@@ -247,13 +250,13 @@ func (t *DCTunnel) SendData(data []byte) {
})
}
func (t *DCTunnel) SetOnData(fn func([]byte)) { t.onData = fn }
func (t *DCTunnel) OnData() func([]byte) { return t.onData }
func (t *DCTunnel) SetOnClose(fn func()) { t.onClose = fn }
func (t *DCTunnel) Reconfigure(fps, batch int) {}
func (t *DCTunnel) SetOnData(fn func([]byte)) { t.onData = fn }
func (t *DCTunnel) OnData() func([]byte) { return t.onData }
func (t *DCTunnel) SetOnClose(fn func()) { t.onClose = fn }
func (t *DCTunnel) Reconfigure(fps, batch int) {}
func (t *DCTunnel) statsLoop() {
if !dcStatsEnabled {
if !common.Debug {
return
}
var lastRecv, lastSend uint64
+20 -14
View File
@@ -15,8 +15,6 @@ import (
"whitelist-bypass/relay/common"
)
const verboseUDPLogging = false
type creatorUDP struct {
direct *net.UDPConn
socks *common.Socks5UDPSession
@@ -293,7 +291,7 @@ func (rb *RelayBridge) handleJoinerMessage(connID uint32, msgType byte, payload
rb.logFn("relay[joiner]: drop msgType=%d for unknown conn %d (payload=%dB), NACK once", msgType, connID, len(payload))
rb.send(connID, MsgClose, nil)
}
} else {
} else if common.Debug {
rb.logFn("relay[joiner]: drop msgType=%d for unknown conn %d (payload=%dB)", msgType, connID, len(payload))
}
return
@@ -314,7 +312,9 @@ func (rb *RelayBridge) handleJoinerMessage(connID uint32, msgType byte, payload
}
case MsgData:
if _, err := sc.conn.Write(payload); err != nil {
rb.logFn("relay[joiner]: write to socks %d failed: %s", connID, common.MaskError(err))
if common.Debug {
rb.logFn("relay[joiner]: write to socks %d failed: %s", connID, common.MaskError(err))
}
}
case MsgClose:
sc.conn.Close()
@@ -333,13 +333,17 @@ func (rb *RelayBridge) handleCreatorMessage(connID uint32, msgType byte, payload
case MsgData:
val, ok := rb.conns.Load(connID)
if !ok {
rb.logFn("relay[creator]: drop MsgData for unknown conn %d (payload=%dB)", connID, len(payload))
if common.Debug {
rb.logFn("relay[creator]: drop MsgData for unknown conn %d (payload=%dB)", connID, len(payload))
}
rb.send(connID, MsgClose, nil)
return
}
if c, ok := val.(net.Conn); ok {
if _, err := c.Write(payload); err != nil {
rb.logFn("relay[creator]: write to target %d failed: %s", connID, common.MaskError(err))
if common.Debug {
rb.logFn("relay[creator]: write to target %d failed: %s", connID, common.MaskError(err))
}
}
}
case MsgClose:
@@ -402,7 +406,7 @@ func (rb *RelayBridge) handleUDP(connID uint32, payload []byte) {
egress = existing
} else {
egress = created
if verboseUDPLogging {
if common.Debug {
rb.logFn("relay[creator]: UDP %d session opened -> %s payload=%dB", connID, addr, len(data))
}
go func(e *creatorUDP, id uint32, target string) {
@@ -416,14 +420,14 @@ func (rb *RelayBridge) handleUDP(connID uint32, payload []byte) {
e.setReadDeadline(time.Now().Add(60 * time.Second))
n, err := e.read(buf)
if err != nil {
if verboseUDPLogging {
if common.Debug {
rb.logFn("relay[creator]: UDP %d session %s closed after %d replies, %dB in: %v", id, target, replies, totalIn, err)
}
return
}
replies++
totalIn += int64(n)
if verboseUDPLogging && replies == 1 {
if common.Debug && replies == 1 {
rb.logFn("relay[creator]: UDP %d first reply %dB from %s", id, n, target)
}
rb.send(id, MsgUDPReply, buf[:n])
@@ -433,7 +437,9 @@ func (rb *RelayBridge) handleUDP(connID uint32, payload []byte) {
}
if err := egress.writePacket(data, addr); err != nil {
rb.logFn("relay[creator]: UDP %d write %s failed: %v", connID, common.MaskAddr(addr), err)
if common.Debug {
rb.logFn("relay[creator]: UDP %d write %s failed: %v", connID, common.MaskAddr(addr), err)
}
}
}
@@ -572,7 +578,7 @@ func (rb *RelayBridge) handleSOCKS(conn net.Conn) {
}
cmd := buf[1]
if cmd == common.CmdUDP {
if verboseUDPLogging {
if common.Debug {
rb.logFn("relay: SOCKS UDP ASSOCIATE from %s", conn.RemoteAddr())
}
rb.handleUDPAssociate(conn)
@@ -698,7 +704,7 @@ func (rb *RelayBridge) handleUDPAssociate(tcpConn net.Conn) {
reply := []byte{common.Ver, 0x00, 0x00, common.AtypIPv4, 127, 0, 0, 1, 0, 0}
binary.BigEndian.PutUint16(reply[8:10], uint16(localAddr.Port))
tcpConn.Write(reply)
if verboseUDPLogging {
if common.Debug {
rb.logFn("relay: SOCKS UDP listener bound on 127.0.0.1:%d ctrl=%s", localAddr.Port, tcpConn.RemoteAddr())
}
@@ -717,7 +723,7 @@ func (rb *RelayBridge) handleUDPAssociate(tcpConn net.Conn) {
defer func() {
sessionMu.Lock()
defer sessionMu.Unlock()
if verboseUDPLogging {
if common.Debug {
rb.logFn("relay: SOCKS UDP listener 127.0.0.1:%d closing, releasing %d sessions", localAddr.Port, len(sessionKeys))
}
for _, k := range sessionKeys {
@@ -768,7 +774,7 @@ func (rb *RelayBridge) handleUDPAssociate(tcpConn net.Conn) {
sessionMu.Lock()
sessionKeys = append(sessionKeys, mapKey)
sessionMu.Unlock()
if verboseUDPLogging {
if common.Debug {
rb.logFn("relay[joiner]: UDP session %d (%s -> %s) opened, first packet %dB", id, addr, dstAddr, n-headerLen)
}
}
+5 -1
View File
@@ -7,6 +7,8 @@ import (
"github.com/pion/webrtc/v4"
"github.com/pion/webrtc/v4/pkg/media"
"whitelist-bypass/relay/common"
)
const (
@@ -210,7 +212,9 @@ func (t *VP8DataTunnel) writerLoop() {
continue
}
if err := t.track.WriteSample(media.Sample{Data: sample, Duration: sampleInterval}); err != nil {
t.logFn("vp8tunnel: WriteSample error: %v", err)
if common.Debug {
t.logFn("vp8tunnel: WriteSample error: %v", err)
}
continue
}
n := t.sentFrames.Add(1)
+5 -1
View File
@@ -8,6 +8,8 @@ import (
"github.com/pion/webrtc/v4"
"github.com/pion/webrtc/v4/pkg/media"
"whitelist-bypass/relay/common"
)
var legacyVP8Keyframe = []byte{
@@ -190,7 +192,9 @@ func (t *VP8LegacyTunnel) writerLoop() {
}
}
if err := t.track.WriteSample(media.Sample{Data: sample, Duration: sampleInterval}); err != nil {
t.logFn("vp8tunnel-legacy: WriteSample error: %v", err)
if common.Debug {
t.logFn("vp8tunnel-legacy: WriteSample error: %v", err)
}
continue
}
n := t.sentFrames.Add(1)