mirror of
https://github.com/bettercap/bettercap
synced 2025-07-06 13:02:12 -07:00
fix: the data field and the return value of the onData callback for the tcp.proxy are now byte arrays instead of strings (fixes #284)
This commit is contained in:
parent
49beed239f
commit
4206fd6a22
1 changed files with 13 additions and 3 deletions
|
@ -59,7 +59,7 @@ func (s *TcpProxyScript) doDefines(from, to net.Addr, data []byte) (err error) {
|
|||
} else if err = s.VM.Set("to", addrTo); err != nil {
|
||||
log.Error("Error while defining to: %s", err)
|
||||
return
|
||||
} else if err = s.VM.Set("data", string(data)); err != nil {
|
||||
} else if err = s.VM.Set("data", data); err != nil {
|
||||
log.Error("Error while defining data: %s", err)
|
||||
return
|
||||
}
|
||||
|
@ -83,9 +83,19 @@ func (s *TcpProxyScript) OnData(from, to net.Addr, data []byte) []byte {
|
|||
return nil
|
||||
}
|
||||
|
||||
if !ret.IsUndefined() && ret.IsString() {
|
||||
return []byte(ret.String())
|
||||
exported, err := ret.Export()
|
||||
if err != nil {
|
||||
log.Error("Error while exporting results: %s", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
array, ok := exported.([]byte)
|
||||
if !ok {
|
||||
log.Error("Error while casting exported value to array of byte: value = %s", exported)
|
||||
return nil
|
||||
}
|
||||
|
||||
return array
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue