mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-12-26 08:39:08 +01:00
commit
7b07f56972
@ -39,4 +39,6 @@ Before django-helpdesk will be much use, you need to do some basic configuration
|
||||
EMAIL_HOST_USER = 'YYYYYY@ZZZZ.PPP'
|
||||
EMAIL_HOST_PASSWORD = '123456'
|
||||
|
||||
8. If you wish to use SOCKS4/5 proxy with Helpdesk Queue email operations, install PySocks manually.
|
||||
|
||||
You're now up and running! Happy ticketing.
|
||||
|
@ -15,6 +15,7 @@ import imaplib
|
||||
import mimetypes
|
||||
import poplib
|
||||
import re
|
||||
import socket
|
||||
|
||||
from datetime import timedelta
|
||||
from email.header import decode_header
|
||||
@ -84,6 +85,22 @@ def process_queue(q, quiet=False):
|
||||
if not quiet:
|
||||
print "Processing: %s" % q
|
||||
|
||||
if q.socks_proxy_type and q.socks_proxy_host and q.socks_proxy_port:
|
||||
try:
|
||||
import socks
|
||||
except ImportError:
|
||||
raise ImportError("Queue has been configured with proxy settings, but no socks library was installed. Try to install PySocks via pypi.")
|
||||
|
||||
proxy_type = {
|
||||
'socks4': socks.SOCKS4,
|
||||
'socks5': socks.SOCKS5,
|
||||
}.get(q.socks_proxy_type)
|
||||
|
||||
socks.set_default_proxy(proxy_type=proxy_type, addr=q.socks_proxy_host, port=q.socks_proxy_port)
|
||||
socket.socket = socks.socksocket
|
||||
else:
|
||||
socket.socket = socket._socketobject
|
||||
|
||||
email_box_type = settings.QUEUE_EMAIL_BOX_TYPE if settings.QUEUE_EMAIL_BOX_TYPE else q.email_box_type
|
||||
|
||||
if email_box_type == 'pop3':
|
||||
|
32
helpdesk/migrations/0002_socks_proxy.py
Normal file
32
helpdesk/migrations/0002_socks_proxy.py
Normal file
@ -0,0 +1,32 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('helpdesk', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='queue',
|
||||
name='socks_proxy_host',
|
||||
field=models.GenericIPAddressField(help_text='Socks proxy IP address. Default: 127.0.0.1', null=True, verbose_name='Socks Proxy Host', blank=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='queue',
|
||||
name='socks_proxy_port',
|
||||
field=models.IntegerField(help_text='Socks proxy port number. Default: 9150 (default TOR port)', null=True, verbose_name='Socks Proxy Port', blank=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='queue',
|
||||
name='socks_proxy_type',
|
||||
field=models.CharField(choices=[(b'socks4', 'SOCKS4'), (b'socks5', 'SOCKS5')], max_length=8, blank=True, help_text='SOCKS4 or SOCKS5 allows you to proxy your connections through a SOCKS server.', null=True, verbose_name='Socks Proxy Type'),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
@ -178,6 +178,29 @@ class Queue(models.Model):
|
||||
# This is updated by management/commands/get_mail.py.
|
||||
)
|
||||
|
||||
socks_proxy_type = models.CharField(
|
||||
_('Socks Proxy Type'),
|
||||
max_length=8,
|
||||
choices=(('socks4', _('SOCKS4')), ('socks5', _('SOCKS5'))),
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text=_('SOCKS4 or SOCKS5 allows you to proxy your connections through a SOCKS server.'),
|
||||
)
|
||||
|
||||
socks_proxy_host = models.GenericIPAddressField(
|
||||
_('Socks Proxy Host'),
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text=_('Socks proxy IP address. Default: 127.0.0.1'),
|
||||
)
|
||||
|
||||
socks_proxy_port = models.IntegerField(
|
||||
_('Socks Proxy Port'),
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text=_('Socks proxy port number. Default: 9150 (default TOR port)'),
|
||||
)
|
||||
|
||||
def __unicode__(self):
|
||||
return u"%s" % self.title
|
||||
|
||||
@ -202,6 +225,15 @@ class Queue(models.Model):
|
||||
if self.email_box_type == 'imap' and not self.email_box_imap_folder:
|
||||
self.email_box_imap_folder = 'INBOX'
|
||||
|
||||
if self.socks_proxy_type:
|
||||
if not self.socks_proxy_host:
|
||||
self.socks_proxy_host = '127.0.0.1'
|
||||
if not self.socks_proxy_port:
|
||||
self.socks_proxy_port = 9150
|
||||
else:
|
||||
self.socks_proxy_host = None
|
||||
self.socks_proxy_port = None
|
||||
|
||||
if not self.email_box_port:
|
||||
if self.email_box_type == 'imap' and self.email_box_ssl:
|
||||
self.email_box_port = 993
|
||||
|
Loading…
Reference in New Issue
Block a user