Skip to content
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

Resolve DnsEndPoint in UdpConnection #1457

Merged
merged 1 commit into from
Oct 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions SteamKit2/SteamKit2/Networking/Steam3/UdpConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ public void Connect(EndPoint endPoint, int timeout)
inSeqAcked = 0;
inSeqHandled = 0;

if (endPoint is DnsEndPoint dnsEndPoint)
{
var resolved = Dns.GetHostAddresses(dnsEndPoint.Host, AddressFamily.InterNetwork);

if (resolved == null || resolved.Length == 0)
{
throw new ArgumentException("Failed to resolve given dns endpoint.", nameof(endPoint));
}

endPoint = new IPEndPoint(resolved[0], dnsEndPoint.Port);
Copy link
Member

Choose a reason for hiding this comment

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

Should we select random if it resolves to multiple hosts?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not really expecting UDP servers to live for long, so I don't care too much 🤣

Copy link
Member

Choose a reason for hiding this comment

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

lol valid

}

netThread = new Thread( NetLoop )
{
Name = "SK2-UdpConn"
Expand Down