Skip to content

feat: min/max settings, multiple shockers per share code, and new API endpoints#4

Open
LucHeart wants to merge 2 commits intomasterfrom
feat/todo-improvements
Open

feat: min/max settings, multiple shockers per share code, and new API endpoints#4
LucHeart wants to merge 2 commits intomasterfrom
feat/todo-improvements

Conversation

@LucHeart
Copy link
Member

Changes

1. Per-Mapping Min/Max Settings

  • Added ShareCodeMapping class with configurable MinIntensity, MaxIntensity, MinDuration, MaxDuration fields
  • DoWebApiController.Operate now clamps intensity and duration using per-mapping limits instead of hardcoded values
  • DoWebApiController.GetShockerInfo returns the per-mapping max intensity/duration

2. Multiple Shockers per Share Code

  • ShareCodeMapping contains ShockerIds (List<Guid>) instead of a single ShockerId
  • A single PiShock command now triggers all mapped shockers simultaneously via one Control() call
  • UI updated with multi-select shocker picker per mapping

3. ps.pishock.com API Support

  • Added PsWebApiController handling three newer PiShock API endpoints:
    • GET /PiShock/GetUserDevices - Returns synthetic device/shocker list
    • GET /PiShock/GetShareCodesByOwner - Returns share codes with permissions
    • GET /PiShock/GetShockersByShareIds - Returns shocker info by share IDs
  • Added ps.pishock.com as a SAN in the server certificate
  • Added ps.pishock.com to the hosts file redirect (both entries use the same marker)
  • Registered new controller at /PiShock path prefix

UI Updates

  • Mapping form now supports selecting multiple shockers
  • Added min/max intensity and duration fields to the add/edit form
  • Added edit button on existing mappings
  • Table shows intensity range and duration range per mapping

Backward Compatibility

  • Legacy /api/apioperate and /api/GetShockerInfo endpoints continue to work as before
  • Existing config will need migration (Dictionary<string, Guid> → Dictionary<string, ShareCodeMapping>)

…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
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines 58 to +60
"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",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +85 to +86
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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant