config

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package config describes configuration for all of Aetherometer. Aetherometer configuration is written in the TOML format. https://toml.io/en/

Example

The following shows an example TOML config file for Aetherometer.

api_port = 0
disable_auth = false
local_token = "foobar-token"

[sources]
	data_path = "C:\\path\\to\\aetherometer\\resources\\datasheets"

	[sources.maps]
		cache = "C:\\path\\to\\aetherometer\\resources\\maps"
		api_path = ""

[adapters]
	[adapters.hook]
		enabled = true
		dll_path = "C:\\path\\to\\aetherometer\\resources\\win\\deucalion.dll"
		ffxiv_process = "ffxiv_dx11.exe"

[plugins]
"Inspector" = "https://ff14wed.github.io/inspector-plugin/"
"Craftlog" = "https://ff14wed.github.io/craftlog-plugin/"

Config File vs UI Settings

Some of this configuration can also be set in the Aetherometer UI rather than changing it in the file. All changes are synchronized between the application and the file, so there is no issue of out-of-sync configuration. However, some configuration requires a restart of Aetherometer to take effect.

Also note that any comments written in the configuration file will be LOST if you change any configuration in the UI, so it is wise to backup the config file if you really need to.

API Port

The field `api_port` configures the port on which the GraphQL API server will listen. For example, if this value is set to 8080, the server will be queryable on http://localhost:8080/query

Requires a restart of Aetherometer for any changes to this field to take effect.

Disable Auth

Setting `disable_auth` to `true` allows plugins to query the API server without an auth token. CORS validation is still enforced, so web-based plugins are still rejected unless they originate from localhost. Intended for development purposes only. DISABLE AT YOUR OWN RISK.

Token for local plugins

The `local_token` field allows local plugins to specify this token in the Authorization header for the API in order to gain access. This token may not be used from a remote origin.

Auto Update

Setting `auto_update` to `true` allows Aetherometer to download required resources if they are outdated or if they do not exist.

Sources Table

This table is primarily concerned with the configuration of data and map image sources.

Data Path

The field `sources.data_path` configures the location of the CSV files containing FFXIV data. This directory must exist if the TOML config file is provided.

Map Cache

The field `sources.map.cache` configures the location of the map cache. This directory must exist if the TOML config file is provided.

Map API Path

The field `sources.map.api_path` configures where to pull map images from if they do not exist locally. Defaults to "https://xivapi.com"

Adapters Table

This table lists configuration of the various ingress adapters that Aetherometer supports. Currently, only the "hook" adapter for Windows is supported.

Hook Adapter

The table `[adapters.hook]` contains configuration for the "hook" adapter (Windows only). This adapter will automatically inject a hook into each FFXIV process and read networked data to your Aetherometer instance.

Setting the field `adapters.hook.enabled` to `true` enables the adapter.

The field `adapters.hook.dll_path` specifies the hook DLL to inject into FFXIV processes.

The field `adapters.hook.ffxiv_process` should be set to the name of the FFXIV process into which to inject the hook. Generally it should be set to "ffxiv_dx11.exe", but change it "ffxiv.exe" if you are using DirectX 9.

Plugins Table

This table contains a map of plugins, where the key is the display name of the plugin and the value is the URL of the plugin.

If the plugin is a webpage-based plugin, it must be provided in this list in order to be authorized to access the Aetherometer API.

"My Plugin" = "https://foo.com/my/plugin"
"Other Plugin" = "https://bar.com/other/plugin"

In the above example, "My Plugin" and "Other Plugin" will be the display names of the two plugins added. Note that the scheme ("https://" part of the URL) is required.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapters

type Adapters struct {
	// Hook provides the configuration for the Hook adapter.
	Hook HookConfig `toml:"hook"`
	// contains filtered or unexported fields
}

Adapters stores configuration structs for adapters

func (Adapters) IsEnabled

func (a Adapters) IsEnabled(adapterName string) bool

IsEnabled returns whether or not the provided adapter name is enabled

type Config

