Skip to content

Add ConnectUnix and DialUnix#399

Closed
anonymix007 wants to merge 3 commits intogodbus:masterfrom
anonymix007:unix-conn
Closed

Add ConnectUnix and DialUnix#399
anonymix007 wants to merge 3 commits intogodbus:masterfrom
anonymix007:unix-conn

Conversation

@anonymix007
Copy link
Contributor

@anonymix007 anonymix007 commented Dec 12, 2024

These allow creating D-Bus connections from *net.UnixConn on Unix systems.

File descriptors may be wrapped with

func fdToUnixConn(fd dbus.UnixFD, name string) (*net.UnixConn, error) {
	c, err := net.FileConn(os.NewFile(uintptr(fd), name))
	if err != nil {
		return nil, err
	}
    return c.(*net.UnixConn), nil
}

and will work as well.

This also technically introduces some sort of peer-to-peer support if only auth client is needed (i.e. QEMU).

Fixes #76
Partially fixes #384

return variant
case 'h':
idx := dec.decodeU()
if int(idx) < len(dec.fds) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it was crashing otherwise. I don't remember the full details, but here's the code that I was using this PR with: https://github.com/anonymix007/qemu-godisplay
AFAIR it was panicking somewhere, but because of recover it was just silently returning an empty fd array in ScanoutDMABUF2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this would be an unrelated change then; and even then, would need to be solved in a different way. I will cherry-pick the first 2 commits that add ConnectUnix and DialUnix. If the FD decoding behavior is still important for you, please create a separate issue with more details.

Copy link
Contributor Author

@anonymix007 anonymix007 Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switched to another language for that project since Go just doesn't work well with GStreamer, so it's not really important anymore.

@guelfey guelfey mentioned this pull request Nov 14, 2025
@guelfey
Copy link
Member

guelfey commented Nov 14, 2025

merged as #417

@guelfey guelfey closed this Nov 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Why does the peer-to-peer branch seem to be deprecated? Allow creating connections from *net.UnixConn

2 participants