Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: const for ip zero or loopback address #73

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

luohoufu
Copy link
Contributor

What does this PR do

This pull request includes changes to centralize and standardize the use of network address constants across the codebase. The most important changes include the introduction of new constants for reserved and local addresses, and the replacement of hardcoded address strings with these constants.

Centralization and standardization of network address constants:

  • core/util/netutils.go: Introduced new constants ReservedAddress, LocalIpv6Address, and LocalAddress to represent common network addresses.
  • core/util/netutils.go: Replaced hardcoded address strings with the newly defined constants in various functions, such as GetSafetyInternalAddress, GetValidAddress, GetLocalIPs, and ClientIP. [1] [2] [3] [4]

Refactoring to use new address constants:

  • core/api/api.go: Updated the StartAPI function to use the ReservedAddress constant instead of the hardcoded "0.0.0.0" string.
  • core/host/process_info.go: Imported the util package and replaced hardcoded address strings with the new constants in the getPortByPidWindows function. [1] [2]

Rationale for this change

Standards checklist

  • The PR title is descriptive
  • The commit messages are semantic
  • Necessary tests are added
  • Updated the release notes
  • Necessary documents have been added if this is a new feature
  • Performance tests checked, no obvious performance degradation

@luohoufu luohoufu requested review from medcl and silenceqi January 23, 2025 06:37
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.

3 participants