proto

package
v0.0.0-...-25bf8ac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultIPMask = NewIPMask(32, 64)
View Source
var File_iprep_proto protoreflect.FileDescriptor
View Source
var IpRep_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "iprep.IpRep",
	HandlerType: (*IpRepServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Submit",
			Handler:    _IpRep_Submit_Handler,
		},
		{
			MethodName: "GetScore",
			Handler:    _IpRep_GetScore_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "GetAllScores",
			Handler:       _IpRep_GetAllScores_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "iprep.proto",
}

IpRep_ServiceDesc is the grpc.ServiceDesc for IpRep service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterIpRepServer

func RegisterIpRepServer(s grpc.ServiceRegistrar, srv IpRepServer)

Types

type Aggregate

type Aggregate struct {
	ByType []*AggregateTypeEntry `protobuf:"bytes,1,rep,name=by_type,json=byType,proto3" json:"by_type,omitempty"`
	// contains filtered or unexported fields
}

func MakeAggregate

func MakeAggregate(events []*Event) *Aggregate

MakeAggregate builds an Aggregate out of Events. Event details are lost in the aggregate.

func (*Aggregate) AddEvent

func (a *Aggregate) AddEvent(e *Event)

func (*Aggregate) Descriptor deprecated

func (*Aggregate) Descriptor() ([]byte, []int)

Deprecated: Use Aggregate.ProtoReflect.Descriptor instead.

func (*Aggregate) GetByType

func (x *Aggregate) GetByType() []*AggregateTypeEntry

func (*Aggregate) GetCount

func (a *Aggregate) GetCount(evType, ip string) (int64, bool)

func (*Aggregate) Merge

func (a *Aggregate) Merge(b *Aggregate) *Aggregate

func (*Aggregate) ProtoMessage

func (*Aggregate) ProtoMessage()

func (*Aggregate) ProtoReflect

func (x *Aggregate) ProtoReflect() protoreflect.Message

func (*Aggregate) Recalc

func (a *Aggregate) Recalc()

func (*Aggregate) Reset

func (x *Aggregate) Reset()

func (*Aggregate) String

func (x *Aggregate) String() string

type AggregateIPEntry

type AggregateIPEntry struct {
	Ip    string `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"`
	Count int64  `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`
	// contains filtered or unexported fields
}

func (*AggregateIPEntry) Descriptor deprecated

func (*AggregateIPEntry) Descriptor() ([]byte, []int)

Deprecated: Use AggregateIPEntry.ProtoReflect.Descriptor instead.

func (*AggregateIPEntry) GetCount

func (x *AggregateIPEntry) GetCount() int64

func (*AggregateIPEntry) GetIp

func (x *AggregateIPEntry) GetIp() string

func (*AggregateIPEntry) ProtoMessage

func (*AggregateIPEntry) ProtoMessage()

func (*AggregateIPEntry) ProtoReflect

func (x *AggregateIPEntry) ProtoReflect() protoreflect.Message

func (*AggregateIPEntry) Reset

func (x *AggregateIPEntry) Reset()

func (*AggregateIPEntry) String

func (x *AggregateIPEntry) String() string

type AggregateTypeEntry

type AggregateTypeEntry struct {
	ByIp    []*AggregateIPEntry `protobuf:"bytes,1,rep,name=by_ip,json=byIp,proto3" json:"by_ip,omitempty"`
	Type    string              `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
	Details string              `protobuf:"bytes,3,opt,name=details,proto3" json:"details,omitempty"`
	// contains filtered or unexported fields
}

func (*AggregateTypeEntry) Descriptor deprecated

func (*AggregateTypeEntry) Descriptor() ([]byte, []int)

Deprecated: Use AggregateTypeEntry.ProtoReflect.Descriptor instead.

func (*AggregateTypeEntry) GetByIp

func (x *AggregateTypeEntry) GetByIp() []*AggregateIPEntry

func (*AggregateTypeEntry) GetDetails

func (x *AggregateTypeEntry) GetDetails() string

func (*AggregateTypeEntry) GetType

func (x *AggregateTypeEntry) GetType() string

func (*AggregateTypeEntry) ProtoMessage

func (*AggregateTypeEntry) ProtoMessage()

func (*AggregateTypeEntry) ProtoReflect

func (x *AggregateTypeEntry) ProtoReflect() protoreflect.Message

func (*AggregateTypeEntry) Reset

func (x *AggregateTypeEntry) Reset()

func (*AggregateTypeEntry) String

func (x *AggregateTypeEntry) String() string

type Event

type Event struct {
	Ip      string `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"`
	Type    string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
	Details string `protobuf:"bytes,3,opt,name=details,proto3" json:"details,omitempty"`
	Count   int64  `protobuf:"varint,4,opt,name=count,proto3" json:"count,omitempty"`
	// contains filtered or unexported fields
}

