1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-20 06:25:24 +00:00
v2fly/transport/internet/system_listener_test.go

30 lines
592 B
Go
Raw Normal View History

2018-12-03 16:41:24 +00:00
package internet_test
import (
"context"
"net"
"testing"
"github.com/v2fly/v2ray-core/v5/common"
"github.com/v2fly/v2ray-core/v5/transport/internet"
2018-12-03 16:41:24 +00:00
)
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")
}
}