Skip to content

Commit 0c4746a

Browse files
changlin.caiclaude
andcommitted
[v2.0.0] 修正測試 + 移除 --cors 死碼,HTTP 預設 port 改為 8081
CI test 修正: - AppConfigTests 移除已不存在的 AllowedOrigins 斷言(含 Cors_ParsedFromCli 整個測試) - HttpPort 預設斷言對齊 8080 → 8081 設定變更: - AppConfig HttpPort init 預設與 FromArgs fallback:8080 → 8081 (8080 在 Windows 常被 Docker Desktop / Tomcat / 各種 dev server 占用) 文件清理: - README.md / manual.html / release.yml 移除 --cors / EDGELINK_CORS 文件化 (AppConfig 早已不解析 --cors,HttpApiServer 對 CORS 直接回 *) - README / manual / release.yml 預設 port 文字同步 8081 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0a8238c commit 0c4746a

5 files changed

Lines changed: 14 additions & 34 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ jobs:
9393
9494
```
9595
EdgeLinkServer.exe [options]
96-
--port <n> HTTP port (default: 8080)
96+
--port <n> HTTP port (default: 8081)
9797
--no-https Disable HTTPS
9898
--https-port <n> HTTPS port (default: 8443)
99-
--cors <origins> Allowed CORS origins (comma-separated)
10099
```

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ A lightweight .NET 8 server that bridges IoT devices over TCP/UDP, transforms pr
2525
| **Real-time Monitor** | Per-port SSE-streamed log with keyword search |
2626
| **Web UI** | Browser-based management — no frontend setup required |
2727
| **HTTPS** | Auto-generated self-signed certificate with SAN for all local IPs |
28-
| **Security** | PBKDF2 password hashing, session persistence, HttpOnly cookies, CORS allowlist |
28+
| **Security** | PBKDF2 password hashing, session persistence, HttpOnly cookies |
2929
| **File Logging** | Daily rolling log files with 7-day retention |
3030
| **Client SDKs** | Unity (UPM), Arduino, C# (.NET 6), Python (asyncio), JavaScript (Node.js) |
3131

@@ -66,13 +66,12 @@ Full documentation available at `/manual` after starting the server.
6666
```
6767
EdgeLinkServer.exe [options]
6868
69-
--port <n> HTTP port (default: 8080)
69+
--port <n> HTTP port (default: 8081)
7070
--no-https Disable HTTPS (HTTPS is enabled by default)
7171
--https-port <n> HTTPS port (default: 8443)
72-
--cors <origins> Comma-separated allowed CORS origins
7372
7473
Environment variables:
75-
EDGELINK_PORT, EDGELINK_HTTPS, EDGELINK_HTTPS_PORT, EDGELINK_CORS
74+
EDGELINK_PORT, EDGELINK_HTTPS, EDGELINK_HTTPS_PORT
7675
```
7776

7877
Priority: CLI args > environment variables > defaults

Server.Tests/Unit/AppConfigTests.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ public void Defaults_WhenNoArgs_AreApplied()
1212
{
1313
var cfg = AppConfig.FromArgs([]);
1414

15-
Assert.Equal(8080, cfg.HttpPort);
15+
Assert.Equal(8081, cfg.HttpPort);
1616
Assert.True(cfg.HttpsEnabled); // default is true after our change
1717
Assert.Equal(8443, cfg.HttpsPort);
18-
Assert.Equal("", cfg.AllowedOrigins);
1918
}
2019

2120
// ── CLI args ─────────────────────────────────────────────────────────────
@@ -41,22 +40,14 @@ public void NoHttps_Flag_DisablesHttps()
4140
Assert.False(cfg.HttpsEnabled);
4241
}
4342

44-
[Fact]
45-
public void Cors_ParsedFromCli()
46-
{
47-
var cfg = AppConfig.FromArgs(["--cors", "http://localhost:3000"]);
48-
Assert.Equal("http://localhost:3000", cfg.AllowedOrigins);
49-
}
50-
5143
[Fact]
5244
public void MultipleArgs_AllParsed()
5345
{
54-
var cfg = AppConfig.FromArgs(["--port", "7070", "--https-port", "7443", "--no-https", "--cors", "https://example.com"]);
46+
var cfg = AppConfig.FromArgs(["--port", "7070", "--https-port", "7443", "--no-https"]);
5547

5648
Assert.Equal(7070, cfg.HttpPort);
5749
Assert.Equal(7443, cfg.HttpsPort);
5850
Assert.False(cfg.HttpsEnabled);
59-
Assert.Equal("https://example.com", cfg.AllowedOrigins);
6051
}
6152

