Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
CreateTorrent [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
karafeka
Tux's lil' helper
Tux's lil' helper


Joined: 02 Aug 2004
Posts: 89

PostPosted: Fri Nov 17, 2006 6:31 pm    Post subject: CreateTorrent [SOLVED] Reply with quote

Does somebody use CreateTorrent http://www.createtorrent.com/ ? (it's not in portage)

How is possibly to NOT define port?
It doesn't matter what command you give, you automaticly get 6681 default torrent (except if you define one).


Last edited by karafeka on Wed Nov 22, 2006 1:45 pm; edited 1 time in total
Back to top
View user's profile Send private message
MacTuitui
n00b
n00b


Joined: 10 Oct 2003
Posts: 53

PostPosted: Mon Nov 20, 2006 5:58 am    Post subject: Reply with quote

As anything using the internet protocol, you need an adress and a port to connect to. http is 80, ftp 21, ssh 22. If you "do not specify" a port, it means you suppose it is going to be on the default port. But you are using one.

I do not understand your question.
Back to top
View user's profile Send private message
karafeka
Tux's lil' helper
Tux's lil' helper


Joined: 02 Aug 2004
Posts: 89

PostPosted: Mon Nov 20, 2006 11:55 am    Post subject: Reply with quote

Announce url of some trackers is
http://nameofthetracker.org/announce.php

Creating torrent with that announce and defining port 80 on some trackers works fine. But some others checks torrent for correct announce and if it is http://nameofthetracker.org:80/announce.php they give you an error - not correct announce of something similiar.

I solve this problem using maketorrent2 with wine for now.
Maybe somebody knows if it there any other native linux program for creating torrent? Or maybe somebody with some programming experience (I think that createtorrent is written in c++) could modify program, so for example:

createtorrent -a http://nameofthetracker.org/announce.php file output

will write only this announce in the torrent, and not add default stuff, like 6881 and /announce.
I wrote email to author some weeks back, but I didn't recieve an answer.
Back to top
View user's profile Send private message
MacTuitui
n00b
n00b


Joined: 10 Oct 2003
Posts: 53

PostPosted: Tue Nov 21, 2006 3:59 am    Post subject: Reply with quote

Here is a patch for you:

Code:

--- main.c   2004-05-27 19:25:06.000000000 +0900
+++ main2.c   2006-11-21 12:39:00.855984201 +0900
@@ -42,9 +42,11 @@
          { "path", 1, 0, 't' },
          { "piecelength", 1, 0, 'l' },
          { "comment", 1, 0, 'c' },
+         { "noport", 0, 0, 'n'},
+         { "nopath", 0, 0, 'm'},
          { 0, 0, 0, 0 }
       };
-      char c = getopt_long( argc, argv, "a:hvp:t:l:c:", options, &optidx );
+      char c = getopt_long( argc, argv, "a:nmhvp:t:l:c:", options, &optidx );
       if( c == -1 ) {
          break;
       }
@@ -72,6 +74,12 @@
          case 'l':
             piecelen = atoi( optarg );
             break;
+         case 'n':
+            port = "";
+            break;
+         case 'm':
+            path = "";
+            break;      
       }
    }
    for( i = optind; i < argc; ++i ) {
@@ -125,8 +133,37 @@
          ret = 1;
       }
    } else {
-      fprintf( stderr, "invalid port number\n" );
-      ret = 1;
+      FILE* f = fopen( output, "w" );
+      if( f ) {
+         fprintf( f, "d8:announce%d:%s%s", strlen( announce ) + strlen( path ), announce, path );
+         fprintf( f, "4:infod12:piece lengthi%de", piecelen );
+         if( comment ) {
+            fprintf( f, "7:comment%d:%s", strlen( comment ), comment );
+         }
+         fprintf( f, "13:creation datei%de", (unsigned) time( NULL ) );
+         struct stat s;
+         if( ! stat( src, &s ) ) {
+            if( S_ISDIR( s.st_mode ) ) {
+               ret = create_from_directory( src, f, piecelen );
+            } else if( S_ISREG( s.st_mode ) ) {
+               ret = create_from_file( src, f, s.st_size, piecelen );
+            } else {
+               fprintf( stderr, "not a file or directory: %s\n", src );
+               ret = 1;
+            }
+         } else {
+            fprintf( stderr, "could not access %s: %m\n", src );
+            ret = 1;
+         }
+         fwrite( "ee", 1, 2, f );
+         fclose( f );
+         if( ret ) {
+            unlink( output );
+         }
+      } else {
+         fprintf( stderr, "could not open destination file %s\n", output );
+         ret = 1;
+      }
    }
    return ret;
 }
@@ -256,6 +293,8 @@
       "--comment     -c  <comment>     : adds an optional comment to the torrent file\n"
       "--version     -v                : version of createtorrent\n"
       "--help        -h                : this help screen\n"
+      "--noport      -n                : do not specify the port\n"
+      "--nopath      -m                : do not specify the path \n"
    );
 }


Let us call it patch_createtorrent

then untar the archive, copy the patch in the source directory, and do the following :

Code:

