mto bel.blue thanks render
parent
3b53ef938d
commit
4a0e3c15e9
|
|
@ -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
|
||||
|
|
|
|||
7
go.mod
7
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
|
||||
)
|
||||
|
|
|
|||
15
go.sum
15
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=
|
||||
|
|
|
|||
4
main.go
4
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() {
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue