nil pointer: ytimg request is not checked in thumbnail #1

Closed
opened 2024-11-12 17:22:58 -03:00 by acheong08 · 7 comments
goroutine 29 [running]:
net/http.(*conn).serve.func1()
        /root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.linux-amd64/src/net/http/server.go:1947 +0xbe
panic({0x90c420?, 0xdd9d40?})
        /root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.linux-amd64/src/runtime/panic.go:785 +0x132
main.getBestThumbnail({0xc00002e7c3, 0x1a})
        /tmp/http3-ytproxy/utils.go:39 +0x165
main.vi({0xa7f428, 0xc0000cc380}, 0xc00010a780)
        /tmp/http3-ytproxy/httppaths.go:156 +0x10e
main.main.beforeProxy.func8({0xa7f428, 0xc0000cc380}, 0xc00010a780)
        /tmp/http3-ytproxy/main.go:354 +0x299
net/http.HandlerFunc.ServeHTTP(0xc0000cc1c0?, {0xa7f428?, 0xc0000cc380?}, 0x6a3c36?)
        /root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.linux-amd64/src/net/http/server.go:2220 +0x29
net/http.(*ServeMux).ServeHTTP(0x468619?, {0xa7f428, 0xc0000cc380}, 0xc00010a780)
        /root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.linux-amd64/src/net/http/server.go:2747 +0x1ca
net/http.serverHandler.ServeHTTP({0xc00010d890?}, {0xa7f428?, 0xc0000cc380?}, 0x6?)
        /root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.linux-amd64/src/net/http/server.go:3210 +0x8e
net/http.(*conn).serve(0xc0000e66c0, {0xa80250, 0xc00010cab0})
        /root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.linux-amd64/src/net/http/server.go:2092 +0x5d0
created by net/http.(*Server).Serve in goroutine 1
        /root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.linux-amd64/src/net/http/server.go:3360 +0x485

Lines 31 to 45 in 848ad55
func getBestThumbnail(path string) (newpath string) {
formats := [4]string{"maxresdefault.jpg", "sddefault.jpg", "hqdefault.jpg", "mqdefault.jpg"}
for _, format := range formats {
newpath = strings.Replace(path, "maxres.jpg", format, 1)
url := "https://i.ytimg.com" + newpath
resp, _ := h2client.Head(url)
if resp.StatusCode == 200 {
return newpath
}
}
return strings.Replace(path, "maxres.jpg", "mqdefault.jpg", 1)
}

```go goroutine 29 [running]: net/http.(*conn).serve.func1() /root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.linux-amd64/src/net/http/server.go:1947 +0xbe panic({0x90c420?, 0xdd9d40?}) /root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.linux-amd64/src/runtime/panic.go:785 +0x132 main.getBestThumbnail({0xc00002e7c3, 0x1a}) /tmp/http3-ytproxy/utils.go:39 +0x165 main.vi({0xa7f428, 0xc0000cc380}, 0xc00010a780) /tmp/http3-ytproxy/httppaths.go:156 +0x10e main.main.beforeProxy.func8({0xa7f428, 0xc0000cc380}, 0xc00010a780) /tmp/http3-ytproxy/main.go:354 +0x299 net/http.HandlerFunc.ServeHTTP(0xc0000cc1c0?, {0xa7f428?, 0xc0000cc380?}, 0x6a3c36?) /root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.linux-amd64/src/net/http/server.go:2220 +0x29 net/http.(*ServeMux).ServeHTTP(0x468619?, {0xa7f428, 0xc0000cc380}, 0xc00010a780) /root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.linux-amd64/src/net/http/server.go:2747 +0x1ca net/http.serverHandler.ServeHTTP({0xc00010d890?}, {0xa7f428?, 0xc0000cc380?}, 0x6?) /root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.linux-amd64/src/net/http/server.go:3210 +0x8e net/http.(*conn).serve(0xc0000e66c0, {0xa80250, 0xc00010cab0}) /root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.linux-amd64/src/net/http/server.go:2092 +0x5d0 created by net/http.(*Server).Serve in goroutine 1 /root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.linux-amd64/src/net/http/server.go:3360 +0x485 ``` https://git.nadeko.net/Fijxu/http3-ytproxy/src/commit/848ad555f7663ab5da418c8644bc18983439473f/utils.go#L31-L45
Author

