forked from Support/sp-hydra-veil-gui
Location edits now check which protocols are supported for systemwide
This commit is contained in:
parent
7d6d03367a
commit
5b97f6ad1b
1 changed files with 17 additions and 4 deletions
|
|
@ -12,6 +12,7 @@ from core.controllers.ProfileController import ProfileController
|
|||
from core.controllers.LocationController import LocationController
|
||||
from core.models.Result import Result, ResultError
|
||||
from core.controllers.profile_state.update_profile import update_profile
|
||||
from core.controllers.profile_state.data_filters import get_supported_protocols_for_location
|
||||
from core.models.BaseProfile import ProfileType
|
||||
|
||||
from gui.v2.ui.pages.Page import Page
|
||||
|
|
@ -211,17 +212,29 @@ class EditorPage(Page):
|
|||
|
||||
protocol = data_profile.get("protocol", None)
|
||||
profile_type = data_profile.get("connection", None)
|
||||
location_codes = data_profile.get("location", None)
|
||||
|
||||
if not profile_type or not protocol:
|
||||
error_msg = "You've found a bug, where there is no profile type or protocol field."
|
||||
print(error_msg)
|
||||
if not profile_type or not protocol or not location_codes:
|
||||
error_msg = "This profile lacks a profile type, protocol, or location."
|
||||
self.show_a_popup(message=error_msg, title="Missing fields")
|
||||
return
|
||||
|
||||
supported_protocols_result = get_supported_protocols_for_location(location_codes=location_codes, profile_type=profile_type)
|
||||
|
||||
if not supported_protocols_result.valid:
|
||||
error_msg = "This profile lacks supported locations."
|
||||
self.show_a_popup(message=error_msg, title="Invalid location")
|
||||
return
|
||||
|
||||
supported_protocols = supported_protocols_result.data
|
||||
|
||||
if not supported_protocols:
|
||||
error_msg = "This profile lacks supported locations."
|
||||
self.show_a_popup(message=error_msg, title="Invalid location")
|
||||
|
||||
if profile_type == "system-wide":
|
||||
self.process_and_show_labels(data_profile, {
|
||||
"protocol": ['vless', 'hysteria2', 'wireguard'],
|
||||
"protocol": supported_protocols,
|
||||
"connection": ['system-wide'],
|
||||
"location": self.connection_manager.get_location_list(),
|
||||
}, selected_profile_str)
|
||||
|
|
|
|||
Loading…
Reference in a new issue