|
|
|
@ -8,7 +8,7 @@ class GNUnetRest:
|
|
|
|
|
self.host = host
|
|
|
|
|
self.port = port
|
|
|
|
|
|
|
|
|
|
def test(self):
|
|
|
|
|
def is_port_open(self):
|
|
|
|
|
# check if port is open
|
|
|
|
|
# not the best solution, it should better check if REST responds \
|
|
|
|
|
# and not only if port is listening
|
|
|
|
@ -22,15 +22,15 @@ class GNUnetRest:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
# Identity Section
|
|
|
|
|
def getIdentityList(self):
|
|
|
|
|
# returns a list of all identities
|
|
|
|
|
def identity_list(self):
|
|
|
|
|
"""Returns a list of all identities."""
|
|
|
|
|
requeststring = "http://" + self.host + ":" + self.port + "/identity/"
|
|
|
|
|
respdata = requests.get(requeststring).json()
|
|
|
|
|
val = json.loads(json.dumps(respdata))
|
|
|
|
|
return val
|
|
|
|
|
|
|
|
|
|
def getIdentityPubkey(self, thename):
|
|
|
|
|
# returns the public key of an identity specified by name
|
|
|
|
|
def identity_hash(self, thename):
|
|
|
|
|
"""Returns the public key of an identity specified by name."""
|
|
|
|
|
requeststring = (
|
|
|
|
|
"http://"
|
|
|
|
|
+ self.host
|
|
|
|
@ -43,8 +43,8 @@ class GNUnetRest:
|
|
|
|
|
val = json.loads(json.dumps(respdata))
|
|
|
|
|
return val["pubkey"]
|
|
|
|
|
|
|
|
|
|
def getIdentityName(self, thepubkey):
|
|
|
|
|
# returns the name of an identity specified by public key
|
|
|
|
|
def identity_name(self, thepubkey):
|
|
|
|
|
"""Returns the name of an identity specified by public key."""
|
|
|
|
|
requeststring = (
|
|
|
|
|
"http://"
|
|
|
|
|
+ self.host
|
|
|
|
@ -57,8 +57,8 @@ class GNUnetRest:
|
|
|
|
|
val = json.loads(json.dumps(respdata))
|
|
|
|
|
return val["name"]
|
|
|
|
|
|
|
|
|
|
def getNamestoreIdentity(self):
|
|
|
|
|
# returns the default identity of subsystem 'namestore'
|
|
|
|
|
def namestore_identity(self):
|
|
|
|
|
"""Returns the default identity of subsystem 'namestore'."""
|
|
|
|
|
requeststring = (
|
|
|
|
|
"http://"
|
|
|
|
|
+ self.host
|
|
|
|
@ -70,8 +70,8 @@ class GNUnetRest:
|
|
|
|
|
val = json.loads(json.dumps(respdata))
|
|
|
|
|
return val["name"]
|
|
|
|
|
|
|
|
|
|
def createIdentity(self, thename):
|
|
|
|
|
# creates Identy, returns True if successful, False if not
|
|
|
|
|
def create_identity(self, thename):
|
|
|
|
|
"""Creates Identy, returns True if successful, False if not."""
|
|
|
|
|
requeststring = "http://" + self.host + ":" + self.port + "/identity"
|
|
|
|
|
datadict = {"name": thename}
|
|
|
|
|
dataparams = json.dumps(datadict)
|
|
|
|
@ -84,8 +84,12 @@ class GNUnetRest:
|
|
|
|
|
return False
|
|
|
|
|
return ()
|
|
|
|
|
|
|
|
|
|
def changeIdentityName(self, thename, newname):
|
|
|
|
|
# changes name of identity, returns True if successful, False if not
|
|
|
|
|
def change_identity_name(self, thename, newname):
|
|
|
|
|
"""Changes name of identity.
|
|
|
|
|
|
|
|
|
|
Returns True if successful, False if not.
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
requeststring = (
|
|
|
|
|
"http://"
|
|
|
|
|
+ self.host
|
|
|
|
@ -103,8 +107,8 @@ class GNUnetRest:
|
|
|
|
|
else:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def deleteIdentity(self, thename):
|
|
|
|
|
# deletes Identity, returns True if successful, false if not
|
|
|
|
|
def delete_identity(self, thename):
|
|
|
|
|
"""Deletes Identity, returns True if successful, false if not."""
|
|
|
|
|
requeststring = (
|
|
|
|
|
"http://"
|
|
|
|
|
+ self.host
|
|
|
|
@ -122,9 +126,12 @@ class GNUnetRest:
|
|
|
|
|
|
|
|
|
|
# Namestore Section
|
|
|
|
|
|
|
|
|
|
def setNamestoreIdentity(self, thename):
|
|
|
|
|
# sets the default Identity for subsystem 'namestore'
|
|
|
|
|
# returns True if successful False if not
|
|
|
|
|
def set_namestore_identity(self, thename):
|
|
|
|
|
"""Sets the default Identity for subsystem 'namestore'.
|
|
|
|
|
|
|
|
|
|
Returns True if successful False if not.
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
requeststring = (
|
|
|
|
|
"http://"
|
|
|
|
|
+ self.host
|
|
|
|
@ -141,8 +148,8 @@ class GNUnetRest:
|
|
|
|
|
else:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def getNamestoreEntries(self, thezone):
|
|
|
|
|
# returns a list of all namestore entries
|
|
|
|
|
def list_namestore_entries(self, thezone):
|
|
|
|
|
"""Returns a list of all namestore entries."""
|
|
|
|
|
requeststring = (
|
|
|
|
|
"http://" + self.host + ":" + self.port + "/namestore/" + thezone
|
|
|
|
|
)
|
|
|
|
@ -151,8 +158,8 @@ class GNUnetRest:
|
|
|
|
|
return val
|
|
|
|
|
# return(respdata)
|
|
|
|
|
|
|
|
|
|
def addNamestoreEntry(self, thezone, thename, thevalue, thetype):
|
|
|
|
|
# adds a namestore entry, returns true if successful, false if not
|
|
|
|
|
def add_namestore_entry(self, thezone, thename, thevalue, thetype):
|
|
|
|
|
"""Adds a namestore entry, returns true if successful, false if not."""
|
|
|
|
|
requeststring = (
|
|
|
|
|
"http://" + self.host + ":" + self.port + "/namestore/" + thezone
|
|
|
|
|
)
|
|
|
|
@ -171,7 +178,7 @@ class GNUnetRest:
|
|
|
|
|
else:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def changeNamestoreEntry(self, thezone, thename, thevalue, thetype):
|
|
|
|
|
def change_namestore_entry(self, thezone, thename, thevalue, thetype):
|
|
|
|
|
# changes a namestore entry, returns true if successful, false if not
|
|
|
|
|
requeststring = (
|
|
|
|
|
"http://" + self.host + ":" + self.port + "/namestore/" + thezone
|
|
|
|
@ -191,8 +198,12 @@ class GNUnetRest:
|
|
|
|
|
else:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def deleteNamestoreEntry(self, thezone, thename):
|
|
|
|
|
# deletes a namestore entry, returns true if successful, false if not
|
|
|
|
|
def delete_namestore_entry(self, thezone, thename):
|
|
|
|
|
"""Deletes a namestore entry.
|
|
|
|
|
|
|
|
|
|
Returns true if successful, false if not.
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
requeststring = (
|
|
|
|
|
"http://"
|
|
|
|
|
+ self.host
|
|
|
|
@ -210,8 +221,8 @@ class GNUnetRest:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
# GNS section
|
|
|
|
|
def getGNSValuesOfName(self, thezone, thename):
|
|
|
|
|
# returns a list of values and record types with the same record name
|
|
|
|
|
def list_gns_record(self, thezone, thename):
|
|
|
|
|
"""Returns a list of values and record types with the same record name."""
|
|
|
|
|
requeststring = (
|
|
|
|
|
"http://"
|
|
|
|
|
+ self.host
|
|
|
|
@ -226,8 +237,8 @@ class GNUnetRest:
|
|
|
|
|
val = json.loads(json.dumps(respdata))
|
|
|
|
|
return val
|
|
|
|
|
|
|
|
|
|
def getGNSValuesOfNameAndType(self, thezone, thename, thetype):
|
|
|
|
|
# returns a list of values of a certain name and record type
|
|
|
|
|
def list_gns_record_type(self, thezone, thename, thetype):
|
|
|
|
|
"""Returns a list of values of a certain name and record type."""
|
|
|
|
|
requeststring = (
|
|
|
|
|
"http://"
|
|
|
|
|
+ self.host
|
|
|
|
|