Modify HTTP traffic on the fly

nry

Limp Gawd
Joined
Jul 10, 2008
Messages
409
Slightly strange request, I have a Sonos system and want to intercept and modify the HTTP API traffic. So volume control done via the Sonos app will control my amp via IP (I understand that the normal way is to just turn the amp volume quite high and manage the volume via Sonos, but this is [H] after all ;) )

I had a poke around the Sonos API and seems fairly straight forward. Also controlling my amp via IP was easy enough. So no problems there.

My problem is with actually intercepting the traffic and routing it through my application (probably NodeJS based) then pushing it out to the Sonos client. I have a pfSense router setup which I'm assuming could handle this if configured correctly, with this in mind my rough plan is:
  • Sonos iPhone app sends HTTP request
  • pfSense routes request to application hosted on a VM (only port 5005, would need to pass the original URL requested along too)
  • Application reads request
  • Application forwards on non volume based requests
  • If application detects volume request, sends out calculated volume to amp

So any pointers on how I can configure pfSense to do this, or what the correct technical name for this is so I can Google it :)
 

Nicklebon

Gawd
Joined
May 22, 2006
Messages
717
Just a swag, but that sounds like something you could do with a custom IPS signature coupled with a triggered action. I'm assuming pfSense has triggered actions and the ability for custom IPS signatures. You'd likely need a signature for increasing volume and one for decreasing.
 

Eminence_Front

Weaksauce
Joined
Aug 27, 2008
Messages
119
with iRules on F5 you can do this quite easily.

It's as simple as intercepting the inbound HTTP, parsing out the command, and reformatting it to have whatever values you need.

(assuming the API call is consistent.)

You might spend some time over on the F5 forums, and look into irules.

The syntax, behavior may give you some insight on how to perform this type of configuration yourself, using pfsense, or perhaps even a custom triggered event. (generally triggered events would use an action of send tcp_rst, but I suppose you could write a POST command, with whatever content you needed.
 

nry

Limp Gawd
Joined
Jul 10, 2008
Messages
409
Thanks I'll setup some stuff in VMs and see what I can do, here was me hoping for a nice easy solution haha
 
Top