make the container reboot
parent
50727c5e32
commit
90beddd823
|
@ -208,6 +208,7 @@ async def cleanupSent():
|
||||||
|
|
||||||
except:
|
except:
|
||||||
await log.error('Traceback {}'.format(traceback.format_exc()))
|
await log.error('Traceback {}'.format(traceback.format_exc()))
|
||||||
|
raise('Error al leer correos pendientes. Reiniciando servicio.')
|
||||||
return returnvalue
|
return returnvalue
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,34 +15,31 @@ class ilabHandler:
|
||||||
async def handle_HELO(self, server, session, envelope, hostname):
|
async def handle_HELO(self, server, session, envelope, hostname):
|
||||||
ip, port = session.peer
|
ip, port = session.peer
|
||||||
await log.info(u"HELO '{}'".format(hostname))
|
await log.info(u"HELO '{}'".format(hostname))
|
||||||
|
|
||||||
origen = await get_origen(ip, hostname)
|
origen = await get_origen(ip, hostname)
|
||||||
|
|
||||||
origen.sesiones = origen.sesiones + 1
|
origen.sesiones = origen.sesiones + 1
|
||||||
|
|
||||||
await log.info(u"Cliente '{}' en su {} visita".format(hostname, origen.sesiones))
|
await log.info(u"Cliente '{}' en su {} visita".format(hostname, origen.sesiones))
|
||||||
await db.commit()
|
await db.commit()
|
||||||
|
|
||||||
session.host_name = 'smtp.vpc.ilab.cl'
|
session.host_name = 'smtp.vpc.ilab.cl'
|
||||||
|
|
||||||
return '250 smtp.vpc.ilab.cl'
|
return '250 smtp.vpc.ilab.cl'
|
||||||
|
|
||||||
async def handle_RCPT(self, server, session, envelope, address, rcpt_options):
|
async def handle_RCPT(self, server, session, envelope, address, rcpt_options):
|
||||||
await log.info(u"RCPT '{}'".format(address))
|
await log.info(u"RCPT '{}'".format(address))
|
||||||
valid = False
|
|
||||||
try:
|
valid = await validate_direccion(address)
|
||||||
valid = await validate_direccion(address)
|
|
||||||
except BaseException as e:
|
|
||||||
await log.error('Traceback {}'.format(traceback.format_exc()))
|
|
||||||
|
|
||||||
if valid is None:
|
if valid is None:
|
||||||
await log.error(u"RCPT ERROR '{}' inválido".format(address))
|
await log.error(u"RCPT ERROR '{}' inválido".format(address))
|
||||||
return '501 5.5.4 destinatario invalido'
|
return '501 5.5.4 destinatario invalido'
|
||||||
|
|
||||||
envelope.rcpt_tos.append(address)
|
envelope.rcpt_tos.append(address)
|
||||||
|
|
||||||
return '250 OK'
|
return '250 OK'
|
||||||
|
|
||||||
async def handle_DATA(self, server, session, envelope):
|
async def handle_DATA(self, server, session, envelope):
|
||||||
# await log.debug(u"DATA FROM '{}'".format(envelope.mail_from))
|
# await log.debug(u"DATA FROM '{}'".format(envelope.mail_from))
|
||||||
# await log.debug(u"DATA RCPT TOs '{}'".format(', '.join(envelope.rcpt_tos)))
|
# await log.debug(u"DATA RCPT TOs '{}'".format(', '.join(envelope.rcpt_tos)))
|
||||||
|
@ -52,25 +49,25 @@ class ilabHandler:
|
||||||
# data = envelope.content # type: bytes
|
# data = envelope.content # type: bytes
|
||||||
ip, port = session.peer
|
ip, port = session.peer
|
||||||
origen = await get_origen(ip, session.host_name)
|
origen = await get_origen(ip, session.host_name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dbremitente = await validate_direccion(str(envelope.mail_from))
|
dbremitente = await validate_direccion(str(envelope.mail_from))
|
||||||
dbcarta = Carta(remitente=dbremitente, contenido=envelope.content.decode('utf-8'))
|
dbcarta = Carta(remitente=dbremitente, contenido=envelope.content.decode('utf-8'))
|
||||||
db.add(dbcarta)
|
db.add(dbcarta)
|
||||||
await db.commit()
|
await db.commit()
|
||||||
|
|
||||||
for destinatario in envelope.rcpt_tos:
|
for destinatario in envelope.rcpt_tos:
|
||||||
dbdestinatario = await validate_direccion(str(destinatario))
|
dbdestinatario = await validate_direccion(str(destinatario))
|
||||||
dest = Destinatario(correo=dbdestinatario, carta=dbcarta, enviado=0, intentos=0)
|
dest = Destinatario(correo=dbdestinatario, carta=dbcarta, enviado=0, intentos=0)
|
||||||
db.add(dest)
|
db.add(dest)
|
||||||
|
|
||||||
origen.recibidos = origen.recibidos + 1
|
origen.recibidos = origen.recibidos + 1
|
||||||
|
|
||||||
await db.commit()
|
await db.commit()
|
||||||
await log.info(u"Correo: '{}'->'{}'".format(envelope.mail_from, ', '.join(envelope.rcpt_tos)))
|
await log.info(u"Correo: '{}'->'{}'".format(envelope.mail_from, ', '.join(envelope.rcpt_tos)))
|
||||||
|
|
||||||
except:
|
except:
|
||||||
await log.error('Traceback {}'.format(traceback.format_exc()))
|
await log.error('Traceback {}'.format(traceback.format_exc()))
|
||||||
return '500 Error interno, reintentelo'
|
return '500 Error interno, reintentelo'
|
||||||
|
|
||||||
return '250 OK'
|
return '250 OK'
|
||||||
|
|
Loading…
Reference in New Issue