def do_create_session(self, args): """ E.g. > create_session user pass """ user, password = args.split() with nabto_client.NabtoSession(user, password) as session: print('Session opened. Sleep for 5 seconds') sleep(5) self.user = user self.password = password
def do_pair(self, args): """ E.g. > pair user """ if not self.user: print('You must call `create_session` first') return with nabto_client.NabtoSession(self.user, self.password) as session: with open(NABTO_QUERIES) as file: session.RpcSetDefaultInterface(file.read()) dev = NabtoDevice(self.device_name, session) print(dev.pairWithDevice(args))
def do_add_user(self, args): """ E.g. > add_user guest 34e0834b008f0ee3748de75ecee71802 """ user, fingerprint = args.split() if not self.user: print('You must call `create_session` first') return with nabto_client.NabtoSession(self.user, self.password) as session: with open(NABTO_QUERIES) as file: session.RpcSetDefaultInterface(file.read()) dev = NabtoDevice(self.device_name, session) print(dev.addUser(user, fingerprint))
def do_open_tunnel(self, remote_port): """ E.g. > open_tunnel 8090 """ if not self.user: print('You must call `create_session` first') return with nabto_client.NabtoSession(self.user, self.password) as session: with open(NABTO_QUERIES) as file: session.RpcSetDefaultInterface(file.read()) with nabto_client.NabtoTunnel(session, 0, self.device_name, 'localhost', int(remote_port)) as port: print(f'Opened tunnel on port {port}. Sleep for 30 seconds.') sleep(30)