mto bel.blue thanks render

master
Bel LaPointe 2025-11-20 17:14:50 -07:00
parent 3b53ef938d
commit 4a0e3c15e9
12 changed files with 71 additions and 36 deletions

View File

@ -7,8 +7,8 @@ import (
"strings" "strings"
"time" "time"
"gitea.inhome.blapointe.com/local/args" "gitea.bel.blue/local/args"
"gitea.inhome.blapointe.com/local/logb" "gitea.bel.blue/local/logb"
) )
var conf *args.ArgSet var conf *args.ArgSet

7
go.mod
View File

@ -1,10 +1,10 @@
module gitea.inhome.blapointe.com/local/rproxy3 module gitea.bel.blue/local/rproxy3
go 1.18 go 1.18
require ( require (
gitea.inhome.blapointe.com/local/args v0.0.0-20240109214601-658deda479a4 gitea.bel.blue/local/args v0.0.0-20251121001304-83c57f856714
gitea.inhome.blapointe.com/local/logb v0.0.0-20231109150430-1221d87a6dbc gitea.bel.blue/local/logb v0.0.0-20251121001353-d45d53fbaae9
github.com/google/uuid v1.3.0 github.com/google/uuid v1.3.0
golang.org/x/time v0.1.0 golang.org/x/time v0.1.0
) )
@ -13,6 +13,5 @@ require gopkg.in/yaml.v2 v2.4.0
require ( require (
github.com/kr/pretty v0.1.0 // indirect 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 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
) )

15
go.sum
View File

@ -1,8 +1,7 @@
gitea.inhome.blapointe.com/local/args v0.0.0-20240109214601-658deda479a4 h1:4qBHjKAiEwRV1A1tN1JK6PsLV1+UwESXKrjGqfCCdNk= gitea.bel.blue/local/args v0.0.0-20251121001304-83c57f856714 h1:JHV86INH1QmPJoyIhdrDLJq7OKta+fJAwbK0pnxI4Hc=
gitea.inhome.blapointe.com/local/args v0.0.0-20240109214601-658deda479a4/go.mod h1:SqCOE3bE3wvrztVIQGHuyxHKfDjRKU9EWhBdkmkiwyc= gitea.bel.blue/local/args v0.0.0-20251121001304-83c57f856714/go.mod h1:GCzui3GPhOgKgGYNqtW55YkI3vIWCQEHPydGjFhaXV0=
gitea.inhome.blapointe.com/local/logb v0.0.0-20231109150430-1221d87a6dbc h1:u3akQkq12V8xWXlcDgjZxIK6hqo6f1eHd9KOxAKMoKc= gitea.bel.blue/local/logb v0.0.0-20251121001353-d45d53fbaae9 h1:lBkQPYgWZnPxt6CvsSwVh9EZtuvi2lIbGOHPqe/gn1Y=
gitea.inhome.blapointe.com/local/logb v0.0.0-20231109150430-1221d87a6dbc/go.mod h1:KwilawX4UgD4HxSJAVFEzkuckrnHeQrd49KwUX6GpYU= gitea.bel.blue/local/logb v0.0.0-20251121001353-d45d53fbaae9/go.mod h1:+8sJb8UksdadKy43czL7/3TcfBwCkuYT6hFY+RaxP48=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= 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/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= 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/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 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 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 h1:xYY+Bajn2a7VBmTM5GikTmnK8ZuX8YgnQCqZpbBNtmA=
golang.org/x/time v0.1.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 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 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 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 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 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=

View File

