-
Notifications
You must be signed in to change notification settings - Fork 0
Byte array handling for clj #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
src/clojure/network/ip.cljc
Outdated
|
|
||
| #?(:clj | ||
| (defn- to-ip-byte-array [number] | ||
| (let [number (if (instance? BigInteger number) number (biginteger number)) |
There was a problem hiding this comment.
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
src/clojure/network/ip.cljc
Outdated
| (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 |
There was a problem hiding this comment.
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
src/clojure/network/ip.cljc
Outdated
| bytes (if (= (byte 0) (first bytes)) | ||
| (rest bytes) | ||
| bytes) | ||
| byte-size (count bytes) |
There was a problem hiding this comment.
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
src/clojure/network/ip.cljc
Outdated
| (rest bytes) | ||
| bytes) | ||
| byte-size (count bytes) | ||
| should-be (if (<= byte-size 4) 4 16) |
There was a problem hiding this comment.
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
src/clojure/network/ip.cljc
Outdated
| (network-mask [this])) | ||
|
|
||
| #?(:clj | ||
| (defn- to-ip-byte-array [number] |
There was a problem hiding this comment.
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
Currently the library cannot handle the "all" ip:
0.0.0.0This resolves that issue
TODO: