Skip to content

Commit c0c728f

Browse files
authored
Merge branch 'main' into update-deps
2 parents 4f8198b + 18c461a commit c0c728f

6 files changed

Lines changed: 60 additions & 28 deletions

File tree

.github/workflows/docker.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ jobs:
2828
- name: Set up Docker Buildx
2929
uses: docker/setup-buildx-action@v3
3030

31-
- name: Cache Docker layers
32-
uses: actions/cache@v4
33-
with:
34-
path: /tmp/.buildx-cache
35-
key: ${{ runner.os }}-buildx-${{ github.sha }}
36-
restore-keys: |
37-
${{ runner.os }}-buildx-
3831
- name: Log in to the Container registry
3932
uses: docker/login-action@v3
4033
with:
@@ -58,12 +51,10 @@ jobs:
5851
push: true
5952
file: ./Dockerfile
6053
tags: "${{ steps.tags.outputs.value }}"
61-
cache-from: type=local,src=/tmp/.buildx-cache
62-
cache-to: type=local,dest=/tmp/.buildx-cache-new
54+
cache-from: |
55+
type=gha
56+
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
57+
cache-to: |
58+
type=gha,mode=max
59+
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
6360
64-
# https://github.com/docker/build-push-action/issues/252
65-
# https://github.com/moby/buildkit/issues/1896
66-
- name: Move cache to limit growth
67-
run: |
68-
rm -rf /tmp/.buildx-cache
69-
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ The following emojis are used to highlight certain changes:
2828

2929
### Security
3030

