?
This commit is contained in:
parent
8d4abeba41
commit
10742fe2d5
3 changed files with 39 additions and 7 deletions
28
README.md
28
README.md
|
@ -1 +1,27 @@
|
|||
# http3-ytproxy
|
||||
# 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
|
||||
|
|
|
@ -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
|
14
main.go
14
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)
|
||||
|
|
Loading…
Reference in a new issue