| 1 |
/* |
| 2 |
* |
| 3 |
* Copyright 2022 Google LLC |
| 4 |
* |
| 5 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 |
* you may not use this file except in compliance with the License. |
| 7 |
* You may obtain a copy of the License at |
| 8 |
* |
| 9 |
* https://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
* |
| 11 |
* Unless required by applicable law or agreed to in writing, software |
| 12 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 13 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 |
* See the License for the specific language governing permissions and |
| 15 |
* limitations under the License. |
| 16 |
* |
| 17 |
*/ |
| 18 |
|
| 19 |
// Package main runs an S2Av2 service. |
| 20 |
package main |
| 21 |
|
| 22 |
import ( |
| 23 |
"flag" |
| 24 |
"log" |
| 25 |
"net" |
| 26 |
|
| 27 |
"github.com/google/s2a-go/internal/v2/fakes2av2" |
| 28 |
"google.golang.org/grpc" |
| 29 |
|
| 30 |
s2av2pb "github.com/google/s2a-go/internal/proto/v2/s2a_go_proto" |
| 31 |
) |
| 32 |
|
| 33 |
var ( |
| 34 |
port = flag.String("port", ":8008", "Fake S2Av2 server address port.") |
| 35 |
) |
| 36 |
|
| 37 |
func runFakeS2Av2Server(listenPort *string) { |
| 38 |
listener, err := net.Listen("tcp", *port) |
| 39 |
if err != nil { |
| 40 |
log.Fatalf("Failed to listen on port %s: %v", listener.Addr().String(), err) |
| 41 |
} |
| 42 |
s := grpc.NewServer() |
| 43 |
log.Printf("Server: started gRPC Fake S2Av2 Server at port: %s", listener.Addr()) |
| 44 |
s2av2pb.RegisterS2AServiceServer(s, &fakes2av2.Server{}) |
| 45 |
if err := s.Serve(listener); err != nil { |
| 46 |
log.Fatalf("Failed to serve: %v", err) |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
func main() { |
| 51 |
runFakeS2Av2Server(port) |
| 52 |
} |