Documentation ¶
Overview ¶
Package conn provides functionality for handling connections.
Index ¶
- Constants
- Variables
- func ConvertUnixNanoToTime(unixNano uint64) time.Time
- func ListenSocket(ctx context.Context, l *zap.Logger, openMap, dataMap, closeMap *ebpf.Map, ...) (<-chan *models.TestCase, error)
- type Factory
- type ID
- type SockAddrIn
- type SocketCloseEvent
- type SocketDataEvent
- type SocketOpenEvent
- type Tracker
- func (conn *Tracker) AddCloseEvent(event SocketCloseEvent)
- func (conn *Tracker) AddDataEvent(event SocketDataEvent)
- func (conn *Tracker) AddOpenEvent(event SocketOpenEvent)
- func (conn *Tracker) IsComplete() (bool, []byte, []byte, time.Time, time.Time)
- func (conn *Tracker) IsInactive(duration time.Duration) bool
- func (conn *Tracker) ToBytes() ([]byte, []byte)
- func (conn *Tracker) UpdateTimestamps()
- type TrafficDirectionEnum
Constants ¶
const (
EventBodyMaxSize = 16384 // 16 KB
)
constant for the maximum size of the event body
Variables ¶
var Emoji = "\U0001F430" + " Keploy:"
Functions ¶
func ConvertUnixNanoToTime ¶
ConvertUnixNanoToTime takes a Unix timestamp in nanoseconds as a uint64 and returns the corresponding time.Time
Types ¶
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory is a routine-safe container that holds a trackers with unique ID, and able to create new tracker.
func NewFactory ¶
NewFactory creates a new instance of the factory.
func (*Factory) GetOrCreate ¶
GetOrCreate returns a tracker that related to the given conn and transaction ids. If there is no such tracker we create a new one.
func (*Factory) ProcessActiveTrackers ¶
func (factory *Factory) ProcessActiveTrackers(ctx context.Context, t chan *models.TestCase, opts models.IncomingOptions)
ProcessActiveTrackers iterates over all conn the trackers and checks if they are complete. If so, it captures the ingress call and deletes the tracker. If the tracker is inactive for a long time, it deletes it.
type ID ¶
ID is a conversion of the following C-Struct into GO.
struct conn_id_t { uint32_t tgid; int32_t fd; uint64_t tsid; };
type SockAddrIn ¶
SockAddrIn is a conversion of the following C-Struct into GO.
struct sockaddr_in { unsigned short int sin_family; uint16_t sin_port; struct in_addr sin_addr; /* _to size of `struct sockaddr'. */ unsigned char sin_zero[8]; };.
type SocketCloseEvent ¶
SocketCloseEvent is a conversion of the following C-Struct into GO.
struct socket_close_event_t { uint64_t timestamp_ns; struct conn_id_t conn_id; int64_t wr_bytes; int64_t rd_bytes; };.
type SocketDataEvent ¶
type SocketDataEvent struct { EntryTimestampNano uint64 TimestampNano uint64 ConnID ID Direction TrafficDirectionEnum MsgSize uint32 Pos uint64 Msg [EventBodyMaxSize]byte ValidateReadBytes int64 ValidateWrittenBytes int64 }
SocketDataEvent is a conversion of the following C-Struct into GO. struct socket_data_event_t
{ u64 entry_timestamp_ns; u64 timestamp_ns; struct conn_id_t conn_id; enum traffic_direction_t direction; u32 msg_size; u64 pos; char msg[MAX_MSG_SIZE]; s64 validate_rd_bytes s64 validate_wr_bytes };
type SocketOpenEvent ¶
type SocketOpenEvent struct { TimestampNano uint64 ConnID ID Addr SockAddrIn }
SocketOpenEvent is a conversion of the following C-Struct into GO.
struct socket_open_event_t { uint64_t timestamp_ns; struct conn_id_t conn_id; struct sockaddr_in* addr; };.
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker is a routine-safe container that holds a conn with unique ID, and able to create new conn.
func (*Tracker) AddCloseEvent ¶
func (conn *Tracker) AddCloseEvent(event SocketCloseEvent)
func (*Tracker) AddDataEvent ¶
func (conn *Tracker) AddDataEvent(event SocketDataEvent)
func (*Tracker) AddOpenEvent ¶
func (conn *Tracker) AddOpenEvent(event SocketOpenEvent)
func (*Tracker) IsComplete ¶
IsComplete checks if the current conn has valid request & response info to capture and also returns the request and response data buffer.
func (*Tracker) UpdateTimestamps ¶
func (conn *Tracker) UpdateTimestamps()
type TrafficDirectionEnum ¶
type TrafficDirectionEnum int32
TrafficDirectionEnum is a GO-equivalent for the following enum.
enum traffic_direction_t { kEgress, kIngress, };.
const ( EgressTraffic TrafficDirectionEnum = 0 IngressTraffic TrafficDirectionEnum = 1 )
constants for the TrafficDirectionEnum
func (TrafficDirectionEnum) String ¶
func (t TrafficDirectionEnum) String() string