config

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2023 License: MPL-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppConfigFilename         = "config_awl.json"
	AppDataDirectory          = "anywherelan"
	DhtPeerstoreDataDirectory = "peerstore"
	AppDataDirEnvKey          = "AWL_DATA_DIR"

	// TODO 8989 maybe?
	DefaultHTTPPort              = 8639
	AdminHttpServerDomainName    = "admin"
	AdminHttpServerIP            = "127.0.0.66"
	AdminHttpServerListenAddress = "127.0.0.66:80"

	DefaultPeerAlias = "peer"
)
View Source
const DevVersion = "dev"

Variables

View Source
var (
	Version         = DevVersion
	UserAgent       = UserAgentPrefix + SystemInfo + "/" + Version
	UserAgentPrefix = "awl/"
	SystemInfo      = runtime.GOOS + "-" + runtime.GOARCH
)
View Source
var DefaultBootstrapPeers []multiaddr.Multiaddr
View Source
var LinuxFilesOwnerUID = os.Geteuid()

LinuxFilesOwnerUID is used to set correct files owner uid. This is needed because by default all files belong to root when we run as root, but they are stored in user's directory.

Functions

func CalcAppDataDir

func CalcAppDataDir() string

func ChownFileIfNeeded added in v0.9.0

func ChownFileIfNeeded(path string)

func ImportConfig

func ImportConfig(data []byte, directory string) error

func IsDevVersion added in v0.5.1

func IsDevVersion() bool

IsDevVersion Possible duplicate of *Config.DevMode() Based on build version (unchangeable after build, could be used only by developers)

func SystemInfoFromUserAgent added in v0.7.0

func SystemInfoFromUserAgent(userAgent string) (goos string, goarch string)

func VersionFromUserAgent

func VersionFromUserAgent(userAgent string) string

Types

type BlockedPeer

type BlockedPeer struct {
	// Hex-encoded multihash representing a peer ID
	PeerID      string `json:"peerId"`
	DisplayName string `json:"displayName"`
	// Time of adding to config (decline invitation/remove from KnownPeers)
	CreatedAt time.Time `json:"createdAt"`
}

type Config

type Config struct {
	sync.RWMutex `swaggerignore:"true"`

	Version               string                 `json:"version"`
	LoggerLevel           string                 `json:"loggerLevel"`
	HttpListenAddress     string                 `json:"httpListenAddress"`
	HttpListenOnAdminHost bool                   `json:"httpListenOnAdminHost"`
	P2pNode               P2pNodeConfig          `json:"p2pNode"`
	VPNConfig             VPNConfig              `json:"vpn"`
	KnownPeers            map[string]KnownPeer   `json:"knownPeers"`
	BlockedPeers          map[string]BlockedPeer `json:"blockedPeers"`
	Update                UpdateConfig           `json:"update"`
	// contains filtered or unexported fields
}

func LoadConfig

func LoadConfig(bus awlevent.Bus) (*Config, error)

func NewConfig

func NewConfig(bus awlevent.Bus) *Config

func (*Config) DNSNamesMapping

func (c *Config) DNSNamesMapping() map[string]string

func (*Config) DataDir

func (c *Config) DataDir() string

func (*Config) DevMode

func (c *Config) DevMode() bool

DevMode Possible duplicate of IsDevVersion() Based on Config.LoggerLevel (could be used by any user)

func (*Config) Export

func (c *Config) Export() []byte

func (*Config) GenUniqPeerAlias added in v0.5.1

func (c *Config) GenUniqPeerAlias(name, alias string) string

func (*Config) GenerateNextIpAddr

func (c *Config) GenerateNextIpAddr() string

GenerateNextIpAddr is not thread safe.

func (*Config) GetBlockedPeer

func (c *Config) GetBlockedPeer(peerID string) (BlockedPeer, bool)

func (*Config) GetBootstrapPeers

func (c *Config) GetBootstrapPeers() []peer.AddrInfo

