Documentation ¶
Overview ¶
Package sping is a simple example of a client and server that conduct communication using gRPC in a secure fashion with SSL/TLS.
Index ¶
- Constants
- func Insecure(addr string) (*grpc.ClientConn, error)
- func MutualTLS(addr string) (*grpc.ClientConn, error)
- func Output(format string, args ...interface{})
- func TLS(addr string) (*grpc.ClientConn, error)
- type Dailer
- type PingClient
- type PingServer
- func (s *PingServer) Echo(ctx context.Context, ping *pb.Ping) (*pb.Pong, error)
- func (s *PingServer) Serve(port uint) error
- func (s *PingServer) ServeInsecure(port uint) error
- func (s *PingServer) ServeMutualTLS(port uint) error
- func (s *PingServer) ServeTLS(port uint) error
- func (s *PingServer) Shutdown()
Constants ¶
const ( ClientCert = "cert/client.crt" ClientKey = "cert/client.key" )
Client Certificates
const ( ServerCert = "cert/server.crt" ServerKey = "cert/server.key" ServerName = "localhost" ExampleCA = "cert/sping_example.crt" )
Server Certificates
Variables ¶
This section is empty.
Functions ¶
Types ¶
type PingClient ¶
type PingClient struct { Name string Delay time.Duration Limit uint Connection *grpc.ClientConn pb.SecurePingClient // contains filtered or unexported fields }
PingClient sends echo requests to the ping server on demand.
func NewClient ¶
func NewClient(dailer Dailer, address, name string, delay int64, limit uint) *PingClient
NewClient returns a ping client with the specified options.
func (*PingClient) Next ¶
func (c *PingClient) Next() *pb.Ping
Next returns the next ping request in the sequence
func (*PingClient) Ping ¶
func (c *PingClient) Ping(addr string) (*pb.Pong, error)
Ping sends an Ping request to the server and awaits a response. Right now we create a new connection for every single ping.
func (*PingClient) PingMutualTLS ¶
func (c *PingClient) PingMutualTLS(addr string) (*pb.Pong, error)
PingMutualTLS is an alias for Ping. It is mostly here for benchmarking.
type PingServer ¶
PingServer responds to Ping requests and tracks the number of messages sent per sender (responding with the correct sequence).
func NewServer ¶
func NewServer() *PingServer
NewServer returns a ping server with specified options.
func (*PingServer) Serve ¶
func (s *PingServer) Serve(port uint) error
Serve ping requests from gRPC messages
func (*PingServer) ServeInsecure ¶
func (s *PingServer) ServeInsecure(port uint) error
ServeInsecure is a helper method for no server-side encryption. It is mostly here for benchmarking.
func (*PingServer) ServeMutualTLS ¶
func (s *PingServer) ServeMutualTLS(port uint) error
ServeMutualTLS is an alias for Serve. It is mostly here for benchmarking.
func (*PingServer) ServeTLS ¶
func (s *PingServer) ServeTLS(port uint) error
ServeTLS is a helper method for server-side encryption that does not expect client authentication or credentials. It is mostly here for benchmarking.