| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package streamclient | 5 package streamclient |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "errors" | 8 "errors" |
| 9 "io" | 9 "io" |
| 10 | 10 |
| 11 » "github.com/Microsoft/go-winio" | 11 » "gopkg.in/natefinch/npipe.v2" |
| 12 ) | 12 ) |
| 13 | 13 |
| 14 func registerPlatformProtocols(r *Registry) { | 14 func registerPlatformProtocols(r *Registry) { |
| 15 r.Register("net.pipe", newNamedPipeClient) | 15 r.Register("net.pipe", newNamedPipeClient) |
| 16 } | 16 } |
| 17 | 17 |
| 18 // newNamedPipeClient creates a new Client instance bound to a named pipe stream | 18 // newNamedPipeClient creates a new Client instance bound to a named pipe stream |
| 19 // server. | 19 // server. |
| 20 func newNamedPipeClient(path string) (Client, error) { | 20 func newNamedPipeClient(path string) (Client, error) { |
| 21 if path == "" { | 21 if path == "" { |
| 22 return nil, errors.New("streamclient: cannot have empty named pi
pe path") | 22 return nil, errors.New("streamclient: cannot have empty named pi
pe path") |
| 23 } | 23 } |
| 24 | 24 |
| 25 return &clientImpl{ | 25 return &clientImpl{ |
| 26 factory: func() (io.WriteCloser, error) { | 26 factory: func() (io.WriteCloser, error) { |
| 27 » » » return winio.DialPipe(LocalNamedPipePath(path), nil) | 27 » » » return npipe.Dial(LocalNamedPipePath(path)) |
| 28 }, | 28 }, |
| 29 }, nil | 29 }, nil |
| 30 } | 30 } |
| 31 | 31 |
| 32 // LocalNamedPipePath returns the path to a local Windows named pipe named base. | 32 // LocalNamedPipePath returns the path to a local Windows named pipe named base. |
| 33 func LocalNamedPipePath(base string) string { | 33 func LocalNamedPipePath(base string) string { |
| 34 return `\\.\pipe\` + base | 34 return `\\.\pipe\` + base |
| 35 } | 35 } |
| OLD | NEW |