mirror of
				https://github.com/max-moser/network-manager-wireguard.git
				synced 2025-11-04 09:03:49 +03:00 
			
		
		
		
	Merge pull request #13 from Druco/hotfix/ListenPortOptional
Change Listen Port from a required parameter to an optional parameter
This commit is contained in:
		
						commit
						b00d48ee61
					
				@ -127,6 +127,11 @@ check_peer_public_key(const char *str){
 | 
				
			|||||||
static gboolean
 | 
					static gboolean
 | 
				
			||||||
check_interface_listen_port(const char *str)
 | 
					check_interface_listen_port(const char *str)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						// Listen port is not a required field according to man wg
 | 
				
			||||||
 | 
						if(is_empty(str)){
 | 
				
			||||||
 | 
							return TRUE;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(!g_ascii_string_to_unsigned(str, 10, 0, 65535, NULL, NULL)){
 | 
						if(!g_ascii_string_to_unsigned(str, 10, 0, 65535, NULL, NULL)){
 | 
				
			||||||
		return FALSE;
 | 
							return FALSE;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
@ -1029,13 +1029,6 @@ handle_line_error:
 | 
				
			|||||||
		goto out_error;
 | 
							goto out_error;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(!have_listen_port){
 | 
					 | 
				
			||||||
		g_set_error_literal(error, NMV_EDITOR_PLUGIN_ERROR, NMV_EDITOR_PLUGIN_ERROR_FAILED,
 | 
					 | 
				
			||||||
							"The file to import wasn't a valid Wireguard configuration (no local listen port)");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		goto out_error;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(!have_ip4_addr && !have_ip6_addr){
 | 
						if(!have_ip4_addr && !have_ip6_addr){
 | 
				
			||||||
		g_set_error_literal(error, NMV_EDITOR_PLUGIN_ERROR, NMV_EDITOR_PLUGIN_ERROR_FAILED,
 | 
							g_set_error_literal(error, NMV_EDITOR_PLUGIN_ERROR, NMV_EDITOR_PLUGIN_ERROR_FAILED,
 | 
				
			||||||
							"The file to import wasn't a valid Wireguard configuration (no local IPv4 or IPv6 addresses)");
 | 
												"The file to import wasn't a valid Wireguard configuration (no local IPv4 or IPv6 addresses)");
 | 
				
			||||||
@ -1152,14 +1145,6 @@ create_config_string (NMConnection *connection, GError **error)
 | 
				
			|||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(!listen_port){
 | 
					 | 
				
			||||||
		g_set_error_literal(error,
 | 
					 | 
				
			||||||
							NMV_EDITOR_PLUGIN_ERROR,
 | 
					 | 
				
			||||||
							NMV_EDITOR_PLUGIN_ERROR_FILE_NOT_VPN,
 | 
					 | 
				
			||||||
							"Connection was incomplete (missing local listen port)");
 | 
					 | 
				
			||||||
		return NULL;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if(!private_key){
 | 
						if(!private_key){
 | 
				
			||||||
		g_set_error_literal(error,
 | 
							g_set_error_literal(error,
 | 
				
			||||||
							NMV_EDITOR_PLUGIN_ERROR,
 | 
												NMV_EDITOR_PLUGIN_ERROR,
 | 
				
			||||||
@ -1206,7 +1191,10 @@ create_config_string (NMConnection *connection, GError **error)
 | 
				
			|||||||
	args_write_line(f, value);
 | 
						args_write_line(f, value);
 | 
				
			||||||
	g_free(value);
 | 
						g_free(value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	args_write_line(f, NMV_WG_TAG_LISTEN_PORT, "=", listen_port);
 | 
						if(listen_port){
 | 
				
			||||||
 | 
							args_write_line(f, NMV_WG_TAG_LISTEN_PORT, "=", listen_port);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(post_up){
 | 
						if(post_up){
 | 
				
			||||||
		args_write_line(f, NMV_WG_TAG_POST_UP, "=", post_up);
 | 
							args_write_line(f, NMV_WG_TAG_POST_UP, "=", post_up);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user