6253
// ── Environment variables ────────────────────────────────────────────────
@@ -117,13 +108,13 @@ public void Cli_TakesPriorityOverEnv()
117108
public void InvalidPortArg_UsesDefault()
118109
{
119110
var cfg = AppConfig.FromArgs(["--port", "notanumber"]);
120-
Assert.Equal(8080, cfg.HttpPort);
111+
Assert.Equal(8081, cfg.HttpPort);
121112
}
122113

123114
[Fact]
124115
public void MissingPortValue_UsesDefault()
125116
{
126117
var cfg = AppConfig.FromArgs(["--port"]); // value missing
127-
Assert.Equal(8080, cfg.HttpPort);
118+
Assert.Equal(8081, cfg.HttpPort);
128119
}
129120
}

Server/Infrastructure/AppConfig.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ namespace EdgeLink.Infrastructure;
22

33
public class AppConfig
44
{
5-
public int HttpPort { get; init; } = 8080;
5+
public int HttpPort { get; init; } = 8081;
66
public bool HttpsEnabled { get; init; }
77
public int HttpsPort { get; init; } = 8443;
88
public bool InstallService { get; init; }
99
public bool UninstallService { get; init; }
1010

1111
public static AppConfig FromArgs(string[] args) => new()
1212
{
13-
HttpPort = GetInt(args, "--port") ?? GetEnvInt("EDGELINK_PORT") ?? 8080,
13+
HttpPort = GetInt(args, "--port") ?? GetEnvInt("EDGELINK_PORT") ?? 8081,
1414
HttpsEnabled = !HasFlag(args, "--no-https") && GetEnv("EDGELINK_HTTPS") != "0",
1515
HttpsPort = GetInt(args, "--https-port") ?? GetEnvInt("EDGELINK_HTTPS_PORT") ?? 8443,
1616
InstallService = HasFlag(args, "--install"),

Server/WebUI/manual.html

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -759,10 +759,7 @@ <h3>常用啟動參數</h3>
759759
EdgeLinkServer.exe --no-https
760760

761761
<span class="cmt"># 自訂 port</span>
762-
EdgeLinkServer.exe --port 9090 --https-port 9443
763-
764-
<span class="cmt"># 允許跨來源請求(CORS)</span>
765-
EdgeLinkServer.exe --cors https://myapp.com,http://localhost:3000</code></pre>
762+
EdgeLinkServer.exe --port 9090 --https-port 9443</code></pre>
766763
</div>
767764

768765
<h3>自動建立的目錄結構</h3>
@@ -816,13 +813,8 @@ <h3>修改密碼</h3>
816813
</div>
817814
</div>
818815

819-
<h3>CORS 設定</h3>
820-
<p>若前端頁面與 EdgeLink Server 不同源,需在啟動時指定允許的來源:</p>
821-
<div class="code-block">
822-
<div class="code-header"><div class="dots"><div class="dot dot-r"></div><div class="dot dot-y"></div><div class="dot dot-g"></div></div><span class="lang-tag">CMD</span></div>
823-
<pre><code>EdgeLinkServer.exe --cors https://app.example.com,http://localhost:5173</code></pre>
824-
</div>
825-
<p>或使用環境變數 <code>EDGELINK_CORS</code></p>
816+
<h3>CORS</h3>
817+
<p>EdgeLink Server 預設對所有來源開放(<code>Access-Control-Allow-Origin: *</code>)。若需限制來源,請在反向代理層(如 Nginx)處理。</p>
826818

827819
<!-- ─────────────────────────────────────────── -->
828820
<h2 id="webui"><span class="section-num">04</span>Web 管理介面</h2>
@@ -1278,10 +1270,9 @@ <h2 id="cli"><span class="section-num">12</span>CLI 選項</h2>
12781270
<div class="table-wrap"><table>
12791271
<thead><tr><th>CLI 參數</th><th>環境變數</th><th>說明</th><th>預設值</th></tr></thead>
12801272
<tbody>
1281-
<tr><td><code>--port &lt;n&gt;</code></td><td><code>EDGELINK_PORT</code></td><td>HTTP 監聽 port</td><td><code>8080</code></td></tr>
1273+
<tr><td><code>--port &lt;n&gt;</code></td><td><code>EDGELINK_PORT</code></td><td>HTTP 監聽 port</td><td><code>8081</code></td></tr>
12821274
<tr><td><code>--no-https</code></td><td><code>EDGELINK_HTTPS=0</code></td><td>停用 HTTPS</td><td>啟用</td></tr>
12831275
<tr><td><code>--https-port &lt;n&gt;</code></td><td><code>EDGELINK_HTTPS_PORT</code></td><td>HTTPS 監聽 port</td><td><code>8443</code></td></tr>
1284-
<tr><td><code>--cors &lt;origins&gt;</code></td><td><code>EDGELINK_CORS</code></td><td>允許的 CORS 來源(逗號分隔)</td><td>(不允許跨源)</td></tr>
12851276
</tbody>
12861277
</table></div>
12871278

0 commit comments

Comments
 (0)