Updated dependency github.com/godbus/dbus

socks-filter
Bruce Leidl 9 years ago
parent 3ac218f288
commit 6a5a6f08e7

8
Godeps/Godeps.json generated

@ -8,13 +8,13 @@
"Deps": [
{
"ImportPath": "github.com/godbus/dbus",
"Comment": "v3-15-g230e4b2",
"Rev": "230e4b23db2fd81c53eaa0073f76659d4849ce51"
"Comment": "v4.0.0-5-g32c6cc2",
"Rev": "32c6cc29c14570de4cf6d7e7737d68fb2d01ad15"
},
{
"ImportPath": "github.com/godbus/dbus/introspect",
"Comment": "v3-15-g230e4b2",
"Rev": "230e4b23db2fd81c53eaa0073f76659d4849ce51"
"Comment": "v4.0.0-5-g32c6cc2",
"Rev": "32c6cc29c14570de4cf6d7e7737d68fb2d01ad15"
},
{
"ImportPath": "github.com/gotk3/gotk3/cairo",

@ -16,6 +16,7 @@ var (
systemBusLck sync.Mutex
sessionBus *Conn
sessionBusLck sync.Mutex
sessionEnvLck sync.Mutex
)
// ErrClosed is the error returned by calls on a closed connection.
@ -54,6 +55,7 @@ type Conn struct {
outLck sync.RWMutex
signals []chan<- *Signal
signalsClosed bool
signalsLck sync.Mutex
eavesdropped chan<- *Message
@ -91,6 +93,8 @@ func SessionBus() (conn *Conn, err error) {
// SessionBusPrivate returns a new private connection to the session bus.
func SessionBusPrivate() (*Conn, error) {
sessionEnvLck.Lock()
defer sessionEnvLck.Unlock()
address := os.Getenv("DBUS_SESSION_BUS_ADDRESS")
if address != "" && address != "autolaunch:" {
return Dial(address)
@ -186,6 +190,7 @@ func (conn *Conn) Close() error {
conn.closed = true
conn.outLck.Unlock()
conn.signalsLck.Lock()
conn.signalsClosed = true
for _, ch := range conn.signals {
close(ch)
}
@ -338,6 +343,10 @@ func (conn *Conn) inWorker() {
Body: msg.Body,
}
conn.signalsLck.Lock()
if conn.signalsClosed {
conn.signalsLck.Unlock()
return
}
for _, ch := range conn.signals {
ch <- signal
}
@ -621,16 +630,11 @@ func dereferenceAll(vs []interface{}) []interface{} {
// getKey gets a key from a the list of keys. Returns "" on error / not found...
func getKey(s, key string) string {
i := strings.Index(s, key)
if i == -1 {
return ""
}
if i+len(key)+1 >= len(s) || s[i+len(key)] != '=' {
return ""
for _, keyEqualsValue := range strings.Split(s, ",") {
keyValue := strings.SplitN(keyEqualsValue, "=", 2)
if len(keyValue) == 2 && keyValue[0] == key {
return keyValue[1]
}
j := strings.Index(s, ",")
if j == -1 {
j = len(s)
}
return s[i+len(key)+1 : j]
return ""
}

@ -5,6 +5,7 @@ package dbus
import (
"bytes"
"errors"
"os"
"os/exec"
)
@ -23,5 +24,8 @@ func sessionBusPlatform() (*Conn, error) {
return nil, errors.New("dbus: couldn't determine address of session bus")
}
return Dial(string(b[i+1 : j]))
env, addr := string(b[0:i]), string(b[i+1:j])
os.Setenv(env, addr)
return Dial(addr)
}

@ -1,6 +1,7 @@
package dbus
import (
"bytes"
"errors"
"fmt"
"reflect"
@ -126,6 +127,28 @@ func (conn *Conn) handleCall(msg *Message) {
conn.sendError(errmsgUnknownMethod, sender, serial)
}
return
} else if ifaceName == "org.freedesktop.DBus.Introspectable" && name == "Introspect" {
if _, ok := conn.handlers[path]; !ok {
subpath := make(map[string]struct{})
var xml bytes.Buffer
xml.WriteString("<node>")
for h, _ := range conn.handlers {
p := string(path)
if p != "/" {
p += "/"
}
if strings.HasPrefix(string(h), p) {
node_name := strings.Split(string(h[len(p):]), "/")[0]
subpath[node_name] = struct{}{}
}
}
for s, _ := range subpath {
xml.WriteString("\n\t<node name=\"" + s + "\"/>")
}
xml.WriteString("\n</node>")
conn.sendReply(sender, serial, xml.String())
return
}
}
if len(name) == 0 {
conn.sendError(errmsgUnknownMethod, sender, serial)

@ -22,6 +22,13 @@ const (
// FlagNoAutoStart signals that the message bus should not automatically
// start an application when handling this message.
FlagNoAutoStart
// FlagAllowInteractiveAuthorization may be set on a method call
// message to inform the receiving side that the caller is prepared
// to wait for interactive authorization, which might take a
// considerable time to complete. For instance, if this flag is set,
// it would be appropriate to query the user for passwords or
// confirmation via Polkit or a similar framework.
FlagAllowInteractiveAuthorization
)
// Type represents the possible types of a D-Bus message.
@ -248,7 +255,7 @@ func (msg *Message) EncodeTo(out io.Writer, order binary.ByteOrder) error {
// IsValid checks whether msg is a valid message and returns an
// InvalidMessageError if it is not.
func (msg *Message) IsValid() error {
if msg.Flags & ^(FlagNoAutoStart|FlagNoReplyExpected) != 0 {
if msg.Flags & ^(FlagNoAutoStart|FlagNoReplyExpected|FlagAllowInteractiveAuthorization) != 0 {
return InvalidMessageError("invalid flags")
}
if msg.Type == 0 || msg.Type >= typeMax {

@ -0,0 +1,43 @@
//+build !windows
package dbus
import (
"errors"
"net"
)
func init() {
transports["tcp"] = newTcpTransport
}
func tcpFamily(keys string) (string, error) {
switch getKey(keys, "family") {
case "":
return "tcp", nil
case "ipv4":
return "tcp4", nil
case "ipv6":
return "tcp6", nil
default:
return "", errors.New("dbus: invalid tcp family (must be ipv4 or ipv6)")
}
}
func newTcpTransport(keys string) (transport, error) {
host := getKey(keys, "host")
port := getKey(keys, "port")
if host == "" || port == "" {
return nil, errors.New("dbus: unsupported address (must set host and port)")
}
protocol, err := tcpFamily(keys)
if err != nil {
return nil, err
}
socket, err := net.Dial(protocol, net.JoinHostPort(host, port))
if err != nil {
return nil, err
}
return NewConn(socket)
}

@ -0,0 +1,14 @@
package dbus
import "io"
func (t *unixTransport) SendNullByte() error {
n, _, err := t.UnixConn.WriteMsgUnix([]byte{0}, nil, nil)
if err != nil {
return err
}
if n != 1 {
return io.ErrShortWrite
}
return nil
}
Loading…
Cancel
Save