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: properly handle remote hostname #30

Merged
merged 1 commit into from
Sep 9, 2018

Conversation

nbaztec
Copy link
Contributor

@nbaztec nbaztec commented Sep 6, 2018

fixes #29

@nbaztec
Copy link
Contributor Author

nbaztec commented Sep 6, 2018

Yeah you guessed right. The tool does that often it seems :)

About the extension method reorder, I'd noticed something earlier. If theIPAddress overload is before the string implementation then the config parser attempts to cast remoteAddress to the former and errors out in process. That's the error you're getting now.

@FantasticFiasco
Copy link
Owner

Yes you are correct. I always forget that :-( I wish they'd let us somehow define the method(s) used when configuring using app settings.

@nbaztec
Copy link
Contributor Author

nbaztec commented Sep 6, 2018

Yeah took me a while to figure out as well. Maybe I'll submit a patch to fix their reflection logic to do a best match.

@FantasticFiasco
Copy link
Owner

That would surely help most sink developers!

@FantasticFiasco
Copy link
Owner

I'll have to quit for now, but will continue with this tomorrow. Have a good night.

<ItemGroup>
<None Update="appsettings_output_template.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="appsettings_text_formatter.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="appsettings_remote_ip_address.json">
Copy link
Owner

Choose a reason for hiding this comment

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

Are we missing a file?

@FantasticFiasco
Copy link
Owner

I'm going to finish up the last changes tomorrow, and then we'll merge the PR. Thank you for your patience.

@nbaztec
Copy link
Contributor Author

nbaztec commented Sep 9, 2018

Super, I'll submit another PR for the IPv6 mapped socket type. There's no reason to create IPv4 sockets when dual stacks are already supported at the OS level :)

@FantasticFiasco
Copy link
Owner

IPv6 has gained a lot of ground, but there are still environments where this isn't available by default (source),

I would rather probe the hostname and investigate its address family, and then setup the UDP client using that family, or is your argument that the dual mode always will work?

@nbaztec
Copy link
Contributor Author

nbaztec commented Sep 9, 2018

Exactly, the dual mode always works via IPv4 translation (since IPv4s can be represented as IPv6s)

@FantasticFiasco
Copy link
Owner

FantasticFiasco commented Sep 9, 2018

I was worried about Windows XP, but since XP doesn't support .NET 4.5 which I build for, it seems that we are in the clear.

You can open up a new PR after this one is merged, which will be tonight I think. Thank you for all effort you've put into this issue.

@nbaztec
Copy link
Contributor Author

nbaztec commented Sep 9, 2018

You're welcome, appreciate the help with the clean up.

PS: Also when using hostnames, IPv4/IPv6 check is of little significance since a DNS record can hold both types.

Fixes issue where the hostname only resolves into an IP address when the
sink is created. The very nature of hostnames is to provide a route to
instances whose IP address may change, and these code changes allows for
this situation.

One limitation with the changes is that currently only IPv4 addresses are
supported, but an upcoming PR will solve that issue.

Closes FantasticFiasco#29
@FantasticFiasco FantasticFiasco merged commit a7bde60 into FantasticFiasco:master Sep 9, 2018
@nbaztec
Copy link
Contributor Author

nbaztec commented Sep 10, 2018

@FantasticFiasco I noticed that you've removed the existing IPEndpoint overload from here : https://github.com/FantasticFiasco/serilog-sinks-udp/pull/30/files#diff-19ca08d0f67e7b4f5f471a8ee6d81139L38

I'd like to state that this can potentially impact performance for known IP address cases since they would be first sent to a DNS resolver and then converted to IPEndpoint. The DNS resolution being the critical thing here - subject to implementation - could cause potential issues (in most cases should be negligible).

If that's acceptable then no further action is needed. Also it's unfortunate that the PR was rebased on my master and not during merge time - so we've lost the history in case we wish to go back.

@FantasticFiasco
Copy link
Owner

I've looked at the UdpClient source code and you are correct. I'll revert the cleanup on my master.

@FantasticFiasco
Copy link
Owner

I've updated the code, you can see the changes here.

@nbaztec
Copy link
Contributor Author

nbaztec commented Sep 10, 2018

If you wish to recover the lost commits, I have the branch still locally - now with lots of merge conflicts so would reflog it but if you can work it out that's also okay. For next time best use Squash and merge of GitHub or squash only the PR. My version of fork is now out of sync :)

@FantasticFiasco
Copy link
Owner

Sorry I messed up your history, wont happen again :-(

I guess this is one on the reasons why GitHub proposes to create pull requests from branches.

@nbaztec
Copy link
Contributor Author

nbaztec commented Sep 10, 2018

No worries. I'll work it out.

Usually one would squash merge the PR on GitHub directly leaving the original branch intact - it's a bit different from git in a way that it points to a distinct ref. A PR from non master branch wouldn't have changed the outcome of the branch, unfortunately.

@FantasticFiasco
Copy link
Owner

Its a good day when you learn something new, thanks!

@nbaztec
Copy link
Contributor Author

nbaztec commented Sep 10, 2018

You're welcome. I'll work on the mapped IPv4 PR and you might wanna look into upgrading to the latest Serilog.Settings.Configuration package when this is merged serilog/serilog-settings-configuration#131

Have a nice evening.

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.

Remote hostname resolved only once
2 participants