File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,30 @@ func (e *Engine) VMRetrieveFileFromURL(call otto.FunctionCall) otto.Value {
6161 return vmResponse
6262}
6363
64+ func (e * Engine ) VMPostJSON (call otto.FunctionCall ) otto.Value {
65+ readURL , err := call .ArgumentList [0 ].ToString ()
66+ if err != nil {
67+ e .Logger .WithField ("trace" , "true" ).Errorf ("Parameter parsing error: %s" , err .Error ())
68+ return otto .FalseValue ()
69+ }
70+ readJSONString , err := call .ArgumentList [1 ].ToString ()
71+ if err != nil {
72+ e .Logger .WithField ("trace" , "true" ).Errorf ("Parameter parsing error: %s" , err .Error ())
73+ return otto .FalseValue ()
74+ }
75+ _ , bytes , err := PostJSON (readURL , []byte (readJSONString ))
76+ if err != nil {
77+ e .Logger .WithField ("trace" , "true" ).Errorf ("HTTP Error: %s" , err .Error ())
78+ return otto .FalseValue ()
79+ }
80+ vmResponse , err := e .VM .ToValue (bytes )
81+ if err != nil {
82+ e .Logger .WithField ("trace" , "true" ).Errorf ("Return value casting error: %s" , err .Error ())
83+ return otto .FalseValue ()
84+ }
85+ return vmResponse
86+ }
87+
6488func (e * Engine ) VMDNSQuery (call otto.FunctionCall ) otto.Value {
6589 targetDomain := call .Argument (0 )
6690 queryType := call .Argument (1 )
You can’t perform that action at this time.
0 commit comments