/[mldonkey]/mldonkey/src/networks/donkey/donkeyProtoServer.ml
ViewVC logotype

Diff of /mldonkey/src/networks/donkey/donkeyProtoServer.ml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.15 by spiralvoice, Thu Jun 23 10:37:25 2005 UTC revision 1.16 by spiralvoice, Thu Jul 7 00:25:46 2005 UTC
# Line 83  module Connect = struct Line 83  module Connect = struct
83          port = port;          port = port;
84          tags = tags;          tags = tags;
85        }        }
86        
87      let print t =      let print t =
88        lprintf "CONNECT:\n";        lprintf_nl "CONNECT:";
89        lprintf "MD4: %s\n" (Md4.to_string t.md4);        lprintf_nl "MD4: %s" (Md4.to_string t.md4);
90        lprintf "ip: %s\n" (Ip.to_string t.ip);        lprintf_nl "ip: %s" (Ip.to_string t.ip);
91        lprintf "port: %d\n" t.port;        lprintf_nl "port: %d" t.port;
92        lprintf "tags: ";        lprintf "tags: ";
93        print_tags t.tags        print_tags t.tags;
94              lprintf_nl ""
95    
96      let bprint oc t =      let bprint oc t =
97        Printf.bprintf oc "CONNECT:\n";        Printf.bprintf oc "CONNECT:\n";
98        Printf.bprintf oc "%s\n" (Md4.to_string t.md4);        Printf.bprintf oc "%s\n" (Md4.to_string t.md4);
# Line 133  ascii [ 9(3)(4)(0) M a i n(0)(0)(2)(0)(5 Line 134  ascii [ 9(3)(4)(0) M a i n(0)(0)(2)(0)(5
134        iter s 2 nchans        iter s 2 nchans
135    
136      let print t =      let print t =
137        lprintf "CHANNELS:\n";        lprintf_nl "CHANNELS:";
138        List.iter (fun c ->        List.iter (fun c ->
139            lprintf "  %s: %d\n" c.name c.number;            lprintf_nl "  %s: %d" c.name c.number;
140        ) t        ) t
141    
142       let bprint oc t =       let bprint oc t =
# Line 174  module SetID = struct Line 175  module SetID = struct
175         }         }
176    
177      let print t =      let print t =
178        lprintf "SET_ID:\n%s\n" (if t.zlib then "Zlib" else "");        lprintf_nl "SET_ID:\n%s" (if t.zlib then "Zlib" else "");
179        lprintf "id: %s\n" (Ip.to_string t.ip);        lprintf_nl "id: %s" (Ip.to_string t.ip);
180        match t.port with        match t.port with
181          None -> ()          None -> ()
182          | Some port ->          | Some port ->
183             lprintf "Real Port: %d\n" port             lprintf_nl "Real Port: %d" port
184    
185      let bprint oc t =      let bprint oc t =
186        Printf.bprintf oc "SET_ID: %s\n"  (if t.zlib then "Zlib" else "");        Printf.bprintf oc "SET_ID: %s\n"  (if t.zlib then "Zlib" else "");
# Line 199  module AckID = struct Line 200  module AckID = struct
200      let parse len s = ()      let parse len s = ()
201            
202      let print t =      let print t =
203        lprintf "ACK_ID:\n"        lprintf_nl "ACK_ID:"
204    
205      let bprint oc t =      let bprint oc t =
206        Printf.bprintf oc "ACK_ID\n"        Printf.bprintf oc "ACK_ID\n"
# Line 217  module Message = struct Line 218  module Message = struct
218        v        v
219            
220      let print t =      let print t =
221        lprintf "MESSAGE:\n";        lprintf_nl "MESSAGE:";
222        lprintf "message = \"%s\"" (String.escaped t)        lprintf_nl "message = \"%s\"" (String.escaped t)
223            
224      let bprint oc t =      let bprint oc t =
225        Printf.bprintf oc "MESSAGE:\n";        Printf.bprintf oc "MESSAGE:\n";
# Line 256  module Share = struct Line 257  module Share = struct
257        files        files
258            
259      let print t =      let print t =
260        lprintf "SHARED:\n";        lprintf_nl "SHARED:";
261        List.iter (fun t ->        List.iter (fun t ->
262            lprintf "FILE:\n";            lprintf_nl "FILE:";
263            lprintf "  MD4: %s\n" (Md4.to_string t.f_md4);            lprintf_nl "  MD4: %s" (Md4.to_string t.f_md4);
264            lprintf "  ip: %s\n" (Ip.to_string t.f_ip);            lprintf_nl "  ip: %s" (Ip.to_string t.f_ip);
265            lprintf "  port: %d\n" t.f_port;            lprintf_nl "  port: %d" t.f_port;
266            lprintf "  tags: ";            lprintf "  tags: ";
267            print_tags t.f_tags;            print_tags t.f_tags;
268            lprint_newline ();) t            lprintf_nl "";) t
269            
270      let bprint oc t =      let bprint oc t =
271        Printf.bprintf oc "SHARED:\n";        Printf.bprintf oc "SHARED:\n";
# Line 318  module Info = struct Line 319  module Info = struct
319        users, files        users, files
320            
321      let print (users, files) =      let print (users, files) =
322        lprintf "INFO:\n";        lprintf_nl "INFO:";
323        lprintf "users: %d files: %d\n"  users files        lprintf_nl "users: %d files: %d"  users files
324    
325     let bprint oc (users, files) =     let bprint oc (users, files) =
326        Printf.bprintf oc "INFO:\n";        Printf.bprintf oc "INFO:\n";
# Line 349  module ServerList = struct Line 350  module ServerList = struct
350        iter 0        iter 0
351                        
352      let print t =      let print t =
353        lprintf "SERVER LIST\n";        lprintf_nl "SERVER LIST";
354        List.iter (fun l ->        List.iter (fun l ->
355            lprintf "   %s : %d\n" (Ip.to_string l.ip) l.port;            lprintf_nl "   %s : %d" (Ip.to_string l.ip) l.port;
356        ) t        ) t
357    
358      let bprint oc t =      let bprint oc t =
# Line 398  module ServerInfo = struct Line 399  module ServerInfo = struct
399        }        }
400            
401      let print t =      let print t =
402        lprintf "SERVER INFO:\n";        lprintf_nl "SERVER INFO:";
403        lprintf "MD4: %s\n" (Md4.to_string t.md4);        lprintf_nl "MD4: %s" (Md4.to_string t.md4);
404        lprintf "ip: %s\n" (Ip.to_string t.ip);        lprintf_nl "ip: %s" (Ip.to_string t.ip);
405        lprintf "port: %d\n" t.port;        lprintf_nl "port: %d" t.port;
406        lprintf "tags: ";        lprintf "tags: ";
407        print_tags t.tags        print_tags t.tags
408    
# Line 455  module QueryReply  = struct Line 456  module QueryReply  = struct
456      let parse len s = get_replies s 1      let parse len s = get_replies s 1
457            
458      let print t =      let print t =
459        lprintf "FOUND:\n";        lprintf_nl "FOUND:";
460        List.iter (fun t ->        List.iter (fun t ->
461            lprintf "FILE:\n";            lprintf_nl "FILE:";
462            lprintf "  MD4: %s\n" (Md4.to_string t.f_md4);            lprintf_nl "  MD4: %s" (Md4.to_string t.f_md4);
463            lprintf "  ip: %s\n" (Ip.to_string t.f_ip);            lprintf_nl "  ip: %s" (Ip.to_string t.f_ip);
464            lprintf "  port: %d\n" t.f_port;            lprintf_nl "  port: %d" t.f_port;
465            lprintf "  tags: ";            lprintf "  tags: ";
466            print_tags t.f_tags;            print_tags t.f_tags;
467            lprint_newline ();) t            lprintf_nl "") t
468    
469      let bprint oc t =      let bprint oc t =
470        Printf.bprintf oc "FOUND:\n";        Printf.bprintf oc "FOUND:\n";
# Line 504  module NoArg = functor(M: sig val m : st Line 505  module NoArg = functor(M: sig val m : st
505          let parse len s = ()          let parse len s = ()
506                    
507          let print t =          let print t =
508            lprintf "%s:\n" M.m            lprintf_nl "%s:" M.m
509                    
510          let write (buf: Buffer.t) (t: t) = unit          let write (buf: Buffer.t) (t: t) = unit
511                        
# Line 651  translation, i.e. Field_Artist = "Artist Line 652  translation, i.e. Field_Artist = "Artist
652        | QHasMaxVal (name, field) ->        | QHasMaxVal (name, field) ->
653            Printf.bprintf oc "Field[%s] < [%s]" (string_of_field name) (Int64.to_string field)            Printf.bprintf oc "Field[%s] < [%s]" (string_of_field name) (Int64.to_string field)
654        | QNone ->        | QNone ->
655            lprintf "print_query: QNone in query\n";            lprintf_nl "print_query: QNone in query";
656            ()            ()
657            
658            
# Line 714  translation, i.e. Field_Artist = "Artist Line 715  translation, i.e. Field_Artist = "Artist
715            buf_string buf name            buf_string buf name
716    
717        | QNone ->        | QNone ->
718            lprintf "print_query: QNone in query\n";            lprintf_nl "print_query: QNone in query";
719            ()            ()
720                            
721    end    end
# Line 732  module QueryUsers = struct (* request 26 Line 733  module QueryUsers = struct (* request 26
733            let name, pos = get_string s 2 in            let name, pos = get_string s 2 in
734            name            name
735        | _ ->        | _ ->
736            lprintf "QueryUsers: unknown tag %d\n" targ;            lprintf_nl "QueryUsers: unknown tag %d" targ;
737            raise Not_found            raise Not_found
738                        
739      let print t =      let print t =
740        lprintf "QUERY USERS [%s]\n" t        lprintf_nl "QUERY USERS [%s]" t
741    
742       let bprint oc t =       let bprint oc t =
743        Printf.bprintf oc "QUERY USERS [%s]\n" t        Printf.bprintf oc "QUERY USERS [%s]\n" t
# Line 786  module QueryUsersReply = struct (* reque Line 787  module QueryUsersReply = struct (* reque
787        parse_clients s 5 nclients []        parse_clients s 5 nclients []
788            
789      let print t =      let print t =
790        lprintf "QUERY USERS REPLY:\n";        lprintf_nl "QUERY USERS REPLY:";
791        List.iter (fun t ->        List.iter (fun t ->
792            lprintf "MD4: %s\n" (Md4.to_string t.md4);            lprintf_nl "MD4: %s" (Md4.to_string t.md4);
793            lprintf "ip: %s\n" (Ip.to_string t.ip);            lprintf_nl "ip: %s" (Ip.to_string t.ip);
794            lprintf "port: %d\n" t.port;            lprintf_nl "port: %d" t.port;
795            lprintf "tags: ";            lprintf "tags: ";
796            print_tags t.tags; lprint_newline ();) t            print_tags t.tags;
797              lprintf_nl "";) t
798    
799      let bprint oc t =      let bprint oc t =
800        Printf.bprintf oc "QUERY USERS REPLY:\n";        Printf.bprintf oc "QUERY USERS REPLY:\n";
# Line 821  module QueryLocation  = struct Line 823  module QueryLocation  = struct
823        get_md4 s 1        get_md4 s 1
824                
825      let print t =      let print t =
826        lprintf "QUERY LOCATION OF %s" (Md4.to_string t)        lprintf_nl "QUERY LOCATION OF %s" (Md4.to_string t)
827    
828      let bprint oc t =      let bprint oc t =
829        Printf.bprintf oc "QUERY LOCATION OF %s\n" (Md4.to_string t)        Printf.bprintf oc "QUERY LOCATION OF %s\n" (Md4.to_string t)
# Line 854  module QueryLocationReply  = struct Line 856  module QueryLocationReply  = struct
856        { locs =locs; md4 = md4 }        { locs =locs; md4 = md4 }
857            
858      let print t =      let print t =
859        lprintf "LOCATION OF %s\n" (Md4.to_string t.md4);        lprintf_nl "LOCATION OF %s" (Md4.to_string t.md4);
860        List.iter (fun l ->        List.iter (fun l ->
861            lprintf "   %s : %d %s\n" (Ip.to_string l.ip) l.port            lprintf_nl "   %s : %d %s" (Ip.to_string l.ip) l.port
862              (if not (Ip.valid l.ip) then              (if not (Ip.valid l.ip) then
863                Printf.sprintf "(Firewalled %Ld)" (id_of_ip l.ip)                Printf.sprintf "(Firewalled %Ld)" (id_of_ip l.ip)
864              else "");              else "");
# Line 927  module QueryIDReply  = struct Line 929  module QueryIDReply  = struct
929        { ip = ip; port = port; }        { ip = ip; port = port; }
930                
931      let print t =      let print t =
932        lprintf "IDENTIFICATION %s : %d\n" (Ip.to_string t.ip) t.port        lprintf_nl "IDENTIFICATION %s : %d" (Ip.to_string t.ip) t.port
933    
934      let bprint oc t =      let bprint oc t =
935        Printf.bprintf oc "IDENTIFICATION %s : %d\n" (Ip.to_string t.ip) t.port        Printf.bprintf oc "IDENTIFICATION %s : %d\n" (Ip.to_string t.ip) t.port
# Line 951  module QueryServers  = struct Line 953  module QueryServers  = struct
953        { ip = ip; port = port; }        { ip = ip; port = port; }
954                
955      let print t =      let print t =
956        lprintf "QUERY SERVERS %s : %d\n" (Ip.to_string t.ip) t.port        lprintf_nl "QUERY SERVERS %s : %d" (Ip.to_string t.ip) t.port
957    
958      let bprint oc t =      let bprint oc t =
959        Printf.bprintf oc "QUERY SERVERS %s : %d\n" (Ip.to_string t.ip) t.port        Printf.bprintf oc "QUERY SERVERS %s : %d\n" (Ip.to_string t.ip) t.port
# Line 995  module QueryServersReply  = struct Line 997  module QueryServersReply  = struct
997            { server_ip = Ip.null; server_port = 0; servers = servers }              { server_ip = Ip.null; server_port = 0; servers = servers }  
998                
999      let print t =      let print t =
1000        lprintf "SERVERS QUERY REPLY %s : %d\n" (        lprintf_nl "SERVERS QUERY REPLY %s : %d" (
1001          Ip.to_string t.server_ip) t.server_port;          Ip.to_string t.server_ip) t.server_port;
1002        List.iter (fun s ->        List.iter (fun s ->
1003            lprintf "   %s:%d\n" (Ip.to_string s.ip) s.port;            lprintf_nl "   %s:%d" (Ip.to_string s.ip) s.port;
1004        ) t.servers        ) t.servers
1005    
1006       let bprint oc t =       let bprint oc t =
# Line 1154  let rec parse magic s = Line 1156  let rec parse magic s =
1156    with    with
1157      e ->      e ->
1158        if !CommonOptions.verbose_unknown_messages then begin        if !CommonOptions.verbose_unknown_messages then begin
1159            lprintf "Unknown message From server: %s (magic %d)\n"            lprintf_nl "Unknown message From server: %s (magic %d)"
1160              (Printexc2.to_string e) magic;              (Printexc2.to_string e) magic;
1161            let tmp_file = Filename.temp_file "comp" "pak" in            let tmp_file = Filename.temp_file "comp" "pak" in
1162            File.from_string tmp_file s;            File.from_string tmp_file s;
1163            lprintf "Saved unknown packet %s\n" tmp_file;            lprintf_nl "Saved unknown packet %s" tmp_file;
             
1164            dump s;            dump s;
1165            lprint_newline ();            lprintf_nl "";
1166          end;          end;
1167        UnknownReq s        UnknownReq s
1168                
# Line 1172  let print t = Line 1173  let print t =
1173      | SetIDReq t -> SetID.print t      | SetIDReq t -> SetID.print t
1174      | AckIDReq t -> AckID.print t      | AckIDReq t -> AckID.print t
1175      | MessageReq t -> Message.print t      | MessageReq t -> Message.print t
1176      | BadProtocolVersionReq -> lprintf "BAD PROTOCOL VERSION"      | BadProtocolVersionReq -> lprintf_nl "BAD PROTOCOL VERSION"
1177      | ShareReq t -> Share.print t      | ShareReq t -> Share.print t
1178      | InfoReq t -> Info.print t      | InfoReq t -> Info.print t
1179      | ServerListReq t -> ServerList.print t      | ServerListReq t -> ServerList.print t
# Line 1192  let print t = Line 1193  let print t =
1193      | ChatRoomsReq t -> ChatRooms.print t      | ChatRoomsReq t -> ChatRooms.print t
1194    
1195      | QueryMoreResultsReq ->      | QueryMoreResultsReq ->
1196          lprintf "QUERY MORE RESULTS\n";          lprintf_nl "QUERY MORE RESULTS";
1197      | Mldonkey_MldonkeyUserReplyReq ->      | Mldonkey_MldonkeyUserReplyReq ->
1198          lprintf "MLDONKEY USER\n";          lprintf_nl "MLDONKEY USER";
1199      | Mldonkey_SubscribeReq (num, lifetime, t) ->      | Mldonkey_SubscribeReq (num, lifetime, t) ->
1200          lprintf "MLDONKEY SUBSCRIPTION %d FOR %d SECONDS\n" num lifetime;          lprintf_nl "MLDONKEY SUBSCRIPTION %d FOR %d SECONDS" num lifetime;
1201                    
1202          Query.print t          Query.print t
1203      | Mldonkey_NotificationReq (num,t) ->      | Mldonkey_NotificationReq (num,t) ->
1204          lprintf "MLDONKEY NOTIFICATIONS TO %d\n" num;          lprintf_nl "MLDONKEY NOTIFICATIONS TO %d" num;
1205          QueryReply.print t          QueryReply.print t
1206      | Mldonkey_CloseSubscribeReq num ->      | Mldonkey_CloseSubscribeReq num ->
1207          lprintf "MLDONKEY CLOSE SUBSCRIPTION %d\n" num;          lprintf_nl "MLDONKEY CLOSE SUBSCRIPTION %d" num;
1208      | UnknownReq s ->      | UnknownReq s ->
1209          let len = String.length s in          let len = String.length s in
1210          lprintf "UnknownReq:\n";          lprintf_nl "UnknownReq:";
1211          lprintf "ascii: [";          lprintf "ascii: [";
1212          for i = 0 to len - 1 do          for i = 0 to len - 1 do
1213            let c = s.[i] in            let c = s.[i] in
# Line 1216  let print t = Line 1217  let print t =
1217            else            else
1218              lprintf "(%d)" n              lprintf "(%d)" n
1219          done;          done;
1220          lprintf "]\n";          lprintf_nl "]";
1221          lprintf "dec: [";          lprintf "dec: [";
1222          for i = 0 to len - 1 do          for i = 0 to len - 1 do
1223            let c = s.[i] in            let c = s.[i] in
1224            let n = int_of_char c in            let n = int_of_char c in
1225            lprintf "(%d)" n                        lprintf "(%d)" n            
1226          done;          done;
1227          lprintf "]\n";          lprintf_nl "]";
1228    end;    end;
1229    lprint_newline ()    lprintf_nl ""
1230    
1231    
1232  let bprint oc t =  let bprint oc t =
# Line 1262  let bprint oc t = Line 1263  let bprint oc t =
1263          Printf.bprintf oc "MLDONKEY NOTIFICATIONS TO %d\n" num;          Printf.bprintf oc "MLDONKEY NOTIFICATIONS TO %d\n" num;
1264          QueryReply.bprint oc t          QueryReply.bprint oc t
1265      | Mldonkey_CloseSubscribeReq num ->      | Mldonkey_CloseSubscribeReq num ->
1266          lprintf "MLDONKEY CLOSE SUBSCRIPTION %d\n" num;          lprintf_nl "MLDONKEY CLOSE SUBSCRIPTION %d" num;
1267                    
1268      | UnknownReq s ->      | UnknownReq s ->
1269  (* let len = String.length s in*)  (* let len = String.length s in*)
# Line 1392  let _ = Line 1393  let _ =
1393    lprintf "[%s] <> [%s]\n" s (String.escaped ss);    lprintf "[%s] <> [%s]\n" s (String.escaped ss);
1394    assert (s = ss);    assert (s = ss);
1395    exit 2    exit 2
   *)  
1396      *)

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26