MCPcopy Create free account
hub / github.com/SenseUnit/dumbproxy / AddConvertAddr

Function AddConvertAddr

jsext/addrutil.go:26–43  ·  view source on GitHub ↗
(vm *goja.Runtime)

Source from the content-addressed store, hash-verified

24}
25
26func AddConvertAddr(vm *goja.Runtime) error {
27 return vm.GlobalObject().Set("convert_addr", func(call goja.FunctionCall) goja.Value {
28 if len(call.Arguments) < 1 {
29 return goja.NaN()
30 }
31 addr, err := netip.ParseAddr(call.Argument(0).String())
32 if err != nil {
33 return goja.NaN()
34 }
35 if addr.Is4() {
36 return vm.ToValue(ipv4ToUint32(addr))
37 } else {
38 bi := new(big.Int)
39 bi.SetBytes(addr.AsSlice())
40 return vm.ToValue(bi)
41 }
42 })
43}
44
45var probingAddresses = []string{
46 "8.8.8.8",

Callers

nothing calls this directly

Calls 3

ipv4ToUint32Function · 0.85
SetMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected