Disclosure of Invention
The invention mainly aims to provide a method, a system, equipment and a storage medium for identifying an IP address of an access terminal, which aim to solve the technical problem of how to accurately identify the IP address of the access terminal.
In order to achieve the above object, the present invention provides a method for identifying an IP address of an access terminal, where the method for identifying an IP address of an access terminal includes:
creating a data channel between the link end and the access end;
acquiring SDP text information corresponding to the wall-turning network through the data channel;
analyzing the SDP text information to obtain an SDP analysis result;
if the SDP analysis result contains candidate information, address identification is carried out on the candidate information through a regular expression, and the IP address of the access terminal is obtained.
Optionally, the step of creating a data channel between the link end and the access end includes:
creating an RTCPeERConnection object on a link end, and initializing the RTCPeERConnection object;
and creating a data channel between the link end and the access end through a pc.
Optionally, the step of acquiring SDP text information corresponding to the wall-turning network through the data channel includes:
generating an buffer corresponding to the wall-turning network through a pc.createoffer based on the data channel;
and acquiring SDP text information according to the buffer corresponding to the wall-turning network.
Optionally, if the SDP parsing result includes candidate information, the step of obtaining the IP address of the access terminal further includes:
judging whether the IP address exists in the localIPs object or not through an ipitate function;
and if not, storing the IP address into the localIPs object through an onNewIP callback function.
Optionally, if the SDP parsing result includes candidate information, the step of obtaining the IP address of the access terminal further includes:
setting a session description protocol of the link terminal through a pc.setLocaldescription method;
and transmitting a success callback function and a failure callback function based on the session description protocol.
In addition, in order to achieve the above object, the present invention further provides an IP address identifying system of an access terminal, where the IP address identifying system of the access terminal includes:
the creation module is used for creating a data channel between the link end and the access end;
the acquisition module is used for acquiring SDP text information corresponding to the wall-turning network through the data channel;
the analysis module is used for analyzing the SDP text information to obtain an SDP analysis result;
and the identification module is used for carrying out address identification on the candidate item information through a regular expression if the SDP analysis result contains the candidate item information, so as to obtain the IP address of the access terminal.
In addition, in order to achieve the above object, the present invention further provides an IP address identifying apparatus for an access terminal, the apparatus including: the system comprises a memory, a processor and an IP address identification program of an access terminal stored on the memory and capable of running on the processor, wherein the IP address identification program of the access terminal is configured to realize the steps of the IP address identification method of the access terminal.
In addition, in order to achieve the above object, the present invention also proposes a storage medium having stored thereon an IP address identifying program of an access terminal, which when executed by a processor, implements the steps of the IP address identifying method of the access terminal as described above.
The invention firstly establishes a data channel between a link end and an access end, then obtains SDP text information corresponding to a wall-turning network through the data channel, then analyzes the SDP text information to obtain an SDP analysis result, and if the SDP analysis result contains candidate information, carries out address identification on the candidate information through a regular expression to obtain an IP address of the access end. Compared with the prior art that the DNS query method can identify the existence of the wall-turning network, but cannot accurately identify the real IP address of the user, the invention can accurately identify the IP address of the access terminal by analyzing SDP text information, thereby improving the network security and management efficiency.
Detailed Description
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
Referring to fig. 1, fig. 1 is a schematic structural diagram of an IP address identifying device at an access end of a hardware running environment according to an embodiment of the present invention.
As shown in fig. 1, the IP address identifying apparatus of the access terminal may include: a processor 1001, such as a central processing unit (Central Processing Unit, CPU), a communication bus 1002, a user interface 1003, a network interface 1004, a memory 1005. Wherein the communication bus 1002 is used to enable connected communication between these components. The user interface 1003 may include a Display, an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may further include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a Wireless interface (e.g., a Wireless-Fidelity (Wi-Fi) interface). The Memory 1005 may be a high-speed random access Memory (Random Access Memory, RAM) or a stable nonvolatile Memory (NVM), such as a disk Memory. The memory 1005 may also optionally be a storage system separate from the processor 1001 described above.
It will be appreciated by those skilled in the art that the structure shown in fig. 1 does not constitute a limitation of the IP address identification device of the access terminal, and may include more or fewer components than shown, or may combine certain components, or may have a different arrangement of components.
As shown in fig. 1, an operating system, a network communication module, a user interface module, and an IP address identification program of an access terminal may be included in the memory 1005 as one type of storage medium.
In the IP address identifying device of the access terminal shown in fig. 1, the network interface 1004 is mainly used for data communication with a network server; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 in the IP address identifying device of the access terminal of the present invention may be disposed in the IP address identifying device of the access terminal, where the IP address identifying device of the access terminal invokes the IP address identifying program of the access terminal stored in the memory 1005 through the processor 1001, and executes the IP address identifying method of the access terminal provided by the embodiment of the present invention.
The embodiment of the invention provides an IP address identification method of an access terminal, and referring to fig. 2, fig. 2 is a flow chart of a first embodiment of the IP address identification method of the access terminal of the invention.
In this embodiment, the method for identifying the IP address of the access terminal includes the following steps:
step S10: and creating a data channel between the link end and the access end.
It is to be understood that the execution body of the embodiment may be a link terminal with functions of data processing, network communication, program running, etc., or may be other computer devices with similar functions, etc., and the embodiment is not limited.
It should be noted that, the processing manner of creating the data channel between the link end and the access end is to create an rtcp ererconnection object through a real-time communication protocol, and perform an initialization process on the rtcp ererconnection object; the link end (i.e., the home end) and the access end create a data channel through a pc.createdatachannel ("") based on the initialized rtcp connection object.
In a specific implementation, when a connection is established, an rtcp connection object of WebRTC is used to obtain IP information, an rtcp connection object needs to be created to initialize, an ICE server address is set as a STUN server of Google, and then a callback function onNewIP is defined for processing the obtained IP address. A null function noop is defined for use as a placeholder for the callback function. An object localIPs is defined for storing the acquired IP addresses. A regular expression ipRegex is defined for matching IP addresses. A variable key is defined for traversing the IP address. A data channel was created using pc.
Step S20: and acquiring SDP text information corresponding to the wall-turning network through the data channel.
Further, generating an buffer corresponding to the wall-turning network through the pc.createoffer based on the data channel; and acquiring SDP text information according to the Offer corresponding to the wall-turning network.
In this embodiment, pc.createoffer is used to generate an buffer, which contains SDP information.
Step S30: and analyzing the SDP text information to obtain an SDP analysis result.
It should be noted that the SDP parsing result may include candidate information (i.e., a "candidate" field), or may not include candidate information.
Step S40: if the SDP analysis result contains candidate information, address identification is carried out on the candidate information through a regular expression, and the IP address of the access terminal is obtained.
Further, judging whether an IP address exists in the localIPs object through an ipitate function; and if not, storing the IP address into the localIPs object through an onNewIP callback function. Setting a session description protocol of a link end by a pc.setlocaldescription method; and transmitting a success callback function and a failure callback function based on the session description protocol.
In a specific implementation, the SDP information is traversed according to a row, if a "candidate" field is included in the row, an IP address is matched by using a regular expression ipRegex, and the IP address is processed through a callback function ipIterate. The ipitate function determines whether the IP address already exists in the localIPs object, and if not, calls the onNewIP callback function to process, and stores the IP address in the localIPs object.
It should also be appreciated that the pc.setlocaldescription method is used to set up the local SDP and pass in the success and failure callback functions noop.
The generation of candidates is monitored by a pc. When the icecandate event triggers, judging whether a candidate exists and whether the candidate contains an IP address, if so, matching the IP address by using a regular expression IP Regex, and processing through a callback function ipitate.
It should be noted that, when the method is encapsulated into the webpage JS code, the user who turns over the wall clicks to browse, and the IP address of the visitor can be obtained by using WebRTC function in the above embodiment.
In this embodiment, a data channel is created between a link end and an access end, then SDP text information corresponding to a wall-turning network is acquired through the data channel, then the SDP text information is parsed to obtain an SDP parsing result, and if the SDP parsing result includes candidate information, address identification is performed on the candidate information through a regular expression to obtain an IP address of the access end. Compared with the prior art that the DNS query method can identify the existence of the wall-turning network, but cannot accurately identify the real IP address of the user, in the embodiment, the real IP address of the visitor can be accurately obtained by utilizing the RTCPeerconnection object of the WebRTC without being influenced by factors such as the wall-turning network, and the like, thereby being beneficial to preventing malicious behaviors and network attacks.
Referring to fig. 4, fig. 4 is a block diagram illustrating the structure of a first embodiment of an IP address identifying system at an access terminal according to the present invention.
As shown in fig. 4, the IP address identifying system of the access terminal according to the embodiment of the present invention includes:
the creation module 4001 is configured to create a data channel between the link end and the access end.
It should be noted that, the processing manner of creating the data channel between the link end and the access end is to create an rtcp ererconnection object through a real-time communication protocol, and perform an initialization process on the rtcp ererconnection object; and creating a data channel between the link end and the access end through a pc.
In a specific implementation, when a connection is established, an rtcp connection object of WebRTC is used to obtain IP information, an rtcp connection object needs to be created to initialize, an ICE server address is set as a STUN server of Google, and then a callback function onNewIP is defined for processing the obtained IP address. A null function noop is defined for use as a placeholder for the callback function. An object localIPs is defined for storing the acquired IP addresses. A regular expression ipRegex is defined for matching IP addresses. A variable key is defined for traversing the IP address. A data channel was created using pc.
And the acquisition module 4002 is configured to acquire SDP text information corresponding to the wall-turning network through the data channel.
Further, generating an buffer corresponding to the wall-turning network through the pc.createoffer based on the data channel; and acquiring SDP text information according to the Offer corresponding to the wall-turning network.
In this embodiment, pc.createoffer is used to generate an buffer, which contains SDP information.
And the analysis module 4003 is used for analyzing the SDP text information to obtain an SDP analysis result.
It should be noted that the SDP parsing result may include candidate information (i.e., a "candidate" field), or may not include candidate information.
And the identifying module 4004 is configured to identify, by using a regular expression, the candidate information if the SDP parsing result includes the candidate information, and obtain an IP address of the access terminal.
Further, judging whether an IP address exists in the localIPs object through an ipitate function; and if not, storing the IP address into the localIPs object through an onNewIP callback function. Setting a session description protocol of a link end by a pc.setlocaldescription method; and transmitting a success callback function and a failure callback function based on the session description protocol.
In a specific implementation, the SDP information is traversed according to a row, if a "candidate" field is included in the row, an IP address is matched by using a regular expression ipRegex, and the IP address is processed through a callback function ipIterate. The ipitate function determines whether the IP address already exists in the localIPs object, and if not, calls the onNewIP callback function to process, and stores the IP address in the localIPs object.
It should also be appreciated that the pc.setlocaldescription method is used to set up the local SDP and pass in the success and failure callback functions noop.
The generation of candidates is monitored by a pc. When the icecandate event triggers, judging whether a candidate exists and whether the candidate contains an IP address, if so, matching the IP address by using a regular expression IP Regex, and processing through a callback function ipitate.
It should be noted that, when the method is encapsulated into the webpage JS code, the user who turns over the wall clicks to browse, and the IP address of the visitor can be obtained by using WebRTC function in the above embodiment.
In this embodiment, a data channel is created between a link end and an access end, then SDP text information corresponding to a wall-turning network is acquired through the data channel, then the SDP text information is parsed to obtain an SDP parsing result, and if the SDP parsing result includes candidate information, address identification is performed on the candidate information through a regular expression to obtain an IP address of the access end. Compared with the prior art that the DNS query method can identify the existence of the wall-turning network, but cannot accurately identify the real IP address of the user, in the embodiment, the real IP address of the visitor can be accurately obtained by utilizing the RTCPeerconnection object of the WebRTC without being influenced by factors such as the wall-turning network, and the like, thereby being beneficial to preventing malicious behaviors and network attacks.
Other embodiments or specific implementation manners of the IP address identifying system of the access terminal of the present invention may refer to the above method embodiments, and are not described herein again.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. read-only memory/random-access memory, magnetic disk, optical disk), comprising instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the method according to the embodiments of the present invention.
The foregoing description is only of the preferred embodiments of the present invention, and is not intended to limit the scope of the invention, but rather is intended to cover any equivalents of the structures or equivalent processes disclosed herein or in the alternative, which may be employed directly or indirectly in other related arts.