{"action":"created","comment":{"url":"https://api.github.com/repos/weaveworks/weave/pulls/comments/28340254","id":28340254,"diff_hunk":"@@ -0,0 +1,99 @@\n+package nameserver\n+\n+import (\n+\t\"bytes\"\n+\t\"fmt\"\n+\t. \"github.com/weaveworks/weave/common\"\n+\t\"net\"\n+)\n+\n+// A zone record\n+// Note: we will try to keep all the zone records information is concentrated here. Maybe not all queries will\n+//       use things like priorities or weights, but we do not want to create a hierarchy for dealing with all\n+//       possible queries...\n+type ZoneRecord interface {\n+\tName() string  // The name for this IP\n+\tIP() net.IP    // The IP (v4) address\n+\tPriority() int // The priority\n+\tWeight() int   // The weight\n+}\n+\n+type ZoneLookup interface {\n+\t// Lookup for a name\n+\tLookupName(name string) ([]ZoneRecord, error)\n+\t// Lookup for an address\n+\tLookupInaddr(inaddr string) ([]ZoneRecord, error)\n+}\n+\n+type ZoneObserver interface {\n+\t// Observe anything that affects a particular name in the zone\n+\tObserveName(name string, observer ZoneRecordObserver) error\n+\t// Observe anything that affects a particular IP in the zone\n+\tObserveInaddr(inaddr string, observer ZoneRecordObserver) error\n+}\n+\n+type ZoneRecordObserver func(ZoneRecord)\n+\n+/////////////////////////////////////////////////////////////\n+\n+// A basic record struct (satisfying the ZoneRecord interface)\n+type Record struct {\n+\tname     string\n+\tip       net.IP\n+\tpriority int\n+\tweight   int\n+}\n+\n+func (r Record) Name() string  { return r.name }\n+func (r Record) IP() net.IP    { return r.ip }\n+func (r Record) Priority() int { return r.priority }\n+func (r Record) Weight() int   { return r.weight }\n+\n+func (i Record) String() string {\n+\tvar buf bytes.Buffer\n+\tif len(i.Name()) > 0 {\n+\t\tbuf.WriteString(fmt.Sprintf(\"%s\", i.Name()))\n+\t}\n+\tif !i.IP().IsUnspecified() {\n+\t\tbuf.WriteString(fmt.Sprintf(\"[%s]\", i.IP()))\n+\t}\n+\tif i.Priority() > 0 {\n+\t\tbuf.WriteString(fmt.Sprintf(\"/P:%d\", i.Priority()))\n+\t}\n+\tif i.Weight() > 0 {\n+\t\tbuf.WriteString(fmt.Sprintf(\"/W:%d\", i.Weight()))\n+\t}\n+\n+\treturn buf.String()\n+}\n+\n+/////////////////////////////////////////////////////////////\n+\n+// simple IPv4 type that can be used as a key in a map (in contrast with net.IP), used for sets of IPs, etc...","path":"nameserver/addrs.go","position":72,"original_position":72,"commit_id":"7fbef10c186e1672533dbeea94c79d7adb42bc17","original_commit_id":"7fbef10c186e1672533dbeea94c79d7adb42bc17","user":{"login":"inercia","id":1841612,"avatar_url":"https://avatars.githubusercontent.com/u/1841612?v=3","gravatar_id":"","url":"https://api.github.com/users/inercia","html_url":"https://github.com/inercia","followers_url":"https://api.github.com/users/inercia/followers","following_url":"https://api.github.com/users/inercia/following{/other_user}","gists_url":"https://api.github.com/users/inercia/gists{/gist_id}","starred_url":"https://api.github.com/users/inercia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inercia/subscriptions","organizations_url":"https://api.github.com/users/inercia/orgs","repos_url":"https://api.github.com/users/inercia/repos","events_url":"https://api.github.com/users/inercia/events{/privacy}","received_events_url":"https://api.github.com/users/inercia/received_events","type":"User","site_admin":false},"body":"This type, `IPv4`, will not be really used until I introduce the new `ZoneDb` internal database format...","created_at":"2015-04-14T15:53:32Z","updated_at":"2015-04-14T15:53:32Z","html_url":"https://github.com/weaveworks/weave/pull/559#discussion_r28340254","pull_request_url":"https://api.github.com/repos/weaveworks/weave/pulls/559","_links":{"self":{"href":"https://api.github.com/repos/weaveworks/weave/pulls/comments/28340254"},"html":{"href":"https://github.com/weaveworks/weave/pull/559#discussion_r28340254"},"pull_request":{"href":"https://api.github.com/repos/weaveworks/weave/pulls/559"}}},"pull_request":{"url":"https://api.github.com/repos/weaveworks/weave/pulls/559","id":33271498,"html_url":"https://github.com/weaveworks/weave/pull/559","diff_url":"https://github.com/weaveworks/weave/pull/559.diff","patch_url":"https://github.com/weaveworks/weave/pull/559.patch","issue_url":"https://api.github.com/repos/weaveworks/weave/issues/559","number":559,"state":"open","locked":false,"title":"Support for multiple responses in mDNS","user":{"login":"inercia","id":1841612,"avatar_url":"https://avatars.githubusercontent.com/u/1841612?v=3","gravatar_id":"","url":"https://api.github.com/users/inercia","html_url":"https://github.com/inercia","followers_url":"https://api.github.com/users/inercia/followers","following_url":"https://api.github.com/users/inercia/following{/other_user}","gists_url":"https://api.github.com/users/inercia/gists{/gist_id}","starred_url":"https://api.github.com/users/inercia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inercia/subscriptions","organizations_url":"https://api.github.com/users/inercia/orgs","repos_url":"https://api.github.com/users/inercia/repos","events_url":"https://api.github.com/users/inercia/events{/privacy}","received_events_url":"https://api.github.com/users/inercia/received_events","type":"User","site_admin":false},"body":"This pull request is the stepping stone for full support of multiple responses in WeaveDNS. It focuses in the mDNS client and server, where it provides\r\n\r\n* support for \"insistent\" `Lookups` (maybe not the best name): mDNS queries that try to obtain as many responses as possible for up to 500ms.\r\n* support for multiple responses from `Lookup*()` methods\r\n* a common `ZoneRecord` interface for many structs that contain names and IPs (used in `Lookup` methods, but also in the future database records)\r\n* support for multiple records when building packets with `make*()` methods\r\n* improved unit tests for mDNS\r\n\r\n","created_at":"2015-04-14T15:51:51Z","updated_at":"2015-04-14T15:53:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e086cdb34050fade8df2ea36ad0269d733bdc7b3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/weaveworks/weave/pulls/559/commits","review_comments_url":"https://api.github.com/repos/weaveworks/weave/pulls/559/comments","review_comment_url":"https://api.github.com/repos/weaveworks/weave/pulls/comments{/number}","comments_url":"https://api.github.com/repos/weaveworks/weave/issues/559/comments","statuses_url":"https://api.github.com/repos/weaveworks/weave/statuses/7fbef10c186e1672533dbeea94c79d7adb42bc17","head":{"label":"inercia:weave-338","ref":"weave-338","sha":"7fbef10c186e1672533dbeea94c79d7adb42bc17","user":{"login":"inercia","id":1841612,"avatar_url":"https://avatars.githubusercontent.com/u/1841612?v=3","gravatar_id":"","url":"https://api.github.com/users/inercia","html_url":"https://github.com/inercia","followers_url":"https://api.github.com/users/inercia/followers","following_url":"https://api.github.com/users/inercia/following{/other_user}","gists_url":"https://api.github.com/users/inercia/gists{/gist_id}","starred_url":"https://api.github.com/users/inercia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inercia/subscriptions","organizations_url":"https://api.github.com/users/inercia/orgs","repos_url":"https://api.github.com/users/inercia/repos","events_url":"https://api.github.com/users/inercia/events{/privacy}","received_events_url":"https://api.github.com/users/inercia/received_events","type":"User","site_admin":false},"repo":{"id":26750752,"name":"weave","full_name":"inercia/weave","owner":{"login":"inercia","id":1841612,"avatar_url":"https://avatars.githubusercontent.com/u/1841612?v=3","gravatar_id":"","url":"https://api.github.com/users/inercia","html_url":"https://github.com/inercia","followers_url":"https://api.github.com/users/inercia/followers","following_url":"https://api.github.com/users/inercia/following{/other_user}","gists_url":"https://api.github.com/users/inercia/gists{/gist_id}","starred_url":"https://api.github.com/users/inercia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inercia/subscriptions","organizations_url":"https://api.github.com/users/inercia/orgs","repos_url":"https://api.github.com/users/inercia/repos","events_url":"https://api.github.com/users/inercia/events{/privacy}","received_events_url":"https://api.github.com/users/inercia/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/inercia/weave","description":"The Docker Network","fork":true,"url":"https://api.github.com/repos/inercia/weave","forks_url":"https://api.github.com/repos/inercia/weave/forks","keys_url":"https://api.github.com/repos/inercia/weave/keys{/key_id}","collaborators_url":"https://api.github.com/repos/inercia/weave/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/inercia/weave/teams","hooks_url":"https://api.github.com/repos/inercia/weave/hooks","issue_events_url":"https://api.github.com/repos/inercia/weave/issues/events{/number}","events_url":"https://api.github.com/repos/inercia/weave/events","assignees_url":"https://api.github.com/repos/inercia/weave/assignees{/user}","branches_url":"https://api.github.com/repos/inercia/weave/branches{/branch}","tags_url":"https://api.github.com/repos/inercia/weave/tags","blobs_url":"https://api.github.com/repos/inercia/weave/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/inercia/weave/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/inercia/weave/git/refs{/sha}","trees_url":"https://api.github.com/repos/inercia/weave/git/trees{/sha}","statuses_url":"https://api.github.com/repos/inercia/weave/statuses/{sha}","languages_url":"https://api.github.com/repos/inercia/weave/languages","stargazers_url":"https://api.github.com/repos/inercia/weave/stargazers","contributors_url":"https://api.github.com/repos/inercia/weave/contributors","subscribers_url":"https://api.github.com/repos/inercia/weave/subscribers","subscription_url":"https://api.github.com/repos/inercia/weave/subscription","commits_url":"https://api.github.com/repos/inercia/weave/commits{/sha}","git_commits_url":"https://api.github.com/repos/inercia/weave/git/commits{/sha}","comments_url":"https://api.github.com/repos/inercia/weave/comments{/number}","issue_comment_url":"https://api.github.com/repos/inercia/weave/issues/comments{/number}","contents_url":"https://api.github.com/repos/inercia/weave/contents/{+path}","compare_url":"https://api.github.com/repos/inercia/weave/compare/{base}...{head}","merges_url":"https://api.github.com/repos/inercia/weave/merges","archive_url":"https://api.github.com/repos/inercia/weave/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/inercia/weave/downloads","issues_url":"https://api.github.com/repos/inercia/weave/issues{/number}","pulls_url":"https://api.github.com/repos/inercia/weave/pulls{/number}","milestones_url":"https://api.github.com/repos/inercia/weave/milestones{/number}","notifications_url":"https://api.github.com/repos/inercia/weave/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/inercia/weave/labels{/name}","releases_url":"https://api.github.com/repos/inercia/weave/releases{/id}","created_at":"2014-11-17T10:00:09Z","updated_at":"2015-03-25T11:29:04Z","pushed_at":"2015-04-14T15:43:27Z","git_url":"git://github.com/inercia/weave.git","ssh_url":"git@github.com:inercia/weave.git","clone_url":"https://github.com/inercia/weave.git","svn_url":"https://github.com/inercia/weave","homepage":"","size":2266,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"weaveworks:master","ref":"master","sha":"973996184d34ece5ee9dc40427d3f9fe9e224c57","user":{"login":"weaveworks","id":9976052,"avatar_url":"https://avatars.githubusercontent.com/u/9976052?v=3","gravatar_id":"","url":"https://api.github.com/users/weaveworks","html_url":"https://github.com/weaveworks","followers_url":"https://api.github.com/users/weaveworks/followers","following_url":"https://api.github.com/users/weaveworks/following{/other_user}","gists_url":"https://api.github.com/users/weaveworks/gists{/gist_id}","starred_url":"https://api.github.com/users/weaveworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weaveworks/subscriptions","organizations_url":"https://api.github.com/users/weaveworks/orgs","repos_url":"https://api.github.com/users/weaveworks/repos","events_url":"https://api.github.com/users/weaveworks/events{/privacy}","received_events_url":"https://api.github.com/users/weaveworks/received_events","type":"Organization","site_admin":false},"repo":{"id":23059575,"name":"weave","full_name":"weaveworks/weave","owner":{"login":"weaveworks","id":9976052,"avatar_url":"https://avatars.githubusercontent.com/u/9976052?v=3","gravatar_id":"","url":"https://api.github.com/users/weaveworks","html_url":"https://github.com/weaveworks","followers_url":"https://api.github.com/users/weaveworks/followers","following_url":"https://api.github.com/users/weaveworks/following{/other_user}","gists_url":"https://api.github.com/users/weaveworks/gists{/gist_id}","starred_url":"https://api.github.com/users/weaveworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weaveworks/subscriptions","organizations_url":"https://api.github.com/users/weaveworks/orgs","repos_url":"https://api.github.com/users/weaveworks/repos","events_url":"https://api.github.com/users/weaveworks/events{/privacy}","received_events_url":"https://api.github.com/users/weaveworks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/weaveworks/weave","description":"The Docker Network","fork":false,"url":"https://api.github.com/repos/weaveworks/weave","forks_url":"https://api.github.com/repos/weaveworks/weave/forks","keys_url":"https://api.github.com/repos/weaveworks/weave/keys{/key_id}","collaborators_url":"https://api.github.com/repos/weaveworks/weave/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/weaveworks/weave/teams","hooks_url":"https://api.github.com/repos/weaveworks/weave/hooks","issue_events_url":"https://api.github.com/repos/weaveworks/weave/issues/events{/number}","events_url":"https://api.github.com/repos/weaveworks/weave/events","assignees_url":"https://api.github.com/repos/weaveworks/weave/assignees{/user}","branches_url":"https://api.github.com/repos/weaveworks/weave/branches{/branch}","tags_url":"https://api.github.com/repos/weaveworks/weave/tags","blobs_url":"https://api.github.com/repos/weaveworks/weave/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/weaveworks/weave/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/weaveworks/weave/git/refs{/sha}","trees_url":"https://api.github.com/repos/weaveworks/weave/git/trees{/sha}","statuses_url":"https://api.github.com/repos/weaveworks/weave/statuses/{sha}","languages_url":"https://api.github.com/repos/weaveworks/weave/languages","stargazers_url":"https://api.github.com/repos/weaveworks/weave/stargazers","contributors_url":"https://api.github.com/repos/weaveworks/weave/contributors","subscribers_url":"https://api.github.com/repos/weaveworks/weave/subscribers","subscription_url":"https://api.github.com/repos/weaveworks/weave/subscription","commits_url":"https://api.github.com/repos/weaveworks/weave/commits{/sha}","git_commits_url":"https://api.github.com/repos/weaveworks/weave/git/commits{/sha}","comments_url":"https://api.github.com/repos/weaveworks/weave/comments{/number}","issue_comment_url":"https://api.github.com/repos/weaveworks/weave/issues/comments{/number}","contents_url":"https://api.github.com/repos/weaveworks/weave/contents/{+path}","compare_url":"https://api.github.com/repos/weaveworks/weave/compare/{base}...{head}","merges_url":"https://api.github.com/repos/weaveworks/weave/merges","archive_url":"https://api.github.com/repos/weaveworks/weave/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/weaveworks/weave/downloads","issues_url":"https://api.github.com/repos/weaveworks/weave/issues{/number}","pulls_url":"https://api.github.com/repos/weaveworks/weave/pulls{/number}","milestones_url":"https://api.github.com/repos/weaveworks/weave/milestones{/number}","notifications_url":"https://api.github.com/repos/weaveworks/weave/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/weaveworks/weave/labels{/name}","releases_url":"https://api.github.com/repos/weaveworks/weave/releases{/id}","created_at":"2014-08-18T05:19:07Z","updated_at":"2015-04-14T12:28:22Z","pushed_at":"2015-04-14T15:51:51Z","git_url":"git://github.com/weaveworks/weave.git","ssh_url":"git@github.com:weaveworks/weave.git","clone_url":"https://github.com/weaveworks/weave.git","svn_url":"https://github.com/weaveworks/weave","homepage":"","size":7777,"stargazers_count":3142,"watchers_count":3142,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":165,"mirror_url":null,"open_issues_count":94,"forks":165,"open_issues":94,"watchers":3142,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/weaveworks/weave/pulls/559"},"html":{"href":"https://github.com/weaveworks/weave/pull/559"},"issue":{"href":"https://api.github.com/repos/weaveworks/weave/issues/559"},"comments":{"href":"https://api.github.com/repos/weaveworks/weave/issues/559/comments"},"review_comments":{"href":"https://api.github.com/repos/weaveworks/weave/pulls/559/comments"},"review_comment":{"href":"https://api.github.com/repos/weaveworks/weave/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/weaveworks/weave/pulls/559/commits"},"statuses":{"href":"https://api.github.com/repos/weaveworks/weave/statuses/7fbef10c186e1672533dbeea94c79d7adb42bc17"}}}}