{"action":"created","comment":{"url":"https://api.github.com/repos/syncthing/syncthing/pulls/comments/33659173","id":33659173,"diff_hunk":"@@ -0,0 +1,167 @@\n+// Copyright (C) 2015 The Syncthing Authors.\n+//\n+// This Source Code Form is subject to the terms of the Mozilla Public\n+// License, v. 2.0. If a copy of the MPL was not distributed with this file,\n+// You can obtain one at http://mozilla.org/MPL/2.0/.\n+\n+package main\n+\n+import (\n+\t\"crypto/tls\"\n+\t\"fmt\"\n+\t\"net\"\n+\t\"net/url\"\n+\t\"time\"\n+\n+\tsyncthingprotocol \"github.com/syncthing/protocol\"\n+\t\"github.com/syncthing/relaysrv/client\"\n+\t\"github.com/syncthing/relaysrv/protocol\"\n+\t\"github.com/syncthing/syncthing/internal/config\"\n+\n+\t\"github.com/thejerf/suture\"\n+)\n+\n+func newRelayService(cfg *config.Wrapper, tlsCfg *tls.Config, conns chan<- connection) *relaySvc {\n+\tsvc := &relaySvc{\n+\t\tSupervisor: suture.New(\"relaySvc\", suture.Spec{\n+\t\t\tLog: func(log string) {\n+\t\t\t\tif debugNet {\n+\t\t\t\t\tl.Infoln(log)\n+\t\t\t\t}\n+\t\t\t},\n+\t\t\tFailureBackoff:   5 * time.Minute,\n+\t\t\tFailureDecay:     float64((10 * time.Minute) / time.Second),\n+\t\t\tFailureThreshold: 5,\n+\t\t}),\n+\t\tcfg:    cfg,\n+\t\ttlsCfg: tlsCfg,\n+\t\tconns:  conns,\n+\n+\t\tinvitations: make(chan protocol.SessionInvitation),\n+\t}\n+\n+\tcfg.Subscribe(svc)\n+\n+\treturn svc\n+}\n+\n+type relaySvc struct {\n+\t*suture.Supervisor\n+\tcfg    *config.Wrapper\n+\ttlsCfg *tls.Config\n+\tconns  chan<- connection\n+\n+\tstop    chan struct{}\n+\tstopped chan struct{}\n+\n+\ttokens      map[string]suture.ServiceToken\n+\tinvitations chan protocol.SessionInvitation\n+\trunning     bool\n+}\n+\n+func (s *relaySvc) Serve() {\n+\tif debugNet {\n+\t\tl.Debugln(\"Relay service starting\")\n+\t}\n+\ts.Supervisor.ServeBackground()","path":"cmd/syncthing/relays.go","position":66,"original_position":66,"commit_id":"a8beb2a055cc56995fd873a01f3aec91dafa6839","original_commit_id":"a8beb2a055cc56995fd873a01f3aec91dafa6839","user":{"login":"calmh","id":125426,"avatar_url":"https://avatars.githubusercontent.com/u/125426?v=3","gravatar_id":"","url":"https://api.github.com/users/calmh","html_url":"https://github.com/calmh","followers_url":"https://api.github.com/users/calmh/followers","following_url":"https://api.github.com/users/calmh/following{/other_user}","gists_url":"https://api.github.com/users/calmh/gists{/gist_id}","starred_url":"https://api.github.com/users/calmh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calmh/subscriptions","organizations_url":"https://api.github.com/users/calmh/orgs","repos_url":"https://api.github.com/users/calmh/repos","events_url":"https://api.github.com/users/calmh/events{/privacy}","received_events_url":"https://api.github.com/users/calmh/received_events","type":"User","site_admin":false},"body":"I'm not sure I like this. Would it make more sense to just `Add()` the relevant stuff to itself in the constructor and let whoever created the relayService start it?","created_at":"2015-07-01T08:46:47Z","updated_at":"2015-07-01T08:46:47Z","html_url":"https://github.com/syncthing/syncthing/pull/1995#discussion_r33659173","pull_request_url":"https://api.github.com/repos/syncthing/syncthing/pulls/1995","_links":{"self":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/comments/33659173"},"html":{"href":"https://github.com/syncthing/syncthing/pull/1995#discussion_r33659173"},"pull_request":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/1995"}}},"pull_request":{"url":"https://api.github.com/repos/syncthing/syncthing/pulls/1995","id":38393666,"html_url":"https://github.com/syncthing/syncthing/pull/1995","diff_url":"https://github.com/syncthing/syncthing/pull/1995.diff","patch_url":"https://github.com/syncthing/syncthing/pull/1995.patch","issue_url":"https://api.github.com/repos/syncthing/syncthing/issues/1995","number":1995,"state":"open","locked":false,"title":"Relay support (fixes #1364)","user":{"login":"AudriusButkevicius","id":1144861,"avatar_url":"https://avatars.githubusercontent.com/u/1144861?v=3","gravatar_id":"","url":"https://api.github.com/users/AudriusButkevicius","html_url":"https://github.com/AudriusButkevicius","followers_url":"https://api.github.com/users/AudriusButkevicius/followers","following_url":"https://api.github.com/users/AudriusButkevicius/following{/other_user}","gists_url":"https://api.github.com/users/AudriusButkevicius/gists{/gist_id}","starred_url":"https://api.github.com/users/AudriusButkevicius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AudriusButkevicius/subscriptions","organizations_url":"https://api.github.com/users/AudriusButkevicius/orgs","repos_url":"https://api.github.com/users/AudriusButkevicius/repos","events_url":"https://api.github.com/users/AudriusButkevicius/events{/privacy}","received_events_url":"https://api.github.com/users/AudriusButkevicius/received_events","type":"User","site_admin":false},"body":"The first changeset does:\r\n\r\n1. Change listen addresses to URIs everywhere\r\n2. Break out connectionSvc to support listeners and dialers based on schema (not necessary, but nice to have)\r\n3. Add relay announcement and lookups to discovery service\r\n\r\nThings left to do:\r\n1. Add a subservice to connectionSvc for dealing with relay addresses\r\n2. Keep dialing non-relay addresses, and disconnect existing relay connections if we've managed to get a direct connection.\r\n\r\n\r\n","created_at":"2015-06-23T23:21:52Z","updated_at":"2015-07-01T08:46:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"93b01aae203741414620ac8db938192c8c4129b8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/syncthing/syncthing/pulls/1995/commits","review_comments_url":"https://api.github.com/repos/syncthing/syncthing/pulls/1995/comments","review_comment_url":"https://api.github.com/repos/syncthing/syncthing/pulls/comments{/number}","comments_url":"https://api.github.com/repos/syncthing/syncthing/issues/1995/comments","statuses_url":"https://api.github.com/repos/syncthing/syncthing/statuses/a8beb2a055cc56995fd873a01f3aec91dafa6839","head":{"label":"AudriusButkevicius:relay","ref":"relay","sha":"a8beb2a055cc56995fd873a01f3aec91dafa6839","user":{"login":"AudriusButkevicius","id":1144861,"avatar_url":"https://avatars.githubusercontent.com/u/1144861?v=3","gravatar_id":"","url":"https://api.github.com/users/AudriusButkevicius","html_url":"https://github.com/AudriusButkevicius","followers_url":"https://api.github.com/users/AudriusButkevicius/followers","following_url":"https://api.github.com/users/AudriusButkevicius/following{/other_user}","gists_url":"https://api.github.com/users/AudriusButkevicius/gists{/gist_id}","starred_url":"https://api.github.com/users/AudriusButkevicius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AudriusButkevicius/subscriptions","organizations_url":"https://api.github.com/users/AudriusButkevicius/orgs","repos_url":"https://api.github.com/users/AudriusButkevicius/repos","events_url":"https://api.github.com/users/AudriusButkevicius/events{/privacy}","received_events_url":"https://api.github.com/users/AudriusButkevicius/received_events","type":"User","site_admin":false},"repo":{"id":22119752,"name":"syncthing","full_name":"AudriusButkevicius/syncthing","owner":{"login":"AudriusButkevicius","id":1144861,"avatar_url":"https://avatars.githubusercontent.com/u/1144861?v=3","gravatar_id":"","url":"https://api.github.com/users/AudriusButkevicius","html_url":"https://github.com/AudriusButkevicius","followers_url":"https://api.github.com/users/AudriusButkevicius/followers","following_url":"https://api.github.com/users/AudriusButkevicius/following{/other_user}","gists_url":"https://api.github.com/users/AudriusButkevicius/gists{/gist_id}","starred_url":"https://api.github.com/users/AudriusButkevicius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AudriusButkevicius/subscriptions","organizations_url":"https://api.github.com/users/AudriusButkevicius/orgs","repos_url":"https://api.github.com/users/AudriusButkevicius/repos","events_url":"https://api.github.com/users/AudriusButkevicius/events{/privacy}","received_events_url":"https://api.github.com/users/AudriusButkevicius/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AudriusButkevicius/syncthing","description":"Open Source Continuous File Synchronization","fork":true,"url":"https://api.github.com/repos/AudriusButkevicius/syncthing","forks_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/forks","keys_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/teams","hooks_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/hooks","issue_events_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/issues/events{/number}","events_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/events","assignees_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/assignees{/user}","branches_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/branches{/branch}","tags_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/tags","blobs_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/git/refs{/sha}","trees_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/statuses/{sha}","languages_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/languages","stargazers_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/stargazers","contributors_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/contributors","subscribers_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/subscribers","subscription_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/subscription","commits_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/commits{/sha}","git_commits_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/git/commits{/sha}","comments_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/comments{/number}","issue_comment_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/issues/comments{/number}","contents_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/contents/{+path}","compare_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/merges","archive_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/downloads","issues_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/issues{/number}","pulls_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/pulls{/number}","milestones_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/milestones{/number}","notifications_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/labels{/name}","releases_url":"https://api.github.com/repos/AudriusButkevicius/syncthing/releases{/id}","created_at":"2014-07-22T20:36:14Z","updated_at":"2015-03-30T20:58:54Z","pushed_at":"2015-06-28T20:20:08Z","git_url":"git://github.com/AudriusButkevicius/syncthing.git","ssh_url":"git@github.com:AudriusButkevicius/syncthing.git","clone_url":"https://github.com/AudriusButkevicius/syncthing.git","svn_url":"https://github.com/AudriusButkevicius/syncthing","homepage":"http://discourse.syncthing.net/","size":46753,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"syncthing:master","ref":"master","sha":"c8ac9721d7a9726215d6dac87a7c02ac50542d8f","user":{"login":"syncthing","id":7628018,"avatar_url":"https://avatars.githubusercontent.com/u/7628018?v=3","gravatar_id":"","url":"https://api.github.com/users/syncthing","html_url":"https://github.com/syncthing","followers_url":"https://api.github.com/users/syncthing/followers","following_url":"https://api.github.com/users/syncthing/following{/other_user}","gists_url":"https://api.github.com/users/syncthing/gists{/gist_id}","starred_url":"https://api.github.com/users/syncthing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/syncthing/subscriptions","organizations_url":"https://api.github.com/users/syncthing/orgs","repos_url":"https://api.github.com/users/syncthing/repos","events_url":"https://api.github.com/users/syncthing/events{/privacy}","received_events_url":"https://api.github.com/users/syncthing/received_events","type":"Organization","site_admin":false},"repo":{"id":14712850,"name":"syncthing","full_name":"syncthing/syncthing","owner":{"login":"syncthing","id":7628018,"avatar_url":"https://avatars.githubusercontent.com/u/7628018?v=3","gravatar_id":"","url":"https://api.github.com/users/syncthing","html_url":"https://github.com/syncthing","followers_url":"https://api.github.com/users/syncthing/followers","following_url":"https://api.github.com/users/syncthing/following{/other_user}","gists_url":"https://api.github.com/users/syncthing/gists{/gist_id}","starred_url":"https://api.github.com/users/syncthing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/syncthing/subscriptions","organizations_url":"https://api.github.com/users/syncthing/orgs","repos_url":"https://api.github.com/users/syncthing/repos","events_url":"https://api.github.com/users/syncthing/events{/privacy}","received_events_url":"https://api.github.com/users/syncthing/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/syncthing/syncthing","description":"Open Source Continuous File Synchronization","fork":false,"url":"https://api.github.com/repos/syncthing/syncthing","forks_url":"https://api.github.com/repos/syncthing/syncthing/forks","keys_url":"https://api.github.com/repos/syncthing/syncthing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/syncthing/syncthing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/syncthing/syncthing/teams","hooks_url":"https://api.github.com/repos/syncthing/syncthing/hooks","issue_events_url":"https://api.github.com/repos/syncthing/syncthing/issues/events{/number}","events_url":"https://api.github.com/repos/syncthing/syncthing/events","assignees_url":"https://api.github.com/repos/syncthing/syncthing/assignees{/user}","branches_url":"https://api.github.com/repos/syncthing/syncthing/branches{/branch}","tags_url":"https://api.github.com/repos/syncthing/syncthing/tags","blobs_url":"https://api.github.com/repos/syncthing/syncthing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/syncthing/syncthing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/syncthing/syncthing/git/refs{/sha}","trees_url":"https://api.github.com/repos/syncthing/syncthing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/syncthing/syncthing/statuses/{sha}","languages_url":"https://api.github.com/repos/syncthing/syncthing/languages","stargazers_url":"https://api.github.com/repos/syncthing/syncthing/stargazers","contributors_url":"https://api.github.com/repos/syncthing/syncthing/contributors","subscribers_url":"https://api.github.com/repos/syncthing/syncthing/subscribers","subscription_url":"https://api.github.com/repos/syncthing/syncthing/subscription","commits_url":"https://api.github.com/repos/syncthing/syncthing/commits{/sha}","git_commits_url":"https://api.github.com/repos/syncthing/syncthing/git/commits{/sha}","comments_url":"https://api.github.com/repos/syncthing/syncthing/comments{/number}","issue_comment_url":"https://api.github.com/repos/syncthing/syncthing/issues/comments{/number}","contents_url":"https://api.github.com/repos/syncthing/syncthing/contents/{+path}","compare_url":"https://api.github.com/repos/syncthing/syncthing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/syncthing/syncthing/merges","archive_url":"https://api.github.com/repos/syncthing/syncthing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/syncthing/syncthing/downloads","issues_url":"https://api.github.com/repos/syncthing/syncthing/issues{/number}","pulls_url":"https://api.github.com/repos/syncthing/syncthing/pulls{/number}","milestones_url":"https://api.github.com/repos/syncthing/syncthing/milestones{/number}","notifications_url":"https://api.github.com/repos/syncthing/syncthing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/syncthing/syncthing/labels{/name}","releases_url":"https://api.github.com/repos/syncthing/syncthing/releases{/id}","created_at":"2013-11-26T09:48:21Z","updated_at":"2015-07-01T07:38:23Z","pushed_at":"2015-06-30T18:38:38Z","git_url":"git://github.com/syncthing/syncthing.git","ssh_url":"git@github.com:syncthing/syncthing.git","clone_url":"https://github.com/syncthing/syncthing.git","svn_url":"https://github.com/syncthing/syncthing","homepage":"http://forum.syncthing.net/","size":65508,"stargazers_count":8941,"watchers_count":8941,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":629,"mirror_url":null,"open_issues_count":163,"forks":629,"open_issues":163,"watchers":8941,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/1995"},"html":{"href":"https://github.com/syncthing/syncthing/pull/1995"},"issue":{"href":"https://api.github.com/repos/syncthing/syncthing/issues/1995"},"comments":{"href":"https://api.github.com/repos/syncthing/syncthing/issues/1995/comments"},"review_comments":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/1995/comments"},"review_comment":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/1995/commits"},"statuses":{"href":"https://api.github.com/repos/syncthing/syncthing/statuses/a8beb2a055cc56995fd873a01f3aec91dafa6839"}}}}