config

package
v0.0.0-...-c2cee1d Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//ModeBoth specifies to run both relay, and transit
	ModeBoth = "BOTH"

	//ModeRelay specifies to run only the relay portion
	ModeRelay = "RELAY"

	//ModeTransit specifies to run only the transit portion
	ModeTransit = "TRANSIT"
)

Variables

View Source
var (
	//ErrOptionsMode validation error for mode
	ErrOptionsMode = errors.New("server mode invalid")

	//ErrOptionsCleaning validation error that cleaning interval
	//is larger then the channel expiration
	ErrOptionsCleaning = errors.New("cleaning interval should be less then channel expiration")
)
View Source
var DefaultOptions = Options{
	Mode: ModeBoth,

	Relay: RelayOptions{
		Host:              "",
		Port:              4000,
		DBFile:            "./wormhole-relay.db",
		AllowList:         true,
		CleaningInterval:  5,
		ChannelExpiration: 11,
	},

	Transit: TransitOptions{
		Host: "",
		Port: 4001,
	},

	Logging: log.DefaultOptions,
}

DefaultOptions contains the preset default options for a server.

Functions

This section is empty.

Types

type Options

type Options struct {
	//Mode specifies in which mode should the server operate.
	//Options are:
	// - BOTH (default): Runs both the relay and transit servers on the
	//		same instance
	// - RELAY: Only run the relay server
	// - TRANSIT: Only run the transit server
	Mode string `json:"mode"`

	//Relay holds the relay portion options
	Relay RelayOptions `json:"relay"`

	//Transit holds the transit portion options
	Transit TransitOptions `json:"transit"`

	//Logging holds the options settings for logging operations
	Logging log.Options `json:"logging"`
}

Options is a JSON serializable object holding the configuration settings for running a Wormhole Server.

These options can be loaded from file, or filled in from command line. The intended hierarchy is CLI options > File > Defaults

var Opts *Options

Opts holds a global pointer to the application options

func NewOptions

func NewOptions(defaults *Options, filename string, ctx *cli.Context) (Options, error)

NewOptions compiles the Options object from the provided sources. Will use a custom defaults, or if nil the DefaultOptions object is used. Then will search the fileName json file (if provided) for options. Then will combine the CLI options provided from main(). These options cascade in order where applicable for the option. Will run the Options.Verify() method and return the error after compilation

func ReadOptionsFromFile

func ReadOptionsFromFile(filename string) (Options, error)

ReadOptionsFromFile opens the provided JSON file and marshals the data into a Options object. Returns the results, and the first error encountered. The error is either validation error, or JSON encoding error.

func (Options) Equals

func (o Options) Equals(opts Options) bool

Equals returns true if the supplied options matches these ones (this). Performs this as a deep-equals operation

func (*Options) MergeFrom

func (o *Options) MergeFrom(opt Options) error

MergeFrom combines the fields from the supplied Options parameter into this object (smartly where applicable) and run Verify on itself, returning the validation error if any happened.

func (Options) Verify

func (o Options) Verify() error

Verify checks the Options fields for validity. Returns an error if a problem is incountered

type RelayOptions

type RelayOptions struct {
	//Host portion for the servers to listen on.
	//Leaving this empty is fine as it will just use the default interface.
	Host string `json:"host"`

	//Port number for the server to listen on
	Port uint `json:"port"`

	//WelcomeMOTD set's the welcome message to be displayed on connecting
	//clients
	WelcomeMOTD string `json:"welcomeMOTD"`

	//WelcomeError is displayed to clients, and if provided will have
	//them disconnect immediately
	WelcomeError string `json:"welcomeError"`

	//DBFile path to the SQLite database file for the server to use
	DBFile string `json:"dbFile"`

	//AllowList allows clients to request a list of available nameplates
	AllowList bool `json:"allowList"`

	//CurrentVersion holds the current wormhole client version
	CurrentVersion string `json:"currentVersion"`

	//AdvertisedVersion holds the newest release version, which
	//will be advertised to clients to alert them of a new update
	AdvertisedVersion string `json:"advertisedVersion"`

	//CleaningInterval holds the time interval in which cleaning
	//operations should be ran
	CleaningInterval uint `json:"cleaningInterval"`

	//ChannelExpiration holds the time duration in which a channel
	//can exist without interaction before it is marked as dirty
	//and removed by cleaning. It is recommended this be larger
	//than the CleaningInterval field
	ChannelExpiration uint `json:"channelExpiration"` //TODO: This value is never used
}

RelayOptions holds the settings specific to the relay server operations

type TransitOptions

type TransitOptions struct {
	//Host portion for the servers to listen on.
	//Leaving this empty is fine as it will just use the default interface.
	Host string `json:"host"`

	//Port number for the server to listen on
	Port uint `json:"port"`
}

TransitOptions holds the settings specific to the transit (piping) server

Jump to

Keyboard shortcuts

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