Initial VPN checkin
This commit is contained in:
parent
4a83028311
commit
5594b561e5
|
@ -61,7 +61,7 @@ You can run myNode on your own device in just a few easy steps!
|
|||
* Flash Downloaded Image
|
||||
3. Insert SD Card and Boot your Device
|
||||
4. Attach External HD to Device
|
||||
* 500GB+ Required, 1TB+ Recommended
|
||||
* 1TB+ Required
|
||||
5. Visit http://mynode.local/ or http://ip_of_device/
|
||||
|
||||
## Developing for myNode
|
||||
|
|
|
@ -27,3 +27,4 @@ LND_DATA_FOLDER = "/mnt/hdd/mynode/lnd/data/"
|
|||
ELECTRS_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_electrs_enabled"
|
||||
LNDHUB_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_lndhub_enabled"
|
||||
BTCRPCEXPLORER_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_btcrpceplorer_enabled"
|
||||
VPN_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_vpn_enabled"
|
||||
|
|
|
@ -27,3 +27,4 @@ LND_DATA_FOLDER = "/mnt/hdd/mynode/lnd/data/"
|
|||
ELECTRS_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_electrs_enabled"
|
||||
LNDHUB_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_lndhub_enabled"
|
||||
BTCRPCEXPLORER_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_btcrpceplorer_enabled"
|
||||
VPN_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_vpn_enabled"
|
||||
|
|
23
rootfs/standard/etc/systemd/system/vpn.service
Normal file
23
rootfs/standard/etc/systemd/system/vpn.service
Normal file
|
@ -0,0 +1,23 @@
|
|||
# myNode VPN Service
|
||||
# /etc/systemd/system/vpn.service
|
||||
|
||||
[Unit]
|
||||
Description=myNode VPN
|
||||
Wants=mynode.service
|
||||
After=mynode.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
KillMode=control-group
|
||||
TimeoutSec=60
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
ExecStart=/usr/bin/mynode_vpn.sh
|
||||
User=root
|
||||
Group=root
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog
|
||||
SyslogIdentifier=vpn
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -26,6 +26,7 @@ ufw allow 50194 comment 'VPN Access'
|
|||
ufw allow 56881 comment 'allow myNode QuickSync'
|
||||
ufw allow 51413 comment 'allow myNode QuickSync'
|
||||
ufw allow 6771 comment 'allow myNode QuickSync (LPD)'
|
||||
ufw allow 51194 comment 'allow VPN'
|
||||
ufw allow from 127.0.0.1 comment 'allow from localhost'
|
||||
ufw allow from ::1 comment 'allow from localhost'
|
||||
|
||||
|
|
1089
rootfs/standard/usr/bin/mynode_setup_vpn.sh
Executable file
1089
rootfs/standard/usr/bin/mynode_setup_vpn.sh
Executable file
File diff suppressed because it is too large
Load Diff
16
rootfs/standard/usr/bin/mynode_vpn.sh
Executable file
16
rootfs/standard/usr/bin/mynode_vpn.sh
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
apt -y update
|
||||
|
||||
while [ true ]; do
|
||||
if [ ! -f /home/pivpn/ovpns/mynode_vpn.ovpn ]; then
|
||||
/usr/bin/mynode_setup_vpn.sh
|
||||
|
||||
mkdir -p /home/pivpn/ovpns
|
||||
pivpn add -n mynode_vpn -p bolt -d 3650
|
||||
fi
|
||||
|
||||
systemctl enable openvpn
|
||||
systemctl start openvpn
|
||||
sleep 365d
|
||||
done
|
|
@ -26,3 +26,4 @@ LND_DATA_FOLDER = "/mnt/hdd/mynode/lnd/data/"
|
|||
ELECTRS_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_electrs_enabled"
|
||||
LNDHUB_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_lndhub_enabled"
|
||||
BTCRPCEXPLORER_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_btcrpceplorer_enabled"
|
||||
VPN_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_vpn_enabled"
|
||||
|
|
|
@ -54,3 +54,22 @@ def disable_btcrpcexplorer():
|
|||
#os.system("killall -9 electrs") # Hard kill since we are disabing
|
||||
os.system("systemctl stop btc_rpc_explorer --no-pager")
|
||||
os.system("systemctl disable btc_rpc_explorer --no-pager")
|
||||
|
||||
|
||||
def is_vpn_enabled():
|
||||
if os.path.isfile(VPN_ENABLED_FILE):
|
||||
return True
|
||||
return False
|
||||
|
||||
def enable_vpn():
|
||||
os.system("systemctl enable vpn --no-pager")
|
||||
os.system("systemctl start vpn --no-pager")
|
||||
open(VPN_ENABLED_FILE, 'a').close() # touch file
|
||||
|
||||
def disable_vpn():
|
||||
if os.path.isfile(VPN_ENABLED_FILE):
|
||||
os.remove(VPN_ENABLED_FILE)
|
||||
os.system("systemctl stop vpn --no-pager")
|
||||
os.system("systemctl disable vpn --no-pager")
|
||||
os.system("systemctl stop openvpn --no-pager")
|
||||
os.system("systemctl disable openvpn --no-pager")
|
||||
|
|
|
@ -197,6 +197,8 @@ def index():
|
|||
btcrpcexplorer_status = ""
|
||||
btcrpcexplorer_ready = False
|
||||
btcrpcexplorer_status_color = "gray"
|
||||
vpn_status_color = "gray"
|
||||
vpn_status = ""
|
||||
|
||||
if not get_has_updated_btc_info():
|
||||
message = "<div class='small_message'>{}</<div>".format( get_message(include_funny=True) )
|
||||
|
@ -314,6 +316,18 @@ def index():
|
|||
else:
|
||||
explorer_status = Markup("Bitcoin Explorer<br/><br/>Requires Electrum Server")
|
||||
|
||||
if is_vpn_enabled():
|
||||
status = os.system("systemctl status vpn --no-pager")
|
||||
if status != 0:
|
||||
vpn_status_color = "red"
|
||||
vpn_status = "Unknown"
|
||||
else:
|
||||
vpn_status_color = "green"
|
||||
if os.path.isfile("/home/pivpn/ovpns/mynode_vpn.ovpn"):
|
||||
vpn_status = "Running"
|
||||
else:
|
||||
vpn_status = "Setting up..."
|
||||
|
||||
# Check for new version of software
|
||||
upgrade_available = False
|
||||
current = get_current_version()
|
||||
|
@ -346,6 +360,9 @@ def index():
|
|||
"btcrpcexplorer_status_color": btcrpcexplorer_status_color,
|
||||
"btcrpcexplorer_status": btcrpcexplorer_status,
|
||||
"btcrpcexplorer_enabled": is_btcrpcexplorer_enabled(),
|
||||
"vpn_status_color": vpn_status_color,
|
||||
"vpn_status": vpn_status,
|
||||
"vpn_enabled": is_vpn_enabled(),
|
||||
"product_key_skipped": pk_skipped,
|
||||
"product_key_error": pk_error,
|
||||
"drive_usage": get_drive_usage(),
|
||||
|
@ -398,6 +415,36 @@ def page_product_key():
|
|||
|
||||
return "Error"
|
||||
|
||||
@app.route("/vpn-info")
|
||||
def page_vpn_info():
|
||||
|
||||
message = ""
|
||||
if request.args.get('error_message'):
|
||||
message = Markup("<div class='error_message'>"+request.args.get('error_message')+"</div>")
|
||||
if request.args.get('success_message'):
|
||||
message = Markup("<div class='success_message'>"+request.args.get('success_message')+"</div>")
|
||||
|
||||
status = "Setting up..."
|
||||
if os.path.isfile("/home/pivpn/ovpns/mynode_vpn.ovpn"):
|
||||
status = "Running"
|
||||
templateData = {
|
||||
"title": "myNode VPN Info",
|
||||
"status": status,
|
||||
"message": message,
|
||||
"port": "51194"
|
||||
}
|
||||
return render_template('vpn_info.html', **templateData)
|
||||
|
||||
@app.route("/mynode.ovpn", methods=["POST"])
|
||||
def page_download_ovpn():
|
||||
p = pam.pam()
|
||||
pw = request.form.get('password_download_ovpn')
|
||||
if pw == None or p.authenticate("admin", pw) == False:
|
||||
return redirect(url_for(".page_vpn_info", error_message="Invalid Password"))
|
||||
|
||||
# Download ovpn
|
||||
return send_from_directory(directory="/home/pivpn/ovpns/", filename="mynode_vpn.ovpn")
|
||||
|
||||
|
||||
@app.route("/toggle-lndhub")
|
||||
def page_toggle_lndhub():
|
||||
|
@ -423,6 +470,14 @@ def page_toggle_btcrpcexplorer():
|
|||
enable_btcrpcexplorer()
|
||||
return redirect("/")
|
||||
|
||||
@app.route("/toggle-vpn")
|
||||
def page_toggle_vpn():
|
||||
if is_vpn_enabled():
|
||||
disable_vpn()
|
||||
else:
|
||||
enable_vpn()
|
||||
return redirect("/")
|
||||
|
||||
@app.route("/about")
|
||||
def page_about():
|
||||
return render_template('about.html')
|
||||
|
|
BIN
rootfs/standard/var/www/mynode/static/images/vpn.png
Normal file
BIN
rootfs/standard/var/www/mynode/static/images/vpn.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
|
@ -1,3 +1,4 @@
|
|||
<div class="main_header">Apps</div>
|
||||
<div class="app_tile_row">
|
||||
<div class="app_tile">
|
||||
<div class="app_status_icon {{ rtl_status_color }}"></div>
|
||||
|
@ -61,6 +62,17 @@
|
|||
<a class="ui-button ui-widget ui-corner-all mynode_button" href="#" id="toggle-btcrpcexplorer">{% if btcrpcexplorer_enabled %}Disable{% else %}Enable{% endif %}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="app_tile">
|
||||
<div class="app_status_icon"></div>
|
||||
<div class="app_logo"><img class="app_logo_icon" src="{{ url_for('static', filename="images/cli.png")}}"/></div>
|
||||
<div class="app_title">BTC CLI</div>
|
||||
<div class="app_status"></div>
|
||||
<div class="app_contents"><a class="ui-button ui-widget ui-corner-all mynode_button" href="/bitcoin-cli">CLI</a></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="main_header">Services</div>
|
||||
<div class="app_tile_row">
|
||||
<div class="app_tile">
|
||||
<div class="app_status_icon {{ electrs_status_color }}"></div>
|
||||
<div class="app_logo"><img class="app_logo_icon" src="{{ url_for('static', filename="images/electrum_logo.png")}}"/></div>
|
||||
|
@ -74,10 +86,19 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="app_tile">
|
||||
<div class="app_status_icon"></div>
|
||||
<div class="app_logo"><img class="app_logo_icon" src="{{ url_for('static', filename="images/cli.png")}}"/></div>
|
||||
<div class="app_title">BTC CLI</div>
|
||||
<div class="app_status"></div>
|
||||
<div class="app_contents"><a class="ui-button ui-widget ui-corner-all mynode_button" href="/bitcoin-cli">CLI</a></div>
|
||||
<div class="app_status_icon {{ vpn_status_color }}"></div>
|
||||
<div class="app_logo"><img class="app_logo_icon" src="{{ url_for('static', filename="images/vpn.png")}}"/></div>
|
||||
<div class="app_title">VPN</div>
|
||||
<div class="app_status">{{ vpn_status }}</div>
|
||||
<div class="app_contents">
|
||||
{% if product_key_skipped %}
|
||||
Premium Feature
|
||||
{% else %}
|
||||
{% if vpn_enabled %}
|
||||
<a class="ui-button ui-widget ui-corner-all mynode_button" href="/vpn-info">Info</a>
|
||||
{% endif %}
|
||||
<a class="ui-button ui-widget ui-corner-all mynode_button" href="#" id="toggle-vpn">{% if vpn_enabled %}Disable{% else %}Enable{% endif %}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -15,6 +15,7 @@
|
|||
$(document).ready(function() {
|
||||
electrs_enabled = {% if electrs_enabled %}1{% else %}0{% endif %}
|
||||
lndhub_enabled = {% if lndhub_enabled %}1{% else %}0{% endif %}
|
||||
vpn_enabled = {% if vpn_enabled %}1{% else %}0{% endif %}
|
||||
|
||||
$("#lndhub").on("click", function() {
|
||||
url = location.protocol+'//'+location.hostname+':3000'
|
||||
|
@ -58,6 +59,28 @@
|
|||
return false
|
||||
});
|
||||
|
||||
$("#toggle-vpn").on("click", function() {
|
||||
if (vpn_enabled)
|
||||
{
|
||||
// Disable vpn
|
||||
window.location.href="/toggle-vpn"
|
||||
}
|
||||
else
|
||||
{
|
||||
// Enable vpn
|
||||
var okFunction = function() {
|
||||
window.location.href="/toggle-vpn"
|
||||
}
|
||||
openConfirmDialog("confirm-dialog",
|
||||
"Enable VPN",
|
||||
"Enabling VPN will set your IP to a static IP rather than a dynamic one via DHCP. \
|
||||
The initial setup may take a couple hours.<br/><br/> \
|
||||
Would you like to enable VPN?",
|
||||
okFunction)
|
||||
}
|
||||
return false
|
||||
});
|
||||
|
||||
$("#toggle-btcrpcexplorer").on("click", function() {
|
||||
window.location.href="/toggle-btcrpcexplorer"
|
||||
});
|
||||
|
@ -111,7 +134,6 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="main_header">Apps</div>
|
||||
{% include 'includes/apps_standard.html' %}
|
||||
|
||||
{% if product_key_skipped %}
|
||||
|
|
95
rootfs/standard/var/www/mynode/templates/vpn_info.html
Normal file
95
rootfs/standard/var/www/mynode/templates/vpn_info.html
Normal file
|
@ -0,0 +1,95 @@
|
|||
<!DOCTYPE html lang="en">
|
||||
<head>
|
||||
<title>{{ title }}</title>
|
||||
<link rel="shortcut icon" href="{{ url_for('static', filename='images/favicon.ico') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename="css/mynode.css")}}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename="css/mynode_bitcoind.css")}}">
|
||||
<link href="{{ url_for('static', filename="jquery_ui/jquery-ui.css")}}" rel="stylesheet">
|
||||
<meta http-equiv="Content-Language" content="en">
|
||||
<meta name="google" content="notranslate">
|
||||
<script src="{{ url_for('static', filename="js/jquery-3.3.1.min.js")}}"></script>
|
||||
<script src="{{ url_for('static', filename="jquery_ui/jquery-ui.js")}}"></script>
|
||||
<script src="{{ url_for('static', filename="js/mynode.js")}}"></script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
function downloadOvpn() {
|
||||
$("#download_ovpn_form").submit();
|
||||
download_ovpn_dialog.dialog( "close" );
|
||||
}
|
||||
download_ovpn_dialog = $( "#download-ovpn-dialog" ).dialog({
|
||||
autoOpen: false,
|
||||
resizable: false,
|
||||
height: "auto",
|
||||
width: 600,
|
||||
modal: true,
|
||||
position: { my: "center top", at: "center top", of: window, collision: "none" },
|
||||
buttons: {
|
||||
"Download": downloadOvpn,
|
||||
Cancel: function() {
|
||||
download_ovpn_dialog.dialog( "close" );
|
||||
}
|
||||
},
|
||||
open: function() {
|
||||
$("#password_download_ovpn").val("")
|
||||
}
|
||||
});
|
||||
$("#download_ovpn").on("click", function() {
|
||||
download_ovpn_dialog.dialog( "open" );
|
||||
});
|
||||
$("#download_ovpn_form").on("submit", function() {
|
||||
download_ovpn_dialog.dialog( "close" );
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="logo_header"><a href="/"><img class="logo_image" src="{{ url_for('static', filename="images/logo.png")}}"/></a></div>
|
||||
<div class="mynode_back_div">
|
||||
<a class="ui-button ui-widget ui-corner-all mynode_back" href="/"><span class="ui-icon ui-icon-home"></span>home </a>
|
||||
</div>
|
||||
|
||||
<div style="margin: auto; text-align: center;">
|
||||
{{ message }}
|
||||
</div>
|
||||
|
||||
<div class="main_header">VPN Status</div>
|
||||
<br/>
|
||||
|
||||
<div class="app_tile_row">
|
||||
<div class="info_tile">
|
||||
<div class="info_tile_header">Status</div>
|
||||
<div class="info_tile_contents">{{status}}</div>
|
||||
</div>
|
||||
<div class="info_tile">
|
||||
<div class="info_tile_header">VPN Port</div>
|
||||
<div class="info_tile_contents">{{port}}</div>
|
||||
</div>
|
||||
<div class="info_tile">
|
||||
<div class="info_tile_header">Download OVPN File</div>
|
||||
<div class="info_tile_contents">
|
||||
<a class="ui-button ui-widget ui-corner-all mynode_button_small" id="download_ovpn" style="width: 70%;" href="#">download</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="download-ovpn-dialog" title="Download OVPN File" style="display:none;">
|
||||
<form id="download_ovpn_form" name="download_ovpn_form" action="/mynode.ovpn" method="POST">
|
||||
<p>The OVPN file is required to connect to your device remotely with Open VPN. Do not share this with others or
|
||||
they will be able to access your myNode device and your network.</p>
|
||||
<p>Please enter your password to download your OVPN file.</p>
|
||||
<b>Password:</b>
|
||||
<br/>
|
||||
<input type="password" name="password_download_ovpn" id="password_download_ovpn" value="" class="text ui-widget-content ui-corner-all">
|
||||
|
||||
<!-- Allow form submission with keyboard without duplicating the dialog button -->
|
||||
<input type="submit" tabindex="-1" style="position:absolute; top:-1000px">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% include 'includes/footer.html' %}
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user