npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

icecast-auth

v0.0.1

Published

Icecast command authenticator interface for nodejs.

Downloads

1

Readme

Quickstart

Build Status

Package uses listener authentication mechanism to provide handy interface for collecting detailed connection data and performing following actions with listeners:

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/nodejs
var fs = require('fs');
var AuthHandler = require('icecast-auth');

var handler = new AuthHandler();
handler.on('connection', function(data) {

  // Log data somewhere
  fs.appendFileSync('/tmp/icecast-auth.log', JSON.stringify(data, null, ' '));

  // Accept connection
  handler.accept();
});

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 mount
handler.on('connection', function(data) {
  handler.accept();
});

// Accept user to another mount
handler.on('connection', function(data) {
  handler.accept('/other-mount');
});

requireCredentials

Requires listener to perform basic HTTP authentication (401 HTTP request).

// Only users with "user" login and "secret" password will be allowed to stream
handler.on('connection', function(data) {
  if (data.user !== 'user' && password !== 'secret') {
    handler.requireCredentials();
  } else {
    handler.accept();
  }
});

redirect

Performs HTTP redirect to specified url.

Parameter | Type | Required | Description ----------|--------|----------|------------ url | String | Yes | Url, where listener should be redirected

handler.on('connection', function(data) {
  handler.redirect('http://example.com/');
});

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.on('connection', function(data) {
  handler.decline('You shall not pass!');
});

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:

<authentication type="command">
  <option name="listener_add" value="/path/to/your/script.js"/> 
  <option name="handlers" value="1"/> 
</authentication>

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:

<mount>
  <mount-name>/*.xml</mount-name>
</mount>      
<mount>
  <mount-name>/*.xsl</mount-name>
</mount>        
<mount>
  <mount-name>/*.html</mount-name>
</mount>    
<mount>
  <mount-name>/*.css</mount-name>
</mount>    
<mount>
  <mount-name>/*.jpg</mount-name>
</mount>    
<mount>
  <mount-name>/*.png</mount-name>
</mount>    
<mount>
  <mount-name>/*.ico</mount-name>
</mount>    
<mount>
  <mount-name>/*.m3u</mount-name>
</mount>
<mount>
  <mount-name>/*</mount-name>
  <authentication type="command">
    <option name="listener_add" value="/path/to/your/script.js"/> 
    <option name="handlers" value="1"/> 
  </authentication>
</mount>