MCP: a set's fake payload is a number, and the topic does not say which payload each number is
b4_get_set and b4_get_config return a set's fake payload as faking.sni_type, a number whose defined values are 0 to 8. Both tools marshal the SetConfig struct as it is (mcp.go#L600-L606, mcp.go#L786-L799, mcp.go#L1123-L1134), and the field is a plain int (types.go#L420). The numbers are the FakePayload* constants in iota order (types.go#L163-L173):
| Value | Constant | Web UI label |
|---|---|---|
| 0 | FakePayloadRandom |
Random |
| 1 | FakePayloadCustom |
none |
| 2 | FakePayloadDefault1 (the default) |
Preset: Google (classic) |
| 3 | FakePayloadDefault2 |
Preset: DuckDuckGo |
| 4 | FakePayloadCapture |
My own Payload File |
| 5 | FakePayloadZero |
All Zeros |
| 6 | FakePayloadInverted |
Inverted Original |
| 7 | FakePayloadDomain |
Generated from Domain |
| 8 | FakePayloadSTUN |
Preset: STUN |
The topic faking.sni_type, which b4_get_topic returns, names the payloads in words only: 'random', 'google'/'duckduckgo', 'file', 'zeros', 'inverted', 'domain' (topics.json#L32). It gives no numbers. A model reading "sni_type": 2 cannot tell Google from DuckDuckGo, and nothing says whether 4 is 'file' or 'zeros'. Two values are missing from the topic entirely:
- 8, STUN. It is Discovery's default payload.
bestPayloadstarts as STUN (discovery.go#L72),selectBestPayloadpicks the fastest payload that worked and falls back to STUN when none did (payloads.go#L216-L247), andapplyBestPayloadwrites it into the set (payloads.go#L286-L287). 22 of the 26SNIType:fields inpreset.goare alsoFakePayloadSTUN(for examplepreset.go#L45). - 1, Custom. b4 sends the bytes of
faking.custom_payloadas they are (payload.go#L126-L127). In b4's own code only the zapret/byedpi command-line import sets it, for an inline fake (emit.go#L753-L755).
The web UI has the same gap for 1. Its payload select lists eight options and none of them is 1 (TcpFaking.tsx#L70-L79). When no option matches, B4Select shows the raw value (B4Select.tsx#L76-L79), so an imported set with an inline fake shows its payload type as a bare 1. The select's AI explain button (B4AiExplain) sends the same topic, with the current value and available: [0, 2, 3, 8, 4, 5, 6, 7], numbers only (TcpFaking.tsx#L322-L325).
Writes
b4_set_config_value takes sets[<set>].faking.sni_type as a number only. The path has no entry in mcpEnums, mcpRanges or mcpValueAliases. The log level is the only aliased setting so far (mcp_write.go#L159-L163). As a result:
b4_list_writable_pathslistssets[].faking.sni_typeasnumberwith no options (mcp_write.go#L863-L872).- A write of
stunis refused withvalue "stun" is not a whole number that fits sets[].faking.sni_type. - A write of
9or-3is saved and reported aschanged: true. Beyond an overflow check, the only check on the number ismcpCheckRange, which has no range for this path (mcp_write.go#L617-L628), andconfig.Validatedoes not look at the field.
An unknown value gets no payload data in LoadCapturePayloads (methods.go#L1376-L1377). GetPayload then falls through to the Google ClientHello (payload.go#L121-L129). So a set written with 9 sends the Google preset, and no tool says so.
Fix notes
- Put one name table in
config, indexed by the constant, for exampleFakePayloadNames. Today the names disagree: the topic says 'file' and 'zeros', Discovery's log names saycaptureandzero(payloads.go#L249-L276), and the import notes saycustom. Discovery's list pluscustomis a natural base:random,custom,google,duckduckgo,capture,zero,inverted,domain,stun.getPayloadNamecan read from the table. - Topic
faking.sni_type: give each payload its stored number and table name, say that 2 is the default, and add 1 (custom: the bytes ofcustom_payload, set by the import) and 8 (STUN, what Discovery writes). The entry is 634 bytes, andtopics_test.gocaps an entry at 2800. This is the fix for reads:b4_get_setandb4_get_configkeep returning the number, and only the topic can say what it means. - Alias: add
mcpSetPathPrefix + ".faking.sni_type"tomcpValueAliases, built from the table, with all nine values includingcustom.mcpApplyAliasrefuses anything outside the list, so a stored 1 can still be written back. The same rule makes out-of-range numbers like 9 fail (mcp_write.go#L180-L192). Write results,b4_revert_last_changeandb4_list_writable_pathsthen report the name throughmcpFormatCurrent(mcp_write.go#L549-L557). - UI: add an option for 1 (
payloadCustominen.jsonandru.json) so an imported set no longer shows a bare1. - Tests:
- In
src/ai,TestFakePayloadTopicNamesEveryValue: for every entry in the name table,faking.sni_typecontains the number and the name. The test fails as long as 1 and 8 are missing. - In
src/http/handler,TestMCPWriteFakePayloadByName, modelled onTestMCPWriteLogLevelByName. Writingstunstores 8 and returnscurrent: "stun". Writing9is refused.b4_list_writable_pathslists the nine names forsets[].faking.sni_type.
- In