all: Support multiple device connections (fixes #141) (#8918)

This adds the ability to have multiple concurrent connections to a single device. This is primarily useful when the network has multiple physical links for aggregated bandwidth. A single connection will never see a higher rate than a single link can give, but multiple connections are load-balanced over multiple links.

It is also incidentally useful for older multi-core CPUs, where bandwidth could be limited by the TLS performance of a single CPU core -- using multiple connections achieves concurrency in the required crypto calculations...

Co-authored-by: Simon Frei <freisim93@gmail.com>
Co-authored-by: tomasz1986 <twilczynski@naver.com>
Co-authored-by: bt90 <btom1990@googlemail.com>
This commit is contained in:
Jakob Borg
2023-09-06 12:52:01 +02:00
committed by GitHub
co-authored by Simon Frei tomasz1986 bt90
parent 38bbdebffa
commit c6334e61aa
41 changed files with 1640 additions and 933 deletions
+5 -10
View File
@@ -8,14 +8,6 @@ import (
"io"
)
// The HelloIntf interface is implemented by the version specific hello
// message. It knows its magic number and how to serialize itself to a byte
// buffer.
type HelloIntf interface {
Magic() uint32
Marshal() ([]byte, error)
}
var (
// ErrTooOldVersion is returned by ExchangeHello when the other side
// speaks an older, incompatible version of the protocol.
@@ -25,7 +17,10 @@ var (
ErrUnknownMagic = errors.New("the remote device speaks an unknown (newer?) version of the protocol")
)
func ExchangeHello(c io.ReadWriter, h HelloIntf) (Hello, error) {
func ExchangeHello(c io.ReadWriter, h Hello) (Hello, error) {
if h.Timestamp == 0 {
panic("bug: missing timestamp in outgoing hello")
}
if err := writeHello(c, h); err != nil {
return Hello{}, err
}
@@ -80,7 +75,7 @@ func readHello(c io.Reader) (Hello, error) {
return Hello{}, ErrUnknownMagic
}
func writeHello(c io.Writer, h HelloIntf) error {
func writeHello(c io.Writer, h Hello) error {
msg, err := h.Marshal()
if err != nil {
return err