From ee6d56de673da329df978b3352124527c10487a0 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sun, 29 Dec 2024 16:11:31 +0900 Subject: [PATCH] added xterm-html-file option to server.yaml --- cmd/config.go | 17 +++++++++-------- cmd/main.go | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/cmd/config.go b/cmd/config.go index 902d9b1..9075601 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -66,12 +66,13 @@ type RPCEndpointConfig struct { // rpc client-side configuration } type ServerAppConfig struct { - LogMask []string `yaml:"log-mask"` - LogFile string `yaml:"log-file"` - LogMaxSize int64 `yaml:"log-max-size"` - LogRotate int `yaml:"log-rotate"` - MaxPeers int `yaml:"max-peer-conns"` // maximum number of connections from peers - MaxRpcConns int `yaml:"max-rpc-conns"` // maximum number of rpc connections + LogMask []string `yaml:"log-mask"` + LogFile string `yaml:"log-file"` + LogMaxSize int64 `yaml:"log-max-size"` + LogRotate int `yaml:"log-rotate"` + MaxPeers int `yaml:"max-peer-conns"` // maximum number of connections from peers + MaxRpcConns int `yaml:"max-rpc-conns"` // maximum number of rpc connections + XtermHtmlFile string `yaml:"xterm-html-file"` } type ClientAppConfig struct { @@ -233,7 +234,7 @@ func make_tls_server_config(cfg *ServerTLSConfig) (*tls.Config, error) { cert, err = tls.LoadX509KeyPair(cfg.CertFile, cfg.KeyFile) } else { // use the embedded certificate - cert, err = tls.X509KeyPair(hodu_tls_cert_text, hodul_tls_key_text) + cert, err = tls.X509KeyPair(hodu_tls_cert_text, hodu_tls_key_text) } if err != nil { return nil, fmt.Errorf("failed to load key pair - %s", err) @@ -291,7 +292,7 @@ func make_tls_client_config(cfg *ClientTLSConfig) (*tls.Config, error) { cert, err = tls.LoadX509KeyPair(cfg.CertFile, cfg.KeyFile) } else { // use the embedded certificate - cert, err = tls.X509KeyPair(hodu_tls_cert_text, hodul_tls_key_text) + cert, err = tls.X509KeyPair(hodu_tls_cert_text, hodu_tls_key_text) } if err != nil { return nil, fmt.Errorf("failed to load key pair - %s", err) diff --git a/cmd/main.go b/cmd/main.go index 081af6a..7050cf9 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -22,7 +22,7 @@ var HODU_VERSION string = "0.0.0" //go:embed tls.crt var hodu_tls_cert_text []byte //go:embed tls.key -var hodul_tls_key_text []byte +var hodu_tls_key_text []byte // -------------------------------------------------------------------- type signal_handler struct { @@ -103,6 +103,8 @@ func server_main(ctl_addrs []string, rpc_addrs []string, pxy_addrs []string, wpx var logfile_rotate int var max_rpc_conns int var max_peers int + var xterm_html_file string + var xterm_html string var err error log_mask = hodu.LOG_ALL @@ -129,6 +131,7 @@ func server_main(ctl_addrs []string, rpc_addrs []string, pxy_addrs []string, wpx logfile_rotate = cfg.APP.LogRotate max_rpc_conns = cfg.APP.MaxRpcConns max_peers = cfg.APP.MaxPeers + xterm_html_file = cfg.APP.XtermHtmlFile } if len(rpc_addrs) <= 0 { @@ -144,6 +147,15 @@ func server_main(ctl_addrs []string, rpc_addrs []string, pxy_addrs []string, wpx } } + if xterm_html_file != "" { + var tmp []byte + tmp, err = os.ReadFile(xterm_html_file) + if err != nil { + return fmt.Errorf("failed to read %s - %s", xterm_html_file, err.Error()) + } + xterm_html = string(tmp) + } + s, err = hodu.NewServer( context.Background(), logger, @@ -162,6 +174,8 @@ func server_main(ctl_addrs []string, rpc_addrs []string, pxy_addrs []string, wpx return fmt.Errorf("failed to create new server - %s", err.Error()) } + if xterm_html != "" { s.SetXtermHtml(xterm_html) } + s.StartService(nil) s.StartCtlService() s.StartPxyService()