fixed pgp generation, work on onion
This commit is contained in:
parent
cb3de7056c
commit
6a1a448eab
@ -125,6 +125,8 @@ class API:
|
|||||||
resp = Response("pong!")
|
resp = Response("pong!")
|
||||||
elif action == 'setHMAC':
|
elif action == 'setHMAC':
|
||||||
pass
|
pass
|
||||||
|
elif action == 'getPGP':
|
||||||
|
ascii_armored_public_keys = gpg.export_keys('')
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
@ -28,6 +28,18 @@ class OnionrCommunicate:
|
|||||||
This class handles communication with nodes in the Onionr network.
|
This class handles communication with nodes in the Onionr network.
|
||||||
'''
|
'''
|
||||||
self._core = core.Core()
|
self._core = core.Core()
|
||||||
|
if debug:
|
||||||
|
print('Communicator debugging enabled')
|
||||||
|
torID = open('data/hs/hostname').read()
|
||||||
|
|
||||||
|
# get our own PGP fingerprint
|
||||||
|
fingerprintFile = 'data/own-fingerprint.txt'
|
||||||
|
if not os.path.exists(fingerprintFile):
|
||||||
|
self._core.generateMainPGP(torID)
|
||||||
|
with open(fingerprintFile,'r') as f:
|
||||||
|
self.pgpOwnFingerprint = f.read()
|
||||||
|
print('My PGP fingerprint is ' + self.pgpOwnFingerprint)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
command = self._core.daemonQueue()
|
command = self._core.daemonQueue()
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -29,17 +29,23 @@ class Core:
|
|||||||
'''
|
'''
|
||||||
self.queueDB = 'data/queue.db'
|
self.queueDB = 'data/queue.db'
|
||||||
self.peerDB = 'data/peers.db'
|
self.peerDB = 'data/peers.db'
|
||||||
|
self.ownPGPID = ''
|
||||||
|
|
||||||
#self.daemonQueue() # Call to create the DB if it doesn't exist
|
#self.daemonQueue() # Call to create the DB if it doesn't exist
|
||||||
return
|
return
|
||||||
|
|
||||||
def generateMainPGP(self):
|
def generateMainPGP(self, myID):
|
||||||
''' Generate the main PGP key for our client. Should not be done often.
|
''' Generate the main PGP key for our client. Should not be done often.
|
||||||
Uses own PGP home folder in the data/ directory. '''
|
Uses own PGP home folder in the data/ directory. '''
|
||||||
# Generate main pgp key
|
# Generate main pgp key
|
||||||
gpg = gnupg.GPG(homedir='data/pgp/')
|
gpg = gnupg.GPG(gnupghome='./data/pgp/')
|
||||||
input_data = gpg.gen_key_input(key_type="RSA", key_length=2048, name_real='anon', name_comment='Onionr key', name_email='anon@onionr')
|
input_data = gpg.gen_key_input(key_type="RSA", key_length=2048, name_real=myID, name_email='anon@onionr')
|
||||||
|
#input_data = gpg.gen_key_input(key_type="RSA", key_length=1024)
|
||||||
key = gpg.gen_key(input_data)
|
key = gpg.gen_key(input_data)
|
||||||
|
# Write the key
|
||||||
|
myFingerpintFile = open('data/own-fingerprint.txt', 'w')
|
||||||
|
myFingerpintFile.write(key.fingerprint)
|
||||||
|
myFingerpintFile.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
def addPeer(self, peerID, name=''):
|
def addPeer(self, peerID, name=''):
|
||||||
|
@ -78,7 +78,10 @@ class Onionr:
|
|||||||
if self.debug:
|
if self.debug:
|
||||||
randomPort = 8080
|
randomPort = 8080
|
||||||
else:
|
else:
|
||||||
|
while True:
|
||||||
randomPort = random.randint(1024, 65535)
|
randomPort = random.randint(1024, 65535)
|
||||||
|
if self.onionrUtils.checkPort(randomPort):
|
||||||
|
break
|
||||||
self.config['CLIENT'] = {'CLIENT HMAC': base64.b64encode(os.urandom(32)).decode('utf-8'), 'PORT': randomPort, 'API VERSION': '0.0.0'}
|
self.config['CLIENT'] = {'CLIENT HMAC': base64.b64encode(os.urandom(32)).decode('utf-8'), 'PORT': randomPort, 'API VERSION': '0.0.0'}
|
||||||
with open('data/config.ini', 'w') as configfile:
|
with open('data/config.ini', 'w') as configfile:
|
||||||
self.config.write(configfile)
|
self.config.write(configfile)
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
'''
|
'''
|
||||||
# Misc functions that do not fit in the main api, but are useful
|
# Misc functions that do not fit in the main api, but are useful
|
||||||
import getpass, sys, requests, configparser, os
|
import getpass, sys, requests, configparser, os, socket
|
||||||
class OnionrUtils():
|
class OnionrUtils():
|
||||||
'''Various useful functions'''
|
'''Various useful functions'''
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -48,3 +48,16 @@ class OnionrUtils():
|
|||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
return pass1
|
return pass1
|
||||||
|
def checkPort(self, port):
|
||||||
|
'''Checks if a port is available, returns bool'''
|
||||||
|
# inspired by https://www.reddit.com/r/learnpython/comments/2i4qrj/how_to_write_a_python_script_that_checks_to_see/ckzarux/
|
||||||
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
retVal = False
|
||||||
|
try:
|
||||||
|
sock.bind(('', port))
|
||||||
|
except OSError as e:
|
||||||
|
if e.errno is 98:
|
||||||
|
retVal = True
|
||||||
|
finally:
|
||||||
|
sock.close()
|
||||||
|
return retVal
|
@ -12,3 +12,7 @@ Major work in progress.
|
|||||||
# Development
|
# Development
|
||||||
|
|
||||||
This software is in heavy development. If for some reason you want to get involved, get in touch first.
|
This software is in heavy development. If for some reason you want to get involved, get in touch first.
|
||||||
|
|
||||||
|
## Disclaimer
|
||||||
|
|
||||||
|
The Tor Project, I2P developers, and anyone else do not own, create, or endorse this project, and are not otherwise involved.
|
||||||
|
Loading…
Reference in New Issue
Block a user