{"action":"created","comment":{"url":"https://api.github.com/repos/syncthing/syncthing/pulls/comments/46660991","id":46660991,"diff_hunk":"@@ -165,16 +177,16 @@ next:\n \t\t// clients between the same NAT gateway, and global discovery.\n \t\tif remoteID == s.myID {\n \t\t\tl.Infof(\"Connected to myself (%s) - should not happen\", remoteID)\n-\t\t\tc.Conn.Close()\n+\t\t\tc.Close()\n \t\t\tcontinue\n \t\t}\n \n-\t\t// If we have a relay connection, and the new incoming connection is\n-\t\t// not a relay connection, we should drop that, and prefer the this one.\n+\t\t// If we have a connection, and the new incoming connection is\n+\t\t// of a higher priority, we should drop that, and prefer the this one.\n \t\ts.mut.RLock()\n-\t\tct, ok := s.connType[remoteID]\n+\t\tct, ok := s.currentConnection[remoteID]\n \t\ts.mut.RUnlock()\n-\t\tif ok && !ct.IsDirect() && c.Type.IsDirect() {\n+\t\tif ok && ct.Priority < c.Priority {","path":"lib/connections/svc.go","position":200,"original_position":200,"commit_id":"58ad5e74d9a3b9009b81151c6d1f3668a4a0eb6d","original_commit_id":"58ad5e74d9a3b9009b81151c6d1f3668a4a0eb6d","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":"Possibly, but https://github.com/syncthing/syncthing/blob/master/lib/discover/cache.go#L282 and things like nice levels, network priority marking etc work in the other direction (lower = better).","created_at":"2015-12-04T09:01:56Z","updated_at":"2015-12-04T09:01:56Z","html_url":"https://github.com/syncthing/syncthing/pull/2482#discussion_r46660991","pull_request_url":"https://api.github.com/repos/syncthing/syncthing/pulls/2482","_links":{"self":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/comments/46660991"},"html":{"href":"https://github.com/syncthing/syncthing/pull/2482#discussion_r46660991"},"pull_request":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/2482"}}},"pull_request":{"url":"https://api.github.com/repos/syncthing/syncthing/pulls/2482","id":51001024,"html_url":"https://github.com/syncthing/syncthing/pull/2482","diff_url":"https://github.com/syncthing/syncthing/pull/2482.diff","patch_url":"https://github.com/syncthing/syncthing/pull/2482.patch","issue_url":"https://api.github.com/repos/syncthing/syncthing/issues/2482","number":2482,"state":"open","locked":false,"title":"Refactor connections","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":"Relay is just another listen address\r\nRelay is just another dial address\r\nEasy to add a new type of connections\r\nA listen addresses can change, and have internal and external addresses\r\nA listen address can resolve to multiple addresses that get advertised, which means we can support multiple gateways and multiple port mappings acquired.","created_at":"2015-11-17T20:37:29Z","updated_at":"2015-12-04T09:01:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":{"url":"https://api.github.com/repos/syncthing/syncthing/milestones/2","html_url":"https://github.com/syncthing/syncthing/milestones/v1.0","labels_url":"https://api.github.com/repos/syncthing/syncthing/milestones/2/labels","id":528782,"number":2,"title":"v1.0","description":"Issues that *must* be resolved before releasing v1.0.","creator":{"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},"open_issues":8,"closed_issues":85,"state":"open","created_at":"2014-01-07T11:09:27Z","updated_at":"2015-11-22T12:00:20Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/syncthing/syncthing/pulls/2482/commits","review_comments_url":"https://api.github.com/repos/syncthing/syncthing/pulls/2482/comments","review_comment_url":"https://api.github.com/repos/syncthing/syncthing/pulls/comments{/number}","comments_url":"https://api.github.com/repos/syncthing/syncthing/issues/2482/comments","statuses_url":"https://api.github.com/repos/syncthing/syncthing/statuses/58ad5e74d9a3b9009b81151c6d1f3668a4a0eb6d","head":{"label":"AudriusButkevicius:connrefactor2","ref":"connrefactor2","sha":"58ad5e74d9a3b9009b81151c6d1f3668a4a0eb6d","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-11-28T20:23:47Z","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":57162,"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":"945ddc240351c8fe02642ec85846a6352756eb23","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-12-04T08:29:37Z","pushed_at":"2015-12-04T07:42:30Z","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":63479,"stargazers_count":10564,"watchers_count":10564,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":785,"mirror_url":null,"open_issues_count":172,"forks":785,"open_issues":172,"watchers":10564,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/2482"},"html":{"href":"https://github.com/syncthing/syncthing/pull/2482"},"issue":{"href":"https://api.github.com/repos/syncthing/syncthing/issues/2482"},"comments":{"href":"https://api.github.com/repos/syncthing/syncthing/issues/2482/comments"},"review_comments":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/2482/comments"},"review_comment":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/2482/commits"},"statuses":{"href":"https://api.github.com/repos/syncthing/syncthing/statuses/58ad5e74d9a3b9009b81151c6d1f3668a4a0eb6d"}}}}