mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-28 16:37:24 +02:00
add metrics aggregation (#3452)
This commit is contained in:
parent
86625a4ddb
commit
f67b33484b
7 changed files with 229 additions and 77 deletions
22
pkg/netutil/netutil.go
Normal file
22
pkg/netutil/netutil.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Package netutil contains various functions that help with networking.
|
||||
package netutil
|
||||
|
||||
import "net"
|
||||
|
||||
// AllocatePorts allocates random ports suitable for listening.
|
||||
func AllocatePorts(count int) ([]string, error) {
|
||||
var ports []string
|
||||
for i := 0; i < count; i++ {
|
||||
li, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, port, _ := net.SplitHostPort(li.Addr().String())
|
||||
err = li.Close()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ports = append(ports, port)
|
||||
}
|
||||
return ports, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue