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 + " ...")