Code:
package com.wowza.wms.plugin.collection.module;
import com.wowza.wms.amf.*;
import com.wowza.wms.client.*;
import com.wowza.wms.module.*;
import com.wowza.wms.request.*;
public class ModuleOverridePublishRestrictIP extends ModuleBase {
public void publish(IClient client, RequestFunction function,
AMFDataList params) {
getLogger().info("Overriding Publish");
boolean reject = true;
String[] ipList = null;
try
{
ipList = client.getAppInstance().getProperties().getPropertyStr("ipList").toLowerCase().split(",");
String clientIP = client.getIp();
for (int i = 0; i < ipList.length; i++)
{
if (clientIP.equalsIgnoreCase(ipList[i].trim()))
{
reject = false;
}
}
}
catch(Exception ex)
{
reject = true;
}
if (reject)
{
sendClientOnStatusError(client, "NetStream.Publish.Denied", "The publisher's IP was rejected");
getLogger().info("Client Rejected. IP: " + client.getIp());
}
else
{
invokePrevious(client, function, params);
}
}
public void releaseStream(IClient client, RequestFunction function, AMFDataList params)
{
getLogger().info("Overriding streamRelease");
boolean reject = true;
String[] ipList = null;
try
{
ipList = client.getAppInstance().getProperties().getPropertyStr("ipList").toLowerCase().split(",");
String clientIP = client.getIp();
for (int i = 0; i < ipList.length; i++)
{
if (clientIP.equalsIgnoreCase(ipList[i].trim()))
{
reject = false;
}
}
}
catch(Exception ex)
{
reject = true;
}
if (reject)
{
sendClientOnStatusError(client, "NetStream.Publish.Denied", "The publisher's IP was rejected");
getLogger().info("Client Rejected. IP: " + client.getIp());
}
else
{
invokePrevious(client, function, params);
}
}
}
Add the following module to the Modules list of your Application.xml.
Code:
<Module> <Name>OverridePublishLimitIP</Name> <Description>Override publish</Description> <Class>com.wowza.wms.plugin.collection.module.ModuleOverridePublishRestrictIP</Class> </Module>
Code:
<Property> <Name>ipList</Name> <Value>127.0.0.1</Value> </Property>
- Click here, if you are having problems or would like to discuss this article.
- Leave a comment below, if there is some aspect of this article you would like to see changed or improved.


Article List
Categories
Wowza Media