django-restit 4.2.108__py3-none-any.whl → 4.2.111__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: django-restit
3
- Version: 4.2.108
3
+ Version: 4.2.111
4
4
  Summary: A Rest Framework for DJANGO
5
5
  License: MIT
6
6
  Author: Ian Starnes
@@ -374,7 +374,7 @@ pushit/utils.py,sha256=IeTCGa-164nmB1jIsK1lu1O1QzUhS3BKfuXHGjCW-ck,2121
374
374
  rest/.gitignore,sha256=TbEvWRMnAiajCTOdhiNrd9eeCAaIjRp9PRjE_VkMM5g,118
375
375
  rest/README.md,sha256=V3ETc-cJu8PZIbKr9xSe_pA4JEUpC8Dhw4bQeVCDJPw,5460
376
376
  rest/RemoteEvents.py,sha256=nL46U7AuxIrlw2JunphR1tsXyqi-ep_gD9CYGpYbNgE,72
377
- rest/__init__.py,sha256=yUGGhaiZHnz8BlV-outvcNP7abr5Samxuo6VesvF84Y,121
377
+ rest/__init__.py,sha256=f6yMzn65J43zKPsou6HIxzAW4azgU8ZpZYPncvcWlzU,122
378
378
  rest/arc4.py,sha256=y644IbF1ec--e4cUJ3KEYsewTCITK0gmlwa5mJruFC0,1967
379
379
  rest/cache.py,sha256=1Qg0rkaCJCaVP0-l5hZg2CIblTdeBSlj_0fP6vlKUpU,83
380
380
  rest/crypto/__init__.py,sha256=Tl0U11rgj1eBYqd6OXJ2_XSdNLumW_JkBZnaJqI6Ldw,72
@@ -386,7 +386,7 @@ rest/decorators.py,sha256=ig0LATc3-2mhEJPAWHRbIRM-ZOFyjm6e_F9RhpRWidE,15082
386
386
  rest/encryption.py,sha256=x6Kiez0tVqfxK26MSsRL3k8OS05ni1gEX2aj3I0S9V0,788
387
387
  rest/errors.py,sha256=uKwG9OkLme36etabqK54DMjMQc1fgEoUIAUxXa7WFQw,612
388
388
  rest/extra/__init__.py,sha256=YzmNsch5H5FFLkUK9mIAKyoRK_rJCA9HGb0kubp4h30,54
389
- rest/extra/hostinfo.py,sha256=bAj-6XjY9sJPLHqLxZZLHjmlzSFDJK1L18w81Zb_1ec,3081
389
+ rest/extra/hostinfo.py,sha256=LFigr90B-NU6MkaYDNj7fwfqJVuu9UP1InZMky4kH58,4041
390
390
  rest/extra/json_metadata.py,sha256=p_ffzmANmOFix_oC3voR6_NNTjcn7-T7aXcH-I4_Npg,1078
391
391
  rest/fields.py,sha256=_v1TJVc6vyWlqmwFRJ6mtuR5Fo-lS0KcUhPWIrzKZUo,9719
392
392
  rest/forms.py,sha256=66Wm5cdy8tKib_mGicjq_yd-gNVMFWRECnrDksnNnwU,6316
@@ -413,7 +413,7 @@ rest/models/metadata.py,sha256=1nQ7CYo9bJHoaXE_hVNaj1-Y7yqhHlf2ZlaD1IfTzic,12904
413
413
  rest/net.py,sha256=LcB2QV6VNRtsSdmiQvYZgwQUDwOPMn_VBdRiZ6OpI-I,2974
414
414
  rest/regexes.yaml,sha256=VoGb4E-P_K9f82Yzcpltgzekpt9usRtwu9PYlo46nUw,149463
415
415
  rest/requestex.py,sha256=N56056vV3zWkAP-QrYsCu7SdpPzE5kLuPoxGIuZAKt0,16127
416
- rest/rpc.py,sha256=lHJkZXOxLJJoD4LVPDMXZGk5jV6Yltu7Lu4pMxMpq38,1764
416
+ rest/rpc.py,sha256=wCR22Ds4CgZ9q-ptWuIpc15J01tTRPpAYWEkAA9LDHM,2205
417
417
  rest/search.py,sha256=QVjk2b5tZLgf1zM2MHvJTyRjwUbY5ZD7HXSTmSPXtvU,8362
418
418
  rest/serializers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
419
419
  rest/serializers/collection.py,sha256=V9O4qxw26VX9dSYdbsN0-RNnXEi347Ln8eFLZ003LhA,4646
