Home
Softono
gonnel

gonnel

Open source BSD-2-Clause Go
22
Stars
5
Forks
0
Issues
2
Watchers
4 years
Last Commit

About gonnel

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.

Platforms

Web Self-hosted

Languages

Go

Links

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

Examples:

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