https://github.com/karpeleslab/unixconn
UnixConn tools & utils
https://github.com/karpeleslab/unixconn
Last synced: 12 months ago
JSON representation
UnixConn tools & utils
- Host: GitHub
- URL: https://github.com/karpeleslab/unixconn
- Owner: KarpelesLab
- License: mit
- Created: 2021-07-25T07:31:07.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-07-25T07:42:27.000Z (almost 5 years ago)
- Last Synced: 2024-06-21T07:38:01.791Z (almost 2 years ago)
- Language: Go
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://godoc.org/github.com/KarpelesLab/unixconn)
# UnixConn tools
Some stuff commonly used made more simple.
## socketpair
Calling
```go
pair, err := unixconn.Pair()
```
Allows pair to contain two `*net.UnixConn` that are connected to each other.
Those can be used as replacement to TCP connections in test code, for example.
## cred
Golang already makes this easier thanks to `GetsockoptUcred` but I feel this
can be even better.
```go
uid, gid, pid, err := unixconn.Cred(c)
```
**NOTE**: Using `unixconn.Cred()` on a connection generated by
`unixconn.Pair()` will return the information at the time the call to Pair()
happened, and may not reflect the right information if for example the socket
was passed to a child process.