修复HTTP传输时可能无法传递TOA的问题

This commit is contained in:
GoEdgeLab
2023-07-23 18:49:50 +08:00
parent c2895a296c
commit 22a600dd0a
2 changed files with 5 additions and 3 deletions

View File

@@ -4,9 +4,11 @@ import (
"context"
"crypto/tls"
"errors"
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/TeaOSLab/EdgeNode/internal/goman"
"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
"github.com/iwind/TeaGo/types"
"github.com/pires/go-proxyproto"
"golang.org/x/net/http2"
"net"
@@ -224,7 +226,7 @@ func (this *HTTPClientPool) handleTOA(req *HTTPRequest, ctx context.Context, net
for i := 1; i <= retries; i++ {
var port = int(toaConfig.RandLocalPort())
// TODO 思考是否支持X-Real-IP/X-Forwarded-IP
err := sharedTOAManager.SendMsg("add:" + strconv.Itoa(port) + ":" + req.requestRemoteAddr(true))
err := sharedTOAManager.SendMsg("add:" + strconv.Itoa(port) + ":" + configutils.QuoteIP(req.requestRemoteAddr(true)) + ":" + types.String(req.RemotePort()))
if err != nil {
remotelogs.Error("TOA", "add failed: "+err.Error())
} else {

View File

@@ -60,14 +60,14 @@ func (this *TOAManager) Run(config *nodeconfigs.TOAConfig) error {
return nil
}
binPath := Tea.Root + "/edge-toa/edge-toa" // TODO 可以做成配置
var binPath = Tea.Root + "/edge-toa/edge-toa" // TODO 可以做成配置
_, err := os.Stat(binPath)
if err != nil {
return err
}
remotelogs.Println("TOA", "starting ...")
remotelogs.Println("TOA", "args: "+strings.Join(config.AsArgs(), " "))
cmd := executils.NewCmd(binPath, config.AsArgs()...)
var cmd = executils.NewCmd(binPath, config.AsArgs()...)
err = cmd.Start()
if err != nil {
return err