Skip to content

Commit

Permalink
nsqadmin: fix nodes list links with ipv6 addresses
Browse files Browse the repository at this point in the history
An ipv6 address needs to be wrapped in "[]" when joined with port
because ":" inside the ipv6 address makes it ambiguous.

Most (all?) of our go code uses net.JoinHostPort() which does this.
  • Loading branch information
ploxiln committed Sep 11, 2019
1 parent 470346f commit e4c34b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions nsqadmin/static/js/collections/nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ var Nodes = Backbone.Collection.extend({
},

parse: function(resp) {
resp['nodes'].forEach(function(n) {
var jaddr = n['broadcast_address'];
if (jaddr.includes(':')) {
// ipv6 raw address contains ':'
// it must be wrapped in '[ ]' when joined with port
jaddr = '[' + jaddr + ']';
}
n['broadcast_address_http'] = jaddr + ':' + n['http_port'];
});
return resp['nodes'];
}
});
Expand Down
2 changes: 1 addition & 1 deletion nsqadmin/static/js/views/nodes.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{{#each collection}}
<tr {{#if out_of_date}}class="warning"{{/if}}>
<td>{{hostname}}</td>
<td><a class="link" href="{{basePath "/nodes"}}/{{broadcast_address}}:{{http_port}}">{{broadcast_address}}</a></td>
<td><a class="link" href="{{basePath "/nodes"}}/{{broadcast_address_http}}">{{broadcast_address}}</a></td>
<td>{{tcp_port}}</td>
<td>{{http_port}}</td>
<td>{{version}}</td>
Expand Down

0 comments on commit e4c34b1

Please sign in to comment.