I decided to raise my Doomsday radio.

Why did I want to do this?

  • I've always been interested in broadcasting something.
    • I want to become a media personality.
  • I want it to be independent of other platforms.

It is also because of these points that my blog appeared. But I also wanted to see the reader's feedback.

Without thinking twice, I realized that I wanted a streaming service, but my server couldn't handle video streaming. I decided to raise audio streaming, aka radio.

I had an experience in raising the radio, where I used icecast and liquidsoap'. But then I was making radio music, and this time I want streaming. I googled and found a solution in the form of darkice'. I decided to focus on the combination of icecast and darkice.

I installed icecast first: apt update && apt install icecast2 -y

I created a subdomain with my registrar and entered it in /etc/icecast2/icecast.xml. Then i start service: service icecast2 start

I've set up nginx next.
Icecast outputs its standard status page out of the box. I didn't want to show it to the audience. Instead, I configured nginx like this:

  • Root (/) — returns my HTML page /var/www/radio/index.html
  • The path /live is proxied to Icecast Now, when a person opens radio.0x44616e4368.ru /, he sees:
  • The player
  • Chat
  • Beautiful interface And the audio stream is located at radio.0x44616e4368.ru/live and is not shown as a separate page. I also added an ssl certificate.

Then I went to my laptop, installed darkice, and configured its configuration to connect to my server.

apt install darkice

nvim ~/.darkice.cfg
# [general]
# duration        = 0
# bufferSecs      = 1
# reconnect       = yes

# [input]
# device          = default
# sampleRate      = 44100
# bitsPerSample   = 16
# channel         = 1

# [icecast2-0]
# format          = mp3
# bitrateMode     = cbr
# bitrate         = 128
# server          = $(ip)
# port            = 8000
# password        = $(password)
# mountPoint      = live
# name            = DanCh Live
# description     = DanCh radio
# url             = $(url) 
# genre           = Talk

darkice -c ~/.darkice.cfg

Now I could broadcast, but I couldn't communicate with the audience. I decided to write a simple python chat using websockets.

I added escaping because there was a strange behavior when trying to XSS.

apt install python3-pip

pip3 install websockets --break-system-packages

# #!/usr/bin/env python3
# import asyncio
# import json
# import html
# import websockets
#
# connected = set()
#
# async def chat_handler(websocket):
#     connected.add(websocket)
#     try:
#         async for message in websocket:
#             data = json.loads(message)
#
#             safe_data = {
#                 "nick": html.escape(data.get("nick", "Anon")[:30]),
#                 "text": html.escape(data.get("text", "")[:500]),
#                 "time": html.escape(data.get("time", ""))
#             }
#
#             safe_message = json.dumps(safe_data)
#             for client in connected:
#                 await client.send(safe_message)
#     finally:
#         connected.remove(websocket)
#
# async def main():
#     async with websockets.serve(chat_handler, "127.0.0.1", 8080):
#         await asyncio.Future()
#
# if __name__ == "__main__":
#     asyncio.run(main())

I have written a service that monitors a python file.


You can see how it turned out: radio

I don't know what to broadcast yet ;)