2022-03-08 19:42:28 +01:00
|
|
|
from crypt import crypt as _crypt
|
|
|
|
from string import ascii_letters as _ascii_letters, digits as _digits
|
|
|
|
from secrets import choice as _choice
|
2022-03-29 16:30:38 +02:00
|
|
|
from risotto.utils import multi_function as _multi_function
|
2022-03-08 19:42:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
def sha512_crypt(password):
|
|
|
|
salt = ''.join([_choice(_ascii_letters + _digits) for _ in range(8)])
|
|
|
|
prefix = '$6$'
|
|
|
|
return _crypt(password, prefix + salt)
|
2022-03-29 16:30:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
@_multi_function
|
2022-08-18 10:19:43 +02:00
|
|
|
def calc_domains(domains):
|
2022-03-29 16:30:38 +02:00
|
|
|
ret = []
|
2022-08-18 10:19:43 +02:00
|
|
|
for domain in domains:
|
|
|
|
ret.append(domain)
|
|
|
|
ret.append(domain)
|
|
|
|
ret.append(f'autoconfig.{domain}')
|
2022-03-29 16:30:38 +02:00
|
|
|
return ret
|
2022-08-18 10:19:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
@_multi_function
|
|
|
|
def calc_locations(domain, index):
|
|
|
|
i = index//3
|
|
|
|
if 3 * i == index:
|
|
|
|
# divisible by three
|
|
|
|
return '/autodiscover/autodiscover.xml'
|
|
|
|
elif 3 * i + 1 == index:
|
|
|
|
return '/.well-known/autoconfig/mail/config-v1.1.xml'
|
|
|
|
return '/mail/config-v1.1.xml'
|
|
|
|
|
|
|
|
|
|
|
|
@_multi_function
|
|
|
|
def calc_well_known(index, dns, doms):
|
|
|
|
if None in (dns, doms):
|
|
|
|
return None
|
|
|
|
i = index//3
|
|
|
|
return f'https://{dns}/mail/{doms[i]}/autodiscover/autodiscover.xml'
|