err: dial tcp4 172.217.19.86:443: connect: network is unreachable

i.ytimg.com has ipv6 addresses but ipv4 is still used even if unreachable

err: `dial tcp4 172.217.19.86:443: connect: network is unreachable` `i.ytimg.com` has ipv6 addresses but ipv4 is still used even if unreachable
Author

Need to set -ipv6_only flag

Need to set `-ipv6_only` flag
Author

Is there a reason Dial is overridden vs just the default (which I assume would try both?)

Is there a reason Dial is overridden vs just the default (which I assume would try both?)
Owner

Is there a reason Dial is overridden vs just the default (which I assume would try both?)

No idea. I can't even test IPV6 because I don't even have IPV6 on any of my servers.
And that code is from https://github.com/TeamPiped/http3-ytproxy/blob/main/main.go#L35-L39

This is a hard fork of that repository, used for my invidious instance. I added a lot of things but I'm clueless about the Dialer since I never had any problems with it.

There is any way to reproduce this? I wonder why would you want to use this proxy too.

>Is there a reason Dial is overridden vs just the default (which I assume would try both?) No idea. I can't even test IPV6 because I don't even have IPV6 on any of my servers. And that code is from https://github.com/TeamPiped/http3-ytproxy/blob/main/main.go#L35-L39 This is a hard fork of that repository, used for my invidious instance. I added a lot of things but I'm clueless about the Dialer since I never had any problems with it. There is any way to reproduce this? I wonder why would you want to use this proxy too.
Author

There is any way to reproduce this?

I have a server that only has ipv6 (no ipv4).

I wonder why would you want to use this proxy too.

Invidious can't run from a datacenter IP so I reverse proxy from my server over tailscale. Proxying video and images takes up more bandwidth and tailscale doesn't have great performance. Instead I run invidious from residential but proxy video/images from datacenter.

> There is any way to reproduce this? I have a server that only has ipv6 (no ipv4). > I wonder why would you want to use this proxy too. Invidious can't run from a datacenter IP so I reverse proxy from my server over tailscale. Proxying video and images takes up more bandwidth and tailscale doesn't have great performance. Instead I run invidious from residential but proxy video/images from datacenter.
Author

For the dailer, the supported network (ipv4/ipv6) is passed into the function. Instead of setting it yourself, you can just pass it through unless you want to disable one of them.

Dial: func(network, addr string) (net.Conn, error) {
   		return dialer.Dial(network, addr)
   	},
For the dailer, the supported network (ipv4/ipv6) is passed into the function. Instead of setting it yourself, you can just pass it through unless you want to disable one of them. ```go Dial: func(network, addr string) (net.Conn, error) { return dialer.Dial(network, addr) }, ```
Owner

and tailscale doesn't have great performance.

You can use Netmaker instead, it's a MeshVPN like Tailscale but it uses Kernel level wireguard so performance should be better in a VPS.

The only downside is that you need to setup your own NetMaker server to use it and that can be tricky to do. You can use my NetMaker server with your own account if you want but you will need to request an account of course. And I'm not sure if the connecting cuts of between the devices if the NetMaker server is down.

I have a server that only has ipv6 (no ipv4).

I see.

Btw, yesterday I hard coded some values on the code, you can see why in the commit lol. If you want to use it for your instance, make sure to comment comment that if else statement before compiling or revert to the previous commit. If you use docker you can just use an old version of the image which is catalogued by date.

>and tailscale doesn't have great performance. You can use Netmaker instead, it's a MeshVPN like Tailscale but it uses Kernel level wireguard so performance should be better in a VPS. The only downside is that you need to setup your own NetMaker server to use it and that can be tricky to do. You can use my NetMaker server with your own account if you want but you will need to request an account of course. And I'm not sure if the connecting cuts of between the devices if the NetMaker server is down. >I have a server that only has ipv6 (no ipv4). I see. Btw, yesterday I hard coded some values on the code, you can see why in the commit lol. If you want to use it for your instance, make sure to comment comment that `if else` statement before compiling or revert to the previous commit. If you use docker you can just use an old version of the image which is catalogued by date.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Fijxu/http3-ytproxy#1
No description provided.