func (*Config) GetListenAddresses

func (c *Config) GetListenAddresses() []multiaddr.Multiaddr

func (*Config) GetPeer

func (c *Config) GetPeer(peerID string) (KnownPeer, bool)

func (*Config) IsUniqPeerAlias added in v0.5.1

func (c *Config) IsUniqPeerAlias(excludePeerID, alias string) bool

func (*Config) KnownPeersIds

func (c *Config) KnownPeersIds() []peer.ID

func (*Config) LogLevel

func (c *Config) LogLevel() zapcore.Level

func (*Config) PeerstoreDir

func (c *Config) PeerstoreDir() string

func (*Config) PrivKey

func (c *Config) PrivKey() []byte

func (*Config) RemoveBlockedPeer

func (c *Config) RemoveBlockedPeer(peerID string)

func (*Config) RemovePeer

func (c *Config) RemovePeer(peerID string) (KnownPeer, bool)

func (*Config) Save

func (c *Config) Save()

func (*Config) SetIdentity

func (c *Config) SetIdentity(key crypto.PrivKey, id peer.ID)

func (*Config) SetListenAddresses

func (c *Config) SetListenAddresses(multiaddrs []multiaddr.Multiaddr)

func (*Config) UpdatePeerLastSeen

func (c *Config) UpdatePeerLastSeen(peerID string)

func (*Config) UpsertBlockedPeer

func (c *Config) UpsertBlockedPeer(peerID, displayName string)

func (*Config) UpsertPeer

func (c *Config) UpsertPeer(peer KnownPeer)

func (*Config) VPNLocalIPMask

func (c *Config) VPNLocalIPMask() (net.IP, net.IPMask)

type KnownPeer

type KnownPeer struct {
	// Hex-encoded multihash representing a peer ID
	PeerID string `json:"peerId"`
	// Peer provided name
	Name string `json:"name"`
	// User provided name
	Alias string `json:"alias"`
	// IPAddr used for forwarding
	IPAddr string `json:"ipAddr"`
	// DomainName without zone suffix (.awl)
	DomainName string `json:"domainName"`
	// Time of adding to config (accept/invite)
	CreatedAt time.Time `json:"createdAt"`
	// Time of last connection
	LastSeen time.Time `json:"lastSeen"`
	// Has remote peer confirmed our invitation
	Confirmed bool `json:"confirmed"`
	// Has remote peer declined our invitation
	Declined               bool `json:"declined"`
	WeAllowUsingAsExitNode bool `json:"weAllowUsingAsExitNode"`
	AllowedUsingAsExitNode bool `json:"allowedUsingAsExitNode"`
}

func (KnownPeer) DisplayName

func (kp KnownPeer) DisplayName() string

func (KnownPeer) PeerId

func (kp KnownPeer) PeerId() peer.ID

type P2pNodeConfig

type P2pNodeConfig struct {
	// Hex-encoded multihash representing a peer ID, calculated from Identity
	PeerID                  string        `json:"peerId"`
	Name                    string        `json:"name"`
	Identity                string        `json:"identity"`
	BootstrapPeers          []string      `json:"bootstrapPeers"`
	ListenAddresses         []string      `json:"listenAddresses"`
	ReconnectionIntervalSec time.Duration `json:"reconnectionIntervalSec" swaggertype:"primitive,integer"`
	AutoAcceptAuthRequests  bool          `json:"autoAcceptAuthRequests"`
}

type UpdateConfig

type UpdateConfig struct {
	LowestPriorityChan    string `json:"lowestPriorityChan"`
	UpdateServerURL       string `json:"updateServerURL"`
	TrayAutoCheckEnabled  bool   `json:"trayAutoCheckEnabled"`
	TrayAutoCheckInterval string `json:"trayAutoCheckInterval"`
}

type VPNConfig

type VPNConfig struct {
	InterfaceName string `json:"interfaceName"`
	IPNet         string `json:"ipNet"`
}

Jump to

Keyboard shortcuts

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