forked from thelounge/thelounge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request thelounge#749 from thelounge/xpaw/hexip
Add support for hexip ilines and fix storing client ip in config
- Loading branch information
Showing
5 changed files
with
85 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"use strict"; | ||
|
||
const expect = require("chai").expect; | ||
const Helper = require("../../src/helper"); | ||
|
||
describe("HexIP", function() { | ||
it("should correctly convert IPv4 to hex", function() { | ||
expect(Helper.ip2hex("66.124.160.150")).to.equal("427ca096"); | ||
expect(Helper.ip2hex("127.0.0.1")).to.equal("7f000001"); | ||
expect(Helper.ip2hex("0.0.0.255")).to.equal("000000ff"); | ||
}); | ||
|
||
it("unsupported addresses return default", function() { | ||
expect(Helper.ip2hex("0.0.0.999")).to.equal("00000000"); | ||
expect(Helper.ip2hex("localhost")).to.equal("00000000"); | ||
expect(Helper.ip2hex("::1")).to.equal("00000000"); | ||
expect(Helper.ip2hex("2606:2800:220:1:248:1893:25c8:1946")).to.equal("00000000"); | ||
}); | ||
}); |