@ -1,8 +1,8 @@
package main package main
import ( import (
"gitea.inhome.blapointe.com/local/rproxy3/config" "gitea.bel.blue/local/rproxy3/config"
"gitea.inhome.blapointe.com/local/rproxy3/server" "gitea.bel.blue/local/rproxy3/server"
) )
func main() { func main() {

View File

@ -1,8 +1,8 @@
package server package server
import ( import (
"gitea.inhome.blapointe.com/local/rproxy3/config" "gitea.bel.blue/local/rproxy3/config"
"gitea.inhome.blapointe.com/local/rproxy3/storage" "gitea.bel.blue/local/rproxy3/storage"
"golang.org/x/time/rate" "golang.org/x/time/rate"
) )

View File

@ -10,8 +10,8 @@ import (
"net/url" "net/url"
"strings" "strings"
"gitea.inhome.blapointe.com/local/rproxy3/config" "gitea.bel.blue/local/rproxy3/config"
"gitea.inhome.blapointe.com/local/rproxy3/storage/packable" "gitea.bel.blue/local/rproxy3/storage/packable"
) )
type redirPurge struct { type redirPurge struct {

View File

@ -1,7 +1,7 @@
package server package server
import ( import (
"gitea.inhome.blapointe.com/local/rproxy3/config" "gitea.bel.blue/local/rproxy3/config"
) )
func (s *Server) Routes() error { func (s *Server) Routes() error {

View File

@ -17,9 +17,9 @@ import (
"strings" "strings"
"time" "time"
"gitea.inhome.blapointe.com/local/rproxy3/config" "gitea.bel.blue/local/rproxy3/config"
"gitea.inhome.blapointe.com/local/rproxy3/storage" "gitea.bel.blue/local/rproxy3/storage"
"gitea.inhome.blapointe.com/local/rproxy3/storage/packable" "gitea.bel.blue/local/rproxy3/storage/packable"
"github.com/google/uuid" "github.com/google/uuid"
"golang.org/x/time/rate" "golang.org/x/time/rate"
@ -30,9 +30,10 @@ const nsRouting = "routing"
type listenerScheme int type listenerScheme int
const ( const (
schemeHTTP listenerScheme = iota schemeHTTP listenerScheme = iota
schemeHTTPS listenerScheme = iota schemeHTTPS
schemeTCP listenerScheme = iota schemeTCP
schemeTCPTLS
) )
func (ls listenerScheme) String() string { func (ls listenerScheme) String() string {
@ -43,6 +44,8 @@ func (ls listenerScheme) String() string {
return "https" return "https"
case schemeTCP: case schemeTCP:
return "tcp" return "tcp"
case schemeTCPTLS:
return "tcptls"
} }
return "" return ""
} }
@ -101,15 +104,50 @@ func (s *Server) Run() error {
case schemeTCP: case schemeTCP:
addr, _ := config.GetTCP() addr, _ := config.GetTCP()
return s.ServeTCP(addr) 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") 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 { func (s *Server) ServeTCP(addr string) error {
listen, err := net.Listen("tcp", s.addr) listen, err := net.Listen("tcp", s.addr)
if err != nil { if err != nil {
return err return err
} }
defer listen.Close()
return s.serveTCP(addr, listen)
}
func (s *Server) serveTCP(addr string, listen net.Listener) error {
for { for {
c, err := listen.Accept() c, err := listen.Accept()
if err != nil { if err != nil {
@ -338,11 +376,15 @@ func (s *Server) alt() {
func getScheme() listenerScheme { func getScheme() listenerScheme {
scheme := schemeHTTP scheme := schemeHTTP
if _, _, ok := config.GetSSL(); ok { _, _, ssl := config.GetSSL()
if ssl {
scheme = schemeHTTPS scheme = schemeHTTPS
} }
if _, ok := config.GetTCP(); ok { if _, ok := config.GetTCP(); ok {
scheme = schemeTCP scheme = schemeTCP
if ssl {
scheme = schemeTCPTLS
}
} }
return scheme return scheme
} }

View File

@ -8,8 +8,8 @@ import (
"strings" "strings"
"testing" "testing"
"gitea.inhome.blapointe.com/local/rproxy3/config" "gitea.bel.blue/local/rproxy3/config"
"gitea.inhome.blapointe.com/local/rproxy3/storage" "gitea.bel.blue/local/rproxy3/storage"
"golang.org/x/time/rate" "golang.org/x/time/rate"
) )

View File

@ -3,7 +3,7 @@ package storage
import ( import (
"errors" "errors"
"gitea.inhome.blapointe.com/local/rproxy3/storage/packable" "gitea.bel.blue/local/rproxy3/storage/packable"
) )
var ErrNotFound = errors.New("not found") var ErrNotFound = errors.New("not found")

View File

@ -1,9 +1,10 @@
package storage package storage
import ( import (
"gitea.inhome.blapointe.com/local/rproxy3/storage/packable"
"os" "os"
"testing" "testing"
"gitea.bel.blue/local/rproxy3/storage/packable"
) )
func TestDB(t *testing.T) { func TestDB(t *testing.T) {

View File

@ -3,7 +3,7 @@ package storage
import ( import (
"fmt" "fmt"
"gitea.inhome.blapointe.com/local/rproxy3/storage/packable" "gitea.bel.blue/local/rproxy3/storage/packable"
) )
type Map map[string]map[string][]byte type Map map[string]map[string][]byte