1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package kyoketsu
- import (
- "context"
- "fmt"
- "time"
- "git.aetherial.dev/aeth/kyoketsu/pkg/scan"
- "go.mongodb.org/mongo-driver/mongo"
- "go.mongodb.org/mongo-driver/mongo/options"
- )
- type TopologyDatabaseIO interface {
- AddHostToDb(*scan.TcpScanHost) error // Add a host to the hosts table
- UpdateHostEntry(string, *scan.TcpScanHost) error //Update a host entry, indexing by its ip address
- RemoveHostEntry(string) error
- }
- 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 *scan.TcpScanHost) error {
- return nil
- }
- func (m *MongoClient) UpdateHostEntry(id string, host *scan.TcpScanHost) error {
- return nil
- }
- func (m *MongoClient) RemoveHostEntry(id string) error {
- return nil
- }
|