fortio: fortio.org/fortio/fnet Index | Files

package fnet

import "fortio.org/fortio/fnet"

Index

Package Files

network.go

Constants

const (
    // DefaultGRPCPort is the Fortio gRPC server default port number.
    DefaultGRPCPort = "8079"
    // StandardHTTPPort is the Standard http port number.
    StandardHTTPPort = "80"
    // StandardHTTPSPort is the Standard https port number.
    StandardHTTPSPort = "443"
    // PrefixHTTP is a constant value for representing http protocol that can be added prefix of url
    PrefixHTTP = "http://"
    // PrefixHTTPS is a constant value for representing secure http protocol that can be added prefix of url
    PrefixHTTPS = "https://"

    // POST is a constant value that indicates http method as post
    POST = "POST"
    // GET is a constant value that indicates http method as get
    GET = "GET"
    // UnixDomainSocket type for network addresses.
    UnixDomainSocket = "unix"
)

Variables

var (
    // MaxPayloadSize is the maximum size of payload to be generated by the
    // EchoHandler size= argument. In bytes.
    MaxPayloadSize = 256 * 1024
    // Payload that is returned during echo call
    Payload []byte
)

func ChangeMaxPayloadSize Uses

func ChangeMaxPayloadSize(newMaxPayloadSize int)

ChangeMaxPayloadSize is used to change max payload size and fill it with pseudorandom content

func GeneratePayload Uses

func GeneratePayload(payloadFilePath string, payloadSize int, payload string) []byte

GeneratePayload generates a payload with given inputs. First tries filePath, then random payload, at last payload

func GenerateRandomPayload Uses

func GenerateRandomPayload(payloadSize int) []byte

GenerateRandomPayload generates a random payload with given input size

func GetPort Uses

func GetPort(lAddr net.Addr) string

GetPort extracts the port for TCP sockets and the path for unix domain sockets.

func GetUniqueUnixDomainPath Uses

func GetUniqueUnixDomainPath(prefix string) string

GetUniqueUnixDomainPath returns a path to be used for unix domain socket.

func Listen Uses

func Listen(name string, port string) (net.Listener, net.Addr)

Listen returns a listener for the port. Port can be a port or a bind address and a port (e.g. "8080" or "[::1]:8080"...). If the port component is 0 a free port will be returned by the system. If the port is a pathname (contains a /) a unix domain socket listener will be used instead of regular tcp socket. This logs critical on error and returns nil (is meant for servers that must start).

func NormalizeHostPort Uses

func NormalizeHostPort(inputPort string, addr net.Addr) string

NormalizeHostPort generates host:port string for the address or uses localhost instead of [::] when the original port binding input didn't specify an address

func NormalizePort Uses

func NormalizePort(port string) string

NormalizePort parses port and returns host:port if port is in the form of host:port already or :port if port is only a port (doesn't contain :).

func Proxy Uses

func Proxy(port string, dest net.Addr) net.Addr

Proxy starts a tcp proxy.

func ProxyToDestination Uses

func ProxyToDestination(listenPort string, destination string) net.Addr

ProxyToDestination opens a proxy from the listenPort (or addr:port or unix domain socket path) and forwards all traffic to destination (host:port)

func ReadFileForPayload Uses

func ReadFileForPayload(payloadFilePath string) ([]byte, error)

ReadFileForPayload reads the file from given input path

func Resolve Uses

func Resolve(host string, port string) net.Addr

Resolve returns the TCP address of the host,port suitable for net.Dial. nil in case of errors.

func ResolveDestination Uses

func ResolveDestination(dest string) net.Addr

ResolveDestination returns the TCP address of the "host:port" suitable for net.Dial. nil in case of errors.

func ValidatePayloadSize Uses

func ValidatePayloadSize(size *int)

ValidatePayloadSize compares input size with MaxPayLoadSize. If size exceeds the MaxPayloadSize size will set to MaxPayLoadSize

Package fnet imports 11 packages (graph) and is imported by 9 packages. Updated 2018-08-28. Refresh now. Tools for package owners.