nuclei/pkg/js/libs/rdp/memo.rdp.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

42 lines
1.0 KiB
Go
Executable File

// Warning - This is generated code
package rdp
import (
"errors"
"fmt"
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate"
)
func memoizedisRDP(host string, port int) (IsRDPResponse, error) {
hash := "isRDP" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port)
v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) {
return isRDP(host, port)
})
if err != nil {
return IsRDPResponse{}, err
}
if value, ok := v.(IsRDPResponse); ok {
return value, nil
}
return IsRDPResponse{}, errors.New("could not convert cached result")
}
func memoizedcheckRDPAuth(host string, port int) (CheckRDPAuthResponse, error) {
hash := "checkRDPAuth" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port)
v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) {
return checkRDPAuth(host, port)
})
if err != nil {
return CheckRDPAuthResponse{}, err
}
if value, ok := v.(CheckRDPAuthResponse); ok {
return value, nil
}
return CheckRDPAuthResponse{}, errors.New("could not convert cached result")
}