init
This commit is contained in:
parent
cd8adaea06
commit
43aa894030
@ -145,13 +145,10 @@ func (ctl *Control) HandleReqWorkConn(inMsg *msg.ReqWorkConn) {
|
||||
m := &msg.NewWorkConn{
|
||||
RunID: ctl.runID,
|
||||
}
|
||||
xl.Info("SetNewWorkConn")
|
||||
if err = ctl.authSetter.SetNewWorkConn(m); err != nil {
|
||||
xl.Warn("error during NewWorkConn authentication: %v", err)
|
||||
return
|
||||
}
|
||||
xl.Info("WriteMsg - NewWorkConn")
|
||||
|
||||
if err = msg.WriteMsg(workConn, m); err != nil {
|
||||
xl.Warn("work connection write to server error: %v", err)
|
||||
workConn.Close()
|
||||
@ -159,20 +156,17 @@ func (ctl *Control) HandleReqWorkConn(inMsg *msg.ReqWorkConn) {
|
||||
}
|
||||
|
||||
var startMsg msg.StartWorkConn
|
||||
xl.Info("Starting to read - NewWorkConn")
|
||||
if err = msg.ReadMsgInto(workConn, &startMsg); err != nil {
|
||||
xl.Error("work connection closed before response StartWorkConn message: %v", err)
|
||||
workConn.Close()
|
||||
return
|
||||
}
|
||||
xl.Info("Finished to read - NewWorkConn")
|
||||
if startMsg.Error != "" {
|
||||
xl.Error("StartWorkConn contains error: %s", startMsg.Error)
|
||||
workConn.Close()
|
||||
return
|
||||
}
|
||||
|
||||
xl.Info("Call to HandleWorkConn")
|
||||
// dispatch this work connection to related proxy
|
||||
ctl.pm.HandleWorkConn(startMsg.ProxyName, workConn, &startMsg)
|
||||
}
|
||||
@ -404,7 +398,6 @@ func (ctl *Control) msgHandler() {
|
||||
|
||||
switch m := rawMsg.(type) {
|
||||
case *msg.ReqWorkConn:
|
||||
xl.Info("ReqWorkConn msg")
|
||||
go ctl.HandleReqWorkConn(m)
|
||||
case *msg.NewProxyResp:
|
||||
ctl.HandleNewProxyResp(m)
|
||||
|
@ -1,14 +1,9 @@
|
||||
[common]
|
||||
server_addr = tunnel.io
|
||||
server_port = 7005
|
||||
protocol = websocket
|
||||
log_level = debug
|
||||
server_addr = 127.0.0.1
|
||||
server_port = 7000
|
||||
|
||||
[web]
|
||||
type = http
|
||||
local_port = 3002
|
||||
meta_Authorization = {{ .Envs.AUTHORIZATION }}
|
||||
subdomain = ziv
|
||||
;ips_allow_list = "127.0.0.2/32,192.198.100.10"
|
||||
;http_user = abc
|
||||
;http_pwd = abc
|
||||
[ssh]
|
||||
type = tcp
|
||||
local_ip = 127.0.0.1
|
||||
local_port = 22
|
||||
remote_port = 6000
|
||||
|
@ -1,15 +1,2 @@
|
||||
[common]
|
||||
bind_port = 7005
|
||||
vhost_http_port=82
|
||||
subdomain_host=tunnel.io
|
||||
log_level = trace
|
||||
|
||||
;[plugin.codefresh]
|
||||
;addr = 127.0.0.1:7200
|
||||
;path = /newProxy
|
||||
;ops = NewProxy
|
||||
|
||||
;[plugin.codefresh]
|
||||
;addr = 127.0.0.1:7200
|
||||
;path = /newWorkConn
|
||||
;ops = Ping
|
||||
bind_port = 7000
|
||||
|
2
go.mod
2
go.mod
@ -22,7 +22,7 @@ require (
|
||||
github.com/prometheus/client_golang v1.11.0
|
||||
github.com/rodaine/table v1.0.1
|
||||
github.com/spf13/cobra v1.1.3
|
||||
github.com/stretchr/testify v1.8.0
|
||||
github.com/stretchr/testify v1.7.0
|
||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
|
||||
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 // indirect
|
||||
|
@ -61,7 +61,6 @@ func NewHTTPReverseProxy(option HTTPReverseProxyOptions, vhostRouter *Routers) *
|
||||
proxy := &ReverseProxy{
|
||||
// Modify incoming requests by route policies.
|
||||
Director: func(req *http.Request) {
|
||||
frpLog.Info("Director *********************")
|
||||
req.URL.Scheme = "http"
|
||||
url := req.Context().Value(RouteInfoURL).(string)
|
||||
routeByHTTPUser := req.Context().Value(RouteInfoHTTPUser).(string)
|
||||
@ -90,7 +89,6 @@ func NewHTTPReverseProxy(option HTTPReverseProxyOptions, vhostRouter *Routers) *
|
||||
ResponseHeaderTimeout: rp.responseHeaderTimeout,
|
||||
IdleConnTimeout: 60 * time.Second,
|
||||
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
frpLog.Info("DialContext *********************")
|
||||
url := ctx.Value(RouteInfoURL).(string)
|
||||
host, _ := util.CanonicalHost(ctx.Value(RouteInfoHost).(string))
|
||||
routerByHTTPUser := ctx.Value(RouteInfoHTTPUser).(string)
|
||||
@ -105,7 +103,6 @@ func NewHTTPReverseProxy(option HTTPReverseProxyOptions, vhostRouter *Routers) *
|
||||
// Normal:
|
||||
// GET / HTTP/1.1
|
||||
// Host: example.com
|
||||
frpLog.Info("Proxy *********************")
|
||||
urlHost := req.Context().Value(RouteInfoURLHost).(string)
|
||||
if urlHost != "" {
|
||||
return req.URL, nil
|
||||
@ -167,8 +164,6 @@ func (rp *HTTPReverseProxy) GetHeaders(domain, location, routeByHTTPUser string)
|
||||
|
||||
// CreateConnection create a new connection by route config
|
||||
func (rp *HTTPReverseProxy) CreateConnection(domain, location, routeByHTTPUser string, remoteAddr string) (net.Conn, error) {
|
||||
frpLog.Info("CreateConnection *********************")
|
||||
|
||||
vr, ok := rp.getVhost(domain, location, routeByHTTPUser)
|
||||
if ok {
|
||||
fn := vr.payload.(*RouteConfig).CreateConnFn
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
frpLog "github.com/fatedier/frp/pkg/util/log"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
@ -230,7 +229,6 @@ func parseBasicAuth(auth string) (username, password string, ok bool) {
|
||||
}
|
||||
|
||||
func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||
frpLog.Info("ServeHTTP *********************")
|
||||
transport := p.Transport
|
||||
if transport == nil {
|
||||
transport = http.DefaultTransport
|
||||
|
@ -15,7 +15,6 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
frpLog "github.com/fatedier/frp/pkg/util/log"
|
||||
"io"
|
||||
"net"
|
||||
"strings"
|
||||
@ -138,7 +137,6 @@ func (pxy *HTTPProxy) GetConf() config.ProxyConf {
|
||||
}
|
||||
|
||||
func (pxy *HTTPProxy) GetRealConn(remoteAddr string) (workConn net.Conn, err error) {
|
||||
frpLog.Info("GetRealConn *********************")
|
||||
xl := pxy.xl
|
||||
rAddr, errRet := net.ResolveTCPAddr("tcp", remoteAddr)
|
||||
if errRet != nil {
|
||||
|
@ -317,7 +317,6 @@ func (svr *Service) Run() {
|
||||
}
|
||||
|
||||
func (svr *Service) handleConnection(ctx context.Context, conn net.Conn) {
|
||||
log.Info("handleConnection! ")
|
||||
xl := xlog.FromContextSafe(ctx)
|
||||
|
||||
var (
|
||||
@ -407,7 +406,6 @@ func (svr *Service) HandleListener(l net.Listener) {
|
||||
|
||||
// Start a new goroutine to handle connection.
|
||||
go func(ctx context.Context, frpConn net.Conn) {
|
||||
log.Info("server - handle connection goroutine ")
|
||||
if svr.cfg.TCPMux {
|
||||
fmuxCfg := fmux.DefaultConfig()
|
||||
fmuxCfg.KeepAliveInterval = time.Duration(svr.cfg.TCPMuxKeepaliveInterval) * time.Second
|
||||
|
Loading…
Reference in New Issue
Block a user