Skip to content

Add ConnectUnix and DialUnix#399

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

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

Conversation

@anonymix007

@anonymix007 anonymix007 commented Dec 12, 2024

Copy link
Copy Markdown
Contributor

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

Comment thread decoder.go
return variant
case 'h':
idx := dec.decodeU()
if int(idx) < len(dec.fds) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This regresses #223 , see e.g. https://github.com/godbus/dbus/actions/runs/19359654286/job/55389087192?pr=399#step:6:255. Why did you include this change?

Copy link
Copy Markdown
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
Copy Markdown
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.

@anonymix007 anonymix007 Nov 14, 2025

Copy link
Copy Markdown
Contributor Author

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

guelfey commented Nov 14, 2025

Copy link
Copy Markdown
Member

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