Commit a96b0fe3 authored by Sophie Brun's avatar Sophie Brun

Update upstream source from tag 'upstream/2.7'

Update to upstream version '2.7'
with Debian dir 51691f580503bc678e62d52f4d3e97a6173c8f9b
parents 87cfbf64 11037cce
......@@ -2,12 +2,15 @@
[[projects]]
digest = "1:fa526d5f6ec66a1833c687768639251d6db3bc3b7f32abd0265ae9625a9233de"
name = "github.com/adrianmo/go-nmea"
packages = ["."]
pruneopts = "UT"
revision = "22095aa1b48050243d3eb9a001ca80eb91a0c6fa"
[[projects]]
branch = "master"
digest = "1:6cd4d9bc1e78392036da7cc4fb1fbd65c10b5807d74aaee5fa5e025b441ff6d2"
name = "github.com/bettercap/gatt"
packages = [
".",
......@@ -17,36 +20,46 @@
"linux/gioctl",
"linux/socket",
"linux/util",
"xpc"
"xpc",
]
pruneopts = "UT"
revision = "66e7446993acb3de936b3f487e5933522ed16923"
[[projects]]
digest = "1:b95738a1e6ace058b5b8544303c0871fc01d224ef0d672f778f696265d0f2917"
name = "github.com/bettercap/readline"
packages = ["."]
pruneopts = "UT"
revision = "62c6fe6193755f722b8b8788aa7357be55a50ff1"
version = "v1.4"
[[projects]]
branch = "master"
digest = "1:8efd09ca363b01b7dca5baf091d65473df5f08f107b7c3fcd93c605189e031ed"
name = "github.com/chifflier/nfqueue-go"
packages = ["nfqueue"]
pruneopts = "UT"
revision = "61ca646babef3bd4dea1deb610bfb0005c0a1298"
[[projects]]
branch = "master"
digest = "1:6f9339c912bbdda81302633ad7e99a28dfa5a639c864061f1929510a9a64aa74"
name = "github.com/dustin/go-humanize"
packages = ["."]
pruneopts = "UT"
revision = "02af3965c54e8cacf948b97fef38925c4120652c"
[[projects]]
branch = "master"
digest = "1:744c8fceaf0e0384d75e2371debd4eda76b1404768328d03a184f1d08be5a60f"
name = "github.com/elazarl/goproxy"
packages = ["."]
pruneopts = "UT"
revision = "a96fa3a318260eab29abaf32f7128c9eb07fb073"
[[projects]]
branch = "master"
digest = "1:28e398bb752cd0367439a86d3a7cebfa008c9143d154dd5516397a790a2901e1"
name = "github.com/gobwas/glob"
packages = [
".",
......@@ -56,111 +69,143 @@
"syntax/ast",
"syntax/lexer",
"util/runes",
"util/strings"
"util/strings",
]
pruneopts = "UT"
revision = "f00a7392b43971b2fdb562418faab1f18da2067a"
[[projects]]
digest = "1:51bee9f1987dcdb9f9a1b4c20745d78f6bf6f5f14ad4e64ca883eb64df4c0045"
name = "github.com/google/go-github"
packages = ["github"]
pruneopts = "UT"
revision = "e48060a28fac52d0f1cb758bc8b87c07bac4a87d"
version = "v15.0.0"
[[projects]]
branch = "master"
digest = "1:a63cff6b5d8b95638bfe300385d93b2a6d9d687734b863da8e09dc834510a690"
name = "github.com/google/go-querystring"
packages = ["query"]
pruneopts = "UT"
revision = "53e6ce116135b80d037921a7fdd5138cf32d7a8a"
[[projects]]
digest = "1:22cffca7cf16314eb3cb0c5d2298f7b2f60266d8da172cbae258cdfcc169c1ad"
name = "github.com/google/gopacket"
packages = [
".",
"layers",
"pcap",
"pcapgo"
"pcapgo",
]
pruneopts = "UT"
revision = "11c65f1ca9081dfea43b4f9643f5c155583b73ba"
version = "v1.1.14"
[[projects]]
digest = "1:160eabf7a69910fd74f29c692718bc2437c1c1c7d4c9dea9712357752a70e5df"
name = "github.com/gorilla/context"
packages = ["."]
pruneopts = "UT"
revision = "1ea25387ff6f684839d82767c1733ff4d4d15d0a"
version = "v1.1"
[[projects]]
digest = "1:88aa9e326e2bd6045a46e00a922954b3e1a9ac5787109f49ac85366df370e1e5"
name = "github.com/gorilla/mux"
packages = ["."]
pruneopts = "UT"
revision = "53c1911da2b537f792e7cafcb446b05ffe33b996"
version = "v1.6.1"
[[projects]]
digest = "1:43dd08a10854b2056e615d1b1d22ac94559d822e1f8b6fcc92c1a1057e85188e"
name = "github.com/gorilla/websocket"
packages = ["."]
pruneopts = "UT"
revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b"
version = "v1.2.0"
[[projects]]
branch = "master"
digest = "1:6480de9b8abc75bfb06947e139aa07429dfed37f95a258e90865c4c84a9e188b"
name = "github.com/inconshreveable/go-vhost"
packages = ["."]
pruneopts = "UT"
revision = "06d84117953b22058c096b49a429ebd4f3d3d97b"
[[projects]]
branch = "master"
digest = "1:031558139b6ee2fb7c1bb9f14bc9f394c9ab94c1722897292622d20d5039b246"
name = "github.com/jpillora/go-tld"
packages = ["."]
pruneopts = "UT"
revision = "a31ae10e978ab5f352c5dad2cfbd60546dcea75f"
[[projects]]
digest = "1:4701b2acabe16722ecb1e387d39741a29269386bfc4ba6283ecda362d289eff1"
name = "github.com/malfunkt/iprange"
packages = ["."]
pruneopts = "UT"
revision = "3a31f5ed42d2d8a1fc46f1be91fd693bdef2dd52"
version = "v0.9.0"
[[projects]]
digest = "1:c658e84ad3916da105a761660dcaeb01e63416c8ec7bc62256a9b411a05fcd67"
name = "github.com/mattn/go-colorable"
packages = ["."]
pruneopts = "UT"
revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072"
version = "v0.0.9"
[[projects]]
digest = "1:d4d17353dbd05cb52a2a52b7fe1771883b682806f68db442b436294926bbfafb"
name = "github.com/mattn/go-isatty"
packages = ["."]
pruneopts = "UT"
revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39"
version = "v0.0.3"
[[projects]]
branch = "master"
digest = "1:0320f2921b55f500278fec7d7fe4454e401b9074ef1a88597c3359bc66144a6e"
name = "github.com/mdlayher/dhcp6"
packages = [
".",
"dhcp6opts",
"internal/buffer"
"internal/buffer",
]
pruneopts = "UT"
revision = "e26af0688e455a82b14ebdbecf43f87ead3c4624"
[[projects]]
branch = "master"
digest = "1:2b32af4d2a529083275afc192d1067d8126b578c7a9613b26600e4df9c735155"
name = "github.com/mgutz/ansi"
packages = ["."]
pruneopts = "UT"
revision = "9520e82c474b0a04dd04f8a40959027271bab992"
[[projects]]
digest = "1:17bc403348b60bd01bfd2e507fcb23463e76f4b1f433d50b0872b8219df1250d"
name = "github.com/mgutz/logxi"
packages = ["v1"]
pruneopts = "UT"
revision = "aebf8a7d67ab4625e0fd4a665766fef9a709161b"
version = "v1"
[[projects]]
digest = "1:40e195917a951a8bf867cd05de2a46aaf1806c50cf92eebf4c16f78cd196f747"
name = "github.com/pkg/errors"
packages = ["."]
pruneopts = "UT"
revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
version = "v0.8.0"
[[projects]]
branch = "master"
digest = "1:f4877c1ea67bb492d1b91125bb7f45604736bfbd2ffcbfb9eb44055607525fc3"
name = "github.com/robertkrimen/otto"
packages = [
".",
......@@ -169,34 +214,64 @@
"file",
"parser",
"registry",
"token"
"token",
]
pruneopts = "UT"
revision = "03d472dc43abece8691e609a23d295ab732abba6"
[[projects]]
branch = "master"
digest = "1:b9b666a56e920eaa59ffea0d25a9b848d7073be13689c4a29d04e4a0f548a031"
name = "github.com/tarm/serial"
packages = ["."]
pruneopts = "UT"
revision = "eaafced92e9619f03c72527efeab21e326f3bc36"
[[projects]]
branch = "master"
digest = "1:32f55762862902f08c5d28ed59fbe86cd0c38b088473ed072807467ebadc3f15"
name = "golang.org/x/sys"
packages = ["unix"]
pruneopts = "UT"
revision = "d0faeb539838e250bd0a9db4182d48d4a1915181"
[[projects]]
digest = "1:68d74b9fe9594646dc411e68b85b73b70d861b710570a99e0b2803b5844646b5"
name = "gopkg.in/sourcemap.v1"
packages = [
".",
"base64vlq"
"base64vlq",
]
pruneopts = "UT"
revision = "6e83acea0053641eff084973fee085f0c193c61a"
version = "v1.0.5"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "2b0f222c61ea5761232c564da1ab8bd87de5daf61b4ba4ebc89e8f0965a89f95"
input-imports = [
"github.com/adrianmo/go-nmea",
"github.com/bettercap/gatt",
"github.com/bettercap/readline",
"github.com/chifflier/nfqueue-go/nfqueue",
"github.com/dustin/go-humanize",
"github.com/elazarl/goproxy",
"github.com/gobwas/glob",
"github.com/google/go-github/github",
"github.com/google/gopacket",
"github.com/google/gopacket/layers",
"github.com/google/gopacket/pcap",
"github.com/google/gopacket/pcapgo",
"github.com/gorilla/mux",
"github.com/gorilla/websocket",
"github.com/inconshreveable/go-vhost",
"github.com/jpillora/go-tld",
"github.com/malfunkt/iprange",
"github.com/mattn/go-isatty",
"github.com/mdlayher/dhcp6",
"github.com/mdlayher/dhcp6/dhcp6opts",
"github.com/robertkrimen/otto",
"github.com/tarm/serial",
]
solver-name = "gps-cdcl"
solver-version = 1
......@@ -19,6 +19,10 @@ clean:
@rm -rf $(TARGET)*
@rm -rf build
install:
@mkdir -p /usr/share/bettercap/caplets
@cp bettercap /usr/local/bin/
docker:
@docker build -t bettercap:latest .
......
......@@ -2,7 +2,7 @@ package core
const (
Name = "bettercap"
Version = "2.6"
Version = "2.7"
Author = "Simone 'evilsocket' Margaritelli"
Website = "https://bettercap.org/"
)
......@@ -49,13 +49,13 @@ func LoadProxyScriptSource(path, source string, sess *session.Session) (err erro
// define session pointer
err = s.VM.Set("env", sess.Env.Data)
if err != nil {
log.Error( "Error while defining environment: %s", "\nTraceback:\n " + err.(*otto.Error).String() )
log.Error("Error while defining environment: %s", "\nTraceback:\n "+err.(*otto.Error).String())
return
}
err = s.defineBuiltins()
if err != nil {
log.Error( "Error while defining builtin functions: %s", "\nTraceback:\n " + err.(*otto.Error).String() )
log.Error("Error while defining builtin functions: %s", "\nTraceback:\n "+err.(*otto.Error).String())
return
}
......@@ -63,7 +63,7 @@ func LoadProxyScriptSource(path, source string, sess *session.Session) (err erro
if s.hasCallback("onLoad") {
_, err = s.VM.Run("onLoad()")
if err != nil {
log.Error( "Error while executing onLoad callback: %s", "\nTraceback:\n " + err.(*otto.Error).String() )
log.Error("Error while executing onLoad callback: %s", "\nTraceback:\n "+err.(*otto.Error).String())
return
}
}
......
......@@ -97,7 +97,7 @@ func (p *HTTPProxy) doProxy(req *http.Request) bool {
}
for _, blacklisted := range blacklist {
if strings.HasPrefix(req.Host, blacklisted) {
if strings.Split(req.Host, ":")[0] == blacklisted {
log.Error("Got request with blacklisted host: %s", req.Host)
return false
}
......
......@@ -7,13 +7,9 @@ import (
"net/http"
"net/url"
"strings"
"regexp"
)
type JSHeader struct {
Name string
Value string
}
type JSRequest struct {
Client string
Method string
......@@ -23,7 +19,7 @@ type JSRequest struct {
Query string
Hostname string
ContentType string
Headers []JSHeader
Headers string
Body string
req *http.Request
......@@ -31,15 +27,17 @@ type JSRequest struct {
bodyRead bool
}
var header_regexp = regexp.MustCompile(`(.*?): (.*)`)
func NewJSRequest(req *http.Request) *JSRequest {
headers := make([]JSHeader, 0)
headers := ""
cType := ""
for name, values := range req.Header {
for _, value := range values {
headers = append(headers, JSHeader{name, value})
headers += name + ": " + value + "\r\n"
if name == "Content-Type" {
if strings.ToLower(name) == "content-type" {
cType = value
}
}
......@@ -65,10 +63,7 @@ func NewJSRequest(req *http.Request) *JSRequest {
}
func (j *JSRequest) NewHash() string {
hash := fmt.Sprintf("%s.%s.%s.%s.%s.%s.%s.%s", j.Client, j.Method, j.Version, j.Scheme, j.Hostname, j.Path, j.Query, j.ContentType)
for _, h := range j.Headers {
hash += fmt.Sprintf(".%s-%s", h.Name, h.Value)
}
hash := fmt.Sprintf("%s.%s.%s.%s.%s.%s.%s.%s.%s", j.Client, j.Method, j.Version, j.Scheme, j.Hostname, j.Path, j.Query, j.ContentType, j.Headers)
hash += "." + j.Body
return hash
}
......@@ -87,31 +82,44 @@ func (j *JSRequest) WasModified() bool {
}
func (j *JSRequest) GetHeader(name, deflt string) string {
name = strings.ToLower(name)
for _, h := range j.Headers {
if name == strings.ToLower(h.Name) {
return h.Value
headers := strings.Split(j.Headers, "\r\n")
for i := 0; i < len(headers); i++ {
header_name := header_regexp.ReplaceAllString(headers[i], "$1")
header_value := header_regexp.ReplaceAllString(headers[i], "$2")
if strings.ToLower(name) == strings.ToLower(header_name) {
return header_value
}
}
return deflt
}
func (j *JSRequest) SetHeader(name, value string) {
name = strings.ToLower(name)
for i, h := range j.Headers {
if name == strings.ToLower(h.Name) {
j.Headers[i].Value = value
headers := strings.Split(j.Headers, "\r\n")
for i := 0; i < len(headers); i++ {
header_name := header_regexp.ReplaceAllString(headers[i], "$1")
header_value := header_regexp.ReplaceAllString(headers[i], "$2")
if strings.ToLower(name) == strings.ToLower(header_name) {
old_header := header_name + ": " + header_value + "\r\n"
new_header := header_name + ": " + value + "\r\n"
j.Headers = strings.Replace(j.Headers, old_header, new_header, 1)
return
}
}
j.Headers = append(j.Headers, JSHeader{name, value})
j.Headers += name + ": " + value + "\r\n"
}
func (j *JSRequest) RemoveHeader(name string) {
name = strings.ToLower(name)
for i, h := range j.Headers {
if name == strings.ToLower(h.Name) {
j.Headers = append(j.Headers[:i], j.Headers[i+1:]...)
headers := strings.Split(j.Headers, "\r\n")
for i := 0; i < len(headers); i++ {
header_name := header_regexp.ReplaceAllString(headers[i], "$1")
header_value := header_regexp.ReplaceAllString(headers[i], "$2")
if strings.ToLower(name) == strings.ToLower(header_name) {
removed_header := header_name + ": " + header_value + "\r\n"
j.Headers = strings.Replace(j.Headers, removed_header, "", 1)
return
}
}
}
......@@ -162,10 +170,17 @@ func (j *JSRequest) ToRequest() (req *http.Request) {
}
hadType := false
for _, h := range j.Headers {
req.Header.Set(h.Name, h.Value)
if h.Name == "Content-Type" {
hadType = true
headers := strings.Split(j.Headers, "\r\n")
for i := 0; i < len(headers); i++ {
if headers[i] != "" {
header_name := header_regexp.ReplaceAllString(headers[i], "$1")
header_value := header_regexp.ReplaceAllString(headers[i], "$2")
req.Header.Set(header_name, header_value)
if strings.ToLower(header_name) == "content-type" {
hadType = true
}
}
}
......
......@@ -13,26 +13,27 @@ import (
type JSResponse struct {
Status int
ContentType string
Headers []JSHeader
Headers string
Body string
refHash string
resp *http.Response
bodyRead bool
refHash string
resp *http.Response
bodyRead bool
bodyClear bool
}
func NewJSResponse(res *http.Response) *JSResponse {
cType := ""
headers := make([]JSHeader, 0)
headers := ""
code := 200
if res != nil {
code = res.StatusCode
for name, values := range res.Header {
for _, value := range values {
headers = append(headers, JSHeader{name, value})
headers += name + ": " + value + "\r\n"
if name == "Content-Type" {
if strings.ToLower(name) == "content-type" {
cType = value
}
}
......@@ -45,6 +46,7 @@ func NewJSResponse(res *http.Response) *JSResponse {
Headers: headers,
resp: res,
bodyRead: false,
bodyClear: false,
}
resp.UpdateHash()
......@@ -52,11 +54,7 @@ func NewJSResponse(res *http.Response) *JSResponse {
}
func (j *JSResponse) NewHash() string {
hash := fmt.Sprintf("%d.%s", j.Status, j.ContentType)
for _, h := range j.Headers {
hash += fmt.Sprintf(".%s-%s", h.Name, h.Value)
}
return hash
return fmt.Sprintf("%d.%s.%s", j.Status, j.ContentType, j.Headers)
}
func (j *JSResponse) UpdateHash() {
......@@ -67,6 +65,9 @@ func (j *JSResponse) WasModified() bool {
if j.bodyRead {
// body was read
return true
} else if j.bodyClear {
// body was cleared manually
return true
} else if j.Body != "" {
// body was not read but just set
return true
......@@ -76,42 +77,66 @@ func (j *JSResponse) WasModified() bool {
}
func (j *JSResponse) GetHeader(name, deflt string) string {
name = strings.ToLower(name)
for _, h := range j.Headers {
if name == strings.ToLower(h.Name) {
return h.Value
headers := strings.Split(j.Headers, "\r\n")
for i := 0; i < len(headers); i++ {
header_name := header_regexp.ReplaceAllString(headers[i], "$1")
header_value := header_regexp.ReplaceAllString(headers[i], "$2")
if strings.ToLower(name) == strings.ToLower(header_name) {
return header_value
}
}
return deflt
}
func (j *JSResponse) SetHeader(name, value string) {
name = strings.ToLower(name)
for i, h := range j.Headers {
if name == strings.ToLower(h.Name) {
j.Headers[i].Value = value
headers := strings.Split(j.Headers, "\r\n")
for i := 0; i < len(headers); i++ {
header_name := header_regexp.ReplaceAllString(headers[i], "$1")
header_value := header_regexp.ReplaceAllString(headers[i], "$2")
if strings.ToLower(name) == strings.ToLower(header_name) {
old_header := header_name + ": " + header_value + "\r\n"
new_header := header_name + ": " + value + "\r\n"
j.Headers = strings.Replace(j.Headers, old_header, new_header, 1)
return
}
}
j.Headers = append(j.Headers, JSHeader{name, value})
j.Headers += name + ": " + value + "\r\n"
}
func (j *JSResponse) RemoveHeader(name string) {
name = strings.ToLower(name)
for i, h := range j.Headers {
if name == strings.ToLower(h.Name) {
j.Headers = append(j.Headers[:i], j.Headers[i+1:]...)
headers := strings.Split(j.Headers, "\r\n")
for i := 0; i < len(headers); i++ {
header_name := header_regexp.ReplaceAllString(headers[i], "$1")
header_value := header_regexp.ReplaceAllString(headers[i], "$2")
if strings.ToLower(name) == strings.ToLower(header_name) {
removed_header := header_name + ": " + header_value + "\r\n"
j.Headers = strings.Replace(j.Headers, removed_header, "", 1)
return
}
}
}
func (j *JSResponse) ClearBody() {
j.Body = ""
j.bodyClear = true
}
func (j *JSResponse) ToResponse(req *http.Request) (resp *http.Response) {
resp = goproxy.NewResponse(req, j.ContentType, j.Status, j.Body)
if len(j.Headers) > 0 {
for _, h := range j.Headers {
resp.Header.Add(h.Name, h.Value)
headers := strings.Split(j.Headers, "\r\n")
for i := 0; i < len(headers); i++ {
if headers[i] != "" {
header_name := header_regexp.ReplaceAllString(headers[i], "$1")
header_value := header_regexp.ReplaceAllString(headers[i], "$2")
resp.Header.Add(header_name, header_value)
}
}
return
}
......@@ -125,6 +150,7 @@ func (j *JSResponse) ReadBody() string {
j.Body = string(raw)
j.bodyRead = true
j.bodyClear = false
// reset the response body to the original unread state
j.resp.Body = ioutil.NopCloser(bytes.NewBuffer(raw))
......
......@@ -33,7 +33,7 @@ func LoadHttpProxyScriptSource(path, source string, sess *session.Session) (err
if s.hasCallback("onRequest") {
s.onRequestScript, err = s.VM.Compile("", "onRequest(req, res)")
if err != nil {
log.Error( "Error while compiling onRequest callback: %s", "\nTraceback:\n " + err.(*otto.Error).String() )
log.Error("Error while compiling onRequest callback: %s", "\nTraceback:\n "+err.(*otto.Error).String())
return
}
}
......@@ -41,7 +41,7 @@ func LoadHttpProxyScriptSource(path, source string, sess *session.Session) (err
if s.hasCallback("onResponse") {
s.onResponseScript, err = s.VM.Compile("", "onResponse(req, res)")
if err != nil {
log.Error( "Error while compiling onResponse callback: %s", "\nTraceback:\n " + err.(*otto.Error).String() )
log.Error("Error while compiling onResponse callback: %s", "\nTraceback:\n "+err.(*otto.Error).String())
return
}
}
......@@ -49,7 +49,7 @@ func LoadHttpProxyScriptSource(path, source string, sess *session.Session) (err
if s.hasCallback("onCommand") {
s.onCommandScript, err = s.VM.Compile("", "onCommand(cmd)")
if err != nil {
log.Error( "Error while compiling onCommand callback: %s", "\nTraceback:\n " + err.(*otto.Error).String() )
log.Error("Error while compiling onCommand callback: %s", "\nTraceback:\n "+err.(*otto.Error).String())
return
}
}
......@@ -71,13 +71,13 @@ func LoadHttpProxyScript(path string, sess *session.Session) (err error, s *Http
func (s *HttpProxyScript) doRequestDefines(req *http.Request) (err error, jsreq *JSRequest, jsres *JSResponse) {
jsreq = NewJSRequest(req)
if err = s.VM.Set("req", jsreq); err != nil {
log.Error( "Error while defining request: %s", "\nTraceback:\n " + err.(*otto.Error).String() )
log.Error("Error while defining request: %s", "\nTraceback:\n "+err.(*otto.Error).String())
return
}
jsres = NewJSResponse(nil)
if err = s.VM.Set("res", jsres); err != nil {
log.Error( "Error while defining response: %s", "\nTraceback:\n " + err.(*otto.Error).String() )
log.Error("Error while defining response: %s", "\nTraceback:\n "+err.(*otto.Error).String())
return
}
return
......@@ -86,13 +86,13 @@ func (s *HttpProxyScript) doRequestDefines(req *http.Request) (err error, jsreq
func (s *HttpProxyScript) doResponseDefines(res *http.Response) (err error, jsreq *JSRequest, jsres *JSResponse) {
jsreq = NewJSRequest(res.Request)
if err = s.VM.Set("req", jsreq); err != nil {
log.Error( "Error while defining request: %s", "\nTraceback:\n " + err.(*otto.Error).String() )
log.Error("Error while defining request: %s", "\nTraceback:\n "+err.(*otto.Error).String())
return
}
jsres = NewJSResponse(res)
if err = s.VM.Set("res", jsres); err != nil {
log.Error( "Error while defining response: %s", "\nTraceback:\n " + err.(*otto.Error).String() )
log.Error("Error while defining response: %s", "\nTraceback:\n "+err.(*otto.Error).String())
return
}
......@@ -101,7 +101,7 @@ func (s *HttpProxyScript) doResponseDefines(res *http.Response) (err error, jsre
func (s *HttpProxyScript) doCommandDefines(cmd string) (err error) {
if err = s.VM.Set("cmd", cmd); err != nil {
log.Error( "Error while defining cmd: %s", "\nTraceback:\n " + err.(*otto.Error).String() )
log.Error("Error while defining cmd: %s", "\nTraceback:\n "+err.(*otto.Error).String())
}
return
}
......@@ -114,12 +114,12 @@ func (s *HttpProxyScript) OnRequest(original *http.Request) (jsreq *JSRequest, j
defer s.Unlock()
if err, jsreq, jsres = s.doRequestDefines(original); err != nil {
log.Error( "Error while running bootstrap definitions: %s", "\nTraceback:\n " + err.(*otto.Error).String() )
log.Error("Error while running bootstrap definitions: %s", "\nTraceback:\n "+err.(*otto.Error).String())
return nil, nil
}
if _, err = s.VM.Run(s.onRequestScript); err != nil {
log.Error( "Error while executing onRequest callback: %s", "\nTraceback:\n " + err.(*otto.Error).String() )
log.Error("Error while executing onRequest callback: %s", "\nTraceback:\n "+err.(*otto.Error).String())
return nil, nil
}