2020-06-07 07:41:08 +00:00
|
|
|
/* SPDX-License-Identifier: MIT
|
|
|
|
*
|
2021-01-28 16:52:15 +00:00
|
|
|
* Copyright (C) 2017-2021 WireGuard LLC. All Rights Reserved.
|
2020-06-07 07:41:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
package conn
|
|
|
|
|
|
|
|
func (bind *nativeBind) PeekLookAtSocketFd4() (fd int, err error) {
|
|
|
|
sysconn, err := bind.ipv4.SyscallConn()
|
|
|
|
if err != nil {
|
|
|
|
return -1, err
|
|
|
|
}
|
|
|
|
err = sysconn.Control(func(f uintptr) {
|
|
|
|
fd = int(f)
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return -1, err
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (bind *nativeBind) PeekLookAtSocketFd6() (fd int, err error) {
|
|
|
|
sysconn, err := bind.ipv6.SyscallConn()
|
|
|
|
if err != nil {
|
|
|
|
return -1, err
|
|
|
|
}
|
|
|
|
err = sysconn.Control(func(f uintptr) {
|
|
|
|
fd = int(f)
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return -1, err
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|