Skip to content

Conversation

@diraneyya
Copy link

Summary

This PR adds automatic DNS re-resolution for stale handshakes and comprehensive connection state monitoring with visual feedback. The implementation addresses connection reliability issues when peer endpoints change IP addresses due to DNS updates.

Key Features

  1. Automatic DNS Re-resolution

    • Monitors handshake age every 30 seconds for active tunnels
    • Automatically re-resolves peer endpoints when handshakes exceed 135 seconds
    • Handles both stale handshakes and missing initial handshakes
    • User-configurable via Settings (enabled by default)
  2. Connection State Monitoring

    • Real-time connection state tracking: CONNECTING, CONNECTED, DISCONNECTED
    • Visual indicators with text suffixes on tunnel names
    • Persistent notifications for connection issues
    • Immediate state updates when tunnels are toggled
  3. Enhanced User Feedback

    • Connection state text suffixes in tunnel list: "(Connecting)", "(Connected)", "(Not connected)"
    • Persistent notification with custom icon for failed connections
    • Automatic notification dismissal when connection is restored or tunnel is stopped
    • Monochrome notification icon that displays correctly in system tray
  4. Log Viewer Improvements

    • Multi-line log entry support with proper text wrapping
    • Improved layout to prevent menu overlap
    • Automatic notification dismissal when tunnel is stopped

Technical Implementation

Handshake Monitoring (TunnelManager.kt):

  • Background coroutine checks every 30 seconds
  • Two thresholds:
    • Initial connection: 30 seconds without handshake → DISCONNECTED
    • Established connection: 135 seconds since last handshake → STALE
  • DNS re-resolution triggered automatically via Backend.setState()

Connection States (ConnectionState enum):

  • DOWN: Tunnel is off
  • CONNECTING: First 30s or waiting for initial handshake
  • CONNECTED: Active handshakes within 135s
  • DISCONNECTED: No handshake after 30s, or stale handshakes >135s

Visual Feedback:

  • Data binding integration for automatic UI updates
  • Connection state icons and text suffixes
  • Persistent notifications for connection failures
  • Proper notification icon rendering (monochrome white)

Configuration

Added to Settings screen:

  • "Enable automatic DNS re-resolution" (default: ON)
  • Check interval: 30 seconds (configurable constant)
  • Stale threshold: 135 seconds (configurable constant)

Testing

Tested with:

  • Dynamic DNS endpoints with IP address changes
  • Network interruptions and recovery
  • Multiple tunnel configurations
  • Always-on VPN mode
  • Lockdown mode

Commits

  • Add automatic DNS re-resolution for stale handshakes
  • Add persistent notification for connection issues
  • Fix log viewer: enable text wrapping and remove notification on tunnel stop
  • Show connection state in tunnel names and fix notification icon

🤖 Generated with Claude Code

diraneyya and others added 4 commits October 27, 2025 23:11
Implements periodic monitoring of tunnel handshakes to automatically
re-resolve DNS endpoints when handshakes become stale (>135 seconds old).
This is useful for dynamic DNS endpoints where the IP address may change
while the tunnel is running.

Key changes:
- Added handshake monitor in TunnelManager that checks every 30 seconds
- Monitor detects stale handshakes and triggers DNS re-resolution via setState()
- Added user preference toggle (enabled by default)
- Leverages existing GoBackend DNS resolution logic with retry mechanism
- Comprehensive implementation documentation in IMPLEMENTATION_DNS_RERESOLVE.md

Based on the reresolve-dns.sh script from wireguard-tools, adapted for
Android with Kotlin coroutines and user preferences.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Implement warning notifications that alert users when WireGuard connections
fail to establish or become stale. This provides immediate feedback when
tunnels show as "UP" but aren't actually working.

Features:
- Show persistent notification after 30 seconds when no handshake completes
- Show notification after 135 seconds when handshake becomes stale
- Notification is persistent (ongoing) until issue resolves
- Add DUMP_DIAGNOSTICS broadcast intent for debugging
- Request POST_NOTIFICATIONS permission on Android 13+
- Remove permission requirement for DUMP_DIAGNOSTICS action

The notification helps identify connection problems at networks that block
WireGuard, where the tunnel appears connected but no traffic flows.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
…l stop

- Remove setSingleLine() call to allow log lines to wrap naturally
- Clean up unused isSingleLine field and broken click handler
- Dismiss stale handshake notifications when tunnel is turned OFF
- Clear notifications when no tunnels are running
- Clear tracking state to prevent incorrect warnings
Add connection state text suffixes to tunnel names in the list view for
better visibility. Create monochrome notification icon to fix transparency
and display issues in the notification tray.

- Add displayName property to ObservableTunnel with state-based suffixes:
  (Connecting), (Connected), (Not connected)
- Update tunnel_list_item.xml to display the new displayName property
- Create ic_stat_disconnected.xml with monochrome white fills for notifications
- Fix notification icon in TunnelManager to use ic_stat_disconnected

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@msfjarvis
Copy link
Member

AI generated PRs are not welcome.

@msfjarvis msfjarvis closed this Oct 29, 2025
@diraneyya
Copy link
Author

@msfjarvis I completely hear you. But hear me out: if you take a look at the implementation and you welcome the results (not necessarily the code as-is), then I would be willing to learn how to write Android code properly and make sure that this PR is as human as it gets.

Behind "the AI" you're seeing are hundreds of hours of my work—troubleshooting, testing, and solving a real problem with the current app. This is genuine human effort, just not exerted at the coding level but at the problem-solving and architecture level. You may have felt insulted by my PR (because of the mischaracterization of human-AI collaboration in social media as machine-led rather than human-led), but I can be equally insulted by your quick dismissal of this vital improvement without even building and running the app. Please think about this before closing the PR without at least testing what it does.

LLMs are tools intended to make our lives and software better. In this context, it allowed me to fix something I need critically in my practice, despite not having Android expertise (note: I'm an experienced programmer and software architect, just not in Android specifically). The fact I was able to prototype what I needed quickly doesn't insult you or mean the end result can't be valued—at minimum as a working demo of functionality that's genuinely missing from this app.

This PR was born out of my 100% human contribution here: WireGuard/wireguard-tools#28, which solved the same problem for wireguard-tools when dealing with peers behind NAT+DynDNS.

TL;DR: Please run the app and evaluate the concept. If you approve the functionality, I will re-implement it without using any LLMs—but I need your commitment not to dismiss it after I invest that time. My time is worth money, and I won't contribute 50+ hours only to be rejected anyway. If that's the outcome, I'll just maintain my patched version privately rather than contributing back to the community.

Please make up your mind and let me know. Thank you.@msfjarvis I completely hear you. But hear me out, if you take a look at the implementation and you welcome the results (not necessarily the code), then I would be willing to learn how to write Android code and make sure that this PR is as human as it gets. Behind "the AI" you are describing are hundreds of hours of work from myself, troubleshooting and ensuring that this sound, this is real human effort not exerted at coding per se but a one that still counts as it is solving a real human problem with the current app. You may have felt insulted by my PR (because of the mischaracterisation of human-AI collaboration in social media as a machine led, rather than a human-led, process) but I can be equally insulted by your quick and thoughtless dismissal of this vital improvement to the app. Please think about this before you close the PR without at least building and running the app.

I have attached two screenshots.

LLM's are intended to make our life and to make our software better, and in this context it allows me to fix something that I need very much in my practice, but which I do not necessarily have the expertise to do (note that I am an excellent programmer and a software architect, but in this case have little Android knowledge). The fact I was able to prototype what I needed quickly does not come to insult you or necessarily mean that the end result cannot be honoured at least as a demo of what I personally needed and missed in this app. Please think about that before dismissing my PR.

This PR was born out of my 100% human contribution here WireGuard/wireguard-tools#28 which allowed me to achieve reliable WireGuard connectivity when dealing with a Peer behind NAT+DynDNS.

TL;DR: Please run the app and approve the concept of it and I will re-attempt without using any LLM's if this is what you would need to accept it, in which case I would ask for your commitment not to dismiss me once the code is written by me. My time is worth money and the last thing I would want to happen is contribute 50 hours only to be dismissed at the end by you. If this would happen then I would just use this patched version without contributing back to the community.

Please make up your mind and let me know. Thank

Screenshots

signal-2025-10-29-194456_002

@WireGuard WireGuard locked and limited conversation to collaborators Oct 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants