Skip to content

Conversation

@marinaguzvic
Copy link

@marinaguzvic marinaguzvic commented Jul 20, 2022

Currently the library cannot handle the "all" ip: 0.0.0.0
This resolves that issue

TODO:

  • Fix Bug
  • Test on clj
  • Test on cljs


#?(:clj
(defn- to-ip-byte-array [number]
(let [number (if (instance? BigInteger number) number (biginteger number))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requires a check that the number is >= 0

(defn- to-ip-byte-array [number]
(let [number (if (instance? BigInteger number) number (biginteger number))
bytes (seq (.toByteArray number))
;; If there is a sign byte, remove it

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably always be removed, and we need to explain why we remove it

bytes (if (= (byte 0) (first bytes))
(rest bytes)
bytes)
byte-size (count bytes)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be called byte-count

(rest bytes)
bytes)
byte-size (count bytes)
should-be (if (<= byte-size 4) 4 16)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand the name of this var

(network-mask [this]))

#?(:clj
(defn- to-ip-byte-array [number]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be more descriptive, eg. dec-ip->byte-array

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants