summaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'index.js')
-rw-r--r--index.js22
1 files changed, 20 insertions, 2 deletions
diff --git a/index.js b/index.js
index 43f477a..720639a 100644
--- a/index.js
+++ b/index.js
@@ -34,9 +34,22 @@ class IPAddress extends React.Component {
}
}
- render() {
- var pretty = this.state.octets.join('.') + '/' + this.state.cidr
+ getPretty = () => {
+ return this.state.octets.join('.') + '/' + this.state.cidr
+ }
+ getNetmask = () => {
+ if (this.state.cidr == 0) {
+ return '0.0.0.0'
+ }
+ else {
+ return [...Array(4)].map((x, octet) =>
+ ((((0xFFFFFFFF << (32 - this.state.cidr)) >>> 0) >>> (3-octet)*8) & 0xFF)
+ ).join('.')
+ }
+ }
+
+ render() {
return <div className="ip-address">
<div className="address">
{[...Array(4)].map((x, octet) =>
@@ -61,6 +74,11 @@ class IPAddress extends React.Component {
)}
</ol>
</div>
+
+ <div className="details">
+ <span className="netmask">Netmask: {this.getNetmask()}</span>
+ </div>
+
</div>
}
}