django-restit 4.2.140__py3-none-any.whl → 4.2.143__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: django-restit
3
- Version: 4.2.140
3
+ Version: 4.2.143
4
4
  Summary: A Rest Framework for DJANGO
5
5
  License: MIT
6
6
  Author: Ian Starnes
@@ -96,6 +96,8 @@ inbox/utils/render.py,sha256=CU_F2qUBQE7mjb9Q6Dn9ro5CS_O_zEY-wDMHEClKkIA,4331
96
96
  inbox/utils/sending.py,sha256=BKelTZnbkdSLGpjOY6IRTrzj-Hnw2pPZ7RYQGwe-tqk,2179
97
97
  incident/README.md,sha256=4vbZTJj7uUmq8rogYngxqNYjFTlBOujfWUGheLoFKMc,1114
98
98
  incident/__init__.py,sha256=xgdt3z3z7ygjWv5HxhiWgBtB2W3IUJmmR88NSyUeHuo,3455
99
+ incident/extra/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
100
+ incident/extra/abuse.py,sha256=TaNs1mF7L2ijoAl5iyEX1BaUgaOwsCeeF2_zwj4RSF0,4301
99
101
  incident/migrations/0001_initial.py,sha256=KmJRau3a2QFRaUwUrFUgY2p7FQZCODv3F-Sl0ZArpu0,9720
100
102
  incident/migrations/0002_event_component_event_component_id.py,sha256=Qfu3ndJKh4v7953ULTUZlSa3mVI-lnFIq9VFN1Rbs7Q,595
101
103
  incident/migrations/0003_rule_action.py,sha256=LNqV52qOjxxe3L8qEdln-Hd2voFcpyjOZ_cEsasrv7s,425
@@ -113,15 +115,15 @@ incident/migrations/0014_event_group_alter_rulecheck_index.py,sha256=v3gm5k0LVoa
113
115
  incident/migrations/0015_rule_title_template_alter_incident_state.py,sha256=FPUDhFwqBC39EjeknRT7BPddEf6ExCjsXVb9LMqIn3U,687
114
116
  incident/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
115
117
  incident/models/__init__.py,sha256=NMphuhb0RTMf7Ov4QkNv7iv6_I8Wtr3xQ54yjX_a31M,209
116
- incident/models/event.py,sha256=LNKYdqOj_CO4aGvc2dNmy3K-S52Udi_gZ4-wintbs1s,7901
117
- incident/models/incident.py,sha256=_pzAyUC-RgwrCF-hOIOUDLhdG9koTqZK8pOltBZx48o,21143
118
+ incident/models/event.py,sha256=mk5IQgxtwkLKJEpwIHwO0c45X4CfwqqIN-aI5lJPVBg,7944
119
+ incident/models/incident.py,sha256=n5S-QzGvAOtJmlzbj3vPTY03avIknPjDMLUUq9FyTa0,21648
118
120
  incident/models/ossec.py,sha256=eUDRGawzuLWobKEVGKfdZisDnyjS_Hlxi0T_GCSLCCI,2252
119
121
  incident/models/rules.py,sha256=aRkJ0ZnTv87nAUC1sHVkPExfb3OJ8fgHQIhnCIpIbhQ,7001
120
122
  incident/models/ticket.py,sha256=S3kqGQpYLE6Y4M9IKu_60sgW-f592xNr8uufqHnvDoU,2302
121
123
  incident/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
122
124
  incident/parsers/ossec.py,sha256=fouUsSnrdkEuqDzJ-MxmCP7ny5pCGFS3Tyf6lQSMBc4,11609
123
125
  incident/periodic.py,sha256=eX1rQK6v65A9ugofTvJPSmAWei6C-3EYgzCMuGZ03jM,381
124
- incident/rpc.py,sha256=6JVWTTAr4CN2tAjjIUcXug1z3RhU_ar5CDLzedkduA4,8187
126
+ incident/rpc.py,sha256=rCFVWhWjaRHBLvlpxs-TlnkCNLsP9n6V3tg4KpYNHfg,8747
125
127
  incident/templates/email/incident_change.html,sha256=tQYphypwLukkVdwH0TB2Szz2VEJ7GnsfRS3_ZJ-MYeE,13895
126
128
  incident/templates/email/incident_msg.html,sha256=MZdKhTddUF2MpiH8Z3RTQEmW_ko1n3ajeZ11KLtiLlU,13780
127
129
  incident/templates/email/incident_new.html,sha256=W6nwFQROnyDfMlXub8s02ws4hGnJp16pfgp9xTm_aEc,15185
@@ -377,7 +379,7 @@ pushit/utils.py,sha256=IeTCGa-164nmB1jIsK1lu1O1QzUhS3BKfuXHGjCW-ck,2121
377
379
  rest/.gitignore,sha256=TbEvWRMnAiajCTOdhiNrd9eeCAaIjRp9PRjE_VkMM5g,118
378
380
  rest/README.md,sha256=V3ETc-cJu8PZIbKr9xSe_pA4JEUpC8Dhw4bQeVCDJPw,5460
379
381
  rest/RemoteEvents.py,sha256=nL46U7AuxIrlw2JunphR1tsXyqi-ep_gD9CYGpYbNgE,72
380
- rest/__init__.py,sha256=yQq_7suWzN5e9qoX3OzN7p2okHfUo9n0Rp3W6ZvVR0s,122
382
+ rest/__init__.py,sha256=GJheIdY4xT-lMdgerrt-HFxPfsw3oPkVEAJYFBauwss,122
381
383
  rest/arc4.py,sha256=y644IbF1ec--e4cUJ3KEYsewTCITK0gmlwa5mJruFC0,1967
382
384
  rest/cache.py,sha256=1Qg0rkaCJCaVP0-l5hZg2CIblTdeBSlj_0fP6vlKUpU,83
383
385
  rest/crypto/__init__.py,sha256=Tl0U11rgj1eBYqd6OXJ2_XSdNLumW_JkBZnaJqI6Ldw,72
@@ -416,7 +418,7 @@ rest/models/metadata.py,sha256=1nQ7CYo9bJHoaXE_hVNaj1-Y7yqhHlf2ZlaD1IfTzic,12904
416
418
  rest/net.py,sha256=LcB2QV6VNRtsSdmiQvYZgwQUDwOPMn_VBdRiZ6OpI-I,2974
417
419
  rest/regexes.yaml,sha256=VoGb4E-P_K9f82Yzcpltgzekpt9usRtwu9PYlo46nUw,149463
418
420
  rest/requestex.py,sha256=N56056vV3zWkAP-QrYsCu7SdpPzE5kLuPoxGIuZAKt0,16127
419
- rest/rpc.py,sha256=xun-HuaEqm1Lwg-9Xm4Y2JwOf8wTdpoagHuIUNlqTlI,2891
421
+ rest/rpc.py,sha256=CNQ2RtAPOYxZtpZxjh0sVzBmIGBYMP7n3CDEDwMENF0,2966
420
422
  rest/search.py,sha256=QVjk2b5tZLgf1zM2MHvJTyRjwUbY5ZD7HXSTmSPXtvU,8362
421
423
  rest/serializers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
422
424
  rest/serializers/collection.py,sha256=V9O4qxw26VX9dSYdbsN0-RNnXEi347Ln8eFLZ003LhA,4646
@@ -469,7 +471,7 @@ taskqueue/transports/http.py,sha256=AzliUnw_LuyO2zZZOoUAJGFcTV-Gxt1iE3hCVnIiyGQ,
469
471
  taskqueue/transports/s3.py,sha256=fMosL893u1iQdo6Y1djwb7KEoNo6TTsDPJl13OJdJP8,1913
470
472
  taskqueue/transports/sftp.py,sha256=jT1_krjTHA7DCAukD85aGYRCg9m0cEH9EWzOC-wJGdk,1891
471
473
  taskqueue/transports/sms.py,sha256=H1-LIGEMfbUNqJD9amRcsvKUSwtz9yBj1QNfB7EHjHE,142
472
- taskqueue/worker.py,sha256=wzp44fk6LX94MdrXLp_IJmWgutLCBKqoobk433OiLqw,15822
474
+ taskqueue/worker.py,sha256=1YBeTOziUBtgjtgjiwf5ULFrJAfizqxvHxgWomhgtWs,15655
473
475
  telephony/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
474
476
  telephony/admin.py,sha256=iOdsBfFFbBisdqKSZ36bIrh_z5sU0Wx_PkaFi8wd1iA,243
