Commit Graph
1085 Commits
Author SHA1 Message Date
d00f 1194823cd5 system: drop the defensive checks around the System page fields
The hostname and model fields were populated through element-existence
checks and empty-string fallbacks that the other fields on the page do
without. Assign them the same way.

Suggested-by: vDorst
2026-08-04 05:43:05 +02:00
d00f 94716ceb5d system: derive the default hostname from the MAC address
Every switch came up as "RTLPlayground", so several of them on one
network were indistinguishable until someone configured a name. Append
the last three MAC octets (e.g. RTLPlayground-1ef924) - unique in
practice, still recognisable, and any "hostname ..." line in the startup
config overrides it as before.

Suggested-by: plaes
2026-08-04 05:43:05 +02:00
d00f 13120127df cmd: make "hostname" report the name and reject stray arguments
Typing "hostname" on its own cleared the name: with no argument the copy
loop never ran and the terminating NUL landed at index 0. Report the
current name instead, accept exactly one argument to set it, and reject
anything longer - a name with spaces tokenizes into several words, and
silently keeping only the first one is worse than an error. Walk the
buffer with a pointer, which the compiler codes better than indexing.

Suggested-by: vDorst
2026-08-04 05:43:05 +02:00
ZYT 46037cd54d Add FG-4GT-2SX_V2.0 2026-08-02 06:46:52 +08:00
d00f e6cd362a1e system: show the hardware model on the System page
machine.machine_name is already reported in /information.json as hw_ver;
surface it read-only on the System Settings page so the exact build
target is visible in the UI, without adding a redundant JSON field.
2026-07-25 13:21:13 +02:00
d00f f21b3a32bd system: configurable hostname (device identity)
Add a device hostname settable from the CLI (`hostname <text>`) and the
System Settings page. The value is sanitized on ingest to JSON-safe
printable ASCII (<=23 chars), stored in a shared __xdata buffer, seeded
to "RTLPlayground" at boot, persisted through the startup-config, and
reported in /information.json. It lives in the common header so other
modules can advertise it (LLDP uses it as the System Name TLV).
2026-07-25 13:07:09 +02:00
logicog 35941dd19f Merge pull request #291 from DrDoof/fix/webui-login-cookies
httpd: fix browser login (cookie parsed by name, Connection: close, self-contained login page)
2026-07-25 11:09:19 +02:00
d00f 0f257d38df httpd: shorten comments per review
Keep only the non-obvious bits; the rationale for each change already
lives in the respective commit messages.
2026-07-25 10:39:32 +02:00
logicog 912e68d6eb Merge pull request #295 from sempr/main
Fix rate range for SDS_10GR return value
2026-07-25 08:21:53 +02:00
Sempr c473646389 Fix rate range for SDS_10GR return value
Broaden range of SFP+ rates mapped to SDS_10GR
A commonly used SFP+ form-factor 10GBASE-LR (Hisense LTF1303-BH+) reports 0x62(	BR Nominal: 9800MBd) at
power on and then switches to 0x64 after booting up.

0x62 -> 9.8gbps
0x63 -> 9.9gbps
0x64 -> 10gbps
0x6f -> 11.1gbps
0x70 -> 11.2gbps

These are outside of the previous 0x63-0x6f range which prevented the link from ever being brought up. So I changed the range to 0x62-0x6f
2026-07-24 16:02:20 +08:00
logicog 51cf40d040 Merge pull request #290 from eraiza0816/feat/dockerfile
add: docker use prerequisites
2026-07-24 07:58:12 +02:00
d00f 3fd9cdfa7e httpd: parse the session cookie by name, not fixed offset
Root cause of the "browser login always bounces back with Wrong password!
while curl works": scan_header() read the session id from a fixed offset
into the Cookie header (p + 17), assuming "session=" is the first and only
cookie. Browsers keep stale cookies for a long time - e.g. an "admin" cookie
left over from this switch's VENDOR firmware - so the header can arrive as
"Cookie: admin=..; session=..", the fixed offset then points into the admin
value, authentication silently fails and every page bounces to login although
the password had been accepted. curl sends only "session=", which is why
command-line tests passed while a real browser (with that stale cookie) failed.

- scan_header(): scan the Cookie header for the actual "session=" key
  (matched as "session" - is_word() requires a separator after the pattern
  and '=' is on its list, the first value byte is not).
- is_word_x(): accept ';' as a terminating separator so the session value
  also matches when it is not the last cookie in the header.

Verified on hardware end-to-end in a real browser WITH the stale "admin"
cookie present: login -> index.html, all pages and JSON endpoints work.
2026-07-21 06:48:18 +02:00
d00f 3189820ba0 httpd: send Connection: close (single-connection uIP mitigation)
Real root cause of the "web login fails from a browser but works from curl":
the uIP httpd is built with UIP_CONF_MAX_CONNECTIONS = 1 and uses global
response state (outbuf/slen/session), i.e. it serves exactly one TCP connection
at a time and closes it after each response - but never advertises that via
the Connection header. A browser's HTTP/1.1 client therefore assumes the
connection may be persistent and can park it in its keep-alive pool for reuse;
a later request sent on that pooled connection hits one the server has already
closed, and a POST (unlike a GET) is never retried by the browser, so it can
be silently lost this way.

