{"id":13564036,"url":"https://github.com/markdingo/go-fdpass-demo","last_synced_at":"2026-01-16T15:11:47.899Z","repository":{"id":64307257,"uuid":"252835063","full_name":"markdingo/go-fdpass-demo","owner":"markdingo","description":"Demo code showing how to pass a file descriptor between processes using Unix Domain Sockets","archived":false,"fork":false,"pushed_at":"2024-07-08T20:49:18.000Z","size":9,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-08-01T13:30:42.022Z","etag":null,"topics":["fd-pass","go","unix-domain-sockets"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markdingo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-03T20:34:58.000Z","updated_at":"2024-07-08T20:49:21.000Z","dependencies_parsed_at":"2024-08-01T13:29:58.215Z","dependency_job_id":null,"html_url":"https://github.com/markdingo/go-fdpass-demo","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markdingo%2Fgo-fdpass-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markdingo%2Fgo-fdpass-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markdingo%2Fgo-fdpass-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markdingo%2Fgo-fdpass-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markdingo","download_url":"https://codeload.github.com/markdingo/go-fdpass-demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223030852,"owners_count":17076515,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fd-pass","go","unix-domain-sockets"],"created_at":"2024-08-01T13:01:25.764Z","updated_at":"2026-01-16T15:11:47.869Z","avatar_url":"https://github.com/markdingo.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# go-fdpass-demo\n\nDemo go code showing how to pass a file descriptor between processes\nusing Unix Domain Sockets.\n\nSince fd-passing is a fairly arcane part of Unix and perhaps an even\nmore arcane part of go, I figure that others might benefit from having\naccess to a known working example. While there are plenty of available\nexamples written in C, at the time of writing I could not readily find\na working example in go. Thus this is that.\n\n### When might you use fd-passing?\n\nThere are a number of use-cases, but generally fd-passing is used when\nyou want to centrally manage and control access to underlying system\nresources in a way that is not readily possible with the controls\noffered by the operating system.\n\nFor example you might want to give clients access to sockets created\non privileged ports but only to some clients and only to some\nports. One way to do this is have a server establish the socket and\nfd-pass it back to the client if it passes the access-control rules.\n\nAnother example might be if you want to give clients access to some\nfiles in a directory but not others. Such as those under a certain\nsize or age. The client sends the open request to the server, the\nserver applies the age/size logic and fd-passes back the opened file\nif it's is approved.\n\nAnother use-case is to create a server as a container of idle network\nconnections. If your main server uses a lot of state per connection\nand cannot easily be modified then a small modification to the main\nserver might be to fd-pass idle sockets to the container server which\nmonitors for activity and then fd-passes active sockets back to the\nheavy-state server.\n\nTo be fair, the number of use-cases are not large and some use-cases\nmight be implemented just as easily with fuse or similar. But when you\ndo have a use-case, now you have a guide to get you up and running.\n\n### How to use\n\n1. Run `make`\n\n2. Run `./server` in one terminal\n\n3. Run `./client` in another terminal\n\n4. Type some lines of text into the `./client` terminal\n\n5. Text should show up on the `./server` terminal\n\n### Runs on?\n\nThis demo is know to work on Linux, FreeBSD and macOS using go1.11.6\nand beyond.\n\n\n**--**\n\n**Search terms**: go, golang, fd-passing, CMSG, Control Message, SCM_RIGHTS, recvmsg, sendmsg, Unix.\n\n\n### Copyright and License\n\ngo-fdpass-demo is Copyright :copyright: 2020 Mark Delany. This software  is licensed under the BSD 2-Clause \"Simplified\" License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkdingo%2Fgo-fdpass-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkdingo%2Fgo-fdpass-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkdingo%2Fgo-fdpass-demo/lists"}