1717from ..database .functions import functions
1818from ..config .config import config
1919
20+ from ..utilities .utilities import utilities
21+ from ..utilities .system_status import system_status
22+
2023routes = flask .Blueprint ("routes" , __name__ )
2124
2225white_list = [
@@ -158,19 +161,9 @@ def api_authenticate():
158161 return make_resp_obj (False , error_msg , {"status" : False }, 401 )
159162
160163 if totp_enabled :
161- return make_resp_obj (
162- False ,
163- "Sorry, your username, password or OTP is incorrect." ,
164- {},
165- 401
166- )
164+ return make_resp_obj (False , "Sorry, your username, password or OTP is incorrect." , {}, 401 )
167165 else :
168- return make_resp_obj (
169- False ,
170- "Sorry, your username or password is incorrect." ,
171- {},
172- 401
173- )
166+ return make_resp_obj (False , "Sorry, your username or password is incorrect." , {}, 401 )
174167
175168@routes .route ('/' )
176169def index_handler ():
@@ -216,6 +209,11 @@ def api_retrieve_dashboard_theme():
216209
217210 return make_resp_obj (True , "" , config_server .get ("wgdashboard_theme" ), 200 )
218211
212+ @routes .route ('/api/getDashboardUpdate' )
213+ def api_retrieve_dashboard_update ():
214+ utilities .update_available ()
215+ return make_resp_obj ()
216+
219217@routes .route ('/api/getDashboardConfiguration' )
220218def api_retrieve_dashboard_config ():
221219 return make_resp_obj (data = flask .current_app .wgd_config )
@@ -231,11 +229,31 @@ def api_totp_status():
231229
232230 return make_resp_obj (True , "" , data , 200 )
233231
232+ @routes .route ('/api/getWireguardConfigurations' )
233+ def api_retrieve_wireguard_configurations ():
234+ ok , config_server = config .filter (flask .current_app .wgd_config , 'SERVER' )
235+ if not ok :
236+ log .error ("failed to filter the config in-memory" )
237+ return make_resp_obj (False , 'Internal error' , {}, 500 )
238+
239+ if "wg_conf_path" not in config_server :
240+ return make_resp_obj (False , 'Internal error' , {}, 500 )
241+
242+ wireguard_path = config_server .get ('wg_conf_path' , '/etc/wireguard' )
243+ if os .path .exists (wireguard_path ):
244+ present_confs = os .listdir (wireguard_path )
245+ present_confs .sort ()
246+
247+ log .info (present_confs )
248+
249+ return make_resp_obj (True , 'Wireguard' , {}, 200 )
250+
251+ @routes .route ('/api/systemStatus' )
252+ def api_system_status ():
253+ status = system_status ()
254+ return make_resp_obj (True , "" , status .to_json (), 200 )
255+
234256@routes .route ('/health' , methods = ["GET" ])
235257@routes .route ('/healthz' , methods = ["GET" ])
236258def health_handler ():
237- return make_resp_obj (True ,
238- "Health Endpoint" ,
239- {"status" : "ok" },
240- 200
241- )
259+ return make_resp_obj (True , "Health Endpoint" , {"status" : "ok" }, 200 )
0 commit comments