This adds "Connection: close" to every response so the browser does not pool
and reuse a connection the server is about to drop. On its own this did not
fully explain the reported login failures - the actual authentication bug is
fixed in the next commit (the Cookie header parsed at a fixed offset) - but it
is correct behaviour for a server that only ever handles one connection, and
removes one source of dropped requests.
2026-07-21 06:47:44 +02:00
d00f ed74ec1e97 httpd/login: complete CSP + password autocomplete hint
Two hygiene fixes for the web UI, prompted by a login that appeared to fail
under privacy shields (Brave Shields / NoScript-family extensions):

- httpd: replace the partial "style-src 'self' 'unsafe-inline'" CSP with a
  complete, first-party policy (default-src 'self'; script-src 'self'
  'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:;
  connect-src 'self'; form-action 'self'). Everything the UI needs is
  same-origin; the explicit policy stops shields injecting their own
  restrictive report-only probes (the noisy script-src-elem 'none' console
  spam) and passes a strict-CSP audit. Verified: no CSP violations in-browser.
- login.html: add autocomplete="current-password" so password managers
  recognise the field (they showed "unknown password" without it).

NOTE: these do NOT bypass a browser's LAN-device protection (NoScript "lan" /
Brave Shields), which strips the POST body of requests to a LAN address and is
why the login can fail in-browser while the same credentials work over curl.
That is a deliberate browser security feature; the user must allow the site in
their shields to log in. The backend password (default 1234) is unchanged and
correct.
2026-07-21 06:47:10 +02:00
Your Name dd95a05487 add: docker use prerequisites 2026-07-19 19:49:30 +09:00
logicog 481c02c740 Merge pull request #289 from eraiza0816/fix/httpd-sim-const-warning
fix: httpd-sim-const-warning
2026-07-19 09:49:08 +02:00
Your Name 0a31a65477 fix: httpd_sim 2026-07-19 16:44:21 +09:00
Lynn-Becky 2d176b7ccc add SWTG024AS-A-V2.0.1 with 5 RJ45 port (#282)
* add MACHINE_SWTG024AS_A_2_0_1_5_RJ45

* fix(machine): update SFP port LED color descriptions for PCB-SWTG024AS V2.0

* add(doc): create a simple documentation for SWTG024AS-A-V2.0.1_5_RJ45

* refactor(machine): update machine definition
2026-07-18 06:20:47 +02:00
logicog a1fac63710 Merge pull request #286 from eraiza0816/feature/language-settings
add language selection to system settings
2026-07-18 06:18:33 +02:00
logicog 5c7f82e2fe Merge pull request #285 from eraiza0816/feat/dockerfile
feat: add Dockerfile for development environment
2026-07-18 05:58:10 +02:00
Your Name e765d17c2b feat: add language selection to system settings
Add a language selector to the System Settings page supporting English,
Japanese, and Chinese. The i18n dictionary already contained zh
translations but lacked the UI to switch languages.

Changes:
- html/i18n.js: add sys_language key to en/ja/zh
- html/system.html: add language selector dropdown
- html/system.js: add changeLang() and selector initialization
- tools/httpd_sim.c: fix cookie parsing for multi-cookie headers;
  fix Set-Cookie response (missing Path=/, missing \r\n\r\n);
  add SO_REUSEADDR for faster port reuse
2026-07-15 01:35:10 +09:00
Your Name 8fb9afb955 feat: add Dockerfile for development environment
- Debian 13 (trixie) based with sdcc 4.5.0 from apt
- Includes gcc, make, xxd, python3, libjson-c-dev, golang-go
- Add .dockerignore to exclude build artifacts
- Add Docker usage section to README (collapsible)
2026-07-14 02:10:55 +09:00
logicog e96780fadb Merge pull request #280 from tofurky/ddm_broken_module
Add SFP quirk for devices that misreport DDM capability
2026-07-13 09:57:35 +02:00
Matt Merhar 2221f0fa32 Add SFP quirk for devices that misreport DDM capability
On a QSFPTEK QT-SFP+-T (RTL8261C) 10GBase-T module, the diag type field
(92) comes back as 0x00, but there's actually some statistics available
like temperature. Other metrics may be hard-coded values.

Add a basic struct that allows matching on vendor and/or model, using a
bitfield to allow multiple quirks for a given SFP module. Only
SFP_QUIRK_DDM is implemented.

For modules matching SFP_QUIRK_DDM, attempt an I2C read of the MSB of
module voltage during probe if DDM is "unsupported" - if it's not 0xff,
override the reported options so we can pull the diagnostic data.

To allow simpler comparisons, convert the ASCII fields (vendor,
model, serial) from space-padded to standard NULL-terminated strings.

strcmp() is moved from httpd.c to rtlplayground.c alongside other string
functions and shared between them.

The __reentrant keyword is used for the new functions to avoid using up
additional OSEG space. This allocates the variables on the stack, which
is OK for this particular code path.

The JSON assembly in send_status() is slightly modified to treat the
sfp_module_* data as standard NULL-terminated strings, and a repeated
subtraction was moved into a uint8_t to declutter the code.
2026-07-13 01:31:29 -04:00
logicog f86b8f32de Merge pull request #283 from Lynn-Becky/translate/chinese
Translate to Chinese
2026-07-13 07:15:52 +02:00
logicog 9389db9e9b Merge pull request #284 from eraiza0816/feature-translate
fix: rename local variable to avoid shadowing global translation
2026-07-13 07:15:29 +02:00
Your Name 519c3a8df3 fix: rename local variable to avoid shadowing global translation function 2026-07-10 13:09:41 +09:00
Lynn-Becky 64422367d5 feat(translate):translate to Chinese 2026-07-08 20:40:00 +08:00
logicog dc2b03e331 Merge pull request #279 from eraiza0816/translate-japanese
Support i18n & translate japanese
2026-07-07 19:28:19 +02:00
Your Name fcf1b3c310 Fix: Remove the language-specific display logic. 2026-07-05 02:31:37 +09:00
Your Name 1dd6156a1f add: how to support i18n 2026-07-05 01:09:50 +09:00
Your Name e75a4c2a95 support i18n & translate japanese 2026-07-05 00:51:27 +09:00
René van Dorst 05d8c36afe Merge pull request #278 from eraiza0816/update-docs-SWTG024AS
update document: SKS3200M-4GPY2XF flash size
2026-07-04 12:47:04 +00:00
René van Dorst b6c9eaf00f Merge pull request #275 from riker77/mokerlink-2G040210GSM
Add Mokerlink 2G040210GSM (2M-PCB43-V1.1)
2026-07-04 12:45:47 +00:00
Your Name ecf5f47960 update SKS3200M-4GPY2XF flash size 2026-07-04 15:52:25 +09:00
Ron ebf6ed7526 Update 2M-PCB43-V1.1.md
Add hint to use KP_9000_6XHML_X2 as a compatible machine definition.
2026-06-29 20:30:07 +02:00
riker77 96f2c860fc Add Mokerlink 2G040210GSM (2M-PCB43-V1.1) 2026-06-29 17:57:09 +02:00
feelfree69 b80d46955c Merge pull request #274 from Lynn-Becky/feat/PCB-SWTG024AS-V2.0
fix(machine): move SWTG024AS-specific SDS0 setup to machine.c
2026-06-28 21:32:53 +02:00
Lynn-Becky 0a18c64dcc fix(machine): move SWTG024AS-specific SDS0 setup to machine.c 2026-06-28 22:47:33 +08:00
René van Dorst b53c56e7f6 Merge pull request #273 from Lynn-Becky/feat/PCB-SWTG024AS-V2.0
fix(machine): SWTG024AS V2.0 fix 5th RJ45 port
2026-06-27 19:50:05 +00:00
Lynn-Becky 17d41b53b7 update doc 2026-06-28 00:56:50 +08:00
Lynn-Becky bd98cb0312 fix(machine): SWTG024AS V2.0 fix 5th RJ45 port 2026-06-28 00:48:05 +08:00
René van Dorst 5566d71522 Merge pull request #272 from Lynn-Becky/feat/PCB-SWTG024AS-V2.0
fix(SWTG024AS-V2.0): correct SFP port GPIO assignments
2026-06-27 13:33:29 +00:00
Lynn-Becky 5e1396cc42 fix(machine): correct SFP port GPIO assignments 2026-06-27 21:16:47 +08:00
René van Dorst 7fe0678c92 Merge pull request #271 from th0m4sek/main
Add reset button gpio to SWTG018AS-A V2.0
2026-06-25 18:33:18 +00:00
th0m4sek 7ec25a39a2 Add brands information for SWTG018AS-A V2.0
Added brands section with details for Ampcom and Horaco.
2026-06-25 20:23:54 +02:00
th0m4sek 98e3cde2f5 Update reset_pin on SWTG018AS-A V2.0 2026-06-25 20:16:56 +02:00
René van Dorst d90c02f951 Merge pull request #268 from th0m4sek/main
Table with supported devices
2026-06-23 17:40:51 +00:00
th0m4sek bbb92c86db Fix formatting issue in supported_devices.md 2026-06-23 09:16:05 +02:00
René van Dorst 1635236a05 Merge pull request #266 from hlyi/pr-tool
Tools for detecting GPIO mapping and extracting LED configure
2026-06-23 06:28:38 +00:00