nuclei/pkg/js/libs/smb/memo.smb_private.go
Mzack9999 4c7a0f424e
Transparent Memoization via func Annotation (#4742)
* initial implementation with manual code generation

* testing generation

* refactor to package methods + auto memoize

* more memos

* fixing signatures

* refactor

* adding gen util

* adding util

* regenerate memoized files

---------

Co-authored-by: Tarun Koyalwar <tarun@projectdiscovery.io>
2024-03-01 18:40:18 +05:30

30 lines
742 B
Go
Executable File

// Warning - This is generated code
package smb
import (
"errors"
"fmt"
"time"
"github.com/praetorian-inc/fingerprintx/pkg/plugins"
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate"
)
func memoizedcollectSMBv2Metadata(host string, port int, timeout time.Duration) (*plugins.ServiceSMB, error) {
hash := "collectSMBv2Metadata" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + ":" + fmt.Sprint(timeout)
v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) {
return collectSMBv2Metadata(host, port, timeout)
})
if err != nil {
return nil, err
}
if value, ok := v.(*plugins.ServiceSMB); ok {
return value, nil
}
return nil, errors.New("could not convert cached result")
}