From 63736f80f4cc9a4d88f3d5e677ab305de17b39b8 Mon Sep 17 00:00:00 2001 From: Kadrim <8304331+kadrim@users.noreply.github.com> Date: Mon, 19 Sep 2022 14:57:05 +0000 Subject: [PATCH] add option to disable sideloading --- README.md | 9 +++++++++ main.go | 7 ++++++- proxy.go | 8 +++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 16be32c..9545b27 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,15 @@ services: restart: unless-stopped ``` +## Command-Line Arguments + +The standard behaviour of the program can be altered using the following CLI-Args: + +| Argument | Description | +| ---------------------- | -------------------------------------------------------------------------------------------- | +| -h | Display all available CLI-Arguments | +| -disable-sideloading | This Option will disable sideloading and prevent the use of Port 80 by the Application | + ## TODOs - detect OS and allow User to install the proxy as a boot-service diff --git a/main.go b/main.go index cba9402..17fa775 100644 --- a/main.go +++ b/main.go @@ -1,5 +1,7 @@ package main +import "flag" + const ( port = "3000" host = "plex.tv" @@ -11,6 +13,9 @@ const ( ) func main() { + disableSideloadingPtr := flag.Bool("disable-sideloading", false, "This Option will disable sideloading and prevent the use of Port 80 by the Application") + flag.Parse() + checkIPs() - runProxy() + runProxy(*disableSideloadingPtr) } diff --git a/proxy.go b/proxy.go index d96a2fc..5eff9bf 100644 --- a/proxy.go +++ b/proxy.go @@ -69,7 +69,7 @@ func handleRequest(res http.ResponseWriter, req *http.Request) { proxy.ServeHTTP(res, req) } -func runProxy() { +func runProxy(disableSideloading bool) { // handle simple information path http.HandleFunc("/info", func(res http.ResponseWriter, req *http.Request) { res.Write([]byte("The Plex proxy service is running on " + req.Host)) @@ -118,8 +118,10 @@ func runProxy() { // try to handle everything on port 80 aswell for serving the app // Note: this will not work on non-rooted android because only high-ports can be used go func() { - log.Println("Trying to start app-deployer on port 80 ...") - http.ListenAndServe(":80", nil) + if !disableSideloading { + log.Println("Trying to start app-deployer on port 80 ...") + http.ListenAndServe(":80", nil) + } }() log.Println("Server starting on Port " + port + " ...")