mirror of
https://github.com/bettercap/bettercap
synced 2025-07-05 20:42:09 -07:00
Fix backwards compatible uint64 conversion
This commit is contained in:
parent
086eed49d5
commit
876449e105
1 changed files with 5 additions and 2 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"math"
|
||||
"math/big"
|
||||
|
||||
"github.com/bettercap/bettercap/v2/log"
|
||||
"github.com/bettercap/bettercap/v2/session"
|
||||
|
@ -138,9 +139,11 @@ func jsPropToUint32(obj map[string]interface{}, key string) uint32 {
|
|||
}
|
||||
|
||||
func jsPropToUint64(obj map[string]interface{}, key string) uint64 {
|
||||
if v, ok := obj[key].(int64); ok {
|
||||
if f, ok := obj[key].(float64); ok {
|
||||
bigInt := new(big.Float).SetFloat64(f)
|
||||
v, _ := bigInt.Uint64()
|
||||
if v >= 0 {
|
||||
return uint64(v)
|
||||
return v
|
||||
}
|
||||
}
|
||||
log.Error("error converting JS property to uint64 where key is: %s", key)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue