Skip to content

Commit 7a27171

Browse files
authored
Merge pull request #3 from redpwn/go1.17
chore: upgrade to go1.17
2 parents bf2007f + 9dec43b commit 7a27171

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ jobs:
1010
steps:
1111
- uses: actions/setup-go@v2
1212
with:
13-
go-version: 1.16.5
14-
- run: |
13+
go-version: 1.17.0
14+
- uses: actions/checkout@v2
15+
- name: go build
16+
run: |
1517
sudo apt-get install -y gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf
1618
sudo dpkg --add-architecture arm64
1719
sudo dpkg --add-architecture armhf
@@ -21,9 +23,6 @@ jobs:
2123
' | sudo tee /etc/apt/sources.list.d/arm.list
2224
sudo apt-get update || true
2325
sudo apt-get install libgmp-dev:arm64 libgmp-dev:armhf
24-
- uses: actions/checkout@v2
25-
- name: go build
26-
run: |
2726
go build -v -ldflags '-w -s -extldflags -static' -o redpwnpow-linux-amd64 ./cmd/redpwnpow
2827
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOARCH=arm64 go build -v -ldflags '-w -s -extldflags -static' -o redpwnpow-linux-arm64 ./cmd/redpwnpow
2928
CC=arm-linux-gnueabihf-gcc CGO_ENABLED=1 GOARCH=arm go build -v -ldflags '-w -s -extldflags -static' -o redpwnpow-linux-armv6l ./cmd/redpwnpow
@@ -32,11 +31,11 @@ jobs:
3231
name: linux
3332
path: redpwnpow-linux-*
3433
darwin:
35-
runs-on: macos-10.15
34+
runs-on: macos-11
3635
steps:
3736
- uses: actions/setup-go@v2
3837
with:
39-
go-version: 1.16.5
38+
go-version: 1.17.0
4039
- uses: actions/checkout@v2
4140
- name: go build
4241
run: |
@@ -45,28 +44,29 @@ jobs:
4544
go build -v -ldflags "-w -s -extldflags -L$lib_tmp" -o redpwnpow-darwin-amd64 ./cmd/redpwnpow
4645
oci_tmp=$(mktemp -d)
4746
ghcr_token=$(curl -f 'https://ghcr.io/token?scope=repository:homebrew/core/gmp:pull' | jq -r .token)
48-
curl -fLH "authorization: Bearer $ghcr_token" https://ghcr.io/v2/homebrew/core/gmp/blobs/sha256:ff4ad8d068ba4c14d146abb454991b6c4f246796ec2538593dc5f04ca7593eec | tar xzC "$oci_tmp" --strip-components=2
47+
curl -fLH "authorization: Bearer $ghcr_token" https://ghcr.io/v2/homebrew/core/gmp/blobs/sha256:ff4ad8d068ba4c14d146abb454991b6c4f246796ec2538593dc5f04ca7593eec | tar xzC "$oci_tmp" --strip-components 2
4948
lib_tmp=$(mktemp -d)
5049
cp "$oci_tmp/lib/libgmp.a" "$lib_tmp"
51-
export SDK_NAME=macosx
52-
export SDK_PATH=$(xcrun --show-sdk-path --sdk $SDK_NAME)
53-
export CC="$(xcrun -sdk $SDK_PATH --find clang) -arch arm64 -isysroot $SDK_PATH"
54-
export CFLAGS="-isysroot $SDK_PATH -arch arm64 -I$SDK_PATH/usr/include"
55-
export LD_LIBRARY_PATH="$SDK_PATH/usr/lib"
56-
export CGO_LDFLAGS="-isysroot $SDK_PATH -arch arm64 -L$lib_tmp"
57-
export CGO_CFLAGS="-isysroot $SDK_PATH -arch arm64 -I/usr/local/include"
58-
CGO_ENABLED=1 GOARCH=arm64 go build -v -ldflags '-w -s' -o redpwnpow-darwin-arm64 ./cmd/redpwnpow
50+
sdk_path="$(xcrun --show-sdk-path --sdk macosx)"
51+
CGO_ENABLED=1 GOARCH=arm64 CC="$(xcrun -sdk $sdk_path --find clang) -arch arm64 -isysroot $sdk_path" \
52+
CFLAGS="-isysroot $sdk_path -arch arm64 -I$sdk_path/usr/include" LD_LIBRARY_PATH="$sdk_path/usr/lib" \
53+
CGO_LDFLAGS="-isysroot $sdk_path -arch arm64 -L$lib_tmp" CGO_CFLAGS="-isysroot $sdk_path -arch arm64 -I/usr/local/include" \
54+
go build -v -ldflags '-w -s' -o redpwnpow-darwin-arm64 ./cmd/redpwnpow
5955
lipo -create -output redpwnpow-darwin redpwnpow-darwin-amd64 redpwnpow-darwin-arm64
6056
- uses: actions/upload-artifact@v2
6157
with:
6258
name: darwin
6359
path: redpwnpow-darwin
6460
windows:
65-
runs-on: windows-2019
61+
runs-on: windows-2022
6662
steps:
63+
- uses: actions/setup-go@v2
64+
with:
65+
go-version: 1.17.0
6766
- uses: msys2/setup-msys2@v2
6867
with:
69-
install: mingw-w64-x86_64-go mingw-w64-x86_64-gcc mingw-w64-x86_64-gmp
68+
path-type: inherit
69+
install: mingw-w64-x86_64-gcc mingw-w64-x86_64-gmp
7070
- uses: actions/checkout@v2
7171
- name: go build
7272
shell: msys2 {0}
@@ -90,8 +90,6 @@ jobs:
9090
- uses: softprops/action-gh-release@v1
9191
with:
9292
files: build/*/redpwnpow-*
93-
env:
94-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9593
- name: cloudflare
9694
run: >
9795
curl -sSXPUT https://api.cloudflare.com/client/v4/accounts/${{ secrets.CLOUDFLARE_ACCOUNT }}/workers/scripts/pow

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ redpwnpow challenge
2020
## kCTF
2121

2222
redpwnpow can be used as a drop-in replacement for [kCTF](https://google.github.io/kctf/)'s proof of work solver.
23-
redpwnpow is approximately **10x faster** than kCTF's [Python solver](https://github.com/google/kctf/blob/v1.0/docker-images/challenge/pow.py).
2423

2524
## Go module
2625

@@ -43,10 +42,10 @@ func main() {
4342
c := pow.GenerateChallenge(5000)
4443
fmt.Printf("proof of work: curl -sSfL https://pwn.red/pow | sh -s %s\nsolution: ", c)
4544
s, _ := bufio.NewReader(os.Stdin).ReadString('\n')
46-
if correct, err := c.Check(s); err == nil && correct {
47-
fmt.Println("correct")
45+
if good, err := c.Check(s); err == nil && good {
46+
fmt.Println("good")
4847
} else {
49-
fmt.Println("incorrect")
48+
fmt.Println("bad")
5049
}
5150
}
5251
```

cmd/redpwnpow/redpwnpow.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func run() error {
2222

2323
func main() {
2424
if err := run(); err != nil {
25-
fmt.Fprintln(os.Stderr, err)
25+
fmt.Fprintf(os.Stderr, "error: %v\n", err)
2626
os.Exit(1)
2727
}
2828
}

cmd/redpwnpow/run.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/sh
22
# redpwnpow proof of work runner
3-
# https://github.com/redpwn/pow/blob/master/cmd/redpwnpow/run.sh
3+
# https://github.com/redpwn/pow
44

5-
set -e
5+
set -eu
66
version=VERSION
77
run() {
88
case $(uname | tr '[:upper:]' '[:lower:]') in
@@ -17,10 +17,13 @@ run() {
1717
msys*|mingw*|cygwin*) release=windows-amd64.exe;;
1818
*) echo unknown operating system >&2; exit 1
1919
esac
20-
cache_root=$HOME/.cache/redpwnpow
20+
cache_root=${XDG_CACHE_HOME:-$HOME/.cache}/redpwnpow
2121
mkdir -p "$cache_root"
2222
cache_path=$cache_root/redpwnpow-$version-$release
23-
[ -e "$cache_path" ] || curl -sSfLo "$cache_path" "https://github.com/redpwn/pow/releases/download/$version/redpwnpow-$release" && chmod u+x "$cache_path"
23+
if [ ! -e "$cache_path" ]; then
24+
curl -sSfLo "$cache_path" "https://github.com/redpwn/pow/releases/download/$version/redpwnpow-$release"
25+
chmod u+x "$cache_path"
26+
fi
2427
"$cache_path" "$@"
2528
}
2629
run "$@"

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module github.com/redpwn/pow
22

3-
go 1.16
3+
go 1.17
44

55
require github.com/ncw/gmp v1.0.4

0 commit comments

Comments
 (0)