Documentation
¶
Overview ¶
Copyright 2015 CoreOS, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func GetIPTablesRuleSpecification(rule, specification string) string
- type Error
- type IPTables
- func (ipt *IPTables) Append(table, chain string, rulespec ...string) error
- func (ipt *IPTables) AppendUnique(table, chain string, rulespec ...string) error
- func (ipt *IPTables) ChainExists(table, chain string) (bool, error)
- func (ipt *IPTables) ChangePolicy(table, chain, target string) error
- func (ipt *IPTables) ClearAll() error
- func (ipt *IPTables) ClearAndDeleteChain(table, chain string) error
- func (ipt *IPTables) ClearChain(table, chain string) error
- func (ipt *IPTables) Delete(table, chain string, rulespec ...string) error
- func (ipt *IPTables) DeleteAll() error
- func (ipt *IPTables) DeleteChain(table, chain string) error
- func (ipt *IPTables) DeleteIfExists(table, chain string, rulespec ...string) error
- func (ipt *IPTables) Exists(table, chain string, rulespec ...string) (bool, error)
- func (ipt *IPTables) GetIptablesVersion() (int, int, int)
- func (ipt *IPTables) HasRandomFully() bool
- func (ipt *IPTables) Insert(table, chain string, pos int, rulespec ...string) error
- func (ipt *IPTables) InsertUnique(table, chain string, pos int, rulespec ...string) error
- func (ipt *IPTables) List(table, chain string) ([]string, error)
- func (ipt *IPTables) ListByID(table, chain string, id int) (string, error)
- func (ipt *IPTables) ListChains(table string) ([]string, error)
- func (ipt *IPTables) ListWithCounters(table, chain string) ([]string, error)
- func (ipt *IPTables) NewChain(table, chain string) error
- func (ipt *IPTables) ParseStat(stat []string) (parsed Stat, err error)
- func (ipt *IPTables) Proto() Protocol
- func (ipt *IPTables) RenameChain(table, oldChain, newChain string) error
- func (ipt *IPTables) Stats(table, chain string) ([][]string, error)
- func (ipt *IPTables) StructuredStats(table, chain string) ([]Stat, error)
- type Option
- type Protocol
- type Stat
- type Unlocker
Constants ¶
const ( TableFilter = "filter" ChainInput = "INPUT" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Error ¶
Adds the output of stderr to exec.ExitError
func (*Error) ExitStatus ¶
func (*Error) IsNotExist ¶
IsNotExist returns true if the error is due to the chain or rule not existing
type IPTables ¶
type IPTables struct {
// contains filtered or unexported fields
}
func New ¶
New creates a new IPTables configured with the options passed as parameter. For backwards compatibility, by default always uses IPv4 and timeout 0. i.e. you can create an IPv6 IPTables using a timeout of 5 seconds passing the IPFamily and Timeout options as follow:
ip6t := New(IPFamily(ProtocolIPv6), Timeout(5))
func NewWithProtocol ¶
New creates a new IPTables for the given proto. The proto will determine which command is used, either "iptables" or "ip6tables".
func (*IPTables) AppendUnique ¶
AppendUnique acts like Append except that it won't add a duplicate
func (*IPTables) ChainExists ¶
'-S' is fine with non existing rule index as long as the chain exists therefore pass index 1 to reduce overhead for large chains
func (*IPTables) ChangePolicy ¶
ChangePolicy changes policy on chain to target
func (*IPTables) ClearAndDeleteChain ¶
func (*IPTables) ClearChain ¶
ClearChain flushed (deletes all rules) in the specified table/chain. If the chain does not exist, a new one will be created
func (*IPTables) DeleteChain ¶
DeleteChain deletes the chain in the specified table. The chain must be empty
func (*IPTables) DeleteIfExists ¶
func (*IPTables) GetIptablesVersion ¶
Return version components of the underlying iptables command
func (*IPTables) HasRandomFully ¶
Check if the underlying iptables command supports the --random-fully flag
func (*IPTables) InsertUnique ¶
InsertUnique acts like Insert except that it won't insert a duplicate (no matter the position in the chain)
func (*IPTables) ListChains ¶
ListChains returns a slice containing the name of each chain in the specified table.
func (*IPTables) ListWithCounters ¶
List rules (with counters) in specified table/chain
func (*IPTables) NewChain ¶
NewChain creates a new chain in the specified table. If the chain already exists, it will result in an error.
func (*IPTables) ParseStat ¶
ParseStat parses a single statistic row into a Stat struct. The input should be a string slice that is returned from calling the Stat method.
func (*IPTables) RenameChain ¶
RenameChain renames the old chain to the new one.
type Stat ¶
type Stat struct {
Packets uint64 `json:"pkts"`
Bytes uint64 `json:"bytes"`
Target string `json:"target"`
Protocol string `json:"prot"`
Opt string `json:"opt"`
Input string `json:"in"`
Output string `json:"out"`
Source *net.IPNet `json:"source"`
Destination *net.IPNet `json:"destination"`
Options string `json:"options"`
}
Stat represents a structured statistic entry.