network

package
v0.4.13 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2020 License: AGPL-3.0 Imports: 21 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 Scopes

Variables

This section is empty.

Functions

func SaveOpenDNSRequest added in v0.4.0

func SaveOpenDNSRequest(conn *Connection)

SaveOpenDNSRequest saves a dns request connection that was allowed to proceed.

func SetDefaultFirewallHandler added in v0.4.0

func SetDefaultFirewallHandler(handler FirewallHandler)

SetDefaultFirewallHandler sets the default firewall handler.

Types

type Connection

type Connection struct {
	record.Base
	sync.Mutex

	ID        string
	Scope     string
	IPVersion packet.IPVersion
	Inbound   bool

	// local endpoint
	IPProtocol packet.IPProtocol
	LocalIP    net.IP
	LocalPort  uint16

	// remote endpoint
	Entity *intel.Entity

	Verdict       Verdict
	Reason        string
	ReasonContext interface{}
	ReasonID      string // format source[:id[:id]] // TODO

	Started          int64
	Ended            int64
	Tunneled         bool
	VerdictPermanent bool
	Inspecting       bool
	Encrypted        bool // TODO
	Internal         bool // Portmaster internal connections are marked in order to easily filter these out in the UI
	// contains filtered or unexported fields
}

Connection describes a distinct physical network connection identified by the IP/Port pair.

func GetConnection

func GetConnection(id string) (*Connection, bool)

GetConnection fetches a Connection from the database.

func NewConnectionFromDNSRequest added in v0.4.0

func NewConnectionFromDNSRequest(ctx context.Context, fqdn string, cnames []string, ipVersion packet.IPVersion, localIP net.IP, localPort uint16) *Connection

NewConnectionFromDNSRequest returns a new connection based on the given dns request.

func NewConnectionFromFirstPacket added in v0.4.0

func NewConnectionFromFirstPacket(pkt packet.Packet) *Connection

NewConnectionFromFirstPacket returns a new connection based on the given packet.

func (*Connection) Accept

func (conn *Connection) Accept(reason string)

Accept is like AcceptWithContext but only accepts a reason.

func (*Connection) AcceptWithContext added in v0.4.1

func (conn *Connection) AcceptWithContext(reason string, ctx interface{})

AcceptWithContext accepts the connection.

func (*Connection) Block

func (conn *Connection) Block(reason string)

Block is like BlockWithContext but does only accepts a reason.

func (*Connection) BlockWithContext added in v0.4.1

func (conn *Connection) BlockWithContext(reason string, ctx interface{})

BlockWithContext blocks the connection.

func (*Connection) Deny

func (conn *Connection) Deny(reason string)

Deny is like DenyWithContext but only accepts a reason.

func (*Connection) DenyWithContext added in v0.4.1

func (conn *Connection) DenyWithContext(reason string, ctx interface{})

DenyWithContext blocks or drops the link depending on the connection direction.

func (*Connection) Drop

func (conn *Connection) Drop(reason string)

Drop is like DropWithContext but does only accepts a reason.

func (*Connection) DropWithContext added in v0.4.1

func (conn *Connection) DropWithContext(reason string, ctx interface{})

DropWithContext drops the connection.

func (*Connection) Failed added in v0.4.0

func (conn *Connection) Failed(reason string)

Failed is like FailedWithContext but only accepts a string.

func (*Connection) FailedWithContext added in v0.4.1

func (conn *Connection) FailedWithContext(reason string, ctx interface{})

FailedWithContext marks the connection with VerdictFailed and stores the reason.

func (*Connection) GetActiveInspectors added in v0.4.0

func (conn *Connection) GetActiveInspectors() []bool

GetActiveInspectors returns the list of active inspectors.

func (*Connection) GetInspectorData added in v0.4.0

func (conn *Connection) GetInspectorData() map[uint8]interface{}

GetInspectorData returns the list of inspector data.

func (*Connection) HandlePacket added in v0.4.0

func (conn *Connection) HandlePacket(pkt packet.Packet)

HandlePacket queues packet of Link for handling

func (*Connection) Process

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

Process returns the connection's process.

func (*Connection) Save

func (conn *Connection) Save()

Save saves the connection in the storage and propagates the change through the database system.

func (*Connection) SaveWhenFinished added in v0.4.0

func (conn *Connection) SaveWhenFinished()

SaveWhenFinished marks the connection for saving it after the firewall handler.

func (*Connection) SetActiveInspectors added in v0.4.0

func (conn *Connection) SetActiveInspectors(new []bool)

SetActiveInspectors sets the list of active inspectors.

func (*Connection) SetFirewallHandler added in v0.4.0

func (conn *Connection) SetFirewallHandler(handler FirewallHandler)

SetFirewallHandler sets the firewall handler for this link, and starts a worker to handle the packets.

func (*Connection) SetInspectorData added in v0.4.0

func (conn *Connection) SetInspectorData(new map[uint8]interface{})

SetInspectorData set the list of inspector data.

func (*Connection) SetVerdict added in v0.4.0

func (conn *Connection) SetVerdict(newVerdict Verdict, reason string, reasonCtx interface{}) (ok bool)

SetVerdict sets a new verdict for the connection, making sure it does not interfere with previous verdicts.

func (*Connection) StopFirewallHandler added in v0.4.0

func (conn *Connection) StopFirewallHandler()

StopFirewallHandler unsets the firewall handler and stops the handler worker.

func (*Connection) String

func (conn *Connection) String() string

String returns a string representation of conn.

func (*Connection) UpdateAndCheck added in v0.4.0

func (conn *Connection) UpdateAndCheck() (needsReevaluation bool)

UpdateAndCheck updates profiles and checks whether a reevaluation is needed.

type FirewallHandler

type FirewallHandler func(conn *Connection, pkt packet.Packet)

FirewallHandler defines the function signature for a firewall handle function

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 int8

Verdict describes the decision made about a connection or link.

const (
	// UNDECIDED is the default status of new connections
	VerdictUndecided           Verdict = 0
	VerdictUndeterminable      Verdict = 1
	VerdictAccept              Verdict = 2
	VerdictBlock               Verdict = 3
	VerdictDrop                Verdict = 4
	VerdictRerouteToNameserver Verdict = 5
	VerdictRerouteToTunnel     Verdict = 6
	VerdictFailed              Verdict = 7
)

List of values a Status can have

func (Verdict) String added in v0.2.5

func (v Verdict) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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