From 0547162586d9398adefed17eba5d939d5767799d Mon Sep 17 00:00:00 2001 From: John Brooks Date: Mon, 1 Aug 2016 20:58:10 -0600 Subject: [PATCH] Skeleton of RPC --- backend/backend.go | 22 ++++ backend/rpc.go | 47 ++++++++ cli/cli.go | 54 +++++++++ rpc/core.pb.go | 287 +++++++++++++++++++++++++++++++++++++++++++++ rpc/core.proto | 22 ++++ rpc/network.pb.go | 230 ++++++++++++++++++++++++++++++++++++ rpc/network.proto | 53 +++++++++ 7 files changed, 715 insertions(+) create mode 100644 backend/backend.go create mode 100644 backend/rpc.go create mode 100644 cli/cli.go create mode 100644 rpc/core.pb.go create mode 100644 rpc/core.proto create mode 100644 rpc/network.pb.go create mode 100644 rpc/network.proto diff --git a/backend/backend.go b/backend/backend.go new file mode 100644 index 0000000..a1614b7 --- /dev/null +++ b/backend/backend.go @@ -0,0 +1,22 @@ +package main + +import ( + rpc "github.com/special/ricochet-go/rpc" + "google.golang.org/grpc" + "log" + "net" +) + +const ( + defaultListener = "127.0.0.1:58281" +) + +func main() { + listener, err := net.Listen("tcp", defaultListener) + if err != nil { + log.Fatalf("listen failed: %v", err) + } + rpcServer := grpc.NewServer() + rpc.RegisterRicochetCoreServer(rpcServer, &RicochetCore{}) + rpcServer.Serve(listener) +} diff --git a/backend/rpc.go b/backend/rpc.go new file mode 100644 index 0000000..b46309d --- /dev/null +++ b/backend/rpc.go @@ -0,0 +1,47 @@ +package main + +import ( + "errors" + rpc "github.com/special/ricochet-go/rpc" + "golang.org/x/net/context" + "time" +) + +type RicochetCore struct { +} + +func (core *RicochetCore) GetServerStatus(ctx context.Context, req *rpc.ServerStatusRequest) (*rpc.ServerStatusReply, error) { + if req.RpcVersion != 1 { + return nil, errors.New("Unsupported RPC protocol version") + } + + return &rpc.ServerStatusReply{ + RpcVersion: 1, + ServerVersion: "0.0.0", + }, nil +} + +func (core *RicochetCore) MonitorNetwork(req *rpc.MonitorNetworkRequest, stream rpc.RicochetCore_MonitorNetworkServer) error { + status := &rpc.NetworkStatus{ + Control: &rpc.TorControlStatus{ + Status: rpc.TorControlStatus_ERROR, + ErrorMessage: "Not implemented", + }, + } + + for i := 0; i < 100; i++ { + if err := stream.Send(status); err != nil { + return err + } + time.Sleep(100 * time.Millisecond) + } + return nil +} + +func (core *RicochetCore) StartNetwork(ctx context.Context, req *rpc.StartNetworkRequest) (*rpc.NetworkStatus, error) { + return nil, errors.New("Not implemented") +} + +func (core *RicochetCore) StopNetwork(ctx context.Context, req *rpc.StopNetworkRequest) (*rpc.NetworkStatus, error) { + return nil, errors.New("Not implemented") +} diff --git a/cli/cli.go b/cli/cli.go new file mode 100644 index 0000000..a0645c2 --- /dev/null +++ b/cli/cli.go @@ -0,0 +1,54 @@ +package main + +import ( + rpc "github.com/special/ricochet-go/rpc" + "golang.org/x/net/context" + "google.golang.org/grpc" + "io" + "log" +) + +const ( + defaultAddress = "127.0.0.1:58281" +) + +func main() { + conn, err := grpc.Dial(defaultAddress, grpc.WithInsecure()) + if err != nil { + log.Fatalf("connection failed: %v", err) + } + defer conn.Close() + + c := rpc.NewRicochetCoreClient(conn) + + r, err := c.GetServerStatus(context.Background(), &rpc.ServerStatusRequest{ + RpcVersion: 1, + }) + if err != nil { + log.Fatalf("could not get status: %v", err) + } + log.Printf("get status result: %v", r) + + stream, err := c.MonitorNetwork(context.Background(), &rpc.MonitorNetworkRequest{}) + if err != nil { + log.Fatalf("could not start stream: %v", err) + } + + wait := make(chan struct{}) + go func() { + for { + resp, err := stream.Recv() + if err == io.EOF { + log.Printf("stream eof") + break + } + if err != nil { + log.Fatalf("stream error: %v", err) + } + log.Printf("stream says: %v", resp) + } + wait <- struct{}{} + }() + + <-wait +} diff --git a/rpc/core.pb.go b/rpc/core.pb.go new file mode 100644 index 0000000..1ced577 --- /dev/null +++ b/rpc/core.pb.go @@ -0,0 +1,287 @@ +// Code generated by protoc-gen-go. +// source: core.proto +// DO NOT EDIT! + +/* +Package ricochet is a generated protocol buffer package. + +It is generated from these files: + core.proto + network.proto + +It has these top-level messages: + ServerStatusRequest + ServerStatusReply + MonitorNetworkRequest + TorProcessStatus + TorControlStatus + TorConnectionStatus + NetworkStatus + StartNetworkRequest + StopNetworkRequest +*/ +package ricochet + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +import ( + context "golang.org/x/net/context" + grpc "google.golang.org/grpc" +) + +// 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.ProtoPackageIsVersion2 // please upgrade the proto package + +type ServerStatusRequest struct { + RpcVersion int32 `protobuf:"varint,1,opt,name=rpcVersion" json:"rpcVersion,omitempty"` +} + +func (m *ServerStatusRequest) Reset() { *m = ServerStatusRequest{} } +func (m *ServerStatusRequest) String() string { return proto.CompactTextString(m) } +func (*ServerStatusRequest) ProtoMessage() {} +func (*ServerStatusRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } + +type ServerStatusReply struct { + RpcVersion int32 `protobuf:"varint,1,opt,name=rpcVersion" json:"rpcVersion,omitempty"` + ServerVersion string `protobuf:"bytes,2,opt,name=serverVersion" json:"serverVersion,omitempty"` +} + +func (m *ServerStatusReply) Reset() { *m = ServerStatusReply{} } +func (m *ServerStatusReply) String() string { return proto.CompactTextString(m) } +func (*ServerStatusReply) ProtoMessage() {} +func (*ServerStatusReply) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } + +func init() { + proto.RegisterType((*ServerStatusRequest)(nil), "ricochet.ServerStatusRequest") + proto.RegisterType((*ServerStatusReply)(nil), "ricochet.ServerStatusReply") +} + +// 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.SupportPackageIsVersion3 + +// Client API for RicochetCore service + +type RicochetCoreClient interface { + GetServerStatus(ctx context.Context, in *ServerStatusRequest, opts ...grpc.CallOption) (*ServerStatusReply, error) + MonitorNetwork(ctx context.Context, in *MonitorNetworkRequest, opts ...grpc.CallOption) (RicochetCore_MonitorNetworkClient, error) + StartNetwork(ctx context.Context, in *StartNetworkRequest, opts ...grpc.CallOption) (*NetworkStatus, error) + StopNetwork(ctx context.Context, in *StopNetworkRequest, opts ...grpc.CallOption) (*NetworkStatus, error) +} + +type ricochetCoreClient struct { + cc *grpc.ClientConn +} + +func NewRicochetCoreClient(cc *grpc.ClientConn) RicochetCoreClient { + return &ricochetCoreClient{cc} +} + +func (c *ricochetCoreClient) GetServerStatus(ctx context.Context, in *ServerStatusRequest, opts ...grpc.CallOption) (*ServerStatusReply, error) { + out := new(ServerStatusReply) + err := grpc.Invoke(ctx, "/ricochet.RicochetCore/GetServerStatus", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *ricochetCoreClient) MonitorNetwork(ctx context.Context, in *MonitorNetworkRequest, opts ...grpc.CallOption) (RicochetCore_MonitorNetworkClient, error) { + stream, err := grpc.NewClientStream(ctx, &_RicochetCore_serviceDesc.Streams[0], c.cc, "/ricochet.RicochetCore/MonitorNetwork", opts...) + if err != nil { + return nil, err + } + x := &ricochetCoreMonitorNetworkClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type RicochetCore_MonitorNetworkClient interface { + Recv() (*NetworkStatus, error) + grpc.ClientStream +} + +type ricochetCoreMonitorNetworkClient struct { + grpc.ClientStream +} + +func (x *ricochetCoreMonitorNetworkClient) Recv() (*NetworkStatus, error) { + m := new(NetworkStatus) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *ricochetCoreClient) StartNetwork(ctx context.Context, in *StartNetworkRequest, opts ...grpc.CallOption) (*NetworkStatus, error) { + out := new(NetworkStatus) + err := grpc.Invoke(ctx, "/ricochet.RicochetCore/StartNetwork", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *ricochetCoreClient) StopNetwork(ctx context.Context, in *StopNetworkRequest, opts ...grpc.CallOption) (*NetworkStatus, error) { + out := new(NetworkStatus) + err := grpc.Invoke(ctx, "/ricochet.RicochetCore/StopNetwork", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// Server API for RicochetCore service + +type RicochetCoreServer interface { + GetServerStatus(context.Context, *ServerStatusRequest) (*ServerStatusReply, error) + MonitorNetwork(*MonitorNetworkRequest, RicochetCore_MonitorNetworkServer) error + StartNetwork(context.Context, *StartNetworkRequest) (*NetworkStatus, error) + StopNetwork(context.Context, *StopNetworkRequest) (*NetworkStatus, error) +} + +func RegisterRicochetCoreServer(s *grpc.Server, srv RicochetCoreServer) { + s.RegisterService(&_RicochetCore_serviceDesc, srv) +} + +func _RicochetCore_GetServerStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ServerStatusRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RicochetCoreServer).GetServerStatus(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ricochet.RicochetCore/GetServerStatus", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RicochetCoreServer).GetServerStatus(ctx, req.(*ServerStatusRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _RicochetCore_MonitorNetwork_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(MonitorNetworkRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(RicochetCoreServer).MonitorNetwork(m, &ricochetCoreMonitorNetworkServer{stream}) +} + +type RicochetCore_MonitorNetworkServer interface { + Send(*NetworkStatus) error + grpc.ServerStream +} + +type ricochetCoreMonitorNetworkServer struct { + grpc.ServerStream +} + +func (x *ricochetCoreMonitorNetworkServer) Send(m *NetworkStatus) error { + return x.ServerStream.SendMsg(m) +} + +func _RicochetCore_StartNetwork_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StartNetworkRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RicochetCoreServer).StartNetwork(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ricochet.RicochetCore/StartNetwork", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RicochetCoreServer).StartNetwork(ctx, req.(*StartNetworkRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _RicochetCore_StopNetwork_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StopNetworkRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RicochetCoreServer).StopNetwork(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ricochet.RicochetCore/StopNetwork", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RicochetCoreServer).StopNetwork(ctx, req.(*StopNetworkRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _RicochetCore_serviceDesc = grpc.ServiceDesc{ + ServiceName: "ricochet.RicochetCore", + HandlerType: (*RicochetCoreServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetServerStatus", + Handler: _RicochetCore_GetServerStatus_Handler, + }, + { + MethodName: "StartNetwork", + Handler: _RicochetCore_StartNetwork_Handler, + }, + { + MethodName: "StopNetwork", + Handler: _RicochetCore_StopNetwork_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "MonitorNetwork", + Handler: _RicochetCore_MonitorNetwork_Handler, + ServerStreams: true, + }, + }, + Metadata: fileDescriptor0, +} + +func init() { proto.RegisterFile("core.proto", fileDescriptor0) } + +var fileDescriptor0 = []byte{ + // 236 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0x4a, 0xce, 0x2f, 0x4a, + 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x28, 0xca, 0x4c, 0xce, 0x4f, 0xce, 0x48, 0x2d, + 0x91, 0xe2, 0xcd, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0x86, 0x48, 0x28, 0x99, 0x72, 0x09, 0x07, + 0xa7, 0x16, 0x95, 0xa5, 0x16, 0x05, 0x97, 0x24, 0x96, 0x94, 0x16, 0x07, 0xa5, 0x16, 0x96, 0xa6, + 0x16, 0x97, 0x08, 0xc9, 0x71, 0x71, 0x15, 0x15, 0x24, 0x87, 0xa5, 0x16, 0x15, 0x67, 0xe6, 0xe7, + 0x49, 0x30, 0x2a, 0x30, 0x6a, 0xb0, 0x06, 0x21, 0x89, 0x28, 0x45, 0x72, 0x09, 0xa2, 0x6a, 0x2b, + 0xc8, 0xa9, 0x24, 0xa4, 0x49, 0x48, 0x85, 0x8b, 0xb7, 0x18, 0xac, 0x09, 0xa6, 0x84, 0x09, 0xa8, + 0x84, 0x33, 0x08, 0x55, 0xd0, 0x68, 0x27, 0x13, 0x17, 0x4f, 0x10, 0xd4, 0xb5, 0xce, 0x40, 0x1f, + 0x08, 0xf9, 0x72, 0xf1, 0xbb, 0xa7, 0x96, 0x20, 0x5b, 0x27, 0x24, 0xab, 0x07, 0xf3, 0x8f, 0x1e, + 0x16, 0xd7, 0x4b, 0x49, 0xe3, 0x92, 0x06, 0xb9, 0xd2, 0x87, 0x8b, 0xcf, 0x37, 0x3f, 0x2f, 0xb3, + 0x24, 0xbf, 0xc8, 0x0f, 0x12, 0x12, 0x42, 0xf2, 0x08, 0xe5, 0xa8, 0x32, 0x30, 0xf3, 0xc4, 0x11, + 0x0a, 0xa0, 0x32, 0x10, 0x03, 0x0d, 0x18, 0x85, 0xdc, 0xb8, 0x78, 0x80, 0xec, 0xa2, 0x12, 0x98, + 0x59, 0xc8, 0x2e, 0x43, 0x12, 0x27, 0x64, 0x92, 0x90, 0x0b, 0x17, 0x77, 0x70, 0x49, 0x7e, 0x01, + 0xcc, 0x18, 0x19, 0x64, 0x63, 0xe0, 0xc2, 0x84, 0x4c, 0x49, 0x62, 0x03, 0x47, 0xaa, 0x31, 0x20, + 0x00, 0x00, 0xff, 0xff, 0x19, 0x90, 0x5f, 0x9e, 0xfb, 0x01, 0x00, 0x00, +} diff --git a/rpc/core.proto b/rpc/core.proto new file mode 100644 index 0000000..b104067 --- /dev/null +++ b/rpc/core.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; +package ricochet; + +import "network.proto"; + +service RicochetCore { + rpc GetServerStatus (ServerStatusRequest) returns (ServerStatusReply); + + rpc MonitorNetwork (MonitorNetworkRequest) returns (stream NetworkStatus); + rpc StartNetwork (StartNetworkRequest) returns (NetworkStatus); + rpc StopNetwork (StopNetworkRequest) returns (NetworkStatus); +} + +message ServerStatusRequest { + int32 rpcVersion = 1; +} + +message ServerStatusReply { + int32 rpcVersion = 1; + string serverVersion = 2; +} + diff --git a/rpc/network.pb.go b/rpc/network.pb.go new file mode 100644 index 0000000..76eda73 --- /dev/null +++ b/rpc/network.pb.go @@ -0,0 +1,230 @@ +// Code generated by protoc-gen-go. +// source: network.proto +// DO NOT EDIT! + +package ricochet + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +type TorProcessStatus_Status int32 + +const ( + TorProcessStatus_DISABLED TorProcessStatus_Status = 0 + TorProcessStatus_STOPPED TorProcessStatus_Status = 1 + TorProcessStatus_STARTING TorProcessStatus_Status = 2 + TorProcessStatus_RUNNING TorProcessStatus_Status = 3 +) + +var TorProcessStatus_Status_name = map[int32]string{ + 0: "DISABLED", + 1: "STOPPED", + 2: "STARTING", + 3: "RUNNING", +} +var TorProcessStatus_Status_value = map[string]int32{ + "DISABLED": 0, + "STOPPED": 1, + "STARTING": 2, + "RUNNING": 3, +} + +func (x TorProcessStatus_Status) String() string { + return proto.EnumName(TorProcessStatus_Status_name, int32(x)) +} +func (TorProcessStatus_Status) EnumDescriptor() ([]byte, []int) { return fileDescriptor1, []int{1, 0} } + +type TorControlStatus_Status int32 + +const ( + TorControlStatus_STOPPED TorControlStatus_Status = 0 + TorControlStatus_ERROR TorControlStatus_Status = 1 + TorControlStatus_CONNECTING TorControlStatus_Status = 2 + TorControlStatus_CONNECTED TorControlStatus_Status = 3 +) + +var TorControlStatus_Status_name = map[int32]string{ + 0: "STOPPED", + 1: "ERROR", + 2: "CONNECTING", + 3: "CONNECTED", +} +var TorControlStatus_Status_value = map[string]int32{ + "STOPPED": 0, + "ERROR": 1, + "CONNECTING": 2, + "CONNECTED": 3, +} + +func (x TorControlStatus_Status) String() string { + return proto.EnumName(TorControlStatus_Status_name, int32(x)) +} +func (TorControlStatus_Status) EnumDescriptor() ([]byte, []int) { return fileDescriptor1, []int{2, 0} } + +type TorConnectionStatus_Status int32 + +const ( + TorConnectionStatus_UNKNOWN TorConnectionStatus_Status = 0 + TorConnectionStatus_OFFLINE TorConnectionStatus_Status = 1 + TorConnectionStatus_BOOTSTRAPPING TorConnectionStatus_Status = 2 + TorConnectionStatus_READY TorConnectionStatus_Status = 3 +) + +var TorConnectionStatus_Status_name = map[int32]string{ + 0: "UNKNOWN", + 1: "OFFLINE", + 2: "BOOTSTRAPPING", + 3: "READY", +} +var TorConnectionStatus_Status_value = map[string]int32{ + "UNKNOWN": 0, + "OFFLINE": 1, + "BOOTSTRAPPING": 2, + "READY": 3, +} + +func (x TorConnectionStatus_Status) String() string { + return proto.EnumName(TorConnectionStatus_Status_name, int32(x)) +} +func (TorConnectionStatus_Status) EnumDescriptor() ([]byte, []int) { + return fileDescriptor1, []int{3, 0} +} + +type MonitorNetworkRequest struct { +} + +func (m *MonitorNetworkRequest) Reset() { *m = MonitorNetworkRequest{} } +func (m *MonitorNetworkRequest) String() string { return proto.CompactTextString(m) } +func (*MonitorNetworkRequest) ProtoMessage() {} +func (*MonitorNetworkRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{0} } + +type TorProcessStatus struct { + Status TorProcessStatus_Status `protobuf:"varint,1,opt,name=status,enum=ricochet.TorProcessStatus_Status" json:"status,omitempty"` + ErrorMessage string `protobuf:"bytes,2,opt,name=errorMessage" json:"errorMessage,omitempty"` +} + +func (m *TorProcessStatus) Reset() { *m = TorProcessStatus{} } +func (m *TorProcessStatus) String() string { return proto.CompactTextString(m) } +func (*TorProcessStatus) ProtoMessage() {} +func (*TorProcessStatus) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{1} } + +type TorControlStatus struct { + Status TorControlStatus_Status `protobuf:"varint,1,opt,name=status,enum=ricochet.TorControlStatus_Status" json:"status,omitempty"` + ErrorMessage string `protobuf:"bytes,2,opt,name=errorMessage" json:"errorMessage,omitempty"` + TorVersion string `protobuf:"bytes,10,opt,name=torVersion" json:"torVersion,omitempty"` +} + +func (m *TorControlStatus) Reset() { *m = TorControlStatus{} } +func (m *TorControlStatus) String() string { return proto.CompactTextString(m) } +func (*TorControlStatus) ProtoMessage() {} +func (*TorControlStatus) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{2} } + +type TorConnectionStatus struct { + Status TorConnectionStatus_Status `protobuf:"varint,1,opt,name=status,enum=ricochet.TorConnectionStatus_Status" json:"status,omitempty"` + BootstrapProgress string `protobuf:"bytes,10,opt,name=bootstrapProgress" json:"bootstrapProgress,omitempty"` +} + +func (m *TorConnectionStatus) Reset() { *m = TorConnectionStatus{} } +func (m *TorConnectionStatus) String() string { return proto.CompactTextString(m) } +func (*TorConnectionStatus) ProtoMessage() {} +func (*TorConnectionStatus) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{3} } + +type NetworkStatus struct { + Process *TorProcessStatus `protobuf:"bytes,1,opt,name=process" json:"process,omitempty"` + Control *TorControlStatus `protobuf:"bytes,2,opt,name=control" json:"control,omitempty"` + Connection *TorConnectionStatus `protobuf:"bytes,3,opt,name=connection" json:"connection,omitempty"` +} + +func (m *NetworkStatus) Reset() { *m = NetworkStatus{} } +func (m *NetworkStatus) String() string { return proto.CompactTextString(m) } +func (*NetworkStatus) ProtoMessage() {} +func (*NetworkStatus) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{4} } + +func (m *NetworkStatus) GetProcess() *TorProcessStatus { + if m != nil { + return m.Process + } + return nil +} + +func (m *NetworkStatus) GetControl() *TorControlStatus { + if m != nil { + return m.Control + } + return nil +} + +func (m *NetworkStatus) GetConnection() *TorConnectionStatus { + if m != nil { + return m.Connection + } + return nil +} + +type StartNetworkRequest struct { +} + +func (m *StartNetworkRequest) Reset() { *m = StartNetworkRequest{} } +func (m *StartNetworkRequest) String() string { return proto.CompactTextString(m) } +func (*StartNetworkRequest) ProtoMessage() {} +func (*StartNetworkRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{5} } + +type StopNetworkRequest struct { +} + +func (m *StopNetworkRequest) Reset() { *m = StopNetworkRequest{} } +func (m *StopNetworkRequest) String() string { return proto.CompactTextString(m) } +func (*StopNetworkRequest) ProtoMessage() {} +func (*StopNetworkRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{6} } + +func init() { + proto.RegisterType((*MonitorNetworkRequest)(nil), "ricochet.MonitorNetworkRequest") + proto.RegisterType((*TorProcessStatus)(nil), "ricochet.TorProcessStatus") + proto.RegisterType((*TorControlStatus)(nil), "ricochet.TorControlStatus") + proto.RegisterType((*TorConnectionStatus)(nil), "ricochet.TorConnectionStatus") + proto.RegisterType((*NetworkStatus)(nil), "ricochet.NetworkStatus") + proto.RegisterType((*StartNetworkRequest)(nil), "ricochet.StartNetworkRequest") + proto.RegisterType((*StopNetworkRequest)(nil), "ricochet.StopNetworkRequest") + proto.RegisterEnum("ricochet.TorProcessStatus_Status", TorProcessStatus_Status_name, TorProcessStatus_Status_value) + proto.RegisterEnum("ricochet.TorControlStatus_Status", TorControlStatus_Status_name, TorControlStatus_Status_value) + proto.RegisterEnum("ricochet.TorConnectionStatus_Status", TorConnectionStatus_Status_name, TorConnectionStatus_Status_value) +} + +func init() { proto.RegisterFile("network.proto", fileDescriptor1) } + +var fileDescriptor1 = []byte{ + // 431 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x9c, 0x93, 0xcf, 0xaf, 0xd2, 0x40, + 0x10, 0xc7, 0x5f, 0x1f, 0x91, 0xf7, 0x18, 0x28, 0x81, 0x45, 0x62, 0x63, 0xa2, 0xd1, 0x8d, 0x07, + 0x0f, 0xa6, 0x07, 0xf4, 0x62, 0xe2, 0xaf, 0x02, 0xc5, 0x10, 0x61, 0xdb, 0x6c, 0x8b, 0xc6, 0x23, + 0x34, 0x1b, 0x24, 0x9a, 0x6e, 0xdd, 0x2e, 0xf1, 0xef, 0xf2, 0xea, 0xd5, 0xff, 0xc0, 0xbf, 0xc8, + 0x6d, 0x77, 0x21, 0x6d, 0x8d, 0xc6, 0xbc, 0x13, 0xcc, 0xcc, 0x77, 0xa6, 0xf3, 0x99, 0x99, 0x05, + 0x3b, 0x65, 0xf2, 0x1b, 0x17, 0x9f, 0xdd, 0x4c, 0x70, 0xc9, 0xd1, 0xb5, 0x38, 0x24, 0x3c, 0xf9, + 0xc4, 0x24, 0xbe, 0x03, 0xe3, 0x35, 0x4f, 0x0f, 0x92, 0x0b, 0xa2, 0x15, 0x94, 0x7d, 0x3d, 0xb2, + 0x5c, 0xe2, 0xef, 0x16, 0x0c, 0x62, 0x2e, 0x42, 0xc1, 0x13, 0x96, 0xe7, 0x91, 0xdc, 0xca, 0x63, + 0x8e, 0x9e, 0x43, 0x3b, 0x2f, 0xff, 0x39, 0xd6, 0x03, 0xeb, 0x71, 0x7f, 0xf2, 0xd0, 0x3d, 0x15, + 0x72, 0x9b, 0x5a, 0x57, 0xff, 0x50, 0x93, 0x80, 0x30, 0xf4, 0x98, 0x10, 0x5c, 0xac, 0x95, 0x62, + 0xbb, 0x67, 0xce, 0xa5, 0x2a, 0xd0, 0xa1, 0x35, 0x1f, 0x7e, 0x05, 0x6d, 0xf3, 0xa1, 0x1e, 0x5c, + 0xcf, 0x97, 0x91, 0x37, 0x5d, 0xf9, 0xf3, 0xc1, 0x05, 0xea, 0xc2, 0x55, 0x14, 0x07, 0x61, 0xa8, + 0x0c, 0xab, 0x08, 0x45, 0xb1, 0x47, 0xe3, 0x25, 0x79, 0x3b, 0xb8, 0x2c, 0x42, 0x74, 0x43, 0x48, + 0x61, 0xb4, 0xf0, 0x2f, 0xdd, 0xf3, 0x8c, 0xa7, 0x52, 0xf0, 0x2f, 0xff, 0xd5, 0x73, 0x4d, 0x7b, + 0x83, 0x9e, 0xd1, 0x7d, 0x00, 0x35, 0xbc, 0xf7, 0x4c, 0xe4, 0x07, 0x9e, 0x3a, 0x50, 0x2a, 0x2a, + 0x1e, 0xfc, 0xfa, 0xcc, 0x54, 0xa1, 0xb8, 0x40, 0x1d, 0xb8, 0xe5, 0x53, 0x1a, 0x50, 0x05, 0xd4, + 0x07, 0x98, 0x05, 0x84, 0xf8, 0x33, 0x83, 0x64, 0x43, 0xc7, 0xd8, 0x4a, 0xd9, 0xc2, 0x3f, 0x2d, + 0x18, 0xe9, 0x46, 0x53, 0x96, 0x48, 0x55, 0xd2, 0x94, 0x7b, 0xd1, 0xe0, 0x7a, 0xd4, 0xe4, 0xaa, + 0xc9, 0x9b, 0x68, 0x4f, 0x60, 0xb8, 0xe3, 0x5c, 0xe6, 0x52, 0x6c, 0x33, 0xb5, 0xb7, 0xbd, 0x50, + 0x38, 0xa6, 0xfb, 0x3f, 0x03, 0xf8, 0x4d, 0x15, 0x62, 0x43, 0xde, 0x91, 0xe0, 0x03, 0xd1, 0x7b, + 0x09, 0x16, 0x8b, 0xd5, 0x92, 0xf8, 0x0a, 0x63, 0x08, 0xf6, 0x34, 0x08, 0xe2, 0x28, 0xa6, 0x5e, + 0x18, 0x6a, 0x12, 0x05, 0x49, 0x7d, 0x6f, 0xfe, 0x51, 0x51, 0xfc, 0xb0, 0xc0, 0x36, 0x17, 0x66, + 0x2a, 0x3d, 0x83, 0xab, 0x4c, 0x1f, 0x4c, 0x09, 0xd0, 0x9d, 0xdc, 0xfd, 0xfb, 0x31, 0xd1, 0x93, + 0xb4, 0xc8, 0x4a, 0xf4, 0xca, 0xca, 0x6d, 0x34, 0xb3, 0x6a, 0xeb, 0xa4, 0x27, 0x29, 0x7a, 0x09, + 0x90, 0x9c, 0x07, 0xe2, 0xb4, 0xca, 0xc4, 0x7b, 0xff, 0x9c, 0x17, 0xad, 0x24, 0xe0, 0x31, 0x8c, + 0x94, 0x57, 0xc8, 0xc6, 0x13, 0xb9, 0x0d, 0x28, 0x92, 0x3c, 0xab, 0x7b, 0x77, 0xed, 0xf2, 0x89, + 0x3d, 0xfd, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xb1, 0xce, 0xd8, 0xfb, 0x73, 0x03, 0x00, 0x00, +} diff --git a/rpc/network.proto b/rpc/network.proto new file mode 100644 index 0000000..7192a86 --- /dev/null +++ b/rpc/network.proto @@ -0,0 +1,53 @@ +syntax = "proto3"; +package ricochet; + +message MonitorNetworkRequest { +} + +message TorProcessStatus { + enum Status { + DISABLED = 0; + STOPPED = 1; + STARTING = 2; + RUNNING = 3; + } + Status status = 1; + string errorMessage = 2; +} + +message TorControlStatus { + enum Status { + STOPPED = 0; + ERROR = 1; + CONNECTING = 2; + CONNECTED = 3; + } + Status status = 1; + string errorMessage = 2; + + string torVersion = 10; +} + +message TorConnectionStatus { + enum Status { + UNKNOWN = 0; + OFFLINE = 1; + BOOTSTRAPPING = 2; + READY = 3; + } + Status status = 1; + + string bootstrapProgress = 10; +} + +message NetworkStatus { + TorProcessStatus process = 1; + TorControlStatus control = 2; + TorConnectionStatus connection = 3; +} + +message StartNetworkRequest { +} + +message StopNetworkRequest { +}