But we cannot block or allow according to IP address.
package com.wowza.wms.example.module;
// com.wowza.wms.example.module.ModuleAccessControlHTTPStreaming
import com.wowza.wms.httpstreamer.model.IHTTPStreamerSession;
import com.wowza.wms.module.*;
import com.wowza.wms.application.*;
public class ModuleAccessControlHTTPStreaming extends ModuleBase
{
public void onHTTPSessionCreate(IHTTPStreamerSession httpSession)
{
boolean isGood = true;
String ipAddressClient = httpSession.getIpAddress();
String ipAddressServer = httpSession.getServerIp();
String uri = httpSession.getUri();
String queryStr = httpSession.getQueryStr();
String referrer = httpSession.getReferrer();
String cookieStr = httpSession.getCookieStr();
String userAgent = httpSession.getUserAgent();
IApplicationInstance appInstance = httpSession.getAppInstance();
String streamName = httpSession.getStreamName();
// Here you can use the request and session information above to determine
// if you want to reject the connection
// isGood = true/false;
getLogger().info(“ModuleAccessControlHTTPStreaming.onHTTPSessionCreate[”+appInstance.getContextStr()+“:”+streamName+“]: accept:”+isGood);
// boolean reject = true;
String domainLocks = null;
String domainUrl = null;;
try
{
domainLocks = httpSession.getAppInstance().getProperties().getPropertyStr(“domainLock”).toLowerCase().split(“,”);
//String pageUrl = httpSession.getProperties().getPropertyStr(“connectpageUrl”).toLowerCase();
// domainUrl = pageUrl.split(“/”);
getLogger().info("domainLock: " + httpSession.getAppInstance().getProperties().getPropertyStr(“domainLock”).toLowerCase());
getLogger().info("pageUrl: " + ipAddressClient);
for (int i = 0; i < domainLocks.length; i++)
{
if (domainLocks_.trim().startsWith(“*”))_
{
String lock = domainLocks*.trim().substring(1);*
if (ipAddressClient.endsWith(lock))
{
isGood = true;
}
}
else if (ipAddressClient.equalsIgnoreCase(domainLocks*.trim()))*
{
isGood = true;
}
}
}
catch(Exception ex)
{
isGood = false;
}
if (isGood)
{
getLogger().info("Client Rejected. IP: " + httpSession.getIpAddress());
httpSession.rejectSession();
}
if (!isGood)
httpSession.rejectSession();
}
}