maven-proxy 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -140,63 +140,79 @@ function resolvePath(inputPath) {
140
140
  }
141
141
 
142
142
  function getDefaultConfigTemplate() {
143
- return [
143
+ const lines = [
144
144
  "# Maven Proxy default user config",
145
+ "# Maven Proxy 用户模式默认配置",
145
146
  "# This file is loaded by default in user mode.",
146
147
  "",
147
- "PROXY_PORT=8080",
148
- "REPO_PORT=8081",
149
- "CACHE_DIR=data/cache",
150
- "CACHE_CLEANUP_ENABLED=true",
151
- "CACHE_CLEANUP_DAILY_AT=03:00",
152
- "CACHE_CLEANUP_CHECK_MIN_INTERVAL=10m",
153
- "CACHE_TOUCH_ON_HIT=true",
154
- "CACHE_TOUCH_MIN_INTERVAL=1d",
155
- "CACHE_RETENTION_START=10d",
156
- "CACHE_RETENTION_MIN=1d",
157
- "CACHE_DISK_FREE_TRIGGER=20G",
158
- "CACHE_DISK_FREE_TARGET=25G",
159
- "CACHE_MAX_SIZE=",
160
- "CACHE_TARGET_SIZE=",
161
- "REPO_FALLBACK_REPOS=https://repo1.maven.org/maven2,https://jitpack.io,https://plugins.gradle.org/m2,https://maven.google.com",
162
- "ENABLE_HTTPS_PROXY=true",
163
- "HTTPS_MITM_DOMAINS=repo1.maven.org,repo.maven.apache.org,registry.npmjs.org",
164
- "HTTPS_PASSTHROUGH_FOR_UNMATCHED=false",
165
- "NPM_REGISTRY_DOMAINS=registry.npmjs.org,registry.npmmirror.com,npm.pkg.github.com",
166
- "MAVEN_REPO_DOMAINS=repo1.maven.org,repo.maven.apache.org,jitpack.io,plugins.gradle.org,maven.google.com",
167
- "MULTI_THREAD_DOMAINS=repo1.maven.org",
168
- "MULTI_THREAD_COUNT=8",
169
- "MULTI_THREAD_MIN_SIZE_MB=1",
170
- "DOWNLOAD_TIMEOUT=60s",
171
- "OUTBOUND_KEEP_ALIVE=true",
172
- "OUTBOUND_KEEP_ALIVE_INTERVAL=1s",
173
- "OUTBOUND_MAX_SOCKETS=64",
174
- "OUTBOUND_MAX_FREE_SOCKETS=16",
175
- "MAVEN_AFFINITY_ENABLED=true",
176
- "MAVEN_AFFINITY_INDEX_DIR=data/index",
177
- "MAVEN_NEGATIVE_CACHE_TTL=24h",
178
- "MAVEN_AFFINITY_FLUSH_INTERVAL=5s",
179
- "MAVEN_AFFINITY_EVENT_MAX_MB=8",
180
- "DOWNLOAD_LOG_DIR=data/logs/downloads",
181
- "LOG_RETENTION=7d",
182
- "LOG_TO_STDOUT=false",
183
- "UPSTREAM_PROXY_URL=",
184
- "UPSTREAM_HTTP_PROXY_URL=",
185
- "UPSTREAM_HTTPS_PROXY_URL=",
186
- "UPSTREAM_NO_PROXY=127.0.0.1,localhost",
187
- "UPSTREAM_IGNORE_DOMAINS=",
188
- "CERT_DIR=data/certs",
189
- "ROOT_CERT_PATH=data/certs/root-ca.crt",
190
- "ROOT_KEY_PATH=data/certs/root-ca.key.pem",
191
- "LEAF_CERT_DIR=data/certs/leaf",
192
- "TRUST_STORE_PATH=data/certs/proxy-truststore.jks",
193
- "TRUST_STORE_ALIAS=maven-proxy-root-ca",
194
- "TRUST_STORE_PASSWORD=changeit",
195
- "EXISTING_TRUST_STORE_PATH=",
196
- "EXISTING_TRUST_STORE_PASSWORD=",
197
- "JAVA_HOME=",
198
- "",
199
- ].join("\n");
148
+ ];
149
+
150
+ const appendEntry = (key, value, zhComment, enComment) => {
151
+ lines.push(`# 中文: ${zhComment}`);
152
+ lines.push(`# English: ${enComment}`);
153
+ lines.push(`${key}=${value}`);
154
+ lines.push("");
155
+ };
156
+
157
+ appendEntry("PROXY_PORT", "8080", "代理服务端口,默认 8080。", "Proxy service port. Default: 8080.");
158
+ appendEntry("REPO_PORT", "8081", "本地仓库服务端口,默认 8081。", "Local repository service port. Default: 8081.");
159
+ appendEntry("CACHE_DIR", "data/cache", "缓存根目录,默认 data/cache。", "Cache root directory. Default: data/cache.");
160
+ appendEntry("CACHE_CLEANUP_ENABLED", "true", "是否启用自动缓存清理,默认 true。", "Enable automatic cache cleanup. Default: true.");
161
+ appendEntry("CACHE_CLEANUP_DAILY_AT", "03:00", "每日固定检查时间(本地时区,HH:mm),默认 03:00。", "Fixed daily check time in local timezone (HH:mm). Default: 03:00.");
162
+ appendEntry("CACHE_CLEANUP_CHECK_MIN_INTERVAL", "10m", "压力检测最小间隔(支持 s/m/h/d),默认 10m。", "Minimum interval for pressure checks (supports s/m/h/d). Default: 10m.");
163
+ appendEntry("CACHE_TOUCH_ON_HIT", "true", "缓存命中返回时是否更新文件 mtime,默认 true。", "Update file mtime when serving cache hit. Default: true.");
164
+ appendEntry("CACHE_TOUCH_MIN_INTERVAL", "1d", "同一文件两次 touch 最小间隔(支持 s/m/h/d),默认 1d。", "Minimum interval between touches for the same file (supports s/m/h/d). Default: 1d.");
165
+ appendEntry("CACHE_RETENTION_START", "10d", "清理轮次初始保留窗口(支持 s/m/h/d),默认 10d。", "Initial retention window for cleanup cycle (supports s/m/h/d). Default: 10d.");
166
+ appendEntry("CACHE_RETENTION_MIN", "1d", "清理轮次最小保留窗口(支持 s/m/h/d),默认 1d。", "Minimum retention window for cleanup cycle (supports s/m/h/d). Default: 1d.");
167
+ appendEntry("CACHE_DISK_FREE_TRIGGER", "20G", "磁盘剩余空间低于该值触发清理(支持 K/M/G/T),默认 20G。", "Trigger cleanup when free disk space is below this value (supports K/M/G/T). Default: 20G.");
168
+ appendEntry("CACHE_DISK_FREE_TARGET", "25G", "磁盘剩余空间恢复到该值可停止清理(支持 K/M/G/T),默认 25G。", "Stop cleanup when free disk space recovers to this value (supports K/M/G/T). Default: 25G.");
169
+ appendEntry("CACHE_MAX_SIZE", "", "可选:缓存总大小触发阈值(支持 K/M/G/T),默认空(禁用)。", "Optional: cache total size trigger threshold (supports K/M/G/T). Default: empty (disabled).");
170
+ appendEntry("CACHE_TARGET_SIZE", "", "可选:缓存总大小回落目标(支持 K/M/G/T),默认空(禁用)。", "Optional: cache size recovery target (supports K/M/G/T). Default: empty (disabled).");
171
+ appendEntry(
172
+ "REPO_FALLBACK_REPOS",
173
+ "https://repo1.maven.org/maven2,https://jitpack.io,https://plugins.gradle.org/m2,https://dl.google.com",
174
+ "缓存未命中时回源仓库列表(逗号分隔)。",
175
+ "Fallback repository list when cache misses (comma-separated).",
176
+ );
177
+ appendEntry("ENABLE_HTTPS_PROXY", "true", "是否启用 HTTPS 代理处理(true/false),默认 true。", "Enable HTTPS proxy handling (true/false). Default: true.");
178
+ appendEntry("HTTPS_MITM_DOMAINS", "repo1.maven.org,repo.maven.apache.org,registry.npmjs.org", "执行 MITM 证书签发的域名列表(逗号分隔,支持通配符)。", "Domains for MITM certificate issuance (comma-separated, wildcard supported).");
179
+ appendEntry("HTTPS_PASSTHROUGH_FOR_UNMATCHED", "false", "未命中 MITM 域名时是否允许隧道透传,默认 false。", "Allow tunnel passthrough for unmatched MITM domains. Default: false.");
180
+ appendEntry("NPM_REGISTRY_DOMAINS", "registry.npmjs.org,registry.npmmirror.com,npm.pkg.github.com", "识别为 npm 生态并分流缓存的域名列表(支持通配符)。", "Domains recognized as npm ecosystem for cache routing (wildcard supported).");
181
+ appendEntry("MAVEN_REPO_DOMAINS", "repo1.maven.org,repo.maven.apache.org,jitpack.io,plugins.gradle.org,dl.google.com", "识别为 Maven 生态并分流缓存的域名列表(支持通配符)。", "Domains recognized as Maven ecosystem for cache routing (wildcard supported).");
182
+ appendEntry("MULTI_THREAD_DOMAINS", "repo1.maven.org", "启用多线程下载的域名列表(支持通配符)。", "Domains that enable multi-thread download (wildcard supported).");
183
+ appendEntry("MULTI_THREAD_COUNT", "8", "多线程下载线程数,默认 8。", "Thread count for multi-thread download. Default: 8.");
184
+ appendEntry("MULTI_THREAD_MIN_SIZE_MB", "1", "触发多线程下载的最小文件大小阈值(MB),默认 1。", "Minimum file size threshold in MB to trigger multi-thread download. Default: 1.");
185
+ appendEntry("DOWNLOAD_TIMEOUT", "60s", "上游请求超时时间(支持 s/m/h/d),默认 60s。", "Upstream request timeout (supports s/m/h/d). Default: 60s.");
186
+ appendEntry("DOWNLOAD_LOG_DIR", "data/logs/downloads", "统一主日志与错误日志目录。", "Unified main and error log directory.");
187
+ appendEntry("LOG_RETENTION", "7d", "日志保留时长(支持 s/m/h/d),默认 7d。", "Log retention duration (supports s/m/h/d). Default: 7d.");
188
+ appendEntry("LOG_TO_STDOUT", "false", "是否输出运行期日志到命令行,默认 false。", "Output runtime logs to stdout. Default: false.");
189
+ appendEntry("LOG_CONNECT_EVENTS", "false", "是否输出详细 CONNECT/MITM 握手日志,默认 false。", "Output detailed CONNECT/MITM handshake logs. Default: false.");
190
+ appendEntry("OUTBOUND_KEEP_ALIVE", "true", "是否启用出站 keep-alive 连接复用池,默认 true。", "Enable outbound keep-alive connection pool. Default: true.");
191
+ appendEntry("OUTBOUND_KEEP_ALIVE_INTERVAL", "1s", "keep-alive 间隔(支持 s/m/h/d),默认 1s。", "Keep-alive interval (supports s/m/h/d). Default: 1s.");
192
+ appendEntry("OUTBOUND_MAX_SOCKETS", "64", "每个源站最大出站连接数,默认 64。", "Maximum outbound sockets per upstream host. Default: 64.");
193
+ appendEntry("OUTBOUND_MAX_FREE_SOCKETS", "16", "每个源站可保留空闲连接上限,默认 16。", "Maximum free outbound sockets kept per upstream host. Default: 16.");
194
+ appendEntry("MAVEN_AFFINITY_ENABLED", "true", "是否启用 Maven affinity 缓存索引,默认 true。", "Enable Maven affinity index. Default: true.");
195
+ appendEntry("MAVEN_AFFINITY_INDEX_DIR", "data/index", "Maven affinity 索引目录,默认 data/index。", "Maven affinity index directory. Default: data/index.");
196
+ appendEntry("MAVEN_NEGATIVE_CACHE_TTL", "24h", "负缓存 TTL(支持 s/m/h/d),默认 24h。", "Negative cache TTL (supports s/m/h/d). Default: 24h.");
197
+ appendEntry("MAVEN_AFFINITY_FLUSH_INTERVAL", "5s", "affinity 事件日志 flush 周期(支持 s/m/h/d),默认 5s。", "Affinity event log flush interval (supports s/m/h/d). Default: 5s.");
198
+ appendEntry("MAVEN_AFFINITY_EVENT_MAX_MB", "8", "affinity 事件日志压缩阈值(MB),默认 8。", "Affinity event log compaction threshold in MB. Default: 8.");
199
+ appendEntry("UPSTREAM_PROXY_URL", "", "通用上级代理地址(HTTP/HTTPS 兜底)。", "Generic upstream proxy URL fallback for HTTP/HTTPS.");
200
+ appendEntry("UPSTREAM_HTTP_PROXY_URL", "", "HTTP 请求使用的上级代理地址。", "Upstream proxy URL for HTTP requests.");
201
+ appendEntry("UPSTREAM_HTTPS_PROXY_URL", "", "HTTPS 请求使用的上级代理地址。", "Upstream proxy URL for HTTPS requests.");
202
+ appendEntry("UPSTREAM_NO_PROXY", "127.0.0.1,localhost", "不走上级代理的域名列表(逗号分隔,支持通配符,* 表示全部直连)。", "Domains that bypass upstream proxy (comma-separated, wildcard supported, * means direct for all).");
203
+ appendEntry("UPSTREAM_IGNORE_DOMAINS", "", "额外忽略上级代理的域名列表(支持通配符)。", "Additional domains ignored by upstream proxy (wildcard supported).");
204
+ appendEntry("CERT_DIR", "data/certs", "证书根目录,默认 data/certs。", "Certificate root directory. Default: data/certs.");
205
+ appendEntry("ROOT_CERT_PATH", "data/certs/root-ca.crt", "Root CA 证书路径。", "Root CA certificate path.");
206
+ appendEntry("ROOT_KEY_PATH", "data/certs/root-ca.key.pem", "Root CA 私钥路径。", "Root CA private key path.");
207
+ appendEntry("LEAF_CERT_DIR", "data/certs/leaf", "站点叶子证书目录。", "Leaf certificate directory.");
208
+ appendEntry("TRUST_STORE_PATH", "data/certs/proxy-truststore.jks", "Java trust store 文件路径。", "Java trust store file path.");
209
+ appendEntry("TRUST_STORE_ALIAS", "maven-proxy-root-ca", "导入 Root CA 到 trust store 时使用的别名。", "Alias used to import Root CA into trust store.");
210
+ appendEntry("TRUST_STORE_PASSWORD", "changeit", "trust store 密码。", "Trust store password.");
211
+ appendEntry("EXISTING_TRUST_STORE_PATH", "", "已有 truststore 路径(可选),初始化时可作为源。", "Existing truststore path (optional), used as source during init.");
212
+ appendEntry("EXISTING_TRUST_STORE_PASSWORD", "", "已有 truststore 密码(可选),用于读取 EXISTING_TRUST_STORE_PATH。", "Existing truststore password (optional), used to read EXISTING_TRUST_STORE_PATH.");
213
+ appendEntry("JAVA_HOME", "", "Java 安装路径;为空或无效时会自动探测。", "Java installation path; auto-detected when empty or invalid.");
214
+
215
+ return `${lines.join("\n").trimEnd()}\n`;
200
216
  }
