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 ¶
- type Config
- type HostnameWatcher
- type Service
- func (s *Service) DataDir() string
- func (s *Service) HiddenServiceDir() string
- func (s *Service) IsRunning() bool
- func (s *Service) OnionAddress() string
- func (s *Service) OnionWSAddress() string
- func (s *Service) Start() error
- func (s *Service) Stop() error
- func (s *Service) Upgrader() *websocket.Upgrader
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.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages the Tor subprocess and hidden service listener.
func New ¶
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
DataDir returns the Tor data directory path.
func (*Service) HiddenServiceDir ¶ added in v0.46.1
HiddenServiceDir returns the hidden service directory path.
func (*Service) IsRunning ¶
IsRunning returns whether the Tor service is currently running.
func (*Service) OnionAddress ¶
OnionAddress returns the current .onion address.
func (*Service) OnionWSAddress ¶
OnionWSAddress returns the full WebSocket URL for the hidden service. Format: ws://<address>.onion/
func (*Service) Start ¶
Start spawns the Tor subprocess and initializes the listener.
Source Files
¶
- hostname.go
- service.go