new: new text while generating keys ...
This commit is contained in:
parent
a9123922c0
commit
0f8f77c2be
@ -33,8 +33,8 @@ if __name__ == '__main__':
|
||||
|
||||
plugins.load(config)
|
||||
|
||||
keypair = KeyPair()
|
||||
display = Display(config=config, state={'name': '%s>' % pwnagotchi.name()})
|
||||
keypair = KeyPair(view=display)
|
||||
agent = Agent(view=display, config=config, keypair=keypair)
|
||||
|
||||
logging.info("%s@%s (v%s)" % (pwnagotchi.name(), agent._keypair.fingerprint, pwnagotchi.version))
|
||||
|
@ -10,12 +10,13 @@ DefaultPath = "/etc/pwnagotchi/"
|
||||
|
||||
|
||||
class KeyPair(object):
|
||||
def __init__(self, path=DefaultPath):
|
||||
def __init__(self, path=DefaultPath, view=None):
|
||||
self.path = path
|
||||
self.priv_path = os.path.join(path, "id_rsa")
|
||||
self.priv_key = None
|
||||
self.pub_path = "%s.pub" % self.priv_path
|
||||
self.pub_key = None
|
||||
self._view = view
|
||||
|
||||
if not os.path.exists(self.path):
|
||||
os.makedirs(self.path)
|
||||
@ -23,6 +24,7 @@ class KeyPair(object):
|
||||
while True:
|
||||
# first time, generate new keys
|
||||
if not os.path.exists(self.priv_path) or not os.path.exists(self.pub_path):
|
||||
self._view.on_keys_generation()
|
||||
logging.info("generating %s ..." % self.priv_path)
|
||||
os.system("/usr/bin/ssh-keygen -t rsa -m PEM -b 4096 -N '' -f '%s'" % self.priv_path)
|
||||
|
||||
@ -45,6 +47,7 @@ class KeyPair(object):
|
||||
self.fingerprint = hashlib.sha256(pem_ascii).hexdigest()
|
||||
|
||||
# no exception, keys loaded correctly.
|
||||
self._view.on_normal()
|
||||
return
|
||||
|
||||
except Exception as e:
|
||||
|
@ -213,6 +213,11 @@ class View(object):
|
||||
faces.SAD,
|
||||
faces.LONELY)
|
||||
|
||||
def on_keys_generation(self):
|
||||
self.set('face', faces.AWAKE)
|
||||
self.set('status', self._voice.on_keys_generation())
|
||||
self.update()
|
||||
|
||||
def on_normal(self):
|
||||
self.set('face', faces.AWAKE)
|
||||
self.set('status', self._voice.on_normal())
|
||||
|
@ -28,6 +28,10 @@ class Voice:
|
||||
self._('AI ready.'),
|
||||
self._('The neural network is ready.')])
|
||||
|
||||
def on_keys_generation(self):
|
||||
return random.choice([
|
||||
self._('Generating keys, do not turn off ...')])
|
||||
|
||||
def on_normal(self):
|
||||
return random.choice([
|
||||
'',
|
||||
|
Loading…
x
Reference in New Issue
Block a user