Skip to content

Conversation

@roshii
Copy link
Contributor

@roshii roshii commented Oct 30, 2025

This PR introduces support for Tor-managed hidden services, providing a more secure and simplified way to run persistent onion services without requiring Tor control port access.

Changes

Core Implementation

Modified JMHiddenService class in src/jmbase/twisted_utils.py:

  • Added detection for tor-managed: prefixed hidden service directories
  • Implemented start_tor_managed_onion() method that polls for hostname file creation
  • Added create_filesystem_onion_ep() for better code organization
  • No Tor control port connection needed in managed mode

Daemon Integration

Updated OnionMessageChannel in src/jmdaemon/onionmc.py:

  • Added _start_listener() method for cleaner listener setup
  • Modified genesis node handling to work with managed services
  • Improved error handling and callback management

Testing

Added comprehensive test coverage:

  • test/jmbase/test_twisted_utils.py: Tests for hidden service mode detection and ephemeral service creation
  • test/jmdaemon/test_onionmc.py: Tests for listener setup and different host/port configurations

Benefits

  • Optionally eliminates the need for Tor control port access, reducing attack surface
  • Hidden services ca be configured entirely in torrc, no JoinMarket-specific setup required
  • Existing ephemeral and persistent modes continue to work unchanged
  • HiddenServicePOWDefense ready 🚀

Usage

To use Tor-managed hidden services, configure your joinmarket.cfg:

[MESSAGING:onion]
hidden_service_dir = tor-managed:/path/to/tor/hidden/service/dir

The corresponding torrc entry would be:

HiddenServiceDir /path/to/tor/hidden/service/dir
HiddenServicePort 80 127.0.0.1:8080

The code automatically detects the tor-managed: prefix and switches to managed mode, polling for the hostname file that Tor creates.

@roshii roshii force-pushed the fix/hidden-service-pow branch 3 times, most recently from 2e34935 to 7ed5cff Compare November 11, 2025 16:23
@roshii roshii marked this pull request as ready for review November 11, 2025 16:25
@roshii roshii marked this pull request as draft November 11, 2025 16:58
@roshii roshii force-pushed the fix/hidden-service-pow branch 4 times, most recently from 2981e7a to d289cac Compare November 15, 2025 16:16
@roshii roshii force-pushed the fix/hidden-service-pow branch from d289cac to 6d97bec Compare November 20, 2025 20:41
@roshii roshii marked this pull request as ready for review November 20, 2025 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant