mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-28 16:09:57 +00:00
TUN-8861: Add session limiter to UDP session manager
## Summary In order to make cloudflared behavior more predictable and prevent an exhaustion of resources, we have decided to add session limits that can be configured by the user. This first commit introduces the session limiter and adds it to the UDP handling path. For now the limiter is set to run only in unlimited mode.
This commit is contained in:
36
vendor/go.uber.org/mock/gomock/string.go
generated
vendored
Normal file
36
vendor/go.uber.org/mock/gomock/string.go
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
package gomock
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
// getString is a safe way to convert a value to a string for printing results
|
||||
// If the value is a a mock, getString avoids calling the mocked String() method,
|
||||
// which avoids potential deadlocks
|
||||
func getString(x any) string {
|
||||
if isGeneratedMock(x) {
|
||||
return fmt.Sprintf("%T", x)
|
||||
}
|
||||
if s, ok := x.(fmt.Stringer); ok {
|
||||
return s.String()
|
||||
}
|
||||
return fmt.Sprintf("%v", x)
|
||||
}
|
||||
|
||||
// isGeneratedMock checks if the given type has a "isgomock" field,
|
||||
// indicating it is a generated mock.
|
||||
func isGeneratedMock(x any) bool {
|
||||
typ := reflect.TypeOf(x)
|
||||
if typ == nil {
|
||||
return false
|
||||
}
|
||||
if typ.Kind() == reflect.Ptr {
|
||||
typ = typ.Elem()
|
||||
}
|
||||
if typ.Kind() != reflect.Struct {
|
||||
return false
|
||||
}
|
||||
_, isgomock := typ.FieldByName("isgomock")
|
||||
return isgomock
|
||||
}
|
Reference in New Issue
Block a user