resolve: several follow-ups for resolving service via varlink
Follow-ups for e1634bb832.
- Allow to call the method without "name" and "type".
- Allow to specify SD_RESOLVE_NO_TXT and SD_RESOLVE_NO_ADDRESS.
- Allow to provide multiple services, and fix memory leak.
- Rearrange the return value format.
- Encode TXT field with octescape() to make the field matches with the
io.systemd.Resolve.Monitor interface.
Fixes #31371.
This commit is contained in:
committed by
Lennart Poettering
parent
d0a0059c21
commit
c6c7c461a3
@@ -437,14 +437,23 @@ grep -qF "authenticated: yes" "$RUN_OUT"
|
||||
|
||||
# Test service resolve over Varlink
|
||||
run varlinkctl call /run/systemd/resolve/io.systemd.Resolve io.systemd.Resolve.ResolveService '{"name":"","type":"_mysvc._tcp","domain":"signed.test"}'
|
||||
grep -qF '"srv":{"priority":10,"weight":5,"port":1234,"hostname":"myservice.signed.test"}' "$RUN_OUT"
|
||||
grep -qF '"addr":[{"ifindex":' "$RUN_OUT"
|
||||
grep -qF '"services":[{"priority":10,"weight":5,"port":1234,"hostname":"myservice.signed.test","canonicalName":"myservice.signed.test","addresses":[{"ifindex":' "$RUN_OUT"
|
||||
grep -qF '"family":10,"address":[253,0,222,173,190,239,202,254,0,0,0,0,0,0,0,23]' "$RUN_OUT"
|
||||
grep -qF '"family":2,"address":[10,0,0,20]' "$RUN_OUT"
|
||||
grep -qF '"normalized":"myservice.signed.test"' "$RUN_OUT"
|
||||
grep -qF '"canonical":{"name":null,"type":"_mysvc._tcp","domain":"signed.test"}' "$RUN_OUT"
|
||||
TXT_OUT=$(grep -a -o -P '(?<=\"txt\"\:\[\").*(?=\"\])' "$RUN_OUT" | base64 --decode)
|
||||
assert_in "This is TXT for myservice" "$TXT_OUT"
|
||||
grep -qF '}]}],"txt":["This is TXT for myservice"],"canonical":{"name":null,"type":"_mysvc._tcp","domain":"signed.test"},"flags":' "$RUN_OUT"
|
||||
|
||||
# without name
|
||||
run varlinkctl call /run/systemd/resolve/io.systemd.Resolve io.systemd.Resolve.ResolveService '{"type":"_mysvc._tcp","domain":"signed.test"}'
|
||||
# without txt (SD_RESOLVE_NO_TXT)
|
||||
run varlinkctl call /run/systemd/resolve/io.systemd.Resolve io.systemd.Resolve.ResolveService '{"type":"_mysvc._tcp","domain":"signed.test","flags":64}'
|
||||
(! grep -qF '"txt"' "$RUN_OUT")
|
||||
# without address (SD_RESOLVE_NO_ADDRESS)
|
||||
run varlinkctl call /run/systemd/resolve/io.systemd.Resolve io.systemd.Resolve.ResolveService '{"type":"_mysvc._tcp","domain":"signed.test","flags":128}'
|
||||
(! grep -qF '"addresses"' "$RUN_OUT")
|
||||
# without txt and address
|
||||
run varlinkctl call /run/systemd/resolve/io.systemd.Resolve io.systemd.Resolve.ResolveService '{"type":"_mysvc._tcp","domain":"signed.test","flags":192}'
|
||||
(! grep -qF '"txt"' "$RUN_OUT")
|
||||
(! grep -qF '"addresses"' "$RUN_OUT")
|
||||
|
||||
(! run resolvectl service _invalidsvc._udp signed.test)
|
||||
grep -qE "invalidservice\.signed\.test' not found" "$RUN_OUT"
|
||||
|
||||
Reference in New Issue
Block a user