donaldzou / WGDashboard

Simple dashboard for WireGuard VPN written in Python & Vue.js
https://donaldzou.github.io/WGDashboard-Documentation/
Apache License 2.0
1.56k stars 234 forks source link

ifcfg.default_interface() is None #373

Closed tbnobody closed 1 month ago

tbnobody commented 1 month ago

Describe The Problem When starting the dashboard I get the following errors message:

./wgd.sh debug
------------------------------------------------------------
[WGDashboard] Starting WGDashboard in the foreground.
Traceback (most recent call last):
  File "/opt/wgdashboard/src/dashboard.py", line 1412, in <module>
    DashboardConfig = DashboardConfig()
                      ^^^^^^^^^^^^^^^^^
  File "/opt/wgdashboard/src/dashboard.py", line 1121, in __init__
    "remote_endpoint": ifcfg.default_interface()['inet'],
                       ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
------------------------------------------------------------

To Reproduce I also just launched a python interpreter and executed the following:

python3
Python 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ifcfg
>>> print(ifcfg.default_interface())
None

Not sure how ifcfg determines a default interface but it doesn't seem to work always.

OS Information:

tbnobody commented 1 month ago

This works as a workaround

diff --git a/src/dashboard.py b/src/dashboard.py
index fca6bc0..5cbd83c 100644
--- a/src/dashboard.py
+++ b/src/dashboard.py
@@ -1118,7 +1118,7 @@ class DashboardConfig:
                 "peer_global_DNS": "1.1.1.1",
                 "peer_endpoint_allowed_ip": "0.0.0.0/0",
                 "peer_display_mode": "grid",
-                "remote_endpoint": ifcfg.default_interface()['inet'],
+                "remote_endpoint": ifcfg.default_interface()['inet'] if ifcfg.default_interface() else '',
                 "peer_MTU": "1420",
                 "peer_keep_alive": "21"
             },
donaldzou commented 1 month ago

Will add this workaround to the fix

donaldzou commented 1 month ago

Fixed in v4.0.3. Thanks to @tbnobody providing the fix.