Skip to content

Commit

Permalink
fixed traffic log bug and update trojan
Browse files Browse the repository at this point in the history
  • Loading branch information
Gkirito authored and Ehco1996 committed Nov 10, 2020
1 parent 074ad6c commit c3e9560
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 63 deletions.
32 changes: 32 additions & 0 deletions apps/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,28 @@ def clear_get_user_vmess_configs_by_node_id_cache(sender, instance, *args, **kwa
cache.delete_many(keys)


def clear_get_user_trojan_configs_by_node_id_cache(sender, instance, *args, **kwargs):

if isinstance(instance, m.TrojanNode):
node_ids = [instance.node_id]
elif isinstance(instance, m.User):
node_ids = m.TrojanNode.get_node_ids_by_level(instance.level)
if hasattr(instance, "_pre_level"):
level = getattr(instance, "_pre_level")
node_ids.extend(m.TrojanNode.get_node_ids_by_level(level))
node_ids = set(node_ids)
else:
return

keys = [
m.TrojanNode.get_user_trojan_configs_by_node_id.make_cache_key(
m.TrojanNode, node_id
)
for node_id in node_ids
]
cache.delete_many(keys)


def register_connectors():

# set old user level before save
Expand All @@ -69,3 +91,13 @@ def register_connectors():
pre_delete.connect(
clear_get_user_vmess_configs_by_node_id_cache, sender=m.VmessNode
)

# clear_get_user_trojan_configs_by_node_id_cache
post_save.connect(clear_get_user_trojan_configs_by_node_id_cache, sender=m.User)
pre_delete.connect(clear_get_user_trojan_configs_by_node_id_cache, sender=m.User)
post_save.connect(
clear_get_user_trojan_configs_by_node_id_cache, sender=m.TrojanNode
)
pre_delete.connect(
clear_get_user_trojan_configs_by_node_id_cache, sender=m.TrojanNode
)
5 changes: 3 additions & 2 deletions apps/sspanel/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,11 @@ class Meta:
"ehco_transport_type": forms.Select(attrs={"class": "input"}),
"network": forms.TextInput(attrs={"class": "input"}),
"alpn": forms.TextInput(attrs={"class": "input"}),
"certificateFile": forms.TextInput(attrs={"class": "input"}),
"keyFile": forms.TextInput(attrs={"class": "input"}),
"certificate_file": forms.TextInput(attrs={"class": "input"}),
"key_file": forms.TextInput(attrs={"class": "input"}),
"enable_ehco_lb": forms.CheckboxInput(attrs={"class": "checkbox"}),
"security": forms.TextInput(attrs={"class": "input"}),
"skip_cert_verify": forms.CheckboxInput(attrs={"class": "checkbox"}),
}


