ソースを参照

IP_Address can now be a wildcard (not a valid IP, used for binding)

(cherry picked from commit 4198291cd45da7fce278d21cd5ef4a506086d5f8)
Fabio Alessandrelli 8 年 前
コミット
90a747a52d
2 ファイル変更10 行追加1 行削除
  1. 8 1
      core/io/ip_address.cpp
  2. 2 0
      core/io/ip_address.h

+ 8 - 1
core/io/ip_address.cpp

@@ -174,6 +174,7 @@ void IP_Address::clear() {
 
 
 	memset(&field8[0], 0, sizeof(field8));
 	memset(&field8[0], 0, sizeof(field8));
 	valid = false;
 	valid = false;
+	wildcard = false;
 };
 };
 
 
 bool IP_Address::is_ipv4() const {
 bool IP_Address::is_ipv4() const {
@@ -206,10 +207,16 @@ void IP_Address::set_ipv6(const uint8_t *p_buf) {
 IP_Address::IP_Address(const String &p_string) {
 IP_Address::IP_Address(const String &p_string) {
 
 
 	clear();
 	clear();
-	if (p_string.find(":") >= 0) {
+
+	if (p_string == "*") {
+		// Wildcard (not a vaild IP)
+		wildcard = true;
+
+	} else if (p_string.find(":") >= 0) {
 		// IPv6
 		// IPv6
 		_parse_ipv6(p_string);
 		_parse_ipv6(p_string);
 		valid = true;
 		valid = true;
+
 	} else if (p_string.get_slice_count(".") == 4) {
 	} else if (p_string.get_slice_count(".") == 4) {
 		// IPv4 (mapped to IPv6 internally)
 		// IPv4 (mapped to IPv6 internally)
 		field16[5] = 0xffff;
 		field16[5] = 0xffff;

+ 2 - 0
core/io/ip_address.h

@@ -41,6 +41,7 @@ private:
 	};
 	};
 
 
 	bool valid;
 	bool valid;
+	bool wildcard;
 
 
 protected:
 protected:
 	void _parse_ipv6(const String &p_string);
 	void _parse_ipv6(const String &p_string);
@@ -66,6 +67,7 @@ public:
 	}
 	}
 
 
 	void clear();
 	void clear();
+	bool is_wildcard() const { return wildcard; }
 	bool is_valid() const { return valid; }
 	bool is_valid() const { return valid; }
 	bool is_ipv4() const;
 	bool is_ipv4() const;
 	const uint8_t *get_ipv4() const;
 	const uint8_t *get_ipv4() const;