17 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 |
*) |
*) |
19 |
|
|
20 |
|
open Options |
21 |
open Int64ops |
open Int64ops |
22 |
open AnyEndian |
open AnyEndian |
23 |
open Printf2 |
open Printf2 |
26 |
open LittleEndian |
open LittleEndian |
27 |
open CommonGlobals |
open CommonGlobals |
28 |
|
|
29 |
|
open DonkeyOptions |
30 |
open DonkeyTypes |
open DonkeyTypes |
31 |
open DonkeyMftp |
open DonkeyMftp |
32 |
|
|
33 |
let emule_version b1 b2 b3 b4 b5 = |
let compatibleclient = ref 10 |
34 |
let s = Printf.sprintf "%s" |
|
35 |
(string_of_int(int_of_string("0b" ^ |
let get_emule_version () = |
36 |
(Misc.dec2bin (int_of_string b1) 8) ^ |
(!compatibleclient lsl 24) lor |
37 |
(Misc.dec2bin (int_of_string b2) 7) ^ |
(int_of_string(Autoconf.major_version) lsl 17) lor |
38 |
(Misc.dec2bin (int_of_string b3) 7) ^ |
(int_of_string(Autoconf.minor_version) lsl 10) lor |
39 |
(Misc.dec2bin (int_of_string b4) 3) ^ |
(int_of_string(Autoconf.sub_version) lsl 7) |
|
(Misc.dec2bin (int_of_string b5) 7)))) |
|
|
in s |
|
40 |
|
|
41 |
(* TODO : update this |
(* TODO : update this |
42 |
I downgraded some of those to get better results : |
I downgraded some of those to get better results : |
43 |
We don't use emule udp extension, client_md4 in sourceexchange or complete sources in |
We don't use emule udp extension, client_md4 in sourceexchange or complete sources in |
44 |
file request *) |
file request *) |
45 |
let mldonkey_emule_proto = { |
let mldonkey_emule_proto = |
46 |
|
{ |
47 |
emule_comments = 1; |
emule_comments = 1; |
48 |
emule_version = (int_of_string (emule_version "10" Autoconf.major_version Autoconf.minor_version Autoconf.sub_version "0")); |
emule_version = get_emule_version (); |
|
(* first parameter means compatibleclient, MLDonkeys value is 10 *) |
|
49 |
emule_release = ""; |
emule_release = ""; |
50 |
emule_secident = 3; (* Emule uses v1 if advertising both, v2 if only advertising 2 *) |
emule_secident = 3; (* Emule uses v1 if advertising both, v2 if only advertising 2 *) |
51 |
emule_noviewshared = 0; |
emule_noviewshared = 0; |
54 |
emule_sourceexchange = 2; (* 2 : +client_md4 3 : +IdHybrid (emule Kademlia?)*) |
emule_sourceexchange = 2; (* 2 : +client_md4 3 : +IdHybrid (emule Kademlia?)*) |
55 |
emule_multipacket = 0; (* 1 *) |
emule_multipacket = 0; (* 1 *) |
56 |
emule_extendedrequest = 1; (* 1: +file_status 2: +ncomplete_sources*) |
emule_extendedrequest = 1; (* 1: +file_status 2: +ncomplete_sources*) |
57 |
emule_features = 0; (* 3 *) |
emule_features = 3; (* 3 *) |
58 |
emule_udpver = 0; (* 4 *) |
emule_udpver = 0; (* 4 *) |
59 |
} |
} |
60 |
|
|
104 |
(0)(0)(0)(0)(0)(0) |
(0)(0)(0)(0)(0)(0) |
105 |
] |
] |
106 |
*) |
*) |
107 |
|
let rec lbprint_tags buf tags = |
108 |
|
match tags with |
109 |
|
[] -> Printf.bprintf buf "" |
110 |
|
| tag :: tags -> |
111 |
|
Printf.bprintf buf " (%s)=(%s)" (escaped_string_of_field tag) |
112 |
|
(string_of_tag_value tag.tag_value); |
113 |
|
lbprint_tags buf tags |
114 |
|
|
115 |
module Connect = struct |
module Connect = struct |
116 |
type t = { |
type t = { |
117 |
|
hash_len : int; |
118 |
md4 : Md4.t; |
md4 : Md4.t; |
|
version : int; |
|
119 |
ip: Ip.t; |
ip: Ip.t; |
120 |
port: int; |
port: int; |
121 |
tags : tag list; |
tags : tag list; |
122 |
server_info : (Ip.t * int) option; |
server_info : (Ip.t * int) option; |
123 |
left_bytes: string; |
left_bytes : string; |
124 |
} |
} |
125 |
|
|
126 |
let names_of_tag = |
let names_of_tag = |
127 |
[ |
[ |
128 |
"\001", Field_UNKNOWN "name"; |
"\001", Field_UNKNOWN "name"; |
|
"\017", Field_UNKNOWN "version"; |
|
129 |
"\015", Field_UNKNOWN "port"; |
"\015", Field_UNKNOWN "port"; |
130 |
|
"\017", Field_UNKNOWN "version"; |
131 |
"\031", Field_UNKNOWN "udpport"; |
"\031", Field_UNKNOWN "udpport"; |
132 |
"\060", Field_UNKNOWN "downloadtime"; |
"\060", Field_UNKNOWN "downloadtime"; |
133 |
"\061", Field_UNKNOWN "incompleteparts"; |
"\061", Field_UNKNOWN "incompleteparts"; |
135 |
"\249", Field_UNKNOWN "emule_udpports"; |
"\249", Field_UNKNOWN "emule_udpports"; |
136 |
"\250", Field_UNKNOWN "emule_miscoptions1"; |
"\250", Field_UNKNOWN "emule_miscoptions1"; |
137 |
"\251", Field_UNKNOWN "emule_version"; |
"\251", Field_UNKNOWN "emule_version"; |
138 |
|
"\252", Field_UNKNOWN "buddy_ip"; |
139 |
|
"\253", Field_UNKNOWN "buddy_udp"; |
140 |
|
"\254", Field_UNKNOWN "emule_miscoptions2"; |
141 |
] |
] |
142 |
|
|
143 |
let parse len s = |
let parse reply len s = |
144 |
let version = get_uint8 s 1 in |
let hash_len, pos = if not reply then get_uint8 s 1, 2 else -1, 1 in |
145 |
let md4 = get_md4 s 2 in |
let md4 = get_md4 s pos in |
146 |
let ip = get_ip s 18 in |
let ip = get_ip s (pos+16) in |
147 |
let port = get_port s 22 in |
let port = get_port s (pos+20) in |
148 |
(* lprintf "port: %d" port; lprint_newline (); *) |
let tags, pos = get_tags s (pos+22) names_of_tag in |
149 |
let tags, pos = get_tags s 24 names_of_tag in |
let server_info = Some (get_ip s pos, get_port s (pos+4)) in |
|
let len = String.length s in |
|
|
let server_info = |
|
|
Some (get_ip s pos, get_port s (pos+4)) |
|
|
in |
|
150 |
let left_bytes = String.sub s (pos+6) (String.length s - pos - 6) in |
let left_bytes = String.sub s (pos+6) (String.length s - pos - 6) in |
151 |
{ |
{ |
152 |
|
hash_len = hash_len; |
153 |
md4 = md4; |
md4 = md4; |
|
version = version; |
|
154 |
ip = ip; |
ip = ip; |
155 |
port = port; |
port = port; |
156 |
tags = tags; |
tags = tags; |
158 |
left_bytes = left_bytes; |
left_bytes = left_bytes; |
159 |
} |
} |
160 |
|
|
161 |
|
|
162 |
let print t = |
let print t = |
163 |
lprintf "Connect (version %d) from [%s:%d] MD4: %s" |
let b1 = Buffer.create 50 in |
164 |
t.version |
let b2 = Buffer.create 5 in |
165 |
(Ip.to_string t.ip) |
lbprint_tags b1 t.tags; |
166 |
t.port |
String.iter (fun c -> Printf.bprintf b2 "(%d)" (int_of_char c)) t.left_bytes; |
167 |
(Md4.to_string t.md4); |
lprintf_nl "Connect [hl: %d] [md4: %s] [ip: %s:%d] [server: %s] [left: %s] [tags:%s]" |
168 |
(match t.server_info with |
t.hash_len |
169 |
None -> lprint_newline () |
(Md4.to_string t.md4) |
170 |
| Some (ip, port) -> |
(Ip.to_string t.ip) t.port |
171 |
lprintf_nl " on server: %s:%d" (Ip.to_string ip) port); |
(match t.server_info with |
172 |
lprintf "tags: "; |
None -> "None" |
173 |
print_tags t.tags; |
| Some (ip, port) -> Printf.sprintf "%s:%d" (Ip.to_string ip) port) |
174 |
if String.length t.left_bytes <> 0 then begin |
(if String.length t.left_bytes <> 0 then (Buffer.contents b2) else "None") |
175 |
lprintf " left bytes = "; |
(Buffer.contents b1) |
176 |
String.iter (fun c -> lprintf "(%d)" (int_of_char c)) |
|
177 |
t.left_bytes end |
|
178 |
|
let write reply buf t = |
179 |
|
if not reply then |
180 |
|
buf_int8 buf 16; |
181 |
|
|
|
let write buf t = |
|
|
buf_int8 buf t.version; |
|
182 |
buf_md4 buf t.md4; |
buf_md4 buf t.md4; |
183 |
buf_ip buf t.ip; |
buf_ip buf t.ip; |
184 |
buf_port buf t.port; |
buf_port buf t.port; |
191 |
| Some (ip, port) -> |
| Some (ip, port) -> |
192 |
buf_ip buf ip; |
buf_ip buf ip; |
193 |
buf_port buf port; |
buf_port buf port; |
194 |
end; |
end |
|
Buffer.add_string buf t.left_bytes |
|
195 |
|
|
196 |
end |
end |
197 |
|
|
|
module ConnectReply = struct |
|
|
open Connect |
|
|
type t = Connect.t |
|
|
|
|
|
let parse len s = |
|
|
let version = get_uint8 s 1 in |
|
|
let md4 = get_md4 s 2 in |
|
|
let ip = get_ip s 18 in |
|
|
let port = get_port s 22 in |
|
|
let tags, pos = get_tags s 24 names_of_tag in |
|
|
let len = String.length s in |
|
|
let server_info = |
|
|
Some (get_ip s pos, get_port s (pos+4)) |
|
|
in |
|
|
let left_bytes = String.sub s (pos+6) (String.length s - pos - 6) in |
|
|
{ |
|
|
md4 = md4; |
|
|
version = version; |
|
|
ip = ip; |
|
|
port = port; |
|
|
tags = tags; |
|
|
server_info = server_info; |
|
|
left_bytes = left_bytes; |
|
|
} |
|
|
|
|
|
let parse len s = |
|
|
let md4 = get_md4 s 1 in |
|
|
let ip = get_ip s 17 in |
|
|
let port = get_port s 21 in |
|
|
let tags, pos = get_tags s 23 names_of_tag in |
|
|
let server_info = Some (get_ip s pos, get_port s (pos+4)) in |
|
|
let left_bytes = String.sub s (pos+6) (String.length s - pos - 6) in |
|
|
{ |
|
|
md4 = md4; |
|
|
ip = ip; |
|
|
port = port; |
|
|
tags = tags; |
|
|
server_info = server_info; |
|
|
left_bytes = left_bytes; |
|
|
version = -1; |
|
|
} |
|
|
|
|
|
let print t = |
|
|
lprintf "Connect reply from [%s:%d] MD4: %s" |
|
|
(Ip.to_string t.ip) |
|
|
t.port |
|
|
(Md4.to_string t.md4); |
|
|
(match t.server_info with |
|
|
None -> lprint_newline () |
|
|
| Some (ip, port) -> |
|
|
lprintf_nl " on server: %s:%d" (Ip.to_string ip) port); |
|
|
lprintf "tags: "; |
|
|
print_tags t.tags; |
|
|
if String.length t.left_bytes <> 0 then begin |
|
|
lprintf " left bytes = "; |
|
|
String.iter (fun c -> lprintf "(%d)" (int_of_char c)) |
|
|
t.left_bytes end |
|
|
|
|
|
let write buf t = |
|
|
buf_md4 buf t.md4; |
|
|
buf_ip buf t.ip; |
|
|
buf_port buf t.port; |
|
|
buf_tags buf t.tags names_of_tag; |
|
|
begin |
|
|
match t.server_info with |
|
|
None -> () |
|
|
| Some (ip, port) -> |
|
|
buf_ip buf ip; |
|
|
buf_port buf port; |
|
|
end; |
|
|
Buffer.add_string buf t.left_bytes |
|
|
end |
|
|
|
|
198 |
module Say = struct |
module Say = struct |
199 |
type t = string |
type t = string |
200 |
|
|
203 |
s |
s |
204 |
|
|
205 |
let print t = |
let print t = |
206 |
lprintf "SAY %s" t |
lprintf_nl "SAY %s" t |
207 |
|
|
208 |
let write buf t = |
let write buf t = |
209 |
buf_string buf t |
buf_string buf t |
216 |
get_md4 s 1 |
get_md4 s 1 |
217 |
|
|
218 |
let print t = |
let print t = |
219 |
lprintf "%s OF %s" M.m (Md4.to_string t) |
lprintf_nl "OneMd4: %s OF %s" M.m (Md4.to_string t) |
220 |
|
|
221 |
let write buf t = |
let write buf t = |
222 |
buf_md4 buf t |
buf_md4 buf t |
223 |
end) |
|
224 |
|
end) |
225 |
|
|
226 |
module JoinQueue = struct |
module JoinQueue = struct |
227 |
type t = Md4.t option |
type t = Md4.t option |
232 |
else None |
else None |
233 |
|
|
234 |
let print t = |
let print t = |
235 |
lprintf "JOIN QUEUE"; |
lprintf_nl "JOIN QUEUE %s" |
236 |
(match t with None -> () | Some md4 -> |
(match t with None -> "" | Some md4 -> |
237 |
lprintf " OF %s" (Md4.to_string md4)); |
Printf.sprintf "OF %s" (Md4.to_string md4)) |
|
lprint_newline () |
|
238 |
|
|
239 |
let write emule buf t = |
let write emule buf t = |
240 |
if extendedrequest emule > 0 then |
if extendedrequest emule > 0 then |
321 |
emule_extension = emule_extension } |
emule_extension = emule_extension } |
322 |
|
|
323 |
let print t = |
let print t = |
324 |
lprintf "QUERY FILE OF %s" (Md4.to_string t.md4); |
lprintf_nl "QUERY FILE OF %s" (Md4.to_string t.md4); |
325 |
match t.emule_extension with |
match t.emule_extension with |
326 |
None -> () |
None -> () |
327 |
| Some (bitmap, ncompletesources) -> |
| Some (bitmap, ncompletesources) -> |
432 |
} |
} |
433 |
|
|
434 |
let print t = |
let print t = |
435 |
lprintf_nl "QUERY FILE REPLY OF %s" (Md4.to_string t.md4); |
lprintf_nl "QUERY FILE REPLY OF %s : \"%s\"" (Md4.to_string t.md4) t.name |
|
lprintf_nl " name = \"%s\"" t.name |
|
436 |
|
|
437 |
let write buf t = |
let write buf t = |
438 |
buf_md4 buf t.md4; |
buf_md4 buf t.md4; |
460 |
} |
} |
461 |
|
|
462 |
let print t = |
let print t = |
463 |
lprintf "BLOC OF %s len %Ld [%Ld - %Ld] " (Md4.to_string t.md4) |
lprintf_nl "BLOC OF %s len %Ld [%Ld - %Ld] " (Md4.to_string t.md4) |
464 |
(t.end_pos -- t.start_pos) |
(t.end_pos -- t.start_pos) |
465 |
t.start_pos |
t.start_pos |
466 |
t.end_pos |
t.end_pos |
495 |
} |
} |
496 |
|
|
497 |
let print t = |
let print t = |
498 |
lprintf "QUERY BLOCS OF %s [%s - %s] [%s - %s] [%s - %s]" |
lprintf_nl "QUERY BLOCS OF %s [%s - %s] [%s - %s] [%s - %s]" |
499 |
(Md4.to_string t.md4) |
(Md4.to_string t.md4) |
500 |
(Int64.to_string t.start_pos1) (Int64.to_string t.end_pos1) |
(Int64.to_string t.start_pos1) (Int64.to_string t.end_pos1) |
501 |
(Int64.to_string t.start_pos2) (Int64.to_string t.end_pos2) |
(Int64.to_string t.start_pos2) (Int64.to_string t.end_pos2) |
744 |
} |
} |
745 |
|
|
746 |
let print m t = |
let print m t = |
747 |
lprintf_nl "%s:" m; |
let b1 = Buffer.create 50 in |
748 |
lprintf_nl " version: %d" t.version; |
lbprint_tags b1 t.tags; |
749 |
lprintf_nl " protversion: %d" t.version; |
lprintf_nl "%s: [version: %d] [protversion: %d] [tags:%s]" m t.version t.protversion (Buffer.contents b1) |
|
lprintf " tags: "; |
|
|
print_tags t.tags; |
|
|
lprint_newline () |
|
750 |
|
|
751 |
let write buf t = |
let write buf t = |
752 |
buf_int8 buf t.version; |
buf_int8 buf t.version; |
761 |
|
|
762 |
let parse len s = get_int16 s 1 |
let parse len s = get_int16 s 1 |
763 |
let print t = |
let print t = |
764 |
lprintf_nl "QUEUE RANKING: %d" t |
lprintf_nl "EmuleQueueRanking: %d" t |
765 |
|
|
766 |
let string_null10 = String.make 10 (char_of_int 0) |
let string_null10 = String.make 10 (char_of_int 0) |
767 |
|
|
777 |
|
|
778 |
let parse len s = get_int s 1 |
let parse len s = get_int s 1 |
779 |
let print t = |
let print t = |
780 |
lprintf_nl "QUEUE RANK: %d" t |
lprintf_nl "QueueRank: %d" t |
781 |
|
|
782 |
let write buf t = |
let write buf t = |
783 |
buf_int buf t |
buf_int buf t |
792 |
get_md4 s 1 |
get_md4 s 1 |
793 |
|
|
794 |
let print t = |
let print t = |
795 |
lprintf_nl "EMULE REQUEST SOURCES: %s" (Md4.to_string t) |
lprintf_nl "EmuleRequestSources: %s" (Md4.to_string t) |
796 |
|
|
797 |
let write buf t = |
let write buf t = |
798 |
buf_md4 buf t |
buf_md4 buf t |
941 |
ncount (Md4.to_string t.md4); |
ncount (Md4.to_string t.md4); |
942 |
for i = 0 to ncount - 1 do |
for i = 0 to ncount - 1 do |
943 |
let s = t.sources.(i) in |
let s = t.sources.(i) in |
944 |
if Ip.valid s.src_ip then |
lprintf_nl "%s %s" |
945 |
lprintf_nl " %s:%d" (Ip.to_string s.src_ip) s.src_port |
(if Ip.valid s.src_ip then |
946 |
|
Printf.sprintf "%s:%d" (Ip.to_string s.src_ip) s.src_port |
947 |
else |
else |
948 |
lprintf_nl " Indirect from %s:%d" |
Printf.sprintf "%s:%d (Indirect)" (Ip.to_string s.src_server_ip) s.src_server_port) |
949 |
(Ip.to_string s.src_server_ip) s.src_server_port; |
(if s.src_md4 != Md4.null then |
950 |
if s.src_md4 != Md4.null then |
Printf.sprintf "MD4: %s" (Md4.to_string s.src_md4) |
951 |
lprintf_nl " Md4: %s" (Md4.to_string s.src_md4) |
else "") |
952 |
done |
done |
953 |
|
|
954 |
let write e buf t = |
let write e buf t = |
972 |
|
|
973 |
type t = |
type t = |
974 |
| ConnectReq of Connect.t |
| ConnectReq of Connect.t |
975 |
| ConnectReplyReq of ConnectReply.t |
| ConnectReplyReq of Connect.t |
976 |
| QueryFileReq of QueryFile.t |
| QueryFileReq of QueryFile.t |
977 |
| QueryFileReplyReq of QueryFileReply.t |
| QueryFileReplyReq of QueryFileReply.t |
978 |
| BlocReq of Bloc.t |
| BlocReq of Bloc.t |
1014 |
begin |
begin |
1015 |
match t with |
match t with |
1016 |
| ConnectReq t -> Connect.print t |
| ConnectReq t -> Connect.print t |
1017 |
| ConnectReplyReq t -> ConnectReply.print t |
| ConnectReplyReq t -> Connect.print t |
1018 |
| QueryFileReq t -> QueryFile.print t |
| QueryFileReq t -> QueryFile.print t |
1019 |
| QueryFileReplyReq t -> QueryFileReply.print t |
| QueryFileReplyReq t -> QueryFileReply.print t |
1020 |
| BlocReq t -> Bloc.print t |
| BlocReq t -> Bloc.print t |
1040 |
QueueRank.print t |
QueueRank.print t |
1041 |
|
|
1042 |
| EmuleClientInfoReq t -> |
| EmuleClientInfoReq t -> |
1043 |
EmuleClientInfo.print "EMULE CLIENT INFO" t |
EmuleClientInfo.print "EmuleClientInfo" t |
1044 |
| EmuleClientInfoReplyReq t -> |
| EmuleClientInfoReplyReq t -> |
1045 |
EmuleClientInfo.print "EMULE CLIENT INFO REPLY" t |
EmuleClientInfo.print "EmuleClientInfoReply" t |
1046 |
| EmuleQueueRankingReq t -> |
| EmuleQueueRankingReq t -> |
1047 |
EmuleQueueRanking.print t |
EmuleQueueRanking.print t |
1048 |
| EmuleRequestSourcesReq t -> |
| EmuleRequestSourcesReq t -> |
1079 |
|
|
1080 |
| UnknownReq (opcode, s) -> |
| UnknownReq (opcode, s) -> |
1081 |
let len = String.length s in |
let len = String.length s in |
1082 |
lprintf_nl "UnknownReq: magic %d, opcode %d\n len %d" opcode |
lprintf_nl "UnknownReq: magic (%d), opcode (%d) len (%d)" opcode |
1083 |
(int_of_char s.[0]) |
(int_of_char s.[0]) |
1084 |
(String.length s); |
(String.length s); |
1085 |
lprintf "ascii: ["; |
lprintf "ascii: ["; |
1091 |
else |
else |
1092 |
lprintf "(%d)" n |
lprintf "(%d)" n |
1093 |
done; |
done; |
1094 |
lprintf_nl "]"; |
lprintf "]\n"; |
1095 |
lprintf "dec: ["; |
lprintf "dec: ["; |
1096 |
for i = 0 to len - 1 do |
for i = 0 to len - 1 do |
1097 |
let c = s.[i] in |
let c = s.[i] in |
1098 |
let n = int_of_char c in |
let n = int_of_char c in |
1099 |
lprintf "(%d)" n |
lprintf "(%d)" n |
1100 |
done; |
done; |
1101 |
lprintf_nl "]" |
lprintf "]\n" |
1102 |
end |
end |
1103 |
|
|
1104 |
let rec parse_emule_packet emule opcode len s = |
let rec parse_emule_packet emule opcode len s = |
1113 |
| 0x60 (* 96 *) -> EmuleQueueRankingReq (EmuleQueueRanking.parse len s) |
| 0x60 (* 96 *) -> EmuleQueueRankingReq (EmuleQueueRanking.parse len s) |
1114 |
|
|
1115 |
| 0x61 (* 97 *) -> |
| 0x61 (* 97 *) -> |
1116 |
let (comment,_) = get_string s 1 in |
let rating = get_uint8 s 1 in |
1117 |
EmuleFileDescReq comment |
let (comment,_) = get_string32 s 2 in |
1118 |
|
EmuleFileDescReq (Printf.sprintf "(%d) %s" rating comment) |
1119 |
|
|
1120 |
| 0x81 (* 129 *) -> EmuleRequestSourcesReq (EmuleRequestSources.parse len s) |
| 0x81 (* 129 *) -> EmuleRequestSourcesReq (EmuleRequestSources.parse len s) |
1121 |
| 0x82 (* 130 *) -> |
| 0x82 (* 130 *) -> |
1175 |
EmuleMultiPacketReq (md4, iter 17) |
EmuleMultiPacketReq (md4, iter 17) |
1176 |
|
|
1177 |
| 0x93 (* 147 *) -> |
| 0x93 (* 147 *) -> |
1178 |
|
if String.length s < 16 then begin |
1179 |
|
lprintf_nl "EmuleMultiPacketAnswer: incomplete request"; |
1180 |
|
raise Not_found |
1181 |
|
end; |
1182 |
let md4 = get_md4 s 1 in |
let md4 = get_md4 s 1 in |
1183 |
|
|
1184 |
(* Printf.printf "MULTI EMULE VERSION %d" |
(* Printf.printf "MULTI EMULE VERSION %d" |
1232 |
227 -> |
227 -> |
1233 |
begin |
begin |
1234 |
match opcode with |
match opcode with |
1235 |
| 1 -> ConnectReq (Connect.parse len s) |
| 1 -> ConnectReq (Connect.parse false len s) |
1236 |
| 70 -> BlocReq (Bloc.parse len s) |
| 70 -> BlocReq (Bloc.parse len s) |
1237 |
| 71 -> QueryBlocReq (QueryBloc.parse len s) |
| 71 -> QueryBlocReq (QueryBloc.parse len s) |
1238 |
| 72 -> NoSuchFileReq (NoSuchFile.parse len s) |
| 72 -> NoSuchFileReq (NoSuchFile.parse len s) |
1239 |
| 73 -> EndOfDownloadReq (EndOfDownload.parse len s) |
| 73 -> EndOfDownloadReq (EndOfDownload.parse len s) |
1240 |
| 74 -> ViewFilesReq (ViewFiles.parse len s) |
| 74 -> ViewFilesReq (ViewFiles.parse len s) |
1241 |
| 75 -> ViewFilesReplyReq (ViewFilesReply.parse len s) |
| 75 -> ViewFilesReplyReq (ViewFilesReply.parse len s) |
1242 |
| 76 -> ConnectReplyReq (ConnectReply.parse len s) |
| 76 -> ConnectReplyReq (Connect.parse true len s) |
1243 |
| 77 -> NewUserIDReq (NewUserID.parse len s) |
| 77 -> NewUserIDReq (NewUserID.parse len s) |
1244 |
| 78 -> SayReq (Say.parse len s) |
| 78 -> SayReq (Say.parse len s) |
1245 |
| 79 -> QueryChunksReq (QueryChunks.parse len s) |
| 79 -> QueryChunksReq (QueryChunks.parse len s) |
1296 |
if !CommonOptions.verbose_unknown_messages then begin |
if !CommonOptions.verbose_unknown_messages then begin |
1297 |
lprintf_nl "Unknown message From client: %s (magic %d)" |
lprintf_nl "Unknown message From client: %s (magic %d)" |
1298 |
(Printexc2.to_string e) magic; |
(Printexc2.to_string e) magic; |
1299 |
let tmp_file = Filename.temp_file "comp" "pak" in |
let tmp_file = Filename.temp_file "comp" "pak" in |
1300 |
File.from_string tmp_file s; |
File.from_string tmp_file s; |
1301 |
lprintf_nl "Saved unknown packet %s" tmp_file; |
lprintf_nl "Saved unknown packet %s" tmp_file; |
1302 |
|
|
1303 |
dump s; |
dump s; |
1304 |
lprint_newline (); |
lprint_newline (); |
1327 |
match t with |
match t with |
1328 |
| ConnectReq t -> |
| ConnectReq t -> |
1329 |
buf_int8 buf 1; |
buf_int8 buf 1; |
1330 |
Connect.write buf t |
Connect.write false buf t |
1331 |
| ConnectReplyReq t -> |
| ConnectReplyReq t -> |
1332 |
buf_int8 buf 76; |
buf_int8 buf 76; |
1333 |
ConnectReply.write buf t |
Connect.write true buf t |
1334 |
| QueryFileReq t -> |
| QueryFileReq t -> |
1335 |
buf_int8 buf 88; |
buf_int8 buf 88; |
1336 |
QueryFile.write emule buf t |
QueryFile.write emule buf t |