2020-06-07 09:41:08 +02:00
|
|
|
/* SPDX-License-Identifier: MIT
|
|
|
|
*
|
2022-09-20 17:21:32 +02:00
|
|
|
* Copyright (C) 2017-2023 WireGuard LLC. All Rights Reserved.
|
2020-06-07 09:41:08 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
package conn
|
|
|
|
|
2021-02-22 02:01:50 +01:00
|
|
|
func (bind *StdNetBind) PeekLookAtSocketFd4() (fd int, err error) {
|
2020-06-07 09:41:08 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2021-02-22 02:01:50 +01:00
|
|
|
func (bind *StdNetBind) PeekLookAtSocketFd6() (fd int, err error) {
|
2020-06-07 09:41:08 +02:00
|
|
|
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
|
|
|
|
}
|