network

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2019 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Inbound  = true
	Outbound = false
)

Packer Directions

View Source
const (
	IncomingHost     = "IH"
	IncomingLAN      = "IL"
	IncomingInternet = "II"
	IncomingInvalid  = "IX"
	PeerHost         = "PH"
	PeerLAN          = "PL"
	PeerInternet     = "PI"
	PeerInvalid      = "PX"
)

Non-Domain Connections

View Source
const (
	ReasonUnknownProcess = "unknown connection owner: process could not be found"
)

Static reasons

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	record.Base
	sync.Mutex

	Domain    string
	Direction bool
	Intel     *intel.Intel

	Verdict Verdict
	Reason  string
	Inspect bool

	FirstLinkEstablished int64
	LastLinkEstablished  int64
	LinkCount            uint
	// contains filtered or unexported fields
}

Connection describes a connection between a process and a domain

func GetConnection

func GetConnection(pid int, domain string) (conn *Connection, ok bool)

GetConnection fetches a connection object from the internal storage.

func GetConnectionByDNSRequest

func GetConnectionByDNSRequest(ip net.IP, port uint16, fqdn string) (*Connection, error)

GetConnectionByDNSRequest returns the matching connection from the internal storage.

func GetConnectionByFirstPacket

func GetConnectionByFirstPacket(pkt packet.Packet) (*Connection, error)

GetConnectionByFirstPacket returns the matching connection from the internal storage.

func GetUnknownConnection

func GetUnknownConnection(pkt packet.Packet) (*Connection, error)

GetUnknownConnection returns the connection to a packet of unknown owner.

func (*Connection) Accept

func (conn *Connection) Accept(reason string)

Accept accepts the connection and adds the given reason.

func (conn *Connection) AddLink(link *Link)

AddLink applies the connection to the link and increases sets counter and timestamps.

func (*Connection) AddReason

func (conn *Connection) AddReason(reason string)

AddReason adds a human readable string as to why a certain verdict was set in regard to this connection

func (*Connection) Block

func (conn *Connection) Block(reason string)

Block blocks the connection and adds the given reason.

func (*Connection) Delete

func (conn *Connection) Delete()

Delete deletes a connection from the storage and propagates the change.

func (*Connection) Deny

func (conn *Connection) Deny(reason string)

Deny blocks or drops the connection depending on the connection direction and adds the given reason.

func (*Connection) Drop

func (conn *Connection) Drop(reason string)

Drop drops the connection and adds the given reason.

func (*Connection) GetVerdict

func (conn *Connection) GetVerdict() Verdict

GetVerdict returns the current verdict.

func (*Connection) Process

func (conn *Connection) Process() *process.Process

Process returns the process that owns the connection.

func (conn *Connection) RemoveLink()

RemoveLink lowers the link counter by one.

func (*Connection) Save

func (conn *Connection) Save() error

Save saves the connection object in the storage and propagates the change.

func (*Connection) String

func (conn *Connection) String() string

String returns a string representation of Connection.

func (*Connection) UpdateVerdict

func (conn *Connection) UpdateVerdict(newVerdict Verdict)

UpdateVerdict sets a new verdict for this link, making sure it does not interfere with previous verdicts

type FirewallHandler

type FirewallHandler func(pkt packet.Packet, link *Link)

FirewallHandler defines the function signature for a firewall handle function

type Link struct {
	record.Base
	sync.Mutex

	ID string

	Verdict          Verdict
	Reason           string
	Tunneled         bool
	VerdictPermanent bool
	Inspect          bool
	Started          int64
	Ended            int64
	RemoteAddress    string
	// contains filtered or unexported fields
}

Link describes a distinct physical connection (e.g. TCP connection) - like an instance - of a Connection.

func CreateLinkFromPacket

func CreateLinkFromPacket(pkt packet.Packet) *Link

CreateLinkFromPacket creates a new Link based on Packet.

func GetLink(id string) (*Link, bool)

GetLink fetches a Link from the database from the default namespace for this object

