fixed gpg generation bug and fixed issues relating to first run/setup

This commit is contained in:
Kevin Froman 2018-01-26 21:42:20 -06:00
parent d22d945056
commit ead0741e03
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
3 changed files with 24 additions and 5 deletions

View File

@ -41,7 +41,8 @@ class OnionrCommunicate:
with open(fingerprintFile,'r') as f: with open(fingerprintFile,'r') as f:
self.pgpOwnFingerprint = f.read() self.pgpOwnFingerprint = f.read()
logger.info('My PGP fingerprint is ' + logger.colors.underline + self.pgpOwnFingerprint + logger.colors.reset + logger.colors.fg.green + '.') logger.info('My PGP fingerprint is ' + logger.colors.underline + self.pgpOwnFingerprint + logger.colors.reset + logger.colors.fg.green + '.')
self._core.clearDaemonQueue() if os.path.exists(self._core.queueDB):
self._core.clearDaemonQueue()
while True: while True:
command = self._core.daemonQueue() command = self._core.daemonQueue()

View File

@ -43,6 +43,12 @@ class Core:
self.blockDataLocation = 'data/blocks/' self.blockDataLocation = 'data/blocks/'
self._utils = onionrutils.OnionrUtils(self) self._utils = onionrutils.OnionrUtils(self)
if not os.path.exists('data/'):
os.mkdir('data/')
if not os.path.exists(self.blockDB):
self.createBlockDB()
return return
def generateMainPGP(self, myID): def generateMainPGP(self, myID):
@ -50,9 +56,14 @@ class Core:
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(homedir='./data/pgp/')
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, name_real=myID, name_email='anon@onionr', testing=True)
#input_data = gpg.gen_key_input(key_type="RSA", key_length=1024) #input_data = gpg.gen_key_input(key_type="RSA", key_length=1024)
key = gpg.gen_key(input_data) key = gpg.gen_key(input_data)
logger.info("Generating PGP key, this will take some time..")
while key.status != "key created":
time.sleep(0.5)
print(key.status)
logger.info("Finished generating PGP key")
# Write the key # Write the key
myFingerpintFile = open('data/own-fingerprint.txt', 'w') myFingerpintFile = open('data/own-fingerprint.txt', 'w')
myFingerpintFile.write(key.fingerprint) myFingerpintFile.write(key.fingerprint)
@ -229,8 +240,11 @@ class Core:
'''clear the daemon queue (somewhat dangerousous)''' '''clear the daemon queue (somewhat dangerousous)'''
conn = sqlite3.connect(self.queueDB) conn = sqlite3.connect(self.queueDB)
c = conn.cursor() c = conn.cursor()
c.execute('Delete from commands;') try:
conn.commit() c.execute('delete from commands;')
conn.commit()
except:
pass
conn.close() conn.close()
def generateHMAC(self): def generateHMAC(self):

View File

@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
''' '''
import subprocess, os, random, sys, logger import subprocess, os, random, sys, logger, time
class NetController: class NetController:
'''NetController '''NetController
This class handles hidden service setup on Tor and I2P This class handles hidden service setup on Tor and I2P
@ -28,11 +28,13 @@ class NetController:
self.socksPort = random.randint(1024, 65535) self.socksPort = random.randint(1024, 65535)
self.hsPort = hsPort self.hsPort = hsPort
self.myID = '' self.myID = ''
'''
if os.path.exists(self.torConfigLocation): if os.path.exists(self.torConfigLocation):
torrc = open(self.torConfigLocation, 'r') torrc = open(self.torConfigLocation, 'r')
if not str(self.hsPort) in torrc.read(): if not str(self.hsPort) in torrc.read():
os.remove(self.torConfigLocation) os.remove(self.torConfigLocation)
torrc.close() torrc.close()
'''
return return
def generateTorrc(self): def generateTorrc(self):
if os.path.exists(self.torConfigLocation): if os.path.exists(self.torConfigLocation):
@ -57,6 +59,8 @@ HiddenServicePort 80 127.0.0.1:''' + str(self.hsPort) + '''
break break
elif 'Opening Socks listener' in line.decode(): elif 'Opening Socks listener' in line.decode():
logger.debug(line.decode()) logger.debug(line.decode())
else:
logger.error('Failed to start Tor')
logger.info('Finished starting Tor') logger.info('Finished starting Tor')
self.readyState = True self.readyState = True
myID = open('data/hs/hostname', 'r') myID = open('data/hs/hostname', 'r')