fix anti-spam
This commit is contained in:
		
							parent
							
								
									03ee9a1e0b
								
							
						
					
					
						commit
						5d6574fb37
					
				
					 2 changed files with 5 additions and 6 deletions
				
			
		|  | @ -42,7 +42,7 @@ class Processor(Thread): | |||
|             try: | ||||
|                 msg = queue.get() | ||||
|                 if msg['request'] == 'new_comment': | ||||
|                     new_comment(msg['data']) | ||||
|                     new_comment(msg['data'], msg.get('clientip', '')) | ||||
|                 elif msg['request'] == 'new_mail': | ||||
|                     reply_comment_email(msg['data']) | ||||
|                 elif msg['request'] == 'unsubscribe': | ||||
|  | @ -59,7 +59,7 @@ class Processor(Thread): | |||
|                 logger.exception("processing failure") | ||||
| 
 | ||||
| 
 | ||||
| def new_comment(data): | ||||
| def new_comment(data, clientip): | ||||
| 
 | ||||
|     logger.info('new comment received: %s' % data) | ||||
| 
 | ||||
|  | @ -70,7 +70,6 @@ def new_comment(data): | |||
|     author_site = data.get('site', '').strip() | ||||
|     message = data.get('message', '') | ||||
|     subscribe = data.get('subscribe', '') | ||||
|     clientip = data.get('clientip', '') | ||||
| 
 | ||||
|     # private mode: email contains gravar md5 hash | ||||
|     if config.security['private']: | ||||
|  |  | |||
|  | @ -18,9 +18,9 @@ def new_form_comment(): | |||
|         data = request.form | ||||
| 
 | ||||
|         # add client IP if provided by HTTP proxy | ||||
|         logger.info('headers: {}'.format(request.headers)) | ||||
|         clientip = '' | ||||
|         if 'X-Forwarded-For' in request.headers: | ||||
|             data['clientip'] = request.headers['X-Forwarded-For'] | ||||
|             clientip = request.headers['X-Forwarded-For'] | ||||
|          | ||||
|         # log  | ||||
|         logger.info(data) | ||||
|  | @ -38,7 +38,7 @@ def new_form_comment(): | |||
|             logger.warn('discard spam: data %s' % data) | ||||
|             abort(400) | ||||
| 
 | ||||
|         processor.enqueue({'request': 'new_comment', 'data': data}) | ||||
|         processor.enqueue({'request': 'new_comment', 'data': data, 'clientip': clientip}) | ||||
| 
 | ||||
|     except: | ||||
|         logger.exception("new comment failure") | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Yax
						Yax