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

View File

@ -43,6 +43,12 @@ class Core:
self.blockDataLocation = 'data/blocks/'
self._utils = onionrutils.OnionrUtils(self)
if not os.path.exists('data/'):
os.mkdir('data/')
if not os.path.exists(self.blockDB):
self.createBlockDB()
return
def generateMainPGP(self, myID):
@ -50,9 +56,14 @@ class Core:
Uses own PGP home folder in the data/ directory. '''
# Generate main pgp key
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)
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
myFingerpintFile = open('data/own-fingerprint.txt', 'w')
myFingerpintFile.write(key.fingerprint)
@ -229,8 +240,11 @@ class Core:
'''clear the daemon queue (somewhat dangerousous)'''
conn = sqlite3.connect(self.queueDB)
c = conn.cursor()
c.execute('Delete from commands;')
try:
c.execute('delete from commands;')
conn.commit()
except:
pass
conn.close()
def generateHMAC(self):

View File

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