Documentation ¶
Index ¶
- Constants
- Variables
- func PrettyPrintTuples(tuples []*TupleAndRule, srcList map[string]*pb.RuleResponse_SetInfo, ...)
- type Converter
- func (c *Converter) GetNetworkTuple(src, dst *common.Input, config *npmconfig.Config) ([][]byte, []*TupleAndRule, map[string]*pb.RuleResponse_SetInfo, ...)
- func (c *Converter) GetNetworkTupleFile(src, dst *common.Input, npmCacheFile string, iptableSaveFile string) ([][]byte, []*TupleAndRule, map[string]*pb.RuleResponse_SetInfo, ...)
- func (c *Converter) GetProtobufRulesFromIptable(tableName string) (map[*pb.RuleResponse]struct{}, error)
- func (c *Converter) GetProtobufRulesFromIptableFile(tableName string, npmCacheFile string, iptableSaveFile string) (map[*pb.RuleResponse]struct{}, error)
- func (c *Converter) InitConverter() error
- func (c *Converter) NpmCache() error
- func (c *Converter) NpmCacheFromFile(npmCacheJSONFile string) error
- type Tuple
- type TupleAndRule
Constants ¶
const ( // ANY string ANY string = "ANY" // MinUnsortedIPSetLength indicates the minimum length of an unsorted IP set's origin (i.e dst,dst) MinUnsortedIPSetLength int = 3 // Base indicate the base for ParseInt Base int = 10 // Bitsize indicate the bitsize for ParseInt Bitsize int = 32 )
Variables ¶
var ( ErrUnknownSetType = fmt.Errorf("unknown set type") EgressChain = "AZURE-NPM-EGRESS" EgressChainPrefix = EgressChain + "-" IngressChain = "AZURE-NPM-INGRESS" IngressChainPrefix = IngressChain + "-" )
var AzureNPMChains = []string{
"AZURE-NPM-INGRESS-DROPS",
"AZURE-NPM-INGRESS-FROM",
"AZURE-NPM-INGRESS-PORT",
"AZURE-NPM-EGRESS-DROPS",
"AZURE-NPM-EGRESS-PORT",
"AZURE-NPM-EGRESS-TO",
}
AzureNPMChains contains names of chain that will be include in the result of the converter
var MembersBytes = []byte("Members")
MembersBytes is the string "Members" in bytes array
Functions ¶
func PrettyPrintTuples ¶
func PrettyPrintTuples(tuples []*TupleAndRule, srcList map[string]*pb.RuleResponse_SetInfo, dstList map[string]*pb.RuleResponse_SetInfo)
Types ¶
type Converter ¶
type Converter struct { NPMDebugEndpointHost string NPMDebugEndpointPort string Parser parse.IPTablesParser ListMap map[string]string // key: hash(value), value: one of namespace, label of namespace, multiple values SetMap map[string]string // key: hash(value), value: one of label of pods, cidr, namedport AzureNPMChains map[string]bool NPMCache npmcommon.GenericCache EnableV2NPM bool }
Converter struct
func (*Converter) GetNetworkTuple ¶
func (c *Converter) GetNetworkTuple(src, dst *common.Input, config *npmconfig.Config) ([][]byte, []*TupleAndRule, map[string]*pb.RuleResponse_SetInfo, map[string]*pb.RuleResponse_SetInfo, error)
GetNetworkTuple read from node's NPM cache and iptables-save and returns a list of hit rules between the source and the destination in JSON format and a list of tuples from those rules.
func (*Converter) GetNetworkTupleFile ¶
func (c *Converter) GetNetworkTupleFile( src, dst *common.Input, npmCacheFile string, iptableSaveFile string, ) ([][]byte, []*TupleAndRule, map[string]*pb.RuleResponse_SetInfo, map[string]*pb.RuleResponse_SetInfo, error)
GetNetworkTupleFile read from NPM cache and iptables-save files and returns a list of hit rules between the source and the destination in JSON format and a list of tuples from those rules.
func (*Converter) GetProtobufRulesFromIptable ¶
func (c *Converter) GetProtobufRulesFromIptable(tableName string) (map[*pb.RuleResponse]struct{}, error)
GetProtobufRulesFromIptable returns a list of protobuf rules from node.
func (*Converter) GetProtobufRulesFromIptableFile ¶
func (c *Converter) GetProtobufRulesFromIptableFile( tableName string, npmCacheFile string, iptableSaveFile string, ) (map[*pb.RuleResponse]struct{}, error)
GetProtobufRulesFromIptableFile returns a list of protobuf rules from npmCache and iptable-save files.
func (*Converter) InitConverter ¶
Initialize converter from node.
func (*Converter) NpmCacheFromFile ¶
NpmCacheFromFile initialize NPM cache from file.
type Tuple ¶
type Tuple struct { RuleType string `json:"ruleType"` Direction string `json:"direction"` SrcIP string `json:"srcIP"` SrcPort string `json:"srcPort"` DstIP string `json:"dstIP"` DstPort string `json:"dstPort"` Protocol string `json:"protocol"` }
Tuple struct
type TupleAndRule ¶
type TupleAndRule struct { Tuple *Tuple Rule *pb.RuleResponse }