working commit

This commit is contained in:
2026-05-30 13:37:43 +02:00
parent 89db87e7fa
commit cb69ca11aa
5 changed files with 21 additions and 1 deletions
+7
View File
@@ -7,6 +7,7 @@ import (
"io"
"net"
"net/http"
"strings"
"sync"
"mproxy/app/router"
@@ -16,6 +17,12 @@ func (hand *Handler) ConnectTo(rctx *router.Context) {
hostaddr := rctx.GetHost()
hand.logg.Debugf("Hostaddr: [%s]", hostaddr)
if strings.Contains(hostaddr, "https://") {
hand.logg.Errorf("Wrong request, found schema definition in Host")
rctx.SetStatus(http.StatusBadRequest)
return
}
destConn, err := net.Dial("tcp", hostaddr)
if err != nil {
hand.logg.Errorf("ConnectTo error: %v", err)
+7
View File
@@ -7,6 +7,7 @@ import (
"context"
"io"
"net/http"
"strings"
"time"
"mproxy/app/router"
@@ -16,6 +17,12 @@ func (hand *Handler) PlainCall(rctx *router.Context) {
hostaddr := rctx.GetHost()
hand.logg.Debugf("Hostaddr: [%s]", hostaddr)
if !strings.Contains(hostaddr, "http://") {
hand.logg.Errorf("Non-proxy request, not found schema definition in Host")
rctx.SetStatus(http.StatusBadRequest)
return
}
ctx := rctx.GetContext()
ctx, _ = context.WithTimeout(ctx, 5*time.Second)
reqMethod := rctx.Request.Method
+3 -1
View File
@@ -1,12 +1,13 @@
module mproxy
go 1.26.2
go 1.26
require (
github.com/google/uuid v1.6.0
github.com/spf13/cobra v1.10.2
github.com/spf13/viper v1.21.0
github.com/stretchr/testify v1.11.1
github.com/vmihailenco/msgpack/v5 v5.4.1
go.yaml.in/yaml/v4 v4.0.0-rc.4
sigs.k8s.io/yaml v1.6.0
)
@@ -26,6 +27,7 @@ require (
github.com/spf13/cast v1.10.0 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/sys v0.29.0 // indirect
+4
View File
@@ -45,6 +45,10 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI=
go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=