Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2c94831
Add a filter function to enable bindhost to be device name, instead o…
Apr 7, 2016
cba3257
Merge remote-tracking branch 'upstream/master'
markfoodyburton Dec 14, 2016
42b3f4c
Change in wrr.c to choose the tunnel more 'optimally' (and consider t…
markfoodyburton Dec 14, 2016
8168407
Use non-blocking flags for the tuntap file descriptor
markfoodyburton Dec 14, 2016
add22de
Add the 'weight' of tunnels to the control output so that it can be m…
markfoodyburton Dec 14, 2016
566b4ce
Better calculate 'losses' for tunnels, based on a huristic that if a …
markfoodyburton Dec 14, 2016
3260cde
Add an 'average' srtt to ease calculations
markfoodyburton Dec 14, 2016
7ff5866
Check for valid timestamp when calculating SRTT
Dec 16, 2016
ec83014
Mechanism to allocate bandwidth based on a quota system, priority, ba…
May 16, 2018
b995193
Merge branch 'master' of https://github.com/markfoodyburton/MLVPN
May 16, 2018
c09a986
fix for float/int error
May 16, 2018
0953686
added a way to preset the permitted value, and also fixed up the weig…
May 19, 2018
1f73154
fixed bug in chooser
May 19, 2018
71bd0c1
share non-quote tunnels
May 19, 2018
33baf54
start of new reorder mechanism, which should not rely on srtt timeouts
May 21, 2018
91b9586
bug
May 21, 2018
319b56c
ibetter reorder
May 21, 2018
453f6a6
improve reorder, andmake it adjust automatically
May 22, 2018
81b130b
minor
May 22, 2018
6d9ab70
limit the list order length for reordering
May 28, 2018
65531b9
add permitted data to netdata
May 28, 2018
905d229
Merge branch 'master' of https://github.com/markfoodyburton/MLVPN
May 28, 2018
418de3f
fix wrap round issue in netdata
May 29, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 62 additions & 2 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <ifaddrs.h>

#include "includes.h"
#include "mlvpn.h"
Expand All @@ -36,6 +37,11 @@ extern struct mlvpn_filters_s mlvpn_filters;
extern struct tuntap_s tuntap;
extern struct mlvpn_reorder_buffer *reorder_buffer;

char *ip_from_if(char *ifname);
// we'll declair this here, so that any device name used instead of an IP
// address gets translated before we go anywhere else...


/* Config file reading / re-read.
* config_file_fd: fd opened in priv_open_config
* first_time: set to 0 for re-read, or 1 for initial configuration
Expand Down Expand Up @@ -273,6 +279,7 @@ mlvpn_config(int config_file_fd, int first_time)
char *dstaddr;
char *dstport;
uint32_t bwlimit = 0;
uint32_t quota = 0;
uint32_t timeout = 30;
uint32_t loss_tolerence;
int create_tunnel = 1;
Expand Down Expand Up @@ -311,9 +318,16 @@ mlvpn_config(int config_file_fd, int first_time)
config, lastSection, "remoteport", &dstport, NULL,
"No remote port specified.\n", 1);
}

bindaddr=ip_from_if(bindaddr);


_conf_set_uint_from_conf(
config, lastSection, "bandwidth_upload", &bwlimit, 0,
NULL, 0);
_conf_set_uint_from_conf(
config, lastSection, "quota", &quota, 0,
NULL, 0);
_conf_set_uint_from_conf(
config, lastSection, "timeout", &timeout, default_timeout,
NULL, 0);
Expand Down Expand Up @@ -372,10 +386,16 @@ mlvpn_config(int config_file_fd, int first_time)
}
if (tmptun->bandwidth != bwlimit)
{
log_info("config", "%s bandwidth changed from %d to %d",
log_info("config", "%s bandwidth changed from %d to %d",
tmptun->name, tmptun->bandwidth, bwlimit);
tmptun->bandwidth = bwlimit;
}
if (tmptun->quota != quota)
{
log_info("config", "%s quota changed from %d to %d",
tmptun->name, tmptun->quota, quota);
tmptun->quota = quota;
}
if (tmptun->loss_tolerence != loss_tolerence)
{
log_info("config", "%s loss tolerence changed from %d%% to %d%%",
Expand All @@ -393,7 +413,7 @@ mlvpn_config(int config_file_fd, int first_time)
mlvpn_rtun_new(
lastSection, bindaddr, bindport, bindfib, dstaddr, dstport,
default_server_mode, timeout, fallback_only,
bwlimit, loss_tolerence);
bwlimit, loss_tolerence, quota);
}
if (bindaddr)
free(bindaddr);
Expand Down Expand Up @@ -486,3 +506,43 @@ mlvpn_config(int config_file_fd, int first_time)
log_warnx("config", "parse error");
return 1;
}


/* This is a filter function, it takes an name, if the name turns out to be an
* interface, it translates it to it's IP address,
* the resulting filtered name is returned (whether it has matched an interface
* or not */
char *ip_from_if(char *ifname)
{

struct ifaddrs *ifaddr, *ifa;
int s;
char host[NI_MAXHOST];

if (getifaddrs(&ifaddr) == -1)
{
log_warn(NULL, "unable to collect ifaddrs");
return ifname;
}


for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next)
{
if (ifa->ifa_addr == NULL)
continue;

s=getnameinfo(ifa->ifa_addr,sizeof(struct sockaddr_in),host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);

if((strcmp(ifa->ifa_name,ifname)==0)&&(ifa->ifa_addr->sa_family==AF_INET))
{
if (s == 0)
{
if (ifname) free(ifname);
ifname = strdup(host);
}
}
}

freeifaddrs(ifaddr);
return ifname;
}
6 changes: 5 additions & 1 deletion src/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ void mlvpn_control_write_status(struct mlvpn_control *ctrl);
" \"bandwidth\": %u,\n" \
" \"srtt\": %u,\n" \
" \"loss\": %u,\n" \
" \"permitted\": %u,\n" \
" \"disconnects\": %u,\n" \
" \"last_packet\": %u,\n" \
" \"timeout\": %u\n" \
" \"timeout\": %u,\n" \
" \"weight\": %.3f\n" \
"}%s\n"
#define JSON_STATUS_ERROR_UNKNOWN_COMMAND "{\"error\": 'unknown command'}\n"

Expand Down Expand Up @@ -428,9 +430,11 @@ void mlvpn_control_write_status(struct mlvpn_control *ctrl)
0,
(uint32_t)t->srtt,
mlvpn_loss_ratio(t),
(uint32_t)(t->permitted/1000000),
t->disconnects,
(uint32_t)t->last_activity,
(uint32_t)t->timeout,
t->weight,
(LIST_NEXT(t, entries) ? "," : "")
);
mlvpn_control_write(ctrl, buf, ret);
Expand Down
Loading