{"action":"created","comment":{"url":"https://api.github.com/repos/getlantern/lantern/pulls/comments/28997244","id":28997244,"diff_hunk":"@@ -22,21 +22,30 @@ var (\n // Balancer balances connections established by one or more Dialers.\n type Balancer struct {\n \tdialers []*dialer\n+\ttrusted []*dialer\n }\n \n // New creates a new Balancer using the supplied Dialers.\n func New(dialers ...*Dialer) *Balancer {\n-\tdhs := make([]*dialer, 0, len(dialers))\n+\tbal := new(Balancer)\n+\n+\t// Sort dialers by QOS (ascending) for later selection\n+\tsort.Sort(byQOSAscending(dialers))","path":"src/github.com/getlantern/balancer/balancer.go","position":13,"original_position":13,"commit_id":"a2cec5f6669e128a010ccd891f6509b70511d7e4","original_commit_id":"a2cec5f6669e128a010ccd891f6509b70511d7e4","user":{"login":"aranhoide","id":2204867,"avatar_url":"https://avatars.githubusercontent.com/u/2204867?v=3","gravatar_id":"","url":"https://api.github.com/users/aranhoide","html_url":"https://github.com/aranhoide","followers_url":"https://api.github.com/users/aranhoide/followers","following_url":"https://api.github.com/users/aranhoide/following{/other_user}","gists_url":"https://api.github.com/users/aranhoide/gists{/gist_id}","starred_url":"https://api.github.com/users/aranhoide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aranhoide/subscriptions","organizations_url":"https://api.github.com/users/aranhoide/orgs","repos_url":"https://api.github.com/users/aranhoide/repos","events_url":"https://api.github.com/users/aranhoide/events{/privacy}","received_events_url":"https://api.github.com/users/aranhoide/received_events","type":"User","site_admin":false},"body":"It probably doesn't matter here, but in general it's considered bad form to mutate[1] arguments passed in unless that's the very purpose of the function.  The safest sequence would be to copy `dialers` into `bal.dialers`, then sort `bal.dialers` (which would leave `dialers` alone), then iterate over `bal.dialers` to collect the trusted ones into `bal.trusted`.\r\n\r\n[1] I wasn't sure whether `...this` declaration syntax would result in the same slice being passed when called with `this...` syntax, or whether a copy would be made.  It turns out the same slice is passed, so the callee can modify it in place, with changes visible to the caller.  Try this: \r\n\r\n```go\r\npackage main\r\n\r\nimport \"fmt\"\r\n\r\nfunc main() {\r\n\tss := []string{\"zero\", \"one\", \"two\"}\r\n\tfmt.Println(ss)\r\n\tchange(ss...)\r\n\tfmt.Println(ss)\r\n}\r\n\r\nfunc change(strs ...string) {\r\n\tstrs[2] = \"whoops\"\r\n}\r\n```","created_at":"2015-04-23T19:56:27Z","updated_at":"2015-04-23T19:56:27Z","html_url":"https://github.com/getlantern/lantern/pull/2424#discussion_r28997244","pull_request_url":"https://api.github.com/repos/getlantern/lantern/pulls/2424","_links":{"self":{"href":"https://api.github.com/repos/getlantern/lantern/pulls/comments/28997244"},"html":{"href":"https://github.com/getlantern/lantern/pull/2424#discussion_r28997244"},"pull_request":{"href":"https://api.github.com/repos/getlantern/lantern/pulls/2424"}}},"pull_request":{"url":"https://api.github.com/repos/getlantern/lantern/pulls/2424","id":33806191,"html_url":"https://github.com/getlantern/lantern/pull/2424","diff_url":"https://github.com/getlantern/lantern/pull/2424.diff","patch_url":"https://github.com/getlantern/lantern/pull/2424.patch","issue_url":"https://api.github.com/repos/getlantern/lantern/issues/2424","number":2424,"state":"open","locked":false,"title":"Route HTTP traffic to trusted proxies only","user":{"login":"xiam","id":385670,"avatar_url":"https://avatars.githubusercontent.com/u/385670?v=3","gravatar_id":"","url":"https://api.github.com/users/xiam","html_url":"https://github.com/xiam","followers_url":"https://api.github.com/users/xiam/followers","following_url":"https://api.github.com/users/xiam/following{/other_user}","gists_url":"https://api.github.com/users/xiam/gists{/gist_id}","starred_url":"https://api.github.com/users/xiam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiam/subscriptions","organizations_url":"https://api.github.com/users/xiam/orgs","repos_url":"https://api.github.com/users/xiam/repos","events_url":"https://api.github.com/users/xiam/events{/privacy}","received_events_url":"https://api.github.com/users/xiam/received_events","type":"User","site_admin":false},"body":"This PR adds support for routing plaintext HTTP traffic only to proxies deployed by Lantern, in this moment it may not represent any difference.\r\n\r\nHTTPs can travel safely along trusted and untrusted proxies without compromising user's data, as the protocol itself provides point to point encryption (well, point to Trusted Third Parties and eventually to point, but that's outside our scope).\r\n\r\nA new property `trusted` was added to our configuration settings, this feature depends on whether this flag is set true or not. If no servers marked as `trusted` are found Lantern will try to use any server (getting unsafe access is better than having no access at all).\r\n\r\nRouting an HTTP URL would produce a log like:\r\n\r\n```\r\ncurl -x 127.0.0.1:8787 http://www.google.com/humans.txt\r\n\r\nApr 21 19:56:19.621 - balancer: balancer.go:100 Dialing tcp://www.google.com:80 with (trusted) fronted proxy at nl.fallbacks.getiantem.org:443 using masquerade set cloudflare\r\n```\r\n\r\nWhile routing an HTTPs URL would look like:\r\n\r\n```\r\ncurl -x 127.0.0.1:8787 https://www.google.com/humans.txt\r\n\r\nApr 21 19:57:05.401 - balancer: balancer.go:100 Dialing tcp://s3.amazonaws.com:443 with chained proxy at 178.62.243.211:443\r\n```\r\n\r\nYou'll probably need to edit `lantern.yaml` manually to set the `trusted` field on fronted and chained proxies.\r\n\r\nI also added many comments on the code that would make it easier to understand what is each part trying to do and fixed a few minor bugs.\r\n\r\nSee our discussion at: https://github.com/getlantern/lantern/issues/2290","created_at":"2015-04-21T21:38:43Z","updated_at":"2015-04-23T19:56:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dd63b141f296f951ade6da6997664bb964b9bc48","assignee":{"login":"aranhoide","id":2204867,"avatar_url":"https://avatars.githubusercontent.com/u/2204867?v=3","gravatar_id":"","url":"https://api.github.com/users/aranhoide","html_url":"https://github.com/aranhoide","followers_url":"https://api.github.com/users/aranhoide/followers","following_url":"https://api.github.com/users/aranhoide/following{/other_user}","gists_url":"https://api.github.com/users/aranhoide/gists{/gist_id}","starred_url":"https://api.github.com/users/aranhoide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aranhoide/subscriptions","organizations_url":"https://api.github.com/users/aranhoide/orgs","repos_url":"https://api.github.com/users/aranhoide/repos","events_url":"https://api.github.com/users/aranhoide/events{/privacy}","received_events_url":"https://api.github.com/users/aranhoide/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/getlantern/lantern/pulls/2424/commits","review_comments_url":"https://api.github.com/repos/getlantern/lantern/pulls/2424/comments","review_comment_url":"https://api.github.com/repos/getlantern/lantern/pulls/comments{/number}","comments_url":"https://api.github.com/repos/getlantern/lantern/issues/2424/comments","statuses_url":"https://api.github.com/repos/getlantern/lantern/statuses/a2cec5f6669e128a010ccd891f6509b70511d7e4","head":{"label":"getlantern:fix/issue-2290","ref":"fix/issue-2290","sha":"a2cec5f6669e128a010ccd891f6509b70511d7e4","user":{"login":"getlantern","id":624178,"avatar_url":"https://avatars.githubusercontent.com/u/624178?v=3","gravatar_id":"","url":"https://api.github.com/users/getlantern","html_url":"https://github.com/getlantern","followers_url":"https://api.github.com/users/getlantern/followers","following_url":"https://api.github.com/users/getlantern/following{/other_user}","gists_url":"https://api.github.com/users/getlantern/gists{/gist_id}","starred_url":"https://api.github.com/users/getlantern/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/getlantern/subscriptions","organizations_url":"https://api.github.com/users/getlantern/orgs","repos_url":"https://api.github.com/users/getlantern/repos","events_url":"https://api.github.com/users/getlantern/events{/privacy}","received_events_url":"https://api.github.com/users/getlantern/received_events","type":"Organization","site_admin":false},"repo":{"id":1380117,"name":"lantern","full_name":"getlantern/lantern","owner":{"login":"getlantern","id":624178,"avatar_url":"https://avatars.githubusercontent.com/u/624178?v=3","gravatar_id":"","url":"https://api.github.com/users/getlantern","html_url":"https://github.com/getlantern","followers_url":"https://api.github.com/users/getlantern/followers","following_url":"https://api.github.com/users/getlantern/following{/other_user}","gists_url":"https://api.github.com/users/getlantern/gists{/gist_id}","starred_url":"https://api.github.com/users/getlantern/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/getlantern/subscriptions","organizations_url":"https://api.github.com/users/getlantern/orgs","repos_url":"https://api.github.com/users/getlantern/repos","events_url":"https://api.github.com/users/getlantern/events{/privacy}","received_events_url":"https://api.github.com/users/getlantern/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/getlantern/lantern","description":"Defeat censorship. Share access to the open internet with people around the world through your social network.","fork":false,"url":"https://api.github.com/repos/getlantern/lantern","forks_url":"https://api.github.com/repos/getlantern/lantern/forks","keys_url":"https://api.github.com/repos/getlantern/lantern/keys{/key_id}","collaborators_url":"https://api.github.com/repos/getlantern/lantern/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/getlantern/lantern/teams","hooks_url":"https://api.github.com/repos/getlantern/lantern/hooks","issue_events_url":"https://api.github.com/repos/getlantern/lantern/issues/events{/number}","events_url":"https://api.github.com/repos/getlantern/lantern/events","assignees_url":"https://api.github.com/repos/getlantern/lantern/assignees{/user}","branches_url":"https://api.github.com/repos/getlantern/lantern/branches{/branch}","tags_url":"https://api.github.com/repos/getlantern/lantern/tags","blobs_url":"https://api.github.com/repos/getlantern/lantern/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/getlantern/lantern/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/getlantern/lantern/git/refs{/sha}","trees_url":"https://api.github.com/repos/getlantern/lantern/git/trees{/sha}","statuses_url":"https://api.github.com/repos/getlantern/lantern/statuses/{sha}","languages_url":"https://api.github.com/repos/getlantern/lantern/languages","stargazers_url":"https://api.github.com/repos/getlantern/lantern/stargazers","contributors_url":"https://api.github.com/repos/getlantern/lantern/contributors","subscribers_url":"https://api.github.com/repos/getlantern/lantern/subscribers","subscription_url":"https://api.github.com/repos/getlantern/lantern/subscription","commits_url":"https://api.github.com/repos/getlantern/lantern/commits{/sha}","git_commits_url":"https://api.github.com/repos/getlantern/lantern/git/commits{/sha}","comments_url":"https://api.github.com/repos/getlantern/lantern/comments{/number}","issue_comment_url":"https://api.github.com/repos/getlantern/lantern/issues/comments{/number}","contents_url":"https://api.github.com/repos/getlantern/lantern/contents/{+path}","compare_url":"https://api.github.com/repos/getlantern/lantern/compare/{base}...{head}","merges_url":"https://api.github.com/repos/getlantern/lantern/merges","archive_url":"https://api.github.com/repos/getlantern/lantern/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/getlantern/lantern/downloads","issues_url":"https://api.github.com/repos/getlantern/lantern/issues{/number}","pulls_url":"https://api.github.com/repos/getlantern/lantern/pulls{/number}","milestones_url":"https://api.github.com/repos/getlantern/lantern/milestones{/number}","notifications_url":"https://api.github.com/repos/getlantern/lantern/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/getlantern/lantern/labels{/name}","releases_url":"https://api.github.com/repos/getlantern/lantern/releases{/id}","created_at":"2011-02-17T22:12:29Z","updated_at":"2015-04-23T19:44:12Z","pushed_at":"2015-04-23T19:44:12Z","git_url":"git://github.com/getlantern/lantern.git","ssh_url":"git@github.com:getlantern/lantern.git","clone_url":"https://github.com/getlantern/lantern.git","svn_url":"https://github.com/getlantern/lantern","homepage":"https://getlantern.org","size":867158,"stargazers_count":1138,"watchers_count":1138,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":241,"mirror_url":null,"open_issues_count":363,"forks":241,"open_issues":363,"watchers":1138,"default_branch":"valencia"}},"base":{"label":"getlantern:valencia","ref":"valencia","sha":"d867a6507e1f0beb67ff4baee7893acc73718a59","user":{"login":"getlantern","id":624178,"avatar_url":"https://avatars.githubusercontent.com/u/624178?v=3","gravatar_id":"","url":"https://api.github.com/users/getlantern","html_url":"https://github.com/getlantern","followers_url":"https://api.github.com/users/getlantern/followers","following_url":"https://api.github.com/users/getlantern/following{/other_user}","gists_url":"https://api.github.com/users/getlantern/gists{/gist_id}","starred_url":"https://api.github.com/users/getlantern/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/getlantern/subscriptions","organizations_url":"https://api.github.com/users/getlantern/orgs","repos_url":"https://api.github.com/users/getlantern/repos","events_url":"https://api.github.com/users/getlantern/events{/privacy}","received_events_url":"https://api.github.com/users/getlantern/received_events","type":"Organization","site_admin":false},"repo":{"id":1380117,"name":"lantern","full_name":"getlantern/lantern","owner":{"login":"getlantern","id":624178,"avatar_url":"https://avatars.githubusercontent.com/u/624178?v=3","gravatar_id":"","url":"https://api.github.com/users/getlantern","html_url":"https://github.com/getlantern","followers_url":"https://api.github.com/users/getlantern/followers","following_url":"https://api.github.com/users/getlantern/following{/other_user}","gists_url":"https://api.github.com/users/getlantern/gists{/gist_id}","starred_url":"https://api.github.com/users/getlantern/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/getlantern/subscriptions","organizations_url":"https://api.github.com/users/getlantern/orgs","repos_url":"https://api.github.com/users/getlantern/repos","events_url":"https://api.github.com/users/getlantern/events{/privacy}","received_events_url":"https://api.github.com/users/getlantern/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/getlantern/lantern","description":"Defeat censorship. Share access to the open internet with people around the world through your social network.","fork":false,"url":"https://api.github.com/repos/getlantern/lantern","forks_url":"https://api.github.com/repos/getlantern/lantern/forks","keys_url":"https://api.github.com/repos/getlantern/lantern/keys{/key_id}","collaborators_url":"https://api.github.com/repos/getlantern/lantern/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/getlantern/lantern/teams","hooks_url":"https://api.github.com/repos/getlantern/lantern/hooks","issue_events_url":"https://api.github.com/repos/getlantern/lantern/issues/events{/number}","events_url":"https://api.github.com/repos/getlantern/lantern/events","assignees_url":"https://api.github.com/repos/getlantern/lantern/assignees{/user}","branches_url":"https://api.github.com/repos/getlantern/lantern/branches{/branch}","tags_url":"https://api.github.com/repos/getlantern/lantern/tags","blobs_url":"https://api.github.com/repos/getlantern/lantern/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/getlantern/lantern/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/getlantern/lantern/git/refs{/sha}","trees_url":"https://api.github.com/repos/getlantern/lantern/git/trees{/sha}","statuses_url":"https://api.github.com/repos/getlantern/lantern/statuses/{sha}","languages_url":"https://api.github.com/repos/getlantern/lantern/languages","stargazers_url":"https://api.github.com/repos/getlantern/lantern/stargazers","contributors_url":"https://api.github.com/repos/getlantern/lantern/contributors","subscribers_url":"https://api.github.com/repos/getlantern/lantern/subscribers","subscription_url":"https://api.github.com/repos/getlantern/lantern/subscription","commits_url":"https://api.github.com/repos/getlantern/lantern/commits{/sha}","git_commits_url":"https://api.github.com/repos/getlantern/lantern/git/commits{/sha}","comments_url":"https://api.github.com/repos/getlantern/lantern/comments{/number}","issue_comment_url":"https://api.github.com/repos/getlantern/lantern/issues/comments{/number}","contents_url":"https://api.github.com/repos/getlantern/lantern/contents/{+path}","compare_url":"https://api.github.com/repos/getlantern/lantern/compare/{base}...{head}","merges_url":"https://api.github.com/repos/getlantern/lantern/merges","archive_url":"https://api.github.com/repos/getlantern/lantern/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/getlantern/lantern/downloads","issues_url":"https://api.github.com/repos/getlantern/lantern/issues{/number}","pulls_url":"https://api.github.com/repos/getlantern/lantern/pulls{/number}","milestones_url":"https://api.github.com/repos/getlantern/lantern/milestones{/number}","notifications_url":"https://api.github.com/repos/getlantern/lantern/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/getlantern/lantern/labels{/name}","releases_url":"https://api.github.com/repos/getlantern/lantern/releases{/id}","created_at":"2011-02-17T22:12:29Z","updated_at":"2015-04-23T19:44:12Z","pushed_at":"2015-04-23T19:44:12Z","git_url":"git://github.com/getlantern/lantern.git","ssh_url":"git@github.com:getlantern/lantern.git","clone_url":"https://github.com/getlantern/lantern.git","svn_url":"https://github.com/getlantern/lantern","homepage":"https://getlantern.org","size":867158,"stargazers_count":1138,"watchers_count":1138,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":241,"mirror_url":null,"open_issues_count":363,"forks":241,"open_issues":363,"watchers":1138,"default_branch":"valencia"}},"_links":{"self":{"href":"https://api.github.com/repos/getlantern/lantern/pulls/2424"},"html":{"href":"https://github.com/getlantern/lantern/pull/2424"},"issue":{"href":"https://api.github.com/repos/getlantern/lantern/issues/2424"},"comments":{"href":"https://api.github.com/repos/getlantern/lantern/issues/2424/comments"},"review_comments":{"href":"https://api.github.com/repos/getlantern/lantern/pulls/2424/comments"},"review_comment":{"href":"https://api.github.com/repos/getlantern/lantern/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/getlantern/lantern/pulls/2424/commits"},"statuses":{"href":"https://api.github.com/repos/getlantern/lantern/statuses/a2cec5f6669e128a010ccd891f6509b70511d7e4"}}}}