<commit_before>// +build linux

package udp_test

import (
	"runtime"
	"syscall"
	"testing"

	"github.com/v2ray/v2ray-core/common/alloc"
	v2net "github.com/v2ray/v2ray-core/common/net"
	"github.com/v2ray/v2ray-core/proxy"
	"github.com/v2ray/v2ray-core/testing/assert"
	"github.com/v2ray/v2ray-core/transport/internet"
	. "github.com/v2ray/v2ray-core/transport/internet/udp"
)

func TestHubSocksOption(t *testing.T) {
	assert := assert.On(t)

	hub, err := ListenUDP(v2net.LocalHostIP, v2net.Port(0), ListenOption{
		Callback:            func(*alloc.Buffer, *proxy.SessionInfo) {},
		ReceiveOriginalDest: true,
	})
	assert.Error(err).IsNil()
	conn := hub.Connection()

	sysfd, ok := conn.(internet.SysFd)
	assert.Bool(ok).IsTrue()

	fd, err := sysfd.SysFd()
	assert.Error(err).IsNil()

	v, err := syscall.GetsockoptInt(fd, syscall.SOL_IP, syscall.IP_TRANSPARENT)
	assert.Error(err).IsNil()
	assert.Int(v).Equals(1)

	v, err = syscall.GetsockoptInt(fd, syscall.SOL_IP, syscall.IP_RECVORIGDSTADDR)
	assert.Error(err).IsNil()
	assert.Int(v).Equals(1)
}
<commit_msg>remove unused deps<commit_after>// +build linux

package udp_test

import (
	"syscall"
	"testing"

	"github.com/v2ray/v2ray-core/common/alloc"
	v2net "github.com/v2ray/v2ray-core/common/net"
	"github.com/v2ray/v2ray-core/proxy"
	"github.com/v2ray/v2ray-core/testing/assert"
	"github.com/v2ray/v2ray-core/transport/internet"
	. "github.com/v2ray/v2ray-core/transport/internet/udp"
)

func TestHubSocksOption(t *testing.T) {
	assert := assert.On(t)

	hub, err := ListenUDP(v2net.LocalHostIP, v2net.Port(0), ListenOption{
		Callback:            func(*alloc.Buffer, *proxy.SessionInfo) {},
		ReceiveOriginalDest: true,
	})
	assert.Error(err).IsNil()
	conn := hub.Connection()

	sysfd, ok := conn.(internet.SysFd)
	assert.Bool(ok).IsTrue()

	fd, err := sysfd.SysFd()
	assert.Error(err).IsNil()

	v, err := syscall.GetsockoptInt(fd, syscall.SOL_IP, syscall.IP_TRANSPARENT)
	assert.Error(err).IsNil()
	assert.Int(v).Equals(1)

	v, err = syscall.GetsockoptInt(fd, syscall.SOL_IP, syscall.IP_RECVORIGDSTADDR)
	assert.Error(err).IsNil()
	assert.Int(v).Equals(1)
}

{'fraction_non_alphanumeric': 0.1684011352885525, 'fraction_numerical': 0.017029328287606435, 'mean_word_length': 4.64, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '514089', 'n_tokens_mistral': 929, 'n_tokens_neox': 880, 'n_words': 113}