Skip to content

Commit 0b14a92

Browse files
committed
fix(fs-repo-15-to-16): support existing listener
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
1 parent 64d9993 commit 0b14a92

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

fs-repo-15-to-16/migration/migration.go

+6-13
Original file line numberDiff line numberDiff line change
@@ -186,26 +186,19 @@ func convert(in io.Reader, out io.Writer) error {
186186
uniq := map[string]struct{}{}
187187
for _, v := range swarm {
188188
if addr, ok := v.(string); ok {
189-
190189
// if /quic-v1, add /webrtc-direct under the same port
191190
if quicRegex.MatchString(addr) {
192191
newAddr := quicRegex.ReplaceAllString(addr, "/webrtc-direct")
193-
194-
if _, ok := uniq[newAddr]; ok {
195-
continue
192+
if _, ok := uniq[newAddr]; !ok {
193+
uniq[newAddr] = struct{}{}
194+
newSwarm = append(newSwarm, newAddr)
196195
}
197-
uniq[newAddr] = struct{}{}
198-
199-
newSwarm = append(newSwarm, newAddr)
200196
}
201-
202197
// keep original addr
203-
if _, ok := uniq[addr]; ok {
204-
continue
198+
if _, ok := uniq[addr]; !ok {
199+
uniq[addr] = struct{}{}
200+
newSwarm = append(newSwarm, addr)
205201
}
206-
uniq[addr] = struct{}{}
207-
208-
newSwarm = append(newSwarm, addr)
209202
continue
210203
}
211204
newSwarm = append(newSwarm, v)

fs-repo-15-to-16/test-e2e/repo-v15/config

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"NoAnnounce": [
1313
"/ip4/0.0.0.0/tcp/4001",
1414
"/ip6/::/tcp/4001",
15+
"/ip4/0.0.0.0/udp/4001/webrtc-direct",
1516
"/ip4/0.0.0.0/udp/4001/quic-v1",
1617
"/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
1718
"/ip6/::/udp/4001/quic-v1",

fs-repo-15-to-16/test-e2e/repo-v16/config.15-to-16.bak

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"NoAnnounce": [
1313
"/ip4/0.0.0.0/tcp/4001",
1414
"/ip6/::/tcp/4001",
15+
"/ip4/0.0.0.0/udp/4001/webrtc-direct",
1516
"/ip4/0.0.0.0/udp/4001/quic-v1",
1617
"/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
1718
"/ip6/::/udp/4001/quic-v1",

0 commit comments

Comments
 (0)