Skip to content

Commit

Permalink
make names guaranteed unique
Browse files Browse the repository at this point in the history
  • Loading branch information
Termina1 committed Sep 10, 2024
1 parent bdce170 commit c51d061
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hf
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
Expand Down
6 changes: 4 additions & 2 deletions protocol/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"crypto/tls"
"errors"
"fmt"
"net"
"net/url"
"strings"
Expand All @@ -12,6 +13,7 @@ import (
"time"

"github.com/drpcorg/chotki/utils"
"github.com/google/uuid"
"github.com/puzpuzpuz/xsync/v3"
)

Expand Down Expand Up @@ -101,7 +103,7 @@ func (n *Net) ConnectPool(ctx context.Context, name string, addrs []string) (err

n.wg.Add(1)
go func() {
n.KeepConnecting(ctx, name, addrs)
n.KeepConnecting(ctx, fmt.Sprintf("connect:%s", name), addrs)
n.wg.Done()
}()

Expand Down Expand Up @@ -218,7 +220,7 @@ func (n *Net) KeepListening(ctx context.Context, addr string) {

n.wg.Add(1)
go func() {
n.keepPeer(ctx, remoteAddr, conn)
n.keepPeer(ctx, fmt.Sprintf("listen:%s:%s", uuid.Must(uuid.NewV7()).String(), remoteAddr), conn)
defer n.wg.Done()
}()
}
Expand Down

0 comments on commit c51d061

Please sign in to comment.