@@ -509,7 +509,7 @@ ws4redis/servers/uwsgi.py,sha256=VyhoCI1DnVFqBiJYHoxqn5Idlf6uJPHvfBKgkjs34mo,172
509
509
  ws4redis/settings.py,sha256=K0yBiLUuY81iDM4Yr-k8hbvjn5VVHu5zQhmMK8Dtz0s,1536
510
510
  ws4redis/utf8validator.py,sha256=S0OlfjeGRP75aO6CzZsF4oTjRQAgR17OWE9rgZdMBZA,5122
511
511
  ws4redis/websocket.py,sha256=R0TUyPsoVRD7Y_oU7w2I6NL4fPwiz5Vl94-fUkZgLHA,14848
512
- django_restit-4.2.108.dist-info/LICENSE.md,sha256=VHN4hhEeVOoFjtG-5fVv4jesA4SWi0Z-KgOzzN6a1ps,1068
513
- django_restit-4.2.108.dist-info/METADATA,sha256=xjyg7k6U0iPx-OAcb3QmgJzKIMK_cRecySSJJvmlH8w,7663
514
- django_restit-4.2.108.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
515
- django_restit-4.2.108.dist-info/RECORD,,
512
+ django_restit-4.2.111.dist-info/LICENSE.md,sha256=VHN4hhEeVOoFjtG-5fVv4jesA4SWi0Z-KgOzzN6a1ps,1068
513
+ django_restit-4.2.111.dist-info/METADATA,sha256=Z7wRFxgI3NVj0LMn1EMKppq0Wo50qCh_iKbkvdFqSUA,7663
514
+ django_restit-4.2.111.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
515
+ django_restit-4.2.111.dist-info/RECORD,,
rest/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  from .uberdict import UberDict # noqa: F401
2
2
  from .settings_helper import settings # noqa: F401
3
3
 
4
- __version__ = "4.2.66"
4
+ __version__ = "4.2.111"
rest/extra/hostinfo.py CHANGED
@@ -25,13 +25,47 @@ def getTcpEstablishedCount():
25
25
  return len(getTcpEstablished())
26
26
 
27
27
 
28
- def getTcpEstablished():
28
+ def getTcpEstablished(filter=None):
29
29
  cons = psutil.net_connections(kind="tcp")
30
30
  established = []
31
31
  for c in cons:
32
32
  if c.status == "ESTABLISHED":
33
33
  established.append(c)
34
- return established
34
+ return filterConnections(established, filter)
35
+
36
+
37
+ def filterConnections(cons, filter):
38
+ if filter == "https":
39
+ return [c for c in cons if cons.laddr.port == 443]
40
+ elif filter == "redis":
41
+ return [c for c in cons if cons.raddr.port == 6379]
42
+ elif filter == "postgres":
43
+ return [c for c in cons if cons.raddr.port == 5432]
44
+ elif filter == "unknown":
45
+ return [c for c in cons if cons.raddr.port not in [5432, 6379] and cons.laddr.port != 443]
46
+ return cons
47
+
48
+
49
+ def consToDict(cons):
50
+ out = []
51
+ cid = 0
52
+ for c in cons:
53
+ cid += 1
54
+ out.append({
55
+ "id": cid,
56
+ "type": c.type.name,
57
+ "status": c.status,
58
+ "family": c.family.name,
59
+ "raddr": {
60
+ "port": c.raddr.port,
61
+ "ip": c.raddr.ip
62
+ },
63
+ "laddr": {
64
+ "port": c.laddr.port,
65
+ "ip": c.laddr.ip
66
+ }
67
+ })
68
+ return out
35
69
 
36
70
 
37
71
  def getVersions(out=None):
rest/rpc.py CHANGED
@@ -60,3 +60,13 @@ def on_get_system_info(request):
60
60
  include_blocked=request.DATA.get("blocked"))
61
61
  return views.restGet(request, out)
62
62
 
63
+
64
+ @url('system/cons')
65
+ def on_get_system_cons(request):
66
+ key = request.DATA.get("key")
67
+ if SYS_INFO_KEY is None or key != SYS_INFO_KEY:
68
+ if not ALLOW_PUBLIC_SYS_INFO and not request.user.is_authenticated:
69
+ return views.restPermissionDenied(request, "system info is not public", 565)
70
+ cons = hostinfo.getTcpEstablished(filter=request.DATA.get("filter"))
71
+ return views.restList(request, hostinfo.consToDict(cons))
72
+