Skip to content

Instantly share code, notes, and snippets.

@jcmfernandes
Last active January 18, 2019 18:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jcmfernandes/cb624baee8953f60e97a1167a5557dc8 to your computer and use it in GitHub Desktop.
Save jcmfernandes/cb624baee8953f60e97a1167a5557dc8 to your computer and use it in GitHub Desktop.
[Unit]
Description=Share local port(s) with ngrok
After=syslog.target network.target
[Service]
PrivateTmp=true
Type=simple
Restart=always
RestartSec=1min
StandardOutput=null
StandardError=null
ExecStart=/opt/ngrok/ngrok start --config /opt/ngrok/ngrok.yml --all
ExecStop=/usr/bin/killall ngrok
[Install]
WantedBy=multi-user.target
authtoken:
region: eu
json_resolver_url: ""
dns_resolver_ips: []
console_ui: false
log_level: info
log_format: logfmt
log: /opt/ngrok/ngrok.log
web_addr: localhost:4040
update: false
tunnels:
ssh:
addr: 22
proto: tcp
#!/bin/bash
# https://tinyurl.com/w-tunnels
GIST_FILENAME='w-tunnels.json'
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
set -ex
TMPFILE=$(mktemp)
echo '$GIST_FILENAME_RUBY =' \'${GIST_FILENAME}\' >> $TMPFILE
cat <<-RUBY >> $TMPFILE
require 'open-uri'
require 'json'
tunnels = JSON.parse(open('http://localhost:4040/api/tunnels').read)
tunnels.merge!(updated_at: Time.now.utc.to_s)
IO.write(\$GIST_FILENAME_RUBY, JSON.pretty_generate(tunnels))
RUBY
ruby ${TMPFILE}
rm ${TMPFILE}
git add -u
git commit --allow-empty-message -m ''
git checkout --orphan new-master master
git commit --allow-empty-message -m ''
git branch -M new-master master
git push -f
git gc
{
"tunnels": [
{
"name": "ssh",
"uri": "/api/tunnels/ssh",
"public_url": "tcp://0.tcp.eu.ngrok.io:16858",
"proto": "tcp",
"config": {
"addr": "localhost:22",
"inspect": false
},
"metrics": {
"conns": {
"count": 4,
"gauge": 0,
"rate1": 9.52852247585503e-196,
"rate5": 7.486761581971751e-42,
"rate15": 1.4551065405658382e-16,
"p50": 316628573733,
"p90": 600102170608,
"p95": 600102170608,
"p99": 600102170608
},
"http": {
"count": 0,
"rate1": 0,
"rate5": 0,
"rate15": 0,
"p50": 0,
"p90": 0,
"p95": 0,
"p99": 0
}
}
}
],
"uri": "/api/tunnels",
"updated_at": "2019-01-18 18:35:01 UTC"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment