Skip to content

Network Utility Swiss-Army Knife similar to socat.

License

Notifications You must be signed in to change notification settings

mjwhitta/nutsak

Repository files navigation

Network Utility Swiss-Army Knife (NUtSAK)

Yum

Go Report Card GitHub Workflow Status License

What is this?

NUtSAK is a network utility library. Included is a client offering similar features to socat.

How to install

Open a terminal and run the following:

$ go get -u github.com/mjwhitta/nutsak
$ go install github.com/mjwhitta/nutsak/cmd/sak@latest

Or compile from source:

$ git clone https://github.com/mjwhitta/nutsak.git
$ cd nutsak
$ git submodule update --init
$ make

Usage

CLI

To create a simple TCP listener:

$ sak tcp-listen:4444,fork stdout

To create a simple TCP client:

$ sak stdin tcp:4444

Library

package main

import (
    "time"

    sak "github.com/mjwhitta/nutsak"
)

func main() {
    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)
    }

    // Shutdown in 10 seconds
    go func() {
        time.Sleep(10 * time.Second)
        a.Down()
        b.Down()
    }()

    // Pair NUts to create two-way tunnel
    if e = sak.Pair(a, b); e != nil {
        panic(e)
    }
}

Links

TODO

  • Fix compiling for Windows
  • Improve TCP/TLS fork option
  • EXEC process support
  • HTTP proxy support

About

Network Utility Swiss-Army Knife similar to socat.

Resources

License

Stars

Watchers

Forks