-
Notifications
You must be signed in to change notification settings - Fork 61
Support for tcp transport #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f374b67
Test: Replace EXTERNAL auth with ANONYMOUS auth.
M-Bab ad6b746
Support network (tcp) connections with the path "tcp:host=[ip],port=[…
M-Bab 9eaa471
Communication must be nonblocking. Must be called after connect, resu…
M-Bab abd9035
Use external authentification in local use cases and anonymous authen…
M-Bab 98a1f5d
Merge branch 'master' of github.com:altdesktop/python-dbus-next
M-Bab 62e1c7c
message_bus.py: Remove whitespaces from empty lines. (lint)
M-Bab d8a85d8
Fix another formatting issue.
M-Bab f743031
Added two tests to verify the functionality of DBus via TCP:
M-Bab 48d8a3c
Fix: getblocking is not available prior python 3.7.
M-Bab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,33 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| # In order for this to work a local tcp connection to the DBus a port | ||
| # must be opened to forward to the dbus socket file. The easiest way | ||
| # to achieve this is using "socat": | ||
| # socat TCP-LISTEN:55556,reuseaddr,fork,range=127.0.0.1/32 UNIX-CONNECT:$(echo $DBUS_SESSION_BUS_ADDRESS | sed 's/unix:path=//g') | ||
| # For actual DBus transport over network the authentication might | ||
| # be a further problem. More information here: | ||
| # https://dbus.freedesktop.org/doc/dbus-specification.html#auth-mechanisms | ||
|
|
||
| import sys | ||
| import os | ||
| sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/..')) | ||
|
|
||
| from dbus_next.aio import MessageBus | ||
|
|
||
| import asyncio | ||
|
|
||
| loop = asyncio.get_event_loop() | ||
|
|
||
|
|
||
| async def main(): | ||
| bus = await MessageBus(bus_address="tcp:host=127.0.0.1,port=55556").connect() | ||
| introspection = await bus.introspect('org.freedesktop.Notifications', | ||
| '/org/freedesktop/Notifications') | ||
| obj = bus.get_proxy_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications', | ||
| introspection) | ||
| notification = obj.get_interface('org.freedesktop.Notifications') | ||
| await notification.call_notify("test.py", 0, "", "DBus Test", "Test notification", [""], dict(), | ||
| 5000) | ||
|
|
||
|
|
||
| loop.run_until_complete(main()) |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you call
connect()to send a message across?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically yes. You can specify the callback function and receive the "AUTH EXTERNAL ..." which can be replied with "OK" but then the system got stock (probably due to a lack of the Hello message).
But thats not ultimately necessary to unit test this function because the proof of a network connection seams good enough for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd really like to see a message sent across the connection and successful auth annonymous. #54 for example will add assumptions that the socket is unix that would break this feature and have these tests still pass.
For an example of how to add dbus configuration to the test suites to listen on a tcp address, see the playerctl dockerfile and test suite which is based on this project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the point and I tried to get it working locally - but it did not work before the weekend ended. Somehow the session.conf line order fragility, systemd and even apparmor joined forces to prevent any feeling of success 😞
Maybe I am also not clever enough or at least not experienced enough in DBus/Docker for this. If you don't want to merge it, it's not a problem either because my company can live with my fork as well. The possibility of a TCP connection is all they needed - I just thought it would be nice to upstream it for other users and to ensure a future for this feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok then this might be a bit more complicated. I can merge it with an issue to create tests if it's a big task. How exactly are you using it? The usage example you gave did some kind of socket forwarding.