imux

package module
v0.0.0-...-b325b24 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2018 License: MIT Imports: 9 Imported by: 0

README

imux

imux is a go library and corresponding command line tool for inverse multiplexing sockets

imux

An imux client will create a listener and forward data from any connections to that listener to an imux server, using a configurable number of sockets. An imux server receives data and opens corresponding sockets to the final destination. Encryption is done with self-signed TLS and Trust Of First Use (TOFU).

installation

go get github.com/hkparker/imux/...

example

let's say you wanted to expose an SSH server over imux

server

serve imux on 0.0.0.0:443 and connect out to localhost:22

imux -server --listen=0.0.0.0:443 --dial=localhost:22

client

inverse multiplex over 10 sockets bound to any interface and connect to the server

imux -client --binds='{"0.0.0.0": 10}' --listen=localhost:22 --dial=server:443

now on the client, connect to localhost:22 to ssh to the sever's localhost:22 over the imux connection

ssh localhost

multiple routes

imux can be used to transport a single socket over multiple internet connections using source routing in linux

For example, consider simultaneously using two interfaces:

Interface Address Default Gateway
eth0 192.168.1.2 192.168.1.1
eth1 10.0.0.2 10.0.0.1

create routing tables

echo '128    imux0' >> /etc/iproute2/rt_tables
echo '129    imux1' >> /etc/iproute2/rt_tables

add routes

ip route add default via 192.168.1.1 table imux0 dev eth0
ip route add default via 10.0.0.1 table imux1 dev eth1

add rules

ip rule add from 192.168.1.2 table imux0
ip rule add from 10.0.0.2 table imux1

flush cache

ip route flush cache

connect with binds

here we choose 20 sockets on each interface

imux -client --binds='{"192.168.1.2": 20, "10.0.0.2": 20}' --listen=localhost:22 --dial=server:443

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FailedSocketOuts = make(map[string]chan bool)

Chan of failures to write to destinations

View Source
var MaxChunkDataSize = 16384

Functions

func ManyToOne

func ManyToOne(listener net.Listener, dial_destination Redialer)

Create a new TLB server to accept chunks from anywhere and order them, writing them to corresponding sockets

func OneToMany

func OneToMany(listener net.Listener, binds map[string]int, redialer_generator RedialerGenerator) error

Provide a net.Listener, for which any accepted sockets will have their data inverse multiplexed to a corresponding socket on the server.

Types

type Chunk

type Chunk struct {
	SessionID  string
	SocketID   string
	SequenceID uint64
	Data       []byte
	Close      bool
	Setup      bool
}

A chunk represents a piece of information exchanged between a socket on the client side and a socket on the server size. A session ID defines sockets that are part of one imux session, while the socket ID specifies which socket a chunk should queue into, ordered by the Sequence ID.

type DataIMUX

type DataIMUX struct {
	Chunks    chan Chunk
	Stale     chan Chunk
	SessionID string
}

A DataIMUX will read data from multiple io.Readers and chunk the data into a chunk chan. The Stale attribute provides a way to insert chunks back into the chan from external sources.

func NewDataIMUX

func NewDataIMUX(session_id string) DataIMUX

Create a new DataIMUX for a given session

func (*DataIMUX) ReadFrom

func (data_imux *DataIMUX) ReadFrom(id string, conn io.Reader)

Read from a new data source in this DataIMUX, create chunks from it tagged with the provided socket ID.

type IMUXSocket

type IMUXSocket struct {
	IMUXer   DataIMUX
	Redialer Redialer
}

A client socket that transports data in an imux session, autoreconnecting

type Redialer

type Redialer func() (net.Conn, error)

A function that can be called by an IMUXSocket to reconnect after an error

type RedialerGenerator

type RedialerGenerator func(string) Redialer

A function that generates Redialers for specific bind addresses

type WriteQueue

type WriteQueue struct {
	Chunks chan *Chunk
	// contains filtered or unexported fields
}

A WriteQueue will receive chunks and order them, writing their data out to the Destination in the correct order

func NewWriteQueue

func NewWriteQueue(destination io.WriteCloser) *WriteQueue

Directories

Path Synopsis
bin

Jump to

Keyboard shortcuts

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