Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

credentials/alts: Support UDS addresses in ALTS interop test server #2763

Merged
merged 4 commits into from
Apr 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions interop/alts/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package main
import (
"flag"
"net"
"strings"

grpc "google.golang.org/grpc"
"google.golang.org/grpc/credentials/alts"
Expand All @@ -30,17 +31,28 @@ import (
testpb "google.golang.org/grpc/interop/grpc_testing"
)

const (
udsAddrPrefix = "unix:"
)

var (
hsAddr = flag.String("alts_handshaker_service_address", "", "ALTS handshaker gRPC service address")
serverAddr = flag.String("server_address", ":8080", "The port on which the server is listening")
serverAddr = flag.String("server_address", ":8080", "The address on which the server is listening. Only two types of addresses are supported, 'host:port' and 'unix:/path'.")
)

func main() {
flag.Parse()

lis, err := net.Listen("tcp", *serverAddr)
// If the server address starts with `unix:`, then we have a UDS address.
network := "tcp"
address := *serverAddr
if strings.HasPrefix(address, udsAddrPrefix) {
network = "unix"
address = strings.TrimPrefix(address, udsAddrPrefix)
}
lis, err := net.Listen(network, address)
if err != nil {
grpclog.Fatalf("gRPC Server: failed to start the server at %v: %v", *serverAddr, err)
grpclog.Fatalf("gRPC Server: failed to start the server at %v: %v", address, err)
}
opts := alts.DefaultServerOptions()
if *hsAddr != "" {
Expand Down