This commit is contained in:
Fijxu 2023-11-07 12:18:20 -03:00
parent 8d4abeba41
commit 10742fe2d5
3 changed files with 39 additions and 7 deletions

View file

@ -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

View file

@ -9,9 +9,9 @@ User=root
Group=root Group=root
Environment="DISABLE_WEBP=1" Environment="DISABLE_WEBP=1"
WorkingDirectory=/opt/http3-ytproxy WorkingDirectory=/opt/http3-ytproxy
ExecStart=/opt/http3-ytproxy/http3-ytproxy ExecStart=/opt/http3-ytproxy/http3-ytproxy -s http-proxy-%i.sock
Restart=on-failure Restart=on-failure
RestartSec=3s RestartSec=2s
#ReadWritePaths=/opt/rimgo #ReadWritePaths=/opt/rimgo
NoNewPrivileges=yes NoNewPrivileges=yes

14
main.go
View file

@ -302,6 +302,7 @@ func RelativeUrl(in string) (newurl string) {
func main() { func main() {
var sock string var sock string
var port string
path_prefix = os.Getenv("PREFIX_PATH") path_prefix = os.Getenv("PREFIX_PATH")
@ -312,12 +313,13 @@ func main() {
fmt.Println("socket folder doesn't exists, creating one now.") fmt.Println("socket folder doesn't exists, creating one now.")
err = os.Mkdir("socket", 0755) err = os.Mkdir("socket", 0755)
if err != nil { if err != nil {
fmt.Println("Failed to create folder, error:") fmt.Println("Failed to create folder, error: ")
log.Fatal(err) log.Fatal(err)
} }
} }
flag.StringVar(&sock, "s", "http-proxy.sock", "Specify a socket name") flag.StringVar(&sock, "s", "http-proxy.sock", "Specify a socket name")
flag.StringVar(&port, "p", "8080", "Specify a port number")
flag.Parse() flag.Parse()
socket := "socket" + string(os.PathSeparator) + string(sock) socket := "socket" + string(os.PathSeparator) + string(sock)
@ -326,13 +328,17 @@ func main() {
srv := &http.Server{ srv := &http.Server{
ReadTimeout: 5 * time.Second, ReadTimeout: 5 * time.Second,
WriteTimeout: 1 * time.Hour, WriteTimeout: 1 * time.Hour,
Addr: ":8080", Addr: ":" + string(port),
Handler: &requesthandler{}, Handler: &requesthandler{},
} }
if err != nil { 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()) 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 { } else {
defer listener.Close() defer listener.Close()
srv.Serve(listener) srv.Serve(listener)