diff --git a/config/new.go b/config/new.go index 596c9a1..09c59d7 100755 --- a/config/new.go +++ b/config/new.go @@ -7,8 +7,8 @@ import ( "strings" "time" - "gitea.inhome.blapointe.com/local/args" - "gitea.inhome.blapointe.com/local/logb" + "gitea.bel.blue/local/args" + "gitea.bel.blue/local/logb" ) var conf *args.ArgSet diff --git a/go.mod b/go.mod index e208937..21d0167 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ -module gitea.inhome.blapointe.com/local/rproxy3 +module gitea.bel.blue/local/rproxy3 go 1.18 require ( - gitea.inhome.blapointe.com/local/args v0.0.0-20240109214601-658deda479a4 - gitea.inhome.blapointe.com/local/logb v0.0.0-20231109150430-1221d87a6dbc + gitea.bel.blue/local/args v0.0.0-20251121001304-83c57f856714 + gitea.bel.blue/local/logb v0.0.0-20251121001353-d45d53fbaae9 github.com/google/uuid v1.3.0 golang.org/x/time v0.1.0 ) @@ -13,6 +13,5 @@ require gopkg.in/yaml.v2 v2.4.0 require ( github.com/kr/pretty v0.1.0 // indirect - github.com/yl2chen/cidranger v1.0.2 // indirect gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect ) diff --git a/go.sum b/go.sum index c357619..1328ca4 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,7 @@ -gitea.inhome.blapointe.com/local/args v0.0.0-20240109214601-658deda479a4 h1:4qBHjKAiEwRV1A1tN1JK6PsLV1+UwESXKrjGqfCCdNk= -gitea.inhome.blapointe.com/local/args v0.0.0-20240109214601-658deda479a4/go.mod h1:SqCOE3bE3wvrztVIQGHuyxHKfDjRKU9EWhBdkmkiwyc= -gitea.inhome.blapointe.com/local/logb v0.0.0-20231109150430-1221d87a6dbc h1:u3akQkq12V8xWXlcDgjZxIK6hqo6f1eHd9KOxAKMoKc= -gitea.inhome.blapointe.com/local/logb v0.0.0-20231109150430-1221d87a6dbc/go.mod h1:KwilawX4UgD4HxSJAVFEzkuckrnHeQrd49KwUX6GpYU= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +gitea.bel.blue/local/args v0.0.0-20251121001304-83c57f856714 h1:JHV86INH1QmPJoyIhdrDLJq7OKta+fJAwbK0pnxI4Hc= +gitea.bel.blue/local/args v0.0.0-20251121001304-83c57f856714/go.mod h1:GCzui3GPhOgKgGYNqtW55YkI3vIWCQEHPydGjFhaXV0= +gitea.bel.blue/local/logb v0.0.0-20251121001353-d45d53fbaae9 h1:lBkQPYgWZnPxt6CvsSwVh9EZtuvi2lIbGOHPqe/gn1Y= +gitea.bel.blue/local/logb v0.0.0-20251121001353-d45d53fbaae9/go.mod h1:+8sJb8UksdadKy43czL7/3TcfBwCkuYT6hFY+RaxP48= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= @@ -10,16 +9,10 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/yl2chen/cidranger v1.0.2 h1:lbOWZVCG1tCRX4u24kuM1Tb4nHqWkDxwLdoS+SevawU= -github.com/yl2chen/cidranger v1.0.2/go.mod h1:9U1yz7WPYDwf0vpNWFaeRh0bjwz5RVgRy/9UEQfHl0g= golang.org/x/time v0.1.0 h1:xYY+Bajn2a7VBmTM5GikTmnK8ZuX8YgnQCqZpbBNtmA= golang.org/x/time v0.1.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= diff --git a/main.go b/main.go index e0e9b9a..c745b14 100755 --- a/main.go +++ b/main.go @@ -1,8 +1,8 @@ package main import ( - "gitea.inhome.blapointe.com/local/rproxy3/config" - "gitea.inhome.blapointe.com/local/rproxy3/server" + "gitea.bel.blue/local/rproxy3/config" + "gitea.bel.blue/local/rproxy3/server" ) func main() { diff --git a/server/new.go b/server/new.go index 48269c1..4c900ba 100755 --- a/server/new.go +++ b/server/new.go @@ -1,8 +1,8 @@ package server import ( - "gitea.inhome.blapointe.com/local/rproxy3/config" - "gitea.inhome.blapointe.com/local/rproxy3/storage" + "gitea.bel.blue/local/rproxy3/config" + "gitea.bel.blue/local/rproxy3/storage" "golang.org/x/time/rate" ) diff --git a/server/proxy.go b/server/proxy.go index 51a10b5..05dd216 100755 --- a/server/proxy.go +++ b/server/proxy.go @@ -10,8 +10,8 @@ import ( "net/url" "strings" - "gitea.inhome.blapointe.com/local/rproxy3/config" - "gitea.inhome.blapointe.com/local/rproxy3/storage/packable" + "gitea.bel.blue/local/rproxy3/config" + "gitea.bel.blue/local/rproxy3/storage/packable" ) type redirPurge struct { diff --git a/server/routes.go b/server/routes.go index 7d30def..09aa319 100755 --- a/server/routes.go +++ b/server/routes.go @@ -1,7 +1,7 @@ package server import ( - "gitea.inhome.blapointe.com/local/rproxy3/config" + "gitea.bel.blue/local/rproxy3/config" ) func (s *Server) Routes() error { diff --git a/server/server.go b/server/server.go index ba4752c..c9429eb 100755 --- a/server/server.go +++ b/server/server.go @@ -17,9 +17,9 @@ import ( "strings" "time" - "gitea.inhome.blapointe.com/local/rproxy3/config" - "gitea.inhome.blapointe.com/local/rproxy3/storage" - "gitea.inhome.blapointe.com/local/rproxy3/storage/packable" + "gitea.bel.blue/local/rproxy3/config" + "gitea.bel.blue/local/rproxy3/storage" + "gitea.bel.blue/local/rproxy3/storage/packable" "github.com/google/uuid" "golang.org/x/time/rate" @@ -30,9 +30,10 @@ const nsRouting = "routing" type listenerScheme int const ( - schemeHTTP listenerScheme = iota - schemeHTTPS listenerScheme = iota - schemeTCP listenerScheme = iota + schemeHTTP listenerScheme = iota + schemeHTTPS + schemeTCP + schemeTCPTLS ) func (ls listenerScheme) String() string { @@ -43,6 +44,8 @@ func (ls listenerScheme) String() string { return "https" case schemeTCP: return "tcp" + case schemeTCPTLS: + return "tcptls" } return "" } @@ -101,15 +104,50 @@ func (s *Server) Run() error { case schemeTCP: addr, _ := config.GetTCP() return s.ServeTCP(addr) + case schemeTCPTLS: + addr, _ := config.GetTCP() + cert, key, _ := config.GetSSL() + return s.ServeTCPTLS(addr, cert, key) } return errors.New("did not load server") } +func (s *Server) ServeTCPTLS(addr, c, k string) error { + certificate, err := tls.LoadX509KeyPair(c, k) + if err != nil { + return err + } + certificates := []tls.Certificate{certificate} + listen, err := net.Listen("tcp", s.addr) + if err != nil { + return err + } + defer listen.Close() + tlsListener, err := tls.NewListener(listen, &tls.Config{ + Certificates: certificates, + MinVersion: tls.VersionTLS12, + CurvePreferences: []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256}, + PreferServerCipherSuites: true, + CipherSuites: []uint16{ + tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, + tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, + tls.TLS_RSA_WITH_AES_256_GCM_SHA384, + tls.TLS_RSA_WITH_AES_256_CBC_SHA, + }, + }) + return s.serveTCP(addr, listen) +} + func (s *Server) ServeTCP(addr string) error { listen, err := net.Listen("tcp", s.addr) if err != nil { return err } + defer listen.Close() + return s.serveTCP(addr, listen) +} + +func (s *Server) serveTCP(addr string, listen net.Listener) error { for { c, err := listen.Accept() if err != nil { @@ -338,11 +376,15 @@ func (s *Server) alt() { func getScheme() listenerScheme { scheme := schemeHTTP - if _, _, ok := config.GetSSL(); ok { + _, _, ssl := config.GetSSL() + if ssl { scheme = schemeHTTPS } if _, ok := config.GetTCP(); ok { scheme = schemeTCP + if ssl { + scheme = schemeTCPTLS + } } return scheme } diff --git a/server/server_test.go b/server/server_test.go index c5597e7..8afa025 100755 --- a/server/server_test.go +++ b/server/server_test.go @@ -8,8 +8,8 @@ import ( "strings" "testing" - "gitea.inhome.blapointe.com/local/rproxy3/config" - "gitea.inhome.blapointe.com/local/rproxy3/storage" + "gitea.bel.blue/local/rproxy3/config" + "gitea.bel.blue/local/rproxy3/storage" "golang.org/x/time/rate" ) diff --git a/storage/db.go b/storage/db.go index 8481217..251d42b 100755 --- a/storage/db.go +++ b/storage/db.go @@ -3,7 +3,7 @@ package storage import ( "errors" - "gitea.inhome.blapointe.com/local/rproxy3/storage/packable" + "gitea.bel.blue/local/rproxy3/storage/packable" ) var ErrNotFound = errors.New("not found") diff --git a/storage/db_test.go b/storage/db_test.go index 76adfdb..12f0cb4 100755 --- a/storage/db_test.go +++ b/storage/db_test.go @@ -1,9 +1,10 @@ package storage import ( - "gitea.inhome.blapointe.com/local/rproxy3/storage/packable" "os" "testing" + + "gitea.bel.blue/local/rproxy3/storage/packable" ) func TestDB(t *testing.T) { diff --git a/storage/map.go b/storage/map.go index f2fa458..f5ba8ec 100755 --- a/storage/map.go +++ b/storage/map.go @@ -3,7 +3,7 @@ package storage import ( "fmt" - "gitea.inhome.blapointe.com/local/rproxy3/storage/packable" + "gitea.bel.blue/local/rproxy3/storage/packable" ) type Map map[string]map[string][]byte