瀏覽代碼

Get rid of remote_ip (after several versions with MG_LEGACY_INTERFACE)

This is a first step in removing and replacing all functions using "long"
to represent IP addresses. While 4 bytes is enough to represent IPv4
addresses, IPv6 addresses require 16 bytes (128 bits).
bel2125 7 年之前
父節點
當前提交
adac47c70b
共有 3 個文件被更改,包括 1 次插入18 次删除
  1. 0 5
      include/civetweb.h
  2. 1 7
      src/civetweb.c
  3. 0 6
      src/mod_lua.inl

+ 0 - 5
include/civetweb.h

@@ -155,11 +155,6 @@ struct mg_request_info {
 	                             used */
 	                             used */
 	char remote_addr[48];     /* Client's IP address as a string. */
 	char remote_addr[48];     /* Client's IP address as a string. */
 
 
-#if defined(MG_LEGACY_INTERFACE)
-	long remote_ip; /* Client's IP address. Deprecated: use remote_addr instead
-	                   */
-#endif
-
 	long long content_length; /* Length (in bytes) of the request body,
 	long long content_length; /* Length (in bytes) of the request body,
 	                             can be -1 if no length was given. */
 	                             can be -1 if no length was given. */
 	int remote_port;          /* Client's port */
 	int remote_port;          /* Client's port */

+ 1 - 7
src/civetweb.c

@@ -9520,7 +9520,7 @@ parse_http_request(char *buf, int len, struct mg_request_info *ri)
 	int request_length;
 	int request_length;
 	int init_skip = 0;
 	int init_skip = 0;
 
 
-	/* Reset attributes. DO NOT TOUCH is_ssl, remote_ip, remote_addr,
+    /* Reset attributes. DO NOT TOUCH is_ssl, remote_addr,
 	 * remote_port */
 	 * remote_port */
 	ri->remote_user = ri->request_method = ri->request_uri = ri->http_version =
 	ri->remote_user = ri->request_method = ri->request_uri = ri->http_version =
 	    NULL;
 	    NULL;
@@ -16502,12 +16502,6 @@ worker_thread_run(struct worker_thread_args *thread_args)
 		DEBUG_TRACE("Start processing connection from %s",
 		DEBUG_TRACE("Start processing connection from %s",
 		            conn->request_info.remote_addr);
 		            conn->request_info.remote_addr);
 
 
-#if defined(MG_LEGACY_INTERFACE)
-		/* This legacy interface only works for the IPv4 case */
-		addr = ntohl(conn->client.rsa.sin.sin_addr.s_addr);
-		memcpy(&conn->request_info.remote_ip, &addr, 4);
-#endif
-
 		conn->request_info.is_ssl = conn->client.is_ssl;
 		conn->request_info.is_ssl = conn->client.is_ssl;
 
 
 		if (conn->client.is_ssl) {
 		if (conn->client.is_ssl) {

+ 0 - 6
src/mod_lua.inl

@@ -1615,12 +1615,6 @@ prepare_lua_request_info(struct mg_connection *conn, lua_State *L)
 	reg_string(L, "uri", conn->request_info.local_uri);
 	reg_string(L, "uri", conn->request_info.local_uri);
 	reg_string(L, "http_version", conn->request_info.http_version);
 	reg_string(L, "http_version", conn->request_info.http_version);
 	reg_string(L, "query_string", conn->request_info.query_string);
 	reg_string(L, "query_string", conn->request_info.query_string);
-#if defined(MG_LEGACY_INTERFACE)
-	reg_int(L, "remote_ip", conn->request_info.remote_ip); /* remote_ip is
-	                                                          deprecated, use
-	                                                          remote_addr
-	                                                          instead */
-#endif
 	reg_string(L, "remote_addr", conn->request_info.remote_addr);
 	reg_string(L, "remote_addr", conn->request_info.remote_addr);
 	/* TODO (high): ip version */
 	/* TODO (high): ip version */
 	reg_int(L, "remote_port", conn->request_info.remote_port);
 	reg_int(L, "remote_port", conn->request_info.remote_port);