From 390c5a956bcb659e5473747d0696595e3aabc0d6 Mon Sep 17 00:00:00 2001
From: KIProtect GmbH <github@kiprotect.com>
Date: Mon, 23 May 2022 09:18:04 +0200
Subject: [PATCH] More logging; new 'properties' section in directory entry.

---
 channels/grpc_client.go | 10 +++++++++-
 directory.go            |  1 +
 message_broker.go       |  2 ++
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/channels/grpc_client.go b/channels/grpc_client.go
index 6a76c7f..a1bd1d5 100644
--- a/channels/grpc_client.go
+++ b/channels/grpc_client.go
@@ -234,9 +234,13 @@ func (c *GRPCClientChannel) clearStaleConnections() error {
 				eps.Log.Error(err)
 				lastErr = err
 			}
+			eps.Log.Tracef("Removing stale connection with name '%s' and address '%s'...", connection.Name, connection.Address)
 			delete(c.connections, key)
+		} else {
+			eps.Log.Tracef("Keeping connection with name '%s' and address '%s' open...", connection.Name, connection.Address)
 		}
 	}
+	eps.Log.Tracef("%d open gRPC server-client connections in total...", len(c.connections))
 	return lastErr
 }
 
@@ -342,6 +346,8 @@ func (c *GRPCClientChannel) openConnections() error {
 
 func (c *GRPCClientChannel) openConnection(address, name string) error {
 
+	eps.Log.Tracef("Opening gRPC client connection to name '%s' and address '%s'...", name, address)
+
 	conn := c.getConnection(name)
 
 	if conn == nil {
@@ -419,12 +425,14 @@ func (c *GRPCClientChannel) DeliverRequest(request *eps.Request) (*eps.Response,
 
 	if settings.Proxy != "" {
 
+		eps.Log.Tracef("Destination is only reachable via proxy '%s'...", settings.Proxy)
+
 		if !c.Settings.UseProxy {
 			return nil, fmt.Errorf("destination is only reachable via proxy but proxying is disabled")
 		}
 
 		dialer = func(context context.Context, addr string) (net.Conn, error) {
-			eps.Log.Tracef("Dialing to %s through proxy...", address.Operator)
+			eps.Log.Tracef("Dialing operator '%s' through proxy...", address.Operator)
 
 			// this request comes from ourselves
 			clientInfo := &eps.ClientInfo{
diff --git a/directory.go b/directory.go
index 70df45b..bc21fee 100644
--- a/directory.go
+++ b/directory.go
@@ -36,6 +36,7 @@ func MakeDirectoryEntry() *DirectoryEntry {
 		Certificates: []*OperatorCertificate{},
 		Settings:     []*OperatorSettings{},
 		Records:      []*SignedChangeRecord{},
+		Properties:   &OperatorProperties{},
 	}
 }
 
diff --git a/message_broker.go b/message_broker.go
index f61dd59..406d3d3 100644
--- a/message_broker.go
+++ b/message_broker.go
@@ -143,6 +143,8 @@ func (b *BasicMessageBroker) DeliverRequest(request *Request, clientInfo *Client
 		return nil, fmt.Errorf("client info missing")
 	}
 
+	Log.Tracef("Delivering request with method '%s' from client '%s'...", request.Method, clientInfo.Name)
+
 	var ownEntry, remoteEntry *DirectoryEntry
 	var err error