forked from Wifx/gonetworkmanager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VpnConnection.go
45 lines (34 loc) · 1.13 KB
/
VpnConnection.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package gonetworkmanager
import (
"github.com/godbus/dbus/v5"
)
const (
VpnConnectionInterface = NetworkManagerInterface + ".VPN.Connection"
/* Properties */
VpnConnectionPropertyVpnState = VpnConnectionInterface + ".VpnState" // readable u
VpnConnectionPropertyBanner = VpnConnectionInterface + ".Banner" // readable s
)
type VpnConnection interface {
GetPath() dbus.ObjectPath
// The VPN-specific state of the connection.
GetPropertyVpnState() (NmVpnConnectionState, error)
// The banner string of the VPN connection.
GetPropertyBanner() (string, error)
}
func NewVpnConnection(objectPath dbus.ObjectPath) (VpnConnection, error) {
var a vpnConnection
return &a, a.init(NetworkManagerInterface, objectPath)
}
type vpnConnection struct {
dbusBase
}
func (a *vpnConnection) GetPath() dbus.ObjectPath {
return a.obj.Path()
}
func (a *vpnConnection) GetPropertyVpnState() (NmVpnConnectionState, error) {
v, err := a.getUint32Property(VpnConnectionPropertyVpnState)
return NmVpnConnectionState(v), err
}
func (a *vpnConnection) GetPropertyBanner() (string, error) {
return a.getStringProperty(VpnConnectionPropertyBanner)
}