I’ve thought of a great hack to overcome the limitations that most icecast clients don’t let you specify the ‘source’ field. At first I thought of maybe finding a user by password rather than username. Then I thought, why not just use the password field for the username and password? The username and password can be separated by something like a semicolon. Here’s how I implemented this in liquidsoap:
defget_user(user,password)=ifuser=="source"thenx=string.split(separator=';',password)list.nth(x,0)elseuserendenddefget_password(user,password)=ifuser=="source"thenx=string.split(separator=';',password)list.nth(x,1)elsepasswordendend#auth functiondefdj_auth(user,password)=u=get_user(user,password)p=get_password(user,password)#get the output of the php scriptret=get_process_lines("bundle exec ./dj_auth.rb #{u}#{p}")#ret has now the value of the live client (dj1,dj2, or djx), or "ERROR"/"unknown"ret=list.hd(ret)#return true to let the client transmit data, or false to tell harbor to declineifret=="true"thentitle_prefix:="LIVE NOW ♫✩ -- #{u} ✩♪"trueelsefalseendend# use the auth function with input.harborlive_dj=input.harbor("datafruits",port=9000,auth=dj_auth,on_disconnect=on_disconnect)
You simply check if the username sent was ‘source’ and then split the password string at ‘;’.
Modern Online Radio with Liquidsoap Book - Free Sample
Need more help with liquidsoap?
Can’t get your script to work?
I wrote a book to help you learn Liquidsoap. The book covers all aspects of liquidsoap, from getting started, to making dynamic streams, audio processing, video, customizing metadata, authentication, and more. The book is available for purchase now here!
You can get a free sample chapter of my book! Just enter your email address to subscribe to my mailing list and I'll send you a free PDF sample of the book in return.