Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ipieces README #45

Merged
merged 2 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/bitlux/caches
go 1.23.4

require (
github.com/bitlux/vpnapi v0.0.0-20250207215125-f066bb2314a4
github.com/bitlux/vpnapi v0.0.0-20250217222132-63c262807319
github.com/d4l3k/go-bfloat16 v0.0.0-20211005043715-690c3bdd05f1
github.com/keep94/sqroot/v3 v3.7.2
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
github.com/bitlux/vpnapi v0.0.0-20250207215125-f066bb2314a4 h1:zYVWlKFsyl3tMu3Ak9es+EMW2DUe9nqPQaOQNBtu2XQ=
github.com/bitlux/vpnapi v0.0.0-20250207215125-f066bb2314a4/go.mod h1:ou6ccQPRIv8uzPNeLaRLxnwd2felkT30fwGnJtbVYCg=
github.com/bitlux/vpnapi v0.0.0-20250217222132-63c262807319 h1:wfPTZ1VuQP/IecBGOW+2sNAzqd5hdRdU5+Wh14jiho4=
github.com/bitlux/vpnapi v0.0.0-20250217222132-63c262807319/go.mod h1:ou6ccQPRIv8uzPNeLaRLxnwd2felkT30fwGnJtbVYCg=
github.com/d4l3k/go-bfloat16 v0.0.0-20211005043715-690c3bdd05f1 h1:cBzrdJPAFBsgCrDPnZxlp1dF2+k4r1kVpD7+1S1PVjY=
github.com/d4l3k/go-bfloat16 v0.0.0-20211005043715-690c3bdd05f1/go.mod h1:uw2gLcxEuYUlAd/EXyjc/v55nd3+47YAgWbSXVxPrNI=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down
19 changes: 12 additions & 7 deletions ipieces/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
# ipieces

ipieces is a Go package used to create Geocaching puzzles such as [GCB1ZXB](https://coord.info/GCB1ZXB).
ipieces is a Go package used to create Geocaching puzzles such as
[GCB1ZXB](https://coord.info/GCB1ZXB).

## Documentation

Available at https://pkg.go.dev/github.com/bitlux/caches/ipieces.

## Deployment instructions

I deploy on [Google Cloud Run](https://cloud.google.com/run). To do that, you must first sign
into the [Google Cloud console](https://console.cloud.google.com/),
[create a project](https://cloud.google.com/resource-manager/docs/creating-managing-projects), and have
[`gcloud`](https://cloud.google.com/sdk) installed.
I deploy on [Google Cloud Run](https://cloud.google.com/run).
https://cloud.google.com/run/docs/quickstarts/build-and-deploy/deploy-go-service is a good
reference on how to us Google Cloud Run.

Create a directory for your project and put your code in a file named `main.go`. Run
`go mod init <module name>` to create a module (because your `main.go` imports packages outside the
standard library, Google Cloud Run requires it to be in its own module).

To deploy, `cd` to the directory with your `main.go` file and run:
```
gcloud run deploy --source . <project> [--allow-unauthenticated]
gcloud run deploy --source . <service> [--allow-unauthenticated]
```
where `<service>` is any name you want.

## Testing

Expand All @@ -29,4 +34,4 @@ where `<backdoor>` is the `Puzzle.Backdoor` string you set.
## Contact / Support

I welcome issues and pull requests on GitHub and messages and email on
[geocaching.com](https://www.geocaching.com/profile/?u=bitlux).
[geocaching.com](https://www.geocaching.com/profile/?u=bitlux).
5 changes: 4 additions & 1 deletion ipieces/ipieces.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ func (p Puzzle) handle(w http.ResponseWriter, req *http.Request, tmpl *template.

if p.Client != nil {
resp, err := p.Client.Query(d.IP)
if resp.Message != "" {
fmt.Println("Response message:", resp.Message)
}
if err != nil {
if err == vpnapi.ErrRateLimited {
writeResponse(w, http.StatusTooManyRequests, rateLimitPage, "rate limited: %v\n", err)
Expand All @@ -222,7 +225,7 @@ func (p Puzzle) handle(w http.ResponseWriter, req *http.Request, tmpl *template.
}

if resp.Security.VPN || resp.Security.Proxy || resp.Security.Tor || resp.Security.Relay {
writeResponse(w, http.StatusForbidden, vpnPage, "%t %t %t %t\n", resp.Security.VPN, resp.Security.Proxy, resp.Security.Tor, resp.Security.Relay)
writeResponse(w, http.StatusForbidden, vpnPage, "VPN: %t Proxy: %t Tor: %t Relay: %t\n", resp.Security.VPN, resp.Security.Proxy, resp.Security.Tor, resp.Security.Relay)
return
}
}
Expand Down