tunnels-is / nicelandvpn-desktop

GNU General Public License v3.0
28 stars 10 forks source link

Private VPN server has panic/crashes. #19

Closed cyberofficial closed 10 months ago

cyberofficial commented 10 months ago

Describe the bug Private VPN will crash after a short period of time.

To Reproduce Steps to reproduce the behavior:

  1. Set up private vpn
  2. Browse the web for a bit
  3. VPN Server panics.

Logs

2023/09/15 13:55:32 Fetching config from:  146.59.111.154
2023/09/15 13:55:33 _ INFO _ RE_INIT_TCP_RAW_SOCKET _ @@@@@@@@@@@@@@@@@@@@@@ INITIALIZING RAW TCP SOCKET
2023/09/15 13:55:33 _ INFO _ RE_INIT_UDP_RAW_SOCKET _ @@@@@@@@@@@@@@@@@@@@@@ INITIALIZING RAW UDP SOCKET
2023/09/15 13:55:33 _ INFO _ INIT_ROUTER_CONTROL_SOCKET _  ---------- CONNECTING TO CONTROL SOCKET:195.154.235.56
2023/09/15 13:55:33 _ INFO _ CreateTunnelBuffer _  ???????????????? WAITING FOR OK FROM CONTROLLER195.154.235.56
2023/09/15 13:55:34 _ INFO _ INIT_ROUTER_CONTROL_SOCKET _  ++++++++++++++++ GOT OK FROM CONTROLLER195.154.235.56
2023/09/15 13:59:05 _ INFO _ READ_FROM_TCP_ROUTER_LISTENER _ ON CONTROLER TUNNEL:339195.154.235.56:443[103 1 4 0 2 0 1 83]
2023/09/15 13:59:05 _ INFO _ CREATE_CLIENT_PORT_MAPPING _ IF IP:64.176.214.108
2023/09/15 13:59:05 _ INFO _ CREATE_CLIENT_PORT_MAPPING _ ++++++++++++++ REPLYING TO PORT ALLOCATION >> [200 1 4 0 2 0 3 181]
2023/09/15 14:01:01 _ INFO _ READ_FROM_TCP_ROUTER_LISTENER _ ON CONTROLER TUNNEL:340195.154.235.56:443[103 1 4 1 2 0 1 84]
2023/09/15 14:01:02 _ ERROR _ PROCESS_CLIENT_TUNNEL_SOCKET _ DATA LENGTH READ ERROREOF
2023/09/15 14:01:03 _ INFO _ func2 _ CLOSING ALL CLIENT STUFF
2023/09/15 14:01:06 _ INFO _ PROCESS_CLIENT_UDP_QUEUE _ CLIENT UDP QUEUE CLOSING
2023/09/15 14:01:06 _ INFO _ READ_FROM_GLOBAL_UDP_LISTENER_NEW _ TCP DSTP DOES NOT HAVE A QUEUE:2000
2023/09/15 14:01:06 _ INFO _ PROCESS_CLIENT_TCP_QUEUE _ runtime error: invalid memory address or nil pointer dereferencegoroutine 32 [running]:
runtime/debug.Stack()
        /usr/local/go/src/runtime/debug/stack.go:24 +0x65
main.PROCESS_CLIENT_TCP_QUEUE.func1()
        /mnt/c/Users/anon/go-code/monolith/device/device_core.go:473 +0x4c
panic({0x7628a0, 0xaa63f0})
        /usr/local/go/src/runtime/panic.go:884 +0x212
main.PROCESS_CLIENT_TCP_QUEUE(0x0?)
        /mnt/c/Users/anon/go-code/monolith/device/device_core.go:505 +0x2d1
created by main.CREATE_CLIENT_PORT_MAPPING
        /mnt/c/Users/anon/go-code/monolith/device/device_core.go:858 +0x1453

2023/09/15 14:01:08 _ INFO _ CREATE_CLIENT_PORT_MAPPING _ IF IP:64.176.214.108
2023/09/15 14:01:08 _ INFO _ PROCESS_CLIENT_TCP_QUEUE _ CLIENT TCP QUEUE CLOSING
2023/09/15 14:01:09 _ INFO _ CREATE_CLIENT_PORT_MAPPING _ ++++++++++++++ REPLYING TO PORT ALLOCATION >> [200 1 4 1 2 0 3 180]
2023/09/15 14:01:45 _ ERROR _ PROCESS_CLIENT_TUNNEL_SOCKET _ DATA LENGTH READ ERROREOF
2023/09/15 14:01:47 _ INFO _ func2 _ CLOSING ALL CLIENT STUFF
2023/09/15 14:01:52 _ INFO _ PROCESS_CLIENT_TCP_QUEUE _ CLIENT TCP QUEUE CLOSING
2023/09/15 14:01:54 _ INFO _ PROCESS_CLIENT_UDP_QUEUE _ runtime error: invalid memory address or nil pointer dereferencegoroutine 38 [running]:
runtime/debug.Stack()
        /usr/local/go/src/runtime/debug/stack.go:24 +0x65
main.PROCESS_CLIENT_UDP_QUEUE.func1()
        /mnt/c/Users/anon/go-code/monolith/device/device_core.go:414 +0x4c
panic({0x7628a0, 0xaa63f0})
        /usr/local/go/src/runtime/panic.go:884 +0x212
main.PROCESS_CLIENT_UDP_QUEUE(0x0?)
        /mnt/c/Users/anon/go-code/monolith/device/device_core.go:446 +0x2d1
created by main.CREATE_CLIENT_PORT_MAPPING
        /mnt/c/Users/anon/go-code/monolith/device/device_core.go:864 +0x14c5

2023/09/15 14:02:10 _ INFO _ PROCESS_CLIENT_UDP_QUEUE _ CLIENT UDP QUEUE CLOSING
Killed

Additional context Worked fine for few minutes, then tested out the speed with a speed test and it crashed.

zveinn commented 10 months ago

This race condition happens when the vpn users tunnel socket has been unset after a disconnect. It is uncommon, but can happen. If we wanted to avoid this condition we would have to implement some kind of locking mechanism that would degrade performance in the packet flow.

Thank you for reporting though.