Skip to content
This repository has been archived by the owner on Aug 23, 2021. It is now read-only.

Commit

Permalink
HTTP Proxy Support
Browse files Browse the repository at this point in the history
http://stream-recorder.com/forum/compile-rtmpdump-windows-http-proxy-support-applying-t11027.html
http://lists.mplayerhq.hu/pipermail/rtmpdump/2010-August/001133.html

Here is a modified version of my patch which uses the http_proxy
environment variable instead of command line arguments to specify the
HTTP proxy.  This patch also includes extra checking for the HTTP
response code in HTTP_read().  This checking is required to prevent an
infinite loop when it has a value not equal to 200.
  • Loading branch information
Daniel Burr authored and Steven Penny committed Feb 15, 2012
1 parent 4e06e21 commit a44921b
Show file tree
Hide file tree
Showing 12 changed files with 931 additions and 154 deletions.
9 changes: 6 additions & 3 deletions librtmp/amf.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,9 @@ AMFProp_Decode(AMFObjectProperty *prop, const char *pBuffer, int nSize,
return -1;
}

if (*pBuffer == AMF_NULL)
bDecodeName = 0;

if (bDecodeName && nSize < 4)
{ /* at least name (length + at least 1 byte) and 1 byte of data */
RTMP_Log(RTMP_LOGDEBUG,
Expand Down Expand Up @@ -801,8 +804,8 @@ AMFProp_Dump(AMFObjectProperty *prop)
}
else
{
name.av_val = "no-name.";
name.av_len = sizeof("no-name.") - 1;
name.av_val = "no-name";
name.av_len = sizeof("no-name") - 1;
}
if (name.av_len > 18)
name.av_len = 18;
Expand Down Expand Up @@ -1121,7 +1124,7 @@ AMF_GetProp(AMFObject *obj, const AVal *name, int nIndex)
{
if (nIndex >= 0)
{
if (nIndex <= obj->o_num)
if (nIndex < obj->o_num)
return &obj->o_props[nIndex];
}
else
Expand Down
2 changes: 1 addition & 1 deletion librtmp/dh.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static int MDH_generate_key(MDH *dh)
MP_set(&dh->ctx.P, dh->p);
MP_set(&dh->ctx.G, dh->g);
dh->ctx.len = 128;
dhm_make_public(&dh->ctx, 1024, out, 1, havege_rand, &RTMP_TLS_ctx->hs);
dhm_make_public(&dh->ctx, 1024, out, 1, havege_random, &RTMP_TLS_ctx->hs);
MP_new(dh->pub_key);
MP_new(dh->priv_key);
MP_set(dh->pub_key, &dh->ctx.GX);
Expand Down
14 changes: 12 additions & 2 deletions librtmp/handshake.h
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,18 @@ HandShake(RTMP * r, int FP9HandShake)
__FUNCTION__);
RTMP_LogHex(RTMP_LOGDEBUG, reply, RTMP_SIG_SIZE);
#endif
if (!WriteN(r, (char *)reply, RTMP_SIG_SIZE))
return FALSE;
if (r->Link.CombineConnectPacket)
{
char *HandshakeResponse = malloc(RTMP_SIG_SIZE);
memcpy(HandshakeResponse, (char *) reply, RTMP_SIG_SIZE);
r->Link.HandshakeResponse.av_val = HandshakeResponse;
r->Link.HandshakeResponse.av_len = RTMP_SIG_SIZE;
}
else
{
if (!WriteN(r, (char *) reply, RTMP_SIG_SIZE))
return FALSE;
}

/* 2nd part of handshake */
if (ReadN(r, (char *)serversig, RTMP_SIG_SIZE) != RTMP_SIG_SIZE)
Expand Down
4 changes: 2 additions & 2 deletions librtmp/hashswf.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ extern TLS_CTX RTMP_TLS_ctx;

#endif /* CRYPTO */

#define AGENT "Mozilla/5.0"
#define AGENT "Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20100101 Firefox/8.0"

HTTPResult
HTTP_get(struct HTTP_ctx *http, const char *url, HTTP_read_callback *cb)
Expand Down Expand Up @@ -528,7 +528,7 @@ RTMP_HashSWF(const char *url, unsigned int *size, unsigned char *hash,

if (strncmp(buf, "url: ", 5))
continue;
if (strncmp(buf + 5, url, hlen))
if (strncmp(buf + 5, url, strlen(buf + 5) - 1))
continue;
r1 = strrchr(buf, '/');
i = strlen(r1);
Expand Down
4 changes: 2 additions & 2 deletions librtmp/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ static void rtmp_log_default(int level, const char *format, va_list vl)
vsnprintf(str, MAX_PRINT_LEN-1, format, vl);

/* Filter out 'no-name' */
if ( RTMP_debuglevel<RTMP_LOGALL && strstr(str, "no-name" ) != NULL )
return;
if (RTMP_debuglevel < RTMP_LOGDEBUG && strstr(str, "no-name") != NULL)
return;

if ( !fmsg ) fmsg = stderr;

Expand Down
Loading

0 comments on commit a44921b

Please sign in to comment.