Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Biased Language Updates #4

Merged
merged 7 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# BlacklistStreams
The **BlacklistStreams** server listener and HTTP Provider for [Wowza Streaming Engine™ media server software](https://www.wowza.com/products/streaming-engine) enables you to persistently blacklist streams published to your Wowza media server.
# BlocklistStreams
The **BlocklistStreams** server listener and HTTP Provider for [Wowza Streaming Engine™ media server software](https://www.wowza.com/products/streaming-engine) enables you to persistently blocklist streams published to your Wowza media server.

This repo includes a [compiled version](/lib/wse-plugin-blackliststreams.jar).

## Prerequisites
Wowza Streaming Engine 4.0.0 or later is required.

## Usage
**BlacklistStreams** provides the following functionality:
**BlocklistStreams** provides the following functionality:

* Blacklist stream names using an HTTP Provider (allows selection of streams to blacklist).
* Contents of blacklist persist through each Wowza Streaming Engine media server reboot.
* Allows previously blacklisted stream names to be whitelisted again.
* Supports blacklisting of both RTMP and RTSP sources.
* Blocklist stream names using an HTTP Provider (allows selection of streams to blocklist).
* Contents of blocklist persist through each Wowza Streaming Engine media server reboot.
* Allows previously blocklisted stream names to be whitelisted again.
* Supports blocklisting of both RTMP and RTSP sources.

To blacklist a stream:
To blocklist a stream:

1. Start your Wowza Streaming Engine media server, and then open the following URL to the Stream Blacklists page in a web browser: <pre>http://[wowza-ip-address]:8086/blacklist</pre>
1. Start your Wowza Streaming Engine media server, and then open the following URL to the Stream Blocklists page in a web browser: <pre>http://[wowza-ip-address]:8086/blocklist</pre>

2. When prompted, enter the credentials that you use to sign in to Wowza Streaming Engine Manager.

3. Publish your first stream, and then in the **Stream Blacklists** page, click **Check for new streams**. Your new stream will be displayed in the **Published Streams** list.
3. Publish your first stream, and then in the **Stream Blocklists** page, click **Check for new streams**. Your new stream will be displayed in the **Published Streams** list.

4. Click the **Blacklist** link next to the published stream to add that stream to the blacklist. This will also stop the stream. Any subsequent attempts to publish to that [app-name]/[app-instance]/[stream-name] sequence are rejected until you remove the stream from the blacklist.
4. Click the **Blocklist** link next to the published stream to add that stream to the blocklist. This will also stop the stream. Any subsequent attempts to publish to that [app-name]/[app-instance]/[stream-name] sequence are rejected until you remove the stream from the blocklist.

## More resources
To use the compiled version of this module, see [Blacklist a stream in session with a Wowza Streaming Engine server listener and HTTP provider](https://www.wowza.com/docs/how-to-blacklist-a-stream-in-session-blackliststreams).
Expand Down
Binary file modified lib/wse-plugin-blackliststreams.jar
Binary file not shown.
Binary file added src/com/wowza/wms/plugin/blocklist/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This code and all components (c) Copyright 2006 - 2018, Wowza Media Systems, LLC. All rights reserved.
* This code is licensed pursuant to the Wowza Public License version 1.0, available at www.wowza.com/legal.
*/
package com.wowza.wms.plugin.blacklist;
package com.wowza.wms.plugin.blocklist;

import java.io.BufferedReader;
import java.io.File;
Expand All @@ -16,114 +16,114 @@
import com.wowza.wms.logging.WMSLogger;
import com.wowza.wms.logging.WMSLoggerFactory;

public class BlackListUtils
public class BlockListUtils
{
private static ArrayList<String> streamBlackList = new ArrayList<String>();
private static String blacklistConfigPath = Bootstrap.getServerHome(Bootstrap.CONFIGHOME) + "/conf/blacklist.txt";
private static ArrayList<String> streamblockList = new ArrayList<String>();
private static String blocklistConfigPath = Bootstrap.getServerHome(Bootstrap.CONFIGHOME) + "/conf/blocklist.txt";
static String separatorChar = ":";
private static WMSLogger logger = WMSLoggerFactory.getLogger(BlackListUtils.class);
private static WMSLogger logger = WMSLoggerFactory.getLogger(BlockListUtils.class);

public static void setConfigPath(String config)
{
BlackListUtils.blacklistConfigPath = config;
BlockListUtils.blocklistConfigPath = config;
}

public static void setSeparatorChar(String separatorChar)
{
BlackListUtils.separatorChar = separatorChar;
BlockListUtils.separatorChar = separatorChar;
}

public static void blackListStream(String application, String appInstance, String streamName)
public static void blockListStream(String application, String appInstance, String streamName)
{
BlackListUtils.mergeData();
BlockListUtils.mergeData();

synchronized(BlackListUtils.streamBlackList)
synchronized(BlockListUtils.streamblockList)
{
String streamKey = application + separatorChar + appInstance + separatorChar + streamName;
if (!BlackListUtils.streamBlackList.contains(streamKey))
if (!BlockListUtils.streamblockList.contains(streamKey))
{
BlackListUtils.streamBlackList.add(streamKey);
BlackListUtils.printContents();
BlackListUtils.saveFile();
BlockListUtils.streamblockList.add(streamKey);
BlockListUtils.printContents();
BlockListUtils.saveFile();
}
}
}

public static void removeStreamFromList(String application, String appInstance, String streamName)
{
BlackListUtils.mergeData();
BlockListUtils.mergeData();
String streamKey = application + separatorChar + appInstance + separatorChar + streamName;
if (ServerListenerBlacklistStreams.debug)
logger.info(ServerListenerBlacklistStreams.MODULE_NAME + ".removeStreamFromList[" + streamKey + "] Stream is initiated ");
if (ServerListenerBlocklistStreams.debug)
logger.info(ServerListenerBlocklistStreams.MODULE_NAME + ".removeStreamFromList[" + streamKey + "] Stream is initiated ");

synchronized(BlackListUtils.streamBlackList)
synchronized(BlockListUtils.streamblockList)
{
if (BlackListUtils.streamBlackList.contains(streamKey))
if (BlockListUtils.streamblockList.contains(streamKey))
{
if (BlackListUtils.streamBlackList.remove(streamKey))
if (BlockListUtils.streamblockList.remove(streamKey))
{
BlackListUtils.saveFile();
BlackListUtils.printContents();
BlockListUtils.saveFile();
BlockListUtils.printContents();

logger.info(ServerListenerBlacklistStreams.MODULE_NAME + ".removeStreamFromList[" + streamKey + "] Completed ");
logger.info(ServerListenerBlocklistStreams.MODULE_NAME + ".removeStreamFromList[" + streamKey + "] Completed ");
}
else
{
logger.info(ServerListenerBlacklistStreams.MODULE_NAME + ".removeStreamFromList[" + streamKey + "] Does not exist-2 ");
logger.info(ServerListenerBlocklistStreams.MODULE_NAME + ".removeStreamFromList[" + streamKey + "] Does not exist-2 ");
}
}
else
{
logger.info(ServerListenerBlacklistStreams.MODULE_NAME + ".removeStreamFromList[" + streamKey + "] Does not exist ");
logger.info(ServerListenerBlocklistStreams.MODULE_NAME + ".removeStreamFromList[" + streamKey + "] Does not exist ");
}
}
}

public static boolean isStreamBlackListed(String application, String appInstance, String streamName)
public static boolean isStreamblockListed(String application, String appInstance, String streamName)
{
BlackListUtils.mergeData();
BlockListUtils.mergeData();
String streamKey = application + separatorChar + appInstance + separatorChar + streamName;
return BlackListUtils.streamBlackList.contains(streamKey);
return BlockListUtils.streamblockList.contains(streamKey);
}

public static ArrayList<String> getBlackListedStreams()
public static ArrayList<String> getblockListedStreams()
{
BlackListUtils.mergeData();
synchronized(BlackListUtils.streamBlackList)
BlockListUtils.mergeData();
synchronized(BlockListUtils.streamblockList)
{
return BlackListUtils.streamBlackList;
return BlockListUtils.streamblockList;
}
}

public static void mergeData()
{
synchronized(BlackListUtils.streamBlackList)
synchronized(BlockListUtils.streamblockList)
{
ArrayList<String> fileStored = BlackListUtils.getStoredBlacklistItems();
ArrayList<String> fileStored = BlockListUtils.getStoredblocklistItems();
if (fileStored.size() > 0)
{
for (int i = 0; i < fileStored.size(); i++)
{
if (!BlackListUtils.streamBlackList.contains(fileStored.get(i)))
if (!BlockListUtils.streamblockList.contains(fileStored.get(i)))
{
BlackListUtils.streamBlackList.add(fileStored.get(i));
BlockListUtils.streamblockList.add(fileStored.get(i));
}
}
}
}
}

private static ArrayList<String> getStoredBlacklistItems()
private static ArrayList<String> getStoredblocklistItems()
{
ArrayList<String> blackList = new ArrayList<String>();
File tmpFile = new File(BlackListUtils.blacklistConfigPath);
ArrayList<String> blockList = new ArrayList<String>();
File tmpFile = new File(BlockListUtils.blocklistConfigPath);
if (tmpFile.exists())
{
FileInputStream in = null;
BufferedReader br = null;
try
{
in = new FileInputStream(BlackListUtils.blacklistConfigPath);
in = new FileInputStream(BlockListUtils.blocklistConfigPath);
br = new BufferedReader(new InputStreamReader(in));
String cacheItem;

Expand All @@ -132,13 +132,13 @@ private static ArrayList<String> getStoredBlacklistItems()
cacheItem = cacheItem.trim();
if (!cacheItem.startsWith("#") && cacheItem.length() > 0)
{
blackList.add(cacheItem);
blockList.add(cacheItem);
}
}
}
catch (Exception e)
{
logger.error(ServerListenerBlacklistStreams.MODULE_NAME + ".getStoredBlacklistItems() ", e);
logger.error(ServerListenerBlocklistStreams.MODULE_NAME + ".getStoredblocklistItems() ", e);
}
finally
{
Expand All @@ -164,47 +164,47 @@ private static ArrayList<String> getStoredBlacklistItems()
}
else
{
logger.info(ServerListenerBlacklistStreams.MODULE_NAME + ".getStoredBlacklistItems could not find black list items list");
logger.info(ServerListenerBlocklistStreams.MODULE_NAME + ".getStoredblocklistItems could not find block list items list");
}
return blackList;
return blockList;
}

private static void saveFile()
{
synchronized(BlackListUtils.streamBlackList)
synchronized(BlockListUtils.streamblockList)
{
ArrayList<String> bli = BlackListUtils.streamBlackList;
ArrayList<String> bli = BlockListUtils.streamblockList;
try
{
File f = new File(blacklistConfigPath);
File f = new File(blocklistConfigPath);
if (!f.exists())
{
f.createNewFile();
}

FileWriter tmpFile = new FileWriter(blacklistConfigPath, false);
FileWriter tmpFile = new FileWriter(blocklistConfigPath, false);
StringBuilder b = new StringBuilder();
for (int i = 0; i < bli.size(); i++)
{
logger.info(ServerListenerBlacklistStreams.MODULE_NAME + ".saveFile " + "Line: " + bli.get(i));
logger.info(ServerListenerBlocklistStreams.MODULE_NAME + ".saveFile " + "Line: " + bli.get(i));
b.append(bli.get(i) + "\n");
}
tmpFile.write(b.toString());
tmpFile.close();
}
catch (IOException ioe)
{
logger.error(ServerListenerBlacklistStreams.MODULE_NAME + ".saveFile " + "IOException: " + ioe.getMessage(), ioe);
logger.error(ServerListenerBlocklistStreams.MODULE_NAME + ".saveFile " + "IOException: " + ioe.getMessage(), ioe);
}
}
}

private static void printContents()
{
ArrayList<String> bli = BlackListUtils.getBlackListedStreams();
ArrayList<String> bli = BlockListUtils.getblockListedStreams();
for (int i = 0; i < bli.size(); i++)
{
logger.info(ServerListenerBlacklistStreams.MODULE_NAME + ".printContents " + "bli.get(i): " + bli.get(i));
logger.info(ServerListenerBlocklistStreams.MODULE_NAME + ".printContents " + "bli.get(i): " + bli.get(i));
}

}
Expand Down
Loading