From a4cde35c0bbf7143522b580e3142351dbe55eb68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kowal?= Date: Wed, 15 May 2024 18:11:45 +0200 Subject: [PATCH] #9 Add part of knn classifier --- internal/ddosml/knn.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/internal/ddosml/knn.go b/internal/ddosml/knn.go index 58a52c6..0eb6ce5 100644 --- a/internal/ddosml/knn.go +++ b/internal/ddosml/knn.go @@ -5,24 +5,34 @@ import ( "fmt" "io" "math" + "sync" "github.com/cdipaolo/goml/base" ) -type knnClassifier struct { +type KnnClassifier struct { + knn *knn + + mu sync.Mutex +} + +func NewKNNClassifier() *KnnClassifier { + return &KnnClassifier{ + knn: &knn{}, + } } -func (k *knnClassifier) EnhanceClassifierWithRequest(m *Request) { +func (k *KnnClassifier) EnhanceClassifierWithRequest(m *Request) { //TODO implement me panic("implement me") } -func (k *knnClassifier) IsRequestPotentialDDOS(ctx context.Context, m *Request) bool { +func (k *KnnClassifier) IsRequestPotentialDDOS(ctx context.Context, m *Request) bool { //TODO implement me panic("implement me") } -func (k *knnClassifier) Write(writer io.Writer) error { +func (k *KnnClassifier) Write(writer io.Writer) error { //TODO implement me panic("implement me") }