removed repeated GetId functions using struct embedding

This commit is contained in:
hyung-hwan 2024-12-27 16:52:27 +09:00
parent f1572f9321
commit 9d266180e9
9 changed files with 175 additions and 134 deletions

View File

@ -36,7 +36,7 @@ CMD_DATA=\
CMD_SRCS=\
cmd/config.go \
cmd/logger.go \
cmd/main.go \
cmd/main.go
all: $(NAME)
@ -76,4 +76,4 @@ cmd/tls.crt:
cmd/tls.key:
openssl req -x509 -newkey rsa:4096 -keyout cmd/tls.key -out cmd/tls.crt -sha256 -days 36500 -nodes -subj "/CN=$(NAME)" --addext "subjectAltName=DNS:$(NAME),IP:10.0.0.1,IP:::1"
.PHONY: clean certfiles
.PHONY: clean

View File

@ -88,36 +88,50 @@ type json_out_client_stats struct {
}
// ------------------------------------
type client_ctl_client_conns struct {
type client_ctl struct {
c *Client
id string
}
type client_ctl_client_conns struct {
client_ctl
//c *Client
//id string
}
type client_ctl_client_conns_id struct {
c *Client
client_ctl
}
type client_ctl_client_conns_id_routes struct {
c *Client
client_ctl
}
type client_ctl_client_conns_id_routes_id struct {
c *Client
client_ctl
}
type client_ctl_client_conns_id_routes_id_peers struct {
c *Client
client_ctl
}
type client_ctl_client_conns_id_routes_id_peers_id struct {
c *Client
client_ctl
}
type client_ctl_stats struct {
c *Client
client_ctl
}
// ------------------------------------
func (ctl *client_ctl_client_conns) ServeHTTP(w http.ResponseWriter, req *http.Request) {
func (ctl *client_ctl) GetId() string {
return ctl.id
}
// ------------------------------------
func (ctl *client_ctl_client_conns) ServeHTTP(w http.ResponseWriter, req *http.Request) (int, error) {
var c *Client
var status_code int
var err error
@ -217,19 +231,16 @@ func (ctl *client_ctl_client_conns) ServeHTTP(w http.ResponseWriter, req *http.R
}
done:
// TODO: need to handle x-forwarded-for and other stuff? this is not a real web service, though
c.log.Write("", LOG_DEBUG, "[%s] %s %s %d", req.RemoteAddr, req.Method, req.URL.String(), status_code) // TODO: time taken
return
return status_code, nil
oops:
c.log.Write("", LOG_ERROR, "[%s] %s %s - %s", req.RemoteAddr, req.Method, req.URL.String(), err.Error())
return
return status_code, err
}
// ------------------------------------
// client-conns/{conn_id}
func (ctl *client_ctl_client_conns_id) ServeHTTP(w http.ResponseWriter, req *http.Request) {
func (ctl *client_ctl_client_conns_id) ServeHTTP(w http.ResponseWriter, req *http.Request) (int, error) {
var c *Client
var status_code int
var err error
@ -303,18 +314,15 @@ func (ctl *client_ctl_client_conns_id) ServeHTTP(w http.ResponseWriter, req *htt
}
done:
// TODO: need to handle x-forwarded-for and other stuff? this is not a real web service, though
c.log.Write("", LOG_DEBUG, "[%s] %s %s %d", req.RemoteAddr, req.Method, req.URL.String(), status_code) // TODO: time taken
return
return status_code, nil
oops:
c.log.Write("", LOG_ERROR, "[%s] %s %s - %s", req.RemoteAddr, req.Method, req.URL.String(), err.Error())
return
return status_code, err
}
// ------------------------------------
func (ctl *client_ctl_client_conns_id_routes) ServeHTTP(w http.ResponseWriter, req *http.Request) {
func (ctl *client_ctl_client_conns_id_routes) ServeHTTP(w http.ResponseWriter, req *http.Request) (int, error) {
var c *Client
var status_code int
var err error
@ -422,18 +430,15 @@ func (ctl *client_ctl_client_conns_id_routes) ServeHTTP(w http.ResponseWriter, r
}
done:
// TODO: need to handle x-forwarded-for and other stuff? this is not a real web service, though
c.log.Write("", LOG_DEBUG, "[%s] %s %s %d", req.RemoteAddr, req.Method, req.URL.String(), status_code) // TODO: time taken
return
return status_code, nil
oops:
c.log.Write("", LOG_ERROR, "[%s] %s %s - %s", req.RemoteAddr, req.Method, req.URL.String(), err.Error())
return
return status_code, err
}
// ------------------------------------
func (ctl *client_ctl_client_conns_id_routes_id) ServeHTTP(w http.ResponseWriter, req *http.Request) {
func (ctl *client_ctl_client_conns_id_routes_id) ServeHTTP(w http.ResponseWriter, req *http.Request) (int, error) {
var c *Client
var status_code int
var err error
@ -505,18 +510,15 @@ func (ctl *client_ctl_client_conns_id_routes_id) ServeHTTP(w http.ResponseWriter
}
done:
// TODO: need to handle x-forwarded-for and other stuff? this is not a real web service, though
c.log.Write("", LOG_DEBUG, "[%s] %s %s %d", req.RemoteAddr, req.Method, req.URL.String(), status_code) // TODO: time taken
return
return status_code, nil
oops:
c.log.Write("", LOG_ERROR, "[%s] %s %s - %s", req.RemoteAddr, req.Method, req.URL.String(), err.Error())
return
return status_code, err
}
// ------------------------------------
func (ctl *client_ctl_client_conns_id_routes_id_peers) ServeHTTP(w http.ResponseWriter, req *http.Request) {
func (ctl *client_ctl_client_conns_id_routes_id_peers) ServeHTTP(w http.ResponseWriter, req *http.Request) (int, error) {
var c *Client
var status_code int
var err error
@ -586,18 +588,17 @@ func (ctl *client_ctl_client_conns_id_routes_id_peers) ServeHTTP(w http.Response
default:
status_code = http.StatusBadRequest; w.WriteHeader(status_code)
}
done:
c.log.Write("", LOG_DEBUG, "[%s] %s %s %d", req.RemoteAddr, req.Method, req.URL.String(), status_code) // TODO: time taken
return
return status_code, nil
oops:
c.log.Write("", LOG_ERROR, "[%s] %s %s - %s", req.RemoteAddr, req.Method, req.URL.String(), err.Error())
return
return status_code, err
}
// ------------------------------------
func (ctl *client_ctl_client_conns_id_routes_id_peers_id) ServeHTTP(w http.ResponseWriter, req *http.Request) {
func (ctl *client_ctl_client_conns_id_routes_id_peers_id) ServeHTTP(w http.ResponseWriter, req *http.Request) (int, error) {
var c *Client
var status_code int
var err error
@ -672,17 +673,15 @@ func (ctl *client_ctl_client_conns_id_routes_id_peers_id) ServeHTTP(w http.Respo
}
done:
c.log.Write("", LOG_DEBUG, "[%s] %s %s %d", req.RemoteAddr, req.Method, req.URL.String(), status_code) // TODO: time taken
return
return status_code, nil
oops:
c.log.Write("", LOG_ERROR, "[%s] %s %s - %s", req.RemoteAddr, req.Method, req.URL.String(), err.Error())
return
return status_code, err
}
// ------------------------------------
func (ctl *client_ctl_stats) ServeHTTP(w http.ResponseWriter, req *http.Request) {
func (ctl *client_ctl_stats) ServeHTTP(w http.ResponseWriter, req *http.Request) (int, error) {
var c *Client
var status_code int
var err error
@ -718,10 +717,8 @@ func (ctl *client_ctl_stats) ServeHTTP(w http.ResponseWriter, req *http.Request)
}
//done:
c.log.Write("", LOG_DEBUG, "[%s] %s %s %d", req.RemoteAddr, req.Method, req.URL.String(), status_code) // TODO: time taken
return
return status_code, nil
oops:
c.log.Write("", LOG_ERROR, "[%s] %s %s - %s", req.RemoteAddr, req.Method, req.URL.String(), err.Error())
return
return status_code, err
}

View File

@ -1071,6 +1071,32 @@ func (hlw *client_ctl_log_writer) Write(p []byte) (n int, err error) {
return len(p), nil
}
type ClientHttpHandler interface {
GetId() string
ServeHTTP (w http.ResponseWriter, req *http.Request) (int, error)
}
func (c *Client) wrap_http_handler(handler ClientHttpHandler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
var status_code int
var err error
var start_time time.Time
var time_taken time.Duration
start_time = time.Now()
status_code, err = handler.ServeHTTP(w, req)
time_taken = time.Now().Sub(start_time)
if status_code > 0 {
if err == nil {
c.log.Write(handler.GetId(), LOG_INFO, "[%s] %s %s %d %.9f", req.RemoteAddr, req.Method, req.URL.String(), status_code, time_taken.Seconds())
} else {
c.log.Write(handler.GetId(), LOG_INFO, "[%s] %s %s %d %.9f - %s", req.RemoteAddr, req.Method, req.URL.String(), status_code, time_taken.Seconds(), err.Error())
}
}
})
}
func NewClient(ctx context.Context, logger Logger, ctl_addrs []string, ctl_prefix string, ctltlscfg *tls.Config, rpctlscfg *tls.Config, rpc_max int, peer_max int, peer_conn_tmout time.Duration) *Client {
var c Client
var i int
@ -1091,13 +1117,21 @@ func NewClient(ctx context.Context, logger Logger, ctl_addrs []string, ctl_prefi
c.ctl_prefix = ctl_prefix
c.ctl_mux = http.NewServeMux()
c.ctl_mux.Handle(c.ctl_prefix + "/client-conns", &client_ctl_client_conns{c: &c})
c.ctl_mux.Handle(c.ctl_prefix + "/client-conns/{conn_id}", &client_ctl_client_conns_id{c: &c})
c.ctl_mux.Handle(c.ctl_prefix + "/client-conns/{conn_id}/routes", &client_ctl_client_conns_id_routes{c: &c})
c.ctl_mux.Handle(c.ctl_prefix + "/client-conns/{conn_id}/routes/{route_id}", &client_ctl_client_conns_id_routes_id{c: &c})
c.ctl_mux.Handle(c.ctl_prefix + "/client-conns/{conn_id}/routes/{route_id}/peers", &client_ctl_client_conns_id_routes_id_peers{c: &c})
c.ctl_mux.Handle(c.ctl_prefix + "/client-conns/{conn_id}/routes/{route_id}/peers/{peer_id}", &client_ctl_client_conns_id_routes_id_peers_id{c: &c})
c.ctl_mux.Handle(c.ctl_prefix + "/stats", &client_ctl_stats{c: &c})
//c.ctl_mux.Handle(c.ctl_prefix + "/client-conns", c.wrap_http_handler(&client_ctl_client_conns{c: &c, id: "ctl"}))
c.ctl_mux.Handle(c.ctl_prefix + "/client-conns",
c.wrap_http_handler(&client_ctl_client_conns{client_ctl{c: &c, id: "ctl"}}))
c.ctl_mux.Handle(c.ctl_prefix + "/client-conns/{conn_id}",
c.wrap_http_handler(&client_ctl_client_conns_id{client_ctl{c: &c, id: "ctl"}}))
c.ctl_mux.Handle(c.ctl_prefix + "/client-conns/{conn_id}/routes",
c.wrap_http_handler(&client_ctl_client_conns_id_routes{client_ctl{c: &c, id: "ctl"}}))
c.ctl_mux.Handle(c.ctl_prefix + "/client-conns/{conn_id}/routes/{route_id}",
c.wrap_http_handler(&client_ctl_client_conns_id_routes_id{client_ctl{c: &c, id: "ctl"}}))
c.ctl_mux.Handle(c.ctl_prefix + "/client-conns/{conn_id}/routes/{route_id}/peers",
c.wrap_http_handler(&client_ctl_client_conns_id_routes_id_peers{client_ctl{c: &c, id: "ctl"}}))
c.ctl_mux.Handle(c.ctl_prefix + "/client-conns/{conn_id}/routes/{route_id}/peers/{peer_id}",
c.wrap_http_handler(&client_ctl_client_conns_id_routes_id_peers_id{client_ctl{c: &c, id: "ctl"}}))
c.ctl_mux.Handle(c.ctl_prefix + "/stats",
c.wrap_http_handler(&client_ctl_stats{client_ctl{c: &c, id: "ctl"}}))
c.ctl_addr = make([]string, len(ctl_addrs))
c.ctl = make([]*http.Server, len(ctl_addrs))

View File

@ -51,6 +51,10 @@ type PXYServiceConfig struct {
Addrs []string `yaml:"addresses"`
}
type WPXServiceConfig struct {
Addrs []string `yaml:"addresses"`
}
type RPCServiceConfig struct { // rpc server-side configuration
Addrs []string `yaml:"addresses"`
}
@ -94,7 +98,7 @@ type ServerConfig struct {
} `yaml:"pxy"`
WPX struct {
Service PXYServiceConfig `yaml:"service"`
Service WPXServiceConfig `yaml:"service"`
TLS ServerTLSConfig `yaml:"tls"`
} `yaml:"wpx"`

View File

@ -144,7 +144,7 @@ func (l *AppLogger) write(id string, level hodu.LogLevel, call_depth int, fmtstr
off_m = off_s / 60;
off_h = off_m / 60;
off_m = off_m % 60;
if (off_m < 0) { off_m = -off_m; }
if off_m < 0 { off_m = -off_m; }
sb.WriteString(
fmt.Sprintf("%04d-%02d-%02d %02d:%02d:%02d %+03d%02d ",

View File

@ -15,7 +15,6 @@ import "sync"
import "syscall"
import "time"
// Don't change these items to 'const' as they can be overridden externally with a linker option
var HODU_NAME string = "hodu"
var HODU_VERSION string = "0.0.0"
@ -375,7 +374,7 @@ func main() {
if flgs.NArg() > 0 { goto wrong_usage }
if (cfgfile != "") {
if cfgfile != "" {
cfg, err = load_server_config(cfgfile)
if err != nil {
fmt.Printf ("ERROR: failed to load configuration file %s - %s\n", cfgfile, err.Error())

View File

@ -38,30 +38,40 @@ type json_out_server_stats struct {
// ------------------------------------
type server_ctl_server_conns struct {
s *Server
}
type server_ctl_server_conns_id struct {
s *Server
}
type server_ctl_server_conns_id_routes struct {
s *Server
}
type server_ctl_server_conns_id_routes_id struct {
s *Server
}
type server_ctl_stats struct {
type server_ctl struct {
s *Server
id string
}
type server_ctl_server_conns struct {
server_ctl
}
type server_ctl_server_conns_id struct {
server_ctl
}
type server_ctl_server_conns_id_routes struct {
server_ctl
}
type server_ctl_server_conns_id_routes_id struct {
server_ctl
}
type server_ctl_stats struct {
server_ctl
}
// ------------------------------------
func (ctl *server_ctl_server_conns) ServeHTTP(w http.ResponseWriter, req *http.Request) {
func (ctl *server_ctl) GetId() string {
return ctl.id
}
// ------------------------------------
func (ctl *server_ctl_server_conns) ServeHTTP(w http.ResponseWriter, req *http.Request) (int, error) {
var s *Server
var status_code int
var err error
@ -125,17 +135,15 @@ func (ctl *server_ctl_server_conns) ServeHTTP(w http.ResponseWriter, req *http.R
}
//done:
s.log.Write("", LOG_INFO, "[%s] %s %s %d", req.RemoteAddr, req.Method, req.URL.String(), status_code) // TODO: time taken
return
return status_code, nil
oops:
s.log.Write("", LOG_ERROR, "[%s] %s %s - %s", req.RemoteAddr, req.Method, req.URL.String(), err.Error())
return
return status_code, err
}
// ------------------------------------
func (ctl *server_ctl_server_conns_id) ServeHTTP(w http.ResponseWriter, req *http.Request) {
func (ctl *server_ctl_server_conns_id) ServeHTTP(w http.ResponseWriter, req *http.Request) (int, error) {
var s *Server
var status_code int
var err error
@ -198,17 +206,15 @@ func (ctl *server_ctl_server_conns_id) ServeHTTP(w http.ResponseWriter, req *htt
}
done:
s.log.Write("", LOG_INFO, "[%s] %s %s %d", req.RemoteAddr, req.Method, req.URL.String(), status_code)
return
return status_code, nil
oops:
s.log.Write("", LOG_ERROR, "[%s] %s %s - %s", req.RemoteAddr, req.Method, req.URL.String(), err.Error())
return
return status_code, err
}
// ------------------------------------
func (ctl *server_ctl_server_conns_id_routes) ServeHTTP(w http.ResponseWriter, req *http.Request) {
func (ctl *server_ctl_server_conns_id_routes) ServeHTTP(w http.ResponseWriter, req *http.Request) (int, error) {
var s *Server
var status_code int
var err error
@ -264,17 +270,15 @@ func (ctl *server_ctl_server_conns_id_routes) ServeHTTP(w http.ResponseWriter, r
}
done:
s.log.Write("", LOG_INFO, "[%s] %s %s %d", req.RemoteAddr, req.Method, req.URL.String(), status_code) // TODO: time taken
return
return status_code, nil
oops:
s.log.Write("", LOG_ERROR, "[%s] %s %s - %s", req.RemoteAddr, req.Method, req.URL.String(), err.Error())
return
return status_code, err
}
// ------------------------------------
func (ctl *server_ctl_server_conns_id_routes_id) ServeHTTP(w http.ResponseWriter, req *http.Request) {
func (ctl *server_ctl_server_conns_id_routes_id) ServeHTTP(w http.ResponseWriter, req *http.Request) (int, error) {
var s *Server
var status_code int
var conn_id string
@ -321,20 +325,14 @@ func (ctl *server_ctl_server_conns_id_routes_id) ServeHTTP(w http.ResponseWriter
}
//done:
s.log.Write("", LOG_INFO, "[%s] %s %s %d", req.RemoteAddr, req.Method, req.URL.String(), status_code) // TODO: time taken
return
return status_code, nil
oops:
s.log.Write("", LOG_ERROR, "[%s] %s %s - %s", req.RemoteAddr, req.Method, req.URL.String(), err.Error())
return
return status_code, err
}
// ------------------------------------
func (ctl *server_ctl_stats) GetId() string {
return ctl.id
}
func (ctl *server_ctl_stats) ServeHTTP(w http.ResponseWriter, req *http.Request) (int, error) {
var s *Server
var status_code int

View File

@ -31,22 +31,24 @@ var xterm_css []byte
//go:embed xterm.html
var xterm_html []byte
type server_proxy_http_init struct {
type server_proxy struct {
s *Server
prefix string
id string
}
type server_proxy_http_init struct {
server_proxy
prefix string
}
type server_proxy_http_main struct {
s *Server
server_proxy
prefix string
id string
}
type server_proxy_xterm_file struct {
s *Server
server_proxy
file string
id string
}
// ------------------------------------
@ -168,12 +170,12 @@ func mutate_proxy_req_headers(req *http.Request, newreq *http.Request, path_pref
return upgrade_required
}
// ------------------------------------
func (pxy *server_proxy_http_init) GetId() string {
func (pxy *server_proxy) GetId() string {
return pxy.id
}
// ------------------------------------
func (pxy *server_proxy_http_init) ServeHTTP(w http.ResponseWriter, req *http.Request) (int, error) {
var s *Server
var status_code int
@ -364,10 +366,6 @@ func (pxy *server_proxy_http_main) req_to_proxy_url (req *http.Request, r *Serve
}
}
func (pxy *server_proxy_http_main) GetId() string {
return pxy.id
}
func (pxy *server_proxy_http_main) ServeHTTP(w http.ResponseWriter, req *http.Request) (int, error) {
var s *Server
var r *ServerRoute
@ -489,10 +487,6 @@ type server_proxy_xterm_session_info struct {
RouteId string
}
func (pxy *server_proxy_xterm_file) GetId() string {
return pxy.id
}
func (pxy *server_proxy_xterm_file) ServeHTTP(w http.ResponseWriter, req *http.Request) (int, error) {
var s *Server
var status_code int

View File

@ -934,9 +934,9 @@ func (s *Server) wrap_http_handler(handler ServerHttpHandler) http.Handler {
if status_code > 0 {
if err == nil {
s.log.Write(handler.GetId(), LOG_INFO, "[%s] %s %s %d %v", req.RemoteAddr, req.Method, req.URL.String(), status_code, time_taken)
s.log.Write(handler.GetId(), LOG_INFO, "[%s] %s %s %d %.9f", req.RemoteAddr, req.Method, req.URL.String(), status_code, time_taken.Seconds())
} else {
s.log.Write(handler.GetId(), LOG_INFO, "[%s] %s %s %d %v - %s", req.RemoteAddr, req.Method, req.URL.String(), status_code, time_taken, err.Error())
s.log.Write(handler.GetId(), LOG_INFO, "[%s] %s %s %d %.9f - %s", req.RemoteAddr, req.Method, req.URL.String(), status_code, time_taken.Seconds(), err.Error())
}
}
})
@ -1015,11 +1015,16 @@ func NewServer(ctx context.Context, logger Logger, ctl_addrs []string, rpc_addrs
s.ctl_prefix = ctl_prefix
s.ctl_mux = http.NewServeMux()
s.ctl_mux.Handle(s.ctl_prefix + "/server-conns", &server_ctl_server_conns{s: &s})
s.ctl_mux.Handle(s.ctl_prefix + "/server-conns/{conn_id}", &server_ctl_server_conns_id{s: &s})
s.ctl_mux.Handle(s.ctl_prefix + "/server-conns/{conn_id}/routes", &server_ctl_server_conns_id_routes{s: &s})
s.ctl_mux.Handle(s.ctl_prefix + "/server-conns/{conn_id}/routes/{route_id}", &server_ctl_server_conns_id_routes_id{s: &s})
s.ctl_mux.Handle(s.ctl_prefix + "/stats", s.wrap_http_handler(&server_ctl_stats{s: &s, id: "ctl-stat"}))
s.ctl_mux.Handle(s.ctl_prefix + "/server-conns",
s.wrap_http_handler(&server_ctl_server_conns{server_ctl{s: &s, id: "ctl"}}))
s.ctl_mux.Handle(s.ctl_prefix + "/server-conns/{conn_id}",
s.wrap_http_handler(&server_ctl_server_conns_id{server_ctl{s: &s, id: "ctl"}}))
s.ctl_mux.Handle(s.ctl_prefix + "/server-conns/{conn_id}/routes",
s.wrap_http_handler(&server_ctl_server_conns_id_routes{server_ctl{s: &s, id: "ctl"}}))
s.ctl_mux.Handle(s.ctl_prefix + "/server-conns/{conn_id}/routes/{route_id}",
s.wrap_http_handler(&server_ctl_server_conns_id_routes_id{server_ctl{s: &s, id: "ctl"}}))
s.ctl_mux.Handle(s.ctl_prefix + "/stats",
s.wrap_http_handler(&server_ctl_stats{server_ctl{s: &s, id: "ctl"}}))
s.ctl_addr = make([]string, len(ctl_addrs))
s.ctl = make([]*http.Server, len(ctl_addrs))
@ -1041,16 +1046,25 @@ func NewServer(ctx context.Context, logger Logger, ctl_addrs []string, rpc_addrs
s.pxy_mux = http.NewServeMux() // TODO: make /_init,_ssh,_ssh_ws,_http configurable...
s.pxy_mux.Handle("/_ssh-ws/{conn_id}/{route_id}",
websocket.Handler(func(ws *websocket.Conn) { s.pxy_ws.ServeWebsocket(ws) }))
s.pxy_mux.Handle("/_ssh/server-conns/{conn_id}/routes/{route_id}", &server_ctl_server_conns_id_routes_id{s: &s})
s.pxy_mux.Handle("/_ssh/{conn_id}/{route_id}/", s.wrap_http_handler(&server_proxy_xterm_file{s: &s, file: "xterm.html", id: "pxy-file"}))
s.pxy_mux.Handle("/_ssh/xterm.js", s.wrap_http_handler(&server_proxy_xterm_file{s: &s, file: "xterm.js", id: "pxy-file"}))
s.pxy_mux.Handle("/_ssh/xterm-addon-fit.js", s.wrap_http_handler(&server_proxy_xterm_file{s: &s, file: "xterm-addon-fit.js", id: "pxy-file"}))
s.pxy_mux.Handle("/_ssh/xterm.css", s.wrap_http_handler(&server_proxy_xterm_file{s: &s, file: "xterm.css", id: "pxy-file"}))
s.pxy_mux.Handle("/_ssh/", s.wrap_http_handler(&server_proxy_xterm_file{s: &s, file: "_forbidden", id: "pxy-file"}))
s.pxy_mux.Handle("/_ssh/server-conns/{conn_id}/routes/{route_id}",
s.wrap_http_handler(&server_ctl_server_conns_id_routes_id{server_ctl{s: &s, id: "pxy-ctl"}}))
s.pxy_mux.Handle("/_ssh/{conn_id}/{route_id}/",
s.wrap_http_handler(&server_proxy_xterm_file{server_proxy: server_proxy{s: &s, id: "pxy-file"}, file: "xterm.html"}))
s.pxy_mux.Handle("/_ssh/xterm.js",
s.wrap_http_handler(&server_proxy_xterm_file{server_proxy: server_proxy{s: &s, id: "pxy-file"}, file: "xterm.js"}))
s.pxy_mux.Handle("/_ssh/xterm-addon-fit.js",
s.wrap_http_handler(&server_proxy_xterm_file{server_proxy: server_proxy{s: &s, id: "pxy-file"}, file: "xterm-addon-fit.js"}))
s.pxy_mux.Handle("/_ssh/xterm.css",
s.wrap_http_handler(&server_proxy_xterm_file{server_proxy: server_proxy{s: &s, id: "pxy-file"}, file: "xterm.css"}))
s.pxy_mux.Handle("/_ssh/",
s.wrap_http_handler(&server_proxy_xterm_file{server_proxy: server_proxy{s: &s, id: "pxy-file"}, file: "_forbidden"}))
s.pxy_mux.Handle("/_http/{conn_id}/{route_id}/{trailer...}", s.wrap_http_handler(&server_proxy_http_main{s: &s, prefix: "/_http", id: "pxy-http"}))
s.pxy_mux.Handle("/_init/{conn_id}/{route_id}/{trailer...}", s.wrap_http_handler(&server_proxy_http_init{s: &s, prefix: "/_init", id: "pxy-http"}))
s.pxy_mux.Handle("/", s.wrap_http_handler(&server_proxy_http_main{s: &s, prefix: "", id: "pxy-http"}))
s.pxy_mux.Handle("/_http/{conn_id}/{route_id}/{trailer...}",
s.wrap_http_handler(&server_proxy_http_main{server_proxy: server_proxy{s: &s, id: "pxy-http"}, prefix: "/_http"}))
s.pxy_mux.Handle("/_init/{conn_id}/{route_id}/{trailer...}",
s.wrap_http_handler(&server_proxy_http_init{server_proxy: server_proxy{s: &s, id: "pxy-http"}, prefix: "/_init"}))
s.pxy_mux.Handle("/",
s.wrap_http_handler(&server_proxy_http_main{server_proxy: server_proxy{s: &s, id: "pxy-http"}, prefix: ""}))
s.pxy_addr = make([]string, len(pxy_addrs))
s.pxy = make([]*http.Server, len(pxy_addrs))
@ -1069,7 +1083,8 @@ func NewServer(ctx context.Context, logger Logger, ctl_addrs []string, rpc_addrs
// ---------------------------------------------------------
s.wpx_mux = http.NewServeMux()
s.wpx_mux.Handle("/{port_id}/{trailer...}", s.wrap_http_handler(&server_proxy_http_main{s: &s, prefix: PORT_ID_MARKER, id: "wpx"}))
s.wpx_mux.Handle("/{port_id}/{trailer...}",
s.wrap_http_handler(&server_proxy_http_main{server_proxy: server_proxy{s: &s, id: "wpx"}, prefix: PORT_ID_MARKER}))
s.wpx_mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(http.StatusForbidden)
})