475
477
  telephony/decorators.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -502,10 +504,10 @@ wiki/rpc/wiki.py,sha256=RQY1gtqxdNhp13n3SkZL9WZ6RatrtCIh7QOYta6-UUU,1327
502
504
  wiki/tq.py,sha256=wvuBZ3OMV_D2o4kpJhVLIOwpEUfwlglqLJQvpncAwtk,313
503
505
  ws4redis/README.md,sha256=QvwdsauPKxx4qQqnJ991xeU8DgFQCj3CeQt-nCE4s-w,3624
504
506
  ws4redis/__init__.py,sha256=teNfv83A_ke1CBt9BB7NsnWCcFBhnUFPsPESjF554_k,46
505
- ws4redis/client.py,sha256=kElPtVMVObLUXAfu32v_PHd0HyygrW-ukk37_Tuo7ZM,7062
506
- ws4redis/connection.py,sha256=rlzdmgyjmuqETxjNf3uZU3tfoBeQQTzD4ZFru_u3JAs,13738
507
+ ws4redis/client.py,sha256=HTntgqlMzZU9MhBz3fn3fXDpzfaTDZx_9tIb5SU91hY,7077
508
+ ws4redis/connection.py,sha256=HeRrQUxNYMJ-2SSSYB2XBHScKRbQRMCuQueDSUDJXXQ,13740
507
509
  ws4redis/exceptions.py,sha256=EGLoRTdqJVwz900pwhciqPuSjBBd08hhLgFu6umHrI4,636
508
- ws4redis/redis.py,sha256=IfT4p3bUtlqso9rryNliH9Ebzlx8-Q2VJcs1kFioeGA,6093
510
+ ws4redis/redis.py,sha256=jHfwpUG0Nru_zSyD-xwJhX67gASqVtTFiAc3RwgTcJs,6542
509
511
  ws4redis/servers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
510
512
  ws4redis/servers/base.py,sha256=3nYZF5jSsQxNLbnLtKLFJ82xJs_Mc7N1H2kEOx8wT6o,3747
511
513
  ws4redis/servers/django.py,sha256=cKOE4U0cE8I3_rDaLgv-KuDb376RASdOzUn7MlDA4As,5900
@@ -513,7 +515,7 @@ ws4redis/servers/uwsgi.py,sha256=VyhoCI1DnVFqBiJYHoxqn5Idlf6uJPHvfBKgkjs34mo,172
513
515
  ws4redis/settings.py,sha256=KKq00EwoGnz1yLwCZr5Dfoq2izivmAdsNEEM4EhZwN4,1610
514
516
  ws4redis/utf8validator.py,sha256=S0OlfjeGRP75aO6CzZsF4oTjRQAgR17OWE9rgZdMBZA,5122
515
517
  ws4redis/websocket.py,sha256=R0TUyPsoVRD7Y_oU7w2I6NL4fPwiz5Vl94-fUkZgLHA,14848
