Skip to content

Commit 8b2e4ff

Browse files
committed
add user-agent to all outgoing requests
1 parent 36394ca commit 8b2e4ff

9 files changed

Lines changed: 18 additions & 14 deletions

File tree

.github/scripts/fetch-posthog-popular-stops.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ INSIGHTS=(
2121
fetch() {
2222
local short_id=$1
2323
local query
24-
query=$(curl -sG "https://eu.posthog.com/api/projects/$PROJ/insights/" \
24+
query=$(curl -sG -A "entur-geocoder" "https://eu.posthog.com/api/projects/$PROJ/insights/" \
2525
-H "Authorization: Bearer $TOKEN" \
2626
--data-urlencode "short_id=$short_id" \
2727
| jq ".results[0].query | .source.breakdownFilter.breakdown_limit = $LIMIT")
28-
curl -s "https://eu.posthog.com/api/projects/$PROJ/query/" \
28+
curl -s -A "entur-geocoder" "https://eu.posthog.com/api/projects/$PROJ/query/" \
2929
-H "Authorization: Bearer $TOKEN" \
3030
-H "Content-Type: application/json" \
3131
-d "{\"query\": $query}"

.github/workflows/cache-data-sources.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
steps:
3535
- name: Download ${{ matrix.source.name }}
3636
run: |
37-
curl -fL --retry 3 --retry-delay 10 -o "${{ matrix.source.filename }}" "${{ matrix.source.url }}"
37+
curl -fL --retry 3 --retry-delay 10 -A "entur-geocoder" -o "${{ matrix.source.filename }}" "${{ matrix.source.url }}"
3838
ls -lh "${{ matrix.source.filename }}"
3939
4040
- name: Verify file size

.github/workflows/monitor-photon-data.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Check Photon import date
1414
id: check
1515
run: |
16-
INFO=$(curl -sf https://api.entur.io/geocoder/v2/info)
16+
INFO=$(curl -sf -A "entur-geocoder" https://api.entur.io/geocoder/v2/info)
1717
IMPORT_DATE=$(echo "$INFO" | jq -r '.photonImportDate')
1818
1919
echo "Import date: $IMPORT_DATE"

photon/download-latest-nominatim-data.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ case "$TAG_INPUT" in
1818
latest|latest-prod)
1919
POINTER_URL="https://storage.googleapis.com/${BUCKET}/${PREFIX}/${TAG_INPUT}.txt"
2020
echo "Resolving $TAG_INPUT pointer: $POINTER_URL"
21-
TAG=$(curl -fsSL "$POINTER_URL" | tr -d '[:space:]')
21+
TAG=$(curl -fsSL -A "entur-geocoder" "$POINTER_URL" | tr -d '[:space:]')
2222
;;
2323
*)
2424
TAG="$TAG_INPUT"
@@ -27,5 +27,5 @@ esac
2727

2828
URL="https://storage.googleapis.com/${BUCKET}/${PREFIX}/${TAG}/${FILENAME}"
2929
echo "Downloading $URL"
30-
curl -fL --retry 3 --retry-delay 10 -o "$FILENAME" "$URL"
30+
curl -fL --retry 3 --retry-delay 10 -A "entur-geocoder" -o "$FILENAME" "$URL"
3131
ls -lh "$FILENAME"

photon/download-latest-photon-data.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ case "$TAG_INPUT" in
2020
latest|latest-prod)
2121
POINTER_URL="https://storage.googleapis.com/${BUCKET}/${PREFIX}/${TAG_INPUT}.txt"
2222
echo "Resolving $TAG_INPUT pointer: $POINTER_URL"
23-
TAG=$(curl -fsSL "$POINTER_URL" | tr -d '[:space:]')
23+
TAG=$(curl -fsSL -A "entur-geocoder" "$POINTER_URL" | tr -d '[:space:]')
2424
;;
2525
*)
2626
TAG="$TAG_INPUT"
@@ -32,9 +32,9 @@ echo "Downloading $URL"
3232

3333
TARBALL=$(mktemp)
3434
trap 'rm -f "$TARBALL"' EXIT
35-
curl -fL --retry 3 --retry-delay 10 -o "$TARBALL" "$URL"
35+
curl -fL --retry 3 --retry-delay 10 -A "entur-geocoder" -o "$TARBALL" "$URL"
3636

37-
EXPECTED=$(curl -fsSL --retry 3 --retry-delay 5 "${URL}.sha256" | tr -d '[:space:]')
37+
EXPECTED=$(curl -fsSL --retry 3 --retry-delay 5 -A "entur-geocoder" "${URL}.sha256" | tr -d '[:space:]')
3838
ACTUAL=$(sha256sum "$TARBALL" | awk '{print $1}')
3939
if [ "$EXPECTED" != "$ACTUAL" ]; then
4040
echo "checksum mismatch: expected $EXPECTED got $ACTUAL" >&2

photon/import/create-nominatim-data.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ if [ ! -f "$BINARY" ]; then
3838
*) fail "Unsupported OS: $OS" ;;
3939
esac
4040
echo "Downloading nominatim-converter $VERSION..."
41-
curl -sfL --retry 2 "$BASE_URL/$ARTIFACT" -o "$BINARY"
41+
curl -sfL --retry 2 -A "entur-geocoder" "$BASE_URL/$ARTIFACT" -o "$BINARY"
4242
chmod +x "$BINARY"
4343
fi
4444

