Skip to content

Commit

Permalink
14-to-15: add filtering to All local addresses fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorropo committed Aug 31, 2023
1 parent 15439f1 commit 00a9f01
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 3 deletions.
11 changes: 8 additions & 3 deletions fs-repo-14-to-15/migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,15 @@ func convert(in io.Reader, out io.Writer) error {
return fmt.Errorf("invalid type for .Addresses got %T expected json map", a)
}

if s, ok := addresses["Swarm"]; ok {
for _, addressToRemove := range [...]string{"Swarm", "Announce", "AppendAnnounce", "NoAnnounce"} {
s, ok := addresses[addressToRemove]
if !ok {
continue
}

swarm, ok := s.([]interface{})
if !ok {
return fmt.Errorf("invalid type for .Addresses.Swarm got %T expected json array", s)
return fmt.Errorf("invalid type for .Addresses.%s got %T expected json array", addressToRemove, s)
}

var newSwarm []interface{}
Expand All @@ -194,7 +199,7 @@ func convert(in io.Reader, out io.Writer) error {
newSwarm = append(newSwarm, v)
}
}
addresses["Swarm"] = newSwarm
addresses[addressToRemove] = newSwarm
}
}

Expand Down
24 changes: 24 additions & 0 deletions fs-repo-14-to-15/not-sharness/repotest-golden/config
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
{
"Addresses": {
"Announce": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
"/ip4/0.0.0.0/udp/4001/quic-v1",
"/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
"/ip6/::/udp/4001/quic-v1",
"/ip6/::/udp/4001/quic-v1/webtransport"
],
"AppendAnnounce": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
"/ip4/0.0.0.0/udp/4001/quic-v1",
"/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
"/ip6/::/udp/4001/quic-v1",
"/ip6/::/udp/4001/quic-v1/webtransport"
],
"NoAnnounce": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
"/ip4/0.0.0.0/udp/4001/quic-v1",
"/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
"/ip6/::/udp/4001/quic-v1",
"/ip6/::/udp/4001/quic-v1/webtransport"
],
"Swarm": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
Expand Down
30 changes: 30 additions & 0 deletions fs-repo-14-to-15/not-sharness/repotest-golden/config.14-to-15.bak
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
{
"Addresses": {
"Announce": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
"/ip4/0.0.0.0/udp/4001/quic",
"/ip4/0.0.0.0/udp/4001/quic-v1",
"/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
"/ip6/::/udp/4001/quic",
"/ip6/::/udp/4001/quic-v1",
"/ip6/::/udp/4001/quic-v1/webtransport"
],
"AppendAnnounce": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
"/ip4/0.0.0.0/udp/4001/quic",
"/ip4/0.0.0.0/udp/4001/quic-v1",
"/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
"/ip6/::/udp/4001/quic",
"/ip6/::/udp/4001/quic-v1",
"/ip6/::/udp/4001/quic-v1/webtransport"
],
"NoAnnounce": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
"/ip4/0.0.0.0/udp/4001/quic",
"/ip4/0.0.0.0/udp/4001/quic-v1",
"/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
"/ip6/::/udp/4001/quic",
"/ip6/::/udp/4001/quic-v1",
"/ip6/::/udp/4001/quic-v1/webtransport"
],
"Swarm": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
Expand Down
30 changes: 30 additions & 0 deletions fs-repo-14-to-15/not-sharness/repotest-init/config
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
{
"Addresses": {
"Announce": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
"/ip4/0.0.0.0/udp/4001/quic",
"/ip4/0.0.0.0/udp/4001/quic-v1",
"/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
"/ip6/::/udp/4001/quic",
"/ip6/::/udp/4001/quic-v1",
"/ip6/::/udp/4001/quic-v1/webtransport"
],
"AppendAnnounce": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
"/ip4/0.0.0.0/udp/4001/quic",
"/ip4/0.0.0.0/udp/4001/quic-v1",
"/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
"/ip6/::/udp/4001/quic",
"/ip6/::/udp/4001/quic-v1",
"/ip6/::/udp/4001/quic-v1/webtransport"
],
"NoAnnounce": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
"/ip4/0.0.0.0/udp/4001/quic",
"/ip4/0.0.0.0/udp/4001/quic-v1",
"/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
"/ip6/::/udp/4001/quic",
"/ip6/::/udp/4001/quic-v1",
"/ip6/::/udp/4001/quic-v1/webtransport"
],
"Swarm": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
Expand Down

0 comments on commit 00a9f01

Please sign in to comment.