diff --git a/.github/workflows/image.yaml b/.github/workflows/image.yaml new file mode 100644 index 0000000..10010c4 --- /dev/null +++ b/.github/workflows/image.yaml @@ -0,0 +1,43 @@ +name: shisui latest image + +on: + push: + branches: [main] + +defaults: + run: + shell: bash + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: write + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + push_image_to_github: + name: Push Docker image to Github + runs-on: ubuntu-latest + permissions: write-all + steps: + - name: Check out the repo + uses: actions/checkout@v4 + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile.portal + push: true + tags: ${{ env.REGISTRY }}/${{ github.repository }}:latest diff --git a/Dockerfile b/Dockerfile index e65815f..706f49b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,13 @@ -FROM --platform=linux/amd64 golang:1.23 as builder +FROM golang:1.23 as builder WORKDIR /app COPY . . -RUN go env -w GOPROXY=https://goproxy.cn,direct -# RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build ./cmd/shisui/main.go + RUN make shisui -FROM --platform=linux/amd64 ubuntu:22.04 +FROM ubuntu:22.04 COPY --from=builder /app/build/bin/shisui /usr/local/bin/app diff --git a/portalwire/portal_protocol.go b/portalwire/portal_protocol.go index 25ee448..76e63d0 100644 --- a/portalwire/portal_protocol.go +++ b/portalwire/portal_protocol.go @@ -280,7 +280,7 @@ func (p *PortalProtocol) RoutingTableInfo() [][]string { } func (p *PortalProtocol) AddEnr(n *enode.Node) { - added := p.table.AddInboundNode(n) + added := p.table.AddFoundNode(n, true) if !added { p.Log.Warn("add node failed", "id", n.ID(), "ip", n.IPAddr()) return @@ -970,6 +970,8 @@ func (p *PortalProtocol) handleFindNodes(fromAddr *net.UDPAddr, request *FindNod enrs := p.truncateNodes(nodes, maxPayloadSize, enrOverhead) nodesMsg := &Nodes{ + // https://github.com/ethereum/portal-network-specs/blob/master/portal-wire-protocol.md + // total: The total number of Nodes response messages being sent. Currently fixed to only 1 response message. Total: 1, Enrs: enrs, }