natsmsgserver

package
v0.0.0-...-147f0cf Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const NoAuthUserID = "unauthenticated"

Variables

This section is empty.

Functions

This section is empty.

Types

type NatsServerConfig

type NatsServerConfig struct {
	// configurable settings
	Host   string `yaml:"host,omitempty"`   // default: localhost
	Port   int    `yaml:"port,omitempty"`   // default: 4222
	WSPort int    `yaml:"wsPort,omitempty"` // default: 0 (disabled)

	LogLevel string `yaml:"logLevel,omitempty"` // default: warn
	LogFile  string `yaml:"logFile,omitempty"`  // default: no logfile
	Debug    bool   `yaml:"debug,omitempty"`    // default: false

	MaxDataMemoryMB int    `yaml:"maxDataMemoryMB,omitempty"` // default: 1024
	DataDir         string `yaml:"dataDir,omitempty"`         // default is server default
	AppAccountName  string `yaml:"appAccountName,omitempty"`  // default: hiveot

	// Disable running the embedded messaging server. Default False
	NoAutoStart bool `yaml:"noAutoStart,omitempty"`

	// The certs and keys can be set directly or loaded from above files
	CaCert          *x509.Certificate `yaml:"-"` // preset, load, or error
	CaKey           *ecdsa.PrivateKey `yaml:"-"` // preset, load, or error
	ServerTLS       *tls.Certificate  `yaml:"-"` // preset, load, or generate
	AppAccountKP    nkeys.KeyPair     `yaml:"-"` // preset, load, or generate
	AdminUserKP     nkeys.KeyPair     `yaml:"-"` // generated
	CoreServiceKP   nkeys.KeyPair     `yaml:"-"` // generated
	SystemAccountKP nkeys.KeyPair     `yaml:"-"` // generated
	SystemUserKP    nkeys.KeyPair     `yaml:"-"` // generated

	// appAccount to use with users and nkeys
	AppAcct *server.Account `yaml:"-"`
}

NatsServerConfig holds the configuration for nkeys and jwt based servers

func (*NatsServerConfig) CreateNatsNKeyOptions

func (cfg *NatsServerConfig) CreateNatsNKeyOptions() (server.Options, error)

CreateNatsNKeyOptions create a Nats options struct for use with NKey authentication. Note that Setup() must have been called first.

func (*NatsServerConfig) LoadCreateUserKP

func (cfg *NatsServerConfig) LoadCreateUserKP(clientID string, keysDir string, writeChanges bool) (userKP nkeys.KeyPair, err error)

LoadCreateUserKP loads a user keypair, or creates one if it doesn't exist By convention the filenam is {clientID}.key

clientID is the serviceID/deviceID/userID
writeChanges if a file is given and key is generated

func (*NatsServerConfig) Setup

func (cfg *NatsServerConfig) Setup(keysDir, storesDir string, writeChanges bool) (err error)

Setup the nats server config. This applies sensible defaults to Config.

Any existing values that are previously set remain unchanged. Missing values are created. Certs and keys are loaded as per configuration.

Set 'writeChanges' to persist generated server cert, operator and account keys

	keysDir is the default key location
	storesDir is the data storage root (default $HOME/stores)
 writeChanges writes generated account key to the keysDir

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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