allow pomerium to be embedded as a library (#3415)

This commit is contained in:
Denis Mishin 2022-06-15 20:29:19 -04:00 committed by GitHub
parent 6e1ebffc59
commit d1037d784a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 292 additions and 207 deletions

View file

@ -4,6 +4,7 @@ import (
"crypto/tls"
"github.com/pomerium/pomerium/internal/hashutil"
"github.com/pomerium/pomerium/internal/netutil"
)
// Config holds pomerium configuration options.
@ -58,3 +59,19 @@ func (cfg *Config) AllCertificates() ([]tls.Certificate, error) {
func (cfg *Config) Checksum() uint64 {
return hashutil.MustHash(cfg)
}
// AllocatePorts populates
func (cfg *Config) AllocatePorts() error {
ports, err := netutil.AllocatePorts(5)
if err != nil {
return err
}
cfg.GRPCPort = ports[0]
cfg.HTTPPort = ports[1]
cfg.OutboundPort = ports[2]
cfg.MetricsPort = ports[3]
cfg.DebugPort = ports[4]
return nil
}