mirror of
https://github.com/linka-cloud/grpc.git
synced 2025-12-18 08:53:13 +00:00
feat(server/client): add windows pipe, pipe peer credentials support
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
20
creds/peercreds/peercreds_unix.go
Normal file
20
creds/peercreds/peercreds_unix.go
Normal file
@@ -0,0 +1,20 @@
|
||||
//go:build !windows
|
||||
|
||||
package peercreds
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"github.com/tailscale/peercred"
|
||||
)
|
||||
|
||||
func Get(conn net.Conn) (*Creds, error) {
|
||||
creds, err := peercred.Get(conn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var c Creds
|
||||
c.uid, _ = creds.UserID()
|
||||
c.pid, _ = creds.PID()
|
||||
return &c, nil
|
||||
}
|
||||
Reference in New Issue
Block a user