Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

ngrok 1.6 (new formula) #27598

Closed
wants to merge 1 commit into from
Closed

Conversation

philadams-zz
Copy link
Contributor

This pr adds a brew for ngrok1, a tool that allows you to securely expose
a local web server to the internet and capture all traffic for detailed
inspection and replay. The formula is Go-based and depends on Go,
Bazaar, and Mercurial.

This formula is a new from-source PR as requested by @MikeMcQuaid on
issue #20839 - essentially a resubmission of #23732 which has an
unresponsive author.

This pr adds a brew for ngrok[1], a tool that allows you to securely expose
a local web server to the internet and capture all traffic for detailed
inspection and replay. The formula is Go-based and depends on Go,
Bazaar, and Mercurial.

This formula is a new from-source PR as requested by @MikeMcQuaid on
issue 20839 - essentially a resubmission of 23732 which has an
unresponsive author.

[1]: https://ngrok.com
end

test do
system "#{bin}/ngrok", "version"
Copy link
Member

Choose a reason for hiding this comment

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

Can this test be modified to do something more substantial then e.g. --version or --help? See cmake.rb for an example of a formula with a good test. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking for a good example of a Formula for a networking library with a robust test. Tor just does this whole --version thing too. Will get back to you asap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haven't found a good example brew test yet. Does simply reading the output of something like ngrok --log=stdout 8080 for the string [client] Tunnel established... make sense? I don't know if this is more robust than just --version: we'd then be testing more that the service was up than that ngrok had been installed.

Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

wget is a good example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, ngrok is a program that tries to keep open a connection to a remote server, reconnecting as needed. wget's test confirms that grabbing google.com's index completes as expected (and fails when there's no network connection of course). ngrok never 'completes'...

One thing we could do is something like Open3.popen3("#{bin}/ngrok -log stdout 8080") do |stdin, stdout, _|... and in the block check that the first line of stdout is doing something we expect (in this case, reading the config file). https://github.com/Homebrew/homebrew/blob/master/Library/Contributions/example-formula.rb gave me this idea.

Is there a better way to 'test' ngrok is correctly installed? @inconshreveable - thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

More discussion on this point here: #23732 (comment)

@caifara caifara mentioned this pull request Apr 3, 2014
@adamv adamv added the go label May 4, 2014
@lucasmartins
Copy link

Was this abandoned?

@philadams-zz
Copy link
Contributor Author

@lucasmartins This PR is in a stuck state due to there being neither a consensus nor further good ideas about how to meaningfully test a network program intended to just keep open a tunnel. If you've got good ones, please suggest / implement! I'd love to see ngrok in homebrew :)

@MikeMcQuaid
Copy link
Member

Pushed, sorry for delay here.

@philadams-zz
Copy link
Contributor Author

Awesome - thanks!

@philadams-zz philadams-zz deleted the ngrok-pr branch May 8, 2014 12:42
@lucasmartins
Copy link

Personally, I don't think we need a reliable test to release a experimental version.

Although, if we need to check if the recently installed ngrok works I suggest using lsof, ngrok listens to a local port and establishes 2 external connections:

# ngrok 8080
$ lsof -i -n | grep 'ngrok'
ngrok     2579 lucasmartins    8u  IPv4 0xe2544265d8122f89      0t0  TCP 127.0.0.1:yo-main (LISTEN)
ngrok     2579 lucasmartins   10u  IPv4 0xe2544265dd319f89      0t0  TCP 192.168.0.113:50677->96.126.125.171:https (ESTABLISHED)
ngrok     2579 lucasmartins   13u  IPv4 0xe2544265d81ac771      0t0  TCP 192.168.0.113:50679->96.126.125.171:https (ESTABLISHED)

We can also munch this data using wc -l:

$ lsof -i -n | grep 'ngrok'| wc -l
3

Is that acceptable?

@MikeMcQuaid
Copy link
Member

This was merged.

@philadams-zz
Copy link
Contributor Author

@lucasmartins I really quite like that idea. You can check those connections (with a munching wc -l) then kill the ngrok process. Neat.

If you'd like to do a PR to make the test better, that'd be awesome.

@Homebrew Homebrew locked and limited conversation to collaborators Feb 17, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants