added pty terminal support to the client side

This commit is contained in:
2025-06-21 02:43:28 +09:00
parent 01eb2edd6e
commit 6baf3b2b53
15 changed files with 748 additions and 35 deletions

View File

@ -105,6 +105,9 @@ type ClientAppConfig struct {
MaxPeers int `yaml:"max-peer-conns"` // maximum number of connections from peers
MaxRpcConns int `yaml:"max-rpc-conns"` // maximum number of rpc connections
PeerConnTmout time.Duration `yaml:"peer-conn-timeout"`
PtsUser string `yaml:"pts-user"`
PtsShell string `yaml:"pts-shell"`
XtermPtsHtmlFile string `yaml:"xterm-pts-html-file"`
}
type ServerConfig struct {

View File

@ -252,6 +252,10 @@ func client_main(ctl_addrs []string, rpc_addrs []string, route_configs []string,
var logmask hodu.LogMask
var logfile_maxsize int64
var logfile_rotate int
var pts_user string
var pts_shell string
var xterm_pts_html_file string
var xterm_pts_html string
var i int
var err error
@ -281,6 +285,9 @@ func client_main(ctl_addrs []string, rpc_addrs []string, route_configs []string,
if logfile == "" { logfile = cfg.APP.LogFile }
logfile_maxsize = cfg.APP.LogMaxSize
logfile_rotate = cfg.APP.LogRotate
pts_user = cfg.APP.PtsUser
pts_shell = cfg.APP.PtsShell
xterm_pts_html_file = cfg.APP.XtermPtsHtmlFile
config.RpcConnMax = cfg.APP.MaxRpcConns
config.PeerConnMax = cfg.APP.MaxPeers
config.PeerConnTmout = cfg.APP.PeerConnTmout
@ -305,8 +312,22 @@ func client_main(ctl_addrs []string, rpc_addrs []string, route_configs []string,
return fmt.Errorf("failed to initialize logger - %s", err.Error())
}
}
if xterm_pts_html_file != "" {
var tmp []byte
tmp, err = os.ReadFile(xterm_pts_html_file)
if err != nil {
return fmt.Errorf("failed to read %s - %s", xterm_pts_html_file, err.Error())
}
xterm_pts_html = string(tmp)
}
c = hodu.NewClient(context.Background(), HODU_NAME, logger, config)
if pts_user != "" { c.SetPtsUser(pts_user) }
if pts_shell != "" { c.SetPtsShell(pts_shell) }
if xterm_pts_html != "" { c.SetXtermPtsHtml(xterm_pts_html) }
c.StartService(&cc)
c.StartCtlService() // control channel
c.StartExtService(&signal_handler{svc:c}, nil) // signal handler task