Skip to content

Commit

Permalink
fix(fs-repo-15-to-16): support existing listener
Browse files Browse the repository at this point in the history
some users might've enabled listener while testing 0.29.0
and if it was on the same port, they could just forget to remove it,
because it was ignored.

in such case, the old code would add  /webrtc-direct and 'continue' loop
which woudl mean /quic-v1 is not added back, effectively breaking QUIC.

this adds fix + regression test for that scenario
  • Loading branch information
lidel committed Aug 2, 2024
1 parent 64d9993 commit 0b14a92
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
19 changes: 6 additions & 13 deletions fs-repo-15-to-16/migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,26 +186,19 @@ func convert(in io.Reader, out io.Writer) error {
uniq := map[string]struct{}{}
for _, v := range swarm {
if addr, ok := v.(string); ok {

// if /quic-v1, add /webrtc-direct under the same port
if quicRegex.MatchString(addr) {
newAddr := quicRegex.ReplaceAllString(addr, "/webrtc-direct")

if _, ok := uniq[newAddr]; ok {
continue
if _, ok := uniq[newAddr]; !ok {
uniq[newAddr] = struct{}{}
newSwarm = append(newSwarm, newAddr)
}
uniq[newAddr] = struct{}{}

newSwarm = append(newSwarm, newAddr)
}

// keep original addr
if _, ok := uniq[addr]; ok {
continue
if _, ok := uniq[addr]; !ok {
uniq[addr] = struct{}{}
newSwarm = append(newSwarm, addr)
}
uniq[addr] = struct{}{}

newSwarm = append(newSwarm, addr)
continue
}
newSwarm = append(newSwarm, v)
Expand Down
1 change: 1 addition & 0 deletions fs-repo-15-to-16/test-e2e/repo-v15/config
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"NoAnnounce": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
"/ip4/0.0.0.0/udp/4001/webrtc-direct",
"/ip4/0.0.0.0/udp/4001/quic-v1",
"/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
"/ip6/::/udp/4001/quic-v1",
Expand Down
1 change: 1 addition & 0 deletions fs-repo-15-to-16/test-e2e/repo-v16/config.15-to-16.bak
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"NoAnnounce": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
"/ip4/0.0.0.0/udp/4001/webrtc-direct",
"/ip4/0.0.0.0/udp/4001/quic-v1",
"/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
"/ip6/::/udp/4001/quic-v1",
Expand Down

0 comments on commit 0b14a92

Please sign in to comment.