mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 00:24:40 +01:00
started working on ui gRPC protocol
This commit is contained in:
parent
9887fc936d
commit
6659350085
5 changed files with 311 additions and 3 deletions
11
Makefile
11
Makefile
|
@ -1,7 +1,12 @@
|
|||
all: osd
|
||||
all: protocol osd
|
||||
|
||||
protocol:
|
||||
@cd ui.proto && make
|
||||
|
||||
osd:
|
||||
go build -o osd github.com/evilsocket/opensnitch/daemon
|
||||
@cd daemon && make && mv daemon ../osd
|
||||
|
||||
clean:
|
||||
rm -rf osd ui
|
||||
@cd ui.proto && make clean
|
||||
@cd daemon && make clean
|
||||
@rm -rf osd
|
||||
|
|
7
daemon/Makefile
Normal file
7
daemon/Makefile
Normal file
|
@ -0,0 +1,7 @@
|
|||
all: daemon
|
||||
|
||||
daemon:
|
||||
@go build .
|
||||
|
||||
clean:
|
||||
@rm -rf daemon
|
5
ui.proto/Makefile
Normal file
5
ui.proto/Makefile
Normal file
|
@ -0,0 +1,5 @@
|
|||
all:
|
||||
protoc -I. ui.proto --go_out=plugins=grpc:.
|
||||
|
||||
clean:
|
||||
@rm -rf ui.pb.go
|
264
ui.proto/ui.pb.go
Normal file
264
ui.proto/ui.pb.go
Normal file
|
@ -0,0 +1,264 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: ui.proto
|
||||
|
||||
/*
|
||||
Package ui is a generated protocol buffer package.
|
||||
|
||||
It is generated from these files:
|
||||
ui.proto
|
||||
|
||||
It has these top-level messages:
|
||||
RuleRequest
|
||||
RuleReply
|
||||
*/
|
||||
package ui
|
||||
|
||||
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 RuleRequest struct {
|
||||
Protocol string `protobuf:"bytes,1,opt,name=protocol" json:"protocol,omitempty"`
|
||||
SrcIp string `protobuf:"bytes,2,opt,name=src_ip,json=srcIp" json:"src_ip,omitempty"`
|
||||
SrcPort uint32 `protobuf:"varint,3,opt,name=src_port,json=srcPort" json:"src_port,omitempty"`
|
||||
DstIp string `protobuf:"bytes,4,opt,name=dst_ip,json=dstIp" json:"dst_ip,omitempty"`
|
||||
DstHost string `protobuf:"bytes,5,opt,name=dst_host,json=dstHost" json:"dst_host,omitempty"`
|
||||
DstPort uint32 `protobuf:"varint,6,opt,name=dst_port,json=dstPort" json:"dst_port,omitempty"`
|
||||
ProcessId uint32 `protobuf:"varint,7,opt,name=process_id,json=processId" json:"process_id,omitempty"`
|
||||
ProcessPath string `protobuf:"bytes,8,opt,name=process_path,json=processPath" json:"process_path,omitempty"`
|
||||
ProcessArgs []string `protobuf:"bytes,9,rep,name=process_args,json=processArgs" json:"process_args,omitempty"`
|
||||
}
|
||||
|
||||
func (m *RuleRequest) Reset() { *m = RuleRequest{} }
|
||||
func (m *RuleRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*RuleRequest) ProtoMessage() {}
|
||||
func (*RuleRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||
|
||||
func (m *RuleRequest) GetProtocol() string {
|
||||
if m != nil {
|
||||
return m.Protocol
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *RuleRequest) GetSrcIp() string {
|
||||
if m != nil {
|
||||
return m.SrcIp
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *RuleRequest) GetSrcPort() uint32 {
|
||||
if m != nil {
|
||||
return m.SrcPort
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *RuleRequest) GetDstIp() string {
|
||||
if m != nil {
|
||||
return m.DstIp
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *RuleRequest) GetDstHost() string {
|
||||
if m != nil {
|
||||
return m.DstHost
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *RuleRequest) GetDstPort() uint32 {
|
||||
if m != nil {
|
||||
return m.DstPort
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *RuleRequest) GetProcessId() uint32 {
|
||||
if m != nil {
|
||||
return m.ProcessId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *RuleRequest) GetProcessPath() string {
|
||||
if m != nil {
|
||||
return m.ProcessPath
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *RuleRequest) GetProcessArgs() []string {
|
||||
if m != nil {
|
||||
return m.ProcessArgs
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type RuleReply struct {
|
||||
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
|
||||
Action string `protobuf:"bytes,2,opt,name=action" json:"action,omitempty"`
|
||||
Duration string `protobuf:"bytes,3,opt,name=duration" json:"duration,omitempty"`
|
||||
What string `protobuf:"bytes,4,opt,name=what" json:"what,omitempty"`
|
||||
With string `protobuf:"bytes,5,opt,name=with" json:"with,omitempty"`
|
||||
}
|
||||
|
||||
func (m *RuleReply) Reset() { *m = RuleReply{} }
|
||||
func (m *RuleReply) String() string { return proto.CompactTextString(m) }
|
||||
func (*RuleReply) ProtoMessage() {}
|
||||
func (*RuleReply) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
|
||||
|
||||
func (m *RuleReply) GetName() string {
|
||||
if m != nil {
|
||||
return m.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *RuleReply) GetAction() string {
|
||||
if m != nil {
|
||||
return m.Action
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *RuleReply) GetDuration() string {
|
||||
if m != nil {
|
||||
return m.Duration
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *RuleReply) GetWhat() string {
|
||||
if m != nil {
|
||||
return m.What
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *RuleReply) GetWith() string {
|
||||
if m != nil {
|
||||
return m.With
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*RuleRequest)(nil), "ui.RuleRequest")
|
||||
proto.RegisterType((*RuleReply)(nil), "ui.RuleReply")
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
// Client API for UI service
|
||||
|
||||
type UIClient interface {
|
||||
AskRule(ctx context.Context, in *RuleRequest, opts ...grpc.CallOption) (*RuleReply, error)
|
||||
}
|
||||
|
||||
type uIClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewUIClient(cc *grpc.ClientConn) UIClient {
|
||||
return &uIClient{cc}
|
||||
}
|
||||
|
||||
func (c *uIClient) AskRule(ctx context.Context, in *RuleRequest, opts ...grpc.CallOption) (*RuleReply, error) {
|
||||
out := new(RuleReply)
|
||||
err := grpc.Invoke(ctx, "/ui.UI/AskRule", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for UI service
|
||||
|
||||
type UIServer interface {
|
||||
AskRule(context.Context, *RuleRequest) (*RuleReply, error)
|
||||
}
|
||||
|
||||
func RegisterUIServer(s *grpc.Server, srv UIServer) {
|
||||
s.RegisterService(&_UI_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _UI_AskRule_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(RuleRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UIServer).AskRule(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/ui.UI/AskRule",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UIServer).AskRule(ctx, req.(*RuleRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _UI_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "ui.UI",
|
||||
HandlerType: (*UIServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "AskRule",
|
||||
Handler: _UI_AskRule_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "ui.proto",
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("ui.proto", fileDescriptor0) }
|
||||
|
||||
var fileDescriptor0 = []byte{
|
||||
// 300 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x91, 0x4f, 0x4b, 0xc3, 0x40,
|
||||
0x10, 0xc5, 0x6d, 0xda, 0xe6, 0xcf, 0xd4, 0x22, 0x2c, 0x28, 0x6b, 0x41, 0xa8, 0x3d, 0x15, 0x84,
|
||||
0x82, 0xfa, 0x09, 0x7a, 0xb3, 0xb7, 0x12, 0xf0, 0x5c, 0xd6, 0x6c, 0x68, 0x16, 0x63, 0x77, 0xdd,
|
||||
0x99, 0x20, 0xc5, 0xcf, 0xe0, 0x77, 0x96, 0x9d, 0x6c, 0xb5, 0xb7, 0x99, 0xf7, 0xdb, 0xf7, 0x48,
|
||||
0xde, 0x40, 0xde, 0x99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, 0x7c, 0x35, 0x8a, 0x62, 0x09, 0x3c, 0xb3, 0x66, 0xa8, 0x89, 0xff, 0xcf, 0xf3, 0xd3,
|
||||
0x23, 0x24, 0xaf, 0x1b, 0xf1, 0x00, 0xd9, 0x1a, 0xdf, 0xc3, 0x57, 0x88, 0xab, 0x55, 0x67, 0x56,
|
||||
0x67, 0xe7, 0x99, 0x4d, 0xff, 0x05, 0xd7, 0x1e, 0x17, 0x17, 0x6f, 0x29, 0x5f, 0xe7, 0xf9, 0x37,
|
||||
0x00, 0x00, 0xff, 0xff, 0xb5, 0x2d, 0x32, 0xfb, 0xd6, 0x01, 0x00, 0x00,
|
||||
}
|
27
ui.proto/ui.proto
Normal file
27
ui.proto/ui.proto
Normal file
|
@ -0,0 +1,27 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package ui;
|
||||
|
||||
service UI {
|
||||
rpc AskRule (RuleRequest) returns (RuleReply) {}
|
||||
}
|
||||
|
||||
message RuleRequest {
|
||||
string protocol = 1;
|
||||
string src_ip = 2;
|
||||
uint32 src_port = 3;
|
||||
string dst_ip = 4;
|
||||
string dst_host = 5;
|
||||
uint32 dst_port = 6;
|
||||
uint32 process_id = 7;
|
||||
string process_path = 8;
|
||||
repeated string process_args = 9;
|
||||
}
|
||||
|
||||
message RuleReply {
|
||||
string name = 1;
|
||||
string action = 2;
|
||||
string duration = 3;
|
||||
string what = 4;
|
||||
string with = 5;
|
||||
}
|
Loading…
Add table
Reference in a new issue