/* GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 kyoketsu, a Client-To-Client Network Enumeration System Copyright (C) 2024 Russell Hrubesky, ChiralWorks Software LLC Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ package kyoketsu import ( "context" "fmt" "time" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" ) type TopologyDatabaseIO interface { /* This interface defines the Input and output methods that will be necessary for an appropriate implementation of the data storage that the distributed system will use. When I get around to implementing the client-to-client format of this, it could be anything. */ AddHostToDb(*Host) error // Add a host to the hosts table UpdateHostEntry(string, *Host) error //Update a host entry, indexing by its ip address RemoveHostEntry(string) error // Remove a host from the database } type MongoClient struct { conn *mongo.Client } func NewMongoClient(host string, port int) *MongoClient { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() client, err := mongo.Connect(ctx, options.Client().ApplyURI(fmt.Sprintf("mongodb://%s:%v", host, port))) defer func() { if err = client.Disconnect(ctx); err != nil { panic(err) } }() return &MongoClient{conn: client} } func (m *MongoClient) addDocument(id string, data interface{}) error { return nil } func (m *MongoClient) AddHostToDb(host *Host) error { return nil } func (m *MongoClient) UpdateHostEntry(id string, host *Host) error { return nil } func (m *MongoClient) RemoveHostEntry(id string) error { return nil }