45 lines
949 B
C++
45 lines
949 B
C++
#include "wireguard/wgcpp.hpp"
|
|
#include <cstdio>
|
|
|
|
int main(void) {
|
|
Users users;
|
|
WG wg(users, "wgdev1", 51820, 0xc0a80000,24);
|
|
User &user = wg.add_cfg("Test");
|
|
if (user.ipv4 != 0xc0a80002) {
|
|
return 1;
|
|
}
|
|
wg.merge();
|
|
for (auto stat : *wg.peer_state()) {
|
|
printf("%d %x %s\n", stat.active, stat.ipv4, stat.pubkey);
|
|
}
|
|
|
|
printf("user2,4 append\n");
|
|
|
|
User &user2 = wg.add_cfg("Test2");
|
|
if (user2.ipv4 != 0xc0a80003) {
|
|
return 1;
|
|
}
|
|
|
|
User &user4 = wg.add_cfg("Test4", 0xc0a80005);
|
|
if (user4.ipv4 != 0xc0a80005) {
|
|
return 1;
|
|
}
|
|
|
|
wg.merge();
|
|
for (auto stat : *wg.peer_state()) {
|
|
printf("%d %x %s\n", stat.active, stat.ipv4, stat.pubkey);
|
|
}
|
|
|
|
printf("user 3 prepend\n");
|
|
User &user3 = wg.add_cfg("Test3", 0xc0a80004);
|
|
if (user3.ipv4 != 0xc0a80004) {
|
|
return 1;
|
|
}
|
|
|
|
wg.merge();
|
|
for (auto stat : *wg.peer_state()) {
|
|
printf("%d %x %s\n", stat.active, stat.ipv4, stat.pubkey);
|
|
}
|
|
|
|
return 0;
|
|
}
|