Location query method and device, equipment, storage medium and program product
By normalizing the IP address and using the query identifier, the problem of low efficiency of IP address query in the prior art is solved, and efficient and accurate location information query is achieved.
Patent Information
- Application Number
- CN202510819042.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-18
- Publication Date
- 2025-09-19
AI Technical Summary
In the prior art, the efficiency of querying location information in a database through an IP address is low.
By receiving the location query request, the IP address to be queried is normalized, the target IP address is determined, and the query is performed in the database according to the query identifier to avoid direct matching in the database by IP address.
It improves the efficiency of location query, reduces data transmission overhead, and improves the accuracy and speed of query.
Smart Images

Figure CN120676453A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of big data, and in particular to a location query method, device, equipment, storage medium and program product. Background Art
[0002] Internet Protocol (IP) addresses can be used to identify every device on the Internet. The location information corresponding to the IP address can be stored in a database.
[0003] In related technologies, a database can be queried for location information corresponding to a user device based on its IP address. By querying the database for the location information of IP addresses associated with large-scale daily transactions, risk monitoring can be implemented for users in sensitive areas. However, directly querying a database for location information based on an IP address requires matching the IP address in the database, making the query inefficient. Summary of the Invention
[0004] The present application provides a location query method, apparatus, device, storage medium and program product to solve the technical problem of low query efficiency.
[0005] In a first aspect, the present application provides a location query method, comprising:
[0006] receiving a location query request from a server, the location query request being used to request at least one location information corresponding to at least one Internet Protocol (IP) address to be queried;
[0007] For any IP address to be queried, normalize the IP address to be queried according to the location query request to obtain the target IP address;
[0008] Determine a query identifier corresponding to each target IP address, where the query identifier is an address identifier storing location information corresponding to each IP address in a database, and the address identifier corresponds to at least one address IP;
[0009] According to the query identifier corresponding to each target IP address, query processing is performed in the database to obtain the location information corresponding to each IP address to be queried, and the location information corresponding to each IP address to be queried is sent to the server.
[0010] In a second aspect, the present application provides a location query device, including a receiving module, a normalization processing module, a determination module, a query processing module, and a sending module:
[0011] The receiving module is used to receive a location query request from a server, where the location query request is used to request at least one location information corresponding to at least one Internet Protocol (IP) address to be queried;
[0012] The normalization processing module is used to perform normalization processing on any IP address to be queried according to the location query request to obtain a target IP address;
[0013] The determination module is used to determine the query identifier corresponding to each target IP address, the query identifier is an address identifier storing the location information corresponding to each IP address in the database, and the address identifier corresponds to at least one address IP;
[0014] The query processing module is used to perform query processing in the database according to the query identifier corresponding to each target IP address to obtain the location information corresponding to each IP address to be queried;
[0015] The sending module is used to send the location information corresponding to each IP address to be queried to the server.
[0016] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a memory, a processor;
[0017] The memory stores computer-executable instructions;
[0018] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the above first aspect and / or various possible implementations of the first aspect.
[0019] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the first aspect above and / or various possible implementation methods of the first aspect.
[0020] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the above first aspect and / or various possible implementation methods of the first aspect.
[0021] The location query method, device, equipment, storage medium, and program product provided by the present application can normalize the IP address to be queried according to the location query request to obtain the target IP address; determine the query identifier corresponding to each target IP address, perform query processing in the database according to the query identifier corresponding to each target IP address, obtain the location information corresponding to each IP address to be queried, and send the location information corresponding to each IP address to be queried to the server. After receiving the query request for the IP address, the IP address is normalized to obtain the target IP address, and the query identifier corresponding to the target IP address in the database can be determined. The query identifier can be used to quickly locate the target IP address in the database without having to query the database by IP address, thereby improving the efficiency of the query. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0023] Figure 1 A schematic diagram of an application scenario provided in an embodiment of the present application;
[0024] Figure 2 A flowchart of a location query method provided in an embodiment of the present application;
[0025] Figure 3 A flowchart of another location query method provided in an embodiment of the present application;
[0026] Figure 4 A schematic diagram of the architecture of a location query method provided in an embodiment of the present application;
[0027] Figure 5 A schematic diagram of the structure of a location query device provided in an embodiment of the present application;
[0028] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0029] The above drawings illustrate specific embodiments of the present application, which will be described in more detail below. These drawings and the textual description are not intended to limit the scope of the present application in any way, but rather to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments. DETAILED DESCRIPTION
[0030] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
[0031] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with the relevant laws, regulations and standards of the relevant countries and regions, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0032] In addition, this application involves conducting big data analysis of user information (including but not limited to personal biometrics, identity data, consumption data, asset data, electronic terminal operation data, etc.), and using artificial intelligence technology to make automated decisions, and making technical solutions that have a significant impact on personal rights and interests based on the results of automated decisions. The application provides users with corresponding operation entrances for them to choose to agree or reject the results of automated decisions; if the user chooses to reject, the expert decision-making process will be entered.
[0033] It should be noted that the location query method, device, equipment, storage medium and program product provided in this application can be used in the field of big data, and can also be used in any field other than the field of big data. The application field of the location query method, device, equipment, storage medium and product in this application is not limited.
[0034] Figure 1 This is a schematic diagram of an application scenario provided by an embodiment of this application. Figure 1 , including a user device 101, a server 102, a processing device 103 and a database 104.
[0035] An application can be installed on user device 101. When a user accesses the application through user device 101, the application server 102 can obtain the IP address of the user when accessing the application through user device 101. Location information corresponding to the IP address can be stored in database 104. Server 102 can send a location query request to processing device 103. Processing device 103, based on the location query request, queries database 104 for the IP address and determines the user's location at the time of access.
[0036] In related technologies, a database can be queried for location information corresponding to a user device based on its IP address. By querying the database for the location information of IP addresses associated with large-scale daily transactions, risk monitoring can be implemented for users in sensitive areas. However, directly querying a database for location information based on an IP address requires matching the IP address in the database, making the query inefficient.
[0037] The location query method provided by the embodiment of the present application can receive a location query request from a server, and the location query request is used to request multiple location information corresponding to multiple IP addresses to be queried; for any IP address to be queried, the IP address to be queried is normalized according to the location query request to obtain a target IP address; the query identifier corresponding to each target IP address is determined, and the query identifier is an identifier that stores the location information corresponding to each IP address in the database; according to the query identifier corresponding to each target IP address, query processing is performed in the database to obtain the location information corresponding to each IP address to be queried, and the location information corresponding to each IP address to be queried is sent to the server. In the above execution process, after receiving the query request for the IP address, the IP address is normalized to obtain the target IP address, the query identifier corresponding to the target IP address in the database can be determined, and the query identifier can be used to quickly locate the target IP address in the database without having to query the database through the IP address, thereby improving the efficiency of the query.
[0038] The following specific embodiments describe in detail the technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0039] Figure 2 This is a flowchart of a location query method provided in an embodiment of the present application. Figure 2 , the method may include:
[0040] S201: Receive a location query request from a server.
[0041] The execution subject of the embodiment of the present application can be a processing device, or a location query device set in the processing device. The location query device can be implemented by software or a combination of software and hardware.
[0042] The location query request may be used to request at least one location information corresponding to at least one IP address to be queried.
[0043] The server can be used to provide services for the application and may store one or more user devices accessing the application when the application is accessed.
[0044] For example, when multiple user devices access the application at the same time, the server generates a location query request and sends the location query request to the processing device. The location query request can query the location information of multiple IP addresses to be queried.
[0045] S202: For any IP address to be queried, normalize the IP address to be queried according to the location query request to obtain the target IP address.
[0046] Specifically, the address type corresponding to the IP address to be queried can be determined according to the location query request; and the IP address to be queried is normalized according to the address type corresponding to the IP address to be queried to obtain the target IP address.
[0047] The IP address to be queried has a corresponding address type, which may include a first address type and a second address type. For example, the first address type may be IPv4, and the second address type may be IPv6.
[0048] For different address types, the queried IP address can be normalized to obtain the target IP address.
[0049] The target IP address may include a first IP address and a second IP address. The first IP address may be a normalized address of the IP address to be queried corresponding to the first address type, and the second IP address may be a normalized address of the address to be queried corresponding to the second address type.
[0050] In this application, the query address can be normalized for different address types to obtain the target IP address, and the query matching can be performed through the normalized target IP address to improve the accuracy of the query.
[0051] S203: Determine the query identifier corresponding to each target IP address.
[0052] The query identifier may be an address identifier storing location information corresponding to each IP address in a database.
[0053] An IP address has its corresponding location information, wherein the location information of multiple IP addresses may be the same. Multiple address identifiers and the location information corresponding to each address identifier may be stored in a database, and one address identifier may correspond to multiple IP addresses.
[0054] S204: Perform query processing in the database according to the query identifier corresponding to each target IP address to obtain the location information corresponding to each IP address to be queried.
[0055] For any target IP address, the target address identifier corresponding to the query identifier is determined among multiple address identifiers in the database, and the location information corresponding to the target address identifier is determined as the location information of the IP address to be queried corresponding to the target IP address.
[0056] SQL functions can be built in the database, and the http protocol can be used in the SQL function to support finding location information through query identifiers, which can keep the simplicity of external programs using SQL to find IP addresses.
[0057] S205: Send the location information corresponding to each IP address to be queried to the server.
[0058] The location information corresponding to each IP address to be queried can be sent to the server together, without sending the location information one at a time, which can reduce the data transmission overhead and improve the query efficiency.
[0059] The location query method provided in this embodiment can normalize the IP address after receiving a location query request for an IP address to obtain a target IP address, and then determine the query identifier corresponding to the target IP address in the database. The query identifier can be used to quickly locate the target IP address in the database without having to query the database through the IP address, thereby improving the efficiency of the query.
[0060] Figure 3 This is a flow chart of another location query method provided in an embodiment of the present application. Figure 3 , the method may include:
[0061] S301: Receive a location query request from a server.
[0062] The execution process of S301 can refer to the execution process of S201 in the above embodiment, and will not be repeated here.
[0063] S302: For any IP address to be queried, determine the address type corresponding to the IP address to be queried according to the location query request.
[0064] In some possible embodiments, the address length and / or address symbol corresponding to the IP address to be queried may be determined, and the address type corresponding to the IP address to be queried may be determined based on the address length and / or address symbol.
[0065] For example, assuming that the first address type is IPv4, the first address type is a 32-bit binary number, usually expressed in dotted decimal notation, then the address length is 32 bits, and the address symbol is a dot; the second address type is IPv6, the second address type is a 128-bit binary number, usually expressed in hexadecimal notation separated by colons, then the address length is 128 bits, and the address symbol is a colon; assuming that the address length corresponding to the IP address to be queried is 32 bits, and the address symbol is a dot, it can be determined that the address type of the IP address to be queried is the first address type.
[0066] S303: If the address type is the first address type, perform format conversion on the IP address to be queried to obtain a first IP address.
[0067] The data type of the IP address to be queried may be a string type, and the data type of the first IP address may be a data type.
[0068] The IP address to be queried of the character string type may be converted into the first IP address of the data type through format conversion processing.
[0069] In some possible embodiments, the IP address to be queried is segmented to obtain multiple interval values; each interval value is processed to obtain a conversion value corresponding to each interval value; and each conversion value is summed to obtain the first IP address.
[0070] The first address type is IPv4. The IP address to be queried is divided into four interval values according to the dot ".". Each interval value can correspond to a different position in the 32-bit binary number. There are four interval values in total, namely the first interval value, the second interval value, the third interval value, and the fourth interval value. Among them, the first interval value occupies the highest 8 bits (bits 24 to 31), the second interval value occupies the middle 8 bits (bits 16 to 23), the third interval value occupies the middle 8 bits (bits 8 to 15), and the fourth interval value occupies the lowest 8 bits (bits 0 to 7). Each interval value is an unsigned integer between 0 and 255.
[0071] For any interval value, the interval sequence number of the interval value between multiple interval values can be determined; the product of the preset value corresponding to the interval sequence number and the interval value is determined as the conversion value. For example, the interval sequence number of the first interval value is sequence number 1, the interval sequence number of the second interval value is sequence number 2, the interval sequence number of the third interval value is sequence number 3, and the interval sequence number of the fourth interval value is sequence number 4. The preset value corresponding to sequence number 1 is , the preset value corresponding to sequence number 2 is , the preset value corresponding to sequence number 3 is , the preset value corresponding to sequence number 4 is 1.
[0072] For example, assuming the IP address to be queried is "123.119.248.0", after segmentation, the first interval value is 123, the second interval value is 119, the third interval value is 248, and the fourth interval value is 0. After data processing of each interval value, the converted value corresponding to the first interval value is 2063597568, the converted value corresponding to the second interval value is 7798784, the converted value corresponding to the third interval value is 63488, and the converted value corresponding to the fourth interval value is 0. The first IP address is 2071459840. Assuming the IP address to be queried is "123.119.251.255", the first IP address is 2071460863.
[0073] In this application, the IP address to be queried is converted into a first IP address through format conversion processing, and a string type IP address can be converted into an integer type IP address. In the string format, the query requires each character to be compared and queried. When querying through an integer type IP address, it can be directly located through numerical calculation, which can improve the efficiency of the query. By sorting the values of each interval and performing data processing on the values of each interval, the effectiveness of the conversion into a numerical value can be improved, thereby improving the accuracy of the query.
[0074] S304: If the address type is the second address type, perform data expansion processing on the IP address to be queried to obtain a second IP address.
[0075] The IP address to be queried may be in a compressed format, and the second IP address may be in a standard format.
[0076] In some possible embodiments, at least one ellipsis symbol is determined in the IP address to be queried; the omitted fields corresponding to each ellipsis symbol are determined; and the IP address to be queried is supplemented according to the omitted fields corresponding to each ellipsis symbol to obtain a second IP address.
[0077] The second address type can be IPv6. An IPv6 address consists of eight groups of 16 bits (each group is 4 hexadecimal digits), separated by colons. In compressed format, consecutive zero segments (i.e., 16 bits of all zeros) can be replaced by double colons. The ellipsis symbol can be a double colon, which is expanded to an ellipsis field during data expansion.
[0078] For example, assuming that the IP address to be queried is "::98F", the omission symbol is "::", and the omitted field is "0000:0000:0000:0000:0000:0000:0000:0000:", by omitting the field, the second IP address after data expansion processing of the queried IP address is "0000:0000:0000:0000:0000:0000:0000:098F"; assuming that the IP address to be queried is "FE60::07C:FE:0:0:5CA8", the omitted field is ":0000:0000:", and the second IP address after data expansion processing is "FE60:0000:0000:007C:00FE:0000:0000:5CA8".
[0079] In this application, converting the compressed format into a standard format can ensure the uniqueness and consistency of the address and improve the accuracy of the query.
[0080] In this application, if the address type is the first address type, the format conversion processing is performed on the queried IP address to obtain the first IP address. If the address type is the second address type, the data expansion processing is performed on the queried IP address to obtain the second IP address. The IP address can be normalized according to the normalization method corresponding to different address types, which can improve the accuracy of the IP address when querying.
[0081] S305: For any target IP address, obtain an address identification information table corresponding to the address type of the target IP address.
[0082] The address identifier information table may include multiple address identifiers, the minimum IP address and the maximum IP address of the address segment corresponding to each address identifier, and the number of valid addresses in the address segment corresponding to each address identifier.
[0083] The address identification information table may be stored in the memory of the server.
[0084] The address identifier is the unique identifier of the address segment. The address identifier is the primary key in the database. The corresponding location information can be obtained in the database through the address identifier.
[0085] The minimum IP address can be used to limit the query lower limit of the address segment, and the maximum IP address can be used to limit the query upper limit of the address segment.
[0086] The minimum and maximum IP addresses are stored in the address identification information table in integer form. For example, if the address identification information table corresponds to IPv4, the string type IP address "123.119.251.255" is stored in the address identification information table as the integer IP address "2071460863".
[0087] The number of valid addresses can be the maximum index of the IP addresses covered in each address segment, which can avoid out-of-bounds access.
[0088] For example, ipIdArr can store the address identifier of an address segment, ipMinArr can store the minimum IP address in the address segment, ipMaxArr can store the maximum IP address in the address segment, and the validSize variable can dynamically record the current number of valid addresses. The IP address can be an IPv4 address or an IPv6 address.
[0089] In this application, the address identifier information table includes the address identifier and the maximum and minimum addresses corresponding to the address identifier, which can quickly query the address identifier corresponding to the target IP address in memory, thereby improving query efficiency. In addition, the IP addresses in the address identifier information table are stored as integer types, which occupy fewer bytes and can reduce the memory space occupied, thereby improving query efficiency.
[0090] S306: Determine the target address segment corresponding to the target IP address in the address identification information table.
[0091] In this application, binary calculation can be directly performed on the target IP address and the address segment in the address identification information to determine the corresponding target address segment. There is no need to compare each character, which can improve the efficiency of the query.
[0092] In some possible embodiments, the target address segment may be determined by a binary search method.
[0093] The binary search method has a time complexity of O and is very efficient. For example, to sort an array of 20 million IPv4 addresses, the maximum number of comparisons required is k=log(2000*10000,2) ≈ 24.
[0094] S307: Determine the address identifier corresponding to the target address segment as the query identifier corresponding to the target IP address.
[0095] The address identifier in the address identifier information table is the primary key in the database. Each address identifier has its corresponding location information, which is the location corresponding to all IP addresses in the address segment corresponding to the address identifier.
[0096] In this application, the query identifier can be determined in memory, and the location information corresponding to the query identifier can be directly obtained in the database, which can improve the efficiency of the query. At the same time, since multiple IP addresses may correspond to the same location information, storing the location information corresponding to multiple IP addresses as a unit in the database can reduce the use of database storage resources.
[0097] S308: Perform query processing in the database according to the query identifier corresponding to each target IP address to obtain the location information corresponding to each IP address to be queried.
[0098] S309: Send the location information corresponding to each IP address to be queried to the server.
[0099] The execution process of S308-S309 can refer to the execution process of S204-S205 in the above embodiment, and will not be repeated here.
[0100] The location query method provided in the embodiment of the present application can determine the query identifier corresponding to the IP address to be queried in the address identifier information table based on the normalized target IP address, determine the location information in the database using the query identifier, and determine the corresponding query identifier in the database in memory using the target IP address, thereby improving query efficiency. In addition, in memory, the address segment can be directly located in the address identifier information table through numerical calculation using the normalized integer form of the target IP address, thereby improving query efficiency.
[0101] Figure 4 This is a schematic diagram of the architecture of a location query method provided in an embodiment of the present application. Figure 4 , including a server, a processing device and a database. After receiving the location query request from the server, the processing device can determine the address type corresponding to any IP address to be queried. The address type includes a first address type (for example, IPv4 type) and a second address type (for example, IPv6 type). The IP address to be queried is normalized according to the address type to obtain the target IP address.
[0102] From memory, retrieve an address identifier information table corresponding to the address type. The address identifier information table includes multiple address identifiers and the minimum and maximum IP addresses of the address segments corresponding to each address identifier. The minimum and maximum IP addresses are normalized IP addresses. Determine the query identifier corresponding to the target IP address from the multiple address identifiers in the address identifier information table.
[0103] The database may store multiple address identifiers and the location information corresponding to each address identifier. The processing device may determine the location information corresponding to the IP address to be queried in the database using the query identifier. The processing device may send at least one location information corresponding to at least one IP address to be queried corresponding to the location query request to the server.
[0104] Figure 5 This is a schematic diagram of the structure of a location query device provided in an embodiment of the present application. Figure 5The location query device 500 may include a receiving module 501, a normalization processing module 502, a determination module 503, a query processing module 504 and a sending module 505:
[0105] The receiving module 501 is used to receive a location query request from a server, where the location query request is used to request at least one location information corresponding to at least one Internet Protocol (IP) address to be queried;
[0106] The normalization processing module 502 is used to perform normalization processing on any IP address to be queried according to the location query request to obtain the target IP address;
[0107] The determination module 503 is used to determine the query identifier corresponding to each target IP address, where the query identifier is an address identifier storing the location information corresponding to each IP address in the database, and the address identifier corresponds to at least one address IP;
[0108] The query processing module 504 is used to perform query processing in the database according to the query identifier corresponding to each target IP address to obtain the location information corresponding to each IP address to be queried;
[0109] The sending module 505 is used to send the location information corresponding to each IP address to be queried to the server.
[0110] In some possible embodiments, the normalization processing module 502 is specifically configured to:
[0111] Determine the address type corresponding to the IP address to be queried according to the location query request;
[0112] According to the address type corresponding to the IP address to be queried, the IP address to be queried is normalized to obtain the target IP address.
[0113] In some possible embodiments, the address type includes a first address type and a second address type; the target IP address includes a first IP address and a second IP address; and the normalization processing module 502 is specifically configured to:
[0114] If the address type is the first address type, the IP address to be queried is format converted to obtain the first IP address, the data type of the IP address to be queried is a string type, and the data type of the first IP address is a data type;
[0115] If the address type is the second address type, data expansion processing is performed on the IP address to be queried to obtain the second IP address. The IP address to be queried is in a compressed format, and the second IP address is in a standard format.
[0116] In some possible embodiments, the normalization processing module 502 is specifically configured to:
[0117] The IP address to be queried is split to obtain multiple interval values;
[0118] Perform data processing on the values in each interval to obtain the conversion values corresponding to the values in each interval;
[0119] The converted values are summed to obtain the first IP address.
[0120] In some possible embodiments, for any interval value, the normalization processing module 502 is specifically configured to:
[0121] Determine the interval sequence number of the interval value between multiple interval values;
[0122] The product of the preset value corresponding to the interval sequence number and the interval value is determined as the conversion value.
[0123] In some possible embodiments, the normalization processing module 502 is specifically configured to:
[0124] Determine at least one abbreviation in the IP address to be queried;
[0125] Determine the omitted fields corresponding to each ellipsis symbol;
[0126] The IP address to be queried is supplemented according to the omitted fields corresponding to the ellipsis symbols to obtain a second IP address.
[0127] In some possible embodiments, for any target IP address, the determination module 503 is specifically configured to:
[0128] Obtain the address identification information table corresponding to the address type of the target IP address;
[0129] In the address identification information table, determine the target address segment corresponding to the target IP address;
[0130] The address identifier corresponding to the target address segment is determined as the query identifier corresponding to the target IP address.
[0131] In some possible embodiments, the address identifier information table includes multiple address identifiers, the minimum IP address and the maximum IP address of the address segment corresponding to each address identifier, and the number of valid addresses in the address segment corresponding to each address identifier.
[0132] The location query device provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effects are similar and will not be described in detail in this embodiment.
[0133] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 6The electronic device 600 may include a processor 601 and a memory 602. Exemplarily, the processor 601 and the memory 602 are interconnected via a bus 603.
[0134] Memory 602 stores computer-executable instructions;
[0135] The processor 601 executes the computer-executable instructions stored in the memory 602 , so that the processor 601 executes the location query method as shown in the above method embodiment.
[0136] Accordingly, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, the method for querying the location of the above-mentioned method embodiment is implemented.
[0137] Accordingly, an embodiment of the present application may also provide a computer program product, including a computer program. When the computer program is executed by a processor, it can implement the location query method shown in the above method embodiment.
[0138] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0139] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0140] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0141] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.
[0142] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0143] Memory may include non-permanent storage in a computer-readable medium, in the form of random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0144] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can be implemented using any method or technology for information storage. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change RAM (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media, such as modulated data signals and carrier waves.
[0145] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0146] The above are merely embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.
Claims
1. A location query method, characterized in that: include: receiving a location query request from a server, the location query request being used to request at least one location information corresponding to at least one Internet Protocol (IP) address to be queried; For any IP address to be queried, normalize the IP address to be queried according to the location query request to obtain the target IP address; Determine a query identifier corresponding to each target IP address, where the query identifier is an address identifier storing location information corresponding to each IP address in a database, and the address identifier corresponds to at least one address IP; According to the query identifier corresponding to each target IP address, query processing is performed in the database to obtain the location information corresponding to each IP address to be queried, and the location information corresponding to each IP address to be queried is sent to the server.
2. The method according to claim 1, characterized in that Normalizing the IP address to be queried according to the location query request to obtain a target IP address includes: Determining, according to the location query request, an address type corresponding to the IP address to be queried; According to the address type corresponding to the IP address to be queried, the IP address to be queried is normalized to obtain the target IP address.
3. The method according to claim 2, characterized in that The address type includes a first address type and a second address type; the target IP address includes a first IP address and a second IP address; and normalizing the IP address to be queried according to the address type corresponding to the IP address to be queried to obtain the target IP address, including: If the address type is the first address type, performing format conversion processing on the IP address to be queried to obtain the first IP address, the data type of the IP address to be queried is a string type, and the data type of the first IP address is a data type; If the address type is the second address type, data expansion processing is performed on the IP address to be queried to obtain the second IP address, the IP address to be queried is in a compressed format, and the second IP address is in a standard format.
4. The method according to claim 3, characterized in that Performing format conversion on the IP address to be queried to obtain the first IP address includes: Segmenting the IP address to be queried to obtain multiple interval values; Perform data processing on the values in each interval to obtain the conversion values corresponding to the values in each interval; The converted values are summed to obtain the first IP address.
5. The method according to claim 4, characterized in that For any interval value; performing data processing on the interval value to obtain a conversion value corresponding to the interval value, including: Determine the interval sequence number of the interval value between the multiple interval values; The product of the preset value corresponding to the interval sequence number and the interval value is determined as the conversion value.
6. The method according to claim 3, characterized in that Performing data expansion processing on the IP address to be queried to obtain the second IP address includes: Determining at least one ellipsis symbol in the IP address to be queried; Determine the omitted fields corresponding to each ellipsis symbol; The IP address to be queried is supplemented according to the omitted fields corresponding to the respective omitted symbols to obtain the second IP address.
7. The method according to claim 1, characterized in that For any target IP address; Determining the query identifier corresponding to the target IP address includes: Obtaining an address identification information table corresponding to the address type of the target IP address; Determine the target address segment corresponding to the target IP address in the address identification information table; The address identifier corresponding to the target address segment is determined as the query identifier corresponding to the target IP address.
8. The method according to claim 7, characterized in that The address identifier information table includes multiple address identifiers, the minimum IP address and the maximum IP address of the address segment corresponding to each address identifier, and the number of valid addresses of the address segment corresponding to each address identifier.
9. A location query device, characterized in that: It includes receiving module, normalization processing module, determination module, query processing module and sending module: The receiving module is used to receive a location query request from a server, where the location query request is used to request at least one location information corresponding to at least one Internet Protocol (IP) address to be queried; The normalization processing module is used to perform normalization processing on any IP address to be queried according to the location query request to obtain a target IP address; The determination module is used to determine the query identifier corresponding to each target IP address, the query identifier is an address identifier storing the location information corresponding to each IP address in the database, and the address identifier corresponds to at least one address IP; The query processing module is used to perform query processing in the database according to the query identifier corresponding to each target IP address to obtain the location information corresponding to each IP address to be queried; The sending module is used to send the location information corresponding to each IP address to be queried to the server.
10. An electronic device, characterized in that: include: a processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 8 when executed by a processor.
12. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 8 when the computer program is executed by a processor.