Skip to content

Commit

Permalink
add option to disable sideloading
Browse files Browse the repository at this point in the history
  • Loading branch information
kadrim committed Sep 19, 2022
1 parent c56780a commit 63736f8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package main

import "flag"

const (
port = "3000"
host = "plex.tv"
Expand All @@ -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)
}
8 changes: 5 additions & 3 deletions proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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 + " ...")
Expand Down

0 comments on commit 63736f8

Please sign in to comment.