-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.go
More file actions
34 lines (29 loc) · 887 Bytes
/
server.go
File metadata and controls
34 lines (29 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package tornago
// Server exposes Tor SocksPort and ControlPort addresses for clients to use.
type Server interface {
// SocksAddr returns the Tor SocksPort address.
SocksAddr() string
// ControlAddr returns the Tor ControlPort address.
ControlAddr() string
}
// server is the default Server implementation backed by ServerConfig.
type server struct {
// cfg holds the resolved server configuration.
cfg ServerConfig
}
// NewServer builds a Server from the given configuration.
func NewServer(cfg ServerConfig) (Server, error) {
cfg, err := normalizeServerConfig(cfg)
if err != nil {
return nil, err
}
return &server{cfg: cfg}, nil
}
// SocksAddr returns the Tor SocksPort address.
func (s *server) SocksAddr() string {
return s.cfg.SocksAddr()
}
// ControlAddr returns the Tor ControlPort address.
func (s *server) ControlAddr() string {
return s.cfg.ControlAddr()
}