201
217
 
202
218
  async function initConfigFile(configFile, force = false) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maven-proxy",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Maven proxy with cache, HTTPS MITM for selected domains, and local repo publishing",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -19,6 +19,7 @@
19
19
  "cli:start": "node bin/maven-proxy.js start --mode development",
20
20
  "cli:stop": "node bin/maven-proxy.js stop",
21
21
  "cli:doctor": "node bin/maven-proxy.js doctor --mode development",
22
+ "cli:doctor:user": "node bin/maven-proxy.js doctor --mode user",
22
23
  "cli:truststore:print": "node bin/maven-proxy.js truststore print --mode development",
23
24
  "cli:truststore:init": "node bin/maven-proxy.js truststore init --mode development",
24
25
  "cli:truststore:merge": "node bin/maven-proxy.js truststore merge --mode development",
@@ -193,7 +193,7 @@ const defaultRepoFallbackRepos = [
193
193
  "https://repo1.maven.org/maven2",
194
194
  "https://jitpack.io",
195
195
  "https://plugins.gradle.org/m2",
196
- "https://maven.google.com",
196
+ "https://dl.google.com",
197
197
  ];
198
198
 
199
199
  const repoFallbackRepos = normalizeRepoList(
@@ -206,7 +206,7 @@ const defaultMavenRepoDomains = [
206
206
  "repo.maven.apache.org",
207
207
  "jitpack.io",
208
208
  "plugins.gradle.org",
209
- "maven.google.com",
209
+ "dl.google.com",
210
210
  ...extractHostsFromUrls(repoFallbackRepos),
211
211
  ];
212
212