Skip to content

Remove force_reuse_port from nyat-core #1

@uchouT

Description

@uchouT

Problem

force_reuse_port has two design issues that make it a poor fit for a library crate:

  1. Blocking /proc scan in async context

force_reuse_port() synchronously iterates /proc/net/tcp and /proc/[pid]/fd/* to locate the process and fd occupying the target port. This runs inside the async mapper setup path.

  1. Narrow privilege requirements

pidfd_getfd(2) requires the caller to have the same uid as the target process (or be root). In practice, this limits usage to services running
as root — a narrow scenario that does not justify the complexity in a general-purpose library.

Proposal

Move force_reuse_port out of nyat-core:

  • Make LocalAddr::socket() pub, returning a bound socket to the caller
  • nyat-core only sets SO_REUSEPORT on its own sockets (passive reuse)
  • Active forced reuse becomes the caller's responsibility

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions