Skip to content

Conversation

cfc4n
Copy link
Member

@cfc4n cfc4n commented Jul 22, 2025

support eCaptureQ

This pull request introduces several new features and refactors to the ecaptureq package, focusing on implementing a WebSocket server, creating a data model for packet handling, and improving the WebSocket utility. The changes add functionality for encoding and decoding packet data, handling WebSocket read/write operations, and managing concurrency through buffered channels.

New features in ecaptureq package:

  • Packet data model and JSON serialization:

    • Added the PacketData struct to represent packet information, including fields such as Timestamp, SrcIP, DstIP, and PayloadBase64. The struct uses JSON tags for serialization compatibility with frontend expectations.
    • Implemented Encode and Decode methods for converting PacketData instances to and from JSON byte streams.
  • WebSocket server implementation:

    • Added the Server struct with fields for address, logging buffer, WebSocket instance, and logger.
    • Implemented methods Start, Write, and Read for starting the server, writing data to WebSocket connections, and logging received data.

Refactor and enhancements to WebSocket utility (pkg/util/ws):

  • Buffered write channel:

    • Introduced a writeChan with a configurable buffer size (WriteChanLength) to handle concurrent writes to WebSocket connections efficiently. [1] [2]
  • Separation of read and write handlers:

    • Refactored the Server struct to use distinct readHandler and writeChan fields, improving clarity and functionality for WebSocket message handling.
  • Concurrent WebSocket operations:

    • Enhanced the handleWebSocket method to use two goroutines: one for processing incoming messages via readHandler and another for sending messages from writeChan. This ensures non-blocking operations for both reading and writing.

support eCaptureQ

Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
@cfc4n cfc4n requested a review from Copilot July 22, 2025 16:43
@cfc4n cfc4n self-assigned this Jul 22, 2025
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 22, 2025
@cfc4n cfc4n added this to the v1.5.0 milestone Jul 22, 2025
Copilot

This comment was marked as outdated.

Copy link

Failed to generate code suggestions for PR

@dosubot dosubot bot added the enhancement New feature or request label Jul 22, 2025
cfc4n added 3 commits July 24, 2025 01:23
…log transmission

Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
…log transmission

Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jul 25, 2025
cfc4n added 3 commits July 28, 2025 00:53
…t server

Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
…ket client

Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
@cfc4n cfc4n requested a review from Copilot July 27, 2025 17:14
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces WebSocket server capabilities and data structures for log handling in the eCaptureQ package. The implementation includes a complete WebSocket server system with message broadcasting, client connection management, and structured data models for packet information exchange.

  • Adds PacketData structure with JSON serialization for frontend compatibility
  • Implements WebSocket server with client management through Hub pattern
  • Refactors existing WebSocket utility to support custom connection handlers

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
user/event/ievent.go Removes commented interface methods
user/config/iconfig.go Adds EcaptureQ configuration field and GetAddrType method
pkg/util/ws/server.go Refactors to support custom WebSocket handlers instead of base64 decoding
pkg/util/ws/server_test.go Updates test to use new handler signature
pkg/ecaptureq/proto.go Defines message types and data structures with JSON encoding
pkg/ecaptureq/server.go Implements WebSocket server with logging and event handling
pkg/ecaptureq/hub.go Implements client connection management and message broadcasting
pkg/ecaptureq/client.go Handles individual WebSocket client connections
cli/cmd/root.go Integrates eCaptureQ server into CLI with conditional initialization
cli/cmd/ecaptureq.go Provides writer adapters for eCaptureQ integration
Comments suppressed due to low confidence (1)

pkg/ecaptureq/server.go:61

  • [nitpick] The variable name i is not used and is ambiguous. Consider removing it or giving it a more descriptive name if it serves a purpose.
		var i = 0

cfc4n added 11 commits July 29, 2025 23:59
…port

Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
…essing

Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
…f payload

Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
…eartbeat logic

Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
…ents in server

Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
…age validation

Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
@cfc4n cfc4n merged commit d6cebb5 into master Aug 1, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant