diff --git a/README.md b/README.md index 06ade2a..830f43c 100644 --- a/README.md +++ b/README.md @@ -1 +1,27 @@ -# http3-ytproxy \ No newline at end of file +# http3-ytproxy + +A fork of http3-ytproxy adding support for dynamic socket names and port numbers, just because I'am too lazy to change the code enough to use Go routines. So I prefer to run different threads instead. + +The socket folder will be created automatically. + +## Arguments: + +``` + -p string + Specify a port number (default "8080") + -s string + Specify a socket name (default "http-proxy.sock") +``` + +## SystemD service + +Copy the `http3-ytproxy@.service` to `/etc/systemd/system/` and use it like this: + +``` +# This will create the http-proxy-1.sock file +$ sudo systemctl enable --now http3-ytproxy@1.service +# And this one will be http-proxy-2.sock +$ sudo systemctl enable --now http3-ytproxy@2.service +``` + +lolxdxdxd fastest invidious instance in the fucking world wtfffffffffffffffffffffff diff --git a/http3-ytproxy.service b/http3-ytproxy@.service similarity index 90% rename from http3-ytproxy.service rename to http3-ytproxy@.service index 55f9821..ff79fdd 100644 --- a/http3-ytproxy.service +++ b/http3-ytproxy@.service @@ -9,9 +9,9 @@ User=root Group=root Environment="DISABLE_WEBP=1" WorkingDirectory=/opt/http3-ytproxy -ExecStart=/opt/http3-ytproxy/http3-ytproxy +ExecStart=/opt/http3-ytproxy/http3-ytproxy -s http-proxy-%i.sock Restart=on-failure -RestartSec=3s +RestartSec=2s #ReadWritePaths=/opt/rimgo NoNewPrivileges=yes diff --git a/main.go b/main.go index c3a6e8d..6d6bb2e 100644 --- a/main.go +++ b/main.go @@ -302,6 +302,7 @@ func RelativeUrl(in string) (newurl string) { func main() { var sock string + var port string path_prefix = os.Getenv("PREFIX_PATH") @@ -312,12 +313,13 @@ func main() { fmt.Println("socket folder doesn't exists, creating one now.") err = os.Mkdir("socket", 0755) if err != nil { - fmt.Println("Failed to create folder, error:") + fmt.Println("Failed to create folder, error: ") log.Fatal(err) } } flag.StringVar(&sock, "s", "http-proxy.sock", "Specify a socket name") + flag.StringVar(&port, "p", "8080", "Specify a port number") flag.Parse() socket := "socket" + string(os.PathSeparator) + string(sock) @@ -326,13 +328,17 @@ func main() { srv := &http.Server{ ReadTimeout: 5 * time.Second, WriteTimeout: 1 * time.Hour, - Addr: ":8080", + Addr: ":" + string(port), Handler: &requesthandler{}, } if err != nil { - fmt.Println("Failed to bind to UDS, falling back to TCP/IP") + fmt.Println("Failed to bind to UDS, please check the socket name, falling back to TCP/IP") fmt.Println(err.Error()) - srv.ListenAndServe() + err := srv.ListenAndServe() + if err != nil { + fmt.Println("Cannot bind to port", string(port), "Error:", err) + fmt.Println("Please try changing the port number") + } } else { defer listener.Close() srv.Serve(listener)