improve config

This commit is contained in:
ginuerzh
2022-01-26 18:29:48 +08:00
parent 713586729b
commit 44acdc9215
14 changed files with 160 additions and 119 deletions

View File

@ -43,7 +43,7 @@ func (h *forwardHandler) Init(md md.Metadata) (err error) {
if h.group == nil {
// dummy node used by relay connector.
h.group = chain.NewNodeGroup(chain.NewNode("dummy", ":0"))
h.group = chain.NewNodeGroup(&chain.Node{Name: "dummy", Addr: ":0"})
}
h.router = &chain.Router{
@ -90,26 +90,26 @@ func (h *forwardHandler) Handle(ctx context.Context, conn net.Conn) {
}
log = log.WithFields(map[string]interface{}{
"dst": fmt.Sprintf("%s/%s", target.Addr(), network),
"dst": fmt.Sprintf("%s/%s", target.Addr, network),
})
log.Infof("%s >> %s", conn.RemoteAddr(), target.Addr())
log.Infof("%s >> %s", conn.RemoteAddr(), target.Addr)
cc, err := h.router.Dial(ctx, network, target.Addr())
cc, err := h.router.Dial(ctx, network, target.Addr)
if err != nil {
log.Error(err)
// TODO: the router itself may be failed due to the failed node in the router,
// the dead marker may be a wrong operation.
target.Marker().Mark()
target.Marker.Mark()
return
}
defer cc.Close()
target.Marker().Reset()
target.Marker.Reset()
t := time.Now()
log.Infof("%s <-> %s", conn.RemoteAddr(), target.Addr())
log.Infof("%s <-> %s", conn.RemoteAddr(), target.Addr)
handler.Transport(conn, cc)
log.WithFields(map[string]interface{}{
"duration": time.Since(t),
}).Infof("%s >-< %s", conn.RemoteAddr(), target.Addr())
}).Infof("%s >-< %s", conn.RemoteAddr(), target.Addr)
}