mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
fix country + plugin use
*ping now always return hostname on query *handle case there is no USE_ on a plugin *fix country actions.py duplicate
This commit is contained in:
parent
a97f90e713
commit
4f228866b2
3 changed files with 9 additions and 22 deletions
|
|
@ -1,14 +1,3 @@
|
|||
def country():
|
||||
return {
|
||||
"message": "ok",
|
||||
"data": {
|
||||
"info": "test",
|
||||
"blacklist_count": 3,
|
||||
"whitelist_count": 23,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def country(**kwargs):
|
||||
try:
|
||||
data = kwargs["app"].config["INSTANCES"].get_metrics("country")
|
||||
|
|
|
|||
|
|
@ -1268,7 +1268,8 @@ def custom_plugin(plugin: str):
|
|||
curr_plugin = plug
|
||||
break
|
||||
|
||||
# Get USE_<NAME> and check if the plugin is used by one service
|
||||
# Get USE_<NAME> if exists
|
||||
# Check if the plugin is used by one service
|
||||
config = app.config["CONFIG"].get_config(methods=False)
|
||||
services = app.config["CONFIG"].get_services(with_drafts=True)
|
||||
use_key = False
|
||||
|
|
@ -1277,8 +1278,11 @@ def custom_plugin(plugin: str):
|
|||
if key.upper().startswith("USE_"):
|
||||
use_key = key
|
||||
|
||||
is_used = True if config[use_key] == "yes" else False
|
||||
# Case no USE_<NAME>, it means always show
|
||||
if not use_key:
|
||||
is_used = True if config[use_key] == "yes" else False
|
||||
|
||||
# Case USE_<NAME>, it means show only if used by one service
|
||||
if use_key and not is_used:
|
||||
for service in services:
|
||||
if service[use_key] == "yes":
|
||||
|
|
|
|||
|
|
@ -123,8 +123,8 @@ class Instance:
|
|||
def metrics_redis(self) -> Tuple[bool, dict[str, Any]]:
|
||||
return self.apiCaller.send_to_apis("GET", "/redis/stats", response=True)
|
||||
|
||||
def ping(self, plugin_id, hostname: Optional[str] = "") -> Tuple[bool, dict[str, Any]]:
|
||||
return self.apiCaller.send_to_apis("POST", f"/{plugin_id}/ping{'?host={hostname}' if hostname else ''}", response=True)
|
||||
def ping(self, plugin_id, hostname: str = "") -> Tuple[bool, dict[str, Any]]:
|
||||
return self.apiCaller.send_to_apis("POST", f"/{plugin_id}/ping?host={hostname}", response=True)
|
||||
|
||||
|
||||
class Instances:
|
||||
|
|
@ -438,13 +438,7 @@ class Instances:
|
|||
ping = {"status": "error"}
|
||||
for instance in self.get_instances():
|
||||
try:
|
||||
if plugin_id == "redis":
|
||||
resp, ping_data = instance.ping(plugin_id, instance["name"])
|
||||
else:
|
||||
resp, ping_data = instance.ping(plugin_id)
|
||||
print("res")
|
||||
print(resp)
|
||||
print(ping_data)
|
||||
resp, ping_data = instance.ping(plugin_id, instance["name"])
|
||||
except:
|
||||
continue
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue