add weight for tunnel connector

This commit is contained in:
ginuerzh
2024-01-27 23:31:23 +08:00
parent 43d37d0a5f
commit b5b39de62c
7 changed files with 45 additions and 14 deletions

View File

@ -30,6 +30,8 @@ func (h *tunnelHandler) handleBind(ctx context.Context, conn net.Conn, network,
if network == "udp" {
connectorID = relay.NewUDPConnectorID(uuid[:])
}
// copy weight from tunnelID
connectorID = connectorID.SetWeight(tunnelID.Weight())
v := md5.Sum([]byte(tunnelID.String()))
endpoint := hex.EncodeToString(v[:8])