net

package
v3.2.5 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT, Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NetConn

type NetConn struct {
	// contains filtered or unexported fields
}

NetConn is a connection to a remote host. this is returned/create by Open and OpenTLS functions. @example ```javascript const net = require('nuclei/net'); const conn = net.Open('tcp', 'acme.com:80'); ```

func Open

func Open(protocol, address string) (*NetConn, error)

Open opens a new connection to the address with a timeout. supported protocols: tcp, udp @example ```javascript const net = require('nuclei/net'); const conn = net.Open('tcp', 'acme.com:80'); ```

func OpenTLS

func OpenTLS(protocol, address string) (*NetConn, error)

Open opens a new connection to the address with a timeout. supported protocols: tcp, udp @example ```javascript const net = require('nuclei/net'); const conn = net.OpenTLS('tcp', 'acme.com:443'); ```

func (*NetConn) Close

func (c *NetConn) Close() error

Close closes the connection. @example ```javascript const net = require('nuclei/net'); const conn = net.Open('tcp', 'acme.com:80'); conn.Close(); ```

func (*NetConn) Recv

func (c *NetConn) Recv(N int) ([]byte, error)

Recv is similar to RecvFull but does not guarantee full read instead it creates a buffer of N bytes and returns whatever is returned by the connection for reading headers or initial bytes from the server this is usually used. for reading a fixed number of already known bytes (ex: body based on content-length) use RecvFull. @example ```javascript const net = require('nuclei/net'); const conn = net.Open('tcp', 'acme.com:80'); const data = conn.Recv(1024); log(`Received ${data.length} bytes from the server`) ```

func (*NetConn) RecvFull added in v3.2.0

func (c *NetConn) RecvFull(N int) ([]byte, error)

RecvFull receives data from the connection with a timeout. If N is 0, it will read all data sent by the server with 8MB limit. it tries to read until N bytes or timeout is reached. @example ```javascript const net = require('nuclei/net'); const conn = net.Open('tcp', 'acme.com:80'); const data = conn.RecvFull(1024); ```

func (*NetConn) RecvFullHex added in v3.2.0

func (c *NetConn) RecvFullHex(N int) (string, error)

RecvFullHex receives data from the connection with a timeout in hex format. If N is 0,it will read all data sent by the server with 8MB limit. until N bytes or timeout is reached. @example ```javascript const net = require('nuclei/net'); const conn = net.Open('tcp', 'acme.com:80'); const data = conn.RecvFullHex(1024); ```

func (*NetConn) RecvFullString added in v3.2.0

func (c *NetConn) RecvFullString(N int) (string, error)

RecvFullString receives data from the connection with a timeout output is returned as a string. If N is 0, it will read all data sent by the server with 8MB limit. @example ```javascript const net = require('nuclei/net'); const conn = net.Open('tcp', 'acme.com:80'); const data = conn.RecvFullString(1024); ```

func (*NetConn) RecvHex

func (c *NetConn) RecvHex(N int) (string, error)

RecvHex is similar to RecvFullHex but does not guarantee full read instead it creates a buffer of N bytes and returns whatever is returned by the connection for reading headers or initial bytes from the server this is usually used. for reading a fixed number of already known bytes (ex: body based on content-length) use RecvFull. @example ```javascript const net = require('nuclei/net'); const conn = net.Open('tcp', 'acme.com:80'); const data = conn.RecvHex(1024); ```

func (*NetConn) RecvString

func (c *NetConn) RecvString(N int) (string, error)

RecvString is similar to RecvFullString but does not guarantee full read, instead it creates a buffer of N bytes and returns whatever is returned by the connection for reading headers or initial bytes from the server this is usually used. for reading a fixed number of already known bytes (ex: body based on content-length) use RecvFullString. @example ```javascript const net = require('nuclei/net'); const conn = net.Open('tcp', 'acme.com:80'); const data = conn.RecvString(1024); ```

func (*NetConn) Send

func (c *NetConn) Send(data string) error

Send sends data to the connection with a timeout. @example ```javascript const net = require('nuclei/net'); const conn = net.Open('tcp', 'acme.com:80'); conn.Send('hello'); ```

func (*NetConn) SendArray

func (c *NetConn) SendArray(data []interface{}) error

SendArray sends array data to connection @example ```javascript const net = require('nuclei/net'); const conn = net.Open('tcp', 'acme.com:80'); conn.SendArray(['hello', 'world']); ```

func (*NetConn) SendHex

func (c *NetConn) SendHex(data string) error

SendHex sends hex data to connection @example ```javascript const net = require('nuclei/net'); const conn = net.Open('tcp', 'acme.com:80'); conn.SendHex('68656c6c6f'); ```

func (*NetConn) SetTimeout

func (c *NetConn) SetTimeout(value int)

SetTimeout sets read/write timeout for the connection (in seconds). @example ```javascript const net = require('nuclei/net'); const conn = net.Open('tcp', 'acme.com:80'); conn.SetTimeout(10); ```

Jump to

Keyboard shortcuts

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