blob: d0d3ef00b9c65b8e86d99e8b2258d1daafb3742a [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 {
giolekvac6439492021-05-02 20:49:39 +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.
giolekvaa748ff92021-05-02 22:00:34 +040016 RegisterDevice(d types.DeviceInfo) error
giolekvad12813b2021-05-01 19:58:44 +040017 // Completely removes device with given public key from the network.
18 RemoveDevice(pubKey types.PublicKey) error
giolekva66e2efa2021-05-01 23:58:58 +040019 // Creates new group with given name and returns it's id.
20 // Name does not have to be unique.
21 CreateGroup(name string) (types.GroupID, error)
22 // Deletes group with given id.
23 DeleteGroup(id types.GroupID) error
24 // Adds device with given public key to the group and returns updated network configuration.
25 AddDeviceToGroup(pubKey types.PublicKey, id types.GroupID) (*types.NetworkMap, error)
26 // Removes device from the group and returns updated network configuration.
27 RemoveDeviceFromGroup(pubKey types.PublicKey, id types.GroupID) (*types.NetworkMap, error)
Giorgi Lekveishvili93c6aa52021-05-09 12:59:09 +040028 // Returns network configuration for a device with a given public key.
giolekvad12813b2021-05-01 19:58:44 +040029 // Result of this call must be encrypted with the same public key before
30 // sending it back to the client, so only the owner of it's corresponding
31 // private key is able to decrypt and use it.
32 GetNetworkMap(pubKey types.PublicKey) (*types.NetworkMap, error)
33 // AddNetworkMapChangeCallback can be used to receive new network configurations
34 // for a device with given public key.
35 AddNetworkMapChangeCallback(pubKey types.PublicKey, cb NetworkMapChangeCallback) error
36}