View random ngrok URL when run in background

前端 未结 12 1707
旧时难觅i
旧时难觅i 2021-02-02 08:16

When I start an ngrok client with ./ngrok tcp 22 it runs in the foreground and I can see the randoming generated forwarding URL, such as tcp://0.tcp.ngrok.io:

12条回答
  •  迷失自我
    2021-02-02 08:33

    In Ruby

    require 'httparty'
    
    # get ngrok public url
    begin
      response = HTTParty.get 'http://localhost:4040/api/tunnels'
      json = JSON.parse response.body
      new_sms_url = json['tunnels'].first['public_url']
    rescue Errno::ECONNREFUSED
      print 'no ngrok instance found. shutting down'
      exit
    end
    

提交回复
热议问题