-
Notifications
You must be signed in to change notification settings - Fork 51
/
service.go
42 lines (31 loc) · 1.02 KB
/
service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package common
import (
"net"
"github.com/aporeto-inc/trireme-lib/utils/portspec"
)
// Service is a protocol/port service of interest - used to pass user requests
type Service struct {
// Ports are the corresponding ports
Ports *portspec.PortSpec `json:"ports,omitempty"`
// Port is the service port. This has been deprecated and will be removed in later releases 01/13/2018
Port uint16
// Protocol is the protocol number
Protocol uint8 `json:"protocol,omitempty"`
// Addresses are the IP addresses. An empty list means 0.0.0.0/0
Addresses []*net.IPNet `json:"addresses,omitempty"`
// FQDNs is the list of FQDNs for the service.
FQDNs []string `json:"fqdns,omitempty"`
}
// ConvertServicesToPortList converts an array of services to a port list
func ConvertServicesToPortList(services []Service) string {
portlist := ""
for _, s := range services {
portlist = portlist + s.Ports.String() + ","
}
if len(portlist) == 0 {
portlist = "0"
} else {
portlist = string(portlist[:len(portlist)-1])
}
return portlist
}