def get_fleio_server_settings(whmcs_server: Tblservers): server_settings = { 'username': whmcs_server.username, 'hostname': whmcs_server.hostname, 'accesshash': whmcs_server.accesshash, 'password': whmcs_server.password, 'ipaddress': whmcs_server.ipaddress, 'assignedips': whmcs_server.assignedips, 'noc': whmcs_server.noc, 'statusaddress': whmcs_server.statusaddress, 'nameserver1': whmcs_server.nameserver1, 'nameserver1ip': whmcs_server.nameserver1ip, 'nameserver2': whmcs_server.nameserver2, 'nameserver2ip': whmcs_server.nameserver2ip, 'nameserver3': whmcs_server.nameserver3, 'nameserver3ip': whmcs_server.nameserver3ip, 'nameserver4': whmcs_server.nameserver4, 'nameserver4ip': whmcs_server.nameserver4ip, 'nameserver5': whmcs_server.nameserver5, 'nameserver5ip': whmcs_server.nameserver5ip, 'maxaccounts': whmcs_server.maxaccounts, 'secure': True if whmcs_server.secure == 'on' else False, 'port': whmcs_server.port, 'id': whmcs_server.id } if whmcs_server.type == 'cpanel': server_settings['key'] = fernet_encrypt(whmcs_server.accesshash) if whmcs_server.type == 'hypanel': server_settings['url'] = whmcs_server.hostname server_settings['password'] = fernet_encrypt(whmcs_server.password) return server_settings
def save(self, force_insert=False, force_update=False, using=None, update_fields=None): self.token_hash = fernet_encrypt(self.token_hash) if self.ipn_cc_mask: self.ipn_cc_mask = fernet_encrypt(self.ipn_cc_mask) if self.ipn_cc_exp_date: self.ipn_cc_exp_date = fernet_encrypt(self.ipn_cc_exp_date) return super().save(force_insert=force_insert, force_update=force_update, using=using, update_fields=update_fields)
def save(self, force_insert=False, force_update=False, using=None, update_fields=None): self.stripe_customer_id = fernet_encrypt(self.stripe_customer_id) self.stripe_payment_method = fernet_encrypt(self.stripe_payment_method) return super().save(force_insert=force_insert, force_update=force_update, using=using, update_fields=update_fields)
def encrypt_api_key(key): try: server_key = fernet_encrypt(key) except Exception as e: LOG.exception(e) server_key = None return server_key
def to_internal_value(self, data): if data: try: data = fernet_encrypt(data) except Exception as e: LOG.exception(e) data = None return super(HypanelPasswordSerializer, self).to_internal_value(data)
def save(self, force_insert=False, force_update=False, using=None, update_fields=None): self.secret_key = fernet_encrypt(self.secret_key) return super().save(force_insert=force_insert, force_update=force_update, using=using, update_fields=update_fields)
def reset_license(license_key, path='.'): try: if license_key is None: LOG.error('License not found. You must set the license first to use this script.') return 1 content, status = _set_license(license_key, path) if status != 200: LOG.error(content) return status else: Option.objects.update_or_create(section='LICENSE', field='key', defaults={'value': fernet_encrypt(license_key)}) LOG.info('License updated') return 0 except requests.ConnectionError: LOG.error("Can't connect to server. Please check your internet connection and retry.")
def _set_license(license_key, path='.'): """Install license""" # get license response = get_license_file(license_key) if response.status_code != rest_status.HTTP_200_OK: return response.content, response.status_code # save/update key in db Option.objects.update_or_create( section='LICENSE', field='key', defaults={'value': fernet_encrypt(license_key)}) # extract extract_license(response, path) # reload server if not reload_uwsgi(): reload_non_uwsgi_server() return 'Ok', rest_status.HTTP_200_OK
def encode_epp_code(epp_code): if epp_code is None: return None return fernet_encrypt(epp_code)