Skip to content
Snippets Groups Projects
Commit 44bb27b3 authored by Tom Herbers's avatar Tom Herbers Committed by Florian Maurer
Browse files

ff-mesh-vpn-tunneldigger: init

This is a dump of the former core package gluon-mesh-vpn-tunneldigger:

https://github.com/freifunk-gluon/gluon/tree/c2dc338abfbebb34dcf62124dc09be85fa88f8ef/package/gluon-mesh-vpn-tunneldigger

Only neccesary changes have been made.
parent 8d7065be
No related branches found
No related tags found
No related merge requests found
Showing with 132 additions and 0 deletions
include $(TOPDIR)/rules.mk
PKG_NAME:=ff-mesh-vpn-tunneldigger
PKG_VERSION:=0.0.1
PKG_RELEASE:=1
PKG_LICENSE:=BSD-2-Clause
include $(TOPDIR)/../package/gluon.mk
define Package/$(PKG_NAME)
TITLE:=Support for connecting meshes via tunneldigger/L2TPv3 pseudowire
DEPENDS:=+gluon-core +gluon-mesh-vpn-core +tunneldigger +simple-tc
endef
$(eval $(call BuildPackageGluon,$(PKG_NAME)))
# ff-mesh-vpn-tunneldigger
This package is based on the former core gluon package [gluon-mesh-vpn-tunneldigger](https://github.com/freifunk-gluon/gluon/tree/c2dc338abfbebb34dcf62124dc09be85fa88f8ef/package/gluon-mesh-vpn-tunneldigger).
It you want to keep using tunneldigger you need to take the following steps:
- `modules`: add this repo as described in the [README.md](../README.md#using-this-repository)
- `image-customization.lua`: remove the `mesh-vpn-tunneldigger` feature
- `image-customization.lua`: add the `config-mode-mesh-vpn` feature:
`features({'config-mode-mesh-vpn'})`
Not needed if you don't use the config mode or don't want to enable configuration of VPN settings via the config mode.
- `image-customization.lua`: add the `ff-mesh-vpn-tunneldigger` package:
`packages({'ff-mesh-vpn-tunneldigger'})`
need_string_array(in_domain({'mesh_vpn', 'tunneldigger', 'brokers'}))
need_number({'mesh_vpn', 'tunneldigger', 'mtu'})
#!/bin/sh
/etc/init.d/tunneldigger stop
#!/bin/sh
/etc/init.d/tunneldigger start
*/5 * * * * /usr/bin/tunneldigger-watchdog
#!/usr/bin/lua
local site = require 'gluon.site'
local util = require 'gluon.util'
local vpn_core = require 'gluon.mesh-vpn'
local uci = require('simple-uci').cursor()
uci:section('tunneldigger', 'broker', 'mesh_vpn', {
uuid = util.node_id(),
interface = vpn_core.get_interface(),
bind_interface = 'br-wan',
group = 'gluon-mesh-vpn',
broker_selection = 'usage',
address = site.mesh_vpn.tunneldigger.brokers(),
})
uci:save('tunneldigger')
#!/usr/bin/lua
local uci = require('simple-uci').cursor()
local function restart_tunneldigger()
os.execute('logger -t tunneldigger-watchdog "Restarting Tunneldigger."')
os.execute('/etc/init.d/tunneldigger restart')
end
local function has_mesh_vpn_neighbours()
local handle = io.popen('batctl o', 'r')
if not handle then
return false
end
for line in handle:lines() do
if line:find('mesh%-vpn') then
handle:close()
return true
end
end
handle:close()
return false
end
if uci:get_bool('tunneldigger', 'mesh_vpn', 'enabled') then
if not has_mesh_vpn_neighbours() then
os.execute('logger -t tunneldigger-watchdog "No vpn-mesh neighbours found."')
restart_tunneldigger()
return
end
end
local uci = require('simple-uci').cursor()
local site = require 'gluon.site'
local vpn_core = require 'gluon.mesh-vpn'
local M = {}
function M.public_key()
return nil
end
function M.enable(val)
uci:set('tunneldigger', 'mesh_vpn', 'enabled', val)
uci:save('tunneldigger')
end
function M.active()
return site.mesh_vpn.tunneldigger() ~= nil
end
function M.set_limit(ingress_limit, egress_limit)
if ingress_limit ~= nil then
uci:set('tunneldigger', 'mesh_vpn', 'limit_bw_down', ingress_limit)
else
uci:delete('tunneldigger', 'mesh_vpn', 'limit_bw_down')
end
if egress_limit ~= nil then
uci:section('simple-tc', 'interface', 'mesh_vpn', {
ifname = vpn_core.get_interface(),
enabled = true,
limit_egress = egress_limit,
})
else
uci:delete('simple-tc', 'mesh_vpn')
end
uci:save('tunneldigger')
uci:save('simple-tc')
end
function M.mtu()
return site.mesh_vpn.tunneldigger.mtu()
end
return M
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment