Overhaul cmake configuration, add console api, fix http code that caused issues with cgi-bin

This commit is contained in:
2026-05-27 03:02:16 -05:00
parent 266ef5f830
commit 8413c67ec6
177 changed files with 20088 additions and 17948 deletions

View File

@@ -6,61 +6,67 @@ using namespace Tesses::Framework::Filesystem;
using namespace Tesses::Framework::Serialization::Bencode;
using namespace Tesses::Framework::TextStreams;
using namespace Tesses::Framework::BitTorrent;
void usage(Args& args)
{
std::cout << "USAGE: " << args.filename << " [options] torrent_contents torrent_file.torrent" << std::endl << std::endl;
void usage(Args &args) {
std::cout << "USAGE: " << args.filename
<< " [options] torrent_contents torrent_file.torrent" << std::endl
<< std::endl;
std::cout << "OPTIONS:" << std::endl;
std::cout << "tracker: torrent tracker url (require at least one)" << std::endl;
std::cout << "tracker: torrent tracker url (require at least one)"
<< std::endl;
std::cout << "webseed: url for web seeding" << std::endl;
std::cout << "comment: set the comment" << std::endl;
std::cout << "created_by: set the created by field, defaults to TessesFrameworkTorrent" << std::endl;
std::cout << "piece_length: set the piece length, defaults to " + std::to_string(DEFAULT_PIECE_LENGTH) << std::endl << std::endl;
std::cout << "created_by: set the created by field, defaults to "
"TessesFrameworkTorrent"
<< std::endl;
std::cout << "piece_length: set the piece length, defaults to " +
std::to_string(DEFAULT_PIECE_LENGTH)
<< std::endl
<< std::endl;
std::cout << "FLAGS:" << std::endl;
std::cout << "help: bring this help message up" << std::endl;
std::cout << "private: enable private tracker flag" << std::endl;
exit(1);
}
int main(int argc, char** argv)
{
int main(int argc, char **argv) {
TF_Init();
std::vector<BeString> webseeds;
std::vector<BeString> trackers;
bool isPrivate=false;
bool isPrivate = false;
int64_t pieceLength = DEFAULT_PIECE_LENGTH;
std::string comment="";
std::string comment = "";
std::string created_by = "TessesFrameworkTorrent";
Args args(argc, argv);
if(args.positional.size() < 2)
if (args.positional.size() < 2)
usage(args);
for(auto& opt : args.options)
{
if(opt.first == "tracker")
for (auto &opt : args.options) {
if (opt.first == "tracker")
trackers.push_back(opt.second);
else if(opt.first == "webseed")
else if (opt.first == "webseed")
webseeds.push_back(opt.second);
else if(opt.first == "comment")
else if (opt.first == "comment")
comment = opt.second;
else if(opt.first == "created_by")
else if (opt.first == "created_by")
created_by = opt.second;
else if(opt.first == "piece_length")
else if (opt.first == "piece_length")
pieceLength = std::stoll(opt.second);
}
for(auto& flag : args.flags)
{
if(flag == "help")
for (auto &flag : args.flags) {
if (flag == "help")
usage(args);
if(flag == "private")
if (flag == "private")
isPrivate = true;
}
if(trackers.empty())
if (trackers.empty())
usage(args);
{
auto torrent_file_stream = LocalFS->OpenFile(args.positional[1],"wb");
TorrentFile::CreateTorrent(torrent_file_stream,trackers,webseeds,LocalFS, args.positional[0], isPrivate, pieceLength, comment, created_by);
auto torrent_file_stream = LocalFS->OpenFile(args.positional[1], "wb");
TorrentFile::CreateTorrent(torrent_file_stream, trackers, webseeds,
LocalFS, args.positional[0], isPrivate,
pieceLength, comment, created_by);
}
return 0;
}