516
- django_restit-4.2.140.dist-info/LICENSE.md,sha256=VHN4hhEeVOoFjtG-5fVv4jesA4SWi0Z-KgOzzN6a1ps,1068
517
- django_restit-4.2.140.dist-info/METADATA,sha256=GQO5bs9dpHrS_uY2j0m8maJ6xr5TiAKkn3F4Nh7A2eI,7663
518
- django_restit-4.2.140.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
519
- django_restit-4.2.140.dist-info/RECORD,,
518
+ django_restit-4.2.143.dist-info/LICENSE.md,sha256=VHN4hhEeVOoFjtG-5fVv4jesA4SWi0Z-KgOzzN6a1ps,1068
519
+ django_restit-4.2.143.dist-info/METADATA,sha256=FpgN7kXRO3P4WCA8vaKZHxvyRcQRuhLyXH3la6TydgQ,7663
520
+ django_restit-4.2.143.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
521
+ django_restit-4.2.143.dist-info/RECORD,,
File without changes
@@ -0,0 +1,125 @@
1
+ import requests
2
+ import ipaddress
3
+ from objict import objict
4
+ from rest import settings
5
+ from datetime import datetime
6
+ from enum import Enum
7
+
8
+ API_KEY = settings.get("ABUSEIPDB_KEY", "")
9
+
10
+ DEFAULT_HEADERS = {
11
+ 'Accept': 'application/json',
12
+ 'Key': API_KEY
13
+ }
14
+
15
+
16
+ class AbuseCategory(Enum):
17
+ DNS_COMPROMISE = (1, "Altering DNS records resulting in improper redirection.")
18
+ DNS_POISONING = (2, "Falsifying domain server cache (cache poisoning).")
19
+ FRAUD_ORDERS = (3, "Fraudulent orders.")
20
+ DDOS_ATTACK = (4, "Participating in distributed denial-of-service (usually part of botnet).")
21
+ FTP_BRUTE_FORCE = (5, "FTP Brute-Force")
22
+ PING_OF_DEATH = (6, "Oversized IP packet.")
23
+ PHISHING = (7, "Phishing websites and/or email.")
24
+ FRAUD_VOIP = (8, "Fraud VoIP")
25
+ OPEN_PROXY = (9, "Open proxy, open relay, or Tor exit node.")
26
+ WEB_SPAM = (10, "Comment/forum spam, HTTP referer spam, or other CMS spam.")
27
+ EMAIL_SPAM = (11, "Spam email content, infected attachments, and phishing emails.")
28
+ BLOG_SPAM = (12, "CMS blog comment spam.")
29
+ VPN_IP = (13, "Conjunctive category.")
30
+ PORT_SCAN = (14, "Scanning for open ports and vulnerable services.")
31
+ HACKING = (15, "Hacking")
32
+ SQL_INJECTION = (16, "Attempts at SQL injection.")
33
+ SPOOFING = (17, "Email sender spoofing.")
34
+ BRUTE_FORCE = (18, "Credential brute-force attacks on webpage logins and services.")
35
+ BAD_WEB_BOT = (19, "Webpage scraping and crawlers that do not honor robots.txt.")
36
+ EXPLOITED_HOST = (20, "Host is likely infected with malware and being used for other attacks.")
37
+ WEB_APP_ATTACK = (21, "Attempts to probe for or exploit installed web applications.")
38
+ SSH = (22, "Secure Shell (SSH) abuse.")
39
+ IOT_TARGETED = (23, "Abuse targeted at an 'Internet of Things' type device.")
40
+
41
+ def __init__(self, code, description):
42
+ self.code = code
43
+ self.description = description
44
+
45
+ def __str__(self):
46
+ return f"{self.name} ({self.code}): {self.description}"
47
+
48
+
49
+ def lookup(ip, max_days=0):
50
+ """
51
+ {
52
+ "data": {
53
+ "ipAddress": "118.25.6.39",
54
+ "isPublic": true,
55
+ "ipVersion": 4,
56
+ "isWhitelisted": false,
57
+ "abuseConfidenceScore": 100,
58
+ "countryCode": "CN",
59
+ "countryName": "China",
60
+ "usageType": "Data Center/Web Hosting/Transit",
61
+ "isp": "Tencent Cloud Computing (Beijing) Co. Ltd",
62
+ "domain": "tencent.com",
63
+ "hostnames": [],
64
+ "isTor": false,
65
+ "totalReports": 1,
66
+ "numDistinctUsers": 1,
67
+ "lastReportedAt": "2018-12-20T20:55:14+00:00",
68
+ "reports": [
69
+ {
70
+ "reportedAt": "2018-12-20T20:55:14+00:00",
71
+ "comment": "Dec 20 20:55:14 srv206 sshd[13937]: Invalid user oracle from 118.25.6.39",
72
+ "categories": [
73
+ 18,
74
+ 22
75
+ ],
76
+ "reporterId": 1,
77
+ "reporterCountryCode": "US",
78
+ "reporterCountryName": "United States"
79
+ }
80
+ ]
81
+ }
82
+ }
83
+ """
84
+ if not API_KEY:
85
+ return objict(errors=[{"detail": "Missing API KEY", "status": 401}])
86
+ url = 'https://api.abuseipdb.com/api/v2/check'
87
+ params = dict(ipAddress=ip)
88
+ if max_days:
89
+ params["maxAgeInDays"] = max_days
90
+ response = requests.request(
91
+ method='GET', url=url, headers=DEFAULT_HEADERS,
92
+ params=params)
93
+ return objict.fromJSON(response.text)
94
+
95
+
96
+ def reportAbuse(ip, comment, categories):
97
+ """
98
+ {
99
+ "data": {
100
+ "ipAddress": "127.0.0.1",
101
+ "abuseConfidenceScore": 52
102
+ }
103
+ }
104
+ """
105
+ if not API_KEY:
106
+ return objict(errors=[{"detail": "Missing API KEY", "status": 401}])
107
+ url = 'https://api.abuseipdb.com/api/v2/report'
108
+ now_str = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
109
+ params = dict(ip=ip, comment=comment, timestamp=now_str, categories=categories)
110
+ response = requests.request(
111
+ method='POST', url=url,
112
+ headers=DEFAULT_HEADERS, params=params)
113
+ return objict.fromJSON(response.text)
114
+
115
+
116
+ def isPrivate(ip, ignore_errors=False):
117
+ if not ignore_errors:
118
+ ip_obj = ipaddress.ip_address(ip)
119
+ return ip_obj.is_private
120
+ try:
121
+ ip_obj = ipaddress.ip_address(ip)
122
+ return ip_obj.is_private
123
+ except Exception:
124
+ pass
125
+ return None
incident/models/event.py CHANGED
@@ -193,6 +193,7 @@ class Event(JSONMetaData, rm.RestModel):
193
193
  incident.description = self.description
