Skip to content

Commit

Permalink
fix: add :: to selfaddress detection (#1489)
Browse files Browse the repository at this point in the history
* fix: add :: to selfaddress detection (ipv6 of 0.0.0.0)

* fix: case semantic order
  • Loading branch information
kilrau authored Apr 20, 2020
1 parent e5121a0 commit 18aa554
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/p2p/Pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,9 @@ class Pool extends EventEmitter {
private addressIsSelf = (address: Address): boolean => {
if (address.port === this.listenPort) {
switch (address.host) {
case '::1':
case '::':
case '0.0.0.0':
case '::1':
case '127.0.0.1':
case 'localhost':
return true;
Expand Down
3 changes: 2 additions & 1 deletion test/jest/Pool.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ describe('P2P Pool', () => {

test('should reject connecting to its own addresses', async () => {
const selfAddresses = [
'::1',
'::',
'0.0.0.0',
'::1',
'127.0.0.1',
'localhost',
];
Expand Down

0 comments on commit 18aa554

Please sign in to comment.