mirror of
https://github.com/dalbodeule/hop-gate.git
synced 2025-12-08 04:45:43 +09:00
Implement initial DTLS handshake flow for server and client using pion/dtls. Load server and client configuration from .env/environment, including new debug flags and logging config. On the server: - load ServerConfig from env, including DTLS listen addr and debug flag - create DTLS listener with optional self-signed localhost cert in debug - accept DTLS sessions and run PerformServerHandshake with a dummy domain validator On the client: - load ClientConfig from env, then override with CLI flags where given - validate required fields: server_addr, domain, api_key, local_target - create DTLS client and run PerformClientHandshake - support debug mode to skip server certificate verification Also: - update go.mod/go.sum with pion/dtls and related dependencies - extend .env.example with new ports, client config, and debug flags - ignore built binaries via bin/ in .gitignore BREAKING CHANGE: client environment variables have changed. The former HOP_CLIENT_ID, HOP_CLIENT_AUTH_TOKEN and HOP_CLIENT_SERVICE_PORTS are replaced by HOP_CLIENT_DOMAIN, HOP_CLIENT_API_KEY, HOP_CLIENT_LOCAL_TARGET and HOP_CLIENT_DEBUG. Client startup now requires server_addr, domain, api_key and local_target to be provided (via env or CLI).
69 lines
2.1 KiB
Plaintext
69 lines
2.1 KiB
Plaintext
# hop-gate .env example
|
|
#
|
|
# 이 파일을 복사해서 `.env` 로 이름을 바꾼 뒤 값을 채워서 사용하세요.
|
|
# internal/config 패키지의 LoadServerConfigFromEnv / LoadClientConfigFromEnv 가
|
|
# .env를 먼저 읽고, 이후 환경변수로부터 설정을 구성합니다.
|
|
|
|
# ---- Logging / Loki ----
|
|
|
|
# 로그 레벨: debug/info/warn/error
|
|
HOP_LOG_LEVEL=info
|
|
|
|
# Loki HTTP push 사용 여부 (Promtail 없이 직접 push 할 때 true)
|
|
HOP_LOKI_ENABLE=false
|
|
|
|
# Loki HTTP push 엔드포인트 (예: http://loki:3100/loki/api/v1/push)
|
|
#HOP_LOKI_ENDPOINT=http://loki:3100/loki/api/v1/push
|
|
|
|
# 멀티 테넌시 Loki 사용 시 Tenant ID (X-Scope-OrgID 등으로 사용)
|
|
#HOP_LOKI_TENANT_ID=
|
|
|
|
# Basic Auth 자격 증명 (필요할 때만)
|
|
#HOP_LOKI_USERNAME=
|
|
#HOP_LOKI_PASSWORD=
|
|
|
|
# 모든 로그에 공통으로 붙일 라벨 (콤마 구분: key=value,key2=value2)
|
|
# 예: app=hop-gate,env=dev,region=ap-northeast-2
|
|
#HOP_LOKI_STATIC_LABELS=app=hop-gate,env=dev,region=ap-northeast-2
|
|
|
|
|
|
# ---- Server ports & domains ----
|
|
|
|
# HTTP 리스닝 포트 (보통 :80, ACME HTTP-01 및 HTTPS 리다이렉트용)
|
|
HOP_SERVER_HTTP_LISTEN=:8080
|
|
|
|
# HTTPS 리스닝 포트 (보통 :443)
|
|
HOP_SERVER_HTTPS_LISTEN=:8443
|
|
|
|
# DTLS 리스닝 포트 (보통 :443, 필요시 별도 포트 사용)
|
|
HOP_SERVER_DTLS_LISTEN=:8443
|
|
|
|
# 메인 도메인 (예: example.com)
|
|
HOP_SERVER_DOMAIN=example.com
|
|
|
|
# 프록시용 서브도메인/별도 도메인 목록 (콤마 구분)
|
|
# 예: api.example.com,edge.example.com
|
|
HOP_SERVER_PROXY_DOMAINS=api.example.com,edge.example.com
|
|
|
|
# 디버깅용 플래그
|
|
# 1. self signed localhost cert 사용여부 (debug: true -> 사용)
|
|
HOP_SERVER_DEBUG=true
|
|
|
|
# ---- Client settings ----
|
|
|
|
# DTLS 서버 주소 (host:port)
|
|
# 예: example.com:443
|
|
HOP_CLIENT_SERVER_ADDR=localhost:8443
|
|
|
|
# 클라이언트 도메인
|
|
HOP_CLIENT_DOMAIN=test.example.com
|
|
|
|
# 인증 토큰 (서버에서 검증용으로 사용 가능)
|
|
HOP_CLIENT_API_KEY=TEST_API_KEY_0123456789_ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
|
|
|
|
# 서비스 매핑: name=host:port 형태
|
|
HOP_CLIENT_LOCAL_TARGET=127.0.0.1:8080
|
|
|
|
# 디버깅용 플래그
|
|
# 1. self signed 인증서를 신뢰(인증서 체인 검증 스킵)
|
|
HOP_CLIENT_DEBUG=true |