Skip to content

Commit

Permalink
Fix traffic calculation in EhcoRelayConfigView
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehco1996 committed Apr 9, 2024
1 parent 2c65d56 commit 5eac277
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apps/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,12 @@ def post(self, request, node_id):
# TODO make this async
rules: List[m.RelayRule] = node.relay_rules.all()
name_rule_map = {rule.name: rule for rule in rules}
for data in request.json:
for data in request.json.get("stats", []):
name = data["relay_label"]
if name in name_rule_map:
rule = name_rule_map[name]
rule.up_traffic += data["stats"]["up"] * node.enlarge_scale
rule.down_traffic += data["stats"]["down"] * node.enlarge_scale
rule.up_traffic += data["up_bytes"] * node.enlarge_scale
rule.down_traffic += data["down_bytes"] * node.enlarge_scale
for rule in rules:
rule.save()
return JsonResponse(data={})
Expand Down

0 comments on commit 5eac277

Please sign in to comment.