Skip to content

Commit

Permalink
Merge pull request #1186 from ploxiln/ipv6_nodes_link_fix
Browse files Browse the repository at this point in the history
nsqadmin: fix nodes list links with ipv6 addresses
  • Loading branch information
ploxiln authored Sep 17, 2019
2 parents 470346f + bb2fc64 commit 9faeb4a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 24 deletions.
4 changes: 2 additions & 2 deletions nsqadmin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Read the [docs](http://nsq.io/components/nsqadmin.html)
1. `$ npm install`
2. `$ ./gulp --series clean watch` or `$ ./gulp --series clean build`
3. `$ go-bindata --debug --pkg=nsqadmin --prefix=static/build static/build/...`
4. `$ go build && ./nsqadmin`
5. make changes (repeat step 5 if you make changes to any Go code)
4. `$ go build ../apps/nsqadmin && ./nsqadmin`
5. make changes (repeat step 4 only if you make changes to any Go code)
6. `$ go-bindata --pkg=nsqadmin --prefix=static/build static/build/...`
7. commit other changes and `bindata.go`
51 changes: 30 additions & 21 deletions nsqadmin/bindata.go

Large diffs are not rendered by default.

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 9faeb4a

Please sign in to comment.