portmaster: github.com/safing/portmaster/network Index | Files | Directories

package network

import "github.com/safing/portmaster/network"


Package Files

clean.go connection.go database.go dns.go module.go status.go


const (
    Inbound  = true
    Outbound = false

Packer Directions

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

Non-Domain Scopes

func SaveOpenDNSRequest Uses

func SaveOpenDNSRequest(conn *Connection)

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

func SetDefaultFirewallHandler Uses

func SetDefaultFirewallHandler(handler FirewallHandler)

SetDefaultFirewallHandler sets the default firewall handler.

type Connection Uses

type Connection struct {

    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 Uses

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

GetConnection fetches a Connection from the database.

func NewConnectionFromDNSRequest Uses

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 Uses

func NewConnectionFromFirstPacket(pkt packet.Packet) *Connection

NewConnectionFromFirstPacket returns a new connection based on the given packet.

func (*Connection) Accept Uses

func (conn *Connection) Accept(reason string)

Accept is like AcceptWithContext but only accepts a reason.

func (*Connection) AcceptWithContext Uses

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

AcceptWithContext accepts the connection.

func (*Connection) Block Uses

func (conn *Connection) Block(reason string)

Block is like BlockWithContext but does only accepts a reason.

func (*Connection) BlockWithContext Uses

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

BlockWithContext blocks the connection.

func (*Connection) Deny Uses

func (conn *Connection) Deny(reason string)

Deny is like DenyWithContext but only accepts a reason.

func (*Connection) DenyWithContext Uses

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

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

func (*Connection) Drop Uses

func (conn *Connection) Drop(reason string)

Drop is like DropWithContext but does only accepts a reason.

func (*Connection) DropWithContext Uses

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

DropWithContext drops the connection.

func (*Connection) Failed Uses

func (conn *Connection) Failed(reason string)

Failed is like FailedWithContext but only accepts a string.

func (*Connection) FailedWithContext Uses

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

FailedWithContext marks the connection with VerdictFailed and stores the reason.

func (*Connection) GetActiveInspectors Uses

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

GetActiveInspectors returns the list of active inspectors.

func (*Connection) GetExtraRRs Uses

func (conn *Connection) GetExtraRRs(ctx context.Context, request *dns.Msg) []dns.RR

GetExtraRRs returns a slice of RRs with additional informational records.

func (*Connection) GetInspectorData Uses

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

GetInspectorData returns the list of inspector data.

func (*Connection) HandlePacket Uses

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

HandlePacket queues packet of Link for handling

func (*Connection) Process Uses

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

Process returns the connection's process.

func (*Connection) ReplyWithDNS Uses

func (conn *Connection) ReplyWithDNS(ctx context.Context, request *dns.Msg) *dns.Msg

ReplyWithDNS creates a new reply to the given request with the data from the RRCache, and additional informational records.

func (*Connection) Save Uses

func (conn *Connection) Save()

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

func (*Connection) SaveWhenFinished Uses

func (conn *Connection) SaveWhenFinished()

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

func (*Connection) SetActiveInspectors Uses

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

SetActiveInspectors sets the list of active inspectors.

func (*Connection) SetFirewallHandler Uses

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 Uses

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

SetInspectorData set the list of inspector data.

func (*Connection) SetVerdict Uses

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 Uses

func (conn *Connection) StopFirewallHandler()

StopFirewallHandler unsets the firewall handler and stops the handler worker.

func (*Connection) String Uses

func (conn *Connection) String() string

String returns a string representation of conn.

func (*Connection) UpdateAndCheck Uses

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

UpdateAndCheck updates profiles and checks whether a reevaluation is needed.

type FirewallHandler Uses

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

FirewallHandler defines the function signature for a firewall handle function

type StorageInterface Uses

type StorageInterface struct {

StorageInterface provices a storage.Interface to the configuration manager.

func (*StorageInterface) Get Uses

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

Get returns a database record.

func (*StorageInterface) Query Uses

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

Query returns a an iterator for the supplied query.

type Verdict Uses

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 Uses

func (v Verdict) String() string

func (Verdict) Verb Uses

func (v Verdict) Verb() string

Verb returns the verdict as a past tense verb.



Package network imports 23 packages (graph) and is imported by 4 packages. Updated 2020-10-17. Refresh now. Tools for package owners.