| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | |
| 3 // that can be found in the LICENSE file. | |
| 4 | |
| 5 package main | |
| 6 | |
| 7 import ( | |
| 8 "errors" | |
| 9 "fmt" | |
| 10 | |
| 11 "github.com/luci/luci-go/client/internal/logdog/butler/streamserver" | |
| 12 "golang.org/x/net/context" | |
| 13 ) | |
| 14 | |
| 15 const ( | |
| 16 // An example stream server URI. | |
| 17 // | |
| 18 // This expands to: //localhost/pipe/<name> | |
| 19 exampleStreamServerURI = streamServerURI("net.pipe:logdog-butler") | |
| 20 ) | |
| 21 | |
| 22 type streamServerURI string | |
| 23 | |
| 24 func (u streamServerURI) Parse() (string, error) { | |
| 25 typ, value := parseStreamServer(string(u)) | |
| 26 if typ != "net.pipe" { | |
| 27 return "", errors.New("Unsupported URI scheme.") | |
| 28 } | |
| 29 | |
| 30 if value == "" { | |
| 31 return "", errors.New("cannot have empty pipe name") | |
| 32 } | |
| 33 return value, nil | |
| 34 } | |
| 35 | |
| 36 // Validates that the URI is correct for Windows. | |
| 37 func (u streamServerURI) Validate() error { | |
| 38 _, err := u.Parse() | |
| 39 return err | |
| 40 } | |
| 41 | |
| 42 // Create a Windows stream server. | |
| 43 func createStreamServer(ctx context.Context, uri streamServerURI) streamserver.S
treamServer { | |
| 44 name, err := uri.Parse() | |
| 45 if err != nil { | |
| 46 panic("Failed to parse stream server URI.") | |
| 47 } | |
| 48 return streamserver.NewNamedPipeServer(ctx, fmt.Sprintf(`\\.\pipe\%s`, n
ame)) | |
| 49 } | |
| OLD | NEW |