func (*Event) Descriptor deprecated

func (*Event) Descriptor() ([]byte, []int)

Deprecated: Use Event.ProtoReflect.Descriptor instead.

func (*Event) GetCount

func (x *Event) GetCount() int64

func (*Event) GetDetails

func (x *Event) GetDetails() string

func (*Event) GetIp

func (x *Event) GetIp() string

func (*Event) GetType

func (x *Event) GetType() string

func (*Event) ProtoMessage

func (*Event) ProtoMessage()

func (*Event) ProtoReflect

func (x *Event) ProtoReflect() protoreflect.Message

func (*Event) Reset

func (x *Event) Reset()

func (*Event) String

func (x *Event) String() string

type GetAllScoresRequest

type GetAllScoresRequest struct {
	Horizon   int64   `protobuf:"varint,1,opt,name=horizon,proto3" json:"horizon,omitempty"`
	Threshold float32 `protobuf:"fixed32,2,opt,name=threshold,proto3" json:"threshold,omitempty"`
	// contains filtered or unexported fields
}

func (*GetAllScoresRequest) Descriptor deprecated

func (*GetAllScoresRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetAllScoresRequest.ProtoReflect.Descriptor instead.

func (*GetAllScoresRequest) GetHorizon

func (x *GetAllScoresRequest) GetHorizon() int64

func (*GetAllScoresRequest) GetThreshold

func (x *GetAllScoresRequest) GetThreshold() float32

func (*GetAllScoresRequest) ProtoMessage

func (*GetAllScoresRequest) ProtoMessage()

func (*GetAllScoresRequest) ProtoReflect

func (x *GetAllScoresRequest) ProtoReflect() protoreflect.Message

func (*GetAllScoresRequest) Reset

func (x *GetAllScoresRequest) Reset()

func (*GetAllScoresRequest) String

func (x *GetAllScoresRequest) String() string

type GetScoreRequest

type GetScoreRequest struct {
	Ip      string `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"`
	Horizon int64  `protobuf:"varint,2,opt,name=horizon,proto3" json:"horizon,omitempty"`
	// contains filtered or unexported fields
}

func (*GetScoreRequest) Descriptor deprecated

func (*GetScoreRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetScoreRequest.ProtoReflect.Descriptor instead.

func (*GetScoreRequest) GetHorizon

func (x *GetScoreRequest) GetHorizon() int64

func (*GetScoreRequest) GetIp

func (x *GetScoreRequest) GetIp() string

func (*GetScoreRequest) ProtoMessage

func (*GetScoreRequest) ProtoMessage()

func (*GetScoreRequest) ProtoReflect

func (x *GetScoreRequest) ProtoReflect() protoreflect.Message

func (*GetScoreRequest) Reset

func (x *GetScoreRequest) Reset()

func (*GetScoreRequest) String

func (x *GetScoreRequest) String() string

type GetScoreResponse

type GetScoreResponse struct {
	Ip    string  `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"`
	Score float32 `protobuf:"fixed32,2,opt,name=score,proto3" json:"score,omitempty"`
	// contains filtered or unexported fields
}

func (*GetScoreResponse) Descriptor deprecated

func (*GetScoreResponse) Descriptor() ([]byte, []int)

Deprecated: Use GetScoreResponse.ProtoReflect.Descriptor instead.

func (*GetScoreResponse) GetIp

func (x *GetScoreResponse) GetIp() string

func (*GetScoreResponse) GetScore

func (x *GetScoreResponse) GetScore() float32

func (*GetScoreResponse) ProtoMessage

func (*GetScoreResponse) ProtoMessage()

func (*GetScoreResponse) ProtoReflect

func (x *GetScoreResponse) ProtoReflect() protoreflect.Message

func (*GetScoreResponse) Reset

func (x *GetScoreResponse) Reset()

func (*GetScoreResponse) String

func (x *GetScoreResponse) String() string

type IPMask

type IPMask struct {
	// contains filtered or unexported fields
}

IPMask is a utility type to mask v4/v6 addresses retaining different number of bits for each protocol.

func NewIPMask

func NewIPMask(v4bits, v6bits int) IPMask

func (IPMask) MaskIP

func (m IPMask) MaskIP(ip net.IP) net.IP

func (IPMask) MaskString

func (m IPMask) MaskString(ipstr string) string

type IpRepClient

type IpRepClient interface {
	Submit(ctx context.Context, in *SubmitRequest, opts ...grpc.CallOption) (*empty.Empty, error)
	GetScore(ctx context.Context, in *GetScoreRequest, opts ...grpc.CallOption) (*GetScoreResponse, error)
	GetAllScores(ctx context.Context, in *GetAllScoresRequest, opts ...grpc.CallOption) (IpRep_GetAllScoresClient, error)
}

IpRepClient is the client API for IpRep service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewIpRepClient

func NewIpRepClient(cc grpc.ClientConnInterface) IpRepClient

type IpRepServer

type IpRepServer interface {
	Submit(context.Context, *SubmitRequest) (*empty.Empty, error)
	GetScore(context.Context, *GetScoreRequest) (*GetScoreResponse, error)
	GetAllScores(*GetAllScoresRequest, IpRep_GetAllScoresServer) error
	// contains filtered or unexported methods
}

IpRepServer is the server API for IpRep service. All implementations must embed UnimplementedIpRepServer for forward compatibility

type IpRep_GetAllScoresClient

type IpRep_GetAllScoresClient interface {
	Recv() (*GetScoreResponse, error)
	grpc.ClientStream
}

type IpRep_GetAllScoresServer

type IpRep_GetAllScoresServer interface {
	Send(*GetScoreResponse) error
	grpc.ServerStream
}

type Map

type Map map[string]map[string]int64

Map is an in-memory aggregate representation: type/ip/count.

func (Map) ByIP

func (m Map) ByIP(ip string) map[string]int64

func (Map) Incr

func (m Map) Incr(evType, ip string, n int64)

func (Map) ToAggregate

func (m Map) ToAggregate() *Aggregate

func (Map) Update

func (m Map) Update(a *Aggregate)

type SubmitRequest

type SubmitRequest struct {
	Events     []*Event     `protobuf:"bytes,1,rep,name=events,proto3" json:"events,omitempty"`
	Aggregates []*Aggregate `protobuf:"bytes,2,rep,name=aggregates,proto3" json:"aggregates,omitempty"`
	// contains filtered or unexported fields
}

func (*SubmitRequest) Descriptor deprecated

func (*SubmitRequest) Descriptor() ([]byte, []int)

Deprecated: Use SubmitRequest.ProtoReflect.Descriptor instead.

func (*SubmitRequest) GetAggregates

func (x *SubmitRequest) GetAggregates() []*Aggregate

func (*SubmitRequest) GetEvents

func (x *SubmitRequest) GetEvents() []*Event

func (*SubmitRequest) ProtoMessage

func (*SubmitRequest) ProtoMessage()

func (*SubmitRequest) ProtoReflect

func (x *SubmitRequest) ProtoReflect() protoreflect.Message

func (*SubmitRequest) Reset

func (x *SubmitRequest) Reset()

func (*SubmitRequest) String

func (x *SubmitRequest) String() string

type UnimplementedIpRepServer

type UnimplementedIpRepServer struct {
}

UnimplementedIpRepServer must be embedded to have forward compatible implementations.

func (UnimplementedIpRepServer) GetAllScores

func (UnimplementedIpRepServer) GetScore

func (UnimplementedIpRepServer) Submit

type UnsafeIpRepServer

type UnsafeIpRepServer interface {
	// contains filtered or unexported methods
}

UnsafeIpRepServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to IpRepServer will result in compilation errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL