mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
Add draft service number, pro_plugins and is_pro to anonymous report
This commit is contained in:
parent
f87693075e
commit
d9dfcaf730
3 changed files with 23 additions and 6 deletions
|
|
@ -53,6 +53,7 @@ try:
|
|||
data["integration"] = data["integration"].lower()
|
||||
data["database"] = f"{db.database_uri.split(':')[0].split('+')[0]}/{database_version}"
|
||||
data["service_number"] = str(len(services))
|
||||
data["draft_service_number"] = 0
|
||||
data["python_version"] = version.split(" ")[0]
|
||||
|
||||
data["use_ui"] = "no"
|
||||
|
|
@ -61,12 +62,25 @@ try:
|
|||
for server in services:
|
||||
if db_config.get(f"{server}_USE_UI", db_config.get("USE_UI", {"value": "no"}))["value"] == "yes":
|
||||
data["use_ui"] = "yes"
|
||||
break
|
||||
if db_config.get(f"{server}_IS_DRAFT", db_config.get("IS_DRAFT", {"value": "no"}))["value"] == "yes":
|
||||
data["draft_service_number"] += 1
|
||||
# Singlesite case
|
||||
elif db_config.get("USE_UI", {"value": "no"})["value"] == "yes":
|
||||
data["use_ui"] = "yes"
|
||||
else:
|
||||
if db_config.get("USE_UI", {"value": "no"})["value"] == "yes":
|
||||
data["use_ui"] = "yes"
|
||||
if db_config.get("IS_DRAFT", {"value": "no"})["value"] == "yes":
|
||||
data["draft_service_number"] = 1
|
||||
|
||||
data["draft_service_number"] = str(data["draft_service_number"])
|
||||
data["external_plugins"] = []
|
||||
data["pro_plugins"] = []
|
||||
|
||||
for plugin in db.get_plugins():
|
||||
if plugin["type"] == "external":
|
||||
data["external_plugins"].append(f"{plugin['id']}/{plugin['version']}")
|
||||
elif plugin["type"] == "pro":
|
||||
data["pro_plugins"].append(f"{plugin['id']}/{plugin['version']}")
|
||||
|
||||
data["external_plugins"] = [f"{plugin['id']}/{plugin['version']}" for plugin in db.get_plugins(_type="external")]
|
||||
data["os"] = {
|
||||
"name": "Linux",
|
||||
"version": "Unknown",
|
||||
|
|
@ -104,7 +118,7 @@ try:
|
|||
|
||||
tmp_anonymous_report_path.joinpath("last_report.json").write_text(dumps(data, indent=4), encoding="utf-8")
|
||||
|
||||
response = post("https://api.bunkerweb.io/data", json=data, headers={"User-Agent": f"BunkerWeb/{data['version']}"}, allow_redirects=True, timeout=10)
|
||||
response = post("http://api:8080/data", json=data, headers={"User-Agent": f"BunkerWeb/{data['version']}"}, allow_redirects=True, timeout=10)
|
||||
response.raise_for_status()
|
||||
|
||||
cached, err = cache_file(tmp_anonymous_report_path.joinpath("last_report.json"), anonymous_report_path.joinpath("last_report.json"), None, db)
|
||||
|
|
|
|||
|
|
@ -992,6 +992,9 @@ class Database:
|
|||
if is_multisite:
|
||||
for service in services:
|
||||
config[f"{service.id}_IS_DRAFT"] = "yes" if service.is_draft else "no"
|
||||
if methods:
|
||||
config[f"{service.id}_IS_DRAFT"] = {"value": config[f"{service.id}_IS_DRAFT"], "global": False, "method": "default"}
|
||||
|
||||
checked_settings = []
|
||||
for key, value in deepcopy(config).items():
|
||||
original_key = key
|
||||
|
|
|
|||
|
|
@ -814,7 +814,7 @@ def services():
|
|||
"full_value": service["SERVER_NAME"]["value"],
|
||||
"method": service["SERVER_NAME"]["method"],
|
||||
},
|
||||
"IS_DRAFT": service.pop("IS_DRAFT", "no"),
|
||||
"IS_DRAFT": service.pop("IS_DRAFT", {"value": "no"})["value"],
|
||||
"USE_REVERSE_PROXY": service["USE_REVERSE_PROXY"],
|
||||
"SERVE_FILES": service["SERVE_FILES"],
|
||||
"REMOTE_PHP": service["REMOTE_PHP"],
|
||||
|
|
|
|||
Loading…
Reference in a new issue