renamed pts to pty to avoid name collision

This commit is contained in:
2025-08-08 19:24:52 +09:00
parent 3fd91b2c45
commit d0f1663bf3
15 changed files with 470 additions and 298 deletions

View File

@ -146,11 +146,11 @@ type Client struct {
conns atomic.Int64
routes atomic.Int64
peers atomic.Int64
pts_sessions atomic.Int64
pty_sessions atomic.Int64
}
pts_user string
pts_shell string
pty_user string
pty_shell string
xterm_html string
}
@ -1348,6 +1348,16 @@ start_over:
cts.C.log.Write(cts.Sid, LOG_ERROR, "Invalid conn_notice packet from %s", cts.remote_addr_p)
}
case PACKET_KIND_RPTY_START:
// TODO:
case PACKET_KIND_RPTY_STOP:
// TODO:
case PACKET_KIND_RPTY_DATA:
// TODO:
case PACKET_KIND_RPTY_EOF:
// TODO:
default:
// do nothing. ignore the rest
}
@ -1646,28 +1656,27 @@ func NewClient(ctx context.Context, name string, logger Logger, cfg *ClientConfi
c.ctl_mux.Handle("/_ctl/events",
c.SafeWrapWebsocketHandler(c.WrapWebsocketHandler(&client_ctl_ws{client_ctl{c: &c, id: HS_ID_CTL}})))
c.ctl_mux.Handle("/_pty/ws",
c.SafeWrapWebsocketHandler(c.WrapWebsocketHandler(&client_pty_ws{C: &c, Id: HS_ID_CTL})))
c.ctl_mux.Handle("/_pts/ws",
c.SafeWrapWebsocketHandler(c.WrapWebsocketHandler(&client_pts_ws{C: &c, Id: HS_ID_CTL})))
c.ctl_mux.Handle("/_pts/xterm.js",
c.WrapHttpHandler(&client_pts_xterm_file{client_ctl: client_ctl{c: &c, id: HS_ID_CTL}, file: "xterm.js"}))
c.ctl_mux.Handle("/_pts/xterm.js/",
c.WrapHttpHandler(&client_pts_xterm_file{client_ctl: client_ctl{c: &c, id: HS_ID_CTL}, file: "_forbidden"}))
c.ctl_mux.Handle("/_pts/xterm-addon-fit.js",
c.WrapHttpHandler(&client_pts_xterm_file{client_ctl: client_ctl{c: &c, id: HS_ID_CTL}, file: "xterm-addon-fit.js"}))
c.ctl_mux.Handle("/_pts/xterm-addon-fit.js/",
c.WrapHttpHandler(&client_pts_xterm_file{client_ctl: client_ctl{c: &c, id: HS_ID_CTL}, file: "_forbidden"}))
c.ctl_mux.Handle("/_pts/xterm.css",
c.WrapHttpHandler(&client_pts_xterm_file{client_ctl: client_ctl{c: &c, id: HS_ID_CTL}, file: "xterm.css"}))
c.ctl_mux.Handle("/_pts/xterm.css/",
c.WrapHttpHandler(&client_pts_xterm_file{client_ctl: client_ctl{c: &c, id: HS_ID_CTL}, file: "_forbidden"}))
c.ctl_mux.Handle("/_pts/xterm.html",
c.WrapHttpHandler(&client_pts_xterm_file{client_ctl: client_ctl{c: &c, id: HS_ID_CTL}, file: "xterm.html"}))
c.ctl_mux.Handle("/_pts/xterm.html/", // without this forbidden, /_pts/xterm.js/ access resulted in xterm.html.
c.WrapHttpHandler(&client_pts_xterm_file{client_ctl: client_ctl{c: &c, id: HS_ID_CTL}, file: "_forbidden"}))
c.ctl_mux.Handle("/_pts/",
c.WrapHttpHandler(&client_pts_xterm_file{client_ctl: client_ctl{c: &c, id: HS_ID_CTL}, file: "_redir:xterm.html"}))
c.ctl_mux.Handle("/_pty/xterm.js",
c.WrapHttpHandler(&client_pty_xterm_file{client_ctl: client_ctl{c: &c, id: HS_ID_CTL}, file: "xterm.js"}))
c.ctl_mux.Handle("/_pty/xterm.js/",
c.WrapHttpHandler(&client_pty_xterm_file{client_ctl: client_ctl{c: &c, id: HS_ID_CTL}, file: "_forbidden"}))
c.ctl_mux.Handle("/_pty/xterm-addon-fit.js",
c.WrapHttpHandler(&client_pty_xterm_file{client_ctl: client_ctl{c: &c, id: HS_ID_CTL}, file: "xterm-addon-fit.js"}))
c.ctl_mux.Handle("/_pty/xterm-addon-fit.js/",
c.WrapHttpHandler(&client_pty_xterm_file{client_ctl: client_ctl{c: &c, id: HS_ID_CTL}, file: "_forbidden"}))
c.ctl_mux.Handle("/_pty/xterm.css",
c.WrapHttpHandler(&client_pty_xterm_file{client_ctl: client_ctl{c: &c, id: HS_ID_CTL}, file: "xterm.css"}))
c.ctl_mux.Handle("/_pty/xterm.css/",
c.WrapHttpHandler(&client_pty_xterm_file{client_ctl: client_ctl{c: &c, id: HS_ID_CTL}, file: "_forbidden"}))
c.ctl_mux.Handle("/_pty/xterm.html",
c.WrapHttpHandler(&client_pty_xterm_file{client_ctl: client_ctl{c: &c, id: HS_ID_CTL}, file: "xterm.html"}))
c.ctl_mux.Handle("/_pty/xterm.html/", // without this forbidden, /_pty/xterm.js/ access resulted in xterm.html.
c.WrapHttpHandler(&client_pty_xterm_file{client_ctl: client_ctl{c: &c, id: HS_ID_CTL}, file: "_forbidden"}))
c.ctl_mux.Handle("/_pty/",
c.WrapHttpHandler(&client_pty_xterm_file{client_ctl: client_ctl{c: &c, id: HS_ID_CTL}, file: "_redir:xterm.html"}))
c.ctl_addr = make([]string, len(cfg.CtlAddrs))
c.ctl = make([]*http.Server, len(cfg.CtlAddrs))
@ -1688,7 +1697,7 @@ func NewClient(ctx context.Context, name string, logger Logger, cfg *ClientConfi
c.stats.conns.Store(0)
c.stats.routes.Store(0)
c.stats.peers.Store(0)
c.stats.pts_sessions.Store(0)
c.stats.pty_sessions.Store(0)
return &c
}
@ -1985,20 +1994,20 @@ func (c *Client) GetXtermHtml() string {
return c.xterm_html
}
func (c *Client) SetPtsUser(user string) {
c.pts_user = user
func (c *Client) SetPtyUser(user string) {
c.pty_user = user
}
func (c *Client) GetPtsUser() string {
return c.pts_user
func (c *Client) GetPtyUser() string {
return c.pty_user
}
func (c *Client) SetPtsShell(user string) {
c.pts_shell = user
func (c *Client) SetPtyShell(user string) {
c.pty_shell = user
}
func (c *Client) GetPtsShell() string {
return c.pts_shell
func (c *Client) GetPtyShell() string {
return c.pty_shell
}
func (c *Client) RunCtlTask(wg *sync.WaitGroup) {