commit
61c300c393
|
@ -17,7 +17,7 @@ LNBITS_DEFAULT_WALLET_NAME="LNbits wallet"
|
|||
LNBITS_DATA_FOLDER="./data"
|
||||
# LNBITS_DATABASE_URL="postgres://user:password@host:port/databasename"
|
||||
|
||||
LNBITS_DISABLED_EXTENSIONS="amilk"
|
||||
LNBITS_DISABLED_EXTENSIONS="amilk,ngrok"
|
||||
LNBITS_FORCE_HTTPS=true
|
||||
LNBITS_SERVICE_FEE="0.0"
|
||||
|
||||
|
|
20
lnbits/extensions/ngrok/README.md
Normal file
20
lnbits/extensions/ngrok/README.md
Normal file
|
@ -0,0 +1,20 @@
|
|||
<h1>Ngrok</h1>
|
||||
<h2>Serve lnbits over https for free using ngrok</h2>
|
||||
|
||||
<img src="https://i.ibb.co/QfDD4FS/Screenshot-2021-07-02-7-28-35-AM.png">
|
||||
|
||||
<h2>How it works</h2>
|
||||
|
||||
When enabled, ngrok creates a tunnel to ngrok.io with https support and tells you the https web address where you can access your lnbits instance. If you are not the first user to enable it, it doesn't create a new one, it just tells you the existing one. Useful for creating/managing/using lnurls, which must be served either via https or via tor. Note that if you restart your device, your device will generate a new url. If anyone is using your old one for wallets, lnurls, etc., whatever they are doing will stop working.
|
||||
|
||||
<h2>Installation</h2>
|
||||
|
||||
Check the Extensions page on your instance of lnbits. If you have copy of lnbits with ngrok as one of the built in extensions, click Enable -- that's the only thing you need to do to install it.
|
||||
|
||||
If your copy of lnbits does not have ngrok as one of the built in extensions, stop lnbits, create go into your lnbits folder, and run this command: ./venv/bin/pip install pyngrok. Then go into the lnbits subdirectory and the extensions subdirectory within that. (So lnbits > lnbits > extensions.) Create a new subdirectory in there called freetunnel, download this repository as a zip file, and unzip it in the freetunnel directory. If your unzipper creates a new "freetunnel" subdirectory, take everything out of there and put it in the freetunnel directory you created. Then go back to the top level lnbits directory and run these commands:
|
||||
|
||||
```
|
||||
./venv/bin/quart assets
|
||||
./venv/bin/quart migrate
|
||||
./venv/bin/hypercorn -k trio --bind 0.0.0.0:5000 'lnbits.app:create_app()'
|
||||
```
|
8
lnbits/extensions/ngrok/__init__.py
Normal file
8
lnbits/extensions/ngrok/__init__.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
from quart import Blueprint
|
||||
from lnbits.db import Database
|
||||
|
||||
db = Database("ext_ngrok")
|
||||
|
||||
ngrok_ext: Blueprint = Blueprint("ngrok", __name__, template_folder="templates")
|
||||
|
||||
from .views import * # noqa
|
1
lnbits/extensions/ngrok/__pycache__/.gitkeep
Normal file
1
lnbits/extensions/ngrok/__pycache__/.gitkeep
Normal file
|
@ -0,0 +1 @@
|
|||
|
6
lnbits/extensions/ngrok/config.json
Normal file
6
lnbits/extensions/ngrok/config.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "Ngrok",
|
||||
"short_description": "Serve lnbits over https for free using ngrok",
|
||||
"icon": "trip_origin",
|
||||
"contributors": ["supertestnet"]
|
||||
}
|
11
lnbits/extensions/ngrok/migrations.py
Normal file
11
lnbits/extensions/ngrok/migrations.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
# async def m001_initial(db):
|
||||
|
||||
# await db.execute(
|
||||
# """
|
||||
# CREATE TABLE example.example (
|
||||
# id TEXT PRIMARY KEY,
|
||||
# wallet TEXT NOT NULL,
|
||||
# time TIMESTAMP NOT NULL DEFAULT """ + db.timestamp_now + """
|
||||
# );
|
||||
# """
|
||||
# )
|
53
lnbits/extensions/ngrok/templates/ngrok/index.html
Normal file
53
lnbits/extensions/ngrok/templates/ngrok/index.html
Normal file
|
@ -0,0 +1,53 @@
|
|||
{% extends "base.html" %} {% from "macros.jinja" import window_vars with context
|
||||
%} {% block page %}
|
||||
|
||||
<div class="row q-col-gutter-md">
|
||||
<div class="col-12 col-lg-7 q-gutter-y-md">
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<h5 class="text-subtitle1 q-mt-none q-mb-md">
|
||||
Access this lnbits instance at the following url
|
||||
</h5>
|
||||
<q-separator class="q-my-lg"></q-separator>
|
||||
<p><a href="{{ ngrok }}" target="_blank">{{ ngrok }}</a></p>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-md-5 q-gutter-y-md">
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<h6 class="text-subtitle1 q-my-none">Ngrok extension</h6>
|
||||
</q-card-section>
|
||||
<q-card-section class="q-pa-none">
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<p>
|
||||
Note that if you restart your device, your device will generate a
|
||||
new url. If anyone is using your old one for wallets, lnurls,
|
||||
etc., whatever they are doing will stop working.
|
||||
</p>
|
||||
<small
|
||||
>Created by
|
||||
<a href="https://github.com/supertestnet" target="_blank"
|
||||
>Supertestnet</a
|
||||
>.</small
|
||||
>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}{% block scripts %} {{ window_vars(user) }}
|
||||
<script>
|
||||
new Vue({
|
||||
el: '#vue',
|
||||
mixins: [windowMixin],
|
||||
data: function () {
|
||||
return {}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
28
lnbits/extensions/ngrok/views.py
Normal file
28
lnbits/extensions/ngrok/views.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
from quart import g, render_template
|
||||
|
||||
from lnbits.decorators import check_user_exists, validate_uuids
|
||||
|
||||
from pyngrok import conf, ngrok
|
||||
from . import ngrok_ext
|
||||
|
||||
|
||||
def log_event_callback(log):
|
||||
string = str(log)
|
||||
string2 = string[string.find('url="https') : string.find('url="https') + 40]
|
||||
if string2:
|
||||
string3 = string2
|
||||
string4 = string3[4:]
|
||||
global string5
|
||||
string5 = string4.replace('"', "")
|
||||
|
||||
|
||||
conf.get_default().log_event_callback = log_event_callback
|
||||
|
||||
ngrok_tunnel = ngrok.connect(5000)
|
||||
|
||||
|
||||
@ngrok_ext.route("/")
|
||||
@validate_uuids(["usr"], required=True)
|
||||
@check_user_exists()
|
||||
async def index():
|
||||
return await render_template("ngrok/index.html", ngrok=string5, user=g.user)
|
|
@ -27,6 +27,7 @@ marshmallow==3.11.1
|
|||
outcome==1.1.0
|
||||
priority==1.3.0
|
||||
pydantic==1.8.1
|
||||
pyngrok==5.0.5
|
||||
pypng==0.0.20
|
||||
pyqrcode==1.2.1
|
||||
pyscss==1.3.7
|
||||
|
|
Loading…
Reference in New Issue
Block a user