Skip to content
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

Feature/update dbus introspection #81

Merged
merged 2 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/development/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ node /com/telekom_mms/oc_daemon/Daemon {
Connect(in s server,
in s cookie,
in s host,
in s connectURL,
in s connect_url,
in s fingerprint,
in s resolve);
Disconnect();
Expand All @@ -41,10 +41,10 @@ node /com/telekom_mms/oc_daemon/Daemon {

`Connect()` is used to connect to a VPN server. The parameter `server` is the
name of the VPN server. The remaining parameters are the login information
returned by `openconnect -authenticate`: `Cookie` is an access token containing
information for authentication and authorization on the VPN server. `Host` is
the VPN server address. `ConnectURL` is the VPN server URL. `Fingerprint` is
the fingerprint of the server's certificate. `Resolve` maps the server's host
returned by `openconnect -authenticate`: `cookie` is an access token containing
information for authentication and authorization on the VPN server. `host` is
the VPN server address. `connect_url` is the VPN server URL. `fingerprint` is
the fingerprint of the server's certificate. `resolve` maps the server's host
name to its IP address to bypass DNS resolution.

`Disconnect()` is used to disconnect from the current VPN server.
Expand Down
32 changes: 31 additions & 1 deletion internal/dbusapi/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,44 @@ func (s *Service) Start() error {
s.props = props

// introspection
// set names of method arguments
introMeths := introspect.Methods(meths)
for _, m := range introMeths {
if m.Name != "Connect" {
continue
}
m.Args[0].Name = "server"
m.Args[1].Name = "cookie"
m.Args[2].Name = "host"
m.Args[3].Name = "connect_url"
m.Args[4].Name = "fingerprint"
m.Args[5].Name = "resolve"

}
// set peer interface
peerData := introspect.Interface{
Name: "org.freedesktop.DBus.Peer",
Methods: []introspect.Method{
{
Name: "Ping",
},
{
Name: "GetMachineId",
Args: []introspect.Arg{
{Name: "machine_uuid", Type: "s", Direction: "out"},
},
},
},
}
n := &introspect.Node{
Name: Path,
Interfaces: []introspect.Interface{
introspect.IntrospectData,
peerData,
prop.IntrospectData,
{
Name: Interface,
Methods: introspect.Methods(meths),
Methods: introMeths,
Properties: props.Introspection(Interface),
},
},
Expand Down
Loading