add bind for relay
This commit is contained in:
@ -2,6 +2,7 @@ package forward
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
@ -42,7 +43,7 @@ func (h *forwardHandler) Init(md md.Metadata) (err error) {
|
||||
return h.parseMetadata(md)
|
||||
}
|
||||
|
||||
// implements chain.Chainable interface
|
||||
// WithChain implements chain.Chainable interface
|
||||
func (h *forwardHandler) WithChain(chain *chain.Chain) {
|
||||
h.chain = chain
|
||||
}
|
||||
@ -74,8 +75,13 @@ func (h *forwardHandler) Handle(ctx context.Context, conn net.Conn) {
|
||||
return
|
||||
}
|
||||
|
||||
network := "tcp"
|
||||
if _, ok := conn.(net.PacketConn); ok {
|
||||
network = "udp"
|
||||
}
|
||||
|
||||
h.logger = h.logger.WithFields(map[string]interface{}{
|
||||
"dst": target.Addr(),
|
||||
"dst": fmt.Sprintf("%s/%s", target.Addr(), network),
|
||||
})
|
||||
|
||||
h.logger.Infof("%s >> %s", conn.RemoteAddr(), target.Addr())
|
||||
@ -85,11 +91,6 @@ func (h *forwardHandler) Handle(ctx context.Context, conn net.Conn) {
|
||||
WithRetry(h.md.retryCount).
|
||||
WithLogger(h.logger)
|
||||
|
||||
network := "tcp"
|
||||
if _, ok := conn.(net.PacketConn); ok {
|
||||
network = "udp"
|
||||
}
|
||||
|
||||
cc, err := r.Dial(ctx, network, target.Addr())
|
||||
if err != nil {
|
||||
h.logger.Error(err)
|
||||
|
@ -2,6 +2,7 @@ package forward
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
@ -68,8 +69,13 @@ func (h *forwardHandler) Handle(ctx context.Context, conn net.Conn) {
|
||||
return
|
||||
}
|
||||
|
||||
network := "tcp"
|
||||
if _, ok := conn.(net.PacketConn); ok {
|
||||
network = "udp"
|
||||
}
|
||||
|
||||
h.logger = h.logger.WithFields(map[string]interface{}{
|
||||
"dst": target.Addr(),
|
||||
"dst": fmt.Sprintf("%s/%s", target.Addr(), network),
|
||||
})
|
||||
|
||||
h.logger.Infof("%s >> %s", conn.RemoteAddr(), target.Addr())
|
||||
@ -79,11 +85,6 @@ func (h *forwardHandler) Handle(ctx context.Context, conn net.Conn) {
|
||||
WithRetry(h.md.retryCount).
|
||||
WithLogger(h.logger)
|
||||
|
||||
network := "tcp"
|
||||
if _, ok := conn.(net.PacketConn); ok {
|
||||
network = "udp"
|
||||
}
|
||||
|
||||
cc, err := r.Dial(ctx, network, target.Addr())
|
||||
if err != nil {
|
||||
h.logger.Error(err)
|
||||
|
Reference in New Issue
Block a user