Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
SteamOS Devkit Service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
devkit
SteamOS Devkit Service
Commits
58ad7677
Commit
58ad7677
authored
1 year ago
by
Timothee Besset
Browse files
Options
Downloads
Patches
Plain Diff
WIP migrating from avahi to systemd-resolved RegisterService
parent
1459a046
Branches
ttimo/systemd-resolved
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/steamos-devkit-service.py
+40
-20
40 additions, 20 deletions
src/steamos-devkit-service.py
with
40 additions
and
20 deletions
src/steamos-devkit-service.py
+
40
−
20
View file @
58ad7677
...
@@ -36,7 +36,6 @@ import urllib.parse
...
@@ -36,7 +36,6 @@ import urllib.parse
import
argparse
import
argparse
import
dbus
import
dbus
import
avahi
SERVICE_PORT
=
32000
SERVICE_PORT
=
32000
PACKAGE
=
"
steamos-devkit-service
"
PACKAGE
=
"
steamos-devkit-service
"
...
@@ -306,10 +305,9 @@ class DevkitService:
...
@@ -306,10 +305,9 @@ class DevkitService:
self
.
port
=
SERVICE_PORT
self
.
port
=
SERVICE_PORT
self
.
name
=
get_machine_name
()
self
.
name
=
get_machine_name
()
self
.
host
=
""
self
.
domain
=
""
self
.
stype
=
"
_steamos-devkit._tcp
"
self
.
stype
=
"
_steamos-devkit._tcp
"
self
.
text
=
""
self
.
text
=
""
# FIXME: Avahi remnant, add UnregisterService though
self
.
group
=
None
self
.
group
=
None
config
=
configparser
.
ConfigParser
()
config
=
configparser
.
ConfigParser
()
...
@@ -361,30 +359,52 @@ class DevkitService:
...
@@ -361,30 +359,52 @@ class DevkitService:
self
.
httpd
.
server_activate
()
self
.
httpd
.
server_activate
()
def
publish
(
self
):
def
publish
(
self
):
"""
Publish ourselves on
avahi mdns system
as an available devkit device.
"""
Publish ourselves on
mdns
as an available devkit device.
"""
"""
bus
=
dbus
.
SystemBus
()
bus
=
dbus
.
SystemBus
()
# https://www.freedesktop.org/software/systemd/man/latest/org.freedesktop.resolve1.html
self
.
text
=
[
f
"
{
CURRENT_TXTVERS
}
"
.
encode
(),
self
.
text
=
[
f
"
{
CURRENT_TXTVERS
}
"
.
encode
(),
f
"
settings=
{
json
.
dumps
(
self
.
settings
)
}
"
.
encode
(),
f
"
settings=
{
json
.
dumps
(
self
.
settings
)
}
"
.
encode
(),
f
"
login=
{
ENTRY_POINT_USER
}
"
.
encode
(),
f
"
login=
{
ENTRY_POINT_USER
}
"
.
encode
(),
f
"
devkit1=
{
ENTRY_POINT
}
"
.
encode
()
f
"
devkit1=
{
ENTRY_POINT
}
"
.
encode
()
]
]
server
=
dbus
.
Interface
(
register
=
bus
.
get_object
(
bus
.
get_object
(
'
org.freedesktop.resolve1
'
,
avahi
.
DBUS_NAME
,
'
/org/freedesktop/resolve1
'
avahi
.
DBUS_PATH_SERVER
),
).
get_dbus_method
(
avahi
.
DBUS_INTERFACE_SERVER
)
'
RegisterService
'
,
'
org.freedesktop.resolve1.Manager
'
avahi_object
=
dbus
.
Interface
(
)
bus
.
get_object
(
avahi
.
DBUS_NAME
,
server
.
EntryGroupNew
()),
# TMP
avahi
.
DBUS_INTERFACE_ENTRY_GROUP
)
print
(
f
'
name:
{
self
.
name
}
, type:
{
self
.
stype
}
, text:
{
self
.
text
}
'
)
avahi_object
.
AddService
(
avahi
.
IF_UNSPEC
,
avahi
.
PROTO_UNSPEC
,
dbus
.
UInt32
(
0
),
self
.
name
,
self
.
stype
,
self
.
domain
,
self
.
host
,
register
(
dbus
.
UInt16
(
int
(
self
.
port
)),
self
.
text
)
# Passing '%H' should amount to the same thing
# (is expanded based on specifiers, see https://www.man7.org/linux/man-pages/man5/systemd.dnssd.5.html)
avahi_object
.
Commit
()
self
.
name
,
self
.
group
=
avahi_object
# 'name_template' .. what is this?
# also referred to as 'service instance name' in the implementation
# can't be an empty string, gets expanded with the same specifier rules as name,
# gets random numbers appended to it for a new instance name in case of service collisions?
self
.
name
,
self
.
stype
,
dbus
.
UInt16
(
int
(
self
.
port
)),
dbus
.
UInt16
(
10
),
# priority (see https://en.wikipedia.org/wiki/SRV_record)
dbus
.
UInt16
(
0
),
# weight
# Avahi's AddService used "aay" and you could pass self.text directly (python string list)
# The Resolved spec is "aa{say}"
# [ self.text, ] does not work, need to construct something more complicated
# (for no good reason based on the implementation of bus_method_register_service, it still only cares to get a string list)
# in any case we seem to have blocking issues before passing this correctly is a concern, so just use a dummy
#[ self.text, ],
# 'TypeError: list indices must be integers or slices, not bytes'
[
[],
],
)
# FIXME: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.InteractiveAuthorizationRequired: Interactive authentication required.
def
unpublish
(
self
):
def
unpublish
(
self
):
"""
Remove publishing of ourselves as devkit device since we are quitting.
"""
Remove publishing of ourselves as devkit device since we are quitting.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment