cups

package
v3.9.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2020 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TLSCredentials

func TLSCredentials(trust *x509.Certificate, client *tls.Certificate) ([]byte, error)

TLSCredentials appends the TLS trust certificate and client credentials. Only the leaf client certificate is included.

func TokenCredentials

func TokenCredentials(trust *x509.Certificate, authorization string) ([]byte, error)

TokenCredentials appends the TLS trust certificate and the contents of the Authorization header. Only the leaf of the trust certificate is considered.

Types

type Option

type Option func(s *Server)

Option configures the CUPSServer.

func WithAllowCUPSURIUpdate

func WithAllowCUPSURIUpdate(allow bool) Option

WithAllowCUPSURIUpdate configures the CUPS server to allow updates of the CUPS Server URI.

func WithAuth

func WithAuth(auth func(ctx context.Context) grpc.CallOption) Option

WithAuth overrides the CUPS server's server auth func.

func WithDefaultLNSURI

func WithDefaultLNSURI(uri string) Option

WithDefaultLNSURI configures the CUPS server with a default LNS URI to use when no Gateway Server address is registered for a gateway.

func WithExplicitEnable

func WithExplicitEnable(enable bool) Option

WithExplicitEnable requires CUPS to be explicitly enabled with a cups attribute in the gateway registry.

func WithRegisterUnknown

func WithRegisterUnknown(owner *ttnpb.OrganizationOrUserIdentifiers, auth func(context.Context) grpc.CallOption) Option

WithRegisterUnknown configures the CUPS server to register gateways if they do not already exist in the registry. The gateways will be registered under the given owner.

func WithRegistries

func WithRegistries(registry ttnpb.GatewayRegistryClient, access ttnpb.GatewayAccessClient) Option

WithRegistries overrides the CUPS server's gateway registries.

func WithSigner

func WithSigner(keyCRC uint32, signer crypto.Signer) Option

WithSigner configures the CUPS server with a firmware signer.

func WithTLSConfig

func WithTLSConfig(tlsConfig *tls.Config) Option

WithTLSConfig configures the CUPS server with the given TLS config that will be used to lookup CUPS/LNS Root CAs.

func WithTrust

func WithTrust(cert *x509.Certificate) Option

WithTrust configures the CUPS server to return the given certificate to gateways as trusted certificate for the CUPS server. This should typically be the certificate of the Root CA in the chain of the CUPS server's TLS certificate.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server implements the Basic Station Configuration and Update Server.

func NewServer

func NewServer(c *component.Component, options ...Option) *Server

NewServer returns a new CUPS server on top of the given gateway registry and gateway access clients.

func (*Server) RegisterRoutes

func (s *Server) RegisterRoutes(web *web.Server)

RegisterRoutes implements web.Registerer

func (*Server) UpdateInfo

func (s *Server) UpdateInfo(c echo.Context) error

UpdateInfo implements the CUPS update-info handler.

type ServerConfig

type ServerConfig struct {
	ExplicitEnable  bool `name:"require-explicit-enable" description:"Require gateways to explicitly enable CUPS"`
	RegisterUnknown struct {
		Type   string `name:"account-type" description:"Type of account to register unknown gateways to (user|organization)"`
		ID     string `name:"id" description:"ID of the account to register unknown gateways to"`
		APIKey string `name:"api-key" description:"API Key to use for unknown gateway registration"`
	} `name:"owner-for-unknown"`
	Default struct {
		LNSURI string `name:"lns-uri" description:"The default LNS URI that the gateways should use"`
	} `name:"default" description:"Default gateway settings"`
	AllowCUPSURIUpdate bool `name:"allow-cups-uri-update" description:"Allow CUPS URI updates"`
}

ServerConfig is the configuration of the CUPS server.

func (ServerConfig) NewServer

func (conf ServerConfig) NewServer(c *component.Component, customOpts ...Option) *Server

NewServer returns a new CUPS server from this config on top of the component.

type UpdateInfoRequest

type UpdateInfoRequest struct {
	Router             basicstation.EUI `json:"router"`
	CUPSURI            string           `json:"cupsUri"`
	LNSURI             string           `json:"tcUri"`
	CUPSCredentialsCRC uint32           `json:"cupsCredCrc"`
	LNSCredentialsCRC  uint32           `json:"tcCredCrc"`
	Station            string           `json:"station"`
	Model              string           `json:"model"`
	Package            string           `json:"package"`
	KeyCRCs            []uint32         `json:"keys"`
}

UpdateInfoRequest is the contents of the update-info request.

type UpdateInfoResponse

type UpdateInfoResponse struct {
	CUPSURI         string
	LNSURI          string
	CUPSCredentials []byte
	LNSCredentials  []byte
	SignatureKeyCRC uint32
	Signature       []byte
	UpdateData      []byte
}

UpdateInfoResponse is the response to the update-info request.

func (UpdateInfoResponse) MarshalBinary

func (r UpdateInfoResponse) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (*UpdateInfoResponse) UnmarshalBinary

func (r *UpdateInfoResponse) UnmarshalBinary(data []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

Jump to

Keyboard shortcuts

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