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
|
|
|
|
|
2021-02-22 01:01:50 +00:00
|
|
|
func (bind *StdNetBind) PeekLookAtSocketFd4() (fd int, err error) {
|
2020-06-07 07:41:08 +00: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 01:01:50 +00:00
|
|
|
func (bind *StdNetBind) PeekLookAtSocketFd6() (fd int, err error) {
|
2020-06-07 07:41:08 +00: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
|
|
|
|
}
|