feat: min/max settings, multiple shockers per share code, and new API endpoints#4
feat: min/max settings, multiple shockers per share code, and new API endpoints#4
Conversation
…ock.com API endpoints - Add ShareCodeMapping class with MinIntensity, MaxIntensity, MinDuration, MaxDuration fields - Support multiple shocker IDs per share code mapping (List<Guid>) - Update DoWebApiController to use per-mapping limits and send controls to all mapped shockers - Add PsWebApiController handling GetUserDevices, GetShareCodesByOwner, GetShockersByShareIds - Add ps.pishock.com as SAN in server certificate - Add ps.pishock.com to hosts file redirect - Update Blazor UI with multi-select shockers and min/max configuration fields
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 18846bb329
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| var sanBuilder = new SubjectAlternativeNameBuilder(); | ||
| sanBuilder.AddDnsName("do.pishock.com"); | ||
| sanBuilder.AddDnsName("ps.pishock.com"); |
There was a problem hiding this comment.
Regenerate existing server certs for new ps SAN
Adding ps.pishock.com to SAN here only affects newly generated certificates; LoadOrCreateServerCert still returns any existing, unexpired interception-server.pfx, so upgraded users keep a cert that only matches do.pishock.com and TLS validation for https://ps.pishock.com will fail until they manually delete/regenerate the cert.
Useful? React with 👍 / 👎.
| "if ($content -notmatch 'OpenShock Interception') {", | ||
| " Add-Content -Path $hostsPath -Value \"`n$line\" -NoNewline:$false", | ||
| " $toAdd = \"`n\" + ($lines -join \"`n\");", | ||
| " Add-Content -Path $hostsPath -Value $toAdd -NoNewline:$false", |
There was a problem hiding this comment.
Add missing ps hosts entry when marker already exists
The add script appends both host entries only when no OpenShock Interception marker exists, so machines that already have the legacy single do.pishock.com entry (with the same marker) will never receive the new ps.pishock.com redirect and the /PiShock interception path will not be reached until users manually remove/re-add hosts entries.
Useful? React with 👍 / 👎.
| var durationMs = (ushort)Math.Clamp(request.Duration * 1000, mapping.MinDuration * 1000, mapping.MaxDuration * 1000); | ||
| var intensity = (byte)Math.Clamp(request.Intensity, mapping.MinIntensity, mapping.MaxIntensity); |
There was a problem hiding this comment.
Validate min/max mapping bounds before request clamping
These clamps assume Min* <= Max*, but the new mapping form stores each field independently and does not enforce ordering, so a configuration like MinIntensity > MaxIntensity or MinDuration > MaxDuration will make Math.Clamp throw ArgumentException and fail apioperate requests at runtime.
Useful? React with 👍 / 👎.
- Add Operate endpoint to PsWebApiController matching the ps.pishock.com non-legacy operate API (same share code based auth, same control flow) - Add HealthWebApiController with /Health/Check (200) and /Health/Server (204) endpoints to satisfy apps that health-check the PiShock API - Register health controller in InterceptionService
Changes
1. Per-Mapping Min/Max Settings
ShareCodeMappingclass with configurableMinIntensity,MaxIntensity,MinDuration,MaxDurationfieldsDoWebApiController.Operatenow clamps intensity and duration using per-mapping limits instead of hardcoded valuesDoWebApiController.GetShockerInforeturns the per-mapping max intensity/duration2. Multiple Shockers per Share Code
ShareCodeMappingcontainsShockerIds(List<Guid>) instead of a singleShockerIdControl()call3. ps.pishock.com API Support
PsWebApiControllerhandling three newer PiShock API endpoints:GET /PiShock/GetUserDevices- Returns synthetic device/shocker listGET /PiShock/GetShareCodesByOwner- Returns share codes with permissionsGET /PiShock/GetShockersByShareIds- Returns shocker info by share IDsps.pishock.comas a SAN in the server certificateps.pishock.comto the hosts file redirect (both entries use the same marker)/PiShockpath prefixUI Updates
Backward Compatibility
/api/apioperateand/api/GetShockerInfoendpoints continue to work as before