Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // providers ProviderGoogle = "google" ProviderLinode = "linode" )
Functions ¶
func PublicIP ¶
PublicIP fetches the current public IP from the URL defined by ipURL. On error, it will return an empty string and error.
func WithFirewall ¶
func WithFirewall(name string) configOpts
WithFirewall sets the Firewall's name in the fwsync configuration.
func WithIPLimit ¶
func WithIPLimit(limit int) configOpts
WithIPLimit sets the number of allowed IPs.
func WithProject ¶
func WithProject(project string) configOpts
WithProject sets the Project for the fwsync configuration.
func WithProvider ¶
func WithProvider(provider string) configOpts
WithProvider sets the Provider for the fwsync configuration.
func WithSourceIPs ¶
func WithSourceIPs(sourceIPs ...string) configOpts
WithSourceIPs sets the allowed IPs in the fwsync configuration.
Types ¶
type Config ¶
type Config struct {
Provider string `yaml:"provider"`
Project string `yaml:"project,omitempty"`
IPLimit int `yaml:"ip_limit,omitempty"`
Name string `yaml:"name"`
SourceIPs []string `yaml:"ips"`
}
Config describes the fwsync configuration. It is used to hold basic information about the firewall and the desired IPs that are to be allowed.
func LoadFromFile ¶
LoadFromFile creates a new Config from the .fwsync configuration file.
func New ¶
func New(opts ...configOpts) *Config
New creates a new Config and returns a pointer to it.
func (*Config) Add ¶
Add will add the given IP to the configuration file. If the new IP puts the number of IPs held in the configuration file over the limit defined by ipLimit then the oldest IP is removed.
func (*Config) AuthForProvider ¶
AuthForProvider authenticates for a given supported Cloud Provider and returns the provider's implementation of generic.Provider.
func (*Config) HasIP ¶
HasIP checks if the current configuration has a given IP. Returns the index of the IP and true if found. Returns -1 and false if not found.