pipe

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

README

pipe

SSH connections are breaking with MAC issue after sending large files, preventing automatic admin such as ansible.

Pipe is intended to test alternatives.

Results

io.Copy

a direct io.Copy between read and write appears bombproof

io.Copy to bi-directional channel pair as an intermediary

This exhibits the same failure mechanisms as our relay. It implies that there is some side-effect to do with the timing of io.Copy channels that is resulting in the issue (assumed to be packet combination)

Ideas

websocket intermediary
Initial stage

io.Copy from conn (tcp) to conn (websocket), set one side up as websocket client, the other as server

If that works, then extend to include

[conn(tcp)<->conn(ws)]<->[conn(ws)<->channels]<->[channels<->conn(ws)]<->[conn(ws)<->conn(tcp)]

if that works, then theoretically, this should work

[conn(tcp)<->conn(ws)]<->[conn(ws)<->channels]<->[channel-based relay]<->[channels<->conn(ws)]<->[conn(ws)<->conn(tcp)]

Reconnecting

There is work in googles corp-relay to allow ssh connections to be retained over broken connections.

This looks useful, although complicates the implementation initially.

As an intermediate step consider this approach

(a) management connection on host side continues to use reconws, because it does not actually convey any ssh data so can continue in present form. Thus restarting server etc won't prevent the management connection from being made, but it will break any existing connections. (b) modify the host ssh connections to use some one-off conn-based io.Copy() approach (if that works) (c) modify the client ssh connections to use the same

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Listen int
	Target int
}

type Pipe

type Pipe struct {
	Left   chan []byte
	Listen int
	Right  chan []byte
	Target int
}

func New

func New(config Config) *Pipe

func (*Pipe) Run

func (p *Pipe) Run(ctx context.Context)

func (*Pipe) RunChannel

func (p *Pipe) RunChannel(ctx context.Context)
         |--------|          |--------|             |--------|           |--------|
         \        \  ---->   \        \ ----a--->   \        \  ---->    \        \
Target   | target | io.Copy  | left   |  channels   | right  | io.Copy   | client |  Listen
Port     \        \  <----   \        \             \        \  <-----   \        \  Port
         |--------|          |--------| <---b-----  |--------|           |--------|

RunDevelop represents a pipe with an intermediate communication over channels which, if it works, proves that we can relay because our websocket clients have a channel-based interface (TODO consider if that should stay the case?)

func (*Pipe) RunCopy

func (p *Pipe) RunCopy(ctx context.Context)

func (*Pipe) RunDevelop

func (p *Pipe) RunDevelop(ctx context.Context)

func (*Pipe) RunWS

func (p *Pipe) RunWS(ctx context.Context)
                              using freeport
         |--------|          |--------|             |--------|           |--------|
         \        \  ---->   \        \             \        \  ---->    \        \
Target   | target | io.Copy  | host   |  websocket  | client | io.Copy   | client |  Listen
Port     \        \  <----   \        \   <--->     \        \  <-----   \        \  Port
         |--------|          |--------|             |--------|           |--------|

This works with simultaneous connections, even streaming large binary files at the same time

func (*Pipe) RunWSChan

func (p *Pipe) RunWSChan(ctx context.Context)
                              using freeport0                                using freeport1
                              wsPort0               wsURL0                  wsPort1                wsURL1
         |--------|          |--------|             |--------|              |--------|             |--------|           |--------|
         \ tcp    \  ---->   \ ws     \             \ ws     \  ----a--->   \ ws     \             \ ws     \  ---->    \ tcp    \
Target   | target | io.Copy  | host   |  websocket  | client |   channels   | host   |  websocket  | client | io.Copy   | client |  Listen
Port     \        \  <----   \        \   <--->     \        \              \        \   <--->     \        \  <-----   \        \  Port
         |--------|          |--------|             |--------|  <---b-----  |--------|             |--------|           |--------|

Part    |<---------- A ------------------>|<------B--------------->|<--------C----------->|<------------------D---------------->|

This can also relay large binary files without error, so the websocket to channel implementation here is ok This is different to approach taken in the existing shellbar hub, so that needs testing/revising

Jump to

Keyboard shortcuts

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