{"action":"created","comment":{"url":"https://api.github.com/repos/libp2p/rust-libp2p/pulls/comments/224015746","pull_request_review_id":163276977,"id":224015746,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNDAxNTc0Ng==","diff_hunk":"@@ -194,40 +193,30 @@ impl Transport for TcpConfig {\n     }\n \n     fn nat_traversal(&self, server: &Multiaddr, observed: &Multiaddr) -> Option<Multiaddr> {\n-        // Check that `server` only has two components and retreive them.\n-        let mut server_protocols_iter = server.iter();\n-        let server_proto1 = server_protocols_iter.next()?;\n-        let server_proto2 = server_protocols_iter.next()?;\n-        if server_protocols_iter.next().is_some() {\n-            return None;\n-        }\n+        let mut address = Multiaddr::default();\n+\n+        let mut server_iter = server.iter();\n+        let mut observed_iter = observed.iter();\n \n-        // Check that `observed` only has two components and retreive them.\n-        let mut observed_protocols_iter = observed.iter();\n-        let observed_proto1 = observed_protocols_iter.next()?;\n-        let observed_proto2 = observed_protocols_iter.next()?;\n-        if observed_protocols_iter.next().is_some() {\n-            return None;\n+        // Use the observed IP address.\n+        match (server_iter.next(), observed_iter.next()) {\n+            (Some(Protocol::Ip4(_)), Some(x@Protocol::Ip4(_))) => address.append(x),\n+            (Some(Protocol::Ip6(_)), Some(x@Protocol::Ip6(_))) => address.append(x),\n+            _ => return None\n         }\n \n-        // Check that `server` is a valid TCP/IP address.\n-        match (&server_proto1, &server_proto2) {\n-            (&Protocol::Ip4(_), &Protocol::Tcp(_))\n-            | (&Protocol::Ip6(_), &Protocol::Tcp(_)) => {}\n-            _ => return None,\n+        // Check for TCP but retain the server port.","path":"transports/tcp/src/lib.rs","position":41,"original_position":42,"commit_id":"4f35e5dcc1def7b259c665331f5a585969124f0b","original_commit_id":"3034ef31767c8c1285cadf71a31e4d9ffde46a52","user":{"login":"tomaka","id":1412254,"node_id":"MDQ6VXNlcjE0MTIyNTQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1412254?v=4","gravatar_id":"","url":"https://api.github.com/users/tomaka","html_url":"https://github.com/tomaka","followers_url":"https://api.github.com/users/tomaka/followers","following_url":"https://api.github.com/users/tomaka/following{/other_user}","gists_url":"https://api.github.com/users/tomaka/gists{/gist_id}","starred_url":"https://api.github.com/users/tomaka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomaka/subscriptions","organizations_url":"https://api.github.com/users/tomaka/orgs","repos_url":"https://api.github.com/users/tomaka/repos","events_url":"https://api.github.com/users/tomaka/events{/privacy}","received_events_url":"https://api.github.com/users/tomaka/received_events","type":"User","site_admin":false},"body":"I think we don't need the observed address to have the TCP suffix. Just matching IP is enough.","created_at":"2018-10-10T10:09:31Z","updated_at":"2018-10-10T10:18:19Z","html_url":"https://github.com/libp2p/rust-libp2p/pull/550#discussion_r224015746","pull_request_url":"https://api.github.com/repos/libp2p/rust-libp2p/pulls/550","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/libp2p/rust-libp2p/pulls/comments/224015746"},"html":{"href":"https://github.com/libp2p/rust-libp2p/pull/550#discussion_r224015746"},"pull_request":{"href":"https://api.github.com/repos/libp2p/rust-libp2p/pulls/550"}}},"pull_request":{"url":"https://api.github.com/repos/libp2p/rust-libp2p/pulls/550","id":221712429,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIxNzEyNDI5","html_url":"https://github.com/libp2p/rust-libp2p/pull/550","diff_url":"https://github.com/libp2p/rust-libp2p/pull/550.diff","patch_url":"https://github.com/libp2p/rust-libp2p/pull/550.patch","issue_url":"https://api.github.com/repos/libp2p/rust-libp2p/issues/550","number":550,"state":"open","locked":false,"title":"Change some `nat_traversal`s to consider a prefix.","user":{"login":"twittner","id":132165,"node_id":"MDQ6VXNlcjEzMjE2NQ==","avatar_url":"https://avatars0.githubusercontent.com/u/132165?v=4","gravatar_id":"","url":"https://api.github.com/users/twittner","html_url":"https://github.com/twittner","followers_url":"https://api.github.com/users/twittner/followers","following_url":"https://api.github.com/users/twittner/following{/other_user}","gists_url":"https://api.github.com/users/twittner/gists{/gist_id}","starred_url":"https://api.github.com/users/twittner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twittner/subscriptions","organizations_url":"https://api.github.com/users/twittner/orgs","repos_url":"https://api.github.com/users/twittner/repos","events_url":"https://api.github.com/users/twittner/events{/privacy}","received_events_url":"https://api.github.com/users/twittner/received_events","type":"User","site_admin":false},"body":"Transports should consider only the relevant address prefix.\r\n\r\nFixes #544.","created_at":"2018-10-10T09:10:28Z","updated_at":"2018-10-10T10:18:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ddbef9f1714bcd39c1bb2a7bf3748ab57e5ba192","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/libp2p/rust-libp2p/pulls/550/commits","review_comments_url":"https://api.github.com/repos/libp2p/rust-libp2p/pulls/550/comments","review_comment_url":"https://api.github.com/repos/libp2p/rust-libp2p/pulls/comments{/number}","comments_url":"https://api.github.com/repos/libp2p/rust-libp2p/issues/550/comments","statuses_url":"https://api.github.com/repos/libp2p/rust-libp2p/statuses/4f35e5dcc1def7b259c665331f5a585969124f0b","head":{"label":"twittner:nat_traversal_prefix","ref":"nat_traversal_prefix","sha":"4f35e5dcc1def7b259c665331f5a585969124f0b","user":{"login":"twittner","id":132165,"node_id":"MDQ6VXNlcjEzMjE2NQ==","avatar_url":"https://avatars0.githubusercontent.com/u/132165?v=4","gravatar_id":"","url":"https://api.github.com/users/twittner","html_url":"https://github.com/twittner","followers_url":"https://api.github.com/users/twittner/followers","following_url":"https://api.github.com/users/twittner/following{/other_user}","gists_url":"https://api.github.com/users/twittner/gists{/gist_id}","starred_url":"https://api.github.com/users/twittner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twittner/subscriptions","organizations_url":"https://api.github.com/users/twittner/orgs","repos_url":"https://api.github.com/users/twittner/repos","events_url":"https://api.github.com/users/twittner/events{/privacy}","received_events_url":"https://api.github.com/users/twittner/received_events","type":"User","site_admin":false},"repo":{"id":127297671,"node_id":"MDEwOlJlcG9zaXRvcnkxMjcyOTc2NzE=","name":"rust-libp2p","full_name":"twittner/rust-libp2p","private":false,"owner":{"login":"twittner","id":132165,"node_id":"MDQ6VXNlcjEzMjE2NQ==","avatar_url":"https://avatars0.githubusercontent.com/u/132165?v=4","gravatar_id":"","url":"https://api.github.com/users/twittner","html_url":"https://github.com/twittner","followers_url":"https://api.github.com/users/twittner/followers","following_url":"https://api.github.com/users/twittner/following{/other_user}","gists_url":"https://api.github.com/users/twittner/gists{/gist_id}","starred_url":"https://api.github.com/users/twittner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twittner/subscriptions","organizations_url":"https://api.github.com/users/twittner/orgs","repos_url":"https://api.github.com/users/twittner/repos","events_url":"https://api.github.com/users/twittner/events{/privacy}","received_events_url":"https://api.github.com/users/twittner/received_events","type":"User","site_admin":false},"html_url":"https://github.com/twittner/rust-libp2p","description":"The Rust Implementation of libp2p networking stack. ","fork":true,"url":"https://api.github.com/repos/twittner/rust-libp2p","forks_url":"https://api.github.com/repos/twittner/rust-libp2p/forks","keys_url":"https://api.github.com/repos/twittner/rust-libp2p/keys{/key_id}","collaborators_url":"https://api.github.com/repos/twittner/rust-libp2p/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/twittner/rust-libp2p/teams","hooks_url":"https://api.github.com/repos/twittner/rust-libp2p/hooks","issue_events_url":"https://api.github.com/repos/twittner/rust-libp2p/issues/events{/number}","events_url":"https://api.github.com/repos/twittner/rust-libp2p/events","assignees_url":"https://api.github.com/repos/twittner/rust-libp2p/assignees{/user}","branches_url":"https://api.github.com/repos/twittner/rust-libp2p/branches{/branch}","tags_url":"https://api.github.com/repos/twittner/rust-libp2p/tags","blobs_url":"https://api.github.com/repos/twittner/rust-libp2p/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/twittner/rust-libp2p/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/twittner/rust-libp2p/git/refs{/sha}","trees_url":"https://api.github.com/repos/twittner/rust-libp2p/git/trees{/sha}","statuses_url":"https://api.github.com/repos/twittner/rust-libp2p/statuses/{sha}","languages_url":"https://api.github.com/repos/twittner/rust-libp2p/languages","stargazers_url":"https://api.github.com/repos/twittner/rust-libp2p/stargazers","contributors_url":"https://api.github.com/repos/twittner/rust-libp2p/contributors","subscribers_url":"https://api.github.com/repos/twittner/rust-libp2p/subscribers","subscription_url":"https://api.github.com/repos/twittner/rust-libp2p/subscription","commits_url":"https://api.github.com/repos/twittner/rust-libp2p/commits{/sha}","git_commits_url":"https://api.github.com/repos/twittner/rust-libp2p/git/commits{/sha}","comments_url":"https://api.github.com/repos/twittner/rust-libp2p/comments{/number}","issue_comment_url":"https://api.github.com/repos/twittner/rust-libp2p/issues/comments{/number}","contents_url":"https://api.github.com/repos/twittner/rust-libp2p/contents/{+path}","compare_url":"https://api.github.com/repos/twittner/rust-libp2p/compare/{base}...{head}","merges_url":"https://api.github.com/repos/twittner/rust-libp2p/merges","archive_url":"https://api.github.com/repos/twittner/rust-libp2p/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/twittner/rust-libp2p/downloads","issues_url":"https://api.github.com/repos/twittner/rust-libp2p/issues{/number}","pulls_url":"https://api.github.com/repos/twittner/rust-libp2p/pulls{/number}","milestones_url":"https://api.github.com/repos/twittner/rust-libp2p/milestones{/number}","notifications_url":"https://api.github.com/repos/twittner/rust-libp2p/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/twittner/rust-libp2p/labels{/name}","releases_url":"https://api.github.com/repos/twittner/rust-libp2p/releases{/id}","deployments_url":"https://api.github.com/repos/twittner/rust-libp2p/deployments","created_at":"2018-03-29T13:44:40Z","updated_at":"2018-10-02T15:48:50Z","pushed_at":"2018-10-10T10:14:38Z","git_url":"git://github.com/twittner/rust-libp2p.git","ssh_url":"git@github.com:twittner/rust-libp2p.git","clone_url":"https://github.com/twittner/rust-libp2p.git","svn_url":"https://github.com/twittner/rust-libp2p","homepage":"https://libp2p.io","size":1854,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"libp2p:master","ref":"master","sha":"9bdaabc88476f1b899491015dedaec36ad2d7a58","user":{"login":"libp2p","id":14838238,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0ODM4MjM4","avatar_url":"https://avatars3.githubusercontent.com/u/14838238?v=4","gravatar_id":"","url":"https://api.github.com/users/libp2p","html_url":"https://github.com/libp2p","followers_url":"https://api.github.com/users/libp2p/followers","following_url":"https://api.github.com/users/libp2p/following{/other_user}","gists_url":"https://api.github.com/users/libp2p/gists{/gist_id}","starred_url":"https://api.github.com/users/libp2p/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libp2p/subscriptions","organizations_url":"https://api.github.com/users/libp2p/orgs","repos_url":"https://api.github.com/users/libp2p/repos","events_url":"https://api.github.com/users/libp2p/events{/privacy}","received_events_url":"https://api.github.com/users/libp2p/received_events","type":"Organization","site_admin":false},"repo":{"id":86106381,"node_id":"MDEwOlJlcG9zaXRvcnk4NjEwNjM4MQ==","name":"rust-libp2p","full_name":"libp2p/rust-libp2p","private":false,"owner":{"login":"libp2p","id":14838238,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0ODM4MjM4","avatar_url":"https://avatars3.githubusercontent.com/u/14838238?v=4","gravatar_id":"","url":"https://api.github.com/users/libp2p","html_url":"https://github.com/libp2p","followers_url":"https://api.github.com/users/libp2p/followers","following_url":"https://api.github.com/users/libp2p/following{/other_user}","gists_url":"https://api.github.com/users/libp2p/gists{/gist_id}","starred_url":"https://api.github.com/users/libp2p/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libp2p/subscriptions","organizations_url":"https://api.github.com/users/libp2p/orgs","repos_url":"https://api.github.com/users/libp2p/repos","events_url":"https://api.github.com/users/libp2p/events{/privacy}","received_events_url":"https://api.github.com/users/libp2p/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/libp2p/rust-libp2p","description":"The Rust Implementation of libp2p networking stack. ","fork":false,"url":"https://api.github.com/repos/libp2p/rust-libp2p","forks_url":"https://api.github.com/repos/libp2p/rust-libp2p/forks","keys_url":"https://api.github.com/repos/libp2p/rust-libp2p/keys{/key_id}","collaborators_url":"https://api.github.com/repos/libp2p/rust-libp2p/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/libp2p/rust-libp2p/teams","hooks_url":"https://api.github.com/repos/libp2p/rust-libp2p/hooks","issue_events_url":"https://api.github.com/repos/libp2p/rust-libp2p/issues/events{/number}","events_url":"https://api.github.com/repos/libp2p/rust-libp2p/events","assignees_url":"https://api.github.com/repos/libp2p/rust-libp2p/assignees{/user}","branches_url":"https://api.github.com/repos/libp2p/rust-libp2p/branches{/branch}","tags_url":"https://api.github.com/repos/libp2p/rust-libp2p/tags","blobs_url":"https://api.github.com/repos/libp2p/rust-libp2p/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/libp2p/rust-libp2p/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/libp2p/rust-libp2p/git/refs{/sha}","trees_url":"https://api.github.com/repos/libp2p/rust-libp2p/git/trees{/sha}","statuses_url":"https://api.github.com/repos/libp2p/rust-libp2p/statuses/{sha}","languages_url":"https://api.github.com/repos/libp2p/rust-libp2p/languages","stargazers_url":"https://api.github.com/repos/libp2p/rust-libp2p/stargazers","contributors_url":"https://api.github.com/repos/libp2p/rust-libp2p/contributors","subscribers_url":"https://api.github.com/repos/libp2p/rust-libp2p/subscribers","subscription_url":"https://api.github.com/repos/libp2p/rust-libp2p/subscription","commits_url":"https://api.github.com/repos/libp2p/rust-libp2p/commits{/sha}","git_commits_url":"https://api.github.com/repos/libp2p/rust-libp2p/git/commits{/sha}","comments_url":"https://api.github.com/repos/libp2p/rust-libp2p/comments{/number}","issue_comment_url":"https://api.github.com/repos/libp2p/rust-libp2p/issues/comments{/number}","contents_url":"https://api.github.com/repos/libp2p/rust-libp2p/contents/{+path}","compare_url":"https://api.github.com/repos/libp2p/rust-libp2p/compare/{base}...{head}","merges_url":"https://api.github.com/repos/libp2p/rust-libp2p/merges","archive_url":"https://api.github.com/repos/libp2p/rust-libp2p/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/libp2p/rust-libp2p/downloads","issues_url":"https://api.github.com/repos/libp2p/rust-libp2p/issues{/number}","pulls_url":"https://api.github.com/repos/libp2p/rust-libp2p/pulls{/number}","milestones_url":"https://api.github.com/repos/libp2p/rust-libp2p/milestones{/number}","notifications_url":"https://api.github.com/repos/libp2p/rust-libp2p/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/libp2p/rust-libp2p/labels{/name}","releases_url":"https://api.github.com/repos/libp2p/rust-libp2p/releases{/id}","deployments_url":"https://api.github.com/repos/libp2p/rust-libp2p/deployments","created_at":"2017-03-24T20:05:11Z","updated_at":"2018-10-10T09:07:35Z","pushed_at":"2018-10-10T10:14:39Z","git_url":"git://github.com/libp2p/rust-libp2p.git","ssh_url":"git@github.com:libp2p/rust-libp2p.git","clone_url":"https://github.com/libp2p/rust-libp2p.git","svn_url":"https://github.com/libp2p/rust-libp2p","homepage":"https://libp2p.io","size":1857,"stargazers_count":467,"watchers_count":467,"language":"Rust","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":67,"mirror_url":null,"archived":false,"open_issues_count":105,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":67,"open_issues":105,"watchers":467,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/libp2p/rust-libp2p/pulls/550"},"html":{"href":"https://github.com/libp2p/rust-libp2p/pull/550"},"issue":{"href":"https://api.github.com/repos/libp2p/rust-libp2p/issues/550"},"comments":{"href":"https://api.github.com/repos/libp2p/rust-libp2p/issues/550/comments"},"review_comments":{"href":"https://api.github.com/repos/libp2p/rust-libp2p/pulls/550/comments"},"review_comment":{"href":"https://api.github.com/repos/libp2p/rust-libp2p/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/libp2p/rust-libp2p/pulls/550/commits"},"statuses":{"href":"https://api.github.com/repos/libp2p/rust-libp2p/statuses/4f35e5dcc1def7b259c665331f5a585969124f0b"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"tomaka"}}