forked from jaewon713/gingko
-
Notifications
You must be signed in to change notification settings - Fork 1
/
libtorrent-1.0.0-RC2.patch
1751 lines (1639 loc) · 58.5 KB
/
libtorrent-1.0.0-RC2.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff -Naur libtorrent-rasterbar-1.0.0/bindings/python/compile_flags libtorrent/bindings/python/compile_flags
--- libtorrent-rasterbar-1.0.0/bindings/python/compile_flags 2014-05-12 07:22:24.000000000 +0800
+++ libtorrent/bindings/python/compile_flags 2014-10-11 18:55:34.000000000 +0800
@@ -1 +1 @@
- -DTORRENT_USE_OPENSSL -DWITH_SHIPPED_GEOIP_H -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_DYN_LINK -DTORRENT_LINKING_SHARED -I/opt/local/include -lboost_system-mt -lboost_python-mt -lssl -lcrypto -L/opt/local/lib -I/opt/local/include
+ -DTORRENT_NO_DEPRECATE -DTORRENT_DISABLE_ENCRYPTION -DTORRENT_DISABLE_GEO_IP -DTORRENT_DISABLE_DHT -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_DYN_LINK -I/home/users/liuming03/workspace/op/oped/noah/thirdparty/libtorrent/../../../../../third-64/boost/include -I./ -lrt -lpthread -L./ -lboost_system -lpthread
diff -Naur libtorrent-rasterbar-1.0.0/bindings/python/link_flags libtorrent/bindings/python/link_flags
--- libtorrent-rasterbar-1.0.0/bindings/python/link_flags 2014-05-12 07:22:24.000000000 +0800
+++ libtorrent/bindings/python/link_flags 2014-10-11 18:55:34.000000000 +0800
@@ -1 +1 @@
--L/opt/local/lib
+-L/home/users/liuming03/workspace/op/oped/noah/thirdparty/libtorrent/../../../../../third-64/boost/lib
diff -Naur libtorrent-rasterbar-1.0.0/configure libtorrent/configure
--- libtorrent-rasterbar-1.0.0/configure 2014-05-12 07:22:12.000000000 +0800
+++ libtorrent/configure 2014-10-11 18:55:34.000000000 +0800
@@ -16217,7 +16217,7 @@
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
CC="$PTHREAD_CC"
-CXXFLAGS="$CXXFLAGS -ftemplate-depth=120"
+CXXFLAGS="$CXXFLAGS"
$as_echo "Checking for visibility support:"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__((visibility(\"hidden\")))" >&5
diff -Naur libtorrent-rasterbar-1.0.0/include/libtorrent/add_torrent_params.hpp libtorrent/include/libtorrent/add_torrent_params.hpp
--- libtorrent-rasterbar-1.0.0/include/libtorrent/add_torrent_params.hpp 2014-04-30 04:14:17.000000000 +0800
+++ libtorrent/include/libtorrent/add_torrent_params.hpp 2014-10-11 18:55:34.000000000 +0800
@@ -244,6 +244,9 @@
// the torrent handle immediately after adding it.
flag_sequential_download = 0x800,
+ // for seed mode announce to tracker, added by liuming03
+ flag_real_seed = 0x1000,
+
// internal
default_flags = flag_update_subscribe | flag_auto_managed | flag_paused | flag_apply_ip_filter
#ifndef TORRENT_NO_DEPRECATE
@@ -272,6 +275,10 @@
// a list of hostname and port pairs, representing DHT nodes to be added
// to the session (if DHT is enabled). The hostname may be an IP address.
std::vector<std::pair<std::string, int> > dht_nodes;
+
+ // thrift trackers list
+ std::vector<std::pair<std::string, int> > thrift_trackers;
+
std::string name;
std::string save_path;
diff -Naur libtorrent-rasterbar-1.0.0/include/libtorrent/aux_/session_impl.hpp libtorrent/include/libtorrent/aux_/session_impl.hpp
--- libtorrent-rasterbar-1.0.0/include/libtorrent/aux_/session_impl.hpp 2014-05-11 16:19:59.000000000 +0800
+++ libtorrent/include/libtorrent/aux_/session_impl.hpp 2014-10-11 18:55:34.000000000 +0800
@@ -808,6 +808,13 @@
tcp::endpoint m_ipv6_interface;
tcp::endpoint m_ipv4_interface;
+ tcp::endpoint m_ipv4_local_interface;
+ void init_local_interface();
+ const tcp::endpoint& local_interface()
+ {
+ return m_ipv4_local_interface;
+ }
+
// since we might be listening on multiple interfaces
// we might need more than one listen socket
std::list<listen_socket_t> m_listen_sockets;
@@ -1245,6 +1252,14 @@
// the main working thread
boost::scoped_ptr<thread> m_thread;
+ // set announce callback, added by liuming03
+ typedef boost::function<void(torrent_handle, boost::shared_ptr<ex_announce_request>)> ex_announce_func;
+ ex_announce_func m_ex_annfunc;
+ void add_ex_announce_func(const ex_announce_func &func)
+ {
+ m_ex_annfunc = func;
+ }
+
#if TORRENT_USE_ASSERTS && defined BOOST_HAS_PTHREADS
pthread_t m_network_thread;
diff -Naur libtorrent-rasterbar-1.0.0/include/libtorrent/config.hpp libtorrent/include/libtorrent/config.hpp
--- libtorrent-rasterbar-1.0.0/include/libtorrent/config.hpp 2014-05-03 11:39:15.000000000 +0800
+++ libtorrent/include/libtorrent/config.hpp 2014-10-11 18:55:34.000000000 +0800
@@ -475,9 +475,9 @@
#define TORRENT_USE_IFADDRS 0
#endif
-#ifndef TORRENT_USE_IPV6
-#define TORRENT_USE_IPV6 1
-#endif
+//#ifndef TORRENT_USE_IPV6
+//#define TORRENT_USE_IPV6 1
+//#endif
#ifndef TORRENT_USE_MLOCK
#define TORRENT_USE_MLOCK 1
@@ -509,9 +509,9 @@
#define TORRENT_COMPACT_PICKER 0
#endif
-#ifndef TORRENT_USE_I2P
-#define TORRENT_USE_I2P 1
-#endif
+//#ifndef TORRENT_USE_I2P
+//#define TORRENT_USE_I2P 1
+//#endif
#if !defined TORRENT_IOV_MAX
#ifdef IOV_MAX
diff -Naur libtorrent-rasterbar-1.0.0/include/libtorrent/create_torrent.hpp libtorrent/include/libtorrent/create_torrent.hpp
--- libtorrent-rasterbar-1.0.0/include/libtorrent/create_torrent.hpp 2014-03-23 14:56:36.000000000 +0800
+++ libtorrent/include/libtorrent/create_torrent.hpp 2014-10-11 18:55:34.000000000 +0800
@@ -262,6 +262,12 @@
// sources than the tracker for peers, and to not advertize itself publicly,
// apart from the tracker.
void set_priv(bool p) { m_private = p; }
+
+ void set_cluster_config(const std::string &host, int port, const std::string &user
+ , const std::string &passwd, const std::string &path);
+
+ const sha1_hash& get_info_hash() { return m_info_hash; }
+
bool priv() const { return m_private; }
// returns the number of pieces in the associated file_storage object.
@@ -333,6 +339,9 @@
// this is the root cert for SSL torrents
std::string m_root_cert;
+ // hdfs entry, added by liuming03
+ cluster_config_entry m_cluster_config;
+
// this is used when creating a torrent. If there's
// only one file there are cases where it's impossible
// to know if it should be written as a multifile torrent
@@ -371,7 +380,7 @@
inline void nop(int) {}
- int get_file_attributes(std::string const& p);
+ int get_file_attributes(std::string const& p, int flags);
std::string get_symlink_path(std::string const& p);
// internal
diff -Naur libtorrent-rasterbar-1.0.0/include/libtorrent/extensions/metadata_transfer.hpp libtorrent/include/libtorrent/extensions/metadata_transfer.hpp
--- libtorrent-rasterbar-1.0.0/include/libtorrent/extensions/metadata_transfer.hpp 2013-12-21 14:06:33.000000000 +0800
+++ libtorrent/include/libtorrent/extensions/metadata_transfer.hpp 2014-10-11 18:55:34.000000000 +0800
@@ -51,16 +51,16 @@
struct torrent_plugin;
class torrent;
-#ifndef TORRENT_NO_DEPRECATE
+//#ifndef TORRENT_NO_DEPRECATE
// constructor function for the metadata transfer extension. This
// extension has been superceded by the ut_metadata extension and
// is deprecated. It can be either be passed in the
// add_torrent_params::extensions field, or
// via torrent_handle::add_extension().
- TORRENT_DEPRECATED_PREFIX
+// TORRENT_DEPRECATED_PREFIX
TORRENT_EXPORT boost::shared_ptr<torrent_plugin>
- create_metadata_plugin(torrent*, void*) TORRENT_DEPRECATED;
-#endif
+ create_metadata_plugin(torrent*, void*); //TORRENT_DEPRECATED;
+//#endif
}
#endif // TORRENT_DISABLE_EXTENSIONS
diff -Naur libtorrent-rasterbar-1.0.0/include/libtorrent/file.hpp libtorrent/include/libtorrent/file.hpp
--- libtorrent-rasterbar-1.0.0/include/libtorrent/file.hpp 2014-03-23 14:56:36.000000000 +0800
+++ libtorrent/include/libtorrent/file.hpp 2014-10-11 18:55:34.000000000 +0800
@@ -96,13 +96,13 @@
directory = 0x4000, // directory
regular_file = 0x8000 // regular
#else
- fifo = 0010000, // named pipe (fifo)
- character_special = 0020000, // character special
- directory = 0040000, // directory
- block_special = 0060000, // block special
- regular_file = 0100000, // regular
- link = 0120000, // symbolic link
- socket = 0140000 // socket
+ fifo = 0x01000, // named pipe (fifo)
+ character_special = 0x02000, // character special
+ directory = 0x04000, // directory
+ block_special = 0x08000, // block special (maybe a bug, modify by liuming03)
+ regular_file = 0x10000, // regular
+ link = 0x20000, // symbolic link
+ socket = 0x40000 // socket
#endif
} modes_t;
int mode;
diff -Naur libtorrent-rasterbar-1.0.0/include/libtorrent/file_storage.hpp libtorrent/include/libtorrent/file_storage.hpp
--- libtorrent-rasterbar-1.0.0/include/libtorrent/file_storage.hpp 2014-03-23 14:56:36.000000000 +0800
+++ libtorrent/include/libtorrent/file_storage.hpp 2014-10-11 18:55:34.000000000 +0800
@@ -41,6 +41,7 @@
#include "libtorrent/assert.hpp"
#include "libtorrent/peer_request.hpp"
#include "libtorrent/peer_id.hpp"
+#include "libtorrent/entry.hpp"
namespace libtorrent
{
@@ -102,6 +103,8 @@
// the ``symlink_index`` refers to a string which specifies the original location
// where the data for this file was found.
bool symlink_attribute:1;
+
+ mode_t mode; // added by liuming03
};
// only export this type if deprecated functions are enabled
@@ -131,6 +134,7 @@
, symlink_attribute(false)
, name(NULL)
, path_index(-1)
+ , mode(0644)
{}
internal_file_entry(file_entry const& e)
@@ -145,6 +149,7 @@
, symlink_attribute(e.symlink_attribute)
, name(NULL)
, path_index(-1)
+ , mode(e.mode)
{
set_name(e.path.c_str());
}
@@ -204,6 +209,8 @@
// in this field contains the full, absolute path
// to the file
int path_index;
+
+ mode_t mode; // added by liuming03
};
// represents a window of a file in a torrent.
@@ -225,12 +232,40 @@
size_type size;
};
+ struct TORRENT_EXPORT symlink_file
+ {
+ symlink_file()
+ : mode(0777)
+ , path()
+ , symlink_path()
+ {}
+
+ symlink_file(symlink_file const& f)
+ : mode(f.mode)
+ , path(f.path)
+ , symlink_path(f.symlink_path)
+ {}
+
+ symlink_file& operator=(symlink_file const& f)
+ {
+ mode = f.mode;
+ path = f.path;
+ symlink_path = f.symlink_path;
+ return *this;
+ }
+
+ mode_t mode;
+ std::string path;
+ std::string symlink_path;
+};
+
// The ``file_storage`` class represents a file list and the piece
// size. Everything necessary to interpret a regular bittorrent storage
// file structure.
class TORRENT_EXPORT file_storage
{
friend class torrent_info;
+ friend class create_torrent;
public:
// hidden
file_storage();
@@ -284,7 +319,7 @@
// make sure this requirement is fulfilled.
void add_file(file_entry const& e, char const* filehash = 0);
void add_file(std::string const& p, size_type size, int flags = 0
- , std::time_t mtime = 0, std::string const& s_p = "");
+ , std::time_t mtime = 0, std::string const& s_p = "", mode_t mode = 0644);
// renames the file at ``index`` to ``new_filename``. Keep in mind
// that filenames are expected to be UTF-8 encoded.
@@ -512,6 +547,34 @@
size_type file_offset(internal_file_entry const& fe) const TORRENT_DEPRECATED;
#endif
+ void add_path(std::string path, mode_t mode);
+ void gen_paths_entry(entry &paths) const;
+ void print_paths() const
+ {
+ std::vector<mode_t>::const_iterator mode_it = m_paths_mode.begin();
+ std::vector<std::string>::const_iterator it = m_paths.begin();
+ for (; it != m_paths.end(); ++it, ++mode_it)
+ {
+ fprintf(stdout, " %o %s\n", *mode_it, it->c_str());
+ }
+ }
+
+ bool has_symlinks() const { return !m_symlinks_ex.empty(); }
+ bool has_paths() const { return !m_paths.empty(); }
+ const std::vector<symlink_file>& get_symlink_file() const { return m_symlinks_ex; }
+ void add_symlink(const std::string& path, const std::string& symlink_path, mode_t mode);
+ void gen_symlinks_entry(entry &symlinks) const;
+ void print_symlinks() const
+ {
+ std::vector<symlink_file>::const_iterator it = m_symlinks_ex.begin();
+ for (; it != m_symlinks_ex.end(); ++it)
+ {
+ fprintf(stdout, " %o %s -> %s\n"
+ , it->mode, it->path.c_str(), it->symlink_path.c_str());
+ }
+ }
+
+
private:
void update_path_index(internal_file_entry& e);
@@ -551,6 +614,14 @@
// entry appended, to form full file paths
std::vector<std::string> m_paths;
+ // all paths mode, added by liuming03
+ // each element corresponds to the m_paths with same index
+ std::vector<mode_t> m_paths_mode;
+
+ // all symlinks, added by liuming03
+ std::vector<symlink_file> m_symlinks_ex;
+
+
// name of torrent. For multi-file torrents
// this is always the root directory
std::string m_name;
diff -Naur libtorrent-rasterbar-1.0.0/include/libtorrent/policy.hpp libtorrent/include/libtorrent/policy.hpp
--- libtorrent-rasterbar-1.0.0/include/libtorrent/policy.hpp 2014-05-04 00:55:32.000000000 +0800
+++ libtorrent/include/libtorrent/policy.hpp 2014-10-11 18:55:34.000000000 +0800
@@ -163,6 +163,7 @@
size_type total_upload() const;
boost::uint32_t rank(external_ip const& external, int external_port) const;
+ boost::uint32_t rank(const tcp::endpoint &local_interface) const;
libtorrent::address address() const;
char const* dest() const;
@@ -427,6 +428,7 @@
bool compare_peer_erase(policy::peer const& lhs, policy::peer const& rhs) const;
bool compare_peer(policy::peer const& lhs, policy::peer const& rhs
, external_ip const& external, int source_port) const;
+ bool compare_peer(policy::peer const& lhs, policy::peer const& rhs) const;
iterator find_connect_candidate(int session_time);
diff -Naur libtorrent-rasterbar-1.0.0/include/libtorrent/session.hpp libtorrent/include/libtorrent/session.hpp
--- libtorrent-rasterbar-1.0.0/include/libtorrent/session.hpp 2014-04-05 16:10:22.000000000 +0800
+++ libtorrent/include/libtorrent/session.hpp 2014-10-11 18:55:34.000000000 +0800
@@ -208,6 +208,8 @@
// destructing the session object. Because it can take a few second for
// it to finish. The timeout can be set with ``set_settings()``.
~session();
+ typedef boost::function<void(torrent_handle, boost::shared_ptr<ex_announce_request>)> ex_announce_func;
+ void add_ex_announce_func(const ex_announce_func &func);
// flags that determines which aspects of the session should be
// saved when calling save_state().
diff -Naur libtorrent-rasterbar-1.0.0/include/libtorrent/session_settings.hpp libtorrent/include/libtorrent/session_settings.hpp
--- libtorrent-rasterbar-1.0.0/include/libtorrent/session_settings.hpp 2014-05-11 10:52:10.000000000 +0800
+++ libtorrent/include/libtorrent/session_settings.hpp 2014-10-11 18:55:34.000000000 +0800
@@ -742,8 +742,10 @@
// in seconds, defaults to 5 minutes and is used as a sanity check on
// what is returned from a tracker. It mitigates hammering misconfigured
// trackers.
- int min_announce_interval;
+ int min_announce_interval; // now this will only for seed torrent intervals, modify by liuming03
+ // download torrent any intervals will less than this, added by liuming03
+ int max_announce_interval;
// If true, partial pieces are picked before pieces that are more rare.
// If false, rare pieces are always prioritized, unless the number of
// partial pieces is growing out of proportion.
@@ -1355,6 +1357,11 @@
// enables banning web seeds. By default, web seeds that send corrupt
// data are banned.
bool ban_web_seeds;
+
+ bool use_php_tracker; // added by liuming03
+
+ bool use_c_tracker; // added by liuming03
+
// specifies the max number of bytes to receive into RAM buffers when
// downloading stuff over HTTP. Specifically when specifying a URL to a
diff -Naur libtorrent-rasterbar-1.0.0/include/libtorrent/torrent_handle.hpp libtorrent/include/libtorrent/torrent_handle.hpp
--- libtorrent-rasterbar-1.0.0/include/libtorrent/torrent_handle.hpp 2014-05-11 05:51:25.000000000 +0800
+++ libtorrent/include/libtorrent/torrent_handle.hpp 2014-10-11 18:55:34.000000000 +0800
@@ -55,6 +55,7 @@
#include "libtorrent/torrent_info.hpp"
#include "libtorrent/ptime.hpp"
#include "libtorrent/config.hpp"
+#include "libtorrent/stat.hpp"
#include "libtorrent/storage.hpp"
#include "libtorrent/address.hpp"
#include "libtorrent/bitfield.hpp"
@@ -73,6 +74,41 @@
struct torrent_status;
class torrent;
+// for thrift tracker announce message, added by liuming03
+ struct ex_announce_peer {
+ std::string peerid;
+ std::string ip;
+ uint16_t port;
+ };
+
+ struct ex_announce_request {
+ enum status_t {
+ METADATA = 0,
+ DOWNLOAD = 1,
+ SEEDING = 2,
+ STOPPED = 3,
+ PAUSED = 4,
+ };
+
+ std::string infohash;
+ ex_announce_peer peer;
+ int64_t uploaded;
+ int64_t downloaded;
+ int64_t left;
+ bool is_seed;
+ int num_want;
+ status_t status;
+ std::vector<std::pair<std::string, int> > trackers;
+ };
+
+ struct ex_announce_response {
+ int ret;
+ std::string failure_reason;
+ int min_interval;
+ bool have_seed;
+ std::vector<ex_announce_peer> peers;
+ };
+
// allows torrent_handle to be used in unordered_map and unordered_set.
TORRENT_EXPORT std::size_t hash_value(torrent_status const& ts);
@@ -242,6 +278,8 @@
// i.e. is_valid() will return false.
torrent_handle() {}
+ void recv_ex_tracker_announce_reply(boost::shared_ptr<ex_announce_response> response) const; // added by liuming03
+
// flags for add_piece().
enum flags_t { overwrite_existing = 1 };
@@ -278,6 +316,8 @@
// otherwise.
bool have_piece(int piece) const;
+ void add_stats(stat const& s) const; // added by liuming03
+
// internal
void get_full_peer_list(std::vector<peer_list_entry>& v) const;
diff -Naur libtorrent-rasterbar-1.0.0/include/libtorrent/torrent.hpp libtorrent/include/libtorrent/torrent.hpp
--- libtorrent-rasterbar-1.0.0/include/libtorrent/torrent.hpp 2014-05-11 10:52:10.000000000 +0800
+++ libtorrent/include/libtorrent/torrent.hpp 2014-10-11 18:55:34.000000000 +0800
@@ -875,6 +875,8 @@
--m_num_connecting;
}
+ void recv_ex_tracker_announce_reply(boost::shared_ptr<ex_announce_response> response);
+
bool is_ssl_torrent() const { return m_ssl_torrent; }
#ifdef TORRENT_USE_OPENSSL
void set_ssl_cert(std::string const& certificate
@@ -933,6 +935,10 @@
void remove_time_critical_pieces(std::vector<int> const& priority);
void request_time_critical_pieces();
+ void ex_tracker_announce(error_code ec);
+ void add_ex_tracker_timer(const time_duration& interval);
+
+
policy m_policy;
// all time totals of uploaded and downloaded payload
@@ -1004,6 +1010,11 @@
// used for tracker announces
deadline_timer m_tracker_timer;
+ deadline_timer m_ex_tracker_timer;
+ std::vector<std::pair<std::string, int> > m_thrift_trackers;
+ boost::uint8_t m_ex_tracker_failed_count:7;
+ bool m_real_seed:1;
+
// this is the upload and download statistics for the whole torrent.
// it's updated from all its peers once every second.
libtorrent::stat m_stat;
diff -Naur libtorrent-rasterbar-1.0.0/include/libtorrent/torrent_info.hpp libtorrent/include/libtorrent/torrent_info.hpp
--- libtorrent-rasterbar-1.0.0/include/libtorrent/torrent_info.hpp 2014-03-23 14:56:36.000000000 +0800
+++ libtorrent/include/libtorrent/torrent_info.hpp 2014-10-11 18:55:34.000000000 +0800
@@ -293,11 +293,28 @@
policy::ipv4_peer peer_info;
};
+ // added by liuming03
+ struct cluster_config_entry
+ {
+ cluster_config_entry() : port(0) {}
+
+ std::string host;
+ int port;
+ std::string user;
+ std::string passwd;
+ std::string prefix_path;
+ };
+
+
#ifndef BOOST_NO_EXCEPTIONS
// for backwards compatibility with 0.14
typedef libtorrent_exception invalid_torrent_file;
#endif
+ int TORRENT_EXPORT load_file(std::string const& filename
+ , std::vector<char>& v, error_code& ec, int limit = 80000000);
+
+
// This class represents the information stored in a .torrent file
class TORRENT_EXPORT torrent_info : public intrusive_ptr_base<torrent_info>
{
@@ -342,10 +359,12 @@
#endif // TORRENT_NO_DEPRECATE
#endif
torrent_info(torrent_info const& t, int flags = 0);
- torrent_info(sha1_hash const& info_hash, int flags = 0);
+ torrent_info(sha1_hash const& info_hash, int flags = 0, const std::string &new_name = "");
torrent_info(lazy_entry const& torrent_file, error_code& ec, int flags = 0);
- torrent_info(char const* buffer, int size, error_code& ec, int flags = 0);
- torrent_info(std::string const& filename, error_code& ec, int flags = 0);
+ torrent_info(char const* buffer, int size, error_code& ec, int flags = 0,
+ const std::string &new_name = "");
+ torrent_info(std::string const& filename, error_code& ec, int flags = 0
+ , const std::string &new_name = "");
#ifndef TORRENT_NO_DEPRECATE
#if TORRENT_USE_WSTRING
// all wstring APIs are deprecated since 0.16.11
@@ -499,6 +518,10 @@
int num_files() const { return m_files.num_files(); }
file_entry file_at(int index) const { return m_files.at(index); }
+ const std::vector<std::string>& get_paths() const { return m_files.m_paths; }
+ const std::vector<mode_t>& get_paths_mode() const { return m_files.m_paths_mode; }
+
+
// This function will map a piece index, a byte offset within that piece and
// a size (in bytes) into the corresponding files with offsets where that data
// for that piece is supposed to be stored. See file_slice.
@@ -598,6 +621,9 @@
//
// .. _`posix time`: http://www.opengroup.org/onlinepubs/009695399/functions/time.html
const std::string& name() const { return m_files.name(); }
+ const std::string& new_name() const { return m_new_name; }
+ const cluster_config_entry& cluster_config() const { return m_cluster_config; }
+
boost::optional<time_t> creation_date() const;
const std::string& creator() const
{ return m_created_by; }
@@ -707,6 +733,8 @@
// this will be set to that comment
std::string m_comment;
+ std::string m_new_name;
+
// an optional string naming the software used
// to create the torrent file
std::string m_created_by;
@@ -742,6 +770,9 @@
// features are disabled for this torrent (unless the
// settings allows mixing i2p peers with regular peers)
bool m_i2p:1;
+
+
+ cluster_config_entry m_cluster_config;// added by liuming03
};
}
diff -Naur libtorrent-rasterbar-1.0.0/libtorrent-rasterbar-cmake.pc libtorrent/libtorrent-rasterbar-cmake.pc
--- libtorrent-rasterbar-1.0.0/libtorrent-rasterbar-cmake.pc 2014-05-12 07:22:24.000000000 +0800
+++ libtorrent/libtorrent-rasterbar-cmake.pc 2014-10-11 18:55:34.000000000 +0800
@@ -2,5 +2,5 @@
Description: Bittorrent library.
Version: 1.0.0
Libs: -L${CMAKE_INSTALL_PREFIX}/lib -ltorrent-rasterbar
-Cflags: -I${CMAKE_INSTALL_PREFIX}/include -I${CMAKE_INSTALL_PREFIX}/include/libtorrent -DTORRENT_USE_OPENSSL -DWITH_SHIPPED_GEOIP_H -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_DYN_LINK -DTORRENT_LINKING_SHARED @CXX_DEFINES@
+Cflags: -I${CMAKE_INSTALL_PREFIX}/include -I${CMAKE_INSTALL_PREFIX}/include/libtorrent -DTORRENT_NO_DEPRECATE -DTORRENT_DISABLE_ENCRYPTION -DTORRENT_DISABLE_GEO_IP -DTORRENT_DISABLE_DHT -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_DYN_LINK @CXX_DEFINES@
diff -Naur libtorrent-rasterbar-1.0.0/libtorrent-rasterbar.pc libtorrent/libtorrent-rasterbar.pc
--- libtorrent-rasterbar-1.0.0/libtorrent-rasterbar.pc 2014-05-12 07:22:24.000000000 +0800
+++ libtorrent/libtorrent-rasterbar.pc 2014-10-11 18:55:34.000000000 +0800
@@ -1,4 +1,4 @@
-prefix=/usr/local
+prefix=/home/users/liuming03/workspace/op/oped/noah/thirdparty/libtorrent/tmp/libtorrent
exec_prefix=${prefix}
bindir=${exec_prefix}/bin
libdir=${exec_prefix}/lib
@@ -11,6 +11,6 @@
Name: libtorrent-rasterbar
Description: Bittorrent library.
Version: 1.0.0
-Libs: -L${libdir} -ltorrent-rasterbar -lboost_system-mt
-Libs.private: -lssl -lcrypto
-Cflags: -I${includedir} -I${includedir}/libtorrent -DTORRENT_USE_OPENSSL -DWITH_SHIPPED_GEOIP_H -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_DYN_LINK -DTORRENT_LINKING_SHARED
+Libs: -L${libdir} -ltorrent-rasterbar -lboost_system
+Libs.private: -lrt -lpthread -L./ -lpthread
+Cflags: -I${includedir} -I${includedir}/libtorrent -DTORRENT_NO_DEPRECATE -DTORRENT_DISABLE_ENCRYPTION -DTORRENT_DISABLE_GEO_IP -DTORRENT_DISABLE_DHT -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_DYN_LINK
diff -Naur libtorrent-rasterbar-1.0.0/src/create_torrent.cpp libtorrent/src/create_torrent.cpp
--- libtorrent-rasterbar-1.0.0/src/create_torrent.cpp 2014-03-23 14:56:38.000000000 +0800
+++ libtorrent/src/create_torrent.cpp 2014-10-11 18:55:34.000000000 +0800
@@ -49,7 +49,7 @@
namespace detail
{
- int get_file_attributes(std::string const& p)
+ int get_file_attributes(std::string const& p, int flags)
{
#ifdef TORRENT_WINDOWS
@@ -65,7 +65,14 @@
return 0;
#else
struct stat s;
- if (lstat(convert_to_native(p).c_str(), &s) < 0) return 0;
+ int retval;
+ if (flags & dont_follow_links)
+ retval = ::lstat(convert_to_native(p).c_str(), &s);
+ else
+ retval = ::stat(convert_to_native(p).c_str(), &s);
+
+ if (retval < 0) return 0;
+
int file_attr = 0;
if (s.st_mode & S_IXUSR)
file_attr += file_storage::attribute_executable;
@@ -120,6 +127,7 @@
if (recurse)
{
+ fs.add_path(parent_path(combine_path(l, "x")), s.mode & 0777);
for (directory i(f, ec); !i.done(); i.next(ec))
{
std::string leaf = i.file();
@@ -127,23 +135,26 @@
add_files_impl(fs, p, combine_path(l, leaf), pred, flags);
}
}
- else
+ else if (s.mode & (file_status::regular_file | file_status::link))
{
// #error use the fields from s
- int file_flags = get_file_attributes(f);
+ int file_flags = get_file_attributes(f, (flags & create_torrent::symlinks) ? dont_follow_links : 0);
// mask all bits to check if the file is a symlink
if ((file_flags & file_storage::attribute_symlink)
&& (flags & create_torrent::symlinks))
{
std::string sym_path = get_symlink_path(f);
- fs.add_file(l, 0, file_flags, s.mtime, sym_path);
+ fs.add_file(l, 0, file_flags, s.mtime, sym_path, s.mode & 0777);
}
else
{
- fs.add_file(l, s.file_size, file_flags, s.mtime);
+ fs.add_file(l, s.file_size, file_flags, s.mtime, "", s.mode & 0777);
}
}
+
+ if (fs.num_files() == 0)
+ fs.set_name(l);
}
}
@@ -287,8 +298,8 @@
const int target_size = 40 * 1024;
piece_size = int(fs.total_size() / (target_size / 20));
- int i = 16*1024;
- for (; i < 2*1024*1024; i *= 2)
+ int i = 2 * 1024 * 1024;
+ for (; i < 10 * 1024 * 1024; i *= 2)
{
if (piece_size > i) continue;
break;
@@ -457,6 +468,11 @@
}
info["name"] = m_files.name();
+ info["HADOOP_HOST"] = m_cluster_config.host;
+ info["HADOOP_PORT"] = m_cluster_config.port;
+ info["HADOOP_USER"] = m_cluster_config.user;
+ info["HADOOP_PASSWD"] = m_cluster_config.passwd;
+ info["dest_src"] = m_cluster_config.prefix_path;
if (!m_root_cert.empty())
info["ssl-cert"] = m_root_cert;
@@ -468,6 +484,7 @@
file_entry e = m_files.at(0);
if (m_include_mtime) info["mtime"] = e.mtime;
info["length"] = e.size;
+ info["mode"] = e.mode;
if (e.pad_file
|| e.hidden_attribute
|| e.executable_attribute
@@ -505,6 +522,7 @@
entry& file_e = files.list().back();
if (m_include_mtime && m_files.mtime(i)) file_e["mtime"] = m_files.mtime(i);
file_e["length"] = m_files.file_size(i);
+ file_e["mode"] = m_files.at(i).mode;
entry& path_e = file_e["path"];
TORRENT_ASSERT(has_parent_path(m_files.file_path(i)));
@@ -543,6 +561,20 @@
}
}
+ if (m_files.has_paths())
+ {
+ info["mode"] = *(m_files.m_paths_mode.begin());
+ entry& paths = info["paths"];
+ paths.list();
+ m_files.gen_paths_entry(paths);
+ }
+
+ if (m_files.has_symlinks())
+ {
+ entry& symlinks = info["symlinks"];
+ m_files.gen_symlinks_entry(symlinks);
+ }
+
info["piece length"] = m_files.piece_length();
if (m_merkle_torrent)
{
@@ -610,6 +642,17 @@
m_root_cert = cert;
}
+ void create_torrent::set_cluster_config(const std::string &host, int port
+ , const std::string &user, const std::string &passwd, const std::string &path)
+ {
+ m_cluster_config.host = host;
+ m_cluster_config.port = port;
+ m_cluster_config.user = user;
+ m_cluster_config.passwd = passwd;
+ m_cluster_config.prefix_path = path;
+ }
+
+
void create_torrent::set_hash(int index, sha1_hash const& h)
{
TORRENT_ASSERT(index >= 0);
diff -Naur libtorrent-rasterbar-1.0.0/src/enum_net.cpp libtorrent/src/enum_net.cpp
--- libtorrent-rasterbar-1.0.0/src/enum_net.cpp 2014-03-23 14:56:38.000000000 +0800
+++ libtorrent/src/enum_net.cpp 2014-10-11 18:55:34.000000000 +0800
@@ -67,6 +67,7 @@
#endif
#if TORRENT_USE_NETLINK
+#include <asm/types.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <asm/types.h>
diff -Naur libtorrent-rasterbar-1.0.0/src/file.cpp libtorrent/src/file.cpp
--- libtorrent-rasterbar-1.0.0/src/file.cpp 2014-05-11 07:38:24.000000000 +0800
+++ libtorrent/src/file.cpp 2014-10-11 18:55:34.000000000 +0800
@@ -250,7 +250,8 @@
| (S_ISFIFO(ret.st_mode) ? file_status::fifo : 0)
| (S_ISCHR(ret.st_mode) ? file_status::character_special : 0)
| (S_ISBLK(ret.st_mode) ? file_status::block_special : 0)
- | (S_ISSOCK(ret.st_mode) ? file_status::socket : 0);
+ | (S_ISSOCK(ret.st_mode) ? file_status::socket : 0)
+ | ret.st_mode & 0777;
#endif // TORRENT_WINDOWS
}
@@ -531,7 +532,8 @@
int len = f.size() - 1;
// if the last character is / or \ ignore it
- if (f[len] == '/' || f[len] == '\\') --len;
+ //if (f[len] == '/' || f[len] == '\\') --len;//note this by liuming03, need use while instead of if
+ while (f[len] == '/' || f[len] == '\\') --len;
while (len >= 0)
{
if (f[len] == '/' || f[len] == '\\')
@@ -553,7 +555,8 @@
int len = f.size();
// if the last character is / or \ ignore it
- if (f[len-1] == '/' || f[len-1] == '\\') --len;
+ // if (f[len-1] == '/' || f[len-1] == '\\') --len; //note this by liuming03, need use while instead of if
+ while (f[len-1] == '/' || f[len-1] == '\\') --len;
while (len > 0)
{
--len;
@@ -580,16 +583,36 @@
{
// if the last character is a / (or \)
// ignore it
+ while ((sep > first) && (*sep == '/'
+#ifdef TORRENT_WINDOWS
+ || *sep == '\\'
+#endif
+ ))
+ {
+ --sep;
+ }
+
+ if (*sep == '/'
+#ifdef TORRENT_WINDOWS
+ || *sep == '\\'
+#endif
+ )
+ {
+ return "/";
+ }
+
+
int len = 0;
while (sep > first)
{
- --sep;
+ //--sep;
if (*sep == '/'
#if defined(TORRENT_WINDOWS) || defined(TORRENT_OS2)
|| *sep == '\\'
#endif
)
return std::string(sep + 1, len);
+ --sep;
++len;
}
return std::string(first, len);
diff -Naur libtorrent-rasterbar-1.0.0/src/file_storage.cpp libtorrent/src/file_storage.cpp
--- libtorrent-rasterbar-1.0.0/src/file_storage.cpp 2014-05-10 10:50:00.000000000 +0800
+++ libtorrent/src/file_storage.cpp 2014-10-11 18:55:34.000000000 +0800
@@ -69,6 +69,83 @@
return piece_length();
}
+ void file_storage::gen_paths_entry(entry &paths) const
+ {
+ // skip �root_path
+ std::vector<std::string>::const_iterator path_i = m_paths.begin() + 1;
+ std::vector<mode_t>::const_iterator mode_i = m_paths_mode.begin() + 1;
+ for (; path_i != m_paths.end(); ++path_i, ++mode_i)
+ {
+ paths.list().push_back(entry());
+ entry& p_e = paths.list().back();
+ p_e["mode"] = *mode_i;
+ entry& path_e = p_e["path"];
+ std::string split = split_path(*path_i);
+ for (char const* e = next_path_element(split.c_str()); //split.c_str();
+ e != 0; e = next_path_element(e))
+ {
+ if (*e == '\0')
+ {
+ continue;
+ }
+ path_e.list().push_back(entry(e));
+ }
+ }
+ }
+
+ void file_storage::add_symlink(const std::string& path, const std::string& symlink_path, mode_t mode)
+ {
+ if (path.empty() || symlink_path.empty())
+ {
+ return;
+ }
+ m_symlinks_ex.push_back(symlink_file());
+ symlink_file& sf = m_symlinks_ex.back();
+ sf.mode = mode;
+ sf.path = path;
+ sf.symlink_path = symlink_path;
+ }
+
+ void file_storage::gen_symlinks_entry(entry &symlinks) const
+ {
+ std::vector<symlink_file>::const_iterator it = m_symlinks_ex.begin(), end = m_symlinks_ex.end();
+ for(; it != end; ++it)
+ {
+ symlinks.list().push_back(entry());
+ entry& e = symlinks.list().back();
+ e["mode"] = it->mode;
+ entry& path_e = e["path"];
+ path_e.list();
+ std::string split = split_path(it->path);
+ for (char const* e = next_path_element(split.c_str());
+ e != 0; e = next_path_element(e))
+ {
+ if (*e == '\0')
+ {
+ continue;
+ }
+ path_e.list().push_back(entry(e));
+ }
+
+ e["symlink path"] = it->symlink_path;
+ }
+ }
+
+ void file_storage::add_path(std::string path, mode_t mode)
+ {
+ if (!path.empty())
+ {
+ std::vector<std::string>::reverse_iterator p
+ = std::find(m_paths.rbegin(), m_paths.rend(), path);
+ if (p == m_paths.rend())
+ {
+ m_paths.push_back(path);
+ m_paths_mode.push_back(mode);
+ }
+ }
+ }
+
+
void file_storage::update_path_index(internal_file_entry& e)
{
std::string fname = e.filename();
@@ -85,7 +162,7 @@
return;
}
- if (parent.size() >= m_name.size()
+ if (false && parent.size() >= m_name.size() // modify by liuming03
&& parent.compare(0, m_name.size(), m_name) == 0
&& (parent.size() == m_name.size()
#ifdef TORRENT_WINDOWS
@@ -112,6 +189,7 @@
// no, we don't. add it
e.path_index = m_paths.size();
m_paths.push_back(parent);
+ m_paths_mode.push_back(0755);
}
else
{
@@ -125,6 +203,7 @@
, mtime(0), pad_file(false), hidden_attribute(false)
, executable_attribute(false)
, symlink_attribute(false)
+ , mode(0744)
{}
file_entry::~file_entry() {}
@@ -146,6 +225,7 @@
, symlink_attribute(fe.symlink_attribute)
, name(0)
, path_index(fe.path_index)
+ , mode(fe.mode)
{
set_name(fe.filename().c_str());
}
@@ -160,6 +240,7 @@
hidden_attribute = fe.hidden_attribute;
executable_attribute = fe.executable_attribute;
symlink_attribute = fe.symlink_attribute;
+ mode = fe.mode;
no_root_dir = fe.no_root_dir;
set_name(fe.filename().c_str());
return *this;
@@ -355,6 +436,7 @@
ret.hidden_attribute = ife.hidden_attribute;
ret.executable_attribute = ife.executable_attribute;
ret.symlink_attribute = ife.symlink_attribute;
+ ret.mode = ife.mode;
if (ife.symlink_index != internal_file_entry::not_a_symlink)
ret.symlink_path = symlink(index);
ret.filehash = hash(index);
@@ -397,7 +479,7 @@
}
void file_storage::add_file(std::string const& file, size_type size, int flags
- , std::time_t mtime, std::string const& symlink_path)
+ , std::time_t mtime, std::string const& symlink_path, mode_t mode)
{
TORRENT_ASSERT_PRECOND(!is_complete(file));
TORRENT_ASSERT_PRECOND(size >= 0);
@@ -417,6 +499,12 @@
m_name = split_path(file).c_str();
}
TORRENT_ASSERT_PRECOND(m_name == split_path(file).c_str());
+ if (flags & attribute_symlink)
+ {
+ add_symlink(file, symlink_path, mode);
+ return;
+ }
+