From 722ba6348aa958019eb1211b67bfaf26536e7f24 Mon Sep 17 00:00:00 2001 From: Adriana Draghici Date: Thu, 15 Apr 2010 08:42:03 +0000 Subject: [PATCH] autorun: modified PROTOCOL --- autorun/PROTOCOL | 75 ++++++++++++++++++++++++---------------- autorun/Util.py | 3 +- autorun/server/Server.py | 14 ++++---- 3 files changed, 55 insertions(+), 37 deletions(-) diff --git a/autorun/PROTOCOL b/autorun/PROTOCOL index 83f51fa..c7e63ed 100644 --- a/autorun/PROTOCOL +++ b/autorun/PROTOCOL @@ -1,35 +1,54 @@ -Comunicare Client <-> Server +Comunicare Commander <-> Server + +Comunicatia se realizeaza pe portul 10004. -++---------+ start server +----------------------------------------------------------+ -| |---------------> | +--------------+ +--------+ +-------------+ | -| Client | send commands | | Server daemon| | tribler| | transmission| .... | -| |---------------> | +--------------+ +--------+ +-------------+ | -++---------+<--------------- +----------------------------------------------------------+ - ack +++-----------+ start server +----------------------------------------------------------+ +| | ---------------> | +--------------+ +--------+ +-------------+ | +| Commander | send commands | | Server daemon| | tribler| | transmission| .... | +| | ---------------> | +--------------+ +--------+ +-------------+ | +++-----------+ <--------------- +----------------------------------------------------------+ + ack + + +Comenzi Commander <-> Server: + - GET_CLIENTS + - START_CLIENT + - STOP_CLIENT + - ARCHIVE + - CLEANUP +Serverul pastreaza un fisier cu info despre toate fisierele downloadate: + - client type, torrent_metafile, type(log dir, status dir, log file, status file), path -1. Pas initial - NU MAI ESTE NEVOIE - - informatiile legate de clienti - - msg 1: tipul mesajului: CONFIG_MSG (definit in Util.py) - - msg 2: dictionar de dictionare cu datele din clients.xml - exp: {"tribler":{FILE:"Tribler/Tools/cmdline.py", - RUN_TYPE:"script", - INTERPRETER:"python", PREFIX:"PYTHONPATH=.",SUFFIX:"", - UP_LIMIT_OPTION:"",DL_LIMIT_OPTION:"", PORT_OPTION:"-p", - LOG_DIR_OPTION:"-l",DL_DIR_OPTION:"-d"} - } - - dupa fiecare msg 1,2 Serverul trimite un mesaj care indica daca a aparut sau nu vreo eroare +0. Pas initial - Pornire SERVER DAEMON + - argumente: start|stop ip_host +1. Mesaje GET_CLIENTS + -----> tipul mesajului GET_CLIENTS + <----- lista tupluri (client_name, pid) +2. Mesaje GET_OUTPUT + -----> tipul mesajului GET_OUTPUT + <----- lista tupluri: (client_name, metafile, file_type, file_path) + +3. Mesaje ARCHIVE + -----> tipul mesajului ARCHIVE + <----- ACK/ERROR + - Serverul: + - arhiveaza fis din fisierul local de sessions + - sterge fis care au fost arhivate + - sterge din sessions lista fisierelor arhivate + 2. Mesaje START - trimis pt pornirea unui client - - msg 1: tipul mesajului START_MSG (definit in Util.py) - - msg 2: dictionar cu parametrii + -----> tipul mesajului START_CLIENT (definit in Util.py) + <----- ACK/ERROR + -----> dictionar cu parametrii exp: {CLIENT:"tribler", BASE_DIR: "/usr/bin", UP_LIMIT: "512", @@ -41,22 +60,20 @@ Comunicare Client <-> Server LOG_FILE:"log_file", TORRENT: "torrent file" } + <----- ACK pid_client / ERROR - - dupa fiecare msg 1,2 Serverul trimite un mesaj care indica daca a aparut sau nu vreo eroare - -> dupa msg 2 serverul trimite "" - 3. Mesaje STOP - trimis pt oprirea unui client - - msg 1: STOP_MSG (definit in Util.py) - - msg 2: numele clientului (un string) - - dupa fiecare msg 1,2 Serverul trimite un mesaj care indica daca a aparut sau nu vreo eroare + -----> STOP_CLIENT (definit in Util.py) + <----- ACK/ERROR + -----> numele clientului (un string) + <----- ACK/ERROR 4. Mesaje STATUS - trimise de client pt interogarea starii - - msg 1: tipul mesajului STATUS_MSG (definit in Util.py) - - msg 2: dictionar - TODO - - dupa fiecare msg 1,2 Serverul trimite un mesaj care indica daca a aparut sau nu vreo eroare + -----> tipul mesajului STATUS_MSG (definit in Util.py) + -----> diff --git a/autorun/Util.py b/autorun/Util.py index d5da785..10a4128 100644 --- a/autorun/Util.py +++ b/autorun/Util.py @@ -2,7 +2,8 @@ #!/usr/bin/env python SERVER_PORT = 10004 -SERVER_HOST = "127.0.0.1" +#SERVER_HOST = "127.0.0.1" +SERVER_HOST = "172.16.20.3" """ Message types: client -> server """ diff --git a/autorun/server/Server.py b/autorun/server/Server.py index 6ac9bd3..cf4b6c2 100644 --- a/autorun/server/Server.py +++ b/autorun/server/Server.py @@ -11,8 +11,6 @@ from TransmissionRun import * from TriblerRun import * DEBUG = True - - class MyDaemon(Daemon): ip = "" @@ -108,7 +106,7 @@ class MyDaemon(Daemon): serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) if(DEBUG): - print "Server: host ip = %s, port = %d"%(SERVER_HOST,SERVER_PORT) + print "Server: host ip = %s, port = %d"%(ip,port) serversocket.bind((ip,port)); serversocket.listen(10) #max 10 requests clientsocks = [] @@ -169,10 +167,12 @@ if __name__ == "__main__": if len(sys.argv) >= 2: if 'start' == sys.argv[1]: - if(len(sys.argv) != 4): - print "usage:\n\t %s start " % sys.argv[0] - sys.exit(2) - daemon = MyDaemon('/tmp/daemon-example.pid', sys.argv[2], int(sys.argv[3]), stdout = '/home/p2p/out', stderr = 'home/p2p/err') + #if(len(sys.argv) != 4): + # print "usage:\n\t %s start " % sys.argv[0] + # sys.exit(2) + + #daemon = MyDaemon('/tmp/daemon-example.pid', sys.argv[2], int(sys.argv[3]), stdout = '/home/p2p/out', stderr = 'home/p2p/err') + daemon = MyDaemon('/tmp/daemon-example.pid', SERVER_HOST, SERVER_PORT, stdout = '/home/p2p/out', stderr = 'home/p2p/err') daemon.start() elif 'stop' == sys.argv[1]: daemon = MyDaemon('/tmp/daemon-example.pid') -- 2.20.1