108 |
|
|
109 |
|
|
110 |
</lexicon> |
</lexicon> |
111 |
|
diff -Nur --no-dereference smeserver-wireguard-1.0.old/root/etc/e-smith/templates/etc/wireguard/wg0.conf/10interface smeserver-wireguard-1.0/root/etc/e-smith/templates/etc/wireguard/wg0.conf/10interface |
112 |
|
--- smeserver-wireguard-1.0.old/root/etc/e-smith/templates/etc/wireguard/wg0.conf/10interface 2021-06-28 04:41:57.000000000 -0400 |
113 |
|
+++ smeserver-wireguard-1.0/root/etc/e-smith/templates/etc/wireguard/wg0.conf/10interface 2021-10-27 17:41:12.223000000 -0400 |
114 |
|
@@ -4,7 +4,6 @@ |
115 |
|
PrivateKey = {${'wg-quick@wg0'}{private}} |
116 |
|
|
117 |
|
# this should be added to masq with correct interfaces |
118 |
|
-#eth0 should be rempalced by external interface if available or internal |
119 |
|
-#PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE |
120 |
|
-#PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE |
121 |
|
+PostUp = iptables -I FORWARD -i %i -j ACCEPT; iptables -I FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o {$outernet = ($SystemMode eq "serveronly") ? $InternalInterface{Name} : $ExternalInterface{Name}; return $InternalInterface{Name} } -j MASQUERADE |
122 |
|
+PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o {$outernet = ($SystemMode eq "serveronly") ? $InternalInterface{Name} : $ExternalInterface{Name}; return $InternalInterface{Name} } -j MASQUERADE |
123 |
|
|
124 |
|
diff -Nur --no-dereference smeserver-wireguard-1.0.old/root/etc/e-smith/templates/etc/wireguard/wg0.conf/50usersPeers smeserver-wireguard-1.0/root/etc/e-smith/templates/etc/wireguard/wg0.conf/50usersPeers |
125 |
|
--- smeserver-wireguard-1.0.old/root/etc/e-smith/templates/etc/wireguard/wg0.conf/50usersPeers 2021-06-28 04:46:01.000000000 -0400 |
126 |
|
+++ smeserver-wireguard-1.0/root/etc/e-smith/templates/etc/wireguard/wg0.conf/50usersPeers 2021-10-27 17:41:12.429000000 -0400 |
127 |
|
@@ -1,33 +1,36 @@ |
128 |
|
{ |
129 |
|
-$OUT = ""; |
130 |
|
+use esmith::AccountsDB; |
131 |
|
|
132 |
|
-return; |
133 |
|
-my $wg = esmith::ConfigDB->open_ro('/etc/e-smith/db/wireguard') or return "#no peers"; |
134 |
|
-# for each user |
135 |
|
+my $wg = esmith::ConfigDB->open_ro('/home/e-smith/db/wireguard'); |
136 |
|
my $accounts = esmith::AccountsDB->open_ro; |
137 |
|
-for my $user ( $accounts->get_all_by_prop(type => 'wg0') ) { |
138 |
|
+ |
139 |
|
+# for each user |
140 |
|
+my @users = ( $accounts->users ); |
141 |
|
+push(@users, $accounts->get('admin')); |
142 |
|
+for my $user ( @users ) { |
143 |
|
my $username = $user->key; |
144 |
|
+ my $count = 0; |
145 |
|
for my $cnx ( $wg->get_all_by_prop(user => $username) ) { |
146 |
|
+ $count++; |
147 |
|
my $public = $cnx->prop('public'); |
148 |
|
- my $ip = $cnx->prop('ip'); |
149 |
|
+ my $ip = $cnx->key; |
150 |
|
my $info = $cnx->prop('info'); |
151 |
|
+ my $status = $cnx->prop('status') || "enabled"; |
152 |
|
+ if ( $status eq "disabled" ) { |
153 |
|
+ $OUT .= "\n# $username : $info DISABLED (PublicKey = $public ; AllowedIPs = $ip)\n"; |
154 |
|
+ next; |
155 |
|
+ } |
156 |
|
|
157 |
|
-# wireguard |
158 |
|
-#private;public;ips;info#private;public;ips;info |
159 |
|
-#private and public is base64 : +/= could be in it |
160 |
|
-#ips can be v4 or v6 with subnet ./:, |
161 |
|
-#info could have letters, digit and space |
162 |
|
-# to separate multiple # |
163 |
|
- |
164 |
|
- $OUT .= " |
165 |
|
+ $OUT .= " |
166 |
|
[Peer] |
167 |
|
# $username : $info |
168 |
|
PublicKey = $public |
169 |
|
AllowedIPs = $ip\n"; |
170 |
|
- } |
171 |
|
|
172 |
|
+ |
173 |
|
+ } |
174 |
|
+ $OUT .= "# no entry for user $username\n" if $count <1; |
175 |
|
} |
176 |
|
|
177 |
|
|
178 |
|
} |
179 |
|
- |
180 |
|
diff -Nur --no-dereference smeserver-wireguard-1.0.old/root/etc/e-smith/templates/etc/wireguard/wg0.conf/60serversPeers smeserver-wireguard-1.0/root/etc/e-smith/templates/etc/wireguard/wg0.conf/60serversPeers |
181 |
|
--- smeserver-wireguard-1.0.old/root/etc/e-smith/templates/etc/wireguard/wg0.conf/60serversPeers 2021-06-08 03:56:43.000000000 -0400 |
182 |
|
+++ smeserver-wireguard-1.0/root/etc/e-smith/templates/etc/wireguard/wg0.conf/60serversPeers 1969-12-31 19:00:00.000000000 -0500 |
183 |
|
@@ -1,3 +0,0 @@ |
184 |
|
- |
185 |
|
-#TODO |
186 |
|
- |