Exemplo n.º 1
0
 def add(self,):
     args = {
         "p":bool(self.val_pvt.get()),
         "f":False,
         "nomd5":bool(self.val_md5.get()),
         "l":bool(self.val_lcl.get()),
         "filename":self.file
     }
     globals()['response'] = asyncio.run(add_file(args))
     self.cleanup()
Exemplo n.º 2
0
    with open(pathlib.join(path, 'config.json'), 'r') as file:
        config = loads(file.read())
except:
    print("Config not found !")


async def main():
    if len(sys.argv) < 2:
        return "Please provide token"

    _, token = sys.argv
    request = HTTPRequest('delete', config['server_config']['local']['host'],
                          config['server_config']['local']['port'],
                          '/file/' + token)
    try:
        await request.make_request()
    except ConnectionRefusedError:
        return 'Connection refused please start the server.'

    if request.headers.status_code == '200':
        data = request.get_json()
        print(data['message'])
    print('\a')
    return False


if __name__ == "__main__":
    exit_code = asyncio.run(main())
    if exit_code:
        print(exit_code)
Exemplo n.º 3
0
    print("Config not found !")


async def main():
    request = HTTPRequest('get', config['server_config']['local']['host'],
                          config['server_config']['local']['port'],
                          '/file/GET_TOKENS')
    try:
        await request.make_request()
    except ConnectionRefusedError:
        return 'Connection refused please start the server.'

    if request.headers.status_code == '200':
        data = request.get_json()['tokens']
        print(f"{top_left}{hr*(row_1+1)}{t_up}{hr*(row_0+1)}{top_right}")
        print(format_row(filename='Filename', token='Token'))

        print(f"{t_left}{hr*(row_1+1)}{cross}{hr*(row_0+1)}{t_right}")
        for item in data:
            print(format_row(**item))
        print(
            f"{bottom_left}{hr*(row_1+1)}{t_down}{hr*(row_0+1)}{bottom_right}")

    print('\a')
    return False


if __name__ == "__main__":
    if (exit_code := asyncio.run(main())):
        print(exit_code)
Exemplo n.º 4
0
async def name_id(request: Request, name, idd):
    return json_response({"name": name, "id": idd})


@app.route("/save_config/<string:config>")
async def save_config(request: Request, config):
    return text_response("Saved")


if __name__ == "__main__":

    with open(pathlib.join(PATH, "service", "tunnel.pid"), "w+") as file:
        file.write(str(getpid()))

    try:
        asyncio.run(tunnel_manager.init())
    except ConnectionError:
        print("Could not start tunnel, Remote server is not running")

    tun_thread = Thread(target=tunnel_manager.serve, )
    app_thread = Thread(
        target=app.serve,
        kwargs={
            "host": "0.0.0.0",  #CONFIG['server_config']['local']['host'],
            "port": CONFIG['server_config']['local']['port']
        })

    tun_thread.start()
    app_thread.start()

    with open(pathlib.join(PATH, 'service', 'tunnel.pid'), "w+") as file: