Skip to content

Package gonnel provides direct API tunnel using code. this project inspired from ngrok wrapper node.js that using EventEmitter. The Client package intended to handle all function that provided from binary like using auth token or create a tunnel.

License

afdalwahyu/gonnel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gonnel

Go Report Card GoDoc

>Golang wrapper for ngrok. Expose your localhost to the internet.

Tested on linux, hopefully supports Mac, Windows, and Linux

Installation

  • Download ngrok binary file
  • Install package
go get github.com/afdalwahyu/gonnel

Update

go get -u github.com/afdalwahyu/gonnel

Create client & tunnel

package main

import (
	"fmt"
	"github.com/afdalwahyu/gonnel"
	"bufio"
	"os"
)

func main() {
	client, err := gonnel.NewClient(gonnel.Options{
		BinaryPath: "../ngrok-bin/ngrok_linux",
	})
	if err != nil {
		fmt.Println(err)
	}
	defer client.Close()

	done := make(chan bool)
	go client.StartServer(done)
	<-done

	client.AddTunnel(&gonnel.Tunnel{
		Proto:        gonnel.HTTP,
		Name:         "awesome",
		LocalAddress: "127.0.0.1:4040",
		Auth:         "username:password",
	})

	client.ConnectAll()

	fmt.Print("Press any to disconnect")
	reader := bufio.NewReader(os.Stdin)
	reader.ReadRune()

	client.DisconnectAll()
}

How it works

Inspired from node.js wrapper that use ngrok binary, run it and use client api to create or close tunnel

About

Package gonnel provides direct API tunnel using code. this project inspired from ngrok wrapper node.js that using EventEmitter. The Client package intended to handle all function that provided from binary like using auth token or create a tunnel.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages