Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: refactor TestServer_X11 to use inproc networking#18564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
spikecurtis wants to merge1 commit intospike/testutil-in-proc-net
base:spike/testutil-in-proc-net
Choose a base branch
Loading
fromspike/18263-x11-network

Conversation

spikecurtis
Copy link
Contributor

@spikecurtisspikecurtis commentedJun 25, 2025
edited
Loading

relates to#18263

Refactors the x11Forwarder to accept a networkinginterface that we can fake out for testing. This isolates the unit tests from other processes listening in the port range used by X11 forwarding. This will become extremely important in up-stack PRs where we listen on every port in the range and need to control which ports have conflicts.

@spikecurtisGraphite App
Copy link
ContributorAuthor

spikecurtis commentedJun 25, 2025
edited
Loading

// It is intended mainly for testing; production code uses the default
// implementation backed by the operating system networking stack.
type X11Network interface {
Listen(network, address string) (net.Listener, error)
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: It'd be nice to keep this as aListen(ctx, ...) as previously via ListenConfig.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I decided against this because I wanted to reuseInProcNet, which needs to matchthis interface in Serpent. Code reuse beat out the presumably slight benefit of being able to bail out of a Listen call before the OS responds.

if originPort == 0 {
p := X11StartPort + session.display
if p > math.MaxUint32 {
panic("overflow")
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should panic here as that risks killing the whole agent in the unlikely event that we don't have aTCPConn. Logging and closing the connection seems more appropriate especially considering the comment above "or non-TCP connections" suggesting it's not only for tests.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

On closer inspection,0 is a perfectly acceptable value from the perspective of the protocol, and will only occur in testing. No need to panic.

@spikecurtisspikecurtisforce-pushed thespike/18263-x11-network branch from212e2a5 toa272b09CompareJune 26, 2025 10:41
@spikecurtisspikecurtisforce-pushed thespike/testutil-in-proc-net branch fromb39371f to319c17dCompareJune 26, 2025 10:41
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@mafredrimafredriAwaiting requested review from mafredri

Assignees

@spikecurtisspikecurtis

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@spikecurtis@mafredri

[8]ページ先頭

©2009-2025 Movatter.jp