@@ -104,7 +104,7 @@ START_TIME=$(date +%s)
104104
if [ -n "${USAGE_URL:-}" ]; then
105105
USAGE_FILE="${TMPDIR:-/tmp}/nominatim-usage.csv"
106106
echo "Downloading usage CSV: $USAGE_URL"
107-
curl -sfL --retry 2 "$USAGE_URL" -o "$USAGE_FILE"
107+
curl -sfL --retry 2 -A "entur-geocoder" "$USAGE_URL" -o "$USAGE_FILE"
108108
echo " $(wc -l < "$USAGE_FILE") rows -> $USAGE_FILE"
109109
fi
110110

photon/import/download-photon-jar.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ set -euo pipefail
44

55
PHOTON_JAR=https://github.com/entur/photon/releases/download/2026-05-04-apostrophe-s/photon-1.1.0.jar
66

7-
curl -sfL --retry 2 -o photon.jar $PHOTON_JAR && echo photon.jar downloaded successfully && exit 0
7+
curl -sfL --retry 2 -A "entur-geocoder" -o photon.jar $PHOTON_JAR && echo photon.jar downloaded successfully && exit 0
88

99
echo ERROR: failed downloading photon.jar && exit 1

photon/photon-start.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ if [ ! -f "$SENTINEL" ]; then
2727
echo "Downloading $PHOTON_DATA_URL"
2828
TARBALL=$(mktemp)
2929
trap 'rm -f "$TARBALL"' EXIT
30-
curl -fL --retry 3 --retry-delay 10 --connect-timeout 30 -o "$TARBALL" "$PHOTON_DATA_URL"
30+
curl -fL --retry 3 --retry-delay 10 --connect-timeout 30 -A "entur-geocoder" -o "$TARBALL" "$PHOTON_DATA_URL"
3131

3232
# CI always uploads .sha256 alongside the tarball; treat its absence as an error.
33-
EXPECTED=$(curl -fsSL --retry 3 --retry-delay 5 "${PHOTON_DATA_URL}.sha256" | tr -d '[:space:]')
33+
EXPECTED=$(curl -fsSL --retry 3 --retry-delay 5 -A "entur-geocoder" "${PHOTON_DATA_URL}.sha256" | tr -d '[:space:]')
3434
ACTUAL=$(sha256sum "$TARBALL" | awk '{print $1}')
3535
if [ "$EXPECTED" != "$ACTUAL" ]; then
3636
echo "checksum mismatch: expected $EXPECTED got $ACTUAL" >&2

proxy/src/main/kotlin/no/entur/geocoder/proxy/App.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonInclude
44
import com.fasterxml.jackson.databind.ObjectMapper
55
import io.ktor.client.*
66
import io.ktor.client.engine.cio.*
7+
import io.ktor.client.plugins.UserAgent
78
import io.ktor.http.*
89
import io.ktor.serialization.jackson.*
910
import io.ktor.server.application.*
@@ -180,6 +181,9 @@ class App {
180181

181182
private val httpClient =
182183
HttpClient(CIO) {
184+
install(UserAgent) {
185+
agent = "entur-geocoder-proxy"
186+
}
183187
install(ClientContentNegotiation) {
184188
jackson()
185189
}

0 commit comments

Comments
 (0)