Documentation
¶
Overview ¶
Package cups implements the CUPS protocol.
Index ¶
- func TLSCredentials(trust *x509.Certificate, client *tls.Certificate) ([]byte, error)
- func TokenCredentials(trust *x509.Certificate, authorization string) ([]byte, error)
- type Option
- func WithAllowCUPSURIUpdate(allow bool) Option
- func WithAuth(auth func(ctx context.Context) grpc.CallOption) Option
- func WithDefaultLNSURI(uri string) Option
- func WithRegisterUnknown(owner *ttnpb.OrganizationOrUserIdentifiers, ...) Option
- func WithRegistries(registry ttnpb.GatewayRegistryClient, access ttnpb.GatewayAccessClient) Option
- func WithSigner(keyCRC uint32, signer stdcrypto.Signer) Option
- func WithTLSConfig(tlsConfig *tls.Config) Option
- func WithTrust(cert *x509.Certificate) Option
- type Server
- type ServerConfig
- type UpdateInfoRequest
- type UpdateInfoResponse
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 ¶
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 ¶
WithDefaultLNSURI configures the CUPS server with a default LNS URI to use when no Gateway Server address is registered for a gateway.
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 ¶
WithSigner configures the CUPS server with a firmware signer.
func WithTLSConfig ¶
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(ctx context.Context, c *component.Component, conf ServerConfig, options ...Option) (*Server, error)
NewServer returns a new CUPS server.
func (*Server) RegisterRoutes ¶
RegisterRoutes implements web.Registerer.
func (*Server) UpdateInfo ¶
func (s *Server) UpdateInfo(w http.ResponseWriter, r *http.Request)
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. This option is ineffective"` //nolint:lll
RegisterUnknown struct {
Type string `name:"account-type" description:"Type of account to register unknown gateways to (user|organization)"` //nolint:lll
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.
type UpdateInfoRequest ¶
type UpdateInfoRequest struct {
Router id6.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.
func (*UpdateInfoRequest) ValidateContext ¶ added in v3.12.2
func (req *UpdateInfoRequest) ValidateContext(ctx context.Context) error
ValidateContext validates 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.