Skip to content

Draft: Implement PAN struct as main API entry point#288

Open
rolbk wants to merge 14 commits intonetsec-ethz:masterfrom
rolbk:client-api
Open

Draft: Implement PAN struct as main API entry point#288
rolbk wants to merge 14 commits intonetsec-ethz:masterfrom
rolbk:client-api

Conversation

@rolbk
Copy link
Copy Markdown

@rolbk rolbk commented Jan 8, 2026

This PR implements the first draft of the new API design proposed in #285.

Changes

Main API Changes

  • Merged ASContext and proposed Client into PAN struct: The PAN struct now serves as the main entry point for SCION networking, managing the daemon connection, path pool, and statistics. This struct is meant to be kept around as singleton in the application that uses it.
  • No global state: PAN instances are created with New() and can be properly cleaned up, replacing hidden global state
  • Cleaner method signatures: No need to pass asCtx to every function - shared state is managed by the PAN instance

Open Questions

  • Not sure if it's better to have PAN as a struct or an interface. Current implementation uses a struct.
  • Some config options for Dialing and Listening should still be moved to the PAN struct.
  • Classes are still somewhat interleaved (e.g., pathRefreshSubscriber, Selector, dialedConn). Further work is needed to cleanly separate concerns.

Example Usage

// Create PAN instance
pan, err := pan.New(ctx)
if err != nil {
    // handle error
}

// Use PAN for dialing
conn, err := pan.DialUDP(ctx, local, remote,
    pan.WithPolicy(policy),
    pan.WithSelector(selector),
)

Related to #285 and #286


This change is Reviewable

rolbk added 14 commits December 30, 2025 22:37
Remove support for RAINS name resolution, since it is incompatible with the SCION v0.13.0 API
Mark MangleSCIONAddrURL as deprecated since it relies on URL parsing
behavior that will be fixed in Go 1.24.8 as part of CVE-2025-47912.
Key changes:
- Add ASContext interface, pass to Dial/Listen functions
- Remove global host context singleton, require explicit initialization
- Export PathPool with PathPoolInit() for explicit lifecycle
- Use addr.IA from snet directly instead of local type alias
- Simplify ReplySelector.Path() (remove context parameter)
- Fix Path.String() format, improve PathFingerprint readability
- Add periodic refresh for subscribers without cached paths
- Handle SCMP PacketTooBig errors gracefully
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