tor

package
v0.52.4 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: Unlicense Imports: 15 Imported by: 0

Documentation

Overview

Package tor provides Tor hidden service integration for the ORLY relay. It spawns a tor subprocess with automatic configuration and manages the hidden service lifecycle.

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 for the hidden service
	Port int
	// DataDir is the directory for Tor data (torrc, keys, hostname, etc.)
	DataDir string
	// Binary is the path to the tor executable
	Binary string
	// SOCKSPort is the port for outbound SOCKS connections (0 = disabled)
	SOCKSPort int
	// Handler is the HTTP handler to serve (typically the main relay handler)
	Handler http.Handler
}

Config holds Tor subprocess 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 subprocess and hidden service listener.

func New

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

New creates a new Tor service with the given configuration. Returns an error if the tor binary is not found.

func (*Service) DataDir added in v0.46.1

func (s *Service) DataDir() string

DataDir returns the Tor data directory path.

func (*Service) HiddenServiceDir added in v0.46.1

func (s *Service) HiddenServiceDir() string

HiddenServiceDir returns the hidden service directory path.

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.

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 spawns the Tor subprocess and initializes the listener.

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