Documentation ¶
Index ¶
- type Service
- func (service *Service) AddEdgeJob(endpointID portainer.EndpointID, edgeJob *portainer.EdgeJob)
- func (service *Service) GenerateEdgeKey(url, host string, endpointIdentifier int) string
- func (service *Service) GetActiveTunnel(endpoint *portainer.Endpoint) (portainer.TunnelDetails, error)
- func (service *Service) GetTunnelDetails(endpointID portainer.EndpointID) portainer.TunnelDetails
- func (service *Service) KeepTunnelAlive(endpointID portainer.EndpointID, ctx context.Context, maxAlive time.Duration)
- func (service *Service) RemoveEdgeJob(edgeJobID portainer.EdgeJobID)
- func (service *Service) RemoveEdgeJobFromEndpoint(endpointID portainer.EndpointID, edgeJobID portainer.EdgeJobID)
- func (service *Service) SetTunnelStatusToActive(endpointID portainer.EndpointID)
- func (service *Service) SetTunnelStatusToIdle(endpointID portainer.EndpointID)
- func (service *Service) SetTunnelStatusToRequired(endpointID portainer.EndpointID) error
- func (service *Service) StartTunnelServer(addr, port string, snapshotService portainer.SnapshotService) error
- func (service *Service) StopTunnelServer() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
Service represents a service to manage the state of multiple reverse tunnels. It is used to start a reverse tunnel server and to manage the connection status of each tunnel connected to the tunnel server.
func NewService ¶
func NewService(dataStore dataservices.DataStore, shutdownCtx context.Context) *Service
NewService returns a pointer to a new instance of Service
func (*Service) AddEdgeJob ¶
func (service *Service) AddEdgeJob(endpointID portainer.EndpointID, edgeJob *portainer.EdgeJob)
AddEdgeJob register an EdgeJob inside the tunnel details associated to an environment(endpoint).
func (*Service) GenerateEdgeKey ¶
GenerateEdgeKey will generate a key that can be used by an Edge agent to register with a Portainer instance. The key represents the following data in this particular format: portainer_instance_url|tunnel_server_addr|tunnel_server_fingerprint|endpoint_ID The key returned by this function is a base64 encoded version of the data.
func (*Service) GetActiveTunnel ¶
func (service *Service) GetActiveTunnel(endpoint *portainer.Endpoint) (portainer.TunnelDetails, error)
GetActiveTunnel retrieves an active tunnel which allows communicating with edge agent
func (*Service) GetTunnelDetails ¶
func (service *Service) GetTunnelDetails(endpointID portainer.EndpointID) portainer.TunnelDetails
GetTunnelDetails returns information about the tunnel associated to an environment(endpoint).
func (*Service) KeepTunnelAlive ¶
func (service *Service) KeepTunnelAlive(endpointID portainer.EndpointID, ctx context.Context, maxAlive time.Duration)
KeepTunnelAlive keeps the tunnel of the given environment for maxAlive duration, or until ctx is done
func (*Service) RemoveEdgeJob ¶
RemoveEdgeJob will remove the specified Edge job from each tunnel it was registered with.
func (*Service) RemoveEdgeJobFromEndpoint ¶
func (service *Service) RemoveEdgeJobFromEndpoint(endpointID portainer.EndpointID, edgeJobID portainer.EdgeJobID)
func (*Service) SetTunnelStatusToActive ¶
func (service *Service) SetTunnelStatusToActive(endpointID portainer.EndpointID)
SetTunnelStatusToActive update the status of the tunnel associated to the specified environment(endpoint). It sets the status to ACTIVE.
func (*Service) SetTunnelStatusToIdle ¶
func (service *Service) SetTunnelStatusToIdle(endpointID portainer.EndpointID)
SetTunnelStatusToIdle update the status of the tunnel associated to the specified environment(endpoint). It sets the status to IDLE. It removes any existing credentials associated to the tunnel.
func (*Service) SetTunnelStatusToRequired ¶
func (service *Service) SetTunnelStatusToRequired(endpointID portainer.EndpointID) error
SetTunnelStatusToRequired update the status of the tunnel associated to the specified environment(endpoint). It sets the status to REQUIRED. If no port is currently associated to the tunnel, it will associate a random unused port to the tunnel and generate temporary credentials that can be used to establish a reverse tunnel on that port. Credentials are encrypted using the Edge ID associated to the environment(endpoint).
func (*Service) StartTunnelServer ¶
func (service *Service) StartTunnelServer(addr, port string, snapshotService portainer.SnapshotService) error
StartTunnelServer starts a tunnel server on the specified addr and port. It uses a seed to generate a new private/public key pair. If the seed cannot be found inside the database, it will generate a new one randomly and persist it. It starts the tunnel status verification process in the background. The snapshotter is used in the tunnel status verification process.
func (*Service) StopTunnelServer ¶
StopTunnelServer stops tunnel http server