194
194
  elif self.category == "ossec":
195
195
  incident.description = f"{self.hostname}: {self.description}"
196
+ incident.updateAbuseInfo()
196
197
  else:
197
198
  incident.description = self.description
198
199
  incident.save()
@@ -10,6 +10,7 @@ from datetime import datetime, timedelta
10
10
  from rest import log
11
11
  from ws4redis import client as ws4redis
12
12
  import time
13
+ from incident.extra import abuse
13
14
 
14
15
  logger = log.getLogger("incident", filename="incident.log")
15
16
 
@@ -483,6 +484,19 @@ class Incident(models.Model, rm.RestModel, rm.MetaDataModel):
483
484
  email_only=True,
484
485
  from_email=INCIDENT_EMAIL_FROM)
485
486
 
487
+ def updateAbuseInfo(self, ip=None):
488
+ # for now we just check if this ip is in the abuse ip db
489
+ if ip is None:
490
+ ip = self.reporter_ip
491
+ is_priv = abuse.isPrivate(ip, ignore_errors=True)
492
+ if is_priv is not None:
493
+ self.setProperty("is_private_ip", is_priv)
494
+ if is_priv:
495
+ return
496
+ info = abuse.lookup(ip, 0)
497
+ if "errors" not in info:
498
+ self.setProperty("abuse_info", info)
499
+
486
500
  @classmethod
487
501
  def getBundled(cls, rule, event):
488
502
  # calculate our bundle start time
incident/rpc.py CHANGED
@@ -3,6 +3,7 @@ from rest import views as rv
3
3
  from rest import helpers as rh
4
4
  from rest import settings
5
5
  from . import models as am
6
+ from .extra import abuse
6
7
  from .parsers import ossec
7
8
  from taskqueue.models import Task
8
9
  import incident
@@ -234,3 +235,20 @@ def rest_firewall_block(request):
234
235
  @rd.url('ticket/<int:pk>')
235
236
  def rest_on_ticket(request, pk=None):
236
237
  return am.Ticket.on_rest_request(request, pk)
238
+
239
+
240
+ @rd.urlGET('abuse/lookup')
241
+ @rd.requires_params(["ip"])
242
+ def rest_on_abuse_ip_lookup(request):
243
+ resp = abuse.lookup(request.DATA.get("ip"), request.DATA.get("max_age", 0))
244
+ return rv.restReturn(request, resp)
245
+
246
+
247
+ @rd.urlPOST('abuse/report')
248
+ @rd.requires_params(["ip", "comment", "categories"])
249
+ def rest_on_report_abuse(request):
250
+ resp = abuse.reportAbuse(
251
+ ip=request.DATA.get("ip"),
252
+ comment=request.DATA.get("comment"),
253
+ categories=request.DATA.get("categories"))
254
+ return rv.restReturn(request, resp)
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.140"
4
+ __version__ = "4.2.143"
rest/rpc.py CHANGED
@@ -58,7 +58,7 @@ def on_get_status(request):
58
58
  flag = redis.ping()
