add bind for relay

This commit is contained in:
ginuerzh
2021-11-25 17:29:54 +08:00
parent 98ef6c7492
commit 6daf0a4d0f
29 changed files with 600 additions and 352 deletions

View File

@ -84,18 +84,18 @@ func (h *ssuHandler) Handle(ctx context.Context, conn net.Conn) {
WithChain(h.chain).
WithRetry(h.md.retryCount).
WithLogger(h.logger)
c, err := r.Dial(ctx, "udp", "")
c, err := r.Dial(ctx, "udp", "") // UDP association
if err != nil {
h.logger.Error(err)
return
}
defer c.Close()
cc, ok := c.(net.PacketConn)
if !ok {
h.logger.Errorf("%s: not a packet connection")
h.logger.Errorf("wrong connection type")
return
}
defer cc.Close()
t := time.Now()
h.logger.Infof("%s <-> %s", conn.RemoteAddr(), cc.LocalAddr())