feat: add initial implementation of osiris, the TLS terminator for Anubis

Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
Xe Iaso
2025-07-18 19:56:22 +00:00
parent 300720f030
commit 115ee97d1d
20 changed files with 650 additions and 2 deletions

View File

@@ -0,0 +1,48 @@
package config
import (
"errors"
"fmt"
"net"
)
var (
ErrCantBindToPort = errors.New("bind: can't bind to host:port")
)
type Bind struct {
HTTP string `hcl:"http"`
HTTPS string `hcl:"https"`
Metrics string `hcl:"metrics"`
}
func (b *Bind) Valid() error {
var errs []error
ln, err := net.Listen("tcp", b.HTTP)
if err != nil {
errs = append(errs, fmt.Errorf("%w %q: %w", ErrCantBindToPort, b.HTTP, err))
} else {
defer ln.Close()
}
ln, err = net.Listen("tcp", b.HTTPS)
if err != nil {
errs = append(errs, fmt.Errorf("%w %q: %w", ErrCantBindToPort, b.HTTPS, err))
} else {
defer ln.Close()
}
ln, err = net.Listen("tcp", b.Metrics)
if err != nil {
errs = append(errs, fmt.Errorf("%w %q: %w", ErrCantBindToPort, b.Metrics, err))
} else {
defer ln.Close()
}
if len(errs) != 0 {
return errors.Join(errs...)
}
return nil
}