added HTTP Basic authentication for icecast2 logins
This commit is contained in:
parent
268e5d4566
commit
31747d0353
|
@ -1,5 +1,6 @@
|
|||
DarkIce next version
|
||||
|
||||
o added HTTP Basic authentication for icecast2 logins
|
||||
o added mp3 streaming for icecast2
|
||||
o added possibility to stream in mono even when recording in stereo,
|
||||
thus enabling mono and stereo streams with the same darkice instance.
|
||||
|
|
|
@ -6,6 +6,5 @@ o libtoolize ?
|
|||
o revisit real-time scheduling and one-thread-per-connection
|
||||
o look into performance
|
||||
o create proper error-reporting module
|
||||
o add HTTP Basic authentication for icecast2 logins
|
||||
o set comment fields for Ogg Vorbis streams as in
|
||||
http://www.xiph.org/ogg/vorbis/doc/v-comment.html
|
||||
|
|
|
@ -133,7 +133,7 @@ IceCast2 :: sendLogin ( void ) throw ( Exception )
|
|||
sink->write( str, strlen( str));
|
||||
str = getMountPoint();
|
||||
sink->write( str, strlen( str));
|
||||
str = " ICE/1.0";
|
||||
str = " HTTP/1.0";
|
||||
sink->write( str, strlen( str));
|
||||
|
||||
/* send the content type, Ogg Vorbis */
|
||||
|
@ -155,12 +155,23 @@ IceCast2 :: sendLogin ( void ) throw ( Exception )
|
|||
}
|
||||
sink->write( str, strlen( str));
|
||||
|
||||
/* send the ice- headers */
|
||||
str = "\nice-password: ";
|
||||
sink->write( str, strlen(str));
|
||||
str = getPassword();
|
||||
/* send the authentication info */
|
||||
str = "\nAuthorization: Basic ";
|
||||
sink->write( str, strlen(str));
|
||||
{
|
||||
/* send source:<password> encoded as base64 */
|
||||
char * source = "source:";
|
||||
char * pwd = getPassword();
|
||||
char * tmp = new char[Util::strLen(source) + Util::strLen(str) + 1];
|
||||
Util::strCpy( tmp, source);
|
||||
Util::strCat( tmp, pwd);
|
||||
char * base64 = Util::base64Encode( tmp);
|
||||
delete[] tmp;
|
||||
sink->write( base64, strlen(base64));
|
||||
delete[] base64;
|
||||
}
|
||||
|
||||
/* send the ice- headers */
|
||||
str = "\nice-bitrate: ";
|
||||
sink->write( str, strlen( str));
|
||||
if ( log10(getBitRate()) >= (STRBUF_SIZE-2) ) {
|
||||
|
@ -217,6 +228,9 @@ IceCast2 :: sendLogin ( void ) throw ( Exception )
|
|||
$Source$
|
||||
|
||||
$Log$
|
||||
Revision 1.6 2002/08/20 18:39:13 darkeye
|
||||
added HTTP Basic authentication for icecast2 logins
|
||||
|
||||
Revision 1.5 2002/05/28 12:35:41 darkeye
|
||||
code cleanup: compiles under gcc-c++ 3.1, using -pedantic option
|
||||
|
||||
|
|
|
@ -77,6 +77,15 @@ static const char fileid[] = "$Id$";
|
|||
|
||||
/* ============================================================= module code */
|
||||
|
||||
char
|
||||
Util :: base64Table[] = {
|
||||
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
|
||||
'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
|
||||
'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
|
||||
'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/'
|
||||
};
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Calculate the length of a zero-terminated C string,
|
||||
* w/o the zero-termination
|
||||
|
@ -148,6 +157,50 @@ Util :: strDup( const char * str ) throw ( Exception )
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Convert a string into base64 encoding.
|
||||
*----------------------------------------------------------------------------*/
|
||||
char *
|
||||
Util :: base64Encode( const char * str ) throw ( Exception )
|
||||
{
|
||||
if ( !str ) {
|
||||
throw Exception( __FILE__, __LINE__, "no str");
|
||||
}
|
||||
|
||||
const char * data = str;
|
||||
size_t len = strlen( data);
|
||||
char * out = new char[len * 4 / 3 + 4];
|
||||
char * result = out;
|
||||
unsigned chunk;
|
||||
|
||||
while ( len > 0 ) {
|
||||
chunk = (len > 3) ? 3 : len;
|
||||
*out++ = base64Table[(*data & 0xfc) >> 2];
|
||||
*out++ = base64Table[((*data & 0x03) << 4) | ((*(data+1) & 0xf0) >> 4)];
|
||||
switch ( chunk ) {
|
||||
case 3:
|
||||
*out++ = base64Table[((*(data+1) & 0x0f) << 2) |
|
||||
((*(data+2) & 0xc0) >> 6)];
|
||||
*out++ = base64Table[(*(data+2)) & 0x3f];
|
||||
break;
|
||||
case 2:
|
||||
*out++ = base64Table[((*(data+1) & 0x0f) << 2)];
|
||||
*out++ = '=';
|
||||
break;
|
||||
case 1:
|
||||
*out++ = '=';
|
||||
*out++ = '=';
|
||||
break;
|
||||
}
|
||||
data += chunk;
|
||||
len -= chunk;
|
||||
}
|
||||
*out = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Check wether two strings are equal
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -396,6 +449,9 @@ Util :: conv16 ( unsigned char * pcmBuffer,
|
|||
$Source$
|
||||
|
||||
$Log$
|
||||
Revision 1.9 2002/08/20 18:39:14 darkeye
|
||||
added HTTP Basic authentication for icecast2 logins
|
||||
|
||||
Revision 1.8 2002/07/21 08:47:06 darkeye
|
||||
some exception cleanup (throw clauses in function declarations)
|
||||
|
||||
|
|
|
@ -67,6 +67,10 @@ class Util
|
|||
{
|
||||
private:
|
||||
|
||||
/**
|
||||
* Helper table for base64 encoding.
|
||||
*/
|
||||
static char base64Table[];
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -198,6 +202,18 @@ class Util
|
|||
static double
|
||||
strToD ( const char * str ) throw ( Exception );
|
||||
|
||||
/**
|
||||
* Convert a string into base64 encoding.
|
||||
* base64 is described in RFC 2045, section 6.8
|
||||
* The returned string must be freed with delete[].
|
||||
*
|
||||
* @param str the string to convert.
|
||||
* @return the supplied string in base64 encoding.
|
||||
* @exception Exception
|
||||
*/
|
||||
static char *
|
||||
base64Encode ( const char * str ) throw ( Exception );
|
||||
|
||||
/**
|
||||
* Convert an unsigned char buffer holding 8 or 16 bit PCM values
|
||||
* with channels interleaved to a short int buffer, still
|
||||
|
@ -291,6 +307,9 @@ class Util
|
|||
$Source$
|
||||
|
||||
$Log$
|
||||
Revision 1.7 2002/08/20 18:39:14 darkeye
|
||||
added HTTP Basic authentication for icecast2 logins
|
||||
|
||||
Revision 1.6 2002/07/21 08:47:06 darkeye
|
||||
some exception cleanup (throw clauses in function declarations)
|
||||
|
||||
|
|
Loading…
Reference in New Issue