(#814) require a valid announce URL when creating torrents

This commit is contained in:
Charles Kerr
2008-03-24 15:58:06 +00:00
parent 363a583391
commit 910d77ae12
6 changed files with 85 additions and 50 deletions

View File

@@ -43,6 +43,8 @@
#include <kernel/OS.h>
#endif
#include <miniupnp/miniwget.h> /* parseURL */
#include "transmission.h"
#include "trcompat.h"
#include "utils.h"
@@ -973,3 +975,33 @@ tr_sha1_to_hex( char * out, const uint8_t * sha1 )
}
*out = '\0';
}
/***
****
***/
int
tr_httpParseUrl( const char * url_in, int len,
char ** setme_host,
int * setme_port,
char ** setme_path )
{
char * url = tr_strndup( url_in, len );
char * path;
char host[4096+1];
unsigned short port;
int success;
success = parseURL( url, host, &port, &path );
if( success ) {
if( setme_host ) *setme_host = tr_strdup( host );
if( setme_port ) *setme_port = port;
if( setme_path ) *setme_path = tr_strdup( path );
}
tr_free( url );
return !success;
}