key-networks / ztncui

ZeroTier network controller UI
GNU General Public License v3.0
1.55k stars 230 forks source link

Deleting IP assignment from member: Cannot read property 'active' of undefined #7

Closed chotaire closed 6 years ago

chotaire commented 6 years ago

Using the ztncui docker image, when deleting an assigned IP from a member, the following error will always be dropped:

GET /controller/network/12345/member/123/ipAssignments/1/delete 500 8.144 ms - 180,
TypeError: /snapshot/src/views/controller_layout.pug:21,
    19|       .collapse.navbar-collapse(id='BarNav'),
    20|         ul.nav.navbar-nav,
  > 21|           li(class=(nav.active === 'controller_home'? 'active' : '')),
    22|             a(href='/controller') Home,
    23|           li(class=(nav.active === 'users'? 'active' : '')),
    24|             a(href='/users') Users,
Cannot read property 'active' of undefined,
    at eval (eval at wrap (/snapshot/src/node_modules/pug-runtime/wrap.js:6:10), <anonymous>:53:73),
    at template (eval at wrap (/snapshot/src/node_modules/pug-runtime/wrap.js:6:10), <anonymous>:104:225),
    at Object.exports.renderFile (/snapshot/src/node_modules/pug/lib/index.js:428:38),
    at Object.exports.renderFile (/snapshot/src/node_modules/pug/lib/index.js:418:21),
    at View.exports.__express [as engine] (/snapshot/src/node_modules/pug/lib/index.js:465:11),
    at View.render (/snapshot/src/node_modules/express/lib/view.js:135:8),
    at tryRender (/snapshot/src/node_modules/express/lib/application.js:640:10),
    at Function.render (/snapshot/src/node_modules/express/lib/application.js:592:3),
    at ServerResponse.render (/snapshot/src/node_modules/express/lib/response.js:1008:7),
    at /snapshot/src/app.js:0:0,
GET /controller/network/12345/member/123/ipAssignments 200 139.489 ms - 3068,
key-networks commented 6 years ago

I haven't been able to reproduce this. Can you give more details about your environment and the steps to reproduce?

chotaire commented 6 years ago

Environment: ztncui docker image (keynetworks/ztncui)

Host:

# cat /etc/fedora-release ; uname -a ; docker --version
Fedora release 28 (Twenty Eight)
Linux blah 4.16.8-300.fc28.x86_64 #1 SMP Wed May 9 20:23:40 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Docker version 18.05.0-ce, build f150324

Connection to HTTPS web-interface via external Apache reverse proxy:

# rpm -qa httpd
httpd-2.4.33-5.fc28.x86_64

Steps to reproduce:

a) Connect a new client to an existing network
b) Go to ztncui -> Networks -> members
c) Give client a name and Authorize
d) Watch (e.g. reload) how member is receiving an IP assignment
e) Under IP assignment tab, click on assigned IP address
f) Add new IP address, click + sign to execute
g) Delete old/previous IP address
h) Error is logged as WARN (sigh) in about 90% of all cases (e.g. check docker logs or syslog on host)
key-networks commented 6 years ago

Sorry, I have not been able to reproduce this error. My environment is as follows:

Linux blah 4.14.11-300.fc27.x86_64 #1 SMP Wed Jan 3 13:52:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux Docker version 17.12.0-ce, build c97c6d6

I am not using a reverse proxy.

Could you test with using the following scenarios:

  1. Remove the reverse proxy and connect directly.
  2. Downgrade to docker 17.
  3. Test on FC 27.

Hopefully we can isolate the problem.

Thanks

key-networks commented 6 years ago

I have tested on FC 28 with Docker version 18.05.0-ce, build f150324 on: Linux blah 4.16.14-300.fc28.x86_64 #1 SMP Tue Jun 5 16:23:44 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

I did not use a reverse proxy. I could not reproduce this fault. Please try without a reverse proxy and let me know if that makes a difference.

dschulz commented 6 years ago

I'm experiencing the same issue (I think) but with the vanilla package (not dockerized). This is on Ubuntu 16.04.4 using HAProxy as a reverse proxy (for SSL termination).

TypeError: /snapshot/src/views/controller_layout.pug:21
    19|       .collapse.navbar-collapse(id='BarNav')
    20|         ul.nav.navbar-nav
  > 21|           li(class=(nav.active === 'controller_home'? 'active' : ''))
    22|             a(href='/controller') Home
    23|           li(class=(nav.active === 'users'? 'active' : ''))
    24|             a(href='/users') Users

