[PR #121] [CLOSED] fix(cps): implement <c> tag & tests - closes #120 #149

Closed
opened 2026-10-13 21:04:03 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amneziawg-go/pull/121
Author: @Vadim-Khristenko
Created: 3/2/2026
Status: ❌ Closed

Base: master ← Head: feature-implement-packet-counter-tag-for-cps


📝 Commits (1)

  • 15cca22 feat(cps): implement packet counter tag for CPS

📊 Changes

6 files changed (+350 additions, -25 deletions)

View changed files

➕ device/csp_test.go (+264 -0)
📝 device/obf.go (+28 -14)
➕ device/obf_counter.go (+36 -0)
📝 device/peer.go (+9 -8)
📝 device/pools_test.go (+1 -1)
📝 device/send.go (+12 -2)

📄 Description

Summary

  • Implemented support for the <c> CPS tag: a 4‑byte big‑endian packet counter injected into custom signature packets. ( #120 )

What I changed

  • Implemented counter obfuscator: obf_counter.go
  • Parser: added newObfChainWithCounter and counter handling in obf.go
  • Sending path: increment & pass counter getter in send.go
  • Peer state: added cpsPacketCounter in peer.go
  • Tests: added global CPS tests in csp_test.go covering <b>, <r>, <rc>, <rd>, <t>, <c>, mixed chains and error cases
  • Fixed an existing test bug in pools_test.go (use max.Load() in error message)

Why this approach

  • <c> requires a runtime packet counter value, so the obfuscator needs a getter at construction time. To keep changes minimal and compatible with the existing obfBuilders map, I added a small special‑case path (newObfChainWithCounter) rather than changing the builders’ API. This keeps the rest of the code unchanged and localizes the counter logic.
  • Deobfuscate for the counter does not perform validation, consistent with other dynamic tags (random bytes/char/digits); if stronger validation is desired we can add it later.

Tests & verification

  • Added comprehensive CPS tests in csp_test.go. CPS tests pass locally.
  • Fixed pools_test.go so go vet / test runs no longer fail due to the previously incorrect usage.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/amnezia-vpn/amneziawg-go/pull/121 **Author:** [@Vadim-Khristenko](https://github.com/Vadim-Khristenko) **Created:** 3/2/2026 **Status:** ❌ Closed **Base:** `master` ← **Head:** `feature-implement-packet-counter-tag-for-cps` --- ### 📝 Commits (1) - [`15cca22`](https://github.com/amnezia-vpn/amneziawg-go/commit/15cca2272a364dd4d8e01694adc45e567a923fe5) feat(cps): implement packet counter tag for CPS ### 📊 Changes **6 files changed** (+350 additions, -25 deletions) <details> <summary>View changed files</summary> ➕ `device/csp_test.go` (+264 -0) 📝 `device/obf.go` (+28 -14) ➕ `device/obf_counter.go` (+36 -0) 📝 `device/peer.go` (+9 -8) 📝 `device/pools_test.go` (+1 -1) 📝 `device/send.go` (+12 -2) </details> ### 📄 Description ## Summary - Implemented support for the `<c>` CPS tag: a 4‑byte big‑endian packet counter injected into custom signature packets. ( #120 ) ## What I changed - Implemented counter obfuscator: obf_counter.go - Parser: added `newObfChainWithCounter` and counter handling in obf.go - Sending path: increment & pass counter getter in send.go - Peer state: added `cpsPacketCounter` in peer.go - Tests: added global CPS tests in csp_test.go covering `<b>`, `<r>`, `<rc>`, `<rd>`, `<t>`, `<c>`, mixed chains and error cases - Fixed an existing test bug in pools_test.go (use `max.Load()` in error message) ## Why this approach - `<c>` requires a runtime packet counter value, so the obfuscator needs a getter at construction time. To keep changes minimal and compatible with the existing `obfBuilders` map, I added a small special‑case path (`newObfChainWithCounter`) rather than changing the builders’ API. This keeps the rest of the code unchanged and localizes the counter logic. - `Deobfuscate` for the counter does not perform validation, consistent with other dynamic tags (random bytes/char/digits); if stronger validation is desired we can add it later. ## Tests & verification - Added comprehensive CPS tests in csp_test.go. CPS tests pass locally. - Fixed pools_test.go so `go vet` / test runs no longer fail due to the previously incorrect usage. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-13 21:04:03 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amneziawg-go#149
No description provided.