tor

package
v0.46.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2026 License: Unlicense Imports: 12 Imported by: 0

Documentation

Overview

Package tor provides Tor hidden service integration for the ORLY relay. It manages a listener on a dedicated port that receives traffic forwarded from the Tor daemon, and exposes the .onion address for NIP-11 integration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Port is the internal port that Tor forwards .onion traffic to
	Port int
	// HSDir is the Tor HiddenServiceDir path to read .onion hostname from
	HSDir string
	// OnionAddress is an optional manual override for the .onion address
	OnionAddress string
	// Handler is the HTTP handler to serve (typically the main relay handler)
	Handler http.Handler
}

Config holds Tor hidden service configuration.

type HostnameWatcher

type HostnameWatcher struct {
	// contains filtered or unexported fields
}

HostnameWatcher watches the Tor hidden service hostname file for changes. When Tor creates or updates a hidden service, it writes the .onion address to a file called "hostname" in the HiddenServiceDir.

func NewHostnameWatcher

func NewHostnameWatcher(hsDir string) *HostnameWatcher

NewHostnameWatcher creates a new hostname watcher for the given HiddenServiceDir.

func (*HostnameWatcher) Address

func (w *HostnameWatcher) Address() string

Address returns the current .onion address.

func (*HostnameWatcher) HostnameFilePath

func (w *HostnameWatcher) HostnameFilePath() string

HostnameFilePath returns the path to the hostname file.

func (*HostnameWatcher) OnChange

func (w *HostnameWatcher) OnChange(fn func(string))

OnChange sets a callback function to be called when the hostname changes.

func (*HostnameWatcher) Start

func (w *HostnameWatcher) Start() error

Start begins watching the hostname file.

func (*HostnameWatcher) Stop

func (w *HostnameWatcher) Stop()

Stop stops the hostname watcher.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service manages the Tor hidden service listener.

func New

func New(cfg *Config) (*Service, error)

New creates a new Tor service with the given configuration.

func (*Service) IsRunning

func (s *Service) IsRunning() bool

IsRunning returns whether the Tor service is currently running.

func (*Service) OnionAddress

func (s *Service) OnionAddress() string

OnionAddress returns the current .onion address (without .onion suffix).

func (*Service) OnionWSAddress

func (s *Service) OnionWSAddress() string

OnionWSAddress returns the full WebSocket URL for the hidden service. Format: ws://<address>.onion/

func (*Service) Start

func (s *Service) Start() error

Start initializes the Tor listener and hostname watcher.

func (*Service) Stop

func (s *Service) Stop() error

Stop gracefully shuts down the Tor service.

func (*Service) Upgrader

func (s *Service) Upgrader() *websocket.Upgrader

Upgrader returns a WebSocket upgrader configured for Tor connections. Tor connections don't send Origin headers, so we skip origin check.

Source Files

  • hostname.go
  • service.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL