cf92ac7a0c
1.Subfolders in the Config/ directory now show up as submenus. 2.Added a way to run TunSafe as a Windows Service. Foreground Mode: The service will disconnect when TunSafe closes. Background Mode: The service will stay connected in the background. No longer required to run the TunSafe client as Admin as long as the service is running. 3.New config setting [Interface].ExcludedIPs to configure IPs that should not be routed through TunSafe. 4.Can now automatically start TunSafe when Windows starts 5.New UI with tabs and graphs 6.Cache DNS queries to ensure DNS will succeed if connection fails 7.Recreate tray icon when explorer.exe restarts 8.Renamed window title to TunSafe instead of TunSafe VPN Client 9.Main window is now resizable 10.Disallow roaming endpoint when using AllowedIPs=0.0.0.0/0 Only the original endpoint is added in the routing table so this would result in an endless loop of packets. 11.Display approximate Wireguard framing overhead in stats 12.Preparations for protocol handling with multiple threads 13.Delete the routes we made when disconnecting 14.Fix error message about unable to delete a route when connecting
41 lines
1,005 B
C++
41 lines
1,005 B
C++
// SPDX-License-Identifier: AGPL-1.0-only
|
|
// Copyright (C) 2018 Ludvig Strigeus <info@tunsafe.com>. All Rights Reserved.
|
|
#pragma once
|
|
|
|
#include "tunsafe_types.h"
|
|
#include <vector>
|
|
|
|
// Maps CIDR addresses to a peer, always returning the longest match
|
|
// Slow O(n) implementation
|
|
class IpToPeerMap {
|
|
public:
|
|
IpToPeerMap();
|
|
~IpToPeerMap();
|
|
|
|
// Inserts an IP address of a given CIDR length into the lookup table, pointing to peer.
|
|
bool InsertV4(const void *addr, int cidr, void *peer);
|
|
bool InsertV6(const void *addr, int cidr, void *peer);
|
|
|
|
// Lookup the peer matching the IP Address
|
|
void *LookupV4(uint32 ip);
|
|
void *LookupV6(const void *addr);
|
|
|
|
void *LookupV4DefaultPeer();
|
|
void *LookupV6DefaultPeer();
|
|
|
|
// Remove a peer from the table
|
|
void RemovePeer(void *peer);
|
|
private:
|
|
struct Entry4 {
|
|
uint32 ip;
|
|
uint32 mask;
|
|
void *peer;
|
|
};
|
|
struct Entry6 {
|
|
uint8 ip[16];
|
|
uint8 cidr_len;
|
|
void *peer;
|
|
};
|
|
std::vector<Entry4> ipv4_;
|
|
std::vector<Entry6> ipv6_;
|
|
};
|