def new_figure(self, licdict): ret = old_figure(self, licdict) ret['concurrent_connections'] = 1024 return ret
for x in dir(uprop2): if x[:2] == '__': continue if x == 'UsageProperties': exec('old_figure = uprop2.UsageProperties.figure') exec('uprop2.UsageProperties.figure = new_figure') exec('%s = uprop2.%s' % (x, x))
2.9.0 及以上版本内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
from pyovpn.lic import uprop2 old_figure = None
def new_figure(self, licdict): ret = old_figure(self, licdict) ret['concurrent_connections'] = 1024 return ret
for x in dir(uprop2): if x[:2] == '__': continue if x == 'UsageProperties': exec('old_figure = uprop2.UsageProperties.figure') exec('uprop2.UsageProperties.figure = new_figure') exec('%s = uprop2.%s' % (x, x))
# uncompyle6 version 3.7.4 # Python bytecode 3.7 (3394) # Decompiled from: Python 3.7.11 (default, Aug 17 2021, 16:15:07) # [GCC 10.2.1 20210110] # Embedded file name: build/bdist.linux-x86_64/egg/pyovpn/lic/uprop.py # Compiled at: 2021-08-17 12:27:35 # Size of source mod 2**32: 3315 bytes from pyovpn.util.date import YYYYMMDD from pyovpn.util.error import Passthru from pyovpn.lic.prop import LicenseProperties from pyovpn.util.env import get_env_debug from pyovpn.pki.sign import rsa_verify_complex from pyovpn.aws.info import AWSInfo DEBUG = get_env_debug('DEBUG_UPROP')
class UsageProperties(object):
def figure(self, licdict): proplist = set(('concurrent_connections', )) good = set() ret = None if licdict: for key, props in list(licdict.items()): if 'quota_properties' not in props: print('License Manager: key %s is missing usage properties' % key) continue proplist.update(props['quota_properties'].split(',')) good.add(key)
for prop in proplist: v_agg = 0 v_nonagg = 0 if licdict: for key, props in list(licdict.items()): if key in good and prop in props: try: nonagg = int(props[prop]) except: raise Passthru('license property %s (%s)' % (prop, props.get(prop).__repr__()))
apc = self._apc() v_agg += apc if ret == None: ret = {} ret[prop] = max(v_agg + v_nonagg, bool('v_agg') + bool('v_nonagg')) ret['apc'] = bool(apc) if DEBUG: print("ret['%s'] = v_agg(%d) + v_nonagg(%d)" % (prop, v_agg, v_nonagg))
return ret
def _apc(self): try: pcs = AWSInfo.get_product_code() if pcs: return pcs['snoitcennoCtnerrucnoc'[::-1]] except: if DEBUG: print(Passthru('UsageProperties._apc'))
return 0
@staticmethod def _expired(today, props): if 'expiry_date' in props: exp = YYYYMMDD.validate(props['expiry_date']) return today > exp return False
class UsagePropertiesValidate(object): proplist = ('concurrent_connections', 'client_certificates')
def validate(self, usage_properties): lp = LicenseProperties(usage_properties) lp.aggregated_post() lp['quota_properties'] = ','.join([p for p in self.proplist if p in lp]) return lp