var validationError … type Interface … const IPSetCmd … var EntryMemberPattern … var VersionPattern … type IPSet … // Validate checks if a given ipset is valid or not. func (set *IPSet) Validate() error { … } // setIPSetDefaults sets some IPSet fields if not present to their default values. func (set *IPSet) setIPSetDefaults() { … } type Entry … // Validate checks if a given ipset entry is valid or not. The set parameter is the ipset that entry belongs to. func (e *Entry) Validate(set *IPSet) bool { … } // String returns the string format for ipset entry. func (e *Entry) String() string { … } // checkIPandProtocol checks if IP and Protocol of Entry is valid. func (e *Entry) checkIPandProtocol(set *IPSet) bool { … } // checkIP checks if IP of Entry is valid. func (e *Entry) checkIP(set *IPSet) bool { … } type runner … // New returns a new Interface which will exec ipset. func New(exec utilexec.Interface) Interface { … } // CreateSet creates a new set, it will ignore error when the set already exists if ignoreExistErr=true. func (runner *runner) CreateSet(set *IPSet, ignoreExistErr bool) error { … } // If ignoreExistErr is set to true, then the -exist option of ipset will be specified, ipset ignores the error // otherwise raised when the same set (setname and create parameters are identical) already exists. func (runner *runner) createSet(set *IPSet, ignoreExistErr bool) error { … } // AddEntry adds a new entry to the named set. // If the -exist option is specified, ipset ignores the error otherwise raised when // the same set (setname and create parameters are identical) already exists. func (runner *runner) AddEntry(entry string, set *IPSet, ignoreExistErr bool) error { … } // DelEntry is used to delete the specified entry from the set. func (runner *runner) DelEntry(entry string, set string) error { … } // TestEntry is used to check whether the specified entry is in the set or not. func (runner *runner) TestEntry(entry string, set string) (bool, error) { … } // FlushSet deletes all entries from a named set. func (runner *runner) FlushSet(set string) error { … } // DestroySet is used to destroy a named set. func (runner *runner) DestroySet(set string) error { … } // DestroyAllSets is used to destroy all sets. func (runner *runner) DestroyAllSets() error { … } // ListSets list all set names from kernel func (runner *runner) ListSets() ([]string, error) { … } // ListEntries lists all the entries from a named set. func (runner *runner) ListEntries(set string) ([]string, error) { … } // GetVersion returns the version string. func (runner *runner) GetVersion() (string, error) { … } // getIPSetVersionString runs "ipset --version" to get the version string // in the form of "X.Y", i.e "6.19" func getIPSetVersionString(exec utilexec.Interface) (string, error) { … } // checks if port range is valid. The begin port number is not necessarily less than // end port number - ipset util can accept it. It means both 1-100 and 100-1 are valid. func validatePortRange(portRange string) error { … } // checks if the given ipset type is valid. func validateIPSetType(set Type) error { … } // checks if given hash family is supported in ipset func validateHashFamily(family string) error { … } // IsNotFoundError returns true if the error indicates "not found". It parses // the error string looking for known values, which is imperfect but works in // practice. func IsNotFoundError(err error) bool { … } // checks if given protocol is supported in entry func validateProtocol(protocol string) bool { … } // parsePortRange parse the begin and end port from a raw string(format: a-b). beginPort <= endPort // in the return value. func parsePortRange(portRange string) (beginPort int, endPort int, err error) { … } var _ …