feat: tlsmiddlebox experiment (#817)
See https://github.com/ooni/probe/issues/2124
This commit is contained in:
parent
b78b9aca51
commit
f2b88ddb4a
24 changed files with 1670 additions and 0 deletions
29
internal/engine/experiment/tlsmiddlebox/syscall_cgo.go
Normal file
29
internal/engine/experiment/tlsmiddlebox/syscall_cgo.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
//go:build cgo && windows
|
||||
|
||||
package tlsmiddlebox
|
||||
|
||||
//
|
||||
// CGO support for SO_ERROR
|
||||
//
|
||||
|
||||
/*
|
||||
#cgo windows LDFLAGS: -lws2_32
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import "unsafe"
|
||||
|
||||
// getErrFromSockOpt returns the errno of the SO_ERROR
|
||||
//
|
||||
// This is the CGO_ENABLED=1 implementation of this function, which
|
||||
// returns the errno obtained from the getsockopt call
|
||||
func getErrFromSockOpt(fd uintptr) int {
|
||||
var cErrno C.int
|
||||
szInt := C.sizeof_int
|
||||
C.getsockopt((C.SOCKET)(fd), (C.int)(C.SOL_SOCKET), (C.int)(C.SO_ERROR), (*C.char)(unsafe.Pointer(&cErrno)), (*C.int)(unsafe.Pointer(&szInt)))
|
||||
return int(cErrno)
|
||||
}
|
||||
Loading…
Reference in a new issue