1 | /* |
---|
2 | * This file Copyright (C) Mnemosyne LLC |
---|
3 | * |
---|
4 | * This file is licensed by the GPL version 2. Works owned by the |
---|
5 | * Transmission project are granted a special exemption to clause 2(b) |
---|
6 | * so that the bulk of its code can remain under the MIT license. |
---|
7 | * This exemption does not extend to derived works not owned by |
---|
8 | * the Transmission project. |
---|
9 | * |
---|
10 | * $Id: clients.c 13099 2011-11-22 03:30:37Z livings124 $ |
---|
11 | */ |
---|
12 | |
---|
13 | /* thanks amc1! */ |
---|
14 | |
---|
15 | #include <ctype.h> /* isprint() */ |
---|
16 | #include <stdlib.h> /* strtol() */ |
---|
17 | #include <string.h> |
---|
18 | |
---|
19 | #include "transmission.h" |
---|
20 | #include "clients.h" |
---|
21 | #include "utils.h" /* tr_snprintf(), tr_strlcpy() */ |
---|
22 | |
---|
23 | static int |
---|
24 | charint( uint8_t ch ) |
---|
25 | { |
---|
26 | if( '0' <= ch && ch <= '9' ) return ch - '0'; |
---|
27 | if( 'A' <= ch && ch <= 'Z' ) return 10 + ch - 'A'; |
---|
28 | if( 'a' <= ch && ch <= 'z' ) return 36 + ch - 'a'; |
---|
29 | return 0; |
---|
30 | } |
---|
31 | |
---|
32 | static int |
---|
33 | getShadowInt( uint8_t ch, int * setme ) |
---|
34 | { |
---|
35 | const char * str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-"; |
---|
36 | const char * pch = strchr( str, ch ); |
---|
37 | if( !pch ) |
---|
38 | return 0; |
---|
39 | *setme = pch - str; |
---|
40 | return 1; |
---|
41 | } |
---|
42 | |
---|
43 | static int |
---|
44 | strint( const void * pch, int span ) |
---|
45 | { |
---|
46 | char tmp[64]; |
---|
47 | memcpy( tmp, pch, span ); |
---|
48 | tmp[span] = '\0'; |
---|
49 | return strtol( tmp, NULL, 0 ); |
---|
50 | } |
---|
51 | |
---|
52 | static const char* |
---|
53 | getMnemonicEnd( uint8_t ch ) |
---|
54 | { |
---|
55 | switch( ch ) |
---|
56 | { |
---|
57 | case 'b': case 'B': return " (Beta)"; |
---|
58 | case 'd': return " (Debug)"; |
---|
59 | case 'x': case 'X': case 'Z': return " (Dev)"; |
---|
60 | default: return ""; |
---|
61 | } |
---|
62 | } |
---|
63 | |
---|
64 | static void |
---|
65 | three_digits( char * buf, size_t buflen, const char * name, const uint8_t * digits ) |
---|
66 | { |
---|
67 | tr_snprintf( buf, buflen, "%s %d.%d.%d", name, |
---|
68 | charint( digits[0] ), |
---|
69 | charint( digits[1] ), |
---|
70 | charint( digits[2] ) ); |
---|
71 | } |
---|
72 | static void |
---|
73 | four_digits( char * buf, size_t buflen, const char * name, const uint8_t * digits ) |
---|
74 | { |
---|
75 | tr_snprintf( buf, buflen, "%s %d.%d.%d.%d", name, |
---|
76 | charint( digits[0] ), |
---|
77 | charint( digits[1] ), |
---|
78 | charint( digits[2] ), |
---|
79 | charint( digits[3] ) ); |
---|
80 | } |
---|
81 | static void |
---|
82 | two_major_two_minor( char * buf, size_t buflen, const char * name, const uint8_t * digits ) |
---|
83 | { |
---|
84 | tr_snprintf( buf, buflen, "%s %d.%02d", name, |
---|
85 | strint( digits, 2 ), |
---|
86 | strint( digits+2, 2 ) ); |
---|
87 | } |
---|
88 | static void |
---|
89 | no_version( char * buf, size_t buflen, const char * name ) |
---|
90 | { |
---|
91 | tr_strlcpy( buf, name, buflen ); |
---|
92 | } |
---|
93 | |
---|
94 | static void |
---|
95 | mainline_style( char * buf, size_t buflen, const char * name, const uint8_t * id ) |
---|
96 | { |
---|
97 | if( id[4] == '-' && id[6] == '-' ) |
---|
98 | tr_snprintf( buf, buflen, "%s %c.%c.%c", name, id[1], id[3], id[5] ); |
---|
99 | else if( id[5] == '-' ) |
---|
100 | tr_snprintf( buf, buflen, "%s %c.%c%c.%c", name, id[1], id[3], id[4], id[6] ); |
---|
101 | } |
---|
102 | |
---|
103 | static int |
---|
104 | isMainlineStyle( const uint8_t * peer_id ) |
---|
105 | { |
---|
106 | /** |
---|
107 | * One of the following styles will be used: |
---|
108 | * Mx-y-z-- |
---|
109 | * Mx-yy-z- |
---|
110 | */ |
---|
111 | return peer_id[2]=='-' |
---|
112 | && peer_id[7]=='-' |
---|
113 | && ( peer_id[4]=='-' || peer_id[5]=='-' ); |
---|
114 | } |
---|
115 | |
---|
116 | static int |
---|
117 | decodeBitCometClient( char * buf, size_t buflen, const uint8_t * id ) |
---|
118 | { |
---|
119 | int is_bitlord; |
---|
120 | int major, minor; |
---|
121 | const char * name; |
---|
122 | const char * mod = NULL; |
---|
123 | |
---|
124 | if( !memcmp( id, "exbc", 4 ) ) mod = ""; |
---|
125 | else if( !memcmp( id, "FUTB", 4 )) mod = "(Solidox Mod) "; |
---|
126 | else if( !memcmp( id, "xUTB", 4 )) mod = "(Mod 2) "; |
---|
127 | else return false; |
---|
128 | |
---|
129 | is_bitlord = !memcmp( id+6, "LORD", 4 ); |
---|
130 | name = (is_bitlord) ? "BitLord " : "BitComet "; |
---|
131 | major = id[4]; |
---|
132 | minor = id[5]; |
---|
133 | |
---|
134 | /** |
---|
135 | * Bitcomet, and older versions of BitLord, are of the form x.yy. |
---|
136 | * Bitcoment 1.0 and onwards are of the form x.y. |
---|
137 | */ |
---|
138 | if( is_bitlord && major>0 ) |
---|
139 | tr_snprintf( buf, buflen, "%s%s%d.%d", name, mod, major, minor ); |
---|
140 | else |
---|
141 | tr_snprintf( buf, buflen, "%s%s%d.%02d", name, mod, major, minor ); |
---|
142 | |
---|
143 | return true; |
---|
144 | } |
---|
145 | |
---|
146 | void |
---|
147 | tr_clientForId( char * buf, size_t buflen, const void * id_in ) |
---|
148 | { |
---|
149 | const uint8_t * id = id_in; |
---|
150 | |
---|
151 | *buf = '\0'; |
---|
152 | |
---|
153 | if( !id ) |
---|
154 | return; |
---|
155 | |
---|
156 | /* Azureus-style */ |
---|
157 | if( id[0] == '-' && id[7] == '-' ) |
---|
158 | { |
---|
159 | if( !memcmp( id+1, "TR", 2 ) ) |
---|
160 | { |
---|
161 | if( !memcmp( id+3, "000", 3 ) ) /* very old client style: -TR0006- is 0.6 */ |
---|
162 | tr_snprintf( buf, buflen, "Transmission 0.%c", id[6] ); |
---|
163 | else if( !memcmp( id+3, "00", 2) ) /* previous client style: -TR0072- is 0.72 */ |
---|
164 | tr_snprintf( buf, buflen, "Transmission 0.%02d", strint(id+5,2) ); |
---|
165 | else /* current client style: -TR111Z- is 1.11+ */ |
---|
166 | tr_snprintf( buf, buflen, "Transmission %d.%02d%s", strint(id+3,1), strint(id+4,2), |
---|
167 | id[6]=='Z' || id[6]=='X' ? "+" : "" ); |
---|
168 | } |
---|
169 | |
---|
170 | else if( !memcmp( id+1, "UT", 2 ) ) |
---|
171 | { |
---|
172 | tr_snprintf( buf, buflen, "\xc2\xb5Torrent %d.%d.%d%s", |
---|
173 | strint(id+3,1), strint(id+4,1), strint(id+5,1), getMnemonicEnd(id[6]) ); |
---|
174 | } |
---|
175 | else if( !memcmp( id+1, "UM", 2 ) ) |
---|
176 | { |
---|
177 | tr_snprintf( buf, buflen, "\xc2\xb5Torrent Mac %d.%d.%d%s", |
---|
178 | strint(id+3,1), strint(id+4,1), strint(id+5,1), getMnemonicEnd(id[6]) ); |
---|
179 | } |
---|
180 | else if( !memcmp( id+1, "UE", 2 ) ) |
---|
181 | { |
---|
182 | tr_snprintf( buf, buflen, "\xc2\xb5Torrent Embedded %d.%d.%d%s", |
---|
183 | strint(id+3,1), strint(id+4,1), strint(id+5,1), getMnemonicEnd(id[6]) ); |
---|
184 | } |
---|
185 | |
---|
186 | else if( !memcmp( id+1, "AZ", 2 ) ) |
---|
187 | { |
---|
188 | if( id[3] > '3' || ( id[3] == '3' && id[4] >= '1' ) ) /* Vuze starts at version 3.1.0.0 */ |
---|
189 | four_digits( buf, buflen, "Vuze", id+3 ); |
---|
190 | else |
---|
191 | four_digits( buf, buflen, "Azureus", id+3 ); |
---|
192 | } |
---|
193 | |
---|
194 | else if( !memcmp( id+1, "KT", 2 ) ) |
---|
195 | { |
---|
196 | if( id[5] == 'D' ) |
---|
197 | tr_snprintf( buf, buflen, "KTorrent %d.%d Dev %d", charint(id[3]), charint(id[4]), charint(id[6]) ); |
---|
198 | else if( id[5] == 'R' ) |
---|
199 | tr_snprintf( buf, buflen, "KTorrent %d.%d RC %d", charint(id[3]), charint(id[4]), charint(id[6]) ); |
---|
200 | else |
---|
201 | three_digits( buf, buflen, "KTorrent", id+3 ); |
---|
202 | } |
---|
203 | |
---|
204 | else if( !memcmp( id+1, "AG", 2 ) ) four_digits( buf, buflen, "Ares", id+3 ); |
---|
205 | else if( !memcmp( id+1, "AR", 2 ) ) four_digits( buf, buflen, "Arctic", id+3 ); |
---|
206 | else if( !memcmp( id+1, "AT", 2 ) ) four_digits( buf, buflen, "Artemis", id+3 ); |
---|
207 | else if( !memcmp( id+1, "AV", 2 ) ) four_digits( buf, buflen, "Avicora", id+3 ); |
---|
208 | else if( !memcmp( id+1, "BB", 2 ) ) four_digits( buf, buflen, "BitBuddy", id+3 ); |
---|
209 | else if( !memcmp( id+1, "BE", 2 ) ) four_digits( buf, buflen, "BitTorrent SDK", id+3 ); |
---|
210 | else if( !memcmp( id+1, "BG", 2 ) ) four_digits( buf, buflen, "BTGetit", id+3 ); |
---|
211 | else if( !memcmp( id+1, "BM", 2 ) ) four_digits( buf, buflen, "BitMagnet", id+3 ); |
---|
212 | else if( !memcmp( id+1, "BP", 2 ) ) four_digits( buf, buflen, "BitTorrent Pro (Azureus + Spyware)", id+3 ); |
---|
213 | else if( !memcmp( id+1, "BX", 2 ) ) four_digits( buf, buflen, "BittorrentX", id+3 ); |
---|
214 | else if( !memcmp( id+1, "bk", 2 ) ) four_digits( buf, buflen, "BitKitten (libtorrent)", id+3 ); |
---|
215 | else if( !memcmp( id+1, "BS", 2 ) ) four_digits( buf, buflen, "BTSlave", id+3 ); |
---|
216 | else if( !memcmp( id+1, "BW", 2 ) ) four_digits( buf, buflen, "BitWombat", id+3 ); |
---|
217 | else if( !memcmp( id+1, "BX", 2 ) ) four_digits( buf, buflen, "BittorrentX", id+3 ); |
---|
218 | else if( !memcmp( id+1, "EB", 2 ) ) four_digits( buf, buflen, "EBit", id+3 ); |
---|
219 | else if( !memcmp( id+1, "DE", 2 ) ) four_digits( buf, buflen, "Deluge", id+3 ); |
---|
220 | else if( !memcmp( id+1, "DP", 2 ) ) four_digits( buf, buflen, "Propogate Data Client", id+3 ); |
---|
221 | else if( !memcmp( id+1, "FC", 2 ) ) four_digits( buf, buflen, "FileCroc", id+3 ); |
---|
222 | else if( !memcmp( id+1, "FT", 2 ) ) four_digits( buf, buflen, "FoxTorrent/RedSwoosh", id+3 ); |
---|
223 | else if( !memcmp( id+1, "GR", 2 ) ) four_digits( buf, buflen, "GetRight", id+3 ); |
---|
224 | else if( !memcmp( id+1, "GS", 2 ) ) four_digits( buf, buflen, "GSTorrent", id+3 ); |
---|
225 | else if( !memcmp( id+1, "HK", 2 ) ) four_digits( buf, buflen, "Hekate", id+3 ); |
---|
226 | else if( !memcmp( id+1, "HN", 2 ) ) four_digits( buf, buflen, "Hydranode", id+3 ); |
---|
227 | else if( !memcmp( id+1, "KG", 2 ) ) four_digits( buf, buflen, "KGet", id+3 ); |
---|
228 | else if( !memcmp( id+1, "LC", 2 ) ) four_digits( buf, buflen, "LeechCraft", id+3 ); |
---|
229 | else if( !memcmp( id+1, "LH", 2 ) ) four_digits( buf, buflen, "LH-ABC", id+3 ); |
---|
230 | else if( !memcmp( id+1, "NX", 2 ) ) four_digits( buf, buflen, "Net Transport", id+3 ); |
---|
231 | else if( !memcmp( id+1, "MK", 2 ) ) four_digits( buf, buflen, "Meerkat", id+3 ); |
---|
232 | else if( !memcmp( id+1, "MO", 2 ) ) four_digits( buf, buflen, "MonoTorrent", id+3 ); |
---|
233 | else if( !memcmp( id+1, "MR", 2 ) ) four_digits( buf, buflen, "Miro", id+3 ); |
---|
234 | else if( !memcmp( id+1, "MT", 2 ) ) four_digits( buf, buflen, "Moonlight", id+3 ); |
---|
235 | else if( !memcmp( id+1, "OS", 2 ) ) four_digits( buf, buflen, "OneSwarm", id+3 ); |
---|
236 | else if( !memcmp( id+1, "OT", 2 ) ) four_digits( buf, buflen, "OmegaTorrent", id+3 ); |
---|
237 | else if( !memcmp( id+1, "PD", 2 ) ) four_digits( buf, buflen, "Pando", id+3 ); |
---|
238 | else if( !memcmp( id+1, "QD", 2 ) ) four_digits( buf, buflen, "QQDownload", id+3 ); |
---|
239 | else if( !memcmp( id+1, "RS", 2 ) ) four_digits( buf, buflen, "Rufus", id+3 ); |
---|
240 | else if( !memcmp( id+1, "RT", 2 ) ) four_digits( buf, buflen, "Retriever", id+3 ); |
---|
241 | else if( !memcmp( id+1, "RZ", 2 ) ) four_digits( buf, buflen, "RezTorrent", id+3 ); |
---|
242 | else if( !memcmp( id+1, "SD", 2 ) ) four_digits( buf, buflen, "Thunder", id+3 ); |
---|
243 | else if( !memcmp( id+1, "SM", 2 ) ) four_digits( buf, buflen, "SoMud", id+3 ); |
---|
244 | else if( !memcmp( id+1, "SS", 2 ) ) four_digits( buf, buflen, "SwarmScope", id+3 ); |
---|
245 | else if( !memcmp( id+1, "ST", 2 ) ) four_digits( buf, buflen, "SymTorrent", id+3 ); |
---|
246 | else if( !memcmp( id+1, "SZ", 2 ) ) four_digits( buf, buflen, "Shareaza", id+3 ); |
---|
247 | else if( !memcmp( id+1, "S~", 2 ) ) four_digits( buf, buflen, "Shareaza", id+3 ); |
---|
248 | else if( !memcmp( id+1, "st", 2 ) ) four_digits( buf, buflen, "SharkTorrent", id+3 ); |
---|
249 | else if( !memcmp( id+1, "TN", 2 ) ) four_digits( buf, buflen, "Torrent .NET", id+3 ); |
---|
250 | else if( !memcmp( id+1, "TS", 2 ) ) four_digits( buf, buflen, "TorrentStorm", id+3 ); |
---|
251 | else if( !memcmp( id+1, "TT", 2 ) ) four_digits( buf, buflen, "TuoTu", id+3 ); |
---|
252 | else if( !memcmp( id+1, "UL", 2 ) ) four_digits( buf, buflen, "uLeecher!", id+3 ); |
---|
253 | else if( !memcmp( id+1, "VG", 2 ) ) four_digits( buf, buflen, "Vagaa", id+3 ); |
---|
254 | else if( !memcmp( id+1, "WT", 2 ) ) four_digits( buf, buflen, "BitLet", id+3 ); |
---|
255 | else if( !memcmp( id+1, "WY", 2 ) ) four_digits( buf, buflen, "FireTorrent", id+3 ); |
---|
256 | else if( !memcmp( id+1, "XL", 2 ) ) four_digits( buf, buflen, "Xunlei", id+3 ); |
---|
257 | else if( !memcmp( id+1, "XS", 2 ) ) four_digits( buf, buflen, "XSwifter", id+3 ); |
---|
258 | else if( !memcmp( id+1, "XT", 2 ) ) four_digits( buf, buflen, "XanTorrent", id+3 ); |
---|
259 | else if( !memcmp( id+1, "XX", 2 ) ) four_digits( buf, buflen, "Xtorrent", id+3 ); |
---|
260 | else if( !memcmp( id+1, "ZT", 2 ) ) four_digits( buf, buflen, "Zip Torrent", id+3 ); |
---|
261 | |
---|
262 | else if( !memcmp( id+1, "AG", 2 ) ) three_digits( buf, buflen, "Ares", id+3 ); |
---|
263 | else if( !memcmp( id+1, "A~", 2 ) ) three_digits( buf, buflen, "Ares", id+3 ); |
---|
264 | else if( !memcmp( id+1, "ES", 2 ) ) three_digits( buf, buflen, "Electric Sheep", id+3 ); |
---|
265 | else if( !memcmp( id+1, "HL", 2 ) ) three_digits( buf, buflen, "Halite", id+3 ); |
---|
266 | else if( !memcmp( id+1, "LT", 2 ) ) three_digits( buf, buflen, "libtorrent (Rasterbar)", id+3 ); |
---|
267 | else if( !memcmp( id+1, "lt", 2 ) ) three_digits( buf, buflen, "libTorrent (Rakshasa)", id+3 ); |
---|
268 | else if( !memcmp( id+1, "MP", 2 ) ) three_digits( buf, buflen, "MooPolice", id+3 ); |
---|
269 | else if( !memcmp( id+1, "TT", 2 ) ) three_digits( buf, buflen, "TuoTu", id+3 ); |
---|
270 | else if( !memcmp( id+1, "qB", 2 ) ) three_digits( buf, buflen, "qBittorrent", id+3 ); |
---|
271 | |
---|
272 | else if( !memcmp( id+1, "AX", 2 ) ) two_major_two_minor( buf, buflen, "BitPump", id+3 ); |
---|
273 | else if( !memcmp( id+1, "BC", 2 ) ) two_major_two_minor( buf, buflen, "BitComet", id+3 ); |
---|
274 | else if( !memcmp( id+1, "CD", 2 ) ) two_major_two_minor( buf, buflen, "Enhanced CTorrent", id+3 ); |
---|
275 | else if( !memcmp( id+1, "LP", 2 ) ) two_major_two_minor( buf, buflen, "Lphant", id+3 ); |
---|
276 | |
---|
277 | else if( !memcmp( id+1, "BF", 2 ) ) no_version( buf, buflen, "BitFlu" ); |
---|
278 | else if( !memcmp( id+1, "LW", 2 ) ) no_version( buf, buflen, "LimeWire" ); |
---|
279 | |
---|
280 | else if( !memcmp( id+1, "BB", 2 ) ) |
---|
281 | { |
---|
282 | tr_snprintf( buf, buflen, "BitBuddy %c.%c%c%c", id[3], id[4], id[5], id[6] ); |
---|
283 | } |
---|
284 | else if( !memcmp( id+1, "BR", 2 ) ) |
---|
285 | { |
---|
286 | tr_snprintf( buf, buflen, "BitRocket %c.%c (%c%c)", id[3], id[4], id[5], id[6] ); |
---|
287 | } |
---|
288 | else if( !memcmp( id+1, "CT", 2 ) ) |
---|
289 | { |
---|
290 | tr_snprintf( buf, buflen, "CTorrent %d.%d.%02d", charint(id[3]), charint(id[4]), strint(id+5,2) ); |
---|
291 | } |
---|
292 | else if( !memcmp( id+1, "XC", 2 ) || !memcmp( id+1, "XX", 2 ) ) |
---|
293 | { |
---|
294 | tr_snprintf( buf, buflen, "Xtorrent %d.%d (%d)", charint(id[3]), charint(id[4]), strint(id+5,2) ); |
---|
295 | } |
---|
296 | else if( !memcmp( id+1, "BOW", 3 ) ) |
---|
297 | { |
---|
298 | if( !memcmp( &id[4], "A0B", 3 ) ) tr_snprintf( buf, buflen, "Bits on Wheels 1.0.5" ); |
---|
299 | else if( !memcmp( &id[4], "A0C", 3 ) ) tr_snprintf( buf, buflen, "Bits on Wheels 1.0.6" ); |
---|
300 | else tr_snprintf( buf, buflen, "Bits on Wheels %c.%c.%c", id[4], id[5], id[5] ); |
---|
301 | } |
---|
302 | |
---|
303 | if( *buf ) |
---|
304 | return; |
---|
305 | } |
---|
306 | |
---|
307 | /* uTorrent will replace the trailing dash with an extra digit for longer version numbers */ |
---|
308 | if( id[0] == '-' ) |
---|
309 | { |
---|
310 | if( !memcmp( id+1, "UT", 2 ) ) |
---|
311 | { |
---|
312 | tr_snprintf( buf, buflen, "\xc2\xb5Torrent %d.%d.%d%s", |
---|
313 | strint(id+3,1), strint(id+4,1), strint(id+5,2), getMnemonicEnd(id[7]) ); |
---|
314 | } |
---|
315 | else if( !memcmp( id+1, "UM", 2 ) ) |
---|
316 | { |
---|
317 | tr_snprintf( buf, buflen, "\xc2\xb5Torrent Mac %d.%d.%d%s", |
---|
318 | strint(id+3,1), strint(id+4,1), strint(id+5,2), getMnemonicEnd(id[7]) ); |
---|
319 | } |
---|
320 | else if( !memcmp( id+1, "UE", 2 ) ) |
---|
321 | { |
---|
322 | tr_snprintf( buf, buflen, "\xc2\xb5Torrent Embedded %d.%d.%d%s", |
---|
323 | strint(id+3,1), strint(id+4,1), strint(id+5,2), getMnemonicEnd(id[7]) ); |
---|
324 | } |
---|
325 | |
---|
326 | if( *buf ) |
---|
327 | return; |
---|
328 | } |
---|
329 | |
---|
330 | /* Mainline */ |
---|
331 | if( isMainlineStyle( id ) ) |
---|
332 | { |
---|
333 | if( *id=='M' ) mainline_style( buf, buflen, "BitTorrent", id ); |
---|
334 | if( *id=='Q' ) mainline_style( buf, buflen, "Queen Bee", id ); |
---|
335 | if( *buf ) return; |
---|
336 | } |
---|
337 | |
---|
338 | if( decodeBitCometClient( buf, buflen, id ) ) |
---|
339 | return; |
---|
340 | |
---|
341 | /* Clients with no version */ |
---|
342 | if( !memcmp( id, "AZ2500BT", 8 ) ) no_version( buf, buflen, "BitTyrant (Azureus Mod)" ); |
---|
343 | else if( !memcmp( id, "LIME", 4 ) ) no_version( buf, buflen, "Limewire" ); |
---|
344 | else if( !memcmp( id, "martini", 7 ) ) no_version( buf, buflen, "Martini Man" ); |
---|
345 | else if( !memcmp( id, "Pando", 5 ) ) no_version( buf, buflen, "Pando" ); |
---|
346 | else if( !memcmp( id, "a00---0", 7 ) ) no_version( buf, buflen, "Swarmy" ); |
---|
347 | else if( !memcmp( id, "a02---0", 7 ) ) no_version( buf, buflen, "Swarmy" ); |
---|
348 | else if( !memcmp( id, "-G3", 3 ) ) no_version( buf, buflen, "G3 Torrent" ); |
---|
349 | else if( !memcmp( id, "10-------", 9 ) ) no_version( buf, buflen, "JVtorrent" ); |
---|
350 | else if( !memcmp( id, "346-", 4 ) ) no_version( buf, buflen, "TorrentTopia" ); |
---|
351 | else if( !memcmp( id, "eX", 2 ) ) no_version( buf, buflen, "eXeem" ); |
---|
352 | else if( !memcmp( id, "aria2-", 6 ) ) no_version( buf, buflen, "aria2" ); |
---|
353 | else if( !memcmp( id, "-WT-", 4 ) ) no_version( buf, buflen, "BitLet" ); |
---|
354 | else if( !memcmp( id, "-FG", 3 ) ) two_major_two_minor( buf, buflen, "FlashGet", id+3 ); |
---|
355 | |
---|
356 | /* Everything else */ |
---|
357 | else if( !memcmp( id, "S3", 2 ) && id[2] == '-' && id[4] == '-' && id[6] == '-' ) |
---|
358 | { |
---|
359 | tr_snprintf( buf, buflen, "Amazon S3 %c.%c.%c", id[3], id[5], id[7] ); |
---|
360 | } |
---|
361 | else if( !memcmp( id, "OP", 2 ) ) |
---|
362 | { |
---|
363 | tr_snprintf( buf, buflen, "Opera (Build %c%c%c%c)", id[2], id[3], id[4], id[5] ); |
---|
364 | } |
---|
365 | else if( !memcmp( id, "-ML", 3 ) ) |
---|
366 | { |
---|
367 | tr_snprintf( buf, buflen, "MLDonkey %c%c%c%c%c", id[3], id[4], id[5], id[6], id[7] ); |
---|
368 | } |
---|
369 | else if( !memcmp( id, "DNA", 3 ) ) |
---|
370 | { |
---|
371 | tr_snprintf( buf, buflen, "BitTorrent DNA %d.%d.%d", strint(id+3,2), |
---|
372 | strint(id+5,2), |
---|
373 | strint(id+7,2) ); |
---|
374 | } |
---|
375 | else if( !memcmp( id, "Plus", 4 ) ) |
---|
376 | { |
---|
377 | tr_snprintf( buf, buflen, "Plus! v2 %c.%c%c", id[4], id[5], id[6] ); |
---|
378 | } |
---|
379 | else if( !memcmp( id, "XBT", 3 ) ) |
---|
380 | { |
---|
381 | tr_snprintf( buf, buflen, "XBT Client %c.%c.%c%s", id[3], id[4], id[5], getMnemonicEnd(id[6]) ); |
---|
382 | } |
---|
383 | else if( !memcmp( id, "Mbrst", 5 ) ) |
---|
384 | { |
---|
385 | tr_snprintf( buf, buflen, "burst! %c.%c.%c", id[5], id[7], id[9] ); |
---|
386 | } |
---|
387 | else if( !memcmp( id, "btpd", 4 ) ) |
---|
388 | { |
---|
389 | tr_snprintf( buf, buflen, "BT Protocol Daemon %c%c%c", id[5], id[6], id[7] ); |
---|
390 | } |
---|
391 | else if( !memcmp( id, "BLZ", 3 ) ) |
---|
392 | { |
---|
393 | tr_snprintf( buf, buflen, "Blizzard Downloader %d.%d", id[3]+1, id[4] ); |
---|
394 | } |
---|
395 | else if( !memcmp( id, "-SP", 3 ) ) |
---|
396 | { |
---|
397 | three_digits( buf, buflen, "BitSpirit", id+3 ); |
---|
398 | } |
---|
399 | else if( '\0' == id[0] && !memcmp( id+2, "BS", 2 ) ) |
---|
400 | { |
---|
401 | tr_snprintf( buf, buflen, "BitSpirit %u", ( id[1] == 0 ? 1 : id[1] ) ); |
---|
402 | } |
---|
403 | else if( !memcmp( id, "QVOD", 4 ) ) |
---|
404 | { |
---|
405 | four_digits( buf, buflen, "QVOD", id+4 ); |
---|
406 | } |
---|
407 | else if( !memcmp( id, "-NE", 3 ) ) |
---|
408 | { |
---|
409 | four_digits( buf, buflen, "BT Next Evolution", id+3 ); |
---|
410 | } |
---|
411 | |
---|
412 | /* Shad0w-style */ |
---|
413 | { |
---|
414 | int a, b, c; |
---|
415 | if( strchr( "AOQRSTU", id[0] ) |
---|
416 | && getShadowInt( id[1], &a ) |
---|
417 | && getShadowInt( id[2], &b ) |
---|
418 | && getShadowInt( id[3], &c ) ) |
---|
419 | { |
---|
420 | const char * name = NULL; |
---|
421 | |
---|
422 | switch( id[0] ) |
---|
423 | { |
---|
424 | case 'A': name = "ABC"; break; |
---|
425 | case 'O': name = "Osprey"; break; |
---|
426 | case 'Q': name = "BTQueue"; break; |
---|
427 | case 'R': name = "Tribler"; break; |
---|
428 | case 'S': name = "Shad0w"; break; |
---|
429 | case 'T': name = "BitTornado"; break; |
---|
430 | case 'U': name = "UPnP NAT Bit Torrent"; break; |
---|
431 | } |
---|
432 | |
---|
433 | if( name ) |
---|
434 | { |
---|
435 | tr_snprintf( buf, buflen, "%s %d.%d.%d", name, a, b, c ); |
---|
436 | return; |
---|
437 | } |
---|
438 | } |
---|
439 | } |
---|
440 | |
---|
441 | /* No match */ |
---|
442 | if( !*buf ) |
---|
443 | { |
---|
444 | char out[32], *walk=out; |
---|
445 | const char *in, *in_end; |
---|
446 | for( in=(const char*)id, in_end=in+8; in!=in_end; ++in ) { |
---|
447 | if( isprint( *in ) ) |
---|
448 | *walk++ = *in; |
---|
449 | else { |
---|
450 | tr_snprintf( walk, out+sizeof(out)-walk, "%%%02X", (unsigned int)*in ); |
---|
451 | walk += 3; |
---|
452 | } |
---|
453 | } |
---|
454 | *walk = '\0'; |
---|
455 | tr_strlcpy( buf, out, buflen ); |
---|
456 | } |
---|
457 | } |
---|