Expand Down
63 changes: 49 additions & 14 deletions apps/sspanel/migrations/0001_squashed_0055_auto_20200726_0847.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ class Migration(migrations.Migration):
"verbose_name_plural": "用户",
"abstract": False,
},
managers=[("objects", django.contrib.auth.models.UserManager()),],
managers=[
("objects", django.contrib.auth.models.UserManager()),
],
),
migrations.CreateModel(
name="Announcement",
Expand All @@ -315,7 +317,10 @@ class Migration(migrations.Migration):
("time", models.DateTimeField(auto_now_add=True, verbose_name="时间")),
("body", models.TextField(verbose_name="主体")),
],
options={"verbose_name_plural": "系统公告", "ordering": ("-time",),},
options={
"verbose_name_plural": "系统公告",
"ordering": ("-time",),
},
),
migrations.CreateModel(
name="Donate",
Expand Down Expand Up @@ -356,7 +361,10 @@ class Migration(migrations.Migration):
),
),
],
options={"verbose_name_plural": "捐赠记录", "ordering": ("-time",),},
options={
"verbose_name_plural": "捐赠记录",
"ordering": ("-time",),
},
),
migrations.CreateModel(
name="Goods",
Expand Down Expand Up @@ -430,7 +438,10 @@ class Migration(migrations.Migration):
models.PositiveSmallIntegerField(default=1, verbose_name="排序"),
),
],
options={"verbose_name_plural": "商品", "ordering": ["order"],},
options={
"verbose_name_plural": "商品",
"ordering": ["order"],
},
),
migrations.CreateModel(
name="InviteCode",
Expand Down Expand Up @@ -506,7 +517,10 @@ class Migration(migrations.Migration):
),
("isused", models.BooleanField(default=False, verbose_name="是否使用")),
],
options={"verbose_name_plural": "充值码", "ordering": ("isused",),},
options={
"verbose_name_plural": "充值码",
"ordering": ("isused",),
},
),
migrations.CreateModel(
name="PurchaseHistory",
Expand Down Expand Up @@ -543,7 +557,10 @@ class Migration(migrations.Migration):
),
),
],
options={"verbose_name_plural": "购买记录", "ordering": ("-created_at",),},
options={
"verbose_name_plural": "购买记录",
"ordering": ("-created_at",),
},
),
migrations.CreateModel(
name="RebateRecord",
Expand Down Expand Up @@ -580,7 +597,10 @@ class Migration(migrations.Migration):
),
),
],
options={"ordering": ("-created_at",), "verbose_name_plural": "返利记录",},
options={
"ordering": ("-created_at",),
"verbose_name_plural": "返利记录",
},
),
migrations.CreateModel(
name="Ticket",
Expand Down Expand Up @@ -612,7 +632,10 @@ class Migration(migrations.Migration):
),
),
],
options={"verbose_name_plural": "工单", "ordering": ("-time",),},
options={
"verbose_name_plural": "工单",
"ordering": ("-time",),
},
),
migrations.CreateModel(
name="UserOrder",
Expand Down Expand Up @@ -816,7 +839,9 @@ class Migration(migrations.Migration):
),
),
],
options={"verbose_name_plural": "邮件发送记录",},
options={
"verbose_name_plural": "邮件发送记录",
},
),
migrations.CreateModel(
name="NodeOnlineLog",
Expand Down Expand Up @@ -1007,7 +1032,9 @@ class Migration(migrations.Migration):
),
),
],
options={"verbose_name_plural": "Vmess节点",},
options={
"verbose_name_plural": "Vmess节点",
},
),
migrations.CreateModel(
name="SSNode",
Expand Down Expand Up @@ -1153,7 +1180,9 @@ class Migration(migrations.Migration):
),
),
],
options={"verbose_name_plural": "SS节点",},
options={
"verbose_name_plural": "SS节点",
},
),
migrations.CreateModel(
name="RelayNode",
Expand Down Expand Up @@ -1271,7 +1300,9 @@ class Migration(migrations.Migration):
),
("level", models.PositiveIntegerField(default=0)),
],
options={"verbose_name_plural": "中转节点",},
options={
"verbose_name_plural": "中转节点",
},
),
migrations.CreateModel(
name="SSRelayRule",
Expand Down Expand Up @@ -1325,7 +1356,9 @@ class Migration(migrations.Migration):
),
),
],
options={"verbose_name_plural": "SS转发规则",},
options={
"verbose_name_plural": "SS转发规则",
},
),
migrations.CreateModel(
name="VmessRelayRule",
Expand Down Expand Up @@ -1379,6 +1412,8 @@ class Migration(migrations.Migration):
),
),
],
options={"verbose_name_plural": "Vmess转发规则",},
options={
"verbose_name_plural": "Vmess转发规则",
},
),
]
8 changes: 6 additions & 2 deletions apps/sspanel/migrations/0004_auto_20201108_0400.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ class Migration(migrations.Migration):
),
),
],
options={"verbose_name_plural": "Trojan节点",},
options={
"verbose_name_plural": "Trojan节点",
},
),
migrations.AddField(
model_name="relaynode",
Expand Down Expand Up @@ -283,6 +285,8 @@ class Migration(migrations.Migration):
),
),
],
options={"verbose_name_plural": "Trojan转发规则",},
options={
"verbose_name_plural": "Trojan转发规则",
},
),
]
59 changes: 59 additions & 0 deletions apps/sspanel/migrations/0005_auto_20201110_2208.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Generated by Django 3.1.2 on 2020-11-10 14:08

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("sspanel", "0004_auto_20201108_0400"),
]

operations = [
migrations.RemoveField(
model_name="trojannode",
name="certificateFile",
),
migrations.RemoveField(
model_name="trojannode",
name="keyFile",
),
migrations.AddField(
model_name="trojannode",
name="certificate_file",
field=models.CharField(
default="path/to/cert", max_length=64, verbose_name="crt地址"
),
),
migrations.AddField(
model_name="trojannode",
name="key_file",
field=models.CharField(
default="path/to/cert", max_length=64, verbose_name="key地址"
),
),
migrations.AddField(
model_name="trojannode",
name="skip_cert_verify",
field=models.BooleanField(default=False, verbose_name="是否允许不安全连接(跳过tls验证)"),
),
migrations.AlterField(
model_name="ssnode",
name="server",
field=models.CharField(
help_text="支持逗号分隔传多个地址", max_length=128, verbose_name="服务器地址"
),
),
migrations.AlterField(
model_name="trojannode",
name="alpn",
field=models.CharField(
default="http/1.1", max_length=64, verbose_name="alpn"
),
),
migrations.AlterField(
model_name="trojannode",
name="security",
field=models.CharField(default="tls", max_length=64, verbose_name="加密方式"),
),
]
Loading

0 comments on commit c3e9560

Please sign in to comment.