func GetOrCreateLinkByPacket

func GetOrCreateLinkByPacket(pkt packet.Packet) (*Link, bool)

GetOrCreateLinkByPacket returns the associated Link for a packet and a bool expressing if the Link was newly created

func (*Link) Accept

func (link *Link) Accept(reason string)

Accept accepts the link and adds the given reason.

func (*Link) AddReason

func (link *Link) AddReason(reason string)

AddReason adds a human readable string as to why a certain verdict was set in regard to this link

func (*Link) ApplyVerdict

func (link *Link) ApplyVerdict(pkt packet.Packet)

ApplyVerdict appies the link verdict to a packet.

func (*Link) Block

func (link *Link) Block(reason string)

Block blocks the link and adds the given reason.

func (*Link) Connection

func (link *Link) Connection() *Connection

Connection returns the Connection the Link is part of

func (*Link) Delete

func (link *Link) Delete()

Delete deletes a link from the storage and propagates the change.

func (*Link) Deny

func (link *Link) Deny(reason string)

Deny blocks or drops the link depending on the connection direction and adds the given reason.

func (*Link) Drop

func (link *Link) Drop(reason string)

Drop drops the link and adds the given reason.

func (*Link) FirewallHandlerIsSet

func (link *Link) FirewallHandlerIsSet() bool

FirewallHandlerIsSet returns whether a firewall handler is set or not

func (*Link) GetActiveInspectors

func (link *Link) GetActiveInspectors() []bool

GetActiveInspectors returns the list of active inspectors.

func (*Link) GetInspectorData

func (link *Link) GetInspectorData() map[uint8]interface{}

GetInspectorData returns the list of inspector data.

func (*Link) GetVerdict

func (link *Link) GetVerdict() Verdict

GetVerdict returns the current verdict.

func (*Link) HandlePacket

func (link *Link) HandlePacket(pkt packet.Packet)

HandlePacket queues packet of Link for handling

func (*Link) RerouteToNameserver

func (link *Link) RerouteToNameserver()

RerouteToNameserver reroutes the link to the portmaster nameserver.

func (*Link) RerouteToTunnel

func (link *Link) RerouteToTunnel(reason string)

RerouteToTunnel reroutes the link to the tunnel entrypoint and adds the given reason for accepting the connection.

func (*Link) Save

func (link *Link) Save() error

Save saves the link object in the storage and propagates the change.

func (*Link) SetActiveInspectors

func (link *Link) SetActiveInspectors(new []bool)

SetActiveInspectors sets the list of active inspectors.

func (*Link) SetFirewallHandler

func (link *Link) SetFirewallHandler(handler FirewallHandler)

SetFirewallHandler sets the firewall handler for this link

func (*Link) SetInspectorData

func (link *Link) SetInspectorData(new map[uint8]interface{})

SetInspectorData set the list of inspector data.

func (*Link) StopFirewallHandler

func (link *Link) StopFirewallHandler()

StopFirewallHandler unsets the firewall handler

func (*Link) String

func (link *Link) String() string

String returns a string representation of Link.

func (*Link) UpdateVerdict

func (link *Link) UpdateVerdict(newVerdict Verdict)

UpdateVerdict sets a new verdict for this link, making sure it does not interfere with previous verdicts

type StorageInterface

type StorageInterface struct {
	storage.InjectBase
}

StorageInterface provices a storage.Interface to the configuration manager.

func (*StorageInterface) Get

func (s *StorageInterface) Get(key string) (record.Record, error)

Get returns a database record.

func (*StorageInterface) Query

func (s *StorageInterface) Query(q *query.Query, local, internal bool) (*iterator.Iterator, error)

Query returns a an iterator for the supplied query.

type Verdict

type Verdict uint8

Verdict describes the decision made about a connection or link.

const (
	// UNDECIDED is the default status of new connections
	UNDECIDED Verdict = iota
	ACCEPT
	BLOCK
	DROP
	RerouteToNameserver
	RerouteToTunnel
)

List of values a Status can have

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL