packetbrokeragent

package
v3.30.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 56 Imported by: 0

Documentation

Overview

Package packetbrokeragent contains the implementation of the Packet Broker Agent component.

Index

Constants

View Source
const DefaultGatewayOnlineTTL = 10 * time.Minute

DefaultGatewayOnlineTTL is the default time-to-live of the online status reported to Packet Broker. Packet Broker Agent must bump the online status before the previous online status expires, to keep the gateway marked online. A low value results in more calls to Packet Broker Mapper to keep gateways online. A high value results in a longer time until gateways that go offline will be marked offline on the map.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	*component.Component
	// contains filtered or unexported fields
}

Agent implements the Packet Broker Agent component, acting as Home Network.

Agent exposes the Pba interface for Packet Broker registration and routing policy management. Agent also exposes the GsPba and NsPba interfaces for forwarding uplink and subscribing to uplink.

func New

func New(c *component.Component, conf *Config, opts ...Option) (*Agent, error)

New returns a new Packet Broker Agent.

func (*Agent) Context

func (a *Agent) Context() context.Context

Context returns the context.

func (*Agent) RegisterHandlers

func (a *Agent) RegisterHandlers(s *runtime.ServeMux, conn *grpc.ClientConn)

RegisterHandlers registers gRPC handlers.

func (*Agent) RegisterServices

func (a *Agent) RegisterServices(s *grpc.Server)

RegisterServices registers services provided by a at s.

func (*Agent) Roles

func (a *Agent) Roles() []ttnpb.ClusterRole

Roles returns the Packet Broker Agent cluster role.

type Cluster added in v3.27.2

type Cluster interface {
	GetPeerConn(ctx context.Context, role ttnpb.ClusterRole, ids cluster.EntityIdentifiers) (*grpc.ClientConn, error)
	WithClusterAuth() grpc.CallOption
}

Cluster is an interface which selects for methods from the cluster component will be used in the pba.

type Config

type Config struct {
	Registration         RegistrationConfig `name:"registration" description:"Registration with Packet Broker"`
	IAMAddress           string             `name:"iam-address" description:"Address of Packet Broker IAM"`
	ControlPlaneAddress  string             `name:"control-plane-address" description:"Address of Packet Broker Control Plane"`
	DataPlaneAddress     string             `name:"data-plane-address" description:"Address of the Packet Broker Data Plane"`
	MapperAddress        string             `name:"mapper-address" description:"Address of Packet Broker Mapper"`
	Insecure             bool               `name:"insecure" description:"Connect without using TLS"`
	NetID                types.NetID        `name:"net-id" description:"LoRa Alliance NetID"`
	TenantID             string             `name:"tenant-id" description:"Tenant ID within the NetID"`
	ClusterID            string             `name:"cluster-id" description:"Cluster ID uniquely identifying the Forwarder in the NetID and Tenant ID"`
	HomeNetworkClusterID string             `name:"home-network-cluster-id" description:"Home Network Cluster ID, if different from the Cluster ID"`
	AuthenticationMode   string             `name:"authentication-mode" description:"Authentication mode (oauth2)"`
	OAuth2               OAuth2Config       `name:"oauth2" description:"OAuth 2.0 configuration"`
	Forwarder            ForwarderConfig    `name:"forwarder" description:"Forwarder configuration for publishing uplink messages and subscribing to downlink messages"`
	HomeNetwork          HomeNetworkConfig  `name:"home-network" description:"Home Network configuration for subscribing to uplink and publishing downlink messages"`
}

Config configures Packet Broker clients.

type ContactInfoConfig added in v3.12.0

type ContactInfoConfig struct {
	Email string `name:"email" description:"Email address"`
}

ContactInfoConfig defines contact info for Packet Broker.

func (ContactInfoConfig) ContactInfo added in v3.12.0

func (c ContactInfoConfig) ContactInfo(contactType ttnpb.ContactType) *ttnpb.ContactInfo

ContactInfo returns a ContactInfo proto for the configuration.

type EntityRegistry added in v3.27.2

type EntityRegistry interface {
	GetUser(ctx context.Context, req *ttnpb.GetUserRequest) (*ttnpb.User, error)
	GetOrganization(ctx context.Context, req *ttnpb.GetOrganizationRequest) (*ttnpb.Organization, error)
}

EntityRegistry abstracts the Identity server user/organization functions.

type ForwarderConfig

type ForwarderConfig struct {
	Enable            bool             `name:"enable" description:"Enable Forwarder role"`
	WorkerPool        WorkerPoolConfig `name:"worker-pool" description:"Workers pool configuration"`
	TokenKey          []byte           `name:"token-key" description:"AES 128 or 256-bit key for encrypting tokens"`
	TokenAEAD         cipher.AEAD      `name:"-"`
	IncludeGatewayEUI bool             `name:"include-gateway-eui" description:"Include the gateway EUI in forwarded metadata"`          // nolint:lll
	IncludeGatewayID  bool             `name:"include-gateway-id" description:"Include the gateway ID in forwarded metadata"`            // nolint:lll
	HashGatewayID     bool             `name:"hash-gateway-id" description:"Hash the gateway ID (if forwarded in the metadata)"`         // nolint:lll
	GatewayOnlineTTL  time.Duration    `name:"gateway-online-ttl" description:"Time-to-live of online status reported to Packet Broker"` // nolint:lll
}

ForwarderConfig defines configuration of the Forwarder role.

type GetFrequencyPlansStore added in v3.17.0

type GetFrequencyPlansStore func(ctx context.Context) (frequencyPlansStore, error)

GetFrequencyPlansStore defines a function that returns the frequencyPlansStore interface

type HomeNetworkConfig

type HomeNetworkConfig struct {
	Enable          bool                  `name:"enable" description:"Enable Home Network role"`
	DevAddrPrefixes []types.DevAddrPrefix `name:"dev-addr-prefixes" description:"DevAddr prefixes to subscribe to"`
	WorkerPool      WorkerPoolConfig      `name:"worker-pool" description:"Workers pool configuration"`
	IncludeHops     bool                  `name:"include-hops" description:"Include hops in the metadata"`
}

HomeNetworkConfig defines the configuration of the Home Network role.

type IS added in v3.27.2

type IS struct {
	Cluster
	// contains filtered or unexported fields
}

IS defines wrappers that perform grpc calls to the Identity Server.

func (IS) GetOrganization added in v3.27.2

func (is IS) GetOrganization(ctx context.Context, req *ttnpb.GetOrganizationRequest) (*ttnpb.Organization, error)

GetOrganization calls the Entity Registry with cluster auth and returns an organization.

func (IS) GetUser added in v3.27.2

func (is IS) GetUser(ctx context.Context, req *ttnpb.GetUserRequest) (*ttnpb.User, error)

GetUser calls the Entity Registry with cluster auth and returns an user.

type OAuth2Config added in v3.10.6

type OAuth2Config struct {
	ClientID     string `name:"client-id" description:"API key ID used as client ID"`
	ClientSecret string `name:"client-secret" description:"Secret API key value used as client secret"`
	TokenURL     string `name:"token-url" description:"Token URL"`
}

OAuth2Config defines OAuth 2.0 configuration for authentication.

type Option

type Option func(*Agent)

Option configures Agent.

func WithRegistrationInfo added in v3.12.0

func WithRegistrationInfo(extractor RegistrationInfoExtractor) Option

WithRegistrationInfo returns an Option that configures the Agent to use the given registration information extractor.

func WithTenantContextFiller

func WithTenantContextFiller(filler TenantContextFiller) Option

WithTenantContextFiller returns an Option that appends the given filler to the end device identifiers context fillers.

func WithTenantIDExtractor added in v3.12.0

func WithTenantIDExtractor(extractor TenantIDExtractor) Option

WithTenantIDExtractor returns an Option that configures the Agent to use the given tenant ID extractor.

type PacketBrokerClusterIDBuilder added in v3.18.2

type PacketBrokerClusterIDBuilder func(clusterID string) (string, error)

PacketBrokerClusterIDBuilder builds a Packet Broker Cluster ID from a The Things Stack Cluster ID.

type RegistrationConfig added in v3.12.0

type RegistrationConfig struct {
	Name                  string            `name:"name" description:"Friendly name to register with Packet Broker"`
	AdministrativeContact ContactInfoConfig `name:"administrative-contact" description:"Administrative contact to register with Packet Broker"`
	TechnicalContact      ContactInfoConfig `name:"technical-contact" description:"Technical contact to register with Packet Broker"`
	Listed                bool              `name:"listed" description:"List the Home Network in the Packet Broker catalog"`
}

RegistrationConfig defines the registration configuration for Packet Broker.

type RegistrationInfo added in v3.12.0

type RegistrationInfo struct {
	Name          string
	DevAddrBlocks []*ttnpb.PacketBrokerDevAddrBlock
	ContactInfo   []*ttnpb.ContactInfo
	Listed        bool
}

RegistrationInfo contains information about a Packet Broker registration.

type RegistrationInfoExtractor added in v3.12.0

type RegistrationInfoExtractor func(ctx context.Context, homeNetworkClusterID string, clusterIDBuilder PacketBrokerClusterIDBuilder) (*RegistrationInfo, error)

RegistrationInfoExtractor extracts registration information from the context.

type TenantContextFiller

type TenantContextFiller func(parent context.Context, tenantID string) (context.Context, error)

TenantContextFiller fills the parent context based on the tenant ID.

type TenantIDExtractor added in v3.12.0

type TenantIDExtractor func(ctx context.Context) string

TenantIDExtractor extracts the tenant ID from the context.

type WorkerPoolConfig

type WorkerPoolConfig struct {
	Limit int `name:"limit" description:"Limit of active workers"`
}

WorkerPoolConfig contains the worker pool configuration for a Packet Broker role.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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