Flussonic Media Server documentation

Media name aliasing

Flussonic offers very convenient feature: aliasing of stream and file names. It allows to hide name of streams from end users: on each request the name that user provided will be rewritten to internal name that you have configured.

So you have stream "clock" and usually you give people link http://192.168.2.3/clock/index.m3u8 Now you can leave stream named clock in config, but give link http://192.168.2.3/crf7930803e4e334e104/index.m3u8

There are different situations when you may want to use it:

  • hiding stream or file names from users, creating temporary names
  • managing stream names that you have shared to users, revoking embeds

To enable it you need to implement alias rewriting backend and enable it in Flussonic config:

aliaser /opt/flussonic/priv/rewrite.lua;

At the moment only lua backend is accepted. You need to return false or a media name from it. Object req with field name is provided into this backend.

If aliaser is enabled then Flussonic authorization backend will receive additional parameter: user_name, it is an original requested media name.

Example of a rewriting backend Anchor Anchor x2

We will show you example of such rewriting script that will help you to understand this mechanism.

Let's imagine that we want to hide original stream name clock from user and give him temporary link.

Create file /etc/flussonic/alias.lua with:

a = {}

a["alias"] = "clock"

if a[req.name] ~= nil then
  return a[req.name]
else
  return req.name
end

and then enable it in /etc/flussonic/flussonic.conf:

# Global settings:
...
aliaser /etc/flussonic/alias.lua;

Now, we can access clock stream via two names:

http://flussonic/clock/index.m3u8
http://flussonic/alias/index.m3u8

You can add more aliases for your streams. Example:

a = {}

a["alias"] = "clock"
a["alias2"] = "clock"
a["alias3"] = "clock"
a["bbc-news"] = "bbc"
a["bbc-entertainment"] = "bbc"
a["BBC"] = "bbc"

if a[req.name] ~= nil then
  return a[req.name]
else
  return req.name
end

Example of a rewriting backend: crypto version Anchor Anchor x2

We will show you example of such rewriting script that will help you to understand this mechanism.

Let's imagine that we want to hide original stream name clock from user and give him temporary link.

As we do not want to mess with some databases, we will just encrypt with some known key original stream name and give it to user.

For example our key will be 000102030405060708090A0B0C0D0E0F (16 bytes), IV will be full of zeros so hex value of encrypted string clock with aes ctr encryption will be: a5cd5454ec

To decrypt it in our lua script we will need to write following backend:

decrypted = crypto.aes_ctr_decrypt(crypto.from_hex("000102030405060708090A0B0C0D0E0F"), crypto.from_hex(req.name))
return decrypted

Ok, this is nice, but this new stream name doesn't look like something unique, it will be the same.

Let's add some random 4 bytes salt to our stream name. Now encrypted "1234" + "clock" will be: f7930803e4e334e104

Something different. Now on our website we need to add 4 random bytes before our stream name and then encrypt. Our alias rewriting backend will look rather simple:

decrypted = crypto.aes_ctr_decrypt(crypto.from_hex("000102030405060708090A0B0C0D0E0F"), crypto.from_hex(req.name))
return string.sub(decrypted,5)