mirror of
				https://github.com/billz/raspap-webgui.git
				synced 2025-03-01 10:31:47 +00:00 
			
		
		
		
	Merge pull request #1723 from RaspAP/fix/wg-endpoint-seg
Extends wg peer validation to dynamic addresses
This commit is contained in:
		| @@ -623,18 +623,18 @@ function clearBlocklistStatus() { | ||||
|     $('#cbxblocklist-status').removeClass('check-updated').addClass('check-hidden'); | ||||
| } | ||||
|  | ||||
| // Handler for the wireguard generate key button | ||||
| // Handler for the WireGuard generate key button | ||||
| $('.wg-keygen').click(function(){ | ||||
|     var entity_pub = $(this).parent('div').prev('input[type="text"]'); | ||||
|     var entity_priv = $(this).parent('div').next('input[type="hidden"]'); | ||||
|     var parentGroup = $(this).closest('.input-group'); | ||||
|     var entity_pub = parentGroup.find('input[type="text"]'); | ||||
|     var updated = entity_pub.attr('name')+"-pubkey-status"; | ||||
|     var csrfToken = $('meta[name=csrf_token]').attr('content'); | ||||
|     var csrfToken = $('meta[name="csrf_token"]').attr('content'); | ||||
|     $.post('ajax/networking/get_wgkey.php',{'entity':entity_pub.attr('name'), 'csrf_token': csrfToken},function(data){ | ||||
|         var jsonData = JSON.parse(data); | ||||
|         entity_pub.val(jsonData.pubkey); | ||||
|         $('#' + updated).removeClass('check-hidden').addClass('check-updated').delay(500).animate({ opacity: 1 }, 700); | ||||
|     }) | ||||
| }) | ||||
|     }); | ||||
| }); | ||||
|  | ||||
| // Handler for wireguard client.conf download | ||||
| $('.wg-client-dl').click(function(){ | ||||
|   | ||||
| @@ -207,7 +207,10 @@ function SaveWireGuardConfig($status) | ||||
|         } | ||||
|         if (isset($_POST['wg_pendpoint']) && strlen(trim($_POST['wg_pendpoint']) >0 )) { | ||||
|             $wg_pendpoint_seg = substr($_POST['wg_pendpoint'],0,strpos($_POST['wg_pendpoint'],':')); | ||||
|             if (!filter_var($wg_pendpoint_seg,FILTER_VALIDATE_IP)) { | ||||
|             $host_port = explode(':', $wg_pendpoint_seg); | ||||
|             $hostname = $host_port[0]; | ||||
|             if (!filter_var($hostname, FILTER_VALIDATE_IP) &&  | ||||
|                 !filter_var($hostname, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) { | ||||
|                 $status->addMessage('Invalid value for endpoint address', 'danger'); | ||||
|                 $good_input = false; | ||||
|             } | ||||
|   | ||||
| @@ -21,10 +21,8 @@ | ||||
|         </div> | ||||
|         <div class="input-group col-md-12"> | ||||
|           <input type="text" class="form-control" name="wg-peer" id="wg-peerpubkey" value="<?php echo htmlspecialchars($wg_peerpubkey, ENT_QUOTES); ?>" /> | ||||
|           <div class="input-group-append"> | ||||
|             <button class="btn btn-outline-secondary rounded-end wg-keygen" type="button"><i class="fas fa-magic"></i></button> | ||||
|             <span id="wg-peer-pubkey-status" class="input-group-addon check-hidden ms-2 mt-1"><i class="fas fa-check"></i></span> | ||||
|           </div> | ||||
|           <div class="btn btn-outline-secondary rounded-end wg-keygen"><i class="fa-solid fa-wand-magic-sparkles"></i></div> | ||||
|           <span id="wg-peer-pubkey-status" class="input-group-addon check-hidden ms-2 mt-1"><i class="fas fa-check"></i></span> | ||||
|         </div> | ||||
|       </div> | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user