mirror of
https://github.com/linka-cloud/grpc.git
synced 2026-02-06 00:55:31 +00:00
feat(pipe): use wireguard-go pipe implementation until CL299009 is resolved
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
@@ -3,12 +3,15 @@ package service
|
||||
import (
|
||||
"net"
|
||||
|
||||
"github.com/Microsoft/go-winio"
|
||||
"golang.zx2c4.com/wireguard/ipc/namedpipe"
|
||||
)
|
||||
|
||||
// listen uses wireguard's namedpipe package to listen on named pipes on Windows until
|
||||
// https://github.com/golang/go/issues/49650 is resolved.
|
||||
// For other networks, it falls back to the standard net.Listen.
|
||||
func listen(network, address string) (net.Listener, error) {
|
||||
if network == "pipe" {
|
||||
return winio.ListenPipe(address, nil)
|
||||
return namedpipe.Listen(address)
|
||||
}
|
||||
return net.Listen(network, address)
|
||||
}
|
||||
|
||||
@@ -139,7 +139,8 @@ func newService(opts ...Option) (*service, error) {
|
||||
grpc.StreamInterceptor(si),
|
||||
grpc.UnaryInterceptor(ui),
|
||||
}
|
||||
if _, ok := s.opts.lis.(*net.UnixListener); ok || strings.HasPrefix(s.opts.address, "unix://") || strings.HasPrefix(s.opts.address, `\\.\pipe\`) {
|
||||
if (s.opts.lis != nil && (s.opts.lis.Addr().Network() == "unix" || s.opts.lis.Addr().Network() == "pipe")) ||
|
||||
strings.HasPrefix(s.opts.address, "unix://") || strings.HasPrefix(s.opts.address, `\\.\pipe\`) {
|
||||
gopts = append(gopts, grpc.Creds(peercreds.New()))
|
||||
}
|
||||
s.server = grpc.NewServer(append(gopts, s.opts.serverOpts...)...)
|
||||
|
||||
Reference in New Issue
Block a user