Documentation ¶
Overview ¶
Package triggers enumerates all of the various triggers that can be used to match packets.
See the top-level documentation for more details.
Index ¶
Examples ¶
Constants ¶
const ( IPFieldVersion = iota IPFieldIHL IPFieldTOS IPFieldLength IPFieldIdentification IPFieldFlags IPFieldFragmentOffset IPFieldTTL IPFieldProtocol IPFieldChecksum IPFieldSourceAddress IPFieldDestAddress IPFieldPayload )
const ( TCPFieldSourcePort = iota TCPFieldDestPort TCPFieldSeq TCPFieldAck TCPFieldDataOffset TCPFieldReserved TCPFieldFlags TCPFieldWindow TCPFieldChecksum TCPFieldUrgentPointer TCPFieldPayload TCPFieldOptionEOL TCPFieldOptionNOP TCPFieldOptionMSS TCPFieldOptionWScale TCPFieldOptionSackOk TCPFieldOptionSack TCPFieldOptionTimestamp TCPFieldOptionAltChecksum TCPFieldOptionAltChecksumOpt TCPFieldOptionMD5Header TCPFieldOptionUTO )
Variables ¶
var ErrUnsupportedOption = errors.New("unsupported option")
ErrUnsupportedOption is returned when an unsupported TCP option is specified in a trigger rule.
Functions ¶
Types ¶
type IPField ¶
type IPField int
IPField is the type of a supported IP field.
func ParseIPField ¶
ParseIPField parses a field name and returns an IPField, or an error if the field is not supported.
type IPTrigger ¶
type IPTrigger struct {
// contains filtered or unexported fields
}
IPTrigger is a Trigger that matches on the IP layer.
func NewIPTrigger ¶
NewIPTrigger creates a new IP trigger.
Example ¶
package main import ( "fmt" "github.com/getlantern/geneva/triggers" ) func main() { t, _ := triggers.NewIPTrigger("ttl", "64", 0) fmt.Printf("%s", t) }
Output: [IP:ttl:64]
func (*IPTrigger) Gas ¶
Gas denotes how many times this trigger can fire before it stops triggering.
type TCPField ¶
type TCPField int
TCPField is the type of a supported TCP field.
func ParseTCPField ¶
ParseTCPField parses a field name and returns an TCPField, or an error if the field is not supported.
type TCPTrigger ¶
type TCPTrigger struct {
// contains filtered or unexported fields
}
TCPTrigger is a Trigger that matches on the TCP layer.
func NewTCPTrigger ¶
func NewTCPTrigger(field, value string, gas int) (*TCPTrigger, error)
NewTCPTrigger creates a new TCP trigger.
Example ¶
package main import ( "fmt" "github.com/getlantern/geneva/triggers" ) func main() { t, _ := triggers.NewTCPTrigger("flags", "SA", 0) fmt.Printf("%s", t) }
Output: [TCP:flags:SA]
func (*TCPTrigger) Field ¶
func (t *TCPTrigger) Field() string
Field is an TCP-specific field name used by this trigger.
func (*TCPTrigger) Gas ¶
func (t *TCPTrigger) Gas() int
Gas denotes how many times this trigger can fire before it stops triggering.
func (*TCPTrigger) Matches ¶
func (t *TCPTrigger) Matches(pkt gopacket.Packet) (bool, error)
Matches returns whether the trigger matches the packet.
func (*TCPTrigger) Protocol ¶
func (t *TCPTrigger) Protocol() string
Protocol is the protocol that this trigger can act upon.
func (*TCPTrigger) String ¶
func (t *TCPTrigger) String() string
String returns a string representation of this trigger.
type Trigger ¶
type Trigger interface { // Protocol is the protocol that a trigger can act upon. Protocol() string // Field is a protocol-specific field name. Field() string // Gas denotes how many times this trigger can fire before it stops triggering. Gas() int // Matches returns whether the trigger matches the packet. Matches(gopacket.Packet) (bool, error) fmt.Stringer }
Trigger is implemented by any value that describes a Geneva trigger.