/[smecontribs]/rpms/smeserver-wireguard/contribs10/smeserver-wireguard-1.0-bz11721-init.patch
ViewVC logotype

Annotation of /rpms/smeserver-wireguard/contribs10/smeserver-wireguard-1.0-bz11721-init.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.7 - (hide annotations) (download)
Mon Nov 1 02:41:08 2021 UTC (3 years ago) by jpp
Branch: MAIN
CVS Tags: smeserver-wireguard-1_0-8_el7_sme
Changes since 1.6: +33 -0 lines
* Sun Oct 31 2021 Jean-Philippe Pialasse <tests@pialasse.com> 1.0-8.sme
- set DNS if allowedips 0.0.0.0/0 [SME: 11721]
  allowedips displayed as it has been set.

1 jpp 1.1 diff -Nur --no-dereference smeserver-wireguard-1.0.old/root/etc/e-smith/db/configuration/migrate/wireguard smeserver-wireguard-1.0/root/etc/e-smith/db/configuration/migrate/wireguard
2     --- smeserver-wireguard-1.0.old/root/etc/e-smith/db/configuration/migrate/wireguard 2021-10-26 23:15:10.000000000 -0400
3     +++ smeserver-wireguard-1.0/root/etc/e-smith/db/configuration/migrate/wireguard 2021-10-27 17:28:48.614000000 -0400
4     @@ -18,7 +18,7 @@
5     my $minimum=16;
6     my $maximum=32;
7     my $x = $minimum + int(rand($maximum - $minimum));
8     -$DB->set_prop('wg-quick@wg0', 'ip', "172.$x.0.0") ;
9     +$DB->set_prop('wg-quick@wg0', 'ip', "172.$x.0.1") ;
10     }
11    
12     }
13 jpp 1.2 diff -Nur --no-dereference smeserver-wireguard-1.0.old/createlink smeserver-wireguard-1.0/createlink
14     --- smeserver-wireguard-1.0.old/createlink 2021-10-25 23:38:29.000000000 -0400
15     +++ smeserver-wireguard-1.0/createlink 2021-10-27 21:20:46.985000000 -0400
16     @@ -69,5 +69,5 @@
17     ));
18    
19    
20     -
21     +panel_link("wireguard", "manager");
22    
23     diff -Nur --no-dereference smeserver-wireguard-1.0.old/root/etc/e-smith/db/configuration/migrate/wireguard smeserver-wireguard-1.0/root/etc/e-smith/db/configuration/migrate/wireguard
24     --- smeserver-wireguard-1.0.old/root/etc/e-smith/db/configuration/migrate/wireguard 2021-10-27 21:17:33.367000000 -0400
25     +++ smeserver-wireguard-1.0/root/etc/e-smith/db/configuration/migrate/wireguard 2021-10-27 21:18:24.898000000 -0400
26     @@ -6,7 +6,7 @@
27     $DB->set_prop('wg-quick@wg0', 'private', $value ) ;
28     }
29     # recreate public if empty or not the same
30     -$private=${'wg-quick@wg0'}{'private'};
31     +$private=$DB->get_prop('wg-quick@wg0', 'private') ;
32     $public=`/usr/bin/echo $private | /usr/bin/wg pubkey`;
33     chomp $public;
34     if ( ! defined ${'wg-quick@wg0'}{'public'} || ${'wg-quick@wg0'}{'public'} ne $public) {
35 jpp 1.3 diff -Nur --no-dereference smeserver-wireguard-1.0.old/root/etc/e-smith/templates/etc/systemd/system-preset/49-koozali.preset/70wireguard smeserver-wireguard-1.0/root/etc/e-smith/templates/etc/systemd/system-preset/49-koozali.preset/70wireguard
36     --- smeserver-wireguard-1.0.old/root/etc/e-smith/templates/etc/systemd/system-preset/49-koozali.preset/70wireguard 1969-12-31 19:00:00.000000000 -0500
37     +++ smeserver-wireguard-1.0/root/etc/e-smith/templates/etc/systemd/system-preset/49-koozali.preset/70wireguard 2021-06-28 03:17:15.000000000 -0400
38     @@ -0,0 +1,12 @@
39     +# wireguard specific configuration
40     +{
41     +$wg = $wireguard{status} || 'disabled';
42     +$wg0 = ${'wg-quick@wg0'}{status} || 'disabled';
43     +if ($wg0 eq 'enabled') {
44     + $OUT .= "enable wg-quick\@wg0.service\n";
45     +} else {
46     + $OUT .= "disable wg-quick\@wg0.service\n";
47     +}
48     +
49     +}
50     +
51     diff -Nur --no-dereference smeserver-wireguard-1.0.old/root/etc/e-smith/templates/etc/systemd/system-preset/70wireguard smeserver-wireguard-1.0/root/etc/e-smith/templates/etc/systemd/system-preset/70wireguard
52     --- smeserver-wireguard-1.0.old/root/etc/e-smith/templates/etc/systemd/system-preset/70wireguard 2021-06-28 03:17:15.000000000 -0400
53     +++ smeserver-wireguard-1.0/root/etc/e-smith/templates/etc/systemd/system-preset/70wireguard 1969-12-31 19:00:00.000000000 -0500
54     @@ -1,12 +0,0 @@
55     -# wireguard specific configuration
56     -{
57     -$wg = $wireguard{status} || 'disabled';
58     -$wg0 = ${'wg-quick@wg0'}{status} || 'disabled';
59     -if ($wg0 eq 'enabled') {
60     - $OUT .= "enable wg-quick\@wg0.service\n";
61     -} else {
62     - $OUT .= "disable wg-quick\@wg0.service\n";
63     -}
64     -
65     -}
66     -
67 jpp 1.4 diff -Nur --no-dereference smeserver-wireguard-1.0.old/createlink smeserver-wireguard-1.0/createlink
68     --- smeserver-wireguard-1.0.old/createlink 2021-10-27 21:37:41.284000000 -0400
69     +++ smeserver-wireguard-1.0/createlink 2021-10-27 21:38:21.164000000 -0400
70     @@ -33,7 +33,7 @@
71     ));
72     event_services($event, qw(
73     masq restart
74     - 'wg-quick@wg0' restart
75     + wg-quick@wg0 restart
76     ));
77     event_link("wireguard-network", $event, "30");
78    
79     @@ -44,7 +44,7 @@
80     /etc/wireguard/server_public.key
81     ));
82     event_services($event, qw(
83     - 'wg-quick@wg0' restart
84     + wg-quick@wg0 restart
85     ));
86    
87     #wireguard-user-create
88     @@ -65,7 +65,7 @@
89     /etc/wireguard/server_public.key
90     ));
91     event_services($event, qw(
92     - 'wg-quick@wg0' restart
93     + wg-quick@wg0 restart
94     ));
95    
96    
97     diff -Nur --no-dereference smeserver-wireguard-1.0.old/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/wireguard smeserver-wireguard-1.0/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/wireguard
98     --- smeserver-wireguard-1.0.old/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/wireguard 2021-10-26 23:15:11.000000000 -0400
99     +++ smeserver-wireguard-1.0/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/wireguard 2021-10-27 21:41:45.296000000 -0400
100     @@ -239,6 +239,10 @@
101     <trans>You can not alter the server ip, mask, private and public key as there are already some clients configured.</trans>
102     </entry>
103    
104     + <entry>
105     + <base>NO_CONF</base>
106     + <trans>No configured client</trans>
107     + </entry>
108    
109    
110     </lexicon>
111 jpp 1.5 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     -
187 jpp 1.6 diff -Nur --no-dereference smeserver-wireguard-1.0.old/createlink smeserver-wireguard-1.0/createlink
188     --- smeserver-wireguard-1.0.old/createlink 2021-10-27 23:25:06.319000000 -0400
189     +++ smeserver-wireguard-1.0/createlink 2021-10-27 23:33:11.426000000 -0400
190     @@ -16,7 +16,7 @@
191    
192     event_services($event, qw(
193     masq restart
194     - 'wg-quick@wg0' restart
195     + wg-quick@wg0 restart
196     ));
197     event_link("wireguard-network", $event, "30");
198     templates2events("/etc/systemd/system-preset/49-koozali.preset", $event);
199     @@ -54,7 +54,7 @@
200     /etc/wireguard/server_public.key
201     ));
202     event_services($event, qw(
203     - 'wg-quick@wg0' restart
204     + wg-quick@wg0 restart
205     ));
206     event_link("wireguard-user-create", $event, "03");
207    
208     @@ -67,6 +67,11 @@
209     event_services($event, qw(
210     wg-quick@wg0 restart
211     ));
212     +
213     +$event="remoteaccess-update";
214     +event_services($event, qw(
215     + wg-quick@wg0 restart
216     +));
217    
218    
219     panel_link("wireguard", "manager");
220 jpp 1.7 diff -Nur --no-dereference smeserver-wireguard-1.0.old/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/wireguard.pm smeserver-wireguard-1.0/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/wireguard.pm
221     --- smeserver-wireguard-1.0.old/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/wireguard.pm 2021-10-26 23:15:10.000000000 -0400
222     +++ smeserver-wireguard-1.0/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/wireguard.pm 2021-10-31 22:37:41.238000000 -0400
223     @@ -224,6 +224,7 @@
224     my $wg0 = $cdb->get('wg-quick@wg0');
225     my $ServPublic = $wg0->prop('public');
226     my $Port = $wg0->prop('UDPPort');
227     +my $allowedips = $wg0->prop('allowedips') || "0.0.0.0/0";
228    
229     #here we guess wan IP
230     # are we server-gateway mode ? so external lan, should do
231     @@ -233,15 +234,20 @@
232     # dig @resolver4.opendns.com myip.opendns.com +short -4
233     # dig @resolver1.ipv6-sandbox.opendns.com AAAA myip.opendns.com +short -6
234    
235     +#DNS
236     +my $IPAddress = $cdb->get('InternalInterface')->prop('IPAddress');
237     +my $dns = ($allowedips =~ /0.0.0.0\/0/)? "DNS = $IPAddress" : "" ;
238     +
239    
240     my $fulltext ="#configuration for $key $info
241     [Interface]
242     PrivateKey = $private
243     Address = $key
244     +$dns
245    
246     [Peer]
247     PublicKey = $ServPublic
248     -AllowedIPs = 0.0.0.0/0
249     +AllowedIPs = $allowedips
250     Endpoint = $ExternalIP:$Port
251     ";
252     # we could add a DNS field in [Interface]

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed