prehook

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package prehook implements a connection prehook mechanism, to handle any pre-negotiation required by a remote node before the B2F protocol can commence (e.g. packet node traversal).

Index

Constants

This section is empty.

Variables

View Source
var ErrConnNotWrapped = errors.New("connection not wrapped for prehook")

Functions

func Verify

func Verify(file string) error

Verify returns nil if the given script file is found and valid.

Types

type Conn

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

func Wrap

func Wrap(conn net.Conn) *Conn

Wrap returns a wrapped connection with the ability to execute a prehook.

The returned Conn implements the net.Conn interface, and should be used in place of the original throughout the lifetime of the connection once the prehook script is executed.

func (*Conn) Execute

func (p *Conn) Execute(ctx context.Context, script Script) error

Execute executes the prehook script, returning nil if the process terminated successfully (exit code 0).

func (*Conn) Read

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

type Script

type Script struct {
	File string
	Args []string
	Env  []string
}

func (Script) Execute

func (s Script) Execute(ctx context.Context, conn net.Conn) error

Execute executes the prehook script on a wrapped connection.

ErrConnNotWrapped is returned if conn is not wrapped.

Jump to

Keyboard shortcuts

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