util

package
v2.3.0-beta28 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package util provides utility functions for the proxy package.

Index

Constants

This section is empty.

Variables

View Source
var Emoji = "\U0001F430" + " Keploy:"

Functions

func GetJavaHome

func GetJavaHome(ctx context.Context) (string, error)

GetJavaHome returns the JAVA_HOME path

func GetLocalIPv4

func GetLocalIPv4() (net.IP, error)

func GetLocalIPv6

func GetLocalIPv6() (net.IP, error)

func GetNextID

func GetNextID() int64

func IPToDotDecimal

func IPToDotDecimal(ip net.IP) string

func IPv6ToUint32Array

func IPv6ToUint32Array(ip net.IP) ([4]uint32, error)

func IsDirectoryExist

func IsDirectoryExist(path string) bool

func IsJava

func IsJava(input string) bool

func IsJavaInstalled

func IsJavaInstalled() bool

IsJavaInstalled checks if java is installed on the system

func PassThrough

func PassThrough(ctx context.Context, logger *zap.Logger, clientConn net.Conn, dstCfg *models.ConditionalDstCfg, requestBuffer [][]byte) ([]byte, error)

PassThrough function is used to pass the network traffic to the destination connection. It also closes the destination connection if the function returns an error.

func ReadBuffConn

func ReadBuffConn(ctx context.Context, logger *zap.Logger, conn net.Conn, bufferChannel chan []byte, errChannel chan error)

ReadBuffConn is used to read the buffer from the connection

func ReadBytes

func ReadBytes(ctx context.Context, logger *zap.Logger, reader io.Reader) ([]byte, error)

ReadBytes function is utilized to read the complete message from the reader until the end of the file (EOF). It returns the content as a byte array.

func ReadFromPeer

func ReadFromPeer(ctx context.Context, logger *zap.Logger, conn net.Conn, buffChan chan []byte, errChan chan error, peer Peer) error

ReadFromPeer function is used to read the buffer from the peer connection. The peer can be either the client or the destination.

func ReadInitialBuf

func ReadInitialBuf(ctx context.Context, logger *zap.Logger, conn net.Conn) ([]byte, error)

func ReadRequiredBytes

func ReadRequiredBytes(ctx context.Context, logger *zap.Logger, reader io.Reader, numBytes int) ([]byte, error)

ReadRequiredBytes ReadBytes function is utilized to read the required number of bytes from the reader. It returns the content as a byte array.

func Recover

func Recover(logger *zap.Logger, client, dest net.Conn)

Recover recovers from a panic in any parser and logs the stack trace to Sentry. It also closes the client and destination connection.

func ToIP4AddressStr

func ToIP4AddressStr(ip uint32) string

ToIP4AddressStr converts the integer IP4 Address to the octet format

func ToIPV4

func ToIPV4(ip net.IP) (uint32, bool)

func ToIPv6AddressStr

func ToIPv6AddressStr(ip [4]uint32) string

Types

type Conn

type Conn struct {
	net.Conn
	Reader io.Reader
	Logger *zap.Logger
	// contains filtered or unexported fields
}

Conn is helpful for multiple reads from the same connection

func (*Conn) Read

func (c *Conn) Read(p []byte) (int, error)

type Peer

type Peer string
const (
	Client      Peer = "client"
	Destination Peer = "destination"
)

Peer constants

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL