Skip to content

Support --asn for ISP proxies - #213

Open
ulziibay-kernel wants to merge 2 commits into
mainfrom
ulzii/isp-asn-targeting
Open

Support --asn for ISP proxies#213
ulziibay-kernel wants to merge 2 commits into
mainfrom
ulzii/isp-asn-targeting

Conversation

@ulziibay-kernel

@ulziibay-kernel ulziibay-kernel commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Problem

kernel proxy create --type isp --name ulzii-asn --asn AS6079 returned a proxy on AS11426, not AS6079, and said nothing about it.

--asn is registered on the create command for every type, but was only wired into the request for residential and mobile. The isp branch built a config containing country and nothing else, so the flag never left the machine. The types that genuinely can't honour it were no better: datacenter and custom ignored it entirely, and mobile printed a warning and continued.

Change

  • --asn now flows into the ISP config.
  • datacenter, custom, and mobile fail with a clear error rather than dropping the flag. Mobile previously warned and continued for --zip/--asn; the API rejects both, so the CLI now matches instead of building a request the server will refuse.
  • Flag help and README updated, including an ISP example.

Server-side support is kernel/kernel#3059, which validates the ASN against the pool and returns the available ASNs when it isn't there.

On the extra field

ProxyNewParamsConfigIsp in the pinned SDK (v0.85.0) has no Asn field yet — Stainless only regenerates once the spec change in kernel/kernel#3059 merges. Rather than block this PR on that release, the ASN is sent via SetExtraFields, which produces an identical request body:

{"type":"isp","name":"RCN ISP","config":{"country":"US","asn":"AS6079"}}

This is marked with a comment to swap for config.Asn on the next SDK bump. The tests assert on the serialized request rather than the struct field, so they keep verifying the wire format unchanged once asn becomes generated.

Ordering note: this is safe to merge before or after #3059. Until the API side ships, --asn on an ISP proxy is simply ignored by the server, which is today's behaviour.

Test plan

  • go build ./... and go vet ./... clean against the unpatched SDK v0.85.0
  • go test ./... — full suite passes
  • Wire format verified directly against the real SDK: config.asn is present and does not displace country
  • New tests: ISP sends the ASN; ASN coexists with --country; ISP omits it when not requested (so an empty string is never sent, which the API would reject as malformed); datacenter/mobile/custom reject --asn without issuing a request; mobile rejects --zip
  • Follow-up after the SDK bump: replace SetExtraFields with config.Asn

Note

Low Risk
CLI-only proxy create validation and request shaping; no auth or infrastructure changes, with tests locking the wire format.

Overview
kernel proxies create --asn now reaches the API for ISP proxies instead of being dropped on the floor. The value is sent on the ISP config via SetExtraFields until the Go SDK gains a typed Asn field.

Unsupported proxy types no longer silently ignore the flag. Datacenter, custom, and mobile return a clear error if --asn is set; mobile also errors on --zip instead of warning and continuing with a request the API would reject.

README and --asn flag help are updated (ISP/residential scope, pool constraints), with an ISP create example. New tests cover ISP wire format, omission when unset, and rejection paths for unsupported types.

Reviewed by Cursor Bugbot for commit ac173c5. Bugbot is set up for automated code reviews on this repo. Configure here.

--asn was registered on every proxy type but only wired into residential and
mobile, so passing it with --type isp silently dropped it and returned a proxy
on an arbitrary network.

Wires --asn into the ISP config, and makes the types that cannot honour it
(datacenter, custom, mobile) fail with a clear error instead of ignoring it.
Mobile previously warned and continued for --zip/--asn, which the API rejects
anyway, so both are now errors.

Requires the SDK bump that adds Asn to ProxyNewParamsConfigIsp.

Co-authored-by: Cursor <cursoragent@cursor.com>
@kernel-internal

Copy link
Copy Markdown
Contributor

🔧 CI Fix Available

I've pushed a fix for the CI failure.

What failed: make test failed at go vet ./... with a compile error:

cmd/proxies/create.go:69:11: config.Asn undefined (type kernel.ProxyNewParamsConfigIsp has no field or method Asn)

Why: the commit notes this "requires the SDK bump that adds Asn to ProxyNewParamsConfigIsp", but that bump isn't available yet — v0.85.0 (the version pinned in go.mod) is the latest published kernel-go-sdk, and its ProxyNewParamsConfigIsp still only has Country.

Fix: send asn through the SDK's extra-fields escape hatch instead of the typed field, matching how cmd/browsers.go already handles params the SDK doesn't model yet:

if in.ASN != "" {
    config.SetExtraFields(map[string]any{"asn": in.ASN})
}

The two ISP tests now assert on ExtraFields() rather than Asn. The serialized request body is unchanged — {"type":"isp","name":"...","config":{"country":"US","asn":"AS6079"}} with --asn, and asn omitted without it — so this can be swapped back to the typed field once the SDK exposes it. The rest of the PR (rejecting --asn for datacenter/mobile/custom, --zip for mobile, flag help, README) is untouched.

make test passes locally: go vet is clean and all packages pass, including the 4 new ASN tests.

👉 Click here to create a PR with the fix

The generated ProxyNewParamsConfigIsp has no Asn field, so the previous commit
did not build against the pinned SDK. Send asn via SetExtraFields, which
produces the same request body, so the flag works against the deployed API
without waiting on a Stainless release.

Tests now assert on the serialized request rather than the struct field, so
they keep verifying the wire format once asn becomes a generated field.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ulziibay-kernel
ulziibay-kernel marked this pull request as ready for review July 30, 2026 15:46
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