[tuitui@shidax] ~/createtorrent-1.0.0 $ patch main.c patch_createtorrent
patching file main.c
[tuitui@shidax] ~/createtorrent-1.0.0 $ ./configure
... [bunch of stuff] ..
[tuitui@shidax] ~/createtorrent-1.0.0 $ make
... [bunch of stuff] ..
[tuitui@shidax] ~/createtorrent-1.0.0 $ ./createtorrent -h
Usage: createtorrent [OPTIONS] -a announce inputfile/directory output

options:
--announce    -a  <announceurl> : announce url
--port        -p  <port>        : sets the port, default: 6881
--path        -t  <path>        : sets the path on the server, default: /announce
--piecelength -l  <piecelen>    : sets the piece length in bytes, default: 262144
--comment     -c  <comment>     : adds an optional comment to the torrent file
--version     -v                : version of createtorrent
--help        -h                : this help screen
--noport      -n                : do not specify the port
--nopath      -m                : do not specify the path


Then you can do

Code:

[tuitui@shidax] ~/createtorrent-1.0.0 $ ./createtorrent -a http://sometracker.org main.c test.torrent
computing sha1... done
[tuitui@shidax] ~/createtorrent-1.0.0 $ cat test.torrent
d8:announce36:http://sometracker.org:6881/announce4:infod12:piece lengthi262144e13:creation datei1164081100e4:name6:main.c6:lengthi7760e6:pieces20:`Ò!#VÚaV?<¾¥ɾee
[tuitui@shidax] ~/createtorrent-1.0.0 $


See the announce ?

Now you can do:

Code:

[tuitui@shidax] ~/createtorrent-1.0.0 $ ./createtorrent -n -a http://sometracker.org main.c test.torrent
computing sha1... done
[tuitui@shidax] ~/createtorrent-1.0.0 $ cat test.torrent
d8:announce31:http://sometracker.org/announce4:infod12:piece lengthi262144e13:creation datei1164081200e4:name6:main.c6:lengthi7760e6:pieces20:`Ò!#VÚaV?<¾¥ɾee
[tuitui@shidax] ~/createtorrent-1.0.0 $


No more port number here.

And you can add:

Code:

[tuitui@shidax] ~/createtorrent-1.0.0 $ ./createtorrent -nm -a http://sometracker.org main.c test.torrent
computing sha1... done
[tuitui@shidax] ~/createtorrent-1.0.0 $ cat test.torrent
d8:announce22:http://sometracker.org4:infod12:piece lengthi262144e13:creation datei1164081283e4:name6:main.c6:lengthi7760e6:pieces20:`Ò!#VÚaV?<¾¥ɾee
[tuitui@shidax] ~/createtorrent-1.0.0 $


No more announce part.
So basically you can do

Code:

[tuitui@shidax] ~/createtorrent-1.0.0 $ ./createtorrent -nm -a http://sometracker.org/announce.php main.c test.torrent
computing sha1... done
[tuitui@shidax] ~/createtorrent-1.0.0 $ cat test.torrent
d8:announce35:http://sometracker.org/announce.php4:infod12:piece lengthi262144e13:creation datei1164081372e4:name6:main.c6:lengthi7760e6:pieces20:`Ò!#VÚaV?<¾¥ɾee
[tuitui@shidax] ~/createtorrent-1.0.0 $


To get the torrent to specify the announce as http://sometracker.org/announce.php

I am sorry, but I don't have time to test, but the results look fine (yeah, I know, it's lame). So If you run into problems, let me know, maybe I can do something for you.
Back to top
View user's profile Send private message
MacTuitui
n00b
n00b


Joined: 10 Oct 2003
Posts: 53

PostPosted: Tue Nov 21, 2006 4:09 am    Post subject: Reply with quote

Or you could (from the bittorrent mainline page) using the classic bittorrent (in portage).

1. Launch the BitTorrent client.
2. Go to File--Make New Torrent.
3. Select the file or directory of files you wish to publish in the window that comes up. Name the torrent and add any comments you like to describe it.
4. Select a block size to break the file into. You can also just leave it on Auto.
5. Enter the name of the tracker you wish to use to manage the torrent, or specify DHT for trackerless torrents.
6. Finally, click Publish. The torrent file will be created, and the file will begin seeding.
Back to top
View user's profile Send private message
karafeka
Tux's lil' helper
Tux's lil' helper


Joined: 02 Aug 2004
Posts: 89

PostPosted: Tue Nov 21, 2006 9:07 pm    Post subject: Reply with quote

Thank you very much. Patch is working very good. Altough I have to manually change main.c, because I got erorrs on all 4 chunks (maybe we didn't use the same version).

I tried that standard btmaketorrentgui.py some time back and also today, but I get error that it doesn't support unicode files (I'm using utf8).

Once more, thanks.
Back to top
View user's profile Send private message
MacTuitui
n00b
n00b


Joined: 10 Oct 2003
Posts: 53

PostPosted: Wed Nov 22, 2006 4:14 am    Post subject: Reply with quote

You are welcome.

Please put [solved] in the thread's title :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum