Documentation ¶
Index ¶
Constants ¶
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 ¶
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") )
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 ¶
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 ¶
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 ¶
Equals returns true if the supplied options matches these ones (this). Performs this as a deep-equals operation
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