Icecast Streaming Media Server Forum Index Icecast Streaming Media Server
Icecast is a Xiph Foundation Project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Redirect based on country IP

 
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server
View previous topic :: View next topic  
Author Message
robertut



Joined: 31 Aug 2007
Posts: 156

PostPosted: Fri Aug 31, 2007 3:59 pm    Post subject: Redirect based on country IP Reply with quote

Dear all,

There is an interesting situation we're in.

Currently we use Shoutcast DNAS and have a daily peak of 2500 listeners on our 20 server instances. Server bandwidth is okay, the ISP offers us 1GBit of national bandwidth (we're in Hungary), the peak looks nice, around 178 Mbit:




Unfortunately the international bandwidth, out of this 1G is only 10Mbit, which looks pretty ugly:



This means that although the maxuser setting in the servers would allow more users to come in, those from outside Hungary actually cannot even reach the server between 10:00 and 21:00.

Our ISP cannot give more international access, so we think to contract another service, with for example only 100Mbit national, but another extra 10Mbit international.

Now I'd like to make a setup (wouldn't mind ofcourse to move to Icecast) that would somehow identify the listeners country by IP (actually I'd be interested only to filter out internationals) and redirect them to a new server. So national listeners would use the main server in Hungary, and internationals would listen from the second one. But never viceversa.

Any ideas?
Back to top
View user's profile Send private message
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Fri Aug 31, 2007 4:19 pm    Post subject: Reply with quote

The only redirection work is currently in my branch work and the trigger for that is currently based on max listeners. In theory the auth url engine could be used to inform icecast that a new listener should be redirected to an alternative server. I don't see that being a large change. A header could be sent back (based on some test of the IP or whatever) to icecast which specifies where to redirect to.

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
robertut



Joined: 31 Aug 2007
Posts: 156

PostPosted: Mon Sep 03, 2007 6:19 am    Post subject: Reply with quote

Indeed, that could be a great feature. You'd need one or two lists, eventually saved in a separate text file each (or some entry groups in the xml), where you can specify single IP numbers, IP intervals (from-to), classes or IPs with wildcards. Because the main thing is to do some filters based on country, so one will need to get information, what IP classes belong to which country. This is why multiple entries are needed.

And some logic selection possibility, like
- all IPs in the list should be redirected to a specific server, the others offer the streams
- all IPs except the ones in the list should be redirected to a specific server, only those in the list would receive the streams

depending on the needs of the user...

Perhaps the setting should be available on a per mount basis, I mean, each mount could have a different setting. This is why keeping the IP list in a separate file would be easier, only the path to the file would need to be adjusted for each mount.

Are there any chances to include this feature?
Back to top
View user's profile Send private message
robertut



Joined: 31 Aug 2007
Posts: 156

PostPosted: Mon Sep 03, 2007 6:31 am    Post subject: Reply with quote

Oops, I read your e-mail after my post. Thanks, looking into it. Nevermind the words above.
Back to top
View user's profile Send private message
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Mon Sep 03, 2007 12:09 pm    Post subject: Reply with quote

Because of the variability of the possible ways this could be setup, it's very unlikely to be built into icecast. What I have working is a simple mechanism which allow such decisions to be made externally via auth_url. By sending backa location: header you can tell that particular listener to reconnect using the http 302 mechanism. This is currently in my current work which I'll release later today/tomorrow.

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
robertut



Joined: 31 Aug 2007
Posts: 156

PostPosted: Mon Sep 03, 2007 3:23 pm    Post subject: Reply with quote

karlH wrote:
Because of the variability of the possible ways this could be setup, it's very unlikely to be built into icecast. What I have working is a simple mechanism which allow such decisions to be made externally via auth_url. By sending backa location: header you can tell that particular listener to reconnect using the http 302 mechanism. This is currently in my current work which I'll release later today/tomorrow.

karl.
Very good, thanks. Could you please point me into the right direction on redirects? A few hints would be useful and save me a lot of time. If we manage to get something together, we'll change the 20 instances of shoutcast to one single icecast service with 20 mounts.
Back to top
View user's profile Send private message
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Tue Sep 04, 2007 1:21 am    Post subject: Reply with quote

I have uploaded kh20 now on my website. What you need to do is parse the ip and whatever else out of the POST details from listener_add, make a decision based on that data and send a location: http://... header back or not.

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
liveatc



Joined: 22 Sep 2007
Posts: 4
Location: Boston, MA

PostPosted: Sat Sep 22, 2007 10:24 pm    Post subject: Reply with quote

You should do this with DNS. Check this out:

http://www.micro-gravity.com/wiki/index.php?page=GeoDns

I implemented this with Icecast as a proof of concept and the lookups do a pretty darn good job of coming back with the right country.

Dave
Founder, LiveATC.net
http://www.liveatc.net
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
subRebel style by ktauber