interface.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package controller
  2. import (
  3. "net"
  4. "net/url"
  5. )
  6. // Interface can be implemented by VPN servers that can be controlled via GridVPN.
  7. type Interface interface {
  8. // Start MUST cause the underlying VPN server to start accepting connections
  9. // by using the config at hand.
  10. Start() error
  11. // Stop MUST cause the underlying VPN server to stop accepting connections and freeing
  12. // the resources it had allocated.
  13. Stop() error
  14. // Reload SHOULD cause the underlying VPN server to take in effect the changes made
  15. // on the config at hand.
  16. Reload() error
  17. // Status MUST return the appropriate StatusProvider according to the state that the server is in.
  18. Status() StatusProvider
  19. // Configure accepts a new config and SHOULD reflect the changes that are made to the config at hand,
  20. // but SHOULD NOT take those changes in effect.
  21. //
  22. // Invoking Configure(ConfigProvider) with a nil ConfigProvider implies a server config reset/init.
  23. Configure(ConfigProvider) error
  24. // Config MUST return the config at hand.
  25. Config() (ConfigProvider, error)
  26. }
  27. // ConfigProvider interface represents a VPN server configuration.
  28. type ConfigProvider interface {
  29. Kind() string // The kind of the server. OpenVPN, L2TP etc..
  30. ListenAddrs() []url.URL // Server addresses to listen at.
  31. NameServers() []net.IP // DNS server addresses to push to the peers.
  32. }
  33. // StatusProvider interface represents the current status of the VPN server.
  34. type StatusProvider interface {
  35. State() string
  36. // ConnectedPeers() []Peer // Currently connected peers on the VPN server.
  37. }