blob: 78e8449b5531afd9514ba292c9aa367b0ade9eac [file] [log] [blame]
giolekvad12813b2021-05-01 19:58:44 +04001package vpn
2
3import (
4 "github.com/giolekva/pcloud/core/vpn/types"
5)
6
7type NetworkMapChangeCallback func(*types.NetworkMap)
8
9// Manager interface manages mesh VPN configuration for all the devices registed by all users.
10// It does enforce device to device ACLs but delegates user authorization to the client.
11type Manager interface {
giolekva4c6114a2021-05-02 20:46:57 +040012 // Registers new device..
giolekvad12813b2021-05-01 19:58:44 +040013 // Returns VPN network configuration on success and error otherwise.
14 // By default new devices have access to other machines owned by the same user
15 // and a PCloud entrypoint.
giolekva4c6114a2021-05-02 20:46:57 +040016 RegisterDevice(d types.DeviceInfo) (*types.NetworkMap, error)
giolekvad12813b2021-05-01 19:58:44 +040017 // Completely removes device with given public key from the network.
18 RemoveDevice(pubKey types.PublicKey) error
Giorgi Lekveishvili93c6aa52021-05-09 12:59:09 +040019 // Returns network configuration for a device with a given public key.
giolekvad12813b2021-05-01 19:58:44 +040020 // Result of this call must be encrypted with the same public key before
21 // sending it back to the client, so only the owner of it's corresponding
22 // private key is able to decrypt and use it.
23 GetNetworkMap(pubKey types.PublicKey) (*types.NetworkMap, error)
24 // AddNetworkMapChangeCallback can be used to receive new network configurations
25 // for a device with given public key.
26 AddNetworkMapChangeCallback(pubKey types.PublicKey, cb NetworkMapChangeCallback) error
27}