Skip to content

session: implement --interface, --ipv4 and --ipv6 #3483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

bastimeyer
Copy link
Member

@bastimeyer bastimeyer commented Jan 9, 2021

Resolves #3474
Resolves #2192

Implements --interface, -4/--ipv4 and -6/--ipv6, similar to curl.

Concerns

  • What I don't like about this implementation is that it overrides the address family resolving in requests.packages.urllib3.util.connection globally, as it's not session based. This means that when someone creates two sessions from the API and sets the ipv4 or ipv6 option, all other sessions will be affected as well.
  • This does only affect HTTP/HTTPS connections. Web sockets for example are currently all managed individually in certain plugins. The implementation of a common WSSession similar to the HTTPSession would fix this.
  • Not sure if the "general" arguments group is the correct choice. Technically it could also go into the "transport" arguments group.

Examples

Default interface:

$ streamlink -l none -o /dev/null twitch.tv/gamesdonequick best &
$ ss -npt | awk '/streamlink/ {print $4; exit}'
192.168.178.99:33253

Second interface:

$ streamlink -l none -o /dev/null twitch.tv/gamesdonequick best --interface 192.168.100.1 &
$ ss -npt | awk '/streamlink/ {print $4; exit}'
192.168.100.1:43101

Invalid interface:

$ streamlink -l none -o /dev/null twitch.tv/gamesdonequick best --interface 1.2.3.4
error: No playable streams found on this URL: twitch.tv/gamesdonequick

Automatic address family resolving:

$ streamlink -l none -o /dev/null 'youtube.com/watch?v=xcJtL7QggTI' best &
$ ss -npt | awk '/streamlink/ {print $5; exit}'
[2a00:1450:4001:819::200e]:443

IPv4 resolving:

$ streamlink -l none -o /dev/null 'youtube.com/watch?v=xcJtL7QggTI' best --ipv4 &
$ ss -npt | awk '/streamlink/ {print $5; exit}'
74.125.126.91:443

IPv6 resolving (IPv4-only example):

$ streamlink -l none -o /dev/null twitch.tv/gamesdonequick best --ipv6
error: No playable streams found on this URL: twitch.tv/gamesdonequick

@bastimeyer bastimeyer force-pushed the feature/interface-and-addr-family branch from 78e1eff to 35f8e42 Compare January 9, 2021 18:22
@bastimeyer bastimeyer force-pushed the feature/interface-and-addr-family branch from 35f8e42 to 0106675 Compare February 2, 2021 13:21
@bastimeyer
Copy link
Member Author

Rebased and fixed merge conflict which was introduced by #3486

Copy link
Member

@gravyboat gravyboat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping other people would weigh in but this has been open for a bit so I think we should get it merged. While the override is a bit annoying I don't think it's a problem in the grand scheme of things. If people are using this option they know what they're doing.

@gravyboat gravyboat merged commit 6152a60 into streamlink:master Feb 2, 2021
@bastimeyer bastimeyer deleted the feature/interface-and-addr-family branch February 2, 2021 17:04
Billy2011 added a commit to Billy2011/streamlink-27 that referenced this pull request Feb 4, 2021
Billy2011 added a commit to Billy2011/streamlink-27 that referenced this pull request Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

param for source address or IPv4/IPv6 Specify manually the network interface to use in a multi-homed setup?
2 participants