Documentation ¶
Overview ¶
Package nutsak (Network Utility Swiss-Army Knife) will provide a means of tunneling traffic between two endpoints. Here is sample code to create a Pair:
var a sak.NUt var b sak.NUt var e error // Create first NUt if a, e = sak.NewNUt("tcp-listen:4444,fork"); e != nil { panic(e) } // Create second NUt if b, e = sak.NewNUt("stdout"); e != nil { panic(e) } // Pair NUts to create two-way tunnel if e = sak.Pair(a, b); e != nil { panic(e) }
This will create a TCP listener on port 4444 that forks each new connection. Any received data will be written to STDOUT. The Network Utilties (NUts) are created from seeds. Below are the supported SEED TYPES along with their documentation:
FILE:addr[,mode=(append|read|write)]
This seed takes an address that is an absolute or relative filename. This seed is used to read or write a file on disk. The default mode is read.
STDIO:
Aliases: -, STDIN, STDOUT
This seed takes no address or options. It can be used to read from stdin or write to stdout.
TCP:addr
This seed takes an address of the form [IP:]PORT. The IP is optional and essentially defaults to localhost, or more specifically, 0.0.0.0 or [::]. This seed is used to make an outgoing TCP connection.
TCP-LISTEN:addr[,fork]
Aliases: TCP-L
This seed takes an address of the form [IP:]PORT. The IP is optional and essentially defaults to localhost, or more specifically, 0.0.0.0 or [::]. This seed is used to listen on the provided TCP address. The fork option causes the TCP listener to accept multiple connections in parallel.
TLS:addr[,ca=PATH,cert=PATH,key=PATH,verify]
This seed takes an address of the form [IP:]PORT. The IP is optional and essentially defaults to localhost, or more specifically, 0.0.0.0 or [::]. This seed is used to make an outgoing TLS connection. The ca, cert, and key options take a filepath (DER or PEM formatted). The verify option determines if the the server-side CA should be verified. The cert and key options must be used together. If verify is specified, a ca must also be specified.
TLS-LISTEN:addr[,ca=PATH,cert=PATH,fork,key=PATH,verify]
Aliases: TLS-L
This seed takes an address of the form [IP:]PORT. The IP is optional and essentially defaults to localhost, or more specifically, 0.0.0.0 or [::]. This seed is used to listen on the provided TCP address. The ca, cert, and key options take a filepath (DER or PEM formatted). The fork option causes the TLS listener to accept multiple connections in parallel. The verify option determines if the client-side certificate should be verified. The cert and key options are mandatory. If verify is specified, a ca must also be specified.
UDP:addr
This seed takes an address of the form [IP:]PORT. The IP is optional and essentially defaults to localhost, or more specifically, 0.0.0.0 or [::]. This seed is used to make an outgoing UDP connection.
UDP-LISTEN:addr
Aliases: UDP-L
This seed takes an address of the form [IP:]PORT. The IP is optional and essentially defaults to localhost, or more specifically, 0.0.0.0 or [::]. This seed is used to listen on the provided UDP address.
Index ¶
- Constants
- Variables
- func Banner(hide ...bool)
- func BannerNSFW(hide ...bool)
- func Pair(a NUt, b NUt) error
- func Stream(a NUt, b NUt) error
- type FileNUt
- func (nut FileNUt) Close() error
- func (nut *FileNUt) Down() error
- func (nut FileNUt) IsUp() bool
- func (nut *FileNUt) KeepAlive() bool
- func (nut FileNUt) Open() error
- func (nut *FileNUt) Read(p []byte) (int, error)
- func (nut FileNUt) String() string
- func (nut FileNUt) Type() string
- func (nut *FileNUt) Up() error
- func (nut *FileNUt) Write(p []byte) (int, error)
- type NUt
- type StdioNUt
- func (nut StdioNUt) Close() error
- func (nut *StdioNUt) Down() error
- func (nut StdioNUt) IsUp() bool
- func (nut *StdioNUt) KeepAlive() bool
- func (nut StdioNUt) Open() error
- func (nut *StdioNUt) Read(p []byte) (int, error)
- func (nut StdioNUt) String() string
- func (nut StdioNUt) Type() string
- func (nut *StdioNUt) Up() error
- func (nut *StdioNUt) Write(p []byte) (int, error)
- type TCPNUt
- func (nut TCPNUt) Close() error
- func (nut *TCPNUt) Down() error
- func (nut TCPNUt) IsUp() bool
- func (nut *TCPNUt) KeepAlive() bool
- func (nut TCPNUt) Open() error
- func (nut *TCPNUt) Read(p []byte) (int, error)
- func (nut TCPNUt) String() string
- func (nut TCPNUt) Type() string
- func (nut *TCPNUt) Up() error
- func (nut *TCPNUt) Write(p []byte) (int, error)
- type TLSNUt
- func (nut TLSNUt) Close() error
- func (nut *TLSNUt) Down() error
- func (nut TLSNUt) IsUp() bool
- func (nut *TLSNUt) KeepAlive() bool
- func (nut TLSNUt) Open() error
- func (nut *TLSNUt) Read(p []byte) (int, error)
- func (nut TLSNUt) String() string
- func (nut TLSNUt) Type() string
- func (nut *TLSNUt) Up() error
- func (nut *TLSNUt) Write(p []byte) (int, error)
- type UDPNUt
- func (nut UDPNUt) Close() error
- func (nut *UDPNUt) Down() error
- func (nut UDPNUt) IsUp() bool
- func (nut *UDPNUt) KeepAlive() bool
- func (nut UDPNUt) Open() error
- func (nut *UDPNUt) Read(p []byte) (int, error)
- func (nut UDPNUt) String() string
- func (nut UDPNUt) Type() string
- func (nut *UDPNUt) Up() error
- func (nut *UDPNUt) Write(p []byte) (int, error)
Constants ¶
const Version = "1.0.3"
Version is the package version.
Variables ¶
var LogLvl int
LogLvl will be used to determine the amount of log messages displayed.
var Logger *log.Messenger
Logger will be used to log information deemed relevant to the user.
Functions ¶
func BannerNSFW ¶
func BannerNSFW(hide ...bool)
BannerNSFW will display a NSFW piece of art to stdout.
Types ¶
type FileNUt ¶
type FileNUt struct {
// contains filtered or unexported fields
}
FileNUt is a file network utility.
func NewFileNUt ¶
NewFileNUt will return a pointer to a file network utility instance with the provided seed.
func (*FileNUt) Down ¶
Down will stop the network utility. In the case of file, it will close the file.
func (FileNUt) IsUp ¶
func (nut FileNUt) IsUp() bool
IsUp will return whether or not the network utiltity is up and running.
func (*FileNUt) KeepAlive ¶
KeepAlive will return whether or not the network utility should be left running upon EOF. In the case of a file, it is dependent upon mode.
func (FileNUt) String ¶
func (nut FileNUt) String() string
String will return a string representation of the network utility.
func (FileNUt) Type ¶
func (nut FileNUt) Type() string
Type will return the type of the network utility.
type NUt ¶
type NUt interface { // BaseNUt Close() error IsUp() bool Open() error String() string Type() string // Needs implemented Down() error KeepAlive() bool Read(p []byte) (n int, e error) Up() error Write(p []byte) (n int, e error) }
NUt is a network utility capable of reading and writing to a network connection.
type StdioNUt ¶
type StdioNUt struct {
// contains filtered or unexported fields
}
StdioNUt is a stdio network utility.
func NewStdioNUt ¶
NewStdioNUt will return a pointer to a stdio network utility instance with the provided seed.
func (*StdioNUt) Down ¶
Down will stop the network utility. In the case of stdio, it will do nothing.
func (StdioNUt) IsUp ¶
func (nut StdioNUt) IsUp() bool
IsUp will return whether or not the network utiltity is up and running.
func (*StdioNUt) KeepAlive ¶
KeepAlive will return whether or not the network utility should be left running upon EOF. In the case of stdio, it should always return true, if it is also up.
func (StdioNUt) String ¶
func (nut StdioNUt) String() string
String will return a string representation of the network utility.
func (StdioNUt) Type ¶
func (nut StdioNUt) Type() string
Type will return the type of the network utility.
type TCPNUt ¶
type TCPNUt struct {
// contains filtered or unexported fields
}
TCPNUt is a TCP network utility.
func NewTCPNUt ¶
NewTCPNUt will return a pointer to a TCP network utility instance with the provided seed.
func (*TCPNUt) Down ¶
Down will stop the network utility. In the case of TCP, it will close the connection or listener, depending on the mode.
func (TCPNUt) IsUp ¶
func (nut TCPNUt) IsUp() bool
IsUp will return whether or not the network utiltity is up and running.
func (*TCPNUt) KeepAlive ¶
KeepAlive will return whether or not the network utility should be left running upon EOF. In the case of TCP, it is dependent upon mode.
func (TCPNUt) String ¶
func (nut TCPNUt) String() string
String will return a string representation of the network utility.
func (TCPNUt) Type ¶
func (nut TCPNUt) Type() string
Type will return the type of the network utility.
type TLSNUt ¶
type TLSNUt struct {
// contains filtered or unexported fields
}
TLSNUt is a TLS network utility.
func NewTLSNUt ¶
NewTLSNUt will return a pointer to a TLS network utility instance with the provided seed.
func (*TLSNUt) Down ¶
Down will stop the network utility. In the case of TLS, it will close the connection or listener, depending on the mode.
func (TLSNUt) IsUp ¶
func (nut TLSNUt) IsUp() bool
IsUp will return whether or not the network utiltity is up and running.
func (*TLSNUt) KeepAlive ¶
KeepAlive will return whether or not the network utility should be left running upon EOF. In the case of TLS, it is dependent upon mode.
func (TLSNUt) String ¶
func (nut TLSNUt) String() string
String will return a string representation of the network utility.
func (TLSNUt) Type ¶
func (nut TLSNUt) Type() string
Type will return the type of the network utility.
type UDPNUt ¶
type UDPNUt struct {
// contains filtered or unexported fields
}
UDPNUt is a UDP network utility.
func NewUDPNUt ¶
NewUDPNUt will return a pointer to a UDP network utility instance with the provided seed and mode.
func (*UDPNUt) Down ¶
Down will stop the network utility. In the case of UDP, it will close the connection.
func (UDPNUt) IsUp ¶
func (nut UDPNUt) IsUp() bool
IsUp will return whether or not the network utiltity is up and running.
func (*UDPNUt) KeepAlive ¶
KeepAlive will return whether or not the network utility should be left running upon EOF. In the case of UDP, it should always return true, if it is also up.
func (UDPNUt) String ¶
func (nut UDPNUt) String() string
String will return a string representation of the network utility.
func (UDPNUt) Type ¶
func (nut UDPNUt) Type() string
Type will return the type of the network utility.