mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 13:09:49 -07:00
Merge pull request #895 from cmingxu/master
make import statement clean
This commit is contained in:
commit
754b6b3841
7 changed files with 22 additions and 13 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
|
||||||
"github.com/robertkrimen/otto"
|
"github.com/robertkrimen/otto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -13,6 +14,7 @@ func btoa(call otto.FunctionCall) otto.Value {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ReportError("Could not convert to string: %s", varValue)
|
return ReportError("Could not convert to string: %s", varValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,10 +23,12 @@ func atob(call otto.FunctionCall) otto.Value {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ReportError("Could not decode string: %s", call.Argument(0).String())
|
return ReportError("Could not decode string: %s", call.Argument(0).String())
|
||||||
}
|
}
|
||||||
|
|
||||||
v, err := otto.ToValue(string(varValue))
|
v, err := otto.ToValue(string(varValue))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ReportError("Could not convert to string: %s", varValue)
|
return ReportError("Could not convert to string: %s", varValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
js/fs.go
2
js/fs.go
|
@ -67,4 +67,4 @@ func writeFile(call otto.FunctionCall) otto.Value {
|
||||||
}
|
}
|
||||||
|
|
||||||
return otto.NullValue()
|
return otto.NullValue()
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,13 @@ package js
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/robertkrimen/otto"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/robertkrimen/otto"
|
||||||
)
|
)
|
||||||
|
|
||||||
type httpPackage struct {
|
type httpPackage struct {
|
||||||
|
@ -26,7 +27,10 @@ func (c httpPackage) Encode(s string) string {
|
||||||
return url.QueryEscape(s)
|
return url.QueryEscape(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c httpPackage) Request(method string, uri string, headers map[string]string, form map[string]string, json string) httpResponse {
|
func (c httpPackage) Request(method string, uri string,
|
||||||
|
headers map[string]string,
|
||||||
|
form map[string]string,
|
||||||
|
json string) httpResponse {
|
||||||
var reader io.Reader
|
var reader io.Reader
|
||||||
|
|
||||||
if form != nil {
|
if form != nil {
|
||||||
|
|
|
@ -3,7 +3,6 @@ package js
|
||||||
import (
|
import (
|
||||||
"github.com/evilsocket/islazy/log"
|
"github.com/evilsocket/islazy/log"
|
||||||
"github.com/evilsocket/islazy/plugin"
|
"github.com/evilsocket/islazy/plugin"
|
||||||
|
|
||||||
"github.com/robertkrimen/otto"
|
"github.com/robertkrimen/otto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/evilsocket/islazy/str"
|
"github.com/evilsocket/islazy/str"
|
||||||
|
|
||||||
"github.com/google/gopacket"
|
"github.com/google/gopacket"
|
||||||
"github.com/google/gopacket/layers"
|
"github.com/google/gopacket/layers"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package routing
|
package routing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bettercap/bettercap/core"
|
|
||||||
"github.com/evilsocket/islazy/str"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/bettercap/bettercap/core"
|
||||||
|
"github.com/evilsocket/islazy/str"
|
||||||
)
|
)
|
||||||
|
|
||||||
var parser = regexp.MustCompile(`^([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+).*$`)
|
var parser = regexp.MustCompile(`^([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+).*$`)
|
||||||
|
|
|
@ -2,15 +2,17 @@ package session
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/bettercap/bettercap/caplets"
|
|
||||||
_ "github.com/bettercap/bettercap/js"
|
|
||||||
"github.com/evilsocket/islazy/fs"
|
|
||||||
"github.com/evilsocket/islazy/plugin"
|
|
||||||
"github.com/evilsocket/islazy/str"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/bettercap/bettercap/caplets"
|
||||||
|
_ "github.com/bettercap/bettercap/js"
|
||||||
|
|
||||||
|
"github.com/evilsocket/islazy/fs"
|
||||||
|
"github.com/evilsocket/islazy/plugin"
|
||||||
|
"github.com/evilsocket/islazy/str"
|
||||||
)
|
)
|
||||||
|
|
||||||
// require("telegram.js")
|
// require("telegram.js")
|
||||||
|
@ -37,7 +39,7 @@ func preprocess(basePath string, code string, level int) (string, error) {
|
||||||
filepath.Join(caplets.InstallBase, fileName),
|
filepath.Join(caplets.InstallBase, fileName),
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(fileName, ".js") == false {
|
if !strings.Contains(fileName, ".js") {
|
||||||
searchPaths = append(searchPaths, []string{
|
searchPaths = append(searchPaths, []string{
|
||||||
filepath.Join(basePath, fileName) + ".js",
|
filepath.Join(basePath, fileName) + ".js",
|
||||||
filepath.Join(caplets.InstallBase, fileName) + ".js",
|
filepath.Join(caplets.InstallBase, fileName) + ".js",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue