Native Go bindings for D-Bus

Overview

go.dbus

go.dbus is a simple library that implements native Go client bindings for the D-Bus message bus system.

Features

  • Complete native implementation of the D-Bus message protocol
  • Go-like API (channels for signals / asynchronous method calls, Goroutine-safe connections)
  • Subpackages that help with the introspection / property interfaces

Installation

This packages requires Go 1.1. If you installed it and set up your GOPATH, just run:

go get github.com/guelfey/go.dbus

If you want to use the subpackages, you can install them the same way.

Usage

The complete package documentation and some simple examples are available at godoc.org. Also, the _examples directory gives a short overview over the basic usage.

Please note that the API is considered unstable for now and may change without further notice.

License

go.dbus is available under the Simplified BSD License; see LICENSE for the full text.

Comments
  • transport_unix does not compile on mac

    transport_unix does not compile on mac

    It only compiles on linux, since

    syscall.UnixCredentials

    is in an _linux.go file in the standard go library.

    http://golang.org/src/pkg/syscall/sockcmsg_linux.go?s=367:408#L4

    opened by awalterschulze 8
  • "dbus: authentication failed" with any example

    On Fedora 33, building and running any of the examples e.g. list-names.go will fail with

    $ ./listnames
    Failed to connect to session bus: dbus: authentication failed
    

    There's a usable session bus address

    $ echo $DBUS_SESSION_BUS_ADDRESS
    unix:path=/run/user/1000/bus
    

    and command-line d-bus operations work

    $ dbus-send --session --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames
    method return time=1629168407.533841 sender=org.freedesktop.DBus -> destination=:1.10056 serial=4294967295 reply_serial=2
       array [
          string "org.freedesktop.DBus"
          .....
    

    so the bus is usable.

    SELinux is in permissive mode (unfortunately, due to unrelated issues) so it's not SELinux related.

    I don't see any relevant output in dbus-monitor --session when I attempt to auth while it's running.

    It's unclear why this is happening. I'll look into it, but wanted to file this now so others with a similar issue can find it.

    opened by ringerc 5
  • Allow receiving sender in method call

    Allow receiving sender in method call

    Exported methods can receive the sender of the message by specifying an argument of type dbus.Sender. Upon calling, this argument will be set to the sender of the message. Any dbus.Sender arguments are not part of the dbus method signature.

    opened by jessevdk 3
  • It doesn't support empty struct .

    It doesn't support empty struct .

    An empty struct will cause bus connection closed

    type of '()' can be show in d-feet. And dbus spec doesn't specify whether an struct can be an empty.

    opened by snyh 2
  • Support passing sender to method call

    Support passing sender to method call

    It would be nice if the sender could be passed to a method call if a user wants to. A new type Sender string could be introduced which when found in a method signature would receive the sender of the message.

    opened by jessevdk 2
  • Read properties of com.ubuntu.Upstart0_6.Instance

    Read properties of com.ubuntu.Upstart0_6.Instance

    It does not seem possible to read the properties of com.ubuntu.Upstart0_6.Instance (com.ubuntu.Upstart0_6.Instance.name, com.ubuntu.Upstart0_6.Instance.state, etc.), as per: http://upstart.ubuntu.com/wiki/DBusInterface, only execute methods associated to that object. Not sure if there is a supported mechanism, for example, to read the PID of a particular instance.

    opened by acasas 2
  • panic: reflect: call of reflect.Value.Elem on map Value

    panic: reflect: call of reflect.Value.Elem on map Value

    Hi

    I am trying to call GetManagedObjects on the org.freedesktop.DBus.ObjectManager interface of org.freedesktop.UDisks2.

    According to http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager

    The signature is:

        org.freedesktop.DBus.ObjectManager.GetManagedObjects (out DICT<OBJPATH,DICT<STRING,DICT<STRING,VARIANT>>> objpath_interfaces_and_properties);
    
    udisk := conn.Object("org.freedesktop.UDisks2", "/org/freedesktop/UDisks2")
    
    ...
    
    ret := make(map[dbus.ObjectPath]map[string]dbus.Variant)
    err = udisk.Call("org.freedesktop.DBus.ObjectManager.GetManagedObjects", 0).Store(ret)
    
    if err != nil {
      panic(err)
    }
    

    results in

    panic: reflect: call of reflect.Value.Elem on map Value
    

    What would be the correct way to call this method?

    opened by dmacvicar 2
  • Use launchctl to obtain session bus address on OS X

    Use launchctl to obtain session bus address on OS X

    The "standard" way to launch dbus on OS X is through launchd which is responsible for allocating a unix domain socket and then passing it to dbus. This patch splits out a platform specific method to obtain the session bus if DBUS_SESSION_BUS_ADDRESS is not set. On OS X launchctl is queried while on other platforms dbus-launch is used as before.

    opened by jessevdk 1
  • Use launchctl to obtain session bus address on OS X

    Use launchctl to obtain session bus address on OS X

    The "standard" way to launch dbus on OS X is through launchd which is responsible for allocating a unix domain socket and then passing it to dbus. This patch splits out a platform specific method to obtain the session bus if DBUS_SESSION_BUS_ADDRESS is not set. On OS X launchctl is queried while on other platforms dbus-launch is used as before.

    opened by jessevdk 1
  • Use launchctl to obtain session bus address on OS X

    Use launchctl to obtain session bus address on OS X

    The "standard" way to launch dbus on OS X is through launchd which is responsible for allocating a unix domain socket and then passing it to dbus. This patch splits out a platform specific method to obtain the session bus if DBUS_SESSION_BUS_ADDRESS is not set. On OS X launchctl is queried while on other platforms dbus-launch is used as before.

    opened by jessevdk 1
  • Is SendNullByte needed?

    Is SendNullByte needed?

    I'm trying to use go.dbus on OS X which doesn't support syscall.Ucred. However, I found that SendNullByte is currently not used anywhere. Can it be removed altogether?

    opened by jessevdk 1
  • Handle empty SASL handshake to fix

    Handle empty SASL handshake to fix "dbus: authentication failed"

    See issue #68 for details.

    This pull request incorporates the proposed fix for #68 as seen in the commit message for 9c4d13f, as well as an option to trace the protocol exchange during authentication and a small README change.

    Note that this changes the public interface dbus.Auth to allow mechanism implementations to accept and respond with DATA payloads of zero or more elements, instead of the fixed single-element payloads the interface baked in previously.

    This is a breaking API change for external implementations of dbus.Auth but doesn't change any other public API.

    opened by ringerc 0
  • transport_darwin is the right way for all (non-linux) unix systems

    transport_darwin is the right way for all (non-linux) unix systems

    In #33 it was decided to not pin the Ucred calls to Linux only. However this would have been the right thing to do, even for BSDs.

    See these for reference:

    • https://github.com/golang/sys/blob/master/unix/sockcmsg_linux.go
    • https://github.com/golang/sys/blob/master/unix/sockcmsg_unix.go
    opened by reezer 0
  • conn.Close() panics

    conn.Close() panics

    conn.Close() closes the transport corresponding to the connection. After that inWorker() will see EOF and will try to close the connection again. This then leads to attempt to close closed channel.

    $ cat bug.go
    package main
    
    import (
            "time"
    
            dbus "github.com/guelfey/go.dbus"
    )
    
    func main() {
            conn, _ := dbus.SessionBusPrivate()
            conn.Auth(nil)
            conn.Hello()
            conn.RequestName("com.github.guelfey.Demo", dbus.NameFlagDoNotQueue)
            conn.Close()
            time.Sleep(1 * time.Second)
    }
    $ go run bug.go
    panic: close of closed channel
    
    goroutine 6 [running]:
    github.com/guelfey/go%2edbus.(*Conn).Close(0x4c2080010e0, 0x0, 0x0)
            github.com/guelfey/go.dbus/conn.go:178 +0x62
    github.com/guelfey/go%2edbus.(*Conn).inWorker(0x4c2080010e0)
            github.com/guelfey/go.dbus/conn.go:334 +0x10be
    created by github.com/guelfey/go%2edbus.(*Conn).Auth
            github.com/guelfey/go.dbus/auth.go:120 +0xecd
    
    opened by aulanov 2
Owner
Georg Reinke
Georg Reinke
A reimplementation of the TinyGo drivers package for communicating with multiples of the same (supported) devices on one individual I2C bus.

tinygo-multi-i2c A reimplementation of the TinyGo drivers package for communicating with multiples of the same (supported) devices on one individual I

Quinn Millican 3 Mar 10, 2022
Go bindings for unarr (decompression library for RAR, TAR, ZIP and 7z archives)

go-unarr Golang bindings for the unarr library from sumatrapdf. unarr is a decompression library and CLI for RAR, TAR, ZIP and 7z archives. GoDoc See

Milan Nikolic 220 Dec 29, 2022
GObject-introspection based bindings generator

WARNING! This project is no longer maintained. Probably doesn't even compile. GObject-introspection based bindings generator for Go. Work in progress

null 47 Jan 5, 2022
wkhtmltopdf Go bindings and high level interface for HTML to PDF conversion

wkhtmltopdf Go bindings and high level interface for HTML to PDF conversion. Implements wkhtmltopdf Go bindings. It can be used to convert HTML docume

Adrian-George Bostan 139 Dec 17, 2022
Some plain Go/Golang i2c sensor bindings to Waveshare Sense HAT for raspberry pi

i2c some plain Go/Golang i2c sensor bindings to Waveshare Sense HAT for raspberry pi using https://periph.io Supported hardware: Raspberry Zero W 1 ht

Torben Schinke 0 Dec 31, 2021
Weaviate is a cloud-native, modular, real-time vector search engine

Weaviate is a cloud-native, real-time vector search engine (aka neural search engine or deep search engine). There are modules for specific use cases such as semantic search, plugins to integrate Weaviate in any application of your choice, and a console to visualize your data.

SeMI Technologies 3.1k Jan 5, 2023
Phalanx is a cloud-native full-text search and indexing server written in Go built on top of Bluge that provides endpoints through gRPC and traditional RESTful API.

Phalanx Phalanx is a cloud-native full-text search and indexing server written in Go built on top of Bluge that provides endpoints through gRPC and tr

Minoru Osuka 297 Dec 25, 2022
Native Go bindings for D-Bus

go.dbus go.dbus is a simple library that implements native Go client bindings for the D-Bus message bus system. Features Complete native implementatio

Georg Reinke 121 Nov 20, 2022
Go bindings for D-Bus

Documentation Look at the API on GoPkgDoc. Installation goinstall github.com/norisatir/go-dbus Usage Methods Methods is obtained with meth, err := co

nori satir 18 Oct 20, 2019
Go bindings to systemd socket activation, journal, D-Bus, and unit files

go-systemd Go bindings to systemd. The project has several packages: activation - for writing and using socket activation from Go daemon - for notifyi

CoreOS 2.1k Dec 30, 2022
🔊Minimalist message bus implementation for internal communication

?? Bus Bus is a minimalist event/message bus implementation for internal communication. It is heavily inspired from my event_bus package for Elixir la

Mustafa Turan 282 Jan 3, 2023
Go simple async message bus

?? message-bus Go simple async message bus. ?? ABOUT Contributors: Rafał Lorenz Want to contribute ? Feel free to send pull requests! Have problems, b

Rafał Lorenz 240 Dec 29, 2022
A lightweight transactional message bus on top of RabbitMQ

grabbit A lightweight transactional message bus on top of RabbitMQ supporting: Supported Messaging Styles One Way (Fire and forget) Publish/Subscribe

WeWork 90 Dec 22, 2022
Gin best practices, gin development scaffolding, too late to explain, get on the bus.

Table of Contents generated with DocToc gin_scaffold 现在开始 文件分层 log / redis / mysql / http.client 常用方法 swagger文档生成 gin_scaffold Gin best practices, gin

niuyufu 553 Dec 27, 2022
Easy to use distributed event bus similar to Kafka

chukcha Easy to use distributed event bus similar to Kafka. The event bus is designed to be used as a persistent intermediate storage buffer for any k

Yuriy Nasretdinov 81 Dec 30, 2022
simple golang event bus structure

super simple and small event bus structure for golang that allows emissions as go routines.

bfu4 5 Dec 11, 2021
Go-turing-i2c-cmdline - Controlling the i2c management bus of the turing pi with i2c works fine

go-turing-i2c-cmdline What is it? Controlling the i2c management bus of the turi

null 2 Jan 24, 2022
Govent is an event bus framework for DDD event source implement

Govent is an event bus framework for DDD event source implement. Govent can also solve the package circular dependency problem.

Michaelyn 2 Jan 28, 2022
Messagebus - Simple Message Bus Written in Golang

MessageBus Simple Message Bus Written in Golang How to Use go get gopkg.io/Usada

Usada Pekora 2 Apr 21, 2022
A reimplementation of the TinyGo drivers package for communicating with multiples of the same (supported) devices on one individual I2C bus.

tinygo-multi-i2c A reimplementation of the TinyGo drivers package for communicating with multiples of the same (supported) devices on one individual I

Quinn Millican 3 Mar 10, 2022