blob: fdb29cb390e47ab97b02d5af5fa3907b0beaa7e0 [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 {
12 // Registers new device with given public key and name.
giolekva66e2efa2021-05-01 23:58:58 +040013 // New device is isolated from the rest of the network until it is explicitely added to
14 // an existing group.
15 RegisterDevice(name string, pubKey types.PublicKey) error
giolekvad12813b2021-05-01 19:58:44 +040016 // Completely removes device with given public key from the network.
17 RemoveDevice(pubKey types.PublicKey) error
giolekva66e2efa2021-05-01 23:58:58 +040018 // Creates new group with given name and returns it's id.
19 // Name does not have to be unique.
20 CreateGroup(name string) (types.GroupID, error)
21 // Deletes group with given id.
22 DeleteGroup(id types.GroupID) error
23 // Adds device with given public key to the group and returns updated network configuration.
24 AddDeviceToGroup(pubKey types.PublicKey, id types.GroupID) (*types.NetworkMap, error)
25 // Removes device from the group and returns updated network configuration.
26 RemoveDeviceFromGroup(pubKey types.PublicKey, id types.GroupID) (*types.NetworkMap, error)
giolekvad12813b2021-05-01 19:58:44 +040027 // Returns network configuration for a device with give public key.
28 // Result of this call must be encrypted with the same public key before
29 // sending it back to the client, so only the owner of it's corresponding
30 // private key is able to decrypt and use it.
31 GetNetworkMap(pubKey types.PublicKey) (*types.NetworkMap, error)
32 // AddNetworkMapChangeCallback can be used to receive new network configurations
33 // for a device with given public key.
34 AddNetworkMapChangeCallback(pubKey types.PublicKey, cb NetworkMapChangeCallback) error
35}