cmd/routed: document a few things better

This commit is contained in:
Cadey Ratio 2018-01-16 22:23:00 -08:00
parent ee6525661b
commit 19f3dc24ac
1 changed files with 4 additions and 1 deletions

View File

@ -26,7 +26,7 @@ const (
RPCPort uint16 = 39453 RPCPort uint16 = 39453
) )
// Server is the main server type // Server is the main server type.
type Server struct { type Server struct {
cfg *Config cfg *Config
db database.Storage db database.Storage
@ -53,6 +53,7 @@ type Config struct {
CertKey *[32]byte CertKey *[32]byte
} }
// listenTCP configures a listener for TCP+TLS agent connections.
func (s *Server) listenTCP(ctx context.Context, addr string, tcfg *tls.Config) { func (s *Server) listenTCP(ctx context.Context, addr string, tcfg *tls.Config) {
l, err := tls.Listen("tcp", addr, tcfg) l, err := tls.Listen("tcp", addr, tcfg)
if err != nil { if err != nil {
@ -77,6 +78,7 @@ func (s *Server) listenTCP(ctx context.Context, addr string, tcfg *tls.Config) {
} }
} }
// listenKCP configures a listener for KCP+TLS agent connections.
func (s *Server) listenKCP(ctx context.Context, addr string, tcfg *tls.Config) { func (s *Server) listenKCP(ctx context.Context, addr string, tcfg *tls.Config) {
l, err := kcp.Listen(addr) l, err := kcp.Listen(addr)
if err != nil { if err != nil {
@ -170,6 +172,7 @@ func (s *Server) Director(r *http.Request) {
r.Header.Del("X-Client-Ip") r.Header.Del("X-Client-Ip")
} }
// ServeHTTP proxies traffic to a remote backend based on the request meta-information.
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("X-Tor2web") != "" { if r.Header.Get("X-Tor2web") != "" {
http.Error(w, "tor2web proxy use is not allowed", 400) http.Error(w, "tor2web proxy use is not allowed", 400)