Skip to content

Feature implementation from commits 29e37e8..2d3126b#5

Open
codeOwlAI wants to merge 15 commits intofeature-base-branch-5from
feature-head-branch-5
Open

Feature implementation from commits 29e37e8..2d3126b#5
codeOwlAI wants to merge 15 commits intofeature-base-branch-5from
feature-head-branch-5

Conversation

@codeOwlAI
Copy link
Owner

@codeOwlAI codeOwlAI commented Jun 30, 2025

PR Summary

Core Version Update and Network Configuration Enhancements

Overview

This PR updates the core version value, enhances configuration error handling, and improves network interface binding functionality across different platforms.

Change Types

Type Description
Enhancement Improved error reporting with more context
Enhancement Better handling of socket binding for network interfaces
Refactor Modified JSON marshaling for ports and improved Close() method implementation

Affected Modules

Module / File Change Description
core.go Changed Version_z byte value from 6 to 31
conf/common.go Enhanced MarshalJSON implementation for ports with better type handling
conf/xray.go Improved error messages and added protocol information for debugging
wireguard/gvisortun/tun.go Modified Close() method to use sync.Once for safe execution
internet/sockopt_darwin.go Removed functionality binding sockets to specific network interfaces
internet/sockopt_windows.go Added socket configuration for multicast interfaces

Notes for Reviewers

  • Please review the socket binding changes carefully as there are conflicting changes in the Darwin implementation
  • Verify that the Version_z change from 6 to 31 doesn't cause compatibility issues

dependabot bot and others added 15 commits March 29, 2025 13:42
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.37.0 to 0.38.0.
- [Commits](golang/net@v0.37.0...v0.38.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Completes XTLS#1677

---------

Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.64 to 1.1.65.
- [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release)
- [Commits](miekg/dns@v1.1.64...v1.1.65)

---
updated-dependencies:
- dependency-name: github.com/miekg/dns
  dependency-version: 1.1.65
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.71.0 to 1.71.1.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.71.0...v1.71.1)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.31.0 to 0.32.0.
- [Commits](golang/sys@v0.31.0...v0.32.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-version: 0.32.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.12.0 to 0.13.0.
- [Commits](golang/sync@v0.12.0...v0.13.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sync
  dependency-version: 0.13.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.36.0 to 0.37.0.
- [Commits](golang/crypto@v0.36.0...v0.37.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.37.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…shalJSON (XTLS#4585)

* conf: implement MarshalJSON for FakeDNSConfig

* conf: Rewrite MarshalJSON for PortList
decouple PortRange from PortList.

* conf: implement MarshalJSON for HostAddress

* conf: Add MarshalJSON comments and use pointers.
func (v PortList) MarshalJSON() ([]byte, error) {
return json.Marshal(v.String())
// MarshalJSON implements encoding/json.Marshaler.MarshalJSON
func (v *PortList) MarshalJSON() ([]byte, error) {
Copy link

Choose a reason for hiding this comment

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

🐛 Correctness Issue

Breaking API Change: Receiver Type Changed.

Changed from value receiver to pointer receiver which breaks backward compatibility for any code calling MarshalJSON on non-pointer values.

Current Code (Diff):

- func (v *PortList) MarshalJSON() ([]byte, error) {
+ func (v PortList) MarshalJSON() ([]byte, error) {
📝 Committable suggestion

‼️ IMPORTANT
Trust, but verify! 🕵️ Please review this suggestion with the care of a code archaeologist - check that it perfectly replaces the highlighted code, preserves all lines, maintains proper indentation, and won't break anything in production. Your future self will thank you! 🚀

Suggested change
func (v *PortList) MarshalJSON() ([]byte, error) {
func (v PortList) MarshalJSON() ([]byte, error) {

Comment on lines +226 to +231
port, err := strconv.Atoi(portStr)
if err == nil {
return json.Marshal(port)
} else {
return json.Marshal(portStr)
}
Copy link

Choose a reason for hiding this comment

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

🐛 Correctness Issue

Inconsistent JSON Type Serialization.

The new implementation creates inconsistent JSON types where single ports become numbers while ranges become strings, which can break clients expecting consistent types.

Current Code (Diff):

- 	port, err := strconv.Atoi(portStr)
- 	if err == nil {
- 		return json.Marshal(port)
- 	} else {
- 		return json.Marshal(portStr)
- 	}
+ 	return json.Marshal(portStr)
📝 Committable suggestion

‼️ IMPORTANT
Trust, but verify! 🕵️ Please review this suggestion with the care of a code archaeologist - check that it perfectly replaces the highlighted code, preserves all lines, maintains proper indentation, and won't break anything in production. Your future self will thank you! 🚀

Suggested change
port, err := strconv.Atoi(portStr)
if err == nil {
return json.Marshal(port)
} else {
return json.Marshal(portStr)
}
return json.Marshal(portStr)

tun.stack.RemoveNIC(1)

if tun.events != nil {
close(tun.events)
Copy link

Choose a reason for hiding this comment

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

🐛 Correctness Issue

Potential panic on nil channel close.

Removing the nil check before closing channels can cause a panic if Close() is called before the channels are initialized.

Current Code (Diff):

- 		close(tun.events)
+ 		if tun.events != nil {
+ 			close(tun.events)
+ 		}
📝 Committable suggestion

‼️ IMPORTANT
Trust, but verify! 🕵️ Please review this suggestion with the care of a code archaeologist - check that it perfectly replaces the highlighted code, preserves all lines, maintains proper indentation, and won't break anything in production. Your future self will thank you! 🚀

Suggested change
close(tun.events)
if tun.events != nil {
close(tun.events)
}

tun.ep.Close()

if tun.incomingPacket != nil {
close(tun.incomingPacket)
Copy link

Choose a reason for hiding this comment

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

🐛 Correctness Issue

Potential panic on nil channel close.

Removing the nil check before closing incomingPacket channel can cause a panic if Close() is called before the channel is initialized.

Current Code (Diff):

- 		close(tun.incomingPacket)
+ 		if tun.incomingPacket != nil {
+ 			close(tun.incomingPacket)
+ 		}
📝 Committable suggestion

‼️ IMPORTANT
Trust, but verify! 🕵️ Please review this suggestion with the care of a code archaeologist - check that it perfectly replaces the highlighted code, preserves all lines, maintains proper indentation, and won't break anything in production. Your future self will thank you! 🚀

Suggested change
close(tun.incomingPacket)
if tun.incomingPacket != nil {
close(tun.incomingPacket)
}

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.

7 participants