func sshPermissionsFromProcess(
	processGuid string,
	index int,
	receptorClient receptor.Client,
	remoteAddr net.Addr,
) (*ssh.Permissions, error) {
	actual, err := receptorClient.ActualLRPByProcessGuidAndIndex(processGuid, index)
	if err != nil {
		return nil, err
	}

	desired, err := receptorClient.GetDesiredLRP(processGuid)
	if err != nil {
		return nil, err
	}

	sshRoute, err := getRoutingInfo(&desired)
	if err != nil {
		return nil, err
	}

	logMessage := fmt.Sprintf("Successful remote access by %s", remoteAddr.String())

	return createPermissions(sshRoute, &actual, desired.LogGuid, logMessage, index)
}
Esempio n. 2
0
func LRPInstanceStatePoller(receptorClient receptor.Client, processGuid string, index int, lrp *receptor.ActualLRPResponse) func() receptor.ActualLRPState {
	return func() receptor.ActualLRPState {
		lrpInstance, err := receptorClient.ActualLRPByProcessGuidAndIndex(processGuid, index)
		Expect(err).NotTo(HaveOccurred())

		if lrp != nil {
			*lrp = lrpInstance
		}

		return lrpInstance.State
	}
}