{"action":"created","comment":{"url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/pulls/comments/43988864","id":43988864,"diff_hunk":"@@ -0,0 +1,65 @@\n+package org.elasticsearch.discovery.srv;\n+\n+import static org.junit.Assert.assertEquals;\n+import static org.junit.Assert.assertFalse;\n+import static org.junit.Assert.assertTrue;\n+\n+import java.util.List;\n+\n+import org.elasticsearch.common.settings.ImmutableSettings;\n+import org.junit.Test;\n+import org.xbill.DNS.DClass;\n+import org.xbill.DNS.Name;\n+import org.xbill.DNS.Record;\n+import org.xbill.DNS.SRVRecord;\n+import org.xbill.DNS.TextParseException;\n+import org.xbill.DNS.Type;\n+\n+public class SrvUnicastHostsProviderTest {\n+\n+    @Test\n+    public void local_address_returns_true() {\n+        SrvUnicastHostsProvider provider = new SrvUnicastHostsProvider(ImmutableSettings.EMPTY, null, null);\n+        boolean isLocal = provider.isLocalIP(\"127.0.0.1\");\n+        assertTrue(isLocal);\n+    }\n+\n+    @Test\n+    public void non_local_address_returns_false() {\n+        SrvUnicastHostsProvider provider = new SrvUnicastHostsProvider(ImmutableSettings.EMPTY, null, null);\n+        boolean isLocal = provider.isLocalIP(\"255.255.255.255\");\n+        assertFalse(isLocal);\n+    }\n+\n+    @Test\n+    public void non_local_address_returns_fals123e() {\n+        SrvUnicastHostsProvider provider = new SrvUnicastHostsProvider(ImmutableSettings.EMPTY, null, null);\n+        Record[] records = new Record[] { getRecord(\"www.somewhere.com.\"), getRecord(\"localhost.\") };\n+        List<Record> filteredRecords = provider.filterOutOwnRecord(records);\n+        assertEquals(filteredRecords.size(), 1);\n+    }\n+\n+    private Record getRecord(String name) {\n+        try {\n+            Name hostname = new Name(name);\n+\n+            Name target = new Name(name);\n+\n+            return new SRVRecord(hostname, Type.SRV, DClass.ANY, 30, 1, 80, target);\n+        } catch (TextParseException e) {\n+            e.printStackTrace();\n+        }\n+        throw new RuntimeException();\n+    }\n+\n+    @Test\n+    public void isTCP() {\n+        SrvUnicastHostsProvider provider = new SrvUnicastHostsProvider(ImmutableSettings.EMPTY, null, null);\n+        boolean isTCP = provider.isTCP(\"tcp\");\n+        assertTrue(isTCP);\n+\n+        boolean isUDP = provider.isTCP(\"udp\");\n+        assertFalse(isUDP);\n+    }\n+\n+}","path":"src/test/org/elasticsearch/discovery/srv/SrvUnicastHostsProviderTest.java","position":65,"original_position":65,"commit_id":"d1804716be3a388cbae2ff937cd91cda410b7716","original_commit_id":"d1804716be3a388cbae2ff937cd91cda410b7716","user":{"login":"tnn","id":161150,"avatar_url":"https://avatars.githubusercontent.com/u/161150?v=3","gravatar_id":"","url":"https://api.github.com/users/tnn","html_url":"https://github.com/tnn","followers_url":"https://api.github.com/users/tnn/followers","following_url":"https://api.github.com/users/tnn/following{/other_user}","gists_url":"https://api.github.com/users/tnn/gists{/gist_id}","starred_url":"https://api.github.com/users/tnn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tnn/subscriptions","organizations_url":"https://api.github.com/users/tnn/orgs","repos_url":"https://api.github.com/users/tnn/repos","events_url":"https://api.github.com/users/tnn/events{/privacy}","received_events_url":"https://api.github.com/users/tnn/received_events","type":"User","site_admin":false},"body":"newline","created_at":"2015-11-05T08:56:38Z","updated_at":"2015-11-05T08:56:38Z","html_url":"https://github.com/Tradeshift/elasticsearch-srv-discovery/pull/2#discussion_r43988864","pull_request_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/pulls/comments/43988864"},"html":{"href":"https://github.com/Tradeshift/elasticsearch-srv-discovery/pull/2#discussion_r43988864"},"pull_request":{"href":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/pulls/2","id":49796426,"html_url":"https://github.com/Tradeshift/elasticsearch-srv-discovery/pull/2","diff_url":"https://github.com/Tradeshift/elasticsearch-srv-discovery/pull/2.diff","patch_url":"https://github.com/Tradeshift/elasticsearch-srv-discovery/pull/2.patch","issue_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/issues/2","number":2,"state":"open","locked":false,"title":"Removing own interfaces from the list of nodes","user":{"login":"sorenmat","id":335103,"avatar_url":"https://avatars.githubusercontent.com/u/335103?v=3","gravatar_id":"","url":"https://api.github.com/users/sorenmat","html_url":"https://github.com/sorenmat","followers_url":"https://api.github.com/users/sorenmat/followers","following_url":"https://api.github.com/users/sorenmat/following{/other_user}","gists_url":"https://api.github.com/users/sorenmat/gists{/gist_id}","starred_url":"https://api.github.com/users/sorenmat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sorenmat/subscriptions","organizations_url":"https://api.github.com/users/sorenmat/orgs","repos_url":"https://api.github.com/users/sorenmat/repos","events_url":"https://api.github.com/users/sorenmat/events{/privacy}","received_events_url":"https://api.github.com/users/sorenmat/received_events","type":"User","site_admin":false},"body":"This is done to avoid trying to connect to your self\r\nwhen joining a cluster","created_at":"2015-11-05T08:51:20Z","updated_at":"2015-11-05T08:56:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"266d814cc85c011ab3b1cdef0b0fd3dfe9781e19","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/pulls/2/commits","review_comments_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/pulls/2/comments","review_comment_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/issues/2/comments","statuses_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/statuses/d1804716be3a388cbae2ff937cd91cda410b7716","head":{"label":"Tradeshift:resolv_clean","ref":"resolv_clean","sha":"d1804716be3a388cbae2ff937cd91cda410b7716","user":{"login":"Tradeshift","id":432092,"avatar_url":"https://avatars.githubusercontent.com/u/432092?v=3","gravatar_id":"","url":"https://api.github.com/users/Tradeshift","html_url":"https://github.com/Tradeshift","followers_url":"https://api.github.com/users/Tradeshift/followers","following_url":"https://api.github.com/users/Tradeshift/following{/other_user}","gists_url":"https://api.github.com/users/Tradeshift/gists{/gist_id}","starred_url":"https://api.github.com/users/Tradeshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tradeshift/subscriptions","organizations_url":"https://api.github.com/users/Tradeshift/orgs","repos_url":"https://api.github.com/users/Tradeshift/repos","events_url":"https://api.github.com/users/Tradeshift/events{/privacy}","received_events_url":"https://api.github.com/users/Tradeshift/received_events","type":"Organization","site_admin":false},"repo":{"id":42960903,"name":"elasticsearch-srv-discovery","full_name":"Tradeshift/elasticsearch-srv-discovery","owner":{"login":"Tradeshift","id":432092,"avatar_url":"https://avatars.githubusercontent.com/u/432092?v=3","gravatar_id":"","url":"https://api.github.com/users/Tradeshift","html_url":"https://github.com/Tradeshift","followers_url":"https://api.github.com/users/Tradeshift/followers","following_url":"https://api.github.com/users/Tradeshift/following{/other_user}","gists_url":"https://api.github.com/users/Tradeshift/gists{/gist_id}","starred_url":"https://api.github.com/users/Tradeshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tradeshift/subscriptions","organizations_url":"https://api.github.com/users/Tradeshift/orgs","repos_url":"https://api.github.com/users/Tradeshift/repos","events_url":"https://api.github.com/users/Tradeshift/events{/privacy}","received_events_url":"https://api.github.com/users/Tradeshift/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Tradeshift/elasticsearch-srv-discovery","description":"Elasticsearch discovery with SRV records","fork":true,"url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery","forks_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/forks","keys_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/teams","hooks_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/hooks","issue_events_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/issues/events{/number}","events_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/events","assignees_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/assignees{/user}","branches_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/branches{/branch}","tags_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/tags","blobs_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/git/refs{/sha}","trees_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/statuses/{sha}","languages_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/languages","stargazers_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/stargazers","contributors_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/contributors","subscribers_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/subscribers","subscription_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/subscription","commits_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/commits{/sha}","git_commits_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/git/commits{/sha}","comments_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/comments{/number}","issue_comment_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/issues/comments{/number}","contents_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/contents/{+path}","compare_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/merges","archive_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/downloads","issues_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/issues{/number}","pulls_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/pulls{/number}","milestones_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/milestones{/number}","notifications_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/labels{/name}","releases_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/releases{/id}","created_at":"2015-09-22T21:08:26Z","updated_at":"2015-09-22T21:08:27Z","pushed_at":"2015-11-05T08:51:20Z","git_url":"git://github.com/Tradeshift/elasticsearch-srv-discovery.git","ssh_url":"git@github.com:Tradeshift/elasticsearch-srv-discovery.git","clone_url":"https://github.com/Tradeshift/elasticsearch-srv-discovery.git","svn_url":"https://github.com/Tradeshift/elasticsearch-srv-discovery","homepage":null,"size":164,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"Tradeshift:master","ref":"master","sha":"7e76e722aeca09d014ef184364f06ab009605e5d","user":{"login":"Tradeshift","id":432092,"avatar_url":"https://avatars.githubusercontent.com/u/432092?v=3","gravatar_id":"","url":"https://api.github.com/users/Tradeshift","html_url":"https://github.com/Tradeshift","followers_url":"https://api.github.com/users/Tradeshift/followers","following_url":"https://api.github.com/users/Tradeshift/following{/other_user}","gists_url":"https://api.github.com/users/Tradeshift/gists{/gist_id}","starred_url":"https://api.github.com/users/Tradeshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tradeshift/subscriptions","organizations_url":"https://api.github.com/users/Tradeshift/orgs","repos_url":"https://api.github.com/users/Tradeshift/repos","events_url":"https://api.github.com/users/Tradeshift/events{/privacy}","received_events_url":"https://api.github.com/users/Tradeshift/received_events","type":"Organization","site_admin":false},"repo":{"id":42960903,"name":"elasticsearch-srv-discovery","full_name":"Tradeshift/elasticsearch-srv-discovery","owner":{"login":"Tradeshift","id":432092,"avatar_url":"https://avatars.githubusercontent.com/u/432092?v=3","gravatar_id":"","url":"https://api.github.com/users/Tradeshift","html_url":"https://github.com/Tradeshift","followers_url":"https://api.github.com/users/Tradeshift/followers","following_url":"https://api.github.com/users/Tradeshift/following{/other_user}","gists_url":"https://api.github.com/users/Tradeshift/gists{/gist_id}","starred_url":"https://api.github.com/users/Tradeshift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tradeshift/subscriptions","organizations_url":"https://api.github.com/users/Tradeshift/orgs","repos_url":"https://api.github.com/users/Tradeshift/repos","events_url":"https://api.github.com/users/Tradeshift/events{/privacy}","received_events_url":"https://api.github.com/users/Tradeshift/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Tradeshift/elasticsearch-srv-discovery","description":"Elasticsearch discovery with SRV records","fork":true,"url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery","forks_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/forks","keys_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/teams","hooks_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/hooks","issue_events_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/issues/events{/number}","events_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/events","assignees_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/assignees{/user}","branches_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/branches{/branch}","tags_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/tags","blobs_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/git/refs{/sha}","trees_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/statuses/{sha}","languages_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/languages","stargazers_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/stargazers","contributors_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/contributors","subscribers_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/subscribers","subscription_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/subscription","commits_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/commits{/sha}","git_commits_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/git/commits{/sha}","comments_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/comments{/number}","issue_comment_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/issues/comments{/number}","contents_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/contents/{+path}","compare_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/merges","archive_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/downloads","issues_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/issues{/number}","pulls_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/pulls{/number}","milestones_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/milestones{/number}","notifications_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/labels{/name}","releases_url":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/releases{/id}","created_at":"2015-09-22T21:08:26Z","updated_at":"2015-09-22T21:08:27Z","pushed_at":"2015-11-05T08:51:20Z","git_url":"git://github.com/Tradeshift/elasticsearch-srv-discovery.git","ssh_url":"git@github.com:Tradeshift/elasticsearch-srv-discovery.git","clone_url":"https://github.com/Tradeshift/elasticsearch-srv-discovery.git","svn_url":"https://github.com/Tradeshift/elasticsearch-srv-discovery","homepage":null,"size":164,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/pulls/2"},"html":{"href":"https://github.com/Tradeshift/elasticsearch-srv-discovery/pull/2"},"issue":{"href":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/issues/2"},"comments":{"href":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/Tradeshift/elasticsearch-srv-discovery/statuses/d1804716be3a388cbae2ff937cd91cda410b7716"}}}}