{"action":"created","comment":{"url":"https://api.github.com/repos/eclipse/smarthome/pulls/comments/181675480","pull_request_review_id":112329247,"id":181675480,"diff_hunk":"@@ -0,0 +1,209 @@\n+/**\n+ * Copyright (c) 2014,2018 Contributors to the Eclipse Foundation\n+ *\n+ * See the NOTICE file(s) distributed with this work for additional\n+ * information regarding copyright ownership.\n+ *\n+ * This program and the accompanying materials are made available under the\n+ * terms of the Eclipse Public License 2.0 which is available at\n+ * http://www.eclipse.org/legal/epl-2.0\n+ *\n+ * SPDX-License-Identifier: EPL-2.0\n+ */\n+package org.eclipse.smarthome.binding.mqtt.internal.discovery;\n+\n+import java.net.Inet4Address;\n+import java.util.Arrays;\n+import java.util.Collections;\n+import java.util.HashMap;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.concurrent.TimeUnit;\n+import java.util.concurrent.locks.Lock;\n+import java.util.concurrent.locks.ReentrantLock;\n+import java.util.stream.Collectors;\n+\n+import org.apache.commons.net.util.SubnetUtils;\n+import org.eclipse.smarthome.binding.mqtt.MqttBrokerBindingConstants;\n+import org.eclipse.smarthome.binding.mqtt.internal.MqttThingID;\n+import org.eclipse.smarthome.config.discovery.AbstractDiscoveryService;\n+import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder;\n+import org.eclipse.smarthome.config.discovery.DiscoveryService;\n+import org.eclipse.smarthome.core.net.NetUtil;\n+import org.eclipse.smarthome.core.thing.ThingUID;\n+import org.eclipse.smarthome.io.transport.mqtt.MqttBrokerConnection;\n+import org.eclipse.smarthome.io.transport.mqtt.MqttConnectionState;\n+import org.eclipse.smarthome.io.transport.mqtt.MqttException;\n+import org.osgi.service.cm.ConfigurationException;\n+import org.osgi.service.component.annotations.Activate;\n+import org.osgi.service.component.annotations.Component;\n+import org.osgi.service.component.annotations.Deactivate;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+/**\n+ * The {@link NetworkDiscoveryService} is responsible for discovering brokers on\n+ * the current Network. It uses every Network Interface available.\n+ *\n+ * @author David Graeff - Initial contribution\n+ */\n+@Component(immediate = true, service = DiscoveryService.class, configurationPid = \"org.eclipse.smarthome.NetworkDiscoveryService\")","path":"extensions/binding/org.eclipse.smarthome.binding.mqtt/src/main/java/org/eclipse/smarthome/binding/mqtt/internal/discovery/NetworkDiscoveryService.java","position":50,"original_position":50,"commit_id":"1cfa04866a1e868fce0ea064cb6695f3b18d05d7","original_commit_id":"1cfa04866a1e868fce0ea064cb6695f3b18d05d7","user":{"login":"kaikreuzer","id":3244965,"avatar_url":"https://avatars3.githubusercontent.com/u/3244965?v=4","gravatar_id":"","url":"https://api.github.com/users/kaikreuzer","html_url":"https://github.com/kaikreuzer","followers_url":"https://api.github.com/users/kaikreuzer/followers","following_url":"https://api.github.com/users/kaikreuzer/following{/other_user}","gists_url":"https://api.github.com/users/kaikreuzer/gists{/gist_id}","starred_url":"https://api.github.com/users/kaikreuzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaikreuzer/subscriptions","organizations_url":"https://api.github.com/users/kaikreuzer/orgs","repos_url":"https://api.github.com/users/kaikreuzer/repos","events_url":"https://api.github.com/users/kaikreuzer/events{/privacy}","received_events_url":"https://api.github.com/users/kaikreuzer/received_events","type":"User","site_admin":false},"body":"-> pid `discovery.networkmqttbroker`","created_at":"2018-04-16T09:37:53Z","updated_at":"2018-04-16T09:42:40Z","html_url":"https://github.com/eclipse/smarthome/pull/3839#discussion_r181675480","pull_request_url":"https://api.github.com/repos/eclipse/smarthome/pulls/3839","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/comments/181675480"},"html":{"href":"https://github.com/eclipse/smarthome/pull/3839#discussion_r181675480"},"pull_request":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/3839"}}},"pull_request":{"url":"https://api.github.com/repos/eclipse/smarthome/pulls/3839","id":130703871,"html_url":"https://github.com/eclipse/smarthome/pull/3839","diff_url":"https://github.com/eclipse/smarthome/pull/3839.diff","patch_url":"https://github.com/eclipse/smarthome/pull/3839.patch","issue_url":"https://api.github.com/repos/eclipse/smarthome/issues/3839","number":3839,"state":"open","locked":false,"title":"Mqtt Broker configuration binding","user":{"login":"davidgraeff","id":66436,"avatar_url":"https://avatars2.githubusercontent.com/u/66436?v=4","gravatar_id":"","url":"https://api.github.com/users/davidgraeff","html_url":"https://github.com/davidgraeff","followers_url":"https://api.github.com/users/davidgraeff/followers","following_url":"https://api.github.com/users/davidgraeff/following{/other_user}","gists_url":"https://api.github.com/users/davidgraeff/gists{/gist_id}","starred_url":"https://api.github.com/users/davidgraeff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidgraeff/subscriptions","organizations_url":"https://api.github.com/users/davidgraeff/orgs","repos_url":"https://api.github.com/users/davidgraeff/repos","events_url":"https://api.github.com/users/davidgraeff/events{/privacy}","received_events_url":"https://api.github.com/users/davidgraeff/received_events","type":"User","site_admin":false},"body":"## Abstract\r\nAt the moment it is possible to configure brokers in a textual way. Without intensively watching the log file, there is no way to tell if the provided configuration is correct and if the connection to the broker have been established, neither via the GUI (PaperUI) nor machine readable (REST interface).\r\n\r\nThis binding makes the configuration of brokers more intuitive and let the user add broker connections as things. The connections are synced to the `io.transport.mqtt.MqttService` and are therefore available for all other bindings to use.\r\n\r\nFeatures include: \r\n* **2 different Bridges**: SystemBrokerConnection, BrokerConnection \r\n* **Rich status feedback** for system broker connections. No longer skimming through log files if a connection doesn't work. \r\n* **Auto discovery of brokers**: Enumeration of MqttService shared broker connections, best effort subnet and localhost scan on standard Mqtt ports\r\n* **Configurable reconnect time**: This is not possible via textual configuration yet\r\n* **Security** Certificate and public key pinning for ssl connections to brokers \r\n* **Extensive tests** for all handlers, the discovery services and the SSLContextProvider.\r\n\r\n## Discussion\r\n\r\nPoints that need to be discussed might be:\r\n* **No channels** There are no channels on the broker Things. Everything is published to Thing properties right now. The connection status could be made available via a \"status channel\" additionally.\r\n* **Security** The public key and certificate hashes for key and certificate pinning are stored in the thing configuration. I'm not sure if this is the safest places to store them as the configuration can be changed via the rest interface. It is at least the only way to let the user configure them easily at the moment.\r\n\r\nI'm happy to hear some feedback.\r\n\r\nCheers,\r\nDavid","created_at":"2017-07-15T05:05:58Z","updated_at":"2018-04-16T09:42:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e75000643526970e39a18fe5e3c892897843741b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/eclipse/smarthome/pulls/3839/commits","review_comments_url":"https://api.github.com/repos/eclipse/smarthome/pulls/3839/comments","review_comment_url":"https://api.github.com/repos/eclipse/smarthome/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eclipse/smarthome/issues/3839/comments","statuses_url":"https://api.github.com/repos/eclipse/smarthome/statuses/1cfa04866a1e868fce0ea064cb6695f3b18d05d7","head":{"label":"davidgraeff:mqtt_binding","ref":"mqtt_binding","sha":"1cfa04866a1e868fce0ea064cb6695f3b18d05d7","user":{"login":"davidgraeff","id":66436,"avatar_url":"https://avatars2.githubusercontent.com/u/66436?v=4","gravatar_id":"","url":"https://api.github.com/users/davidgraeff","html_url":"https://github.com/davidgraeff","followers_url":"https://api.github.com/users/davidgraeff/followers","following_url":"https://api.github.com/users/davidgraeff/following{/other_user}","gists_url":"https://api.github.com/users/davidgraeff/gists{/gist_id}","starred_url":"https://api.github.com/users/davidgraeff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidgraeff/subscriptions","organizations_url":"https://api.github.com/users/davidgraeff/orgs","repos_url":"https://api.github.com/users/davidgraeff/repos","events_url":"https://api.github.com/users/davidgraeff/events{/privacy}","received_events_url":"https://api.github.com/users/davidgraeff/received_events","type":"User","site_admin":false},"repo":{"id":94952984,"name":"smarthome","full_name":"davidgraeff/smarthome","owner":{"login":"davidgraeff","id":66436,"avatar_url":"https://avatars2.githubusercontent.com/u/66436?v=4","gravatar_id":"","url":"https://api.github.com/users/davidgraeff","html_url":"https://github.com/davidgraeff","followers_url":"https://api.github.com/users/davidgraeff/followers","following_url":"https://api.github.com/users/davidgraeff/following{/other_user}","gists_url":"https://api.github.com/users/davidgraeff/gists{/gist_id}","starred_url":"https://api.github.com/users/davidgraeff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidgraeff/subscriptions","organizations_url":"https://api.github.com/users/davidgraeff/orgs","repos_url":"https://api.github.com/users/davidgraeff/repos","events_url":"https://api.github.com/users/davidgraeff/events{/privacy}","received_events_url":"https://api.github.com/users/davidgraeff/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/davidgraeff/smarthome","description":"Eclipse SmartHome™ project","fork":true,"url":"https://api.github.com/repos/davidgraeff/smarthome","forks_url":"https://api.github.com/repos/davidgraeff/smarthome/forks","keys_url":"https://api.github.com/repos/davidgraeff/smarthome/keys{/key_id}","collaborators_url":"https://api.github.com/repos/davidgraeff/smarthome/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/davidgraeff/smarthome/teams","hooks_url":"https://api.github.com/repos/davidgraeff/smarthome/hooks","issue_events_url":"https://api.github.com/repos/davidgraeff/smarthome/issues/events{/number}","events_url":"https://api.github.com/repos/davidgraeff/smarthome/events","assignees_url":"https://api.github.com/repos/davidgraeff/smarthome/assignees{/user}","branches_url":"https://api.github.com/repos/davidgraeff/smarthome/branches{/branch}","tags_url":"https://api.github.com/repos/davidgraeff/smarthome/tags","blobs_url":"https://api.github.com/repos/davidgraeff/smarthome/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/davidgraeff/smarthome/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/davidgraeff/smarthome/git/refs{/sha}","trees_url":"https://api.github.com/repos/davidgraeff/smarthome/git/trees{/sha}","statuses_url":"https://api.github.com/repos/davidgraeff/smarthome/statuses/{sha}","languages_url":"https://api.github.com/repos/davidgraeff/smarthome/languages","stargazers_url":"https://api.github.com/repos/davidgraeff/smarthome/stargazers","contributors_url":"https://api.github.com/repos/davidgraeff/smarthome/contributors","subscribers_url":"https://api.github.com/repos/davidgraeff/smarthome/subscribers","subscription_url":"https://api.github.com/repos/davidgraeff/smarthome/subscription","commits_url":"https://api.github.com/repos/davidgraeff/smarthome/commits{/sha}","git_commits_url":"https://api.github.com/repos/davidgraeff/smarthome/git/commits{/sha}","comments_url":"https://api.github.com/repos/davidgraeff/smarthome/comments{/number}","issue_comment_url":"https://api.github.com/repos/davidgraeff/smarthome/issues/comments{/number}","contents_url":"https://api.github.com/repos/davidgraeff/smarthome/contents/{+path}","compare_url":"https://api.github.com/repos/davidgraeff/smarthome/compare/{base}...{head}","merges_url":"https://api.github.com/repos/davidgraeff/smarthome/merges","archive_url":"https://api.github.com/repos/davidgraeff/smarthome/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/davidgraeff/smarthome/downloads","issues_url":"https://api.github.com/repos/davidgraeff/smarthome/issues{/number}","pulls_url":"https://api.github.com/repos/davidgraeff/smarthome/pulls{/number}","milestones_url":"https://api.github.com/repos/davidgraeff/smarthome/milestones{/number}","notifications_url":"https://api.github.com/repos/davidgraeff/smarthome/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/davidgraeff/smarthome/labels{/name}","releases_url":"https://api.github.com/repos/davidgraeff/smarthome/releases{/id}","deployments_url":"https://api.github.com/repos/davidgraeff/smarthome/deployments","created_at":"2017-06-21T02:07:59Z","updated_at":"2018-04-12T07:56:29Z","pushed_at":"2018-04-12T09:12:41Z","git_url":"git://github.com/davidgraeff/smarthome.git","ssh_url":"git@github.com:davidgraeff/smarthome.git","clone_url":"https://github.com/davidgraeff/smarthome.git","svn_url":"https://github.com/davidgraeff/smarthome","homepage":"https://www.eclipse.org/smarthome/","size":49635,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"epl-2.0","name":"Eclipse Public License 2.0","spdx_id":"EPL-2.0","url":"https://api.github.com/licenses/epl-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"eclipse:master","ref":"master","sha":"a963da88bb3835c2aa88ac399fe254f71120a3bc","user":{"login":"eclipse","id":56974,"avatar_url":"https://avatars1.githubusercontent.com/u/56974?v=4","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"repo":{"id":15778981,"name":"smarthome","full_name":"eclipse/smarthome","owner":{"login":"eclipse","id":56974,"avatar_url":"https://avatars1.githubusercontent.com/u/56974?v=4","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eclipse/smarthome","description":"Eclipse SmartHome™ project","fork":false,"url":"https://api.github.com/repos/eclipse/smarthome","forks_url":"https://api.github.com/repos/eclipse/smarthome/forks","keys_url":"https://api.github.com/repos/eclipse/smarthome/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eclipse/smarthome/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eclipse/smarthome/teams","hooks_url":"https://api.github.com/repos/eclipse/smarthome/hooks","issue_events_url":"https://api.github.com/repos/eclipse/smarthome/issues/events{/number}","events_url":"https://api.github.com/repos/eclipse/smarthome/events","assignees_url":"https://api.github.com/repos/eclipse/smarthome/assignees{/user}","branches_url":"https://api.github.com/repos/eclipse/smarthome/branches{/branch}","tags_url":"https://api.github.com/repos/eclipse/smarthome/tags","blobs_url":"https://api.github.com/repos/eclipse/smarthome/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eclipse/smarthome/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eclipse/smarthome/git/refs{/sha}","trees_url":"https://api.github.com/repos/eclipse/smarthome/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eclipse/smarthome/statuses/{sha}","languages_url":"https://api.github.com/repos/eclipse/smarthome/languages","stargazers_url":"https://api.github.com/repos/eclipse/smarthome/stargazers","contributors_url":"https://api.github.com/repos/eclipse/smarthome/contributors","subscribers_url":"https://api.github.com/repos/eclipse/smarthome/subscribers","subscription_url":"https://api.github.com/repos/eclipse/smarthome/subscription","commits_url":"https://api.github.com/repos/eclipse/smarthome/commits{/sha}","git_commits_url":"https://api.github.com/repos/eclipse/smarthome/git/commits{/sha}","comments_url":"https://api.github.com/repos/eclipse/smarthome/comments{/number}","issue_comment_url":"https://api.github.com/repos/eclipse/smarthome/issues/comments{/number}","contents_url":"https://api.github.com/repos/eclipse/smarthome/contents/{+path}","compare_url":"https://api.github.com/repos/eclipse/smarthome/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eclipse/smarthome/merges","archive_url":"https://api.github.com/repos/eclipse/smarthome/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eclipse/smarthome/downloads","issues_url":"https://api.github.com/repos/eclipse/smarthome/issues{/number}","pulls_url":"https://api.github.com/repos/eclipse/smarthome/pulls{/number}","milestones_url":"https://api.github.com/repos/eclipse/smarthome/milestones{/number}","notifications_url":"https://api.github.com/repos/eclipse/smarthome/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eclipse/smarthome/labels{/name}","releases_url":"https://api.github.com/repos/eclipse/smarthome/releases{/id}","deployments_url":"https://api.github.com/repos/eclipse/smarthome/deployments","created_at":"2014-01-09T20:47:19Z","updated_at":"2018-04-16T06:41:34Z","pushed_at":"2018-04-16T07:29:58Z","git_url":"git://github.com/eclipse/smarthome.git","ssh_url":"git@github.com:eclipse/smarthome.git","clone_url":"https://github.com/eclipse/smarthome.git","svn_url":"https://github.com/eclipse/smarthome","homepage":"https://www.eclipse.org/smarthome/","size":51596,"stargazers_count":684,"watchers_count":684,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":657,"mirror_url":null,"archived":false,"open_issues_count":420,"license":{"key":"epl-2.0","name":"Eclipse Public License 2.0","spdx_id":"EPL-2.0","url":"https://api.github.com/licenses/epl-2.0"},"forks":657,"open_issues":420,"watchers":684,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/3839"},"html":{"href":"https://github.com/eclipse/smarthome/pull/3839"},"issue":{"href":"https://api.github.com/repos/eclipse/smarthome/issues/3839"},"comments":{"href":"https://api.github.com/repos/eclipse/smarthome/issues/3839/comments"},"review_comments":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/3839/comments"},"review_comment":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/3839/commits"},"statuses":{"href":"https://api.github.com/repos/eclipse/smarthome/statuses/1cfa04866a1e868fce0ea064cb6695f3b18d05d7"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"kaikreuzer"}}