summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-03-10 07:51:28 -0500
committerJeff Carr <[email protected]>2025-03-10 07:59:25 -0500
commitc3e8971e30e39757d63cc440b0ba2ed68bb97533 (patch)
tree4155323940d617a4c698b34f2f09f5acc5a52766 /main.go
parent18c1221efc1a4e6b97afb5547d44055a29150dff (diff)
more on events and auto save events pbv0.0.3
Diffstat (limited to 'main.go')
-rw-r--r--main.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/main.go b/main.go
index 916dc3a..d66d6a9 100644
--- a/main.go
+++ b/main.go
@@ -117,18 +117,23 @@ func handleConnection(clientConn net.Conn, where string, localport int) {
return
}
defer targetConn.Close()
- // log.Printf("Connected to target server: %s where = %s\n", targetConn.RemoteAddr(), where)
- log.Printf("Connected on port %d from client: %s to where = %s\n", localport, clientConn.RemoteAddr(), where)
+ // make a new event from this new connection
+ log.Printf("Connected on port %d from client: %s to where = %s\n", localport, clientConn.RemoteAddr(), where)
e := new(Event)
e.Address = fmt.Sprintf("%s\n", clientConn.RemoteAddr())
e.Where = where
+ e.LocalPort = int64(localport)
e.Ctime = timestamppb.New(time.Now())
-
me.events.Append(e)
+ me.eventsChanged = true
// Bidirectional copy of data
go io.Copy(targetConn, clientConn) // Client -> Target
io.Copy(clientConn, targetConn) // Target -> Client
+
+ // if the socket closes, record the close time
e.Etime = timestamppb.New(time.Now())
+ me.eventsChanged = true
+ log.Printf("Connection closed on port %d from client: %s to where = %s\n", localport, clientConn.RemoteAddr(), where)
}