def __init__(self, auth_by_cert=FORBIDDEN, portal_enabled=False, portal_nets=None, strict=False, ca='', #certconf cert='', #certconf crl='', #certconf key='', #certconf nupki_pki='', #certconf nupki_cert='', #certconf use_nupki=False, #certconf disable_crl=True #certconf ): if portal_nets is None: portal_nets = set() AbstractConf.__init__(self) CertConf.__init__( self, ca=ca, cert=cert, crl=crl, key=key, nupki_pki=nupki_pki, nupki_cert=nupki_cert, use_nupki=use_nupki, disable_crl=disable_crl ) self.auth_by_cert = auth_by_cert self.portal_enabled = portal_enabled self.portal_nets = portal_nets self.strict = strict
def checkSerialVersion(cls, serialized): datastructure_version = serialized.get('DATASTRUCTURE_VERSION') supported_versions = range(1, cls.DATASTRUCTURE_VERSION + 1) if datastructure_version not in supported_versions: #This will raise relevant errors cls.raise_version_error(datastructure_version) if datastructure_version < 2: # Upgrade 1 -> 2: serialized['portal_enabled'] = False serialized['portal_nets'] = set() CertConf.checkSerialVersionA(datastructure_version, serialized) return datastructure_version
def __init__(self, client_network='', enabled=False, port='1194', protocol='udp', redirect=False, server='', manual_pushed_routes = (), ca='', cert='', crl='', key='', nupki_pki='', nupki_cert='', use_nupki=False, disable_crl=False): AbstractConf.__init__(self) CertConf.__init__(self, ca=ca, cert=cert, crl=crl, key=key, nupki_pki=nupki_pki, nupki_cert=nupki_cert, use_nupki=use_nupki, disable_crl=disable_crl) self.client_network = client_network self.enabled = bool(enabled) self.port = port self.protocol = protocol self.redirect = redirect self.server = server self.manual_pushed_routes = manual_pushed_routes
def checkSerialVersion(cls, serialized): datastructure_version = serialized.get('DATASTRUCTURE_VERSION') supported_versions = range(1, cls.DATASTRUCTURE_VERSION + 1) if datastructure_version not in supported_versions: #This will raise relevant errors cls.raise_version_error(datastructure_version) if datastructure_version < 2: #upgrade #1 -> 2: add manual_pushed_routes serialized['manual_pushed_routes'] = () # 2 -> 3: pass # 3 -> 4: pass CertConf.checkSerialVersionA(datastructure_version, serialized) return datastructure_version
def downgradeFields(cls, serialized, wanted_version): if wanted_version < 4 and serialized['DATASTRUCTURE_VERSION'] >= 4: #4 -> 3: CertConf.downgradeFieldsA(serialized) serialized['DATASTRUCTURE_VERSION'] = 3 if wanted_version < 3 and serialized['DATASTRUCTURE_VERSION'] >= 3: #3 -> 2: CertConf.downgradeFieldsA(serialized) serialized['DATASTRUCTURE_VERSION'] = 2 if wanted_version < 2 and serialized['DATASTRUCTURE_VERSION'] >= 2: #2 -> 1: remove manual_pushed_routes del serialized['manual_pushed_routes'] serialized['DATASTRUCTURE_VERSION'] = 1 if wanted_version != serialized['DATASTRUCTURE_VERSION']: raise NotImplementedError() return serialized