diff --git a/src/dash.py b/src/dash.py index 5c0ba74..f1562da 100644 --- a/src/dash.py +++ b/src/dash.py @@ -40,10 +40,12 @@ def local(port,path): ClientIP = output[10:] elif "127.0.0.1" in output: out = str(output).split(' ') + with open('ip.bin', 'r') as file: # extracting the ip from the file + ip = file.read() if out[6] == '/': - process_display(0,0,"Someone Opened the page") + process_display(0,0,"Someone at {} has opened your page.".format(ip)) elif out[-2] == '204': - process_display(0,0,"Upload Completed") + process_display(0,0,"File received from {}".format(ip)) @@ -110,5 +112,6 @@ def forward(port): thread1.join() thread2.join() except: + os.remove('ip.bin') # deleting the file which contains the ip print("\nYou're Great..!\nThanks for using :)") sys.exit(0) diff --git a/src/local.py b/src/local.py index c27c043..8ccc39f 100644 --- a/src/local.py +++ b/src/local.py @@ -13,11 +13,27 @@ @app.route("/") def index(): + try: + ip = request.environ['HTTP_X_FORWARDED_FOR'] # if behind a proxy + except KeyError: + ip = request.environ['REMOTE_ADDR'] + + with open('ip.bin', 'w') as file: # saving the ip in the file + file.write(ip) + return render_template("index.html") @app.route("/upload", methods=['POST']) def upload(): + try: + ip = request.environ['HTTP_X_FORWARDED_FOR'] # if behind a proxy + except KeyError: + ip = request.environ['REMOTE_ADDR'] + + with open('ip.bin', 'w') as file: # saving the ip in the file + file.write(ip) + target = os.path.join(args.path) print(target)