mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-08-21 12:16:26 +00:00
30 lines
582 B
Go
30 lines
582 B
Go
package internet_test
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
"testing"
|
|
|
|
"github.com/xtls/xray-core/common"
|
|
"github.com/xtls/xray-core/transport/internet"
|
|
)
|
|
|
|
func TestRegisterListenerController(t *testing.T) {
|
|
var gotFd uintptr
|
|
|
|
common.Must(internet.RegisterListenerController(func(network string, addr string, fd uintptr) error {
|
|
gotFd = fd
|
|
return nil
|
|
}))
|
|
|
|
conn, err := internet.ListenSystemPacket(context.Background(), &net.UDPAddr{
|
|
IP: net.IPv4zero,
|
|
}, nil)
|
|
common.Must(err)
|
|
common.Must(conn.Close())
|
|
|
|
if gotFd == 0 {
|
|
t.Error("expected none-zero fd, but actually 0")
|
|
}
|
|
}
|