This is an automated email from the ASF dual-hosted git repository.

liuhan pushed a commit to branch tmp_disable_reading
in repository https://gitbox.apache.org/repos/asf/skywalking-rover.git


The following commit(s) were added to refs/heads/tmp_disable_reading by this 
push:
     new d7abff6  rebuild the connection when have update
d7abff6 is described below

commit d7abff62ff655510d9cb5a726686745aa89fa27b
Author: mrproliu <[email protected]>
AuthorDate: Sat Dec 21 22:01:50 2024 +0800

    rebuild the connection when have update
---
 pkg/accesslog/common/connection.go | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/pkg/accesslog/common/connection.go 
b/pkg/accesslog/common/connection.go
index e24a5cb..1e8fc36 100644
--- a/pkg/accesslog/common/connection.go
+++ b/pkg/accesslog/common/connection.go
@@ -21,6 +21,7 @@ import (
        "context"
        "errors"
        "fmt"
+       "github.com/gogo/protobuf/proto"
        "sync"
        "time"
 
@@ -324,17 +325,20 @@ func (c *ConnectionManager) 
connectionPostHandle(connection *ConnectionInfo, eve
                        c.allUnfinishedConnections[fmt.Sprintf("%d_%d", 
event.GetConnectionID(), event.GetRandomID())] = &e.allProcessorFinished
                }
        case events.SocketDetail:
+               tlsMode := connection.RPCConnection.TlsMode
+               protocol := connection.RPCConnection.Protocol
                if e.GetSSL() == 1 && connection.RPCConnection.TlsMode == 
v3.AccessLogConnectionTLSMode_Plain {
-                       connection.RPCConnection.TlsMode = 
v3.AccessLogConnectionTLSMode_TLS
+                       tlsMode = v3.AccessLogConnectionTLSMode_TLS
                }
                if e.GetProtocol() != enums.ConnectionProtocolUnknown && 
connection.RPCConnection.Protocol == v3.AccessLogProtocolType_TCP {
                        switch e.GetProtocol() {
                        case enums.ConnectionProtocolHTTP:
-                               connection.RPCConnection.Protocol = 
v3.AccessLogProtocolType_HTTP_1
+                               protocol = v3.AccessLogProtocolType_HTTP_1
                        case enums.ConnectionProtocolHTTP2:
-                               connection.RPCConnection.Protocol = 
v3.AccessLogProtocolType_HTTP_2
+                               protocol = v3.AccessLogProtocolType_HTTP_2
                        }
                }
+               c.rebuildRPCConnectionWithTLSModeAndProtocol(connection, 
tlsMode, protocol)
        }
 
        // notify all flush listeners the connection is ready to flush
@@ -343,6 +347,14 @@ func (c *ConnectionManager) 
connectionPostHandle(connection *ConnectionInfo, eve
        }
 }
 
+func (c *ConnectionManager) 
rebuildRPCConnectionWithTLSModeAndProtocol(connection *ConnectionInfo,
+       tls v3.AccessLogConnectionTLSMode, protocol v3.AccessLogProtocolType) {
+       logConnection := 
proto.Clone(connection.RPCConnection).(*v3.AccessLogConnection)
+       logConnection.TlsMode = tls
+       logConnection.Protocol = protocol
+       connection.RPCConnection = logConnection
+}
+
 func (c *ConnectionManager) ProcessIsMonitor(pid uint32) bool {
        c.monitoringProcessLock.RLock()
        defer c.monitoringProcessLock.RUnlock()

Reply via email to