type Config struct {
	// APIPort provides the port on which the core API is served.
	APIPort uint16 `toml:"api_port"`

	// DisableAuth allows plugins to query the API server without an auth token.
	// CORS validation is still enforced.
	DisableAuth bool `toml:"disable_auth,omitempty"`

	// LocalToken allows local plugins to authenticate with the API with this
	// token. If empty, it does not allow authentication with an empty string.
	LocalToken string `toml:"local_token,omitempty"`

	// AutoUpdate allows Aetherometer the ability to downloaded required resources
	// if they are outdated or do not exist.
	AutoUpdate bool `toml:"auto_update,omitempty"`

	// Sources contains configuration for data sources.
	Sources Sources `toml:"sources"`

	// Adapters contains the configuration for all the adapters enabled for
	// the core API.
	Adapters Adapters `toml:"adapters"`

	// Plugins is a name -> URL dictionary that allows the listed plugins to
	// access the API and pass CORS validation.  Note that the plugin scheme
	// must be provided.
	Plugins map[string]string `toml:"plugins" json:"Plugins"`
}

Config stores configuration values for the Aetherometer core

func (*Config) Validate

func (c *Config) Validate() error

Validate returns an error when the provided configuration values do not pass validation

type Duration

type Duration time.Duration

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

type HookConfig

type HookConfig struct {
	// Enabled toggles whether or not the Hook adapter is enabled.
	Enabled bool `toml:"enabled"`

	// DLLPath sets the path of the Hook DLL on the system.
	DLLPath string `toml:"dll_path" validate:"file"`

	// FFXIVProcess is the name of the exe file for the game.
	FFXIVProcess string `toml:"ffxiv_process" validate:"nonempty"`

	// DialRetryInterval controls how long to wait before retrying
	// failures to make a connection with the hook DLL.
	// Defaults to 500 milliseconds.
	DialRetryInterval Duration `toml:"dial_retry_interval,omitzero"`

	// PingInterval controls the interval between liveness checks to
	// hook. Defaults to 1 second.
	PingInterval Duration `toml:"ping_interval,omitzero"`
}

HookConfig stores the configuration for the hook adapter

type MapConfig

type MapConfig struct {
	// Cache provides the path of the maps on the local disk.
	Cache string `toml:"cache" validate:"directory"`

	// APIPath provides the URL of an xivapi environment serving the maps if the
	// map could not be found on the local disk. Defaults to https://xivapi.com.
	APIPath string `toml:"api_path"`
}

Maps sets the configuration for the Map endpoint of the API.

type Provider

type Provider struct {
	UpdateEvents *hub.NotifyHub[struct{}]
	ErrorEvents  *hub.NotifyHub[string]
	// contains filtered or unexported fields
}

Provider provides access to a constantly updating config file. It runs as a long running service that hot reloads the config in response to file changes. It returns a current snapshot of the config whenever it is polled for a config file.

func NewProvider

func NewProvider(
	configFile string,
	defaultConfig Config,
	logger *zap.Logger,
) *Provider

NewProvider creates a new config provider.

func (*Provider) AddPlugin

func (p *Provider) AddPlugin(name string, pluginURL string) error

AddPlugin adds the given plugin to the configuration It errors if the plugin name already exists.

func (*Provider) Config

func (p *Provider) Config() Config

Config returns a the stored configuration from the provider.

func (*Provider) EnsureConfigFile

func (p *Provider) EnsureConfigFile() error

EnsureConfigFile ensure the config file exists and validates the initial configuration passed to the provider

func (*Provider) MutateConfig

func (p *Provider) MutateConfig(mutate func(Config) (Config, error)) error

MutateConfig provides a callback that allows the caller to safely mutate the configuration

func (*Provider) RemovePlugin

func (p *Provider) RemovePlugin(name string) error

RemovePlugin removes the plugin with the given name from the configuration. If the plugin doesn't exist, it is a no-op.

func (*Provider) Serve

func (p *Provider) Serve()

Serve runs the main loop for the provider. It updates the saved configuration in response to file changes.

func (*Provider) Stop

func (p *Provider) Stop()

Stop will shutdown this service and wait on it to stop before returning

func (*Provider) WaitUntilReady

func (p *Provider) WaitUntilReady()

WaitUntilReady blocks until the config provider is up and running

type Sources

type Sources struct {
	// DataPath provides the path to the folder with raw EXD files (in CSV format)
	// containing game data.
	DataPath string `toml:"data_path" validate:"directory"`

	// Maps provides the configuration for the Map endpoint of the API.
	Maps MapConfig `toml:"maps"`
}

Sources stores configuration for sources that provide data used to interpret indexes sent over the network

Jump to

Keyboard shortcuts

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