From 5da2cd8d29adc99ac73f4ee626e0cfed1ee6ce45 Mon Sep 17 00:00:00 2001 From: buffermet <29265684+buffermet@users.noreply.github.com> Date: Sat, 22 Feb 2025 19:26:44 +0100 Subject: [PATCH] Fix JavaScript backwards compatible number conversion --- modules/dns_proxy/dns_proxy_js_query.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/dns_proxy/dns_proxy_js_query.go b/modules/dns_proxy/dns_proxy_js_query.go index 263ca213..79b55e2a 100644 --- a/modules/dns_proxy/dns_proxy_js_query.go +++ b/modules/dns_proxy/dns_proxy_js_query.go @@ -159,12 +159,25 @@ func jsPropToUint64(obj map[string]interface{}, key string) uint64 { } } break + case "uint64": + if v, ok := prop.(uint64); ok { + return v + } + break } } log.Error("error converting JS property to uint64 where key is: %s", key) return uint64(0) } +func uint16ArrayToInt64Array(arr []uint16, key string) []int64 { + vArr := make([]int64, 0, len(arr)) + for _, item := range arr { + vArr = append(vArr, int64(item)) + } + return vArr +} + func (j *JSQuery) NewHash() string { answers, _ := json.Marshal(j.Answers) extras, _ := json.Marshal(j.Extras)