Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/pkg/js/libs/oracle/oracledialer.go
2858 views
1
package oracle
2
3
import (
4
"context"
5
"fmt"
6
"net"
7
"time"
8
9
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate"
10
)
11
12
// oracleCustomDialer implements the dialer interface expected by go-ora
13
type oracleCustomDialer struct {
14
executionId string
15
}
16
17
func (o *oracleCustomDialer) dialWithCtx(ctx context.Context, network, address string) (net.Conn, error) {
18
dialers := protocolstate.GetDialersWithId(o.executionId)
19
if dialers == nil {
20
return nil, fmt.Errorf("dialers not initialized for %s", o.executionId)
21
}
22
if !protocolstate.IsHostAllowed(o.executionId, address) {
23
// host is not valid according to network policy
24
return nil, protocolstate.ErrHostDenied.Msgf(address)
25
}
26
return dialers.Fastdialer.Dial(ctx, network, address)
27
}
28
29
func (o *oracleCustomDialer) Dial(network, address string) (net.Conn, error) {
30
return o.dialWithCtx(context.TODO(), network, address)
31
}
32
33
func (o *oracleCustomDialer) DialTimeout(network, address string, timeout time.Duration) (net.Conn, error) {
34
ctx, cancel := context.WithTimeout(context.Background(), timeout)
35
defer cancel()
36
37
return o.dialWithCtx(ctx, network, address)
38
}
39
40
func (o *oracleCustomDialer) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
41
return o.dialWithCtx(ctx, network, address)
42
}
43
44