1️⃣ Base Stage
Decode bencoded integers

Decode bencoded lists

Decode bencoded dictionaries

Parse torrent file

Calculate info hash

Piece hashes

Discover peers

Peer handshake

Download a piece

Download the whole file

2️⃣ Magnet Links
Parse magnet link

Announce extension support

Send extension handshake

Receive extension handshake

Request metadata

Receive metadata

Download a piece

Download the whole file

log
[compile] -- Running vcpkg install
[compile] All requested packages are currently installed.
[compile] All requested installations completed successfully in: 85 us
[compile] -- Running vcpkg install - done
[compile] -- Configuring done (0.0s)
[compile] -- Generating done (0.0s)
[compile] -- Build files have been written to: /app/build
[compile] [ 50%] Building CXX object CMakeFiles/bittorrent.dir/src/main.cpp.o
[compile] In file included from /app/src/main.cpp:112:
[compile] /app/src/lib/nlohmann/json.hpp:24329:34: warning: space between quotes and suffix is deprecated in C++23 [-Wdeprecated-literal-operator]
[compile] 24329 | inline nlohmann::json operator "" _json(const char* s, std::size_t n)
[compile] | ^~
[compile] | --
[compile] /app/src/lib/nlohmann/json.hpp:24329:34: warning: space between quotes and suffix is deprecated in C++23 [-Wdeprecated-literal-operator]
[compile] 24329 | inline nlohmann::json operator "" _json(const char* s, std::size_t n)
[compile] | ^~
[compile] | --
[compile] /app/src/lib/nlohmann/json.hpp:24337:48: warning: space between quotes and suffix is deprecated in C++23 [-Wdeprecated-literal-operator]
[compile] 24337 | inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n)
[compile] | ^~
[compile] | --
[compile] /app/src/lib/nlohmann/json.hpp:24337:48: warning: space between quotes and suffix is deprecated in C++23 [-Wdeprecated-literal-operator]
[compile] 24337 | inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n)
[compile] | ^~
[compile] | --
[compile] /app/src/lib/nlohmann/json.hpp:24401:57: warning: space between quotes and suffix is deprecated in C++23 [-Wdeprecated-literal-operator]
[compile] 24401 | using nlohmann::literals::json_literals::operator "" _json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers)
[compile] | ^~
[compile] | --
[compile] /app/src/lib/nlohmann/json.hpp:24401:57: warning: space between quotes and suffix is deprecated in C++23 [-Wdeprecated-literal-operator]
[compile] 24401 | using nlohmann::literals::json_literals::operator "" _json; // NOLINT(misc-unused-using-decls,google-global-names-in-headers)
[compile] | ^~
[compile] | --
[compile] /app/src/lib/nlohmann/json.hpp:24402:57: warning: space between quotes and suffix is deprecated in C++23 [-Wdeprecated-literal-operator]
[compile] 24402 | using nlohmann::literals::json_literals::operator "" _json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers)
[compile] | ^~
[compile] | --
[compile] /app/src/lib/nlohmann/json.hpp:24402:57: warning: space between quotes and suffix is deprecated in C++23 [-Wdeprecated-literal-operator]
[compile] 24402 | using nlohmann::literals::json_literals::operator "" _json_pointer; //NOLINT(misc-unused-using-decls,google-global-names-in-headers)
[compile] | ^~
[compile] | --
[compile] [100%] Linking CXX executable bittorrent
[compile] [100%] Built target bittorrent
[compile] Moved ./.codecrafters/run.sh → ./your_program.sh
[compile] Compilation successful.
[tester::#DV7] Running tests for Stage #DV7 (Magnet Links - Download the whole file)
[tester::#DV7] Running ./your_bittorrent.sh magnet_download -o /tmp/torrents3105287613/magnet2.gif "magnet:?xt=urn:btih:3f994a835e090238873498636b98a3e78d1c34ca&dn=magnet2.gif&tr=http%3A%2F%2Fbittorrent-test-tracker.codecrafters.io%2Fannounce"
[tester::#DV7] ✓ File size is correct.
[tester::#DV7] ✓ File SHA-1 is correct.
[tester::#DV7] Test passed.
[tester::#QV6] Running tests for Stage #QV6 (Magnet Links - Download a piece)
[tester::#QV6] Running ./your_bittorrent.sh magnet_download_piece -o /tmp/torrents3535771863/piece-1 "magnet:?xt=urn:btih:ad42ce8109f54c99613ce38f9b4d87e70f24a165&dn=magnet1.gif&tr=http%3A%2F%2Fbittorrent-test-tracker.codecrafters.io%2Fannounce" 1
[tester::#QV6] ✓ Piece size is correct.
[tester::#QV6] ✓ Piece SHA-1 is correct.
[tester::#QV6] Running ./your_bittorrent.sh magnet_download_piece -o /tmp/torrents3535771863/piece-2 "magnet:?xt=urn:btih:ad42ce8109f54c99613ce38f9b4d87e70f24a165&dn=magnet1.gif&tr=http%3A%2F%2Fbittorrent-test-tracker.codecrafters.io%2Fannounce" 2
[tester::#QV6] ✓ Piece size is correct.
[tester::#QV6] ✓ Piece SHA-1 is correct.
[tester::#QV6] Test passed.
[tester::#ZH1] Running tests for Stage #ZH1 (Magnet Links - Receive metadata)
[tester::#ZH1] Running ./your_bittorrent.sh magnet_info "magnet:?xt=urn:btih:ad42ce8109f54c99613ce38f9b4d87e70f24a165&dn=magnet1.gif&tr=http%3A%2F%2F127.0.0.1:43377%2Fannounce"
[your_program] Tracker URL: http://127.0.0.1:43377/announce
[your_program] Length: 636505
[your_program] Info Hash: ad42ce8109f54c99613ce38f9b4d87e70f24a165
[your_program] Piece Length: 262144
[your_program] Piece Hashes:
[your_program] 3b46a96d9bc3716d1b75da91e6d753a793ad1cef
[your_program] eda417cb5c1cdbf841125c412da0bec9db8301f3
[your_program] 422f45b1052e2d45da3e2a6516e1bb1f1db00733
[tester::#ZH1] ✓ Tracker URL is correct.
[tester::#ZH1] ✓ Length is correct.
[tester::#ZH1] ✓ Info Hash is correct.
[tester::#ZH1] ✓ Piece Length is correct.
[tester::#ZH1] ✓ Piece Hashes are correct.
[tester::#ZH1] Test passed.
[tester::#NS5] Running tests for Stage #NS5 (Magnet Links - Request metadata)
[tester::#NS5] Running ./your_bittorrent.sh magnet_info "magnet:?xt=urn:btih:ad42ce8109f54c99613ce38f9b4d87e70f24a165&dn=magnet1.gif&tr=http%3A%2F%2F127.0.0.1:36953%2Fannounce"
[your_program] Tracker URL: http://127.0.0.1:36953/announce
[your_program] Length: 636505
[your_program] Info Hash: ad42ce8109f54c99613ce38f9b4d87e70f24a165
[your_program] Piece Length: 262144
[your_program] Piece Hashes:
[your_program] 3b46a96d9bc3716d1b75da91e6d753a793ad1cef
[your_program] eda417cb5c1cdbf841125c412da0bec9db8301f3
[your_program] 422f45b1052e2d45da3e2a6516e1bb1f1db00733
[tester::#NS5] Test passed.
[tester::#JK6] Running tests for Stage #JK6 (Magnet Links - Receive extension handshake)
[tester::#JK6] Running ./your_bittorrent.sh magnet_handshake "magnet:?xt=urn:btih:c5fb9894bdaba464811b088d806bdd611ba490af&dn=magnet3.gif&tr=http%3A%2F%2F127.0.0.1:35353%2Fannounce"
[your_program] Peer ID: 2926f6ad44883b80429d2e90d86772f6bdcd81c0
[your_program] Peer Metadata Extension ID: 206
[tester::#JK6] ✓ Peer ID is correct.
[tester::#JK6] ✓ Peer Metadata Extension ID is correct.
[tester::#JK6] Test passed.
[tester::#XI4] Running tests for Stage #XI4 (Magnet Links - Send extension handshake)
[tester::#XI4] Running ./your_bittorrent.sh magnet_handshake "magnet:?xt=urn:btih:3f994a835e090238873498636b98a3e78d1c34ca&dn=magnet2.gif&tr=http%3A%2F%2F127.0.0.1:46491%2Fannounce"
[your_program] Peer ID: eb3880ed07a5848fa8dfcb6426d0c91c63a4bd2a
[your_program] Peer Metadata Extension ID: 63
[tester::#XI4] Test passed.
[tester::#PK2] Running tests for Stage #PK2 (Magnet Links - Announce extension support)
[tester::#PK2] Running ./your_bittorrent.sh magnet_handshake "magnet:?xt=urn:btih:3f994a835e090238873498636b98a3e78d1c34ca&dn=magnet2.gif&tr=http%3A%2F%2F127.0.0.1:41113%2Fannounce"
[your_program] Peer ID: 39a78ce66c3922cb24f6387e0504658ab243753a
[your_program] Peer Metadata Extension ID: 52
[tester::#PK2] Test passed.
[tester::#HW0] Running tests for Stage #HW0 (Magnet Links - Parse magnet link)
[tester::#HW0] Running ./your_bittorrent.sh magnet_parse "magnet:?xt=urn:btih:c5fb9894bdaba464811b088d806bdd611ba490af&dn=magnet3.gif&tr=http%3A%2F%2Fbittorrent-test-tracker.codecrafters.io%2Fannounce"
[your_program] Tracker URL: http://bittorrent-test-tracker.codecrafters.io/announce
[your_program] Info Hash: c5fb9894bdaba464811b088d806bdd611ba490af
[tester::#HW0] ✓ Info Hash is correct.
[tester::#HW0] ✓ Tracker URL is correct.
[tester::#HW0] Test passed.
[tester::#JV8] Running tests for Stage #JV8 (Download the whole file)
[tester::#JV8] Running ./your_program.sh download -o /tmp/torrents3019937286/congratulations.gif /tmp/torrents3019937286/congratulations.gif.torrent
[tester::#JV8] Test passed.
[tester::#ND2] Running tests for Stage #ND2 (Download a piece)
[tester::#ND2] Running ./your_program.sh download_piece -o /tmp/torrents294608627/piece-2 /tmp/torrents294608627/congratulations.gif.torrent 2
[tester::#ND2] Running ./your_program.sh download_piece -o /tmp/torrents294608627/piece-3 /tmp/torrents294608627/congratulations.gif.torrent 3
[tester::#ND2] Test passed.
[tester::#CA4] Running tests for Stage #CA4 (Peer handshake)
[tester::#CA4] Running ./your_program.sh handshake /tmp/torrents3492609347/test.torrent 127.0.0.1:42071
[your_program] Peer ID: a2def9afe1ba96ab0af3f5e64d1ba818a80d3859
[tester::#CA4] Test passed.
[tester::#FI9] Running tests for Stage #FI9 (Discover peers)
[tester::#FI9] Running ./your_program.sh peers /tmp/torrents2912078557/test.torrent
[your_program] 188.119.61.177:6881
[your_program] 185.107.13.235:54542
[your_program] 88.99.2.101:6881
[tester::#FI9] Test passed.
[tester::#BF7] Running tests for Stage #BF7 (Piece hashes)
[tester::#BF7] Running ./your_program.sh info /tmp/torrents3334855310/test.torrent
[your_program] Tracker URL: http://bttracker.debian.org:6969/announce
[your_program] Length: 1572864
[your_program] Info Hash: ad7f0629e6dd300006827699a4bfb8cfa14c7afc
[your_program] Piece Length: 262144
[your_program] Piece Hashes:
[your_program] a245894e110070f811aaa6f60820cd31786f8bc4
[your_program] 9370e822cc4749ef6d94000b9ac760caceb53d24
[your_program] f0e17035d8eaeee25f5f9e45b94a24eda77c7072
[your_program] 51fbf75ccd309de1eda3cdeba38f8947bef7a583
[your_program] f59bbe58562e71908c24f7dd2e81f70041adda3d
[your_program] 70edcac2611a8829ebf467a6849f5d8408d9d8f4
[tester::#BF7] Test passed.
[tester::#RB2] Running tests for Stage #RB2 (Calculate info hash)
[tester::#RB2] Running ./your_program.sh info /tmp/torrents1651158746/congratulations.gif.torrent
[your_program] Tracker URL: http://bittorrent-test-tracker.codecrafters.io/announce
[your_program] Length: 820892
[your_program] Info Hash: 1cad4a486798d952614c394eb15e75bec587fd08
[your_program] Piece Length: 262144
[your_program] Piece Hashes:
[your_program] 3d42a20edb1cf840cd3528d3a9e921db6338a463
[your_program] 69f885b3988a52ffb03591985402b6d5285940ab
[your_program] 76869e6c9c1f101f94f39de153e468be6a638f4f
[your_program] bded68d02de011a2b687f75b5833f46cce8e3e9c
[tester::#RB2] Running ./your_program.sh info /tmp/torrents1651158746/codercat.gif.torrent
[your_program] Tracker URL: http://bittorrent-test-tracker.codecrafters.io/announce
[your_program] Length: 2994120
[your_program] Info Hash: c77829d2a77d6516f88cd7a3de1a26abcbfab0db
[your_program] Piece Length: 262144
[your_program] Piece Hashes:
[your_program] 3c34309faebf01e49c0f63c90b7edcc2259b6ad0
[your_program] b8519b2ea9bb373ff567f644428156c98a1d00fc
[your_program] 9dc81366587536f48c2098a1d79692f2590fd9a6
[your_program] 033c61e717f8c0d1e55850680eb451e3543b6203
[your_program] 6f54e746ec369f65f32d45f77b1f1c37621fb965
[your_program] c656704b78107ed553bd0813f92fef780267c07b
[your_program] 7431b8683137d20ff594b1f1bf3f8835165d68fb
[your_program] 0432bd8e779608d27782b779c7738062e9b50ab5
[your_program] d6bc0409a0f3a9503857669d47fe752d4577ea00
[your_program] a86ee6abbc30cddb800a0b62d7a296111166d839
[your_program] 783f52b70f0c902d56196bd3ee7f379b5db57e3b
[your_program] 3d8db9e34db63b4ba1be27930911aa37b3f997dd
[tester::#RB2] Running ./your_program.sh info /tmp/torrents1651158746/itsworking.gif.torrent
[your_program] Tracker URL: http://bittorrent-test-tracker.codecrafters.io/announce
[your_program] Length: 2549700
[your_program] Info Hash: 70edcac2611a8829ebf467a6849f5d8408d9d8f4
[your_program] Piece Length: 262144
[your_program] Piece Hashes:
[your_program] 01cc17bbe60fa5a52f64bd5f5b64d99286d50aa5
[your_program] 838f703cf7f6f08d1c497ed390df78f90d5f7566
[your_program] 45bf10974b5816491e30628b78a382ca36c4e05f
[your_program] 84be4bd855b34bcedc0c6e98f66d3e7c63353d1e
[your_program] 86427ac94d6e4f21a6d0d6c8b7ffa4c393c3b131
[your_program] 7c70cd5f44d1ac5505cb855d526ceb0f5f1cd5e3
[your_program] 3796ab05af1fa874173a0a6c1298625ad47b4fe6
[your_program] 272a8ff8fc865b053d974a78681414b38077d7b1
[your_program] b07128d3a6018062bfe779db96d3a93c05fb81d4
[your_program] 7affc94f0985b985eb888a36ec92652821a21be4
[tester::#RB2] Test passed.
[tester::#OW9] Running tests for Stage #OW9 (Parse torrent file)
[tester::#OW9] Running ./your_program.sh info /tmp/torrents3075888958/congratulations.gif.torrent
[your_program] Tracker URL: http://bittorrent-test-tracker.codecrafters.io/announce
[your_program] Length: 820892
[your_program] Info Hash: 1cad4a486798d952614c394eb15e75bec587fd08
[your_program] Piece Length: 262144
[your_program] Piece Hashes:
[your_program] 3d42a20edb1cf840cd3528d3a9e921db6338a463
[your_program] 69f885b3988a52ffb03591985402b6d5285940ab
[your_program] 76869e6c9c1f101f94f39de153e468be6a638f4f
[your_program] bded68d02de011a2b687f75b5833f46cce8e3e9c
[tester::#OW9] Tracker URL is correct
[tester::#OW9] Length is correct
[tester::#OW9] Test passed.
[tester::#MN6] Running tests for Stage #MN6 (Decode bencoded dictionaries)
[tester::#MN6] Running ./your_program.sh decode de
[tester::#MN6] Expected output: {}
[your_program] Logs from your program will appear here!
[your_program] {}
[tester::#MN6] Running ./your_program.sh decode d3:foo6:banana5:helloi52ee
[tester::#MN6] Expected output: {"foo":"banana","hello":52}
[your_program] {"foo":"banana","hello":52}
[your_program] Logs from your program will appear here!
[tester::#MN6] Running ./your_program.sh decode d10:inner_dictd4:key16:value14:key2i42e8:list_keyl5:item15:item2i3eeee
[tester::#MN6] Expected output: {"inner_dict":{"key1":"value1","key2":42,"list_key":["item1","item2",3]}}
[your_program] Logs from your program will appear here!
[your_program] {"inner_dict":{"key1":"value1","key2":42,"list_key":["item1","item2",3]}}
[tester::#MN6] Test passed.
[tester::#AH1] Running tests for Stage #AH1 (Decode bencoded lists)
[tester::#AH1] Running ./your_program.sh decode le
[tester::#AH1] Expected output: []
[your_program] Logs from your program will appear here!
[your_program] []
[tester::#AH1] Running ./your_program.sh decode l5:grapei637ee
[tester::#AH1] Expected output: ["grape",637]
[your_program] Logs from your program will appear here!
[your_program] ["grape",637]
[tester::#AH1] Running ./your_program.sh decode lli637e5:grapeee
[tester::#AH1] Expected output: [[637,"grape"]]
[your_program] Logs from your program will appear here!
[your_program] [[637,"grape"]]
[tester::#AH1] Running ./your_program.sh decode lli4eei5ee
[tester::#AH1] Expected output: [[4],5]
[your_program] Logs from your program will appear here!
[your_program] [[4],5]
[tester::#AH1] Test passed.
[tester::#EB4] Running tests for Stage #EB4 (Decode bencoded integers)
[tester::#EB4] Running ./your_program.sh decode i1062066884e
[your_program] Logs from your program will appear here!
[your_program] 1062066884
[tester::#EB4] Running ./your_program.sh decode i4294967300e
[your_program] Logs from your program will appear here!
[your_program] 4294967300
[tester::#EB4] Running ./your_program.sh decode i-52e
[your_program] -52
[your_program] Logs from your program will appear here!
[tester::#EB4] Test passed.
[tester::#NS2] Running tests for Stage #NS2 (Decode bencoded strings)
[tester::#NS2] Running ./your_program.sh decode 6:banana
[your_program] "banana"
[your_program] Logs from your program will appear here!
[tester::#NS2] Running ./your_program.sh decode 55:http://bittorrent-test-tracker.codecrafters.io/announce
[your_program] Logs from your program will appear here!
[your_program] "http://bittorrent-test-tracker.codecrafters.io/announce"
[tester::#NS2] Test passed.
喜欢这篇文章的人也看了
评论
隐私政策
0/500
滚动到此处加载评论...



