Skip to content

Commit

Permalink
fix #6; allow only owned servers by default
Browse files Browse the repository at this point in the history
  • Loading branch information
pannal committed Oct 13, 2019
1 parent 581f1e0 commit b4977cb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions kitana.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ class Kitana(object):
running_as = "standalone"
maintenance_ran = False
has_update = False
only_owned = True

def __init__(self, prefix="/", timeout=5, plextv_timeout=15, proxy_assets=True, plugin_identifier=None,
language="en"):
language="en", only_owned=True):
self.initialized = False
if os.path.exists("/.dockerenv"):
self.running_as = "docker"
Expand All @@ -94,6 +95,7 @@ def __init__(self, prefix="/", timeout=5, plextv_timeout=15, proxy_assets=True,
self.plextv_timeout = plextv_timeout
self.req_defaults = {"timeout": self.timeout}
self.proxy_assets = proxy_assets
self.only_owned = only_owned
self.default_plugin_identifier = plugin_identifier
self.version_hash = hashlib.md5(self.VERSION.encode("utf-8")).hexdigest()[:7]
self.initialized = True
Expand Down Expand Up @@ -365,6 +367,9 @@ def discover_pms(self, server_name=None, server_addr=None, blacklist_addr=None):
continue

if device["name"] not in servers:
if self.only_owned and not device["owned"] == "1":
continue

servers[device["name"]] = {"connections": [], "owned": device["owned"] == "1",
"publicAddress": device["publicAddress"],
"publicAddressMatches": public_address_matches}
Expand Down Expand Up @@ -599,6 +604,8 @@ def default(self, *args, **kwargs):
help="Connection timeout to the PMS (default: 5)")
parser.add_argument('-pt', '--plextv-timeout', type=int, default=25,
help="Connection timeout to the Plex.TV API (default: 15)")
parser.add_argument('--allow-not-owned', type=bool, default=False, metavar="BOOL", nargs="?", const=True,
help="Allow access to not-owned servers? (default: False)")

args = parser.parse_args()
if args.proxy_base and args.proxy_host_var:
Expand All @@ -615,7 +622,7 @@ def default(self, *args, **kwargs):

kitana = Kitana(prefix=prefix, proxy_assets=args.shadow_assets, timeout=args.timeout,
plextv_timeout=args.plextv_timeout, plugin_identifier=args.plugin_identifier,
language=args.plugin_language)
language=args.plugin_language, only_owned=not args.allow_not_owned)

if isWin32:
args.autoreload = False
Expand Down

0 comments on commit b4977cb

Please sign in to comment.