Last active
December 24, 2020 02:08
-
-
Save Erisa/0342a447cf98032df3b334eeb88428ac to your computer and use it in GitHub Desktop.
A small wrapper around Cloudflared that creates a tunnel based on the given local and remote(optional) endpoints.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################################################################### | |
# A small wrapper around Cloudflared that creates # | |
# a tunnel based on the given local and remote(optional) endpoints. # | |
# License: https://unlicense.org/ # | |
########################################################################### | |
## Config | |
# Under Windows+WSL you'll want to use .exe here. | |
# Since that's what I use personally it's the default. | |
# Remove the '.exe' extension to use your native Linux cloudflared binary. | |
cloudflared_bin = "cloudflared.exe" | |
# (Or if you're feeling in an extra spicy mood, change it to "docker run --network host erisamoe/cloudflared") | |
# (But I don't really recommend that) | |
## End of config | |
## Actual code below. | |
# Just some small debug. | |
# Stole from https://github.com/askn/crystal-by-example/blob/master/command-line-args/argv.cr | |
ARGV.each_with_index {|arg, i| puts "Argument #{i}: #{arg}"} | |
# This used to error but then I had an EXCEPTIONAl idea. | |
if ARGV.size < 1 | |
puts "warn: I need at least one argument to do anything useful!" | |
puts "warn: Defaulting to a test Hello World server." | |
sleep 1 | |
local = "--hello-world" | |
else | |
local = "--url \'#{ARGV[0]}\'" | |
end | |
remote = ARGV[1] unless ARGV.size < 2 | |
if remote | |
`#{ENV["SHELL"]} -c '#{cloudflared_bin} --hostname \'#{remote}\' --url \'#{local}\''` | |
else | |
`#{ENV["SHELL"]} -c '#{cloudflared_bin} \'#{local}\''` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment