{"action":"created","comment":{"url":"https://api.github.com/repos/gravitational/teleport/pulls/comments/144680255","pull_request_review_id":69375442,"id":144680255,"diff_hunk":"@@ -151,16 +222,112 @@ func (s *remoteSite) GetName() string {\n }\n \n func (s *remoteSite) GetLastConnected() time.Time {\n-\ts.Lock()\n-\tdefer s.Unlock()\n-\treturn s.lastActive\n+\tconnInfo, err := s.getLatestTunnelConnection()\n+\tif err != nil {\n+\t\treturn time.Time{}\n+\t}\n+\treturn connInfo.GetLastHeartbeat()\n+}\n+\n+func (s *remoteSite) periodicSendDiscoveryRequests() {\n+\tticker := time.NewTicker(defaults.ReverseTunnelAgentHeartbeatPeriod)\n+\tdefer ticker.Stop()\n+\tif err := s.sendDiscoveryRequest(); err != nil {\n+\t\ts.Warningf(\"failed to send discovery: %v\", err)\n+\t}\n+\tfor {\n+\t\tselect {\n+\t\tcase <-s.ctx.Done():\n+\t\t\ts.Debugf(\"closing\")\n+\t\t\treturn\n+\t\tcase <-ticker.C:\n+\t\t\terr := s.sendDiscoveryRequest()\n+\t\t\tif err != nil {\n+\t\t\t\ts.Warningf(\"could not send discovery request: %v\", trace.DebugReport(err))\n+\t\t\t}\n+\t\t}\n+\t}\n+}\n+\n+func (s *remoteSite) isOnline(conn services.TunnelConnection) bool {\n+\tdiff := s.clock.Now().Sub(conn.GetLastHeartbeat())\n+\treturn diff < defaults.ReverseTunnelOfflineThreshold\n+}\n+\n+// findDisconnectedProxies\n+func (s *remoteSite) findDisconnectedProxies() ([]services.Server, error) {\n+\tconns, err := s.srv.AccessPoint.GetTunnelConnections(s.domainName)\n+\tif err != nil {\n+\t\treturn nil, trace.Wrap(err)\n+\t}\n+\tconnected := make(map[string]bool)\n+\tfor _, conn := range conns {\n+\t\tif s.isOnline(conn) {\n+\t\t\tconnected[conn.GetProxyName()] = true\n+\t\t}\n+\t}\n+\tproxies, err := s.srv.AccessPoint.GetProxies()\n+\tif err != nil {\n+\t\treturn nil, trace.Wrap(err)\n+\t}\n+\tvar missing []services.Server\n+\tfor i := range proxies {\n+\t\tproxy := proxies[i]\n+\t\tif !connected[proxy.GetName()] {\n+\t\t\tmissing = append(missing, proxy)\n+\t\t}\n+\t}\n+\treturn missing, nil\n+}\n+\n+func (s *remoteSite) sendDiscoveryRequest() error {","path":"lib/reversetunnel/remotesite.go","position":262,"original_position":262,"commit_id":"d69f88978be48631f294857491e66fd5773724cb","original_commit_id":"d69f88978be48631f294857491e66fd5773724cb","user":{"login":"russjones","id":5017502,"avatar_url":"https://avatars0.githubusercontent.com/u/5017502?v=4","gravatar_id":"","url":"https://api.github.com/users/russjones","html_url":"https://github.com/russjones","followers_url":"https://api.github.com/users/russjones/followers","following_url":"https://api.github.com/users/russjones/following{/other_user}","gists_url":"https://api.github.com/users/russjones/gists{/gist_id}","starred_url":"https://api.github.com/users/russjones/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/russjones/subscriptions","organizations_url":"https://api.github.com/users/russjones/orgs","repos_url":"https://api.github.com/users/russjones/repos","events_url":"https://api.github.com/users/russjones/events{/privacy}","received_events_url":"https://api.github.com/users/russjones/received_events","type":"User","site_admin":false},"body":"Comment needed for non-trivial function.","created_at":"2017-10-14T00:33:40Z","updated_at":"2017-10-14T00:52:36Z","html_url":"https://github.com/gravitational/teleport/pull/1394#discussion_r144680255","pull_request_url":"https://api.github.com/repos/gravitational/teleport/pulls/1394","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/gravitational/teleport/pulls/comments/144680255"},"html":{"href":"https://github.com/gravitational/teleport/pull/1394#discussion_r144680255"},"pull_request":{"href":"https://api.github.com/repos/gravitational/teleport/pulls/1394"}}},"pull_request":{"url":"https://api.github.com/repos/gravitational/teleport/pulls/1394","id":146270166,"html_url":"https://github.com/gravitational/teleport/pull/1394","diff_url":"https://github.com/gravitational/teleport/pull/1394.diff","patch_url":"https://github.com/gravitational/teleport/pull/1394.patch","issue_url":"https://api.github.com/repos/gravitational/teleport/issues/1394","number":1394,"state":"open","locked":false,"title":"Sasha/curiosity","user":{"login":"klizhentas","id":13717,"avatar_url":"https://avatars1.githubusercontent.com/u/13717?v=4","gravatar_id":"","url":"https://api.github.com/users/klizhentas","html_url":"https://github.com/klizhentas","followers_url":"https://api.github.com/users/klizhentas/followers","following_url":"https://api.github.com/users/klizhentas/following{/other_user}","gists_url":"https://api.github.com/users/klizhentas/gists{/gist_id}","starred_url":"https://api.github.com/users/klizhentas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klizhentas/subscriptions","organizations_url":"https://api.github.com/users/klizhentas/orgs","repos_url":"https://api.github.com/users/klizhentas/repos","events_url":"https://api.github.com/users/klizhentas/events{/privacy}","received_events_url":"https://api.github.com/users/klizhentas/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-10-12T17:36:14Z","updated_at":"2017-10-14T00:52:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7019d90db7d98c74b57bc8ec1efa9bb4529b9c38","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/gravitational/teleport/pulls/1394/commits","review_comments_url":"https://api.github.com/repos/gravitational/teleport/pulls/1394/comments","review_comment_url":"https://api.github.com/repos/gravitational/teleport/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gravitational/teleport/issues/1394/comments","statuses_url":"https://api.github.com/repos/gravitational/teleport/statuses/d69f88978be48631f294857491e66fd5773724cb","head":{"label":"gravitational:sasha/curiosity","ref":"sasha/curiosity","sha":"d69f88978be48631f294857491e66fd5773724cb","user":{"login":"gravitational","id":10781132,"avatar_url":"https://avatars2.githubusercontent.com/u/10781132?v=4","gravatar_id":"","url":"https://api.github.com/users/gravitational","html_url":"https://github.com/gravitational","followers_url":"https://api.github.com/users/gravitational/followers","following_url":"https://api.github.com/users/gravitational/following{/other_user}","gists_url":"https://api.github.com/users/gravitational/gists{/gist_id}","starred_url":"https://api.github.com/users/gravitational/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gravitational/subscriptions","organizations_url":"https://api.github.com/users/gravitational/orgs","repos_url":"https://api.github.com/users/gravitational/repos","events_url":"https://api.github.com/users/gravitational/events{/privacy}","received_events_url":"https://api.github.com/users/gravitational/received_events","type":"Organization","site_admin":false},"repo":{"id":31558937,"name":"teleport","full_name":"gravitational/teleport","owner":{"login":"gravitational","id":10781132,"avatar_url":"https://avatars2.githubusercontent.com/u/10781132?v=4","gravatar_id":"","url":"https://api.github.com/users/gravitational","html_url":"https://github.com/gravitational","followers_url":"https://api.github.com/users/gravitational/followers","following_url":"https://api.github.com/users/gravitational/following{/other_user}","gists_url":"https://api.github.com/users/gravitational/gists{/gist_id}","starred_url":"https://api.github.com/users/gravitational/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gravitational/subscriptions","organizations_url":"https://api.github.com/users/gravitational/orgs","repos_url":"https://api.github.com/users/gravitational/repos","events_url":"https://api.github.com/users/gravitational/events{/privacy}","received_events_url":"https://api.github.com/users/gravitational/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gravitational/teleport","description":"Modern SSH server for clusters and teams.","fork":false,"url":"https://api.github.com/repos/gravitational/teleport","forks_url":"https://api.github.com/repos/gravitational/teleport/forks","keys_url":"https://api.github.com/repos/gravitational/teleport/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gravitational/teleport/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gravitational/teleport/teams","hooks_url":"https://api.github.com/repos/gravitational/teleport/hooks","issue_events_url":"https://api.github.com/repos/gravitational/teleport/issues/events{/number}","events_url":"https://api.github.com/repos/gravitational/teleport/events","assignees_url":"https://api.github.com/repos/gravitational/teleport/assignees{/user}","branches_url":"https://api.github.com/repos/gravitational/teleport/branches{/branch}","tags_url":"https://api.github.com/repos/gravitational/teleport/tags","blobs_url":"https://api.github.com/repos/gravitational/teleport/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gravitational/teleport/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gravitational/teleport/git/refs{/sha}","trees_url":"https://api.github.com/repos/gravitational/teleport/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gravitational/teleport/statuses/{sha}","languages_url":"https://api.github.com/repos/gravitational/teleport/languages","stargazers_url":"https://api.github.com/repos/gravitational/teleport/stargazers","contributors_url":"https://api.github.com/repos/gravitational/teleport/contributors","subscribers_url":"https://api.github.com/repos/gravitational/teleport/subscribers","subscription_url":"https://api.github.com/repos/gravitational/teleport/subscription","commits_url":"https://api.github.com/repos/gravitational/teleport/commits{/sha}","git_commits_url":"https://api.github.com/repos/gravitational/teleport/git/commits{/sha}","comments_url":"https://api.github.com/repos/gravitational/teleport/comments{/number}","issue_comment_url":"https://api.github.com/repos/gravitational/teleport/issues/comments{/number}","contents_url":"https://api.github.com/repos/gravitational/teleport/contents/{+path}","compare_url":"https://api.github.com/repos/gravitational/teleport/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gravitational/teleport/merges","archive_url":"https://api.github.com/repos/gravitational/teleport/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gravitational/teleport/downloads","issues_url":"https://api.github.com/repos/gravitational/teleport/issues{/number}","pulls_url":"https://api.github.com/repos/gravitational/teleport/pulls{/number}","milestones_url":"https://api.github.com/repos/gravitational/teleport/milestones{/number}","notifications_url":"https://api.github.com/repos/gravitational/teleport/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gravitational/teleport/labels{/name}","releases_url":"https://api.github.com/repos/gravitational/teleport/releases{/id}","deployments_url":"https://api.github.com/repos/gravitational/teleport/deployments","created_at":"2015-03-02T19:36:00Z","updated_at":"2017-10-13T17:38:17Z","pushed_at":"2017-10-14T00:33:57Z","git_url":"git://github.com/gravitational/teleport.git","ssh_url":"git@github.com:gravitational/teleport.git","clone_url":"https://github.com/gravitational/teleport.git","svn_url":"https://github.com/gravitational/teleport","homepage":"http://gravitational.com/teleport","size":42281,"stargazers_count":5347,"watchers_count":5347,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":270,"mirror_url":null,"open_issues_count":89,"forks":270,"open_issues":89,"watchers":5347,"default_branch":"master"}},"base":{"label":"gravitational:master","ref":"master","sha":"081d952e5b164e2a7555ada70e45e852c2cb5e57","user":{"login":"gravitational","id":10781132,"avatar_url":"https://avatars2.githubusercontent.com/u/10781132?v=4","gravatar_id":"","url":"https://api.github.com/users/gravitational","html_url":"https://github.com/gravitational","followers_url":"https://api.github.com/users/gravitational/followers","following_url":"https://api.github.com/users/gravitational/following{/other_user}","gists_url":"https://api.github.com/users/gravitational/gists{/gist_id}","starred_url":"https://api.github.com/users/gravitational/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gravitational/subscriptions","organizations_url":"https://api.github.com/users/gravitational/orgs","repos_url":"https://api.github.com/users/gravitational/repos","events_url":"https://api.github.com/users/gravitational/events{/privacy}","received_events_url":"https://api.github.com/users/gravitational/received_events","type":"Organization","site_admin":false},"repo":{"id":31558937,"name":"teleport","full_name":"gravitational/teleport","owner":{"login":"gravitational","id":10781132,"avatar_url":"https://avatars2.githubusercontent.com/u/10781132?v=4","gravatar_id":"","url":"https://api.github.com/users/gravitational","html_url":"https://github.com/gravitational","followers_url":"https://api.github.com/users/gravitational/followers","following_url":"https://api.github.com/users/gravitational/following{/other_user}","gists_url":"https://api.github.com/users/gravitational/gists{/gist_id}","starred_url":"https://api.github.com/users/gravitational/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gravitational/subscriptions","organizations_url":"https://api.github.com/users/gravitational/orgs","repos_url":"https://api.github.com/users/gravitational/repos","events_url":"https://api.github.com/users/gravitational/events{/privacy}","received_events_url":"https://api.github.com/users/gravitational/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gravitational/teleport","description":"Modern SSH server for clusters and teams.","fork":false,"url":"https://api.github.com/repos/gravitational/teleport","forks_url":"https://api.github.com/repos/gravitational/teleport/forks","keys_url":"https://api.github.com/repos/gravitational/teleport/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gravitational/teleport/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gravitational/teleport/teams","hooks_url":"https://api.github.com/repos/gravitational/teleport/hooks","issue_events_url":"https://api.github.com/repos/gravitational/teleport/issues/events{/number}","events_url":"https://api.github.com/repos/gravitational/teleport/events","assignees_url":"https://api.github.com/repos/gravitational/teleport/assignees{/user}","branches_url":"https://api.github.com/repos/gravitational/teleport/branches{/branch}","tags_url":"https://api.github.com/repos/gravitational/teleport/tags","blobs_url":"https://api.github.com/repos/gravitational/teleport/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gravitational/teleport/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gravitational/teleport/git/refs{/sha}","trees_url":"https://api.github.com/repos/gravitational/teleport/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gravitational/teleport/statuses/{sha}","languages_url":"https://api.github.com/repos/gravitational/teleport/languages","stargazers_url":"https://api.github.com/repos/gravitational/teleport/stargazers","contributors_url":"https://api.github.com/repos/gravitational/teleport/contributors","subscribers_url":"https://api.github.com/repos/gravitational/teleport/subscribers","subscription_url":"https://api.github.com/repos/gravitational/teleport/subscription","commits_url":"https://api.github.com/repos/gravitational/teleport/commits{/sha}","git_commits_url":"https://api.github.com/repos/gravitational/teleport/git/commits{/sha}","comments_url":"https://api.github.com/repos/gravitational/teleport/comments{/number}","issue_comment_url":"https://api.github.com/repos/gravitational/teleport/issues/comments{/number}","contents_url":"https://api.github.com/repos/gravitational/teleport/contents/{+path}","compare_url":"https://api.github.com/repos/gravitational/teleport/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gravitational/teleport/merges","archive_url":"https://api.github.com/repos/gravitational/teleport/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gravitational/teleport/downloads","issues_url":"https://api.github.com/repos/gravitational/teleport/issues{/number}","pulls_url":"https://api.github.com/repos/gravitational/teleport/pulls{/number}","milestones_url":"https://api.github.com/repos/gravitational/teleport/milestones{/number}","notifications_url":"https://api.github.com/repos/gravitational/teleport/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gravitational/teleport/labels{/name}","releases_url":"https://api.github.com/repos/gravitational/teleport/releases{/id}","deployments_url":"https://api.github.com/repos/gravitational/teleport/deployments","created_at":"2015-03-02T19:36:00Z","updated_at":"2017-10-13T17:38:17Z","pushed_at":"2017-10-14T00:33:57Z","git_url":"git://github.com/gravitational/teleport.git","ssh_url":"git@github.com:gravitational/teleport.git","clone_url":"https://github.com/gravitational/teleport.git","svn_url":"https://github.com/gravitational/teleport","homepage":"http://gravitational.com/teleport","size":42281,"stargazers_count":5347,"watchers_count":5347,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":270,"mirror_url":null,"open_issues_count":89,"forks":270,"open_issues":89,"watchers":5347,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gravitational/teleport/pulls/1394"},"html":{"href":"https://github.com/gravitational/teleport/pull/1394"},"issue":{"href":"https://api.github.com/repos/gravitational/teleport/issues/1394"},"comments":{"href":"https://api.github.com/repos/gravitational/teleport/issues/1394/comments"},"review_comments":{"href":"https://api.github.com/repos/gravitational/teleport/pulls/1394/comments"},"review_comment":{"href":"https://api.github.com/repos/gravitational/teleport/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gravitational/teleport/pulls/1394/commits"},"statuses":{"href":"https://api.github.com/repos/gravitational/teleport/statuses/d69f88978be48631f294857491e66fd5773724cb"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"russjones"}}