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

feat: parse /etc/hosts for tcpsock:connect() #10

Closed

Conversation

thibaultcha
Copy link
Member

Hi there,

Not sure if this will be welcomed, but I basically thought of a quick hack to parse /etc/hosts and override tcpsock:connect and thought that'd be handy. A particular use-case for this is when implementing a resty-cli script that connects to a local service binded to localhost.

I understand if this is too hacky.

@thibaultcha thibaultcha force-pushed the feat/resolve-etc-hosts branch from 9df3bd9 to 353d0e9 Compare August 23, 2016 19:36
@@ -233,7 +248,7 @@ $main_include_directives
http {
access_log off;
lua_socket_log_errors off;
resolver @nameservers;
resolver @nameservers ipv6=off;
Copy link
Member Author

Choose a reason for hiding this comment

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

this might be undesired but necessary for the www.google.com resolution test. Let me know if inappropriate.

@thibaultcha
Copy link
Member Author

thibaultcha commented Aug 23, 2016

Interesting, the new test is working locally but not on travis. It seems the parsing regex is overlooking aliases, totally overlooked that, my bad.

@agentzh
Copy link
Member

agentzh commented Aug 23, 2016

@thibaultcha Yeah, this is too bloody. Will you instead add /etc/hosts support to the nginx core's resolver instead? Then everything else would just work out of the box including this project :)

@agentzh
Copy link
Member

agentzh commented Aug 23, 2016

@thibaultcha Yeah, I welcome an nginx core patch for this. We can include it in OpenResty by default.

@thibaultcha thibaultcha force-pushed the feat/resolve-etc-hosts branch from 353d0e9 to 7bd38f3 Compare August 23, 2016 20:25
@thibaultcha
Copy link
Member Author

Updated the patch for the sake of it. Will take a look at the nginx core patch!

@agentzh
Copy link
Member

agentzh commented Aug 23, 2016

@thibaultcha There is no IPv6 support on Travis CI's cloud. Not even [::1].

@agentzh
Copy link
Member

agentzh commented Aug 23, 2016

@thibaultcha Awesome. Thanks!

@thibaultcha
Copy link
Member Author

thibaultcha commented Sep 13, 2016

@agentzh I started such a patch. Might take a while since so many things are going on on our side these days, plus the Nginx core code base is new to me. Will get there tho, eventually!

@thibaultcha
Copy link
Member Author

@agentzh I have such a patch ready on my side (finally got some time to finish it). However, I am not sure if it would be welcomed by Nginx. Do you happen to know if so? I know this is a long shot but maybe I am not aware if such a topic came up there already :)

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.

2 participants