initial commit of file from CVS for smeserver-wireguard on Sat Sep 7 16:45:37 AEST 2024
This commit is contained in:
		| @@ -0,0 +1,130 @@ | ||||
| <div id='wrg_list'> | ||||
|  | ||||
|     <p><%=l 'wrg_DESC_MAIN_PAGE'%><br></p> | ||||
|  | ||||
| 	%= form_for 'wireguard' => (method => 'POST') => begin | ||||
|     	    %=  hidden_field 'trt' => 'UPD' | ||||
| 	    <p><%=l 'wrg_LABEL_CONFIG'%><br><br></p> | ||||
| 	    %= submit_button l('wrg_EDIT_CONFIG'), class => 'action' | ||||
| 	% end | ||||
|  | ||||
| 	<p><span class=label> | ||||
| 	%=l 'wrg_INTERFACE' | ||||
| 	</span> wg0<br></p> | ||||
|  | ||||
| 	<p><span class=label> | ||||
| 	%=l 'wrg_LABEL_STATUS' | ||||
| 	</span> | ||||
| 	%= $wrg_datas->{sstatus} | ||||
| 	<br></p> | ||||
|  | ||||
| 	<p><span class=label> | ||||
| 	%=l 'wrg_PUBLIC_KEY' | ||||
| 	</span> | ||||
| 	%= $wrg_datas->{wgpub} | ||||
| 	<br></p> | ||||
|  | ||||
| 	<p><span class=label> | ||||
| 	%=l 'wrg_IP' | ||||
| 	</span> | ||||
| 	%= $wrg_datas->{wgip}.'/'.$wrg_datas->{wgmask} | ||||
| 	<br></p> | ||||
|  | ||||
| 	<p><span class=label> | ||||
| 	%=l 'wrg_PORT' | ||||
| 	</span> | ||||
| 	%= $wrg_datas->{wgport} | ||||
| 	<br></p> | ||||
|  | ||||
| 	<table class="sme-border"><tbody> | ||||
| 	<tr> | ||||
|     	    <th class='sme-border'> | ||||
|     	    %=l 'wrg_PUBLIC_KEY' | ||||
|     	    </th><th class='sme-border'> | ||||
|     	    %=l 'wrg_INFO' | ||||
|     	    </th><th class='sme-border'> | ||||
|     	    %=l 'wrg_ENDPOINT' | ||||
|     	    </th><th class='sme-border'> | ||||
|     	    %=l 'wrg_VPN_IP' | ||||
|     	    </th><th class='sme-border'> | ||||
|     	    %=l 'wrg_LATEST_HANDSHAKE' | ||||
|     	    </th><th class='sme-border'> | ||||
|     	    %=l 'wrg_RECEIVED' | ||||
|     	    </th><th class='sme-border'> | ||||
|     	    %=l 'wrg_SENT' | ||||
|     	    </th><th class='sme-border'> | ||||
|     	    %=l 'wrg_KEEPALIVE' | ||||
|     	    </th> | ||||
|     	</tr> | ||||
|  | ||||
|     % if (scalar @$wgstatus > 0) { | ||||
|     %    foreach my $list (@$wgstatus) { | ||||
|     %		#public-key | private-key | listen-port |persistent-keepalive | ||||
|     %		my @line = split(' ',$list); | ||||
|     %		next if $line[1] eq $wrg_datas->{wgpub}; | ||||
|     %		my ($ginfo, $user); | ||||
|     %    	$ginfo = $c->get_wgs_info('info', "$line[3]"); | ||||
|     %    	$user  = $c->get_wgs_info('user', "$line[3]"); | ||||
|     %    	use POSIX qw( strftime ); | ||||
|     %    	my $dateR= ($line[4] ) ? strftime("%Y-%m-%d %H:%M:%S", localtime($line[4])) : " "; | ||||
|         <tr> | ||||
|             %= t td => (class => 'sme-border') => $line[0] | ||||
|             %= t td => (class => 'sme-border') => "$user : $ginfo" | ||||
|             %= t td => (class => 'sme-border') => $line[2] | ||||
|             %= t td => (class => 'sme-border') => $line[3] | ||||
|             %= t td => (class => 'sme-border') => $dateR | ||||
|             %= t td => (class => 'sme-border') => $line[5] | ||||
|             %= t td => (class => 'sme-border') => $line[6] | ||||
|             %= t td => (class => 'sme-border') => $line[7] | ||||
|     	</tr> | ||||
|     %    } | ||||
|     %	} | ||||
|     	</tbody></table> | ||||
|  | ||||
|     %= form_for 'wireguard' => (method => 'POST') => begin | ||||
| 	<hr class='sectionbar'/> | ||||
| 	<p><%=l 'wrg_LABEL_CLIENTS'%><br><br></p> | ||||
|         %= hidden_field 'trt' => 'NEW' | ||||
| 	%= submit_button l('wrg_ADD_CLIENT'), class => 'action' | ||||
|     % end | ||||
|  | ||||
|     %	if ( scalar @$wgconf == 0 ) { | ||||
|     	    %=l 'wrg_NO_CONF' | ||||
|     %	} else { | ||||
| 	<table class="sme-border"><tbody> | ||||
| 	<tr> | ||||
|     	    <th class='sme-border'> | ||||
|     	    %=l 'wrg_CONF_NAME' | ||||
|     	    </th><th class='sme-border'> | ||||
|     	    %=l 'wrg_USER' | ||||
|     	    </th><th class='sme-border'> | ||||
|     	    %=l 'wrg_INFO' | ||||
|     	    </th><th class='sme-border'> | ||||
|     	    %=l 'wrg_LABEL_STATUS' | ||||
|     	    </th><th class='sme-border' colspan='3'> | ||||
|     	    %=l 'ACTION' | ||||
|     	    </th> | ||||
|     	</tr> | ||||
|     %    foreach my $conf (@$wgconf) { | ||||
|     %    my $status = $c->l(uc($conf->prop('status') || 'enabled')); | ||||
|         <tr> | ||||
|             %= t td => (class => 'sme-border') => $conf->key | ||||
|             %= t td => (class => 'sme-border') => $conf->prop('user') || '' | ||||
|             %= t td => (class => 'sme-border') => $conf->prop('info') || '' | ||||
|             %= t td => (class => 'sme-border') => $status | ||||
|     %	    my $action =  | ||||
|     % 		"<a href='wireguard2?CsrfDef=TOKEN&trt=QRC&Wgconf=" . $conf->key . "'>" . l('wrg_QRCODE') . "</a>";  | ||||
|     	    <td class='sme-border'><%= $c->render_to_string(inline => $action) %></td> | ||||
|     %	    $action =  | ||||
|     % 		"<a href='wireguard2?CsrfDef=TOKEN&trt=MOD&Wgconf=" . $conf->key . "'>" . l('MODIFY') . "</a>";  | ||||
|     	    <td class='sme-border'><%= $c->render_to_string(inline => $action) %></td> | ||||
|     %	    $action =  | ||||
|     % 		"<a href='wireguard2?CsrfDef=TOKEN&trt=REM&Wgconf=" . $conf->key . "'>" . l('REMOVE') . "</a>";  | ||||
|     	    <td class='sme-border'><%= $c->render_to_string(inline => $action) %></td> | ||||
|     	</tr> | ||||
|     %    } | ||||
|     	</tbody> | ||||
|     	</table> | ||||
|     %} | ||||
|     <hr class='sectionbar'/> | ||||
| </div> | ||||
| @@ -0,0 +1,94 @@ | ||||
| <div id='wrg_mod'> | ||||
|  | ||||
|     %= form_for '/wireguard2' => (method => 'POST') => begin | ||||
| 	<p> | ||||
| 	%=l 'wrg_DESC_MODIFY_CLIENT_PAGE' | ||||
| 	</p> | ||||
| 	<hr class='sectionbar'/> | ||||
|  | ||||
| 	<p> | ||||
| 	%=l 'wrg_DESC_CONF_NAME' | ||||
| 	</p> | ||||
|  | ||||
| 	<p><span class=label> | ||||
| 	%=l 'wrg_CONF_NAME' | ||||
| 	</span> | ||||
| 	%= $wrg_datas->{wgconf} | ||||
| 	<br></p> | ||||
|  | ||||
| 	<p> | ||||
| 	%=l 'wrg_DESC_SELECT_ACCOUNT' | ||||
| 	</p> | ||||
|  | ||||
| 	<p><span class=label> | ||||
| 	%=l 'wrg_SELECT_ACCOUNT' | ||||
| 	</span><span class=data> | ||||
| 	% param 'Account' => $wrg_datas->{account} unless param 'Account'; | ||||
| 	%= select_field 'Account' => $c->get_existing_accounts(), class => 'input' | ||||
| 	<br></span></p> | ||||
|  | ||||
| 	<p> | ||||
| 	%=l 'wrg_DESC_INFO_ACC_WIREGUARD' | ||||
| 	</p> | ||||
|  | ||||
| 	<p><span class=label> | ||||
| 	%=l 'wrg_INFO_ACC_WIREGUARD' | ||||
| 	</span><span class=data> | ||||
| 	% param 'Info' => $wrg_datas->{info} unless param 'Info'; | ||||
| 	%=text_field 'Info' => size => '45', class => 'input' | ||||
| 	<br></span></p> | ||||
| 	 | ||||
| 	<p> | ||||
| 	%=l 'wrg_DESC_PRIVATE' | ||||
| 	</p> | ||||
|  | ||||
| 	<p><span class=label> | ||||
| 	%=l 'wrg_LABEL_PRIVATE' | ||||
| 	</span><span class=data> | ||||
| 	% param 'Private' => $wrg_datas->{private} unless param 'Private'; | ||||
| 	%=text_field 'Private' => size => '45', class => 'input' | ||||
| 	<br></span></p> | ||||
| 	 | ||||
| 	<p> | ||||
| 	%=l 'wrg_DESC_PUBLIC' | ||||
| 	</p> | ||||
|  | ||||
| 	<p><span class=label> | ||||
| 	%=l 'wrg_LABEL_PUBLIC' | ||||
| 	</span><span class=data> | ||||
| 	% param 'Public' => $wrg_datas->{public} unless param 'Public'; | ||||
| 	%=text_field 'Public' => size => '45', class => 'input' | ||||
| 	<br></span></p> | ||||
| 	 | ||||
| 	<p> | ||||
| 	%=l 'wrg_DESC_STATUS' | ||||
| 	</p> | ||||
|  | ||||
| 	<p><span class=label> | ||||
| 	%=l 'wrg_LABEL_STATUS' | ||||
| 	</span><span class=data> | ||||
| 	% param 'Status' => $wrg_datas->{status} unless param 'Status'; | ||||
| 	%= select_field 'Status' => [[ (l 'DISABLED') => 'disabled'], [ (l 'ENABLED') => 'enabled']], class => 'input' | ||||
| 	<br></span></p> | ||||
|  | ||||
| 	<p> | ||||
| 	%=l 'wrg_DESC_ALLOWEDIPS' | ||||
| 	</p> | ||||
|  | ||||
| 	<p><span class=label> | ||||
| 	%=l 'wrg_LABEL_ALLOWEDIPS' | ||||
| 	</span><span class=data> | ||||
| 	% param 'Allowedips' => $wrg_datas->{allowedips} unless param 'Allowedips'; | ||||
| 	%=text_field 'Allowedips' => size => '45', class => 'input' | ||||
| 	<br></span></p> | ||||
| 	 | ||||
| 	<div class='center'> | ||||
| 	%= submit_button l('MODIFY'), name => 'modify', class => 'action' | ||||
| 	</div> | ||||
|  | ||||
| 	%= hidden_field 'trt' => $wrg_datas->{trt} | ||||
|     	%= hidden_field 'Wgconf' => $wrg_datas->{wgconf} | ||||
| 	 | ||||
|     % end | ||||
|  | ||||
| </div> | ||||
| @@ -0,0 +1,38 @@ | ||||
| <div id='wrg_new'> | ||||
|  | ||||
|     %= form_for '/wireguard2' => (method => 'POST') => begin | ||||
| 	<p> | ||||
| 	%=l 'wrg_DESC_ADD_CLIENT_PAGE' | ||||
| 	</p> | ||||
|  | ||||
| 	<p> | ||||
| 	%=l 'wrg_DESC_SELECT_ACCOUNT' | ||||
| 	</p> | ||||
|  | ||||
| 	<p><span class=label> | ||||
| 	%=l 'wrg_SELECT_ACCOUNT' | ||||
| 	</span><span class=data> | ||||
| 	<!-- param 'Account' => $wrg_datas->{account} unless param 'Account'; --> | ||||
| 	%= select_field 'Account' => $c->get_existing_accounts(), class => 'input' | ||||
| 	<br></span></p> | ||||
|  | ||||
| 	<p> | ||||
| 	%=l 'wrg_DESC_INFO_ACC_WIREGUARD' | ||||
| 	</p> | ||||
|  | ||||
| 	<p><span class=label> | ||||
| 	%=l 'wrg_INFO_ACC_WIREGUARD' | ||||
| 	</span><span class=data> | ||||
| 	<!-- param 'Info' => $wrg_datas->{info} unless param 'Info'; --> | ||||
| 	%=text_field 'Info' => size => '60', class => 'input' | ||||
| 	<br></span></p> | ||||
|  | ||||
| 	<div class='center'> | ||||
| 	%= submit_button l('ADD'), class => 'action' | ||||
| 	</div> | ||||
|  | ||||
| 	%= hidden_field 'trt' => $wrg_datas->{trt} | ||||
| 	 | ||||
|     % end | ||||
|  | ||||
| </div> | ||||
| @@ -0,0 +1,17 @@ | ||||
| <div id='wrg_qrc'> | ||||
|  | ||||
|     % my $fulltext = join("\n", @{$c->get_conf_info( $wrg_datas->{wgconf} )}); | ||||
|     <br><br> | ||||
|     %= text_area Info => "$fulltext", cols => 70, rows => 10 | ||||
|     <br> | ||||
|  | ||||
|     % my $qr = $c->get_conf_qr("$fulltext"); | ||||
|     %= image "data:image/png;base64,$qr" | ||||
|  | ||||
|     <br> | ||||
|     %=l 'wrg_DESC_DISPLAY_QR_PAGE' | ||||
|     <br> | ||||
|     %= hidden_field 'trt' => $wrg_datas->{trt} | ||||
|     %= hidden_field 'Wgconf' => $wrg_datas->{wgconf} | ||||
|  | ||||
| </div> | ||||
| @@ -0,0 +1,30 @@ | ||||
| <div id='wrg_rem'> | ||||
|  | ||||
|     %= form_for '/wireguard2' => (method => 'POST') => begin | ||||
| 	<p> | ||||
| 	%=l 'wrg_DESC_REMOVE_CLIENT' | ||||
| 	</p> | ||||
|  | ||||
| 	<p><br><span class=label> | ||||
| 	%=l 'wrg_CONF_NAME' | ||||
| 	</span> | ||||
| 	%= $wrg_datas->{wgconf} | ||||
| 	<br></p> | ||||
|  | ||||
| 	<p><span class=label> | ||||
| 	%=l 'COMMENT' | ||||
| 	</span> | ||||
| 	%= $wrg_datas->{wgcomment} | ||||
| 	<br></p> | ||||
|  | ||||
| 	<div class='center'> | ||||
| 	%= submit_button l('CANCEL'), name => 'cancel', class => 'action' | ||||
| 	%= submit_button l('REMOVE'), name => 'remove', class => 'action' | ||||
| 	</div> | ||||
|  | ||||
| 	%= hidden_field 'trt' => $wrg_datas->{trt} | ||||
|     	%= hidden_field 'Wgconf' => $wrg_datas->{wgconf} | ||||
| 	 | ||||
|     % end | ||||
|  | ||||
| </div> | ||||
| @@ -0,0 +1,72 @@ | ||||
| <div id='wrg_upd'> | ||||
|  | ||||
|     %= form_for '/wireguard2' => (method => 'POST') => begin | ||||
| 	<p> | ||||
| 	%=l 'wrg_DESC_MOD_CONFIG_PAGE' | ||||
| 	</p> | ||||
|  | ||||
| 	<p> | ||||
| 	%=l 'wrg_DESC_IP_ACC_WIREGUARD' | ||||
| 	</p> | ||||
|  | ||||
| 	<p><span class=label> | ||||
| 	%=l 'wrg_INFO_IP_WIREGUARD' | ||||
| 	</span><span class=data> | ||||
| 	% param 'Ip' => $wrg_datas->{ip} unless param 'Ip'; | ||||
| 	%=text_field 'Ip' => class => 'input' | ||||
| 	<br></span></p> | ||||
| 	 | ||||
| 	<p> | ||||
| 	%=l 'wrg_DESC_MASK_WIREGUARD' | ||||
| 	</p> | ||||
|  | ||||
| 	<p><span class=label> | ||||
| 	%=l 'wrg_INFO_MASK_WIREGUARD' | ||||
| 	</span><span class=data> | ||||
| 	% param 'Mask' => $wrg_datas->{mask} unless param 'Mask'; | ||||
| 	%=text_field 'Mask' => class => 'input' | ||||
| 	<br></span></p> | ||||
| 	 | ||||
| 	<p> | ||||
| 	%=l 'wrg_DESC_PRIVATE_CONFIG' | ||||
| 	</p> | ||||
|  | ||||
| 	<p><span class=label> | ||||
| 	%=l 'wrg_LABEL_PRIVATE' | ||||
| 	</span><span class=data> | ||||
| 	% param 'Private' => $wrg_datas->{private} unless param 'Private'; | ||||
| 	%=text_field 'Private' => size => '45', class => 'input' | ||||
| 	<br></span></p> | ||||
| 	 | ||||
| 	<p> | ||||
| 	%=l 'wrg_DESC_PUBLIC_CONFIG' | ||||
| 	</p> | ||||
|  | ||||
| 	<p><span class=label> | ||||
| 	%=l 'wrg_LABEL_PUBLIC' | ||||
| 	</span><span class=data> | ||||
| 	% param 'Public' => $wrg_datas->{public} unless param 'Public'; | ||||
| 	%=text_field 'Public' => size => '45', class => 'input' | ||||
| 	<br></span></p> | ||||
| 	 | ||||
| 	<p> | ||||
| 	%=l 'wrg_DESC_STATUS' | ||||
| 	</p> | ||||
|  | ||||
| 	<p><span class=label> | ||||
| 	%=l 'wrg_LABEL_STATUS' | ||||
| 	</span><span class=data> | ||||
| 	% param 'Status' => $wrg_datas->{status} unless param 'Status'; | ||||
| 	%= select_field 'Status' => [[ (l 'DISABLED') => 'disabled'], [ (l 'ENABLED') => 'enabled']], class => 'input' | ||||
| 	<br></span></p> | ||||
|  | ||||
| 	<div class='center'> | ||||
| 	%= submit_button l('MODIFY'), name => 'modify', class => 'action' | ||||
| 	</div> | ||||
|  | ||||
| 	%= hidden_field 'trt' => $wrg_datas->{trt} | ||||
|     	%= hidden_field 'Wgconf' => $wrg_datas->{wgconf} | ||||
| 	 | ||||
|     % end | ||||
|  | ||||
| </div> | ||||
| @@ -0,0 +1,35 @@ | ||||
| % layout 'default', title => "Sme server 2 - wireguard"; | ||||
|  | ||||
| % content_for 'module' => begin | ||||
| <div id='module' class='module wireguard-panel'> | ||||
|  | ||||
|     % if ($config->{debug} == 1) { | ||||
| 	<p> | ||||
| 	%= dumper $c->current_route | ||||
| 	%= dumper $wrg_datas | ||||
| 	</p> | ||||
|     % } | ||||
|     % if ( stash 'error' ) { | ||||
|     	<br><div class=sme-error> | ||||
|     	%= $c->render_to_string(inline => stash 'error')  | ||||
| 	</div> | ||||
|     %} | ||||
|  | ||||
|     <h1><%= $title%></h1> | ||||
|  | ||||
|     % if ($wrg_datas->{trt} eq 'UPD') { | ||||
| 	%= include 'partials/_wrg_upd' | ||||
|     %} elsif ($wrg_datas->{trt} eq 'NEW') { | ||||
| 	%= include 'partials/_wrg_new' | ||||
|     %} elsif ($wrg_datas->{trt} eq 'QRC') { | ||||
| 	%= include 'partials/_wrg_qrc' | ||||
|     %} elsif ($wrg_datas->{trt} eq 'MOD') { | ||||
| 	%= include 'partials/_wrg_mod' | ||||
|     %} elsif ($wrg_datas->{trt} eq 'REM') { | ||||
| 	%= include 'partials/_wrg_rem' | ||||
|     %} else { | ||||
| 	%= include 'partials/_wrg_list' | ||||
|     %} | ||||
|  | ||||
| </div> | ||||
| %end | ||||
		Reference in New Issue
	
	Block a user
	 Trevor Batley
					Trevor Batley