Skip to content
This repository was archived by the owner on May 26, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
slt
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/kmanley/slt

go 1.14

require (
github.com/go-yaml/yaml v2.1.0+incompatible
github.com/inconshreveable/go-vhost v0.0.0-20160627193104-06d84117953b
)
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/go-yaml/yaml v2.1.0+incompatible h1:RYi2hDdss1u4YE7GwixGzWwVo47T8UQwnTLB6vQiq+o=
github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0=
github.com/inconshreveable/go-vhost v0.0.0-20160627193104-06d84117953b h1:IpLPmn6Re21F0MaV6Zsc5RdSE6KuoFpWmHiUSEs3PrE=
github.com/inconshreveable/go-vhost v0.0.0-20160627193104-06d84117953b/go.mod h1:aA6DnFhALT3zH0y+A39we+zbrdMC2N0X/q21e6FI0LU=
28 changes: 21 additions & 7 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import (
"crypto/tls"
"flag"
"fmt"
"github.com/go-yaml/yaml"
vhost "github.com/inconshreveable/go-vhost"
"io"
"io/ioutil"
"log"
"net"
"os"
"sync"
"time"

"github.com/go-yaml/yaml"
vhost "github.com/inconshreveable/go-vhost"
)

const (
Expand Down Expand Up @@ -131,7 +132,7 @@ func (s *Server) runFrontend(name string, front *Frontend, l net.Listener) {
// accept next connection to this frontend
conn, err := l.Accept()
if err != nil {
s.Printf("Failed to accept new connection for '%v': %v", conn.RemoteAddr())
s.Printf("Failed to accept new connection for '%v': %v", conn.RemoteAddr(), err)
if e, ok := err.(net.Error); ok {
if e.Temporary() {
continue
Expand Down Expand Up @@ -170,13 +171,15 @@ func (s *Server) proxyConnection(c net.Conn, front *Frontend) (err error) {
}

func (s *Server) joinConnections(c1 net.Conn, c2 net.Conn) {
defer c1.Close()
defer c2.Close()
var wg sync.WaitGroup
halfJoin := func(dst net.Conn, src net.Conn) {
defer wg.Done()
defer dst.Close()
defer src.Close()
n, err := io.Copy(dst, src)
s.Printf("Copy from %v to %v failed after %d bytes with error %v", src.RemoteAddr(), dst.RemoteAddr(), n, err)
if err != nil {
s.Printf("Copy from %v to %v failed after %d bytes with error %v", src.RemoteAddr(), dst.RemoteAddr(), n, err)
}
}

s.Printf("Joining connections: %v %v", c1.RemoteAddr(), c2.RemoteAddr())
Expand Down Expand Up @@ -289,7 +292,18 @@ func loadTLSConfig(crtPath, keyPath string) (*tls.Config, error) {
}

return &tls.Config{
Certificates: []tls.Certificate{cert},
Certificates: []tls.Certificate{cert},
MinVersion: tls.VersionTLS12,
CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256},
PreferServerCipherSuites: true,
CipherSuites: []uint16{
tls.TLS_AES_128_GCM_SHA256, // TLS 1.3
tls.TLS_AES_256_GCM_SHA384, // TLS 1.3
tls.TLS_CHACHA20_POLY1305_SHA256, // TLS 1.3
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, // TLS 1.2
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, // TLS 1.2
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, // TLS 1.2
},
}, nil
}

Expand Down