59
59
  except Exception:
60
60
  flag = False
61
- status = dict(redis=flag, database={})
61
+ status = dict(redis=flag, database={}, pool=redis.getPoolStatus())
62
62
  for alias in settings.DATABASES.keys():
63
63
  db_conn = connections[alias]
64
64
  try:
@@ -81,6 +81,7 @@ def on_get_system_info(request):
81
81
  out = hostinfo.getHostInfo(
82
82
  include_versions=request.DATA.get("versions") and SOFTWARE_VERSIONS,
83
83
  include_blocked=request.DATA.get("blocked"))
84
+ out["redist_pool"] = redis.getPoolStatus()
84
85
  return views.restGet(request, out)
85
86
 
86
87
 
taskqueue/worker.py CHANGED
@@ -1,23 +1,16 @@
1
-
2
- import requests
3
1
  import threading
4
2
  from concurrent import futures
5
3
 
6
- from redis import ConnectionPool, StrictRedis
7
- from ws4redis import settings as ws4redis_settings
8
-
9
- redis_connection_pool = ConnectionPool(**ws4redis_settings.WS4REDIS_CONNECTION)
4
+ # from redis import ConnectionPool, StrictRedis
5
+ from ws4redis.redis import getRedisClient, getPoolStatus
6
+ from objict import nobjict
10
7
 
11
- def getRedisClient():
12
- return StrictRedis(connection_pool=redis_connection_pool)
13
8
 
14
9
  from .models import redis, Task, TASK_STATE_STARTED
15
10
  from .transports import email, http, sftp, sms, s3
16
11
  from rest import helpers
17
12
  from rest.log import getLogger
18
13
  from rest import settings
19
- from objict import nobjict
20
- from datetime import datetime, timedelta
21
14
  import time
22
15
 
23
16
 
@@ -238,6 +231,7 @@ class WorkManager(object):
238
231
  data.running = self._running_count
239
232
  data.pending = self._pending_count
240
233
  data.scheduled = len(self._scheduled_tasks.keys())
234
+ data.pool = dict(**getPoolStatus())
241
235
  redis.publish(event.data.response_channel, data)
242
236
 
243
237
  def on_task_started(self, task):
ws4redis/client.py CHANGED
@@ -2,7 +2,7 @@ import time
2
2
 
3
3
  from rest import UberDict
4
4
 
5
- from ws4redis.redis import RedisMessage, RedisStore, getRedisClient
5
+ from ws4redis.redis import RedisMessage, RedisStore, getRedisClient, getPoolStatus
6
6
 
7
7
 
8
8
  def buildEventMessage(name=None, message=None, priority=0, model=None, model_pk=None, custom=None):
ws4redis/connection.py CHANGED
@@ -286,7 +286,7 @@ class WebsocketConnection():
286
286
  if bool(self.last_msg):
287
287
  self.on_ws_msg(self.last_msg)
288
288
  except Exception:
289
- logger.exception()
289
+ # logger.exception()
290
290
  logger.error("unable to recv on ws... flushing")
291
291
  self.websocket.flush()
292
292
 
ws4redis/redis.py CHANGED
@@ -17,6 +17,18 @@ def getRedisClient():
17
17
  return StrictRedis(connection_pool=REDIS_CON_POOL)
18
18
 
19
19
 
20
+ # Function to check the number of connections in use and available
21
+ def getPoolStatus():
22
+ status = UberDict()
23
+ if REDIS_CON_POOL is None:
24
+ return status
25
+ status.max_size = REDIS_CON_POOL.max_connections
26
+ status.size = REDIS_CON_POOL._created_connections
27
+ status.in_use = len(REDIS_CON_POOL._in_use_connections)
28
+ status.available = len(REDIS_CON_POOL._available_connections)
29
+ return status
30
+
31
+
20
32
  class RedisMessage(bytes):
21
33
  def __new__(cls, value):
22
34
  if isinstance(value, str):
@@ -156,6 +168,7 @@ class RedisStore():
156
168
  if self.pubsub and self.pubsub.subscribed:
157
169
  self.pubsub.unsubscribe()
158
170
  self.pubsub.reset()
171
+ self.connection = None
159
172
 
160
173
  def __enter__(self):
161
174
  return self