31+
## [v0.10.0]
32+
33+
### Added
34+
35+
- Automatic generation of peer IDs for HTTP block providers when not explicitly configured ([#117](https://github.com/ipfs/someguy/pull/117))
36+
- When `SOMEGUY_HTTP_BLOCK_PROVIDER_ENDPOINTS` are configured but no `SOMEGUY_HTTP_BLOCK_PROVIDER_PEERIDS` are configured, synthetic PeerIDs will now be autogenerated. These are deterministic placeholders derived from endpoint URLs, used only for routing system compatibility with HTTP-based trustless gateways - no libp2p cryptographic operations are performed with these IDs
37+
38+
### Changed
39+
40+
- Modernized Docker build configuration ([#118](https://github.com/ipfs/someguy/pull/118))
41+
- Updated to Go 1.24/1.25 ([#115](https://github.com/ipfs/someguy/pull/115), [#118](https://github.com/ipfs/someguy/pull/118))
42+
3143
## [v0.9.1]
3244

3345
### Added

Dockerfile

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
# syntax=docker/dockerfile:1
12
# Builder
2-
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.23-bookworm AS builder
3+
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.25-bookworm AS builder
34

45
LABEL org.opencontainers.image.source=https://github.com/ipfs/someguy
56
LABEL org.opencontainers.image.documentation=https://github.com/ipfs/someguy#docker
@@ -8,17 +9,20 @@ LABEL org.opencontainers.image.licenses=MIT+APACHE_2.0
89

910
ARG TARGETPLATFORM TARGETOS TARGETARCH
1011

11-
ENV GOPATH /go
12-
ENV SRC_PATH $GOPATH/src/github.com/ipfs/someguy
13-
ENV GO111MODULE on
14-
ENV GOPROXY https://proxy.golang.org
12+
ENV GOPATH=/go
13+
ENV SRC_PATH=$GOPATH/src/github.com/ipfs/someguy
14+
ENV GO111MODULE=on
15+
ENV GOPROXY=https://proxy.golang.org
1516

16-
COPY go.* $SRC_PATH/
17+
COPY go.mod go.sum $SRC_PATH/
1718
WORKDIR $SRC_PATH
18-
RUN go mod download
19+
RUN --mount=type=cache,target=/go/pkg/mod \
20+
go mod download
1921

2022
COPY . $SRC_PATH
21-
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o $GOPATH/bin/someguy
23+
RUN --mount=type=cache,target=/go/pkg/mod \
24+
--mount=type=cache,target=/root/.cache/go-build \
25+
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o $GOPATH/bin/someguy
2226

2327
# Runner
2428
FROM debian:bookworm-slim
@@ -27,9 +31,9 @@ RUN apt-get update && \
2731
apt-get install --no-install-recommends -y tini ca-certificates curl && \
2832
rm -rf /var/lib/apt/lists/*
2933

30-
ENV GOPATH /go
31-
ENV SRC_PATH $GOPATH/src/github.com/ipfs/someguy
32-
ENV DATA_PATH /data/someguy
34+
ENV GOPATH=/go
35+
ENV SRC_PATH=$GOPATH/src/github.com/ipfs/someguy
36+
ENV DATA_PATH=/data/someguy
3337

3438
COPY --from=builder $GOPATH/bin/someguy /usr/local/bin/someguy
3539

docs/environment-variables.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ Default: none
9191

9292
### `SOMEGUY_HTTP_BLOCK_PROVIDER_PEERIDS`
9393

94-
Comma-separated list of [multibase-encoded peerIDs](https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md#string-representation) to use in synthetic provider records returned for HTTP providers in `SOMEGUY_HTTP_BLOCK_PROVIDER_ENDPOINTS`.
94+
Comma-separated list of [multibase-encoded peerIDs](https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md#string-representation) to use in synthetic provider records returned for HTTP providers in `SOMEGUY_HTTP_BLOCK_PROVIDER_ENDPOINTS`. The order of PeerIDs must match the order of endpoints.
95+
96+
If no peerIDs are passed but provider endpoints are configured, synthetic PeerIDs will be automatically generated. These are deterministic identifiers derived from SHA256 hashes of the endpoint URLs, used solely for routing system compatibility. Since these providers use HTTP trustless gateway protocol rather than libp2p, the PeerIDs are purely synthetic and never participate in any cryptographic operations or peer authentication.
9597

9698
Default: none
9799

main.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"crypto/sha256"
45
"errors"
56
"fmt"
67
"log"
@@ -12,6 +13,7 @@ import (
1213
"github.com/ipfs/go-cid"
1314
"github.com/libp2p/go-libp2p/core/peer"
1415
"github.com/multiformats/go-multibase"
16+
"github.com/multiformats/go-multihash"
1517
"github.com/urfave/cli/v2"
1618
)
1719

@@ -175,6 +177,27 @@ func main() {
175177
printIfListConfigured("SOMEGUY_PROVIDER_ENDPOINTS = ", cfg.contentEndpoints)
176178
printIfListConfigured("SOMEGUY_PEER_ENDPOINTS = ", cfg.peerEndpoints)
177179
printIfListConfigured("SOMEGUY_IPNS_ENDPOINTS = ", cfg.ipnsEndpoints)
180+
181+
if len(cfg.blockProviderEndpoints) > 0 && len(cfg.blockProviderPeerIDs) == 0 {
182+
fmt.Printf("SOMEGUY_HTTP_BLOCK_PROVIDER_ENDPOINTS is set but SOMEGUY_HTTP_BLOCK_PROVIDER_PEERIDS were not. PeerIDs will be autogenerated.\n")
183+
// Generate synthetic PeerIDs for HTTP block providers. These are deterministic
184+
// identifiers based on endpoint URLs, used solely for routing system compatibility.
185+
// Since HTTP providers use trustless gateway protocol, these PeerIDs are never
186+
// used for cryptographic operations or libp2p authentication.
187+
for i := 0; i < len(cfg.blockProviderEndpoints); i++ {
188+
digest := sha256.Sum256([]byte(cfg.blockProviderEndpoints[i]))
189+
mh, err := multihash.Encode((digest[:]), multihash.SHA2_256)
190+
if err != nil {
191+
return err
192+
}
193+
p, err := peer.IDFromBytes(mh)
194+
if err != nil {
195+
return err
196+
}
197+
cfg.blockProviderPeerIDs = append(cfg.blockProviderPeerIDs, p.String())
198+
}
199+
}
200+
178201
printIfListConfigured("SOMEGUY_HTTP_BLOCK_PROVIDER_ENDPOINTS = ", cfg.blockProviderEndpoints)
179202
printIfListConfigured("SOMEGUY_HTTP_BLOCK_PROVIDER_PEERIDS = ", cfg.blockProviderPeerIDs)
180203

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "v0.9.1"
2+
"version": "v0.10.0"
33
}

0 commit comments

Comments
 (0)