1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
FLVStreamer v2.1c
(C) 2009 Andrej Stepanchuk
(C) 2009-2010 Howard Chu
(C) 2009-2010 The FLVstreamer Team
License: GPLv2
To compile type "make" with your platform name, e.g. (for osx, linux, or cygwin)
$ make posix
For mingw:
$ make mingw
Please read the Makefile to see what other make variables are used.
Connect Parameters
------------------
Some servers expect additional custom parameters to be attached to the
RTMP connect request. The "--auth" option handles a specific case, where
a boolean TRUE followed by the given string are added to the request.
Other servers may require completely different parameters, so the new
"--conn" option has been added. This option can be set multiple times
on the command line, adding one parameter each time.
The argument to the option must take the form <type> : <value> where
type can be B for boolean, S for string, N for number, and O for object.
For booleans the value must be 0 or 1. Also, for objects the value must
be 1 to start a new object, or 0 to end the current object.
Examples:
--conn B:0 --conn S:hello --conn N:3.14159
Named parameters can be specified by prefixing 'N' to the type. Then the
name should come next, and finally the value:
--conn NB:myflag:1 --conn NS:category:something --conn NN:pi:3.14159
Objects may be added sequentially:
-C O:1 -C NB:flag:1 -C NS:status:success -C O:0 -C O:1 -C NN:time:12.30 -C O:0
or nested:
-C O:1 -C NS:code:hello -C NO:extra:1 -C NS:data:stuff -C O:0 -C O:0
Credit goes to team boxee for the XBMC RTMP code originally used in RTMPDumper.
The current code is based on the XBMC code but rewritten in C by Howard Chu.
Example Servers
---------------
Three different types of servers are also present in this distribution:
rtmpsrv - a stub server
rtmpsuck - a transparent proxy
streams - an RTMP to HTTP gateway
rtmpsrv - Note that this is very incomplete code, and I haven't yet decided
whether or not to finish it. In its current form it is useful for obtaining
all the parameters that a real Flash client would send to an RTMP server, so
that they can be used with flvstreamer.
rtmpsuck - proxy server. See below...
All you need to do is redirect your Flash clients to the machine running this
server and it will dump out all the connect / play parameters that the Flash
client sent. The simplest way to cause the redirect is by editing /etc/hosts
when you know the hostname of the RTMP server, and point it to localhost while
running rtmpsrv on your machine. (This approach should work on any OS; on
Windows you would edit %SystemRoot%\system32\drivers\etc\hosts.)
On Linux you can also use iptables to redirect all outbound RTMP traffic.
You can do this as root:
iptables -t nat -A OUTPUT -p tcp --dport 1935 -j REDIRECT
In my original plan I would have the transparent proxy running as a special
user (e.g. user "proxy"), and regular Flash clients running as any other user.
In that case the proxy would make the connection to the real RTMP server. The
iptables rule would look like this:
iptables -t nat -A OUTPUT -p tcp --dport 1935 -m owner \! --uid-owner proxy \
-j REDIRECT
A rule like the above will be needed to use rtmpsuck.
Using it in this mode takes advantage of the Linux support for IP redirects;
in particular it uses a special getsockopt() call to retrieve the original
destination address of the connection. That way the proxy can create the
real outbound connection without any other help from the user. The equivalent
functionality may exist on other OSs but needs more investigation.
(Based on reading the BSD ipfw manpage, these rules ought to work on BSD:
ipfw add 40 fwd 127.0.0.1 1935 tcp from any to any 1935
ipfw add 40 fwd 127.0.0.1 1935 tcp from any to any 1935 not uid proxy
Some confirmation from any BSD users would be nice.)
(We have a solution for Windows based on a TDI driver; this is known to
work on Win2K and WinXP but is assumed to not work on Vista or Win7 as the
TDI is no longer used on those OS versions. Also, none of the known
solutions are available as freeware.)
The rtmpsuck command has only one option: "-z" to turn on debug logging.
It listens on port 1935 for RTMP sessions, but you can also redirect other
ports to it as needed (read the iptables docs). It first performs an RTMP
handshake with the client, then waits for the client to send a connect
request. It parses and prints the connect parameters, then makes an
outbound connection to the real RTMP server. It performs an RTMP handshake
with that server, forwards the connect request, and from that point on it
just relays packets back and forth between the two endpoints.
It also checks for a few packets that it treats specially: a play packet
from the client will get parsed so that the playpath can be displayed. It
also handles SWF Verification requests from the server, without forwarding
them to the client. (There would be no point, since the response is tied to
each session's handshake.)
Once the play command is processed, all subsequent audio/video data received
from the server will be written to a file, as well as being delivered back
to the client.
The point of all this, instead of just using a sniffer, is that since rtmpsuck
has performed real handshakes with both the client and the server, it can
negotiate whatever encryption keys are needed and so record the unencrypted
data.
streams - HTTP gateway: this is an HTTP server that accepts requests that
consist of flvstreamer parameters. It then connects to the specified RTMP
server and returns the retrieved data in the HTTP response. The only valid
HTTP request is "GET /" but additional options can be provided in normal
URL-encoded fashion. E.g.
GET /?r=rtmp:%2f%2fserver%2fmyapp&y=somefile HTTP/1.0
is equivalent the flvstreamer parameters "-r rtmp://server/myapp -y somefile".
Note that only the shortform (single letter) flvstreamer options are supported.
|