Files
telemt-api/README.md
T
Denozordec d7a63f0da3
Publish telemt-api gateway Docker image / test (push) Failing after 17s
Publish telemt-api gateway Docker image / build-and-push (push) Has been skipped
Add GeoIP support for unique IP aggregation
- Introduced GeoIP configuration options in config.example.yaml to enable geolocation lookups for the /api/agg/unique-ips endpoint.
- Updated the aggregate handler to include optional GeoIP data in responses, enriching unique IP information with country and city details, as well as ASN data if available.
- Enhanced documentation in AGGREGATE.md and README.md to reflect the new GeoIP functionality and its usage.
- Added a dependency on the geoip2-golang library in go.mod for GeoIP lookups.
- Modified tests to accommodate the new GeoIP integration in the aggregate handler.
2026-03-30 01:47:08 +07:00

70 lines
3.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# telemt-api
HTTP‑шлюз на Go для [Telemt Control API](docs/API.md): один порт, **белый список IP (CIDR)**, маршруты вида `/api/{alias}/…``{base_url}/v1/…`, агрегация нескольких инстансов — [`/api/agg/…`](docs/AGGREGATE.md), метрики Prometheus на `/metrics`.
## Быстрый старт (Linux)
Предполагается установлены Docker и Docker Compose v2.
**Рекомендуется** брать уже собранный образ из Container Registry Gitea (после каждого push в репозиторий CI обновляет теги, в том числе `latest`):
```bash
# при необходимости (закрытый registry): логин Gitea + PAT с read:package
docker login git.shts.su
docker pull git.shts.su/denozord/telemt-api:latest
```
Конфиг возьмите из репозитория или создайте свой `config.yaml` (см. [config.example.yaml](config.example.yaml)):
```bash
git clone <url-репозитория> && cd telemt-api
cp config.example.yaml config.yaml
# отредактируйте config.yaml: servers, whitelist_cidrs или allow_all для разработки
docker run -d --name telemt-gateway \
-p 8080:8080 \
-v "$(pwd)/config.yaml:/etc/telemt-gateway/config.yaml:ro" \
-e CONFIG_PATH=/etc/telemt-gateway/config.yaml \
git.shts.su/denozord/telemt-api:latest
curl -sS http://127.0.0.1:8080/health
curl -sS http://127.0.0.1:8080/api/main_srv/health
```
Обновление образа: `docker pull git.shts.su/denozord/telemt-api:latest` и пересоздайте контейнер (`docker rm -f telemt-gateway` и снова `docker run …`).
### Compose
Тот же образ подтягивается из registry (без локальной сборки):
```bash
git clone <url-репозитория> && cd telemt-api
docker compose pull
docker compose up -d
docker compose logs -f gateway
```
### Локальная сборка образа
Если нужен образ из исходников на этой машине: `docker build -t telemt-api-gateway:local .` и в `docker run` укажите тег `telemt-api-gateway:local`. Подробнее — [docs/GATEWAY_RUN.md](docs/GATEWAY_RUN.md).
## Документация
| Документ | Содержание |
|----------|------------|
| **[docs/GATEWAY_RUN.md](docs/GATEWAY_RUN.md)** | Полная инструкция: конфиг, pull/registry, Docker CLI, Compose, CI/CD, неполадки |
| **[docs/API.md](docs/API.md)** | Контракт Telemt Control API (`/v1/…`) |
| **[docs/AGGREGATE.md](docs/AGGREGATE.md)** | Агрегирующие эндпоинты шлюза (`/api/agg/…`) |
| **[docs/GEOIP.md](docs/GEOIP.md)** | GeoLite2 City (страна/город) и опционально ASN (номер AS, организация) для IP в `unique-ips` |
## Сборка и тесты без Docker
```bash
go mod tidy && go test ./...
```
## CI/CD
В репозитории: [.gitea/workflows/docker.yaml](.gitea/workflows/docker.yaml) — тесты Go, сборка и публикация образа в Container Registry Gitea (см. раздел «Обновление и CI/CD» в [docs/GATEWAY_RUN.md](docs/GATEWAY_RUN.md)).