/
opt
/
imh-python
/
lib
/
python3.9
/
site-packages
/
libcloud
/
common
/
/opt/imh-python/lib/python3.9/site-packages/libcloud/common
mkdir
upload
Name
Size
Mode
Actions
__pycache__/
-
0755
rm
abiquo.py
10315
0644
edit
dl
rm
aliyun.py
8800
0644
edit
dl
rm
aws.py
17632
0644
edit
dl
rm
azure.py
10362
0644
edit
dl
rm
azure_arm.py
10058
0644
edit
dl
rm
base.py
33185
0644
edit
dl
rm
brightbox.py
3484
0644
edit
dl
rm
buddyns.py
2489
0644
edit
dl
rm
cloudsigma.py
4389
0644
edit
dl
rm
cloudstack.py
7572
0644
edit
dl
rm
digitalocean.py
7037
0644
edit
dl
rm
dimensiondata.py
58274
0644
edit
dl
rm
dnsimple.py
2030
0644
edit
dl
rm
dnspod.py
2549
0644
edit
dl
rm
durabledns.py
10669
0644
edit
dl
rm
exceptions.py
3425
0644
edit
dl
rm
gandi.py
6225
0644
edit
dl
rm
gandi_live.py
7380
0644
edit
dl
rm
gig_g8.py
2946
0644
edit
dl
rm
gogrid.py
6395
0644
edit
dl
rm
google.py
30831
0644
edit
dl
rm
gridscale.py
4296
0644
edit
dl
rm
hostvirtual.py
2524
0644
edit
dl
rm
kubernetes.py
9061
0644
edit
dl
rm
linode.py
5598
0644
edit
dl
rm
liquidweb.py
6582
0644
edit
dl
rm
luadns.py
2675
0644
edit
dl
rm
maxihost.py
2152
0644
edit
dl
rm
nfsn.py
4137
0644
edit
dl
rm
nsone.py
2443
0644
edit
dl
rm
nttcis.py
74125
0644
edit
dl
rm
onapp.py
2132
0644
edit
dl
rm
openstack.py
18747
0644
edit
dl
rm
openstack_identity.py
61740
0644
edit
dl
rm
ovh.py
5963
0644
edit
dl
rm
pointdns.py
2044
0644
edit
dl
rm
providers.py
4071
0644
edit
dl
rm
rackspace.py
934
0644
edit
dl
rm
softlayer.py
2938
0644
edit
dl
rm
types.py
6914
0644
edit
dl
rm
upcloud.py
8956
0644
edit
dl
rm
vultr.py
4161
0644
edit
dl
rm
worldwidedns.py
7244
0644
edit
dl
rm
xmlrpc.py
3939
0644
edit
dl
rm
zonomi.py
4422
0644
edit
dl
rm
__init__.py
0
0644
edit
dl
rm
Edit:
/opt/imh-python/lib/python3.9/site-packages/libcloud/common/nfsn.py
(4137B)
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import hashlib import random import string import time from libcloud.common.base import ConnectionUserAndKey from libcloud.common.base import JsonResponse from libcloud.common.types import InvalidCredsError, ProviderError from libcloud.utils.py3 import basestring, httplib, urlencode SALT_CHARACTERS = string.ascii_letters + string.digits class NFSNException(ProviderError): def __init__(self, value, http_code, code, driver=None): self.code = code super(NFSNException, self).__init__(value, http_code, driver) class NFSNResponse(JsonResponse): def parse_error(self): if self.status == httplib.UNAUTHORIZED: raise InvalidCredsError('Invalid provider credentials') body = self.parse_body() if isinstance(body, basestring): return body + ' (HTTP Code: %d)' % self.status error = body.get('error', None) debug = body.get('debug', None) # If we only have one of "error" or "debug", use the one that we have. # If we have both, use both, with a space character in between them. value = 'No message specified' if error is not None: value = error if debug is not None: value = debug if error is not None and value is not None: value = error + ' ' + value value = value + ' (HTTP Code: %d)' % self.status return value class NFSNConnection(ConnectionUserAndKey): host = 'api.nearlyfreespeech.net' responseCls = NFSNResponse allow_insecure = False def _header(self, action, data): """ Build the contents of the X-NFSN-Authentication HTTP header. See https://members.nearlyfreespeech.net/wiki/API/Introduction for more explanation. """ login = self.user_id timestamp = self._timestamp() salt = self._salt() api_key = self.key data = urlencode(data) data_hash = hashlib.sha1(data.encode('utf-8')).hexdigest() string = ';'.join((login, timestamp, salt, api_key, action, data_hash)) string_hash = hashlib.sha1(string.encode('utf-8')).hexdigest() return ';'.join((login, timestamp, salt, string_hash)) def request(self, action, params=None, data='', headers=None, method='GET'): """ Add the X-NFSN-Authentication header to an HTTP request. """ if not headers: headers = {} if not params: params = {} header = self._header(action, data) headers['X-NFSN-Authentication'] = header if method == 'POST': headers['Content-Type'] = 'application/x-www-form-urlencoded' return ConnectionUserAndKey.request(self, action, params, data, headers, method) def encode_data(self, data): """ NFSN expects the body to be regular key-value pairs that are not JSON-encoded. """ if data: data = urlencode(data) return data def _salt(self): """ Return a 16-character alphanumeric string. """ r = random.SystemRandom() return ''.join(r.choice(SALT_CHARACTERS) for _ in range(16)) def _timestamp(self): """ Return the current number of seconds since the Unix epoch, as a string. """ return str(int(time.time()))
Save
cmd:
run