Cannot read property 'active' of undefined
    at eval (eval at wrap (/snapshot/src/node_modules/pug-runtime/wrap.js:6:10), <anonymous>:53:73)
    at template (eval at wrap (/snapshot/src/node_modules/pug-runtime/wrap.js:6:10), <anonymous>:104:225)
    at Object.exports.renderFile (/snapshot/src/node_modules/pug/lib/index.js:428:38)
    at Object.exports.renderFile (/snapshot/src/node_modules/pug/lib/index.js:418:21)
    at View.exports.__express [as engine] (/snapshot/src/node_modules/pug/lib/index.js:465:11)
    at View.render (/snapshot/src/node_modules/express/lib/view.js:135:8)
    at tryRender (/snapshot/src/node_modules/express/lib/application.js:640:10)
    at Function.render (/snapshot/src/node_modules/express/lib/application.js:592:3)
    at ServerResponse.render (/snapshot/src/node_modules/express/lib/response.js:1008:7)
    at /snapshot/src/app.js:0:0

This is the relevant HAProxy settings:

frontend https
    bind *:443 ssl crt /etc/haproxy/certs.d/mydomain.net.pem crt /etc/haproxy/certs.d/ no-sslv3
    option http-keep-alive
    option forwardfor
    reqadd X-Forwarded-Proto:\ https
    reqadd X-Forwarded-Port:\ 3443
   # rspadd  Strict-Transport-Security:\ max-age=15768000

    default_backend     ztncui_backend

backend ztncui_backend
    server ztncui 127.0.0.1:3443 ssl verify none

ztncui version:

# apt-cache policy ztncui
ztncui:
  Installed: 0.4.2
  Candidate: 0.4.2
  Version table:
 *** 0.4.2 100
        100 /var/lib/dpkg/status

zerotier version:

apt-cache policy zerotier-one
zerotier-one:
  Installed: 1.2.4
  Candidate: 1.2.8
  Version table:
     1.2.8 500
        500 http://download.zerotier.com/debian/xenial xenial/main amd64 Packages
 *** 1.2.4 100
        100 /var/lib/dpkg/status

Please let me know if you need more info.

dschulz commented 6 years ago

Just to add a detail: connecting directly to the TLS port (enabled with HTTPS_PORT=3443), no reverse proxy involved, with the default self-signed certificate the problem is still reproducible when clicking on a network's name, which links to something like https://w.x.y.z:3443/controller/network/49a6zzzzzzzzz

BTW, I'm using Google Chrome 67.0.3396.99 (Official Build) (64-bit), if that matters.

key-networks commented 6 years ago

@dschulz please try this package without the reverse proxy and let me know if you get the same error: https://s3-us-west-1.amazonaws.com/key-networks/deb/ztncui/1/x86_64/ztncui_0.5.1_amd64.deb

dschulz commented 6 years ago

@key-networks thanks for looking into it. I just tried installing the new package without a reverse proxy in front of it. Configured a proper letsencrypt certificate. The issue it's still reproducible when clicking in the "detail" link, which points to the https://zzzzzzzzzz:3443/controller/network/49a674xxxxxxxxxx:

TypeError: /snapshot/src/views/controller_layout.pug:21
    19|       .collapse.navbar-collapse(id='BarNav')
    20|         ul.nav.navbar-nav
  > 21|           li(class=(nav.active === 'controller_home'? 'active' : ''))
    22|             a(href='/controller') Home
    23|           li(class=(nav.active === 'users'? 'active' : ''))
    24|             a(href='/users') Users

Cannot read property 'active' of undefined
    at eval (eval at wrap (/snapshot/src/node_modules/pug-runtime/wrap.js:6:10), <anonymous>:53:73)
    at template (eval at wrap (/snapshot/src/node_modules/pug-runtime/wrap.js:6:10), <anonymous>:104:225)
    at Object.exports.renderFile (/snapshot/src/node_modules/pug/lib/index.js:428:38)
    at Object.exports.renderFile (/snapshot/src/node_modules/pug/lib/index.js:418:21)
    at View.exports.__express [as engine] (/snapshot/src/node_modules/pug/lib/index.js:465:11)
    at View.render (/snapshot/src/node_modules/express/lib/view.js:135:8)
    at tryRender (/snapshot/src/node_modules/express/lib/application.js:640:10)
    at Function.render (/snapshot/src/node_modules/express/lib/application.js:592:3)
    at ServerResponse.render (/snapshot/src/node_modules/express/lib/response.js:1008:7)
    at /snapshot/src/app.js:0:0

Please let me know if you think I can be of any help.

key-networks commented 6 years ago

@dschulz could you please test this package: https://s3-us-west-1.amazonaws.com/key-networks/deb/ztncui/1/x86_64/ztncui_0.5.3_amd64.deb

dschulz commented 6 years ago

@key-networks thanks! With the 0.5.3 version I couldn't reproduce the issue anymore, it now works as expected.

key-networks commented 6 years ago

@dschulz - thanks for your feedback. @chotaire - the RPM package is now available in the repo.

Installation instructions are at https://key-networks.com/ztncui/#installation

key-networks commented 6 years ago

P.S. A new docker image will hopefully follow soon...