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

Fix pure ipaddreses (ip's without a port) could not resolve. #156

Merged
merged 5 commits into from Sep 17, 2021

Conversation

kepet19
Copy link
Contributor

@kepet19 kepet19 commented Sep 12, 2021

Fixes #134
normal hostnames could be resolve without a port. it was only Ip adresses that could not.

The name you can see in the server list is the same as the adress.

Before

210912-2038-55

Now

image

I have simplified the code and it can still connect to server where it is protected by TCPShield.
I did throw in a empty server where the field is empty.
also kkmp.dk does not exits.

FIY this pr also removes regex

@kepet19 kepet19 force-pushed the clean-entwork-connect branch 2 times, most recently from 60208cc to 2a064ad Compare September 13, 2021 04:58
@terrarier2111
Copy link
Member

terrarier2111 commented Sep 13, 2021

I appreciate your work, but why would you want to remove the srv resolution? it is needed to join the vast majority of big server (e g. hypixel)

@kepet19
Copy link
Contributor Author

kepet19 commented Sep 13, 2021

why would you want to remove the srv resolution?

Upps I thought it was a normal dns lookup where it got the ip's. but I now see it can also get ports.
So the solution I made would not function if they are not using default minecraft port.
I now see it can be a problem.

FIY. mc.hypixel.net seems to function properly.

@terrarier2111
Copy link
Member

Yea, so just revert your changes and only use the default port if the ip is numerical and no port was provided (or if the srv lookup fails) OR as an alternative you could first try the result of the srv lookup, then the provided port (if there is one) and at the or the default port, the second approach would be more complete although a bit harder to implement

@kepet19
Copy link
Contributor Author

kepet19 commented Sep 13, 2021

I made a new commit, that keeps srv
not sure if we should remove the regex crate.
rust std has a ip parser.

   if let Err(_) = std::net::IpAddr::from_str(&addres) {
     ...
   }
   
   same almost
   
  if !IPADDRESS_PATTERN.is_match(&addres) {
    ...
  }
  

@terrarier2111
Copy link
Member

I made a new commit, that keeps srv
not sure if we should remove the regex crate.
rust std has a ip parser.

   if let Err(_) = std::net::IpAddr::from_str(&addres) {
     ...
   }
   
   same almost
   
  if !IPADDRESS_PATTERN.is_match(&addres) {
    ...
  }
  

If you are able to drop it without dropping any functionality that would be great. Are you sure rust can check if somthing is a domain or an ip tho?

@kepet19
Copy link
Contributor Author

kepet19 commented Sep 13, 2021

yes I am sure

it is define like this.

enum IpAddr {
ipV4
ipV6
}

@terrarier2111
Copy link
Member

So you are also sure it that it doesn't automatically resolve the ip behind the domain?

@kepet19
Copy link
Contributor Author

kepet19 commented Sep 13, 2021

So you are also sure it that it doesn't automatically resolve the ip behind the domain?
Here is the for IpAddr
https://doc.rust-lang.org/std/net/enum.IpAddr.html

Yes I tripped checked the code and also run some Manuel test with the server browser.

Conn::try_stream(&address, port, protocol_version)
}

fn try_stream(addres: &str, port: u16, protocol_version: i32) -> Result<Conn, Error> {
Copy link
Member

Choose a reason for hiding this comment

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

there is a typo, in "addres" it should be "address"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch!

address = next.to_string();
let mut port = 25565;

if target.contains(':') {
Copy link
Member

Choose a reason for hiding this comment

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

You could split_once directly here and use a if let instead of first checking contains and then splitting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't even know why, I did not think about that xD.

@terrarier2111
Copy link
Member

Can you rebase? then i'll merge this

@kepet19 kepet19 force-pushed the clean-entwork-connect branch 9 times, most recently from 93b62b8 to 4d37168 Compare September 13, 2021 21:31
@terrarier2111
Copy link
Member

Okay, can you rebase once again? then i'll merge it lol

@kepet19
Copy link
Contributor Author

kepet19 commented Sep 14, 2021

This pr it is rebased on the lastest commit on master ca6e8e2 ?

@terrarier2111
Copy link
Member

There are merge conflicts @kepet19

@kepet19
Copy link
Contributor Author

kepet19 commented Sep 14, 2021

Fixed! @terrarier2111

@terrarier2111
Copy link
Member

Fixed! @terrarier2111

I'll wait for the ci and as i have no access to a computer in like 10 minutes until i get home i'll merge it once i got home.

@terrarier2111
Copy link
Member

terrarier2111 commented Sep 14, 2021

Okay, i am home now, could you resolve the merge conflicts? its the last time now, i promise

@kepet19
Copy link
Contributor Author

kepet19 commented Sep 14, 2021

it is running again
no problem!

@terrarier2111 terrarier2111 merged commit 7e04efd into Lea-fish:main Sep 17, 2021
@kepet19 kepet19 deleted the clean-entwork-connect branch September 17, 2021 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto add 25565 as port if none is set for servers in serverlist
2 participants