-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46f90a5
commit 9d81b1f
Showing
9 changed files
with
135 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import logging | ||
import asyncio | ||
import os | ||
from hbmqtt.broker import Broker | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
config = { | ||
'listeners': { | ||
'default': { | ||
'type': 'tcp', | ||
'bind': '0.0.0.0:1883', | ||
}, | ||
'ws-mqtt': { | ||
'bind': '127.0.0.1:8080', | ||
'type': 'ws', | ||
'max_connections': 10, | ||
}, | ||
}, | ||
'sys_interval': 10, | ||
'auth': { | ||
'allow-anonymous': True, | ||
'password-file': os.path.join(os.path.dirname(os.path.realpath(__file__)), "passwd"), | ||
'plugins': [ | ||
'auth_file', 'auth_anonymous' | ||
] | ||
|
||
}, | ||
'topic-check': { | ||
'enabled': True, | ||
'plugins': [ | ||
'topic_acl' | ||
], | ||
'acl': { | ||
'test': ['repositories/+/master', 'calendar/#', 'data/memes'], | ||
'anonymous': [] | ||
} | ||
} | ||
} | ||
|
||
broker = Broker(config) | ||
|
||
|
||
@asyncio.coroutine | ||
def test_coro(): | ||
yield from broker.start() | ||
|
||
|
||
if __name__ == '__main__': | ||
formatter = "[%(asctime)s] :: %(levelname)s :: %(name)s :: %(message)s" | ||
logging.basicConfig(level=logging.INFO, format=formatter) | ||
asyncio.get_event_loop().run_until_complete(test_coro()) | ||
asyncio.get_event_loop().run_forever() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,9 @@ | |
'plugins': [ | ||
'auth_file', 'auth_anonymous' | ||
] | ||
|
||
}, | ||
'topic-check': { | ||
'enabled': False | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,11 +17,15 @@ | |
@asyncio.coroutine | ||
def uptime_coro(): | ||
C = MQTTClient() | ||
yield from C.connect('mqtt://test:[email protected]:1883') | ||
# yield from C.connect('mqtt://test:[email protected]:1883') | ||
yield from C.connect('mqtt://0.0.0.0:1883') | ||
# Subscribe to '$SYS/broker/uptime' with QOS=1 | ||
yield from C.subscribe([ | ||
('data/memes', QOS_1), # Topic allowed | ||
('data/classified', QOS_1), # Topic forbidden | ||
('repositories/hbmqtt/master', QOS_1), # Topic allowed | ||
('repositories/hbmqtt/devel', QOS_1), # Topic forbidden | ||
('calendar/hbmqtt/releases', QOS_1), # Topic allowed | ||
]) | ||
logger.info("Subscribed") | ||
try: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,9 @@ | |
'plugins': [ | ||
'auth_file', 'auth_anonymous' | ||
] | ||
}, | ||
'topic-check': { | ||
'enabled': False | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,6 @@ auth: | |
allow-anonymous: true | ||
plugins: | ||
- auth_file | ||
- auth_anonymous | ||
- auth_anonymous | ||
topic-check: | ||
enabled: False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters