Quickstart
Package uses listener authentication mechanism to provide handy interface for collecting detailed connection data and performing following actions with listeners:
- Accept connection
- Accept & move listener to another mounpoint
- Decline connection
- Require credentials
- Redirect to given url
To start run npm install icecast-auth
command, configure icecast to enable listener authentication and create executable file with following content. It will log listener's information & accept connections:
#!/usr/bin/nodejsvar fs = ;var AuthHandler = ; var handler = ;handler;
Events
connection
Is emitted when data parsing is finished (received empty line from icecast). Provides following parameters:
Parameter | Type | Description |
---|---|---|
mountpoint |
String | Requested mount name |
user |
String | Basic HTTP auth provided username |
pass |
String | Basic HTTP auth povided password |
ip |
String | Listener's ip address |
agent |
String | Listener's user agent |
referer |
String | Url, where listener came from |
Methods
accept
Accepts listener connection. Allows to specify mount, where user should be moved instead of requested one (icecast internal redirect will be used, HTTP redirect is not performed in this case).
Parameter | Type | Required | Description |
---|---|---|---|
mount |
String | No | Mount, where user should be moved |
// Accept user to requested mounthandler; // Accept user to another mounthandler;
requireCredentials
Requires listener to perform basic HTTP authentication (401 HTTP request).
// Only users with "user" login and "secret" password will be allowed to streamhandler;
redirect
Performs HTTP redirect to specified url.
Parameter | Type | Required | Description |
---|---|---|---|
url |
String | Yes | Url, where listener should be redirected |
handler;
decline
Declines listener with 403 HTTP code. Custom message can be specified.
Parameter | Type | Required | Description |
---|---|---|---|
message |
String | No | Message, that will be sent to user, defaults to Forbidden |
handler;
Icecast configuration
To enable icecast listener command-script authentication it is necessary to add following code in mount
section for required mounts in your icecast configuration file:
It is also possible to add authentication handler using wildcards, but there is a trick: by default icecast executes authentication handler for all requests. To use authentication handler only for mountpoints use following snippet:
/*.xml /*.xsl /*.html /*.css /*.jpg /*.png /*.ico /*.m3u /*