Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/pkg/js/libs/postgres/memo.postgres.go
2070 views
1
// Warning - This is generated code
2
package postgres
3
4
import (
5
"errors"
6
"fmt"
7
8
_ "github.com/projectdiscovery/nuclei/v3/pkg/js/utils/pgwrap"
9
10
utils "github.com/projectdiscovery/nuclei/v3/pkg/js/utils"
11
12
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate"
13
)
14
15
func memoizedisPostgres(executionId string, host string, port int) (bool, error) {
16
hash := "isPostgres" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port)
17
18
v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) {
19
return isPostgres(executionId, host, port)
20
})
21
if err != nil {
22
return false, err
23
}
24
if value, ok := v.(bool); ok {
25
return value, nil
26
}
27
28
return false, errors.New("could not convert cached result")
29
}
30
31
func memoizedexecuteQuery(executionId string, host string, port int, username string, password string, dbName string, query string) (*utils.SQLResult, error) {
32
hash := "executeQuery" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + ":" + fmt.Sprint(username) + ":" + fmt.Sprint(password) + ":" + fmt.Sprint(dbName) + ":" + fmt.Sprint(query)
33
34
v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) {
35
return executeQuery(executionId, host, port, username, password, dbName, query)
36
})
37
if err != nil {
38
return nil, err
39
}
40
if value, ok := v.(*utils.SQLResult); ok {
41
return value, nil
42
}
43
44
return nil, errors.New("could not convert cached result")
45
}
46
47
func memoizedconnect(executionId string, host string, port int, username string, password string, dbName string) (bool, error) {
48
hash := "connect" + ":" + fmt.Sprint(host) + ":" + fmt.Sprint(port) + ":" + fmt.Sprint(username) + ":" + fmt.Sprint(password) + ":" + fmt.Sprint(dbName)
49
50
v, err, _ := protocolstate.Memoizer.Do(hash, func() (interface{}, error) {
51
return connect(executionId, host, port, username, password, dbName)
52
})
53
if err != nil {
54
return false, err
55
}
56
if value, ok := v.(bool); ok {
57
return value, nil
58
}
59
60
return false, errors.New("could not convert cached result")
61
}
62
63