pr feedback, don't write config file when we can test from the configure command. bad --tls-cert/--tls-key returns without ever opening the listener

This commit is contained in:
dovholuknf
2026-06-24 13:53:46 -04:00
parent 265ceca90f
commit baceef8e4e
2 changed files with 12 additions and 5 deletions
+7 -5
View File
@@ -104,16 +104,18 @@ func (o *ConsoleOptions) Run() error {
return err
}
// Resolve the certificate before binding so a cert error doesn't leave the listener open or
// claim the port.
cert, err := o.serverCertificate()
if err != nil {
return err
}
listenAddr := net.JoinHostPort(o.BindAddress, fmt.Sprintf("%d", o.Port))
rawLn, err := net.Listen("tcp", listenAddr)
if err != nil {
return fmt.Errorf("failed to listen on %s: %w", listenAddr, err)
}
cert, err := o.serverCertificate()
if err != nil {
return err
}
ln := tls.NewListener(rawLn, &tls.Config{Certificates: []tls.Certificate{cert}})
// ZAC bundles ship with <base href="/zac/">, so the assets the browser requests are prefixed
+5
View File
@@ -95,6 +95,11 @@ func (o *ConfigureOptions) Run() error {
if o.Path == "" {
return fmt.Errorf("--path must not be empty")
}
// The controller's spa binding rejects a path with interior separators, so fail here rather
// than write a config the controller will refuse to load.
if strings.ContainsAny(o.Path, "/\\") {
return fmt.Errorf("--path %q must be a single segment with no '/' or '\\' separators", o.Path)
}
reader := bufio.NewReader(o.In)
if err := o.ensureLocationAndAssets(reader); err != nil {