mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 08:50:42 +02:00
allow pomerium to be embedded as a library (#3415)
This commit is contained in:
parent
6e1ebffc59
commit
d1037d784a
27 changed files with 292 additions and 207 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue