initial handshake
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
commit
4c8aa9909f
10 changed files with 564 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
*~
|
||||||
|
handshake
|
||||||
|
vendor/
|
17
Makefile
Normal file
17
Makefile
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
PACKAGES=$(shell go list ./... | grep -v /vendor/)
|
||||||
|
REVISION=$(shell git rev-parse HEAD)
|
||||||
|
DEBUG=0
|
||||||
|
|
||||||
|
ifeq ($(DEBUG),1)
|
||||||
|
D =
|
||||||
|
else
|
||||||
|
D = @
|
||||||
|
endif
|
||||||
|
|
||||||
|
all: build
|
||||||
|
|
||||||
|
protos:
|
||||||
|
$(D)protobuild --quiet ${PACKAGES}
|
||||||
|
|
||||||
|
build:
|
||||||
|
$(D)CGO_ENABLED=0 go build -v -ldflags '-extldflags "-static"' .
|
46
Protobuild.toml
Normal file
46
Protobuild.toml
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
version = "unstable"
|
||||||
|
|
||||||
|
generator = "gogo"
|
||||||
|
|
||||||
|
# Plugins allows one to specify one or more plugins for use in generation.
|
||||||
|
#
|
||||||
|
# The common example grpc is provided below.
|
||||||
|
plugins = ["grpc"]
|
||||||
|
|
||||||
|
# Control protoc include paths. Below are usually some good defaults, but feel
|
||||||
|
# free to try it without them if it works for your project.
|
||||||
|
[includes]
|
||||||
|
# Include paths that will be added before all others. Typically, you want to
|
||||||
|
# treat the root of the project as an include, but this may not be necessary.
|
||||||
|
#
|
||||||
|
# "." is included by default
|
||||||
|
before = ["."]
|
||||||
|
|
||||||
|
# Paths that should be treated as include roots in relation to the vendor
|
||||||
|
# directory. These will be calculated with the vendor directory nearest the
|
||||||
|
# target package.
|
||||||
|
#
|
||||||
|
# With the example below, we import the gogo protobufs from the vendor
|
||||||
|
# directory.
|
||||||
|
#
|
||||||
|
# This is empty by default.
|
||||||
|
vendored = ["github.com/gogo/protobuf", "github.com/gogo/googleapis"]
|
||||||
|
|
||||||
|
# Paths that will be added untouched to the end of the includes. We use
|
||||||
|
# `/usr/local/include` to pickup the common install location of protobuf.
|
||||||
|
# This is the default.
|
||||||
|
# after = ["usr/local/include"]
|
||||||
|
|
||||||
|
# This section let's us map protobuf imports to Go packages. These will become
|
||||||
|
# `-M` directives in the call to the go protobuf generator.
|
||||||
|
#
|
||||||
|
# We have a few examples to map packages from the examples.
|
||||||
|
[packages]
|
||||||
|
"gogoproto/gogo.proto" = "github.com/gogo/protobuf/gogoproto"
|
||||||
|
"google/api/annotations.proto" = "github.com/gogo/googleapis"
|
||||||
|
"google/api/http.proto" = "github.com/gogo/googleapis"
|
||||||
|
"google/protobuf/descriptor.proto" = "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
|
||||||
|
"google/protobuf/timestamp.proto" = "github.com/gogo/protobuf/types"
|
||||||
|
"google/protobuf/duration.proto" = "github.com/gogo/protobuf/types"
|
||||||
|
"google/protobuf/any.proto" = "github.com/gogo/protobuf/types"
|
||||||
|
"google/protobuf/empty.proto" = "github.com/gogo/protobuf/types"
|
1
api/v1/doc.go
Normal file
1
api/v1/doc.go
Normal file
|
@ -0,0 +1 @@
|
||||||
|
package v1
|
250
api/v1/handshake.pb.go
Normal file
250
api/v1/handshake.pb.go
Normal file
|
@ -0,0 +1,250 @@
|
||||||
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
|
// source: git.thisco.de/vbatts/handshake/api/v1/handshake.proto
|
||||||
|
|
||||||
|
package v1
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "context"
|
||||||
|
fmt "fmt"
|
||||||
|
proto "github.com/gogo/protobuf/proto"
|
||||||
|
grpc "google.golang.org/grpc"
|
||||||
|
codes "google.golang.org/grpc/codes"
|
||||||
|
status "google.golang.org/grpc/status"
|
||||||
|
math "math"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var _ = proto.Marshal
|
||||||
|
var _ = fmt.Errorf
|
||||||
|
var _ = math.Inf
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the proto package it is being compiled against.
|
||||||
|
// A compilation error at this line likely means your copy of the
|
||||||
|
// proto package needs to be updated.
|
||||||
|
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||||
|
|
||||||
|
type Request struct {
|
||||||
|
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||||
|
Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"`
|
||||||
|
Pubkey string `protobuf:"bytes,3,opt,name=pubkey,proto3" json:"pubkey,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Request) Reset() { *m = Request{} }
|
||||||
|
func (m *Request) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*Request) ProtoMessage() {}
|
||||||
|
func (*Request) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_7562d4bb73541a2a, []int{0}
|
||||||
|
}
|
||||||
|
func (m *Request) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_Request.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_Request.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *Request) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_Request.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *Request) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_Request.Size(m)
|
||||||
|
}
|
||||||
|
func (m *Request) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_Request.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_Request proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *Request) GetID() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.ID
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Request) GetMsg() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Msg
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Request) GetPubkey() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Pubkey
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type Response struct {
|
||||||
|
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||||
|
Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"`
|
||||||
|
Pubkey string `protobuf:"bytes,3,opt,name=pubkey,proto3" json:"pubkey,omitempty"`
|
||||||
|
Challenge string `protobuf:"bytes,4,opt,name=challenge,proto3" json:"challenge,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Response) Reset() { *m = Response{} }
|
||||||
|
func (m *Response) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*Response) ProtoMessage() {}
|
||||||
|
func (*Response) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_7562d4bb73541a2a, []int{1}
|
||||||
|
}
|
||||||
|
func (m *Response) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_Response.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_Response.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *Response) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_Response.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *Response) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_Response.Size(m)
|
||||||
|
}
|
||||||
|
func (m *Response) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_Response.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_Response proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *Response) GetID() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.ID
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Response) GetMsg() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Msg
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Response) GetPubkey() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Pubkey
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Response) GetChallenge() string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Challenge
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterType((*Request)(nil), "de.thisco.vbatts.handshake.v1.Request")
|
||||||
|
proto.RegisterType((*Response)(nil), "de.thisco.vbatts.handshake.v1.Response")
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterFile("git.thisco.de/vbatts/handshake/api/v1/handshake.proto", fileDescriptor_7562d4bb73541a2a)
|
||||||
|
}
|
||||||
|
|
||||||
|
var fileDescriptor_7562d4bb73541a2a = []byte{
|
||||||
|
// 243 bytes of a gzipped FileDescriptorProto
|
||||||
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x4d, 0xcf, 0x2c, 0xd1,
|
||||||
|
0x2b, 0xc9, 0xc8, 0x2c, 0x4e, 0xce, 0xd7, 0x4b, 0x49, 0xd5, 0x2f, 0x4b, 0x4a, 0x2c, 0x29, 0x29,
|
||||||
|
0xd6, 0xcf, 0x48, 0xcc, 0x4b, 0x29, 0xce, 0x48, 0xcc, 0x4e, 0xd5, 0x4f, 0x2c, 0xc8, 0xd4, 0x2f,
|
||||||
|
0x33, 0x44, 0x08, 0xe8, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0xc9, 0xa6, 0xa4, 0xc2, 0x74, 0x41,
|
||||||
|
0xb4, 0xe8, 0x21, 0x54, 0x94, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x55, 0xea, 0x83,
|
||||||
|
0x58, 0x10, 0x4d, 0x4a, 0xde, 0x5c, 0xec, 0x41, 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25, 0x42, 0x62,
|
||||||
|
0x5c, 0x4c, 0x99, 0x29, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x4e, 0x6c, 0x8f, 0xee, 0xc9, 0x33,
|
||||||
|
0x79, 0xba, 0x04, 0x31, 0x65, 0xa6, 0x08, 0x09, 0x70, 0x31, 0xe7, 0x16, 0xa7, 0x4b, 0x30, 0x81,
|
||||||
|
0x24, 0x82, 0x40, 0x4c, 0x21, 0x31, 0x2e, 0xb6, 0x82, 0xd2, 0xa4, 0xec, 0xd4, 0x4a, 0x09, 0x66,
|
||||||
|
0xb0, 0x20, 0x94, 0xa7, 0x94, 0xc5, 0xc5, 0x11, 0x94, 0x5a, 0x5c, 0x90, 0x9f, 0x57, 0x9c, 0x4a,
|
||||||
|
0xb9, 0x69, 0x42, 0x32, 0x5c, 0x9c, 0xc9, 0x19, 0x89, 0x39, 0x39, 0xa9, 0x79, 0xe9, 0xa9, 0x12,
|
||||||
|
0x2c, 0x60, 0x29, 0x84, 0x80, 0x51, 0x2a, 0x17, 0xa7, 0x07, 0xcc, 0x7b, 0x42, 0x11, 0x5c, 0xac,
|
||||||
|
0x1e, 0xa9, 0x39, 0x39, 0xf9, 0x42, 0x6a, 0x7a, 0x78, 0x03, 0x41, 0x0f, 0xea, 0x57, 0x29, 0x75,
|
||||||
|
0x82, 0xea, 0x20, 0xde, 0x70, 0xd2, 0x8a, 0xd2, 0x20, 0x2a, 0x36, 0xac, 0xcb, 0x0c, 0x23, 0x18,
|
||||||
|
0x92, 0xd8, 0xc0, 0x81, 0x6a, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xae, 0xe7, 0x8c, 0x19, 0xc2,
|
||||||
|
0x01, 0x00, 0x00,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var _ context.Context
|
||||||
|
var _ grpc.ClientConn
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the grpc package it is being compiled against.
|
||||||
|
const _ = grpc.SupportPackageIsVersion4
|
||||||
|
|
||||||
|
// HandshakeClient is the client API for Handshake service.
|
||||||
|
//
|
||||||
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
||||||
|
type HandshakeClient interface {
|
||||||
|
Hello(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type handshakeClient struct {
|
||||||
|
cc *grpc.ClientConn
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewHandshakeClient(cc *grpc.ClientConn) HandshakeClient {
|
||||||
|
return &handshakeClient{cc}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *handshakeClient) Hello(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) {
|
||||||
|
out := new(Response)
|
||||||
|
err := c.cc.Invoke(ctx, "/de.thisco.vbatts.handshake.v1.Handshake/Hello", in, out, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// HandshakeServer is the server API for Handshake service.
|
||||||
|
type HandshakeServer interface {
|
||||||
|
Hello(context.Context, *Request) (*Response, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnimplementedHandshakeServer can be embedded to have forward compatible implementations.
|
||||||
|
type UnimplementedHandshakeServer struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*UnimplementedHandshakeServer) Hello(ctx context.Context, req *Request) (*Response, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method Hello not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterHandshakeServer(s *grpc.Server, srv HandshakeServer) {
|
||||||
|
s.RegisterService(&_Handshake_serviceDesc, srv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _Handshake_Hello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(Request)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(HandshakeServer).Hello(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: "/de.thisco.vbatts.handshake.v1.Handshake/Hello",
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(HandshakeServer).Hello(ctx, req.(*Request))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
var _Handshake_serviceDesc = grpc.ServiceDesc{
|
||||||
|
ServiceName: "de.thisco.vbatts.handshake.v1.Handshake",
|
||||||
|
HandlerType: (*HandshakeServer)(nil),
|
||||||
|
Methods: []grpc.MethodDesc{
|
||||||
|
{
|
||||||
|
MethodName: "Hello",
|
||||||
|
Handler: _Handshake_Hello_Handler,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Streams: []grpc.StreamDesc{},
|
||||||
|
Metadata: "git.thisco.de/vbatts/handshake/api/v1/handshake.proto",
|
||||||
|
}
|
25
api/v1/handshake.proto
Normal file
25
api/v1/handshake.proto
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package de.thisco.vbatts.handshake.v1;
|
||||||
|
|
||||||
|
import weak "gogoproto/gogo.proto";
|
||||||
|
//import "google/protobuf/empty.proto";
|
||||||
|
|
||||||
|
option go_package = "git.thisco.de/vbatts/handshake/api/v1;v1";
|
||||||
|
|
||||||
|
service Handshake {
|
||||||
|
rpc Hello(Request) returns (Response);
|
||||||
|
}
|
||||||
|
|
||||||
|
message Request {
|
||||||
|
string id = 1 [(gogoproto.customname) = "ID"];
|
||||||
|
string msg = 2;
|
||||||
|
string pubkey = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Response {
|
||||||
|
string id = 1 [(gogoproto.customname) = "ID"];
|
||||||
|
string msg = 2;
|
||||||
|
string pubkey = 3;
|
||||||
|
string challenge = 4;
|
||||||
|
}
|
12
go.mod
Normal file
12
go.mod
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
module git.thisco.de/vbatts/handshake
|
||||||
|
|
||||||
|
go 1.15
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/gogo/googleapis v1.4.0
|
||||||
|
github.com/gogo/protobuf v1.3.1
|
||||||
|
github.com/pkg/errors v0.9.1
|
||||||
|
github.com/sirupsen/logrus v1.7.0
|
||||||
|
github.com/urfave/cli v1.22.4
|
||||||
|
google.golang.org/grpc v1.33.0
|
||||||
|
)
|
80
go.sum
Normal file
80
go.sum
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
|
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||||
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
|
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
|
||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
|
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||||
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
|
github.com/gogo/googleapis v1.4.0 h1:zgVt4UpGxcqVOw97aRGxT4svlcmdK35fynLNctY32zI=
|
||||||
|
github.com/gogo/googleapis v1.4.0/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c=
|
||||||
|
github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
|
||||||
|
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
|
||||||
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
|
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=
|
||||||
|
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||||
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
|
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||||
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
|
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
|
||||||
|
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
|
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
|
||||||
|
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||||
|
github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
|
||||||
|
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||||
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
|
github.com/urfave/cli v1.22.4 h1:u7tSpNPPswAFymm8IehJhy4uJMlUuU/GmqSkvJ1InXA=
|
||||||
|
github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
|
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
|
||||||
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
|
||||||
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||||
|
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||||
|
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
|
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||||
|
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE=
|
||||||
|
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||||
|
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||||
|
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||||
|
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||||
|
google.golang.org/grpc v1.33.0 h1:IBKSUNL2uBS2DkJBncPP+TwT0sp9tgA8A75NjHt6umg=
|
||||||
|
google.golang.org/grpc v1.33.0/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
117
main.go
Normal file
117
main.go
Normal file
|
@ -0,0 +1,117 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"net"
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
|
v1 "git.thisco.de/vbatts/handshake/api/v1"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
"github.com/urfave/cli"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
app := cli.NewApp()
|
||||||
|
app.Name = "handshake"
|
||||||
|
app.Flags = []cli.Flag{
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "address,a",
|
||||||
|
Usage: "server address",
|
||||||
|
Value: "0.0.0.0:1111",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
app.Commands = []cli.Command{
|
||||||
|
serverCommand,
|
||||||
|
clientCommand,
|
||||||
|
}
|
||||||
|
app.Before = func(clix *cli.Context) error {
|
||||||
|
if clix.GlobalBool("debug") {
|
||||||
|
logrus.SetLevel(logrus.DebugLevel)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if err := app.Run(os.Args); err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var serverCommand = cli.Command{
|
||||||
|
Name: "server",
|
||||||
|
Action: func(clix *cli.Context) error {
|
||||||
|
var (
|
||||||
|
address = clix.GlobalString("address")
|
||||||
|
)
|
||||||
|
|
||||||
|
gs := grpc.NewServer()
|
||||||
|
logrus.Debug("setting up gRPC service")
|
||||||
|
v1.RegisterHandshakeServer(gs, &HandshakeServer{})
|
||||||
|
|
||||||
|
signals := make(chan os.Signal, 32)
|
||||||
|
signal.Notify(signals, syscall.SIGTERM, syscall.SIGINT)
|
||||||
|
go func() {
|
||||||
|
<-signals
|
||||||
|
gs.Stop()
|
||||||
|
}()
|
||||||
|
l, err := net.Listen("tcp", address)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "listen tcp")
|
||||||
|
}
|
||||||
|
defer l.Close()
|
||||||
|
|
||||||
|
logrus.Infof("listening on %q", address)
|
||||||
|
return gs.Serve(l)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var clientCommand = cli.Command{
|
||||||
|
Name: "client",
|
||||||
|
Action: func(clix *cli.Context) error {
|
||||||
|
var (
|
||||||
|
address = clix.GlobalString("address")
|
||||||
|
)
|
||||||
|
conn, err := grpc.Dial(address, grpc.WithInsecure())
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "dialing server")
|
||||||
|
}
|
||||||
|
defer conn.Close()
|
||||||
|
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
signals := make(chan os.Signal)
|
||||||
|
signal.Notify(signals, syscall.SIGTERM, syscall.SIGINT)
|
||||||
|
go func() {
|
||||||
|
<-signals
|
||||||
|
cancel()
|
||||||
|
}()
|
||||||
|
client := v1.NewHandshakeClient(conn)
|
||||||
|
req := v1.Request{
|
||||||
|
Pubkey: "facecafe",
|
||||||
|
Msg: "hello",
|
||||||
|
}
|
||||||
|
resp, err := client.Hello(ctx, &req)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "client hello")
|
||||||
|
}
|
||||||
|
logrus.Infof("pubkey: %q; challenge: %q", resp.Pubkey, resp.Msg)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
type HandshakeServer struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (hs *HandshakeServer) Hello(ctx context.Context, req *v1.Request) (*v1.Response, error) {
|
||||||
|
logrus.Infof("pubkey: %q", req.Pubkey)
|
||||||
|
resp := v1.Response{
|
||||||
|
Pubkey: "deadbeef",
|
||||||
|
Msg: fmt.Sprintf("did you say %q?", req.Msg),
|
||||||
|
}
|
||||||
|
|
||||||
|
//return nil, errors.New("not implemented")
|
||||||
|
return &resp, nil
|
||||||
|
}
|
13
proto.go
Normal file
13
proto.go
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
// go modules are not currently detecting dependencies that are defined in
|
||||||
|
// .proto files, this is a workaround to allow them to be defined and vendored
|
||||||
|
|
||||||
|
import (
|
||||||
|
// google/api is imported for generating protos
|
||||||
|
_ "github.com/gogo/googleapis/google/api"
|
||||||
|
// protobuf/gogoproto is imported for generating protos
|
||||||
|
_ "github.com/gogo/protobuf/gogoproto"
|
||||||
|
// protobuf/proto is imported for generating protos
|
||||||
|
_ "github.com/gogo/protobuf/proto"
|
||||||
|
)
|
Loading…
Reference in a new issue