@ -52,13 +52,19 @@ DEFAULT_CONFIG = {
' RECAPTCHA_PRIVATE_KEY ' : ' ' ,
' RECAPTCHA_PRIVATE_KEY ' : ' ' ,
# Advanced settings
# Advanced settings
' PASSWORD_SCHEME ' : ' BLF-CRYPT ' ,
' PASSWORD_SCHEME ' : ' BLF-CRYPT ' ,
' LOG_LEVEL ' : ' WARNING ' ,
# Host settings
# Host settings
' HOST_IMAP ' : ' imap ' ,
' HOST_IMAP ' : ' imap ' ,
' HOST_LMTP ' : ' imap:2525 ' ,
' HOST_POP3 ' : ' imap ' ,
' HOST_POP3 ' : ' imap ' ,
' HOST_SMTP ' : ' smtp ' ,
' HOST_SMTP ' : ' smtp ' ,
' HOST_AUTHSMTP ' : ' smtp ' ,
' HOST_ADMIN ' : ' admin ' ,
' HOST_ANTISPAM ' : ' antispam:11334 ' ,
' HOST_WEBMAIL ' : ' webmail ' ,
' HOST_WEBMAIL ' : ' webmail ' ,
' HOST_WEBDAV ' : ' webdav:5232 ' ,
' HOST_REDIS ' : ' redis ' ,
' HOST_FRONT ' : ' front ' ,
' HOST_FRONT ' : ' front ' ,
' HOST_AUTHSMTP ' : os . environ . get ( ' HOST_SMTP ' , ' smtp ' ) ,
' SUBNET ' : ' 192.168.203.0/24 ' ,
' SUBNET ' : ' 192.168.203.0/24 ' ,
' POD_ADDRESS_RANGE ' : None
' POD_ADDRESS_RANGE ' : None
}
}
@ -73,7 +79,7 @@ class ConfigManager(dict):
' mysql ' : ' mysql:// {DB_USER} : {DB_PW} @ {DB_HOST} / {DB_NAME} '
' mysql ' : ' mysql:// {DB_USER} : {DB_PW} @ {DB_HOST} / {DB_NAME} '
}
}
HOSTS = ( ' IMAP ' , ' POP3 ' , ' AUTHSMTP ' , ' SMTP ' )
HOSTS = ( ' IMAP ' , ' POP3 ' , ' AUTHSMTP ' , ' SMTP ' , ' REDIS ' )
OPTIONAL_HOSTS = ( ' WEBMAIL ' , ' ANTISPAM ' )
OPTIONAL_HOSTS = ( ' WEBMAIL ' , ' ANTISPAM ' )
def __init__ ( self ) :
def __init__ ( self ) :
@ -83,7 +89,8 @@ class ConfigManager(dict):
optional = [ item for item in self . OPTIONAL_HOSTS if item in self . config and self . config [ item ] != " none " ]
optional = [ item for item in self . OPTIONAL_HOSTS if item in self . config and self . config [ item ] != " none " ]
for item in list ( self . HOSTS ) + optional :
for item in list ( self . HOSTS ) + optional :
host = ' HOST_ ' + item
host = ' HOST_ ' + item
self . config [ host ] = system . resolve_address ( self . config [ host ] )
address = item + ' _ADDRESS '
self . config [ address ] = system . resolve_address ( self . config [ host ] )
def __coerce_value ( self , value ) :
def __coerce_value ( self , value ) :
if isinstance ( value , str ) and value . lower ( ) in ( ' true ' , ' yes ' ) :
if isinstance ( value , str ) and value . lower ( ) in ( ' true ' , ' yes ' ) :
@ -105,6 +112,9 @@ class ConfigManager(dict):
if self . config [ ' DB_FLAVOR ' ] :
if self . config [ ' DB_FLAVOR ' ] :
template = self . DB_TEMPLATES [ self . config [ ' DB_FLAVOR ' ] ]
template = self . DB_TEMPLATES [ self . config [ ' DB_FLAVOR ' ] ]
self . config [ ' SQLALCHEMY_DATABASE_URI ' ] = template . format ( * * self . config )
self . config [ ' SQLALCHEMY_DATABASE_URI ' ] = template . format ( * * self . config )
self . config [ ' RATELIMIT_STORAGE_URL ' ] = ' redis:// {0} /2 ' . format ( self . config [ ' REDIS_ADDRESS ' ] )
self . config [ ' QUOTA_STORAGE_URL ' ] = ' redis:// {0} /1 ' . format ( self . config [ ' REDIS_ADDRESS ' ] )
# update the app config itself
# update the app config itself
app . config = self
app . config = self