Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.
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
14 changes: 14 additions & 0 deletions admin/rt-transcoder-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1022,3 +1022,17 @@ function get_server_var( $server_key, $filter_type = FILTER_SANITIZE_STRING ) {
}
return $server_val;
}

/**
* Get local ip addresses for block.
*
* @return array
*/
function rtt_get_blacklist_ip_addresses() {
// If custom API URL added then don't block local ips.
if ( defined( 'TRANSCODER_API_URL' ) ) {
return array();
}

return array( '127.0.0.1', '::1' );
}
4 changes: 2 additions & 2 deletions admin/rt-transcoder-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function __construct( $no_init = false ) {
}

/* Do not let the user to upload non supported media types on localhost */
$blacklist = array( '127.0.0.1', '::1' );
$blacklist = rtt_get_blacklist_ip_addresses();
$remote_addr = rtt_get_remote_ip_address();
if ( ! in_array( wp_unslash( $remote_addr ), $blacklist, true ) ) {
add_filter( 'rtmedia_plupload_files_filter', array( $this, 'allowed_types' ), 10, 1 );
Expand Down Expand Up @@ -494,7 +494,7 @@ public function save_api_key() {

if ( ! empty( $apikey ) && is_admin() && ! empty( $page ) && ( 'rt-transcoder' === $page ) ) {
/* Do not activate transcoding service on localhost */
$blacklist = array( '127.0.0.1', '::1' );
$blacklist = rtt_get_blacklist_ip_addresses();
$remote_addr = rtt_get_remote_ip_address();
if ( in_array( wp_unslash( $remote_addr ), $blacklist, true ) ) {
$return_page = add_query_arg(
Expand Down