Skip to content

Commit

Permalink
Merge branch 'master' into merge-release-v0.21.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Jul 3, 2023
2 parents 294db3e + f797e9e commit bd17759
Show file tree
Hide file tree
Showing 34 changed files with 518 additions and 1,098 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
LEGACY_IMAGE_NAME: ipfs/go-ipfs
steps:
- name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand All @@ -48,7 +48,7 @@ jobs:
shell: bash

- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/gateway-conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
steps:
# 1. Download the gateway-conformance fixtures
- name: Download gateway-conformance fixtures
uses: ipfs/gateway-conformance/.github/actions/extract-fixtures@v0.1
uses: ipfs/gateway-conformance/.github/actions/extract-fixtures@v0.2
with:
output: fixtures

Expand All @@ -47,6 +47,7 @@ jobs:
{
"example.com": {
"UseSubdomains": true,
"InlineDNSLink": true,
"Paths": ["/ipfs", "/ipns"]
},
"localhost": {
Expand Down Expand Up @@ -76,7 +77,8 @@ jobs:
# Import dnslink records
# the IPFS_NS_MAP env will be used by the daemon
export IPFS_NS_MAP=$(cat ./fixtures/dnslinks.json | jq -r 'to_entries | map("\(.key).example.com:\(.value)") | join(",")')
export IPFS_NS_MAP=$(cat "./fixtures/dnslinks.json" | jq -r '.subdomains | to_entries | map("\(.key).example.com:\(.value)") | join(",")')
export IPFS_NS_MAP="$(cat "./fixtures/dnslinks.json" | jq -r '.domains | to_entries | map("\(.key):\(.value)") | join(",")'),${IPFS_NS_MAP}"
echo "IPFS_NS_MAP=${IPFS_NS_MAP}" >> $GITHUB_ENV
# 5. Start the kubo-gateway
Expand All @@ -87,7 +89,7 @@ jobs:

# 6. Run the gateway-conformance tests
- name: Run gateway-conformance tests
uses: ipfs/gateway-conformance/.github/actions/test@v0.1
uses: ipfs/gateway-conformance/.github/actions/test@v0.2
with:
gateway-url: http://127.0.0.1:8080
json: output.json
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golang-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions/setup-go@v2
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ name: Close and mark stale issue

on:
schedule:
- cron: '0 0 * * *'
- cron: '0 0 * * *'

permissions:
issues: write
pull-requests: write

jobs:
stale:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/sync-release-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ jobs:
with:
node-version: 14
- name: Sync the latest 5 github releases
uses: actions/github-script@v4
uses: actions/github-script@v6
with:
script: |
const fs = require('fs').promises
const max_synced = 5
// fetch github releases
resp = await github.repos.listReleases({
resp = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
page: 1,
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
}
console.log("uploading", file, "to github release", release.tag_name)
const uploadReleaseAsset = async (file) => github.repos.uploadReleaseAsset({
const uploadReleaseAsset = async (file) => github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.id,
Expand Down
24 changes: 7 additions & 17 deletions client/rpc/name.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,20 @@ import (
caopts "github.com/ipfs/boxo/coreiface/options"
nsopts "github.com/ipfs/boxo/coreiface/options/namesys"
"github.com/ipfs/boxo/coreiface/path"
"github.com/ipfs/boxo/ipns"
)

type NameAPI HttpApi

type ipnsEntry struct {
JName string `json:"Name"`
JValue string `json:"Value"`

path path.Path
}

func (e *ipnsEntry) Name() string {
return e.JName
Name string `json:"Name"`
Value string `json:"Value"`
}

func (e *ipnsEntry) Value() path.Path {
return e.path
}

func (api *NameAPI) Publish(ctx context.Context, p path.Path, opts ...caopts.NamePublishOption) (iface.IpnsEntry, error) {
func (api *NameAPI) Publish(ctx context.Context, p path.Path, opts ...caopts.NamePublishOption) (ipns.Name, error) {
options, err := caopts.NamePublishOptions(opts...)
if err != nil {
return nil, err
return ipns.Name{}, err
}

req := api.core().Request("name/publish", p.String()).
Expand All @@ -47,10 +38,9 @@ func (api *NameAPI) Publish(ctx context.Context, p path.Path, opts ...caopts.Nam

var out ipnsEntry
if err := req.Exec(ctx, &out); err != nil {
return nil, err
return ipns.Name{}, err
}
out.path = path.New(out.JValue)
return &out, out.path.IsValid()
return ipns.NameFromString(out.Name)
}

func (api *NameAPI) Search(ctx context.Context, name string, opts ...caopts.NameResolveOption) (<-chan iface.IpnsResult, error) {
Expand Down
11 changes: 1 addition & 10 deletions config/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type Router struct {
Type RouterType

// Parameters are extra configuration that this router might need.
// A common one for reframe router is "Endpoint".
// A common one for HTTP router is "Endpoint".
Parameters interface{}
}

Expand Down Expand Up @@ -81,8 +81,6 @@ func (r *RouterParser) UnmarshalJSON(b []byte) error {
switch out.Type {
case RouterTypeHTTP:
p = &HTTPRouterParams{}
case RouterTypeReframe:
p = &ReframeRouterParams{}
case RouterTypeDHT:
p = &DHTRouterParams{}
case RouterTypeSequential:
Expand All @@ -106,7 +104,6 @@ func (r *RouterParser) UnmarshalJSON(b []byte) error {
type RouterType string

const (
RouterTypeReframe RouterType = "reframe" // More info here: https://github.com/ipfs/specs/tree/main/reframe . Actually deprecated.
RouterTypeHTTP RouterType = "http" // HTTP JSON API for delegated routing systems (IPIP-337).
RouterTypeDHT RouterType = "dht" // DHT router.
RouterTypeSequential RouterType = "sequential" // Router helper to execute several routers sequentially.
Expand All @@ -133,12 +130,6 @@ const (

var MethodNameList = []MethodName{MethodNameProvide, MethodNameFindPeers, MethodNameFindProviders, MethodNameGetIPNS, MethodNamePutIPNS}

type ReframeRouterParams struct {
// Endpoint is the URL where the routing implementation will point to get the information.
// Usually used for reframe Routers.
Endpoint string
}

type HTTPRouterParams struct {
// Endpoint is the URL where the routing implementation will point to get the information.
Endpoint string
Expand Down
77 changes: 12 additions & 65 deletions config/routing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ func TestRouterParameters(t *testing.T) {
PublicIPNetwork: false,
},
}},
"router-reframe": {Router{
Type: RouterTypeReframe,
Parameters: ReframeRouterParams{
Endpoint: "reframe-endpoint",
},
}},
"router-parallel": {Router{
Type: RouterTypeParallel,
Parameters: ComposableRouterParams{
Expand All @@ -39,7 +33,7 @@ func TestRouterParameters(t *testing.T) {
IgnoreErrors: true,
},
{
RouterName: "router-reframe",
RouterName: "router-dht",
Timeout: Duration{10 * time.Second},
IgnoreErrors: false,
ExecuteAfter: &OptionalDuration{&sec},
Expand All @@ -58,7 +52,7 @@ func TestRouterParameters(t *testing.T) {
IgnoreErrors: true,
},
{
RouterName: "router-reframe",
RouterName: "router-dht",
Timeout: Duration{10 * time.Second},
IgnoreErrors: false,
},
Expand All @@ -69,7 +63,7 @@ func TestRouterParameters(t *testing.T) {
},
Methods: Methods{
MethodNameFindPeers: {
RouterName: "router-reframe",
RouterName: "router-dht",
},
MethodNameFindProviders: {
RouterName: "router-dht",
Expand Down Expand Up @@ -99,95 +93,48 @@ func TestRouterParameters(t *testing.T) {
dhtp := r2.Routers["router-dht"].Parameters
require.IsType(&DHTRouterParams{}, dhtp)

rp := r2.Routers["router-reframe"].Parameters
require.IsType(&ReframeRouterParams{}, rp)

sp := r2.Routers["router-sequential"].Parameters
require.IsType(&ComposableRouterParams{}, sp)

pp := r2.Routers["router-parallel"].Parameters
require.IsType(&ComposableRouterParams{}, pp)
}

func TestRouterMissingParameters(t *testing.T) {
require := require.New(t)

r := Routing{
Type: NewOptionalString("custom"),
Routers: map[string]RouterParser{
"router-wrong-reframe": {Router{
Type: RouterTypeReframe,
Parameters: DHTRouterParams{
Mode: "auto",
AcceleratedDHTClient: true,
PublicIPNetwork: false,
},
}},
},
Methods: Methods{
MethodNameFindPeers: {
RouterName: "router-wrong-reframe",
},
MethodNameFindProviders: {
RouterName: "router-wrong-reframe",
},
MethodNameGetIPNS: {
RouterName: "router-wrong-reframe",
},
MethodNameProvide: {
RouterName: "router-wrong-reframe",
},
MethodNamePutIPNS: {
RouterName: "router-wrong-reframe",
},
},
}

out, err := json.Marshal(r)
require.NoError(err)

r2 := &Routing{}

err = json.Unmarshal(out, r2)
require.NoError(err)
require.Empty(r2.Routers["router-wrong-reframe"].Parameters.(*ReframeRouterParams).Endpoint)
}

func TestMethods(t *testing.T) {
require := require.New(t)

methodsOK := Methods{
MethodNameFindPeers: {
RouterName: "router-wrong-reframe",
RouterName: "router-wrong",
},
MethodNameFindProviders: {
RouterName: "router-wrong-reframe",
RouterName: "router-wrong",
},
MethodNameGetIPNS: {
RouterName: "router-wrong-reframe",
RouterName: "router-wrong",
},
MethodNameProvide: {
RouterName: "router-wrong-reframe",
RouterName: "router-wrong",
},
MethodNamePutIPNS: {
RouterName: "router-wrong-reframe",
RouterName: "router-wrong",
},
}

require.NoError(methodsOK.Check())

methodsMissing := Methods{
MethodNameFindPeers: {
RouterName: "router-wrong-reframe",
RouterName: "router-wrong",
},
MethodNameGetIPNS: {
RouterName: "router-wrong-reframe",
RouterName: "router-wrong",
},
MethodNameProvide: {
RouterName: "router-wrong-reframe",
RouterName: "router-wrong",
},
MethodNamePutIPNS: {
RouterName: "router-wrong-reframe",
RouterName: "router-wrong",
},
}

Expand Down
2 changes: 1 addition & 1 deletion core/commands/dag/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
ipld "github.com/ipfs/go-ipld-format"
"github.com/ipfs/kubo/core/commands/cmdenv"

gocar "github.com/ipfs/boxo/ipld/car"
cmds "github.com/ipfs/go-ipfs-cmds"
gocar "github.com/ipld/go-car"
selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse"
)

Expand Down
1 change: 1 addition & 0 deletions core/commands/dag/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
cmds "github.com/ipfs/go-ipfs-cmds"
ipld "github.com/ipfs/go-ipld-format"
ipldlegacy "github.com/ipfs/go-ipld-legacy"
gocarv2 "github.com/ipld/go-car/v2"

"github.com/ipfs/kubo/core/commands/cmdenv"
"github.com/ipfs/kubo/core/commands/cmdutils"
Expand Down
4 changes: 2 additions & 2 deletions core/commands/dht_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func TestKeyTranslation(t *testing.T) {
pid := test.RandPeerIDFatal(t)
pkname := namesys.PkKeyForID(pid)
ipnsname := ipns.RecordKey(pid)
ipnsname := ipns.NameFromPeer(pid).RoutingKey()

pkk, err := escapeDhtKey("/pk/" + pid.Pretty())
if err != nil {
Expand All @@ -28,7 +28,7 @@ func TestKeyTranslation(t *testing.T) {
t.Fatal("keys didn't match!")
}

if ipnsk != ipnsname {
if ipnsk != string(ipnsname) {
t.Fatal("keys didn't match!")
}
}
Loading

0 comments on commit bd17759

Please sign in to comment.