Tunzal -- Expose local endpoints at minimum cost

in #blockstack5 years ago

What is it

Tunzal is a tunneling solution to expose local endpoint outside of the private network. User can use subdomains of tunzal.ml as their public endpoint. The request coming to the public endpoint will be reverse proxied to local services running on their system. This service is similar to ngrok or agro from Cloudflare. Here, we enable users to use their desired subdomain for a premium fee. The premium feature is available for a cost on hr, day, month or year basis.

Here we have tried to move from subscription-based model to usage-based model, by allowing the users to get refunded if they like to discontinue the service or they no longer need it. This is enabled by using the lightning network and its unique feature of enabling micropayment. Currently, in the lightning network, if we want to send the payment to the recipient then firstly recipient has to generate the invoice with the amount specified. Apart from cost specified invoices, the lightning network allows one to generate zero amount invoice. Using zero amount invoice, one can send any amount to the recipient. We have used this to implement a refund mechanism in our service. While generating a secret token for our service, users can specify the zero amount invoice. So, when the user raises the request for a refund, the bitcoin will be transferred back to the user via this invoice. The amount for refund is determined by subtracting usage time in minutes from the total amount(in satoshis) paid for service.

Now for an example: if the user purchases plan A for 1 hr with 60 satoshis. If he uses our service for 20 minutes and raises the request within 60 minutes time frame then he is refunded 40 satoshis. Though if he misses this time frame, no refund is provided. This is because, when generating an invoice, expiration time must be specified. As a result, when generating the zero amount invoice(ZCI) if the user-specified 60*60 seconds then that invoice is only valid for one hr. So, here we assume the expiration of ZCI to be equal to the selected PLAN duration.

The dashboard is available at https://tunzal.ml.

gallery.jpg

How I built it

  • For lightning network node, we are using lnd implementation from lightninglabs.
  • Neutrino client for connecting with blockchain layer.
  • For generating the subdomains of tunzal.ml we are using DNS zone of azure nameservers.
  • The backend API server is connected to mongo for token storage, and execs grpc on the lnd.

sequence_diagram.png

  • Authentication to the dashboard is via blockstack OAuth.
  • Generating token, buying a plan, activating token and getting refunded is done via the dashboard.
  • Once a token is activated, the user can download the tunzal client software from our website. And run client software as shown below:
    inlets client --upstream node1.tunza.ml=<local-endpoint> -t <api-token>
  • After usage, a refund request can be raised on dashboard.
Sort:  

Congratulations @elliotyagami! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You published more than 40 posts. Your next target is to reach 50 posts.

You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.27
TRX 0.13
JST 0.032
BTC 62900.77
ETH 2949.76
USDT 1.00
SBD 3.59