WO2019205288A1 - Connection establishment method, system, and device, and computer readable storage medium - Google Patents

Connection establishment method, system, and device, and computer readable storage medium Download PDF

Info

Publication number
WO2019205288A1
WO2019205288A1 PCT/CN2018/094106 CN2018094106W WO2019205288A1 WO 2019205288 A1 WO2019205288 A1 WO 2019205288A1 CN 2018094106 W CN2018094106 W CN 2018094106W WO 2019205288 A1 WO2019205288 A1 WO 2019205288A1
Authority
WO
WIPO (PCT)
Prior art keywords
login
connection
client
server
request message
Prior art date
Application number
PCT/CN2018/094106
Other languages
French (fr)
Chinese (zh)
Inventor
林小渝
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2019205288A1 publication Critical patent/WO2019205288A1/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/08Network architectures or network communication protocols for network security for authentication of entities
    • H04L63/0815Network architectures or network communication protocols for network security for authentication of entities providing single-sign-on or federations
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0805Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability
    • H04L43/0811Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability by checking connectivity
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/10Active monitoring, e.g. heartbeat, ping or trace-route
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/565Conversion or adaptation of application format or content

Definitions

  • the present application relates to the field of communications technologies, and in particular, to a connection establishing method, system, device, and computer readable storage medium.
  • the existing client and server establish a connection method, that is, the client first sends a connection request to the server, and establishes a communication connection with the server. After the client connects to the server, the client then authenticates the connection request to the user's identity, and then performs operations such as logging in and sending a message. That is, during the process of establishing a connection between the client and the server, the client only needs to obtain the IP of the server (Internet). Protocol, the protocol that is interconnected between networks, can establish a connection with the server. Before establishing a connection with the server, there is no need to verify the identity of the user, so it is easy for illegal elements to connect to the server, which reduces the security of the server. Sex.
  • the main purpose of the present application is to provide a connection establishment method, system, device and computer readable storage medium, aiming at solving the technical problem that existing illegal molecules are easily connected to a server, thereby causing low security of the server.
  • connection establishment method includes the following steps:
  • the server After the server receives the login request, the login request is verified, and the corresponding verification data is obtained, where the login request is sent by the client to the server after detecting the login request;
  • the server After the server receives the request message, it is detected whether the request message meets the establishment rule for establishing a connection;
  • connection establishment system includes a server and a client
  • server includes:
  • a verification module configured to verify the login request after receiving the login request, and obtain corresponding verification data
  • a first sending module configured to send the verification data to the client
  • a detecting module configured to: after receiving the request message sent by the client, detecting whether the request message meets the establishment rule for establishing a connection;
  • the client includes:
  • a second sending module configured to send the login request to the server after detecting the login request
  • An obtaining module configured to: after receiving the verification data sent by the server, and determining, according to the verification data, that the login operation corresponding to the login request is in a normal state, acquiring a login string in the verification data;
  • a conversion module configured to convert the login string into a request message and send the message to the server.
  • connection establishing device which includes a memory, a microprocessor, and a connection establishment program stored on the memory and operable on the processor.
  • connection establishment program stored on the memory and operable on the processor.
  • the present application further provides a computer readable storage medium having a connection establishment program stored thereon, and the connection establishment program is implemented by a processor to implement connection establishment as described above. The steps of the method.
  • the application sends the login request to the server for login verification; when the server receives the login request, the login request is verified, and the verification data is returned to the client; when the client is based on the verification data
  • the login string in the verification data is obtained, and the login string is converted into a request message and sent to the server; when the server receives the request message, and the detection of the request message is met, After establishing the connection establishment rules, the server establishes a connection with the client.
  • FIG. 1 is a schematic flowchart of a first embodiment of a method for establishing a connection according to the present application
  • FIG. 2 is a schematic flowchart of a second embodiment of a method for establishing a connection according to the present application
  • FIG. 3 is a schematic flowchart of a third embodiment of a method for establishing a connection according to the present application.
  • Figure 4 is a block diagram showing the function of the preferred embodiment of the connection establishment system of the present application.
  • FIG. 5 is a schematic structural diagram of a hardware operating environment involved in an embodiment of the present application.
  • FIG. 1 is a schematic flowchart of a first embodiment of a method for establishing a connection according to the present application.
  • connection establishment method provides an embodiment of a connection establishment method. It should be noted that although the logical order is shown in the flowchart, in some cases, the illustrated or described may be performed in an order different from the ones herein. A step of.
  • connection establishment method can be applied to the server, and the connection establishment method includes:
  • Step S10 After receiving the login request, the server verifies the login request, and obtains corresponding verification data, where the login request is sent by the client to the server after detecting the login request.
  • the client When the client detects a login request triggered by its user, it sends a login request to the server. After the server receives the login request sent by the client, the server verifies the login request, obtains the verification result, and obtains corresponding verification data according to the verification result.
  • the login request is triggered by the client user when the client needs to connect to the server.
  • the verification data includes, but is not limited to, a login string, a login device ID (identification number) number, a login user name, and a message ID number.
  • the login string can determine whether the client that sends the login request has the right to establish a connection with the server; the login device ID number is the identity of the client, and the login device ID can determine which client the client established with the server is;
  • the login user name is the identifier of the user who triggered the login request.
  • the server can uniquely identify the user who triggered the login request by logging in the user name.
  • the message ID is the data transmitted between the client and the server after the client and the server establish a connection.
  • the server can be XMPP (Extensible Messaging and Presence Protocol, a scalable communication and presentation protocol server.
  • step S10 includes:
  • Step a after the server receives the login request, extract the login user name and the login password in the login request.
  • the server receives the login request sent by the client, the login user name and the login password are extracted in the login request.
  • the login password is the password required for the client user to log in to the client. Understandably, when the login user name and login password are correct, the user can successfully log in to the client.
  • Step b performing login verification according to the login user name and the login password, to obtain corresponding verification data
  • the configuration information is read, the connection information connected to the server is set according to the configuration information, and the login request is sent to the server according to the connection information. .
  • the server After the server extracts the login user name and the login password in the login request, the server performs login verification according to the login user name and the login password, and obtains verification data corresponding to the login request.
  • the server performs login verification based on the login user name and login password.
  • the specific process is as follows: The server searches for the login user name in its database. If the server finds the login user name in its database, the server determines that the login user name is verified; if the server does not find the login user name in its database, the server determines that the login user name has not passed the verification.
  • the server compares the login password with a pre-stored preset password in its database. If there is a preset password in the database that matches the login password, the server determines that the login password is verified; if the database does not have a preset password consistent with the login password, the server determines that the login password has not passed the verification.
  • the server When the login user name and the login password are verified, the server generates the verification data carrying the login string; when the login user name fails the verification, and/or the login password fails the verification, the server generates the verification data that does not carry the login string. .
  • the configuration information is read, the connection environment established with the server is determined according to the configuration information, and the connection information of the connection server is set according to the configuration information, and the HTTP (HyperText) is used according to the connection information.
  • Transfer Protocol Hypertext Transfer Protocol
  • the connection environment includes but is not limited to the test environment and the local environment.
  • the local environment is the environment where the client and the server are connected, and the test environment is a preset environment.
  • the configuration information includes the client type, the server's IP address, the server's port number, the communication technology type, the communication data transmission type, and the message parsing method.
  • the communication technology type can be set to java non-blocking IO (java non-blocking IO); communication data transmission type can be set to protobuf, protobuf is a specified data propagation format; message parsing method can be used to transfer data to the server, according to google The protobuf protocol converts data into messages.
  • the connection information is the server's IP address and port number.
  • the process of setting the connection information according to the configuration information by the client is: Step 1: Convert the read configuration information into Java. Map object.
  • the array has only two elements [key, value], and a Map ⁇ String is used at this time.
  • Key, String value> Converts the array object into a Java Map object.
  • Step 2 The client assigns a value to its system parameter class member variable to make Java
  • the data in the Map object matches the corresponding member variable.
  • System parameter class System The following member variables are defined in Config: 1client: client mode; 2transport: data transfer mode between client and server; 3host: server IP address; 4port: server port number; 5 Handlers: listens for processing classes.
  • Each member variable has a set (set) and get (get) method. In this embodiment, the system is obtained by using reflection technology. All methods of the Config object, after traversing, filter out the beginning of the set, the method modification type is public or static, and the return type is void (empty type). The method name is substring(3) to get the new string, and Java. The key in the Map object is matched to get the corresponding value.
  • the client After the client sets the connection information of the connection server according to the configuration information, the client performs encapsulation and instantiation operations, and starts a listening thread to listen to the process of establishing a connection with the server through the listening thread, and obtain verification data returned by the server.
  • the client is an interface class and has an implementation class AbStract. Client, AbStract Client has two implementation classes Swing Client and Console Client.
  • the absolute path of the Client class is also obtained by using the reflection technique to get the corresponding class name according to the key, and then calling Class.forName to instantiate the instance of the Client and saving it to the cache. It should be noted that reflection technology is an important mechanism in .NET.
  • the listener thread is a class that encapsulates and instantiates the client's process so that the listener thread can better listen to the entire process of creating a connection during the creation of the connection.
  • step S20 the verification data is sent to the client, so that the client obtains the verification data, and after determining that the login operation corresponding to the login request is in a normal state according to the verification data, obtain the verification data.
  • the login string in the verification data is converted, and the login string is converted into a request message and sent to the server.
  • the verification data is sent to the client, so that the client receives the verification data, and determines that the login operation corresponding to the login request is in a normal state according to the verification data, and obtains the login string in the verification data. Convert the login string into a request message and send it to the server. Further, when the client receives the verification data, the verification data is saved into its system parameter class, so that the login string is obtained in the system parameter category during the process of establishing the connection with the server.
  • step S20 includes:
  • Step c sending the verification data to the client.
  • the client After the client receives the verification data, detecting whether a login string exists in the verification data;
  • the login operation corresponding to the login request is determined to be in a normal state, the login string in the verification data is obtained, and the login string is converted into a request message. Sent to the server.
  • the server sends the verification data to the client
  • the client detects whether the login string exists in the verification data. If the login string is detected in the verification data, the client determines that the login operation corresponding to the login request is in a normal state, and obtains the login string in the verification data, converts the login string into a request packet, and sends the TCP through the nio technology.
  • Transmission The Control Protocol Transmission Control Protocol
  • Nio technology provides non-blocking I/O
  • the asynchronous input and output mechanism provides an achievable basic mechanism for improving system performance.
  • the client determines that the login operation corresponding to the login request is in an abnormal state, and closes the monitoring thread. After the client determines that the login operation is in an abnormal state, the client outputs a login abnormality prompt message to prompt the user to log in abnormally.
  • the step of converting the login string into a request message and sending the message to the server includes:
  • Step d Perform a bit operation according to the length of the login string to recombine the login string to obtain the reassembled login string.
  • the process of the client converting the login string into the request message and sending the message to the server may be: the client obtains the length of the login string, performs a bit operation according to the length of the login string in the for loop body, and reorganizes the login. String, get the refactored login string.
  • Step e Perform modulo operation on the re-established login string and the preset prime number to obtain a data packet corresponding to the login string.
  • the re-composed login string is modulo-operated with the preset prime number to obtain a data packet corresponding to the login string.
  • the preset prime number is 31.
  • the prime number 31 is the length specified in Java. It can be understood that the preset prime number can be modified to other prime numbers in the Java code as needed.
  • step f the data packet is converted into a request message and sent to the server by using a preset protocol.
  • the client After the client obtains the data packet corresponding to the login string, the client converts the data packet into a request packet by using a preset protocol, and sends the request packet to the server.
  • the default agreement can be Google Protobuf protocol or Apache Thrift protocol.
  • Step S30 after the server receives the request message, it is detected whether the request message meets the establishment rule for establishing a connection.
  • the server After receiving the request packet sent by the client, the server detects whether the request packet meets the establishment rule for establishing a connection.
  • step S30 includes:
  • Step g After receiving the request message, the server acquires a login string in the request message, and detects whether a pre-login in the database is found to be the same as the login string in the request message. Set the string.
  • the process of detecting whether the request packet meets the establishment rule of the connection is: after the server receives the request message, the server parses the request message, obtains the login string in the request message, and detects in the database. Whether to find the same preset string as the login string in the request message.
  • the database can be mysql database or RAM (Random-Access Memory, random access memory) memory.
  • step h if the preset character string is found, it is determined that the request message meets the establishment rule for establishing a connection.
  • the server determines that the request message conforms to the connection rule for establishing the connection.
  • step i if the preset character string is not found, it is determined that the request message does not meet the establishment rule for establishing a connection.
  • the server determines that the request packet does not meet the connection rule for establishing a connection.
  • Step S40 If it is detected that the request message meets the establishment rule, establish a connection with the client.
  • the server After the server detects that the request message conforms to the establishment rule for establishing a connection, the server establishes a connection with the client. When a connection is established between the server and the client, the client can transmit data and communicate with the server.
  • the login request is sent to the server for login verification; when the server receives the login request, the login request is verified, and the verification data is returned to the client; when the client is verified according to the verification After the data is determined that the login operation corresponding to the login request is in a normal state, the login string in the verification data is obtained, and the login string is converted into a request message and sent to the server; when the server receives the request message, and the request message is detected, After the establishment rules for establishing a connection are met, the server establishes a connection with the client.
  • connection establishment method of the present application is proposed.
  • connection establishment method further includes:
  • Step S50 Generate first prompt information that successfully establishes a connection with the client, and send the first prompt information to the client, so that the client monitors after receiving the first prompt information.
  • the server After the server successfully establishes a connection with the client, the server generates a first prompt information for successfully establishing a connection with the client, and sends the first prompt information to the client. After receiving the first prompt information, the client outputs the first prompt information in its display interface, and monitors the connection state with the server after receiving the first prompt information.
  • the manner in which the client outputs the first prompt information includes, but is not limited to, a text form and a voice form. For example, the client can output the text information of “successful connection” in its display interface to output the first prompt information.
  • the process of monitoring the connection status between the client and the server is as follows: the client creates a heartbeat packet, and starts a heartbeat packet after creating the heartbeat packet, and sends a timing task to the server through the heartbeat packet to monitor the connection state between the client and the server. . After the client starts the heartbeat packet, the client obtains the corresponding heartbeat log and stores the heartbeat log, so that the user determines whether the client and the server are in the connected state according to the heartbeat log. It should be noted that the client sends a scheduled task to the server through the heartbeat packet, that is, the client continuously sends a connection request to the server.
  • the sending server and the client successfully establish a first prompt information of the connection to the client, and when the client receives the first prompt information, monitor the connection between the server and the server. Status so that client users can keep abreast of the connection status between the client and the server.
  • connection establishment method of the present application is proposed.
  • connection establishment method further includes:
  • Step S60 If it is detected that the request message does not meet the establishment rule, the connection with the client is refused, and the second prompt information is generated.
  • the server If the server detects that the request message does not meet the establishment rule for establishing a connection, the server refuses to establish a connection with the client, and generates a second prompt message for establishing a connection failure.
  • Step S70 Send the second prompt information to the client, so that the client prompts the client user that the connection establishment fails according to the second prompt information.
  • the second prompt information is sent to the client.
  • the client After receiving the second prompt information, the client outputs the second prompt information in its display interface to prompt the connection establishment failure between the user and the server according to the second prompt information.
  • the output manner of the second prompt information output by the client includes, but is not limited to, a text form and a voice form. If the client can display in its display interface The text message "Connection failed" to output the second prompt message.
  • the second prompt information is sent to the client, so that the client prompts the connection establishment between the client user and the server to fail according to the second prompt information, so as to facilitate The user can decide whether to re-establish the connection as needed.
  • connection establishment system includes a server 10 and a client 20
  • server 10 includes:
  • the verification module 11 is configured to: after receiving the login request, verify the login request, and obtain corresponding verification data;
  • the first sending module 12 is configured to send the verification data to the client 20;
  • the detecting module 13 is configured to: after receiving the request message sent by the client 20, check whether the request message meets the establishment rule for establishing a connection;
  • the establishing module 14 is configured to establish a connection with the client 20 if it is detected that the request message meets the establishment rule;
  • the client 20 includes:
  • the second sending module 21 is configured to send the login request to the server 10 after detecting the login request;
  • the obtaining module 22 is configured to: after receiving the verification data sent by the server 10, and determining, according to the verification data, that the login operation corresponding to the login request is in a normal state, acquiring a login string in the verification data;
  • the conversion module 23 is configured to convert the login string into a request message and send the message to the server 10.
  • the login request is sent to the server 10 for login verification.
  • the verification module 11 receives the login request
  • the login request is verified, and the first sending module 12 returns the verification.
  • the data is sent to the client 20; when the obtaining module 22 of the client 20 determines that the login operation corresponding to the login request is in a normal state according to the verification data, the login string in the verification data is acquired, and the conversion module 23 converts the login string into the request message.
  • the connection module 10 establishes a connection with the client 20 after the detection module 13 of the server 10 receives the request message and detects that the request message conforms to the establishment rule for establishing a connection.
  • the verification module 11 includes:
  • An extracting unit configured to: after receiving the login request, extract the login user name and the login password in the login request;
  • a verification unit configured to perform login verification according to the login user name and the login password, to obtain corresponding verification data
  • the second sending module 21 is further configured to: after detecting the login request, read configuration information, set connection information connected to the server 10 according to the configuration information, and send the login request according to the connection information. Sent to the server 10.
  • the obtaining module 22 includes:
  • a detecting unit configured to detect whether a login string exists in the verification data after receiving the verification data
  • the first obtaining unit is configured to: if it is detected that the login string exists in the verification data, determine that the login operation corresponding to the login request is in a normal state, and acquire a login string in the verification data.
  • the conversion module 23 includes:
  • An operation unit configured to perform a bit operation according to the length of the login string to recombine the login string to obtain the reassembled login string; and the reassembled login string and the preset prime number Performing a modulo operation to obtain a data packet corresponding to the login string;
  • a converting unit configured to convert the data packet into a request message and send the request message to the server 10 by using a preset protocol.
  • the detecting module 13 includes:
  • a second acquiring unit configured to acquire a login string in the request packet after receiving the request packet
  • a detecting unit configured to detect whether a preset character string that is the same as the login string in the request message is found in the database
  • a determining unit configured to: if the preset character string is found, determine that the request message meets a setup rule for establishing a connection; if the preset character string is not found, determine that the request message does not meet the establishment The establishment rules for the connection.
  • server 10 further includes:
  • a first generating module configured to generate first prompt information that successfully establishes a connection with the client 20
  • the first sending module 12 is further configured to send the first prompt information to the client 20, so that the client 20 monitors the server 10 after receiving the first prompt information. Connection status.
  • server 10 further includes:
  • a second generating module if it is detected that the request packet does not meet the establishing rule, refuse to establish a connection with the client 20, and generate second prompt information;
  • the first sending module 12 is further configured to send the second prompt information to the client 20, so that the client 20 prompts the client user to establish a connection failure according to the second prompt information.
  • connection establishment system is basically the same as the embodiments of the foregoing connection establishment method, and details are not described herein again.
  • FIG. 5 is a schematic structural diagram of a hardware operating environment involved in an embodiment of the present application.
  • FIG. 5 can be a schematic structural diagram of a hardware running environment of the connection establishment device.
  • the connection establishing device in the embodiment of the present application may be a terminal device such as a PC or a portable computer.
  • the connection establishing device may include a processor 1001, such as a CPU, a memory 1005, a user interface 1003, and a communication bus 1002.
  • the communication bus 1002 is used to implement connection communication between these components.
  • the user interface 1003 can include a display, an input unit such as a keyboard, and the optional user interface 1003 can also include a standard wired interface, a wireless interface.
  • the memory 1005 may be a high speed RAM memory or a stable memory (non-volatile) Memory), such as disk storage.
  • the memory 1005 can also optionally be a storage device independent of the aforementioned processor 1001.
  • connection establishing device may further include a camera, RF (Radio) Frequency, RF) circuits, sensors, audio circuits, WiFi modules, and more.
  • RF Radio
  • RF Radio
  • connection establishing device structure shown in FIG. 5 does not constitute a limitation of the connection establishing device, and may include more or less components than those illustrated, or combine some components or different components. Arrangement.
  • an operating system As shown in FIG. 5, an operating system, a network communication module, a user interface module, and a connection establishment program may be included in the memory 1005 as a computer storage medium.
  • the operating system is a program that manages and controls the connection to establish device hardware and software resources, and supports the connection establishment program and the operation of other software or programs.
  • the user interface 1003 is mainly used to connect a client (user end) to perform data communication with the client; the processor 1001 can be used to call a connection establishment program stored in the memory 1005, and execute The steps of the connection establishment method as described above.
  • connection establishment device of the present application is basically the same as the foregoing embodiments of the connection establishment method, and details are not described herein again.
  • the embodiment of the present application further provides a computer readable storage medium, where the computer readable storage medium stores a connection establishment program, and the connection establishment program is executed by the processor to implement the steps of the connection establishment method as described above. .
  • the foregoing embodiment method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be through hardware, but in many cases, the former is better.
  • Implementation Based on such understanding, the technical solution of the present application, which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM, disk,
  • the optical disc includes a number of instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the methods described in various embodiments of the present application.

Abstract

The present application discloses a connection establishment method, system, and device, and a computer readable storage medium. The method comprises steps of: on receiving a login request a server verifying the login request to obtain corresponding verification data, wherein the login request is sent by a client to the server on detecting the login request; sending the verification data to the client, such that after receiving the verification data, and after determining, according to the verification data, that a login operation corresponding to the login request is in a normal state, the client acquires a login string in the verification data, and converts the login string into a request message and sends the request message to the server; after receiving the request message, the server testing whether the request message meets a connection establishment rule; and if the request message meets the establishment rule, establishing a connection to the client. The present application improves the security of a server.

Description

连接建立方法、系统、设备及计算机可读存储介质  Connection establishment method, system, device and computer readable storage medium
本申请要求于2018年4月24日提交中国专利局、申请号为201810370940.8、发明名称为“连接建立方法、系统、设备及计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在申请中。This application claims priority to Chinese Patent Application No. 201810370940.8, entitled "Connection Establishment Method, System, Equipment, and Computer Readable Storage Media", filed on April 24, 2018, the entire contents of which are hereby incorporated by reference. The citation is incorporated in the application.
技术领域Technical field
本申请涉及通信技术领域,尤其涉及一种连接建立方法、系统、设备及计算机可读存储介质。The present application relates to the field of communications technologies, and in particular, to a connection establishing method, system, device, and computer readable storage medium.
背景技术Background technique
现有客户端和服务器建立连接的方法,都是客户端先发送连接请求给服务器,和服务器建立通信连接。当客户端连接上服务器后,客户端再去认证连接请求对应用户的身份,然后才执行登录和发送消息等操作。即在客户端与服务器建立连接过程中,客户端只要获取到服务器的IP(Internet Protocol,网络之间互连的协议)地址,即可与服务器建立连接,在与服务器建立连接之前,不需要验证用户的身份,因此容易导致非法分子很容易连接到服务器中,降低了服务器的安全性。The existing client and server establish a connection method, that is, the client first sends a connection request to the server, and establishes a communication connection with the server. After the client connects to the server, the client then authenticates the connection request to the user's identity, and then performs operations such as logging in and sending a message. That is, during the process of establishing a connection between the client and the server, the client only needs to obtain the IP of the server (Internet). Protocol, the protocol that is interconnected between networks, can establish a connection with the server. Before establishing a connection with the server, there is no need to verify the identity of the user, so it is easy for illegal elements to connect to the server, which reduces the security of the server. Sex.
发明内容Summary of the invention
本申请的主要目的在于提供一种连接建立方法、系统、设备及计算机可读存储介质,旨在解决现有的非法分子容易连接到服务器中,从而导致服务器安全性低的技术问题。The main purpose of the present application is to provide a connection establishment method, system, device and computer readable storage medium, aiming at solving the technical problem that existing illegal molecules are easily connected to a server, thereby causing low security of the server.
为实现上述目的,本申请提供一种连接建立方法,所述连接建立方法包括步骤:To achieve the above objective, the present application provides a connection establishment method, where the connection establishment method includes the following steps:
当服务器接收到登录请求后,验证所述登录请求,得到对应的验证数据,其中,所述登录请求是所述客户端侦测到登录请求后发送给所述服务器的;After the server receives the login request, the login request is verified, and the corresponding verification data is obtained, where the login request is sent by the client to the server after detecting the login request;
将所述验证数据发送给所述客户端,以供所述客户端在接收到所述验证数据,且根据所述验证数据确定所述登录请求对应的登录操作处于正常状态后,获取所述验证数据中的登录字符串,并将所述登录字符串转换成请求报文发送给所述服务器;And sending the verification data to the client, where the client obtains the verification data, and after determining that the login operation corresponding to the login request is in a normal state according to the verification data, acquiring the verification a login string in the data, and converting the login string into a request message to be sent to the server;
当所述服务器接收到所述请求报文后,检测所述请求报文是否符合建立连接的建立规则;After the server receives the request message, it is detected whether the request message meets the establishment rule for establishing a connection;
若检测到所述请求报文符合所述建立规则,则建立与所述客户端之间的连接。If it is detected that the request message meets the establishment rule, establishing a connection with the client.
此外,为实现上述目的,本申请还提供一种连接建立系统,所述连接建立系统包括服务器和客户端,所述服务器包括:In addition, to achieve the above object, the present application further provides a connection establishment system, where the connection establishment system includes a server and a client, and the server includes:
验证模块,用于当接收到登录请求后,验证所述登录请求,得到对应的验证数据;a verification module, configured to verify the login request after receiving the login request, and obtain corresponding verification data;
第一发送模块,用于将所述验证数据发送给所述客户端;a first sending module, configured to send the verification data to the client;
检测模块,用于当接收到所述客户端发送的请求报文后,检测所述请求报文是否符合建立连接的建立规则;a detecting module, configured to: after receiving the request message sent by the client, detecting whether the request message meets the establishment rule for establishing a connection;
建立模块,用于若检测到所述请求报文符合所述建立规则,则建立与所述客户端之间的连接;Establishing a module, if it is detected that the request message meets the establishment rule, establishing a connection with the client;
所述客户端包括:The client includes:
第二发送模块,用于在侦测到登录请求后,将所述登录请求发送给所述服务器;a second sending module, configured to send the login request to the server after detecting the login request;
获取模块,用于在接收到所述服务器发送的验证数据,且根据所述验证数据确定所述登录请求对应的登录操作处于正常状态后,获取所述验证数据中的登录字符串;An obtaining module, configured to: after receiving the verification data sent by the server, and determining, according to the verification data, that the login operation corresponding to the login request is in a normal state, acquiring a login string in the verification data;
转换模块,用于将所述登录字符串转换成请求报文发送给所述服务器。And a conversion module, configured to convert the login string into a request message and send the message to the server.
此外,为实现上述目的,本申请还提供一种连接建立设备,所述连接建立设备包括存储器、微处理器和存储在所述存储器上并可在所述处理器上运行的连接建立程序,所述连接建立程序被所述微处理器执行时实现如上所述的连接建立方法的步骤。In addition, in order to achieve the above object, the present application further provides a connection establishing device, which includes a memory, a microprocessor, and a connection establishment program stored on the memory and operable on the processor. The steps of the connection establishment method as described above are implemented when the connection establishment program is executed by the microprocessor.
此外,为实现上述目的,本申请还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有连接建立程序,所述连接建立程序被处理器执行时实现如上所述的连接建立方法的步骤。In addition, in order to achieve the above object, the present application further provides a computer readable storage medium having a connection establishment program stored thereon, and the connection establishment program is implemented by a processor to implement connection establishment as described above. The steps of the method.
本申请通过当客户端侦测到登录请求后,将登录请求发送给服务器进行登录验证;当服务器接收到登录请求后,验证该登录请求,并返回验证数据给客户端;当客户端根据验证数据确定登录请求对应的登录操作处于正常状态后,获取验证数据中的登录字符串,将登录字符串转换成请求报文发送给服务器;当服务器接收到请求报文,且检测到该请求报文符合建立连接的建立规则后,服务器才建立与客户端之间的连接。通过在与客户端建立连接之前,先进行登录验证,通过验证后再建立连接,减少了无用连接的创建,减轻了服务器的负担,以及避免了非法分子在获取到服务器的IP地址后即可连接到服务器,提高了服务器的安全性。After the client detects the login request, the application sends the login request to the server for login verification; when the server receives the login request, the login request is verified, and the verification data is returned to the client; when the client is based on the verification data After the login operation corresponding to the login request is in a normal state, the login string in the verification data is obtained, and the login string is converted into a request message and sent to the server; when the server receives the request message, and the detection of the request message is met, After establishing the connection establishment rules, the server establishes a connection with the client. By establishing login authentication before establishing a connection with the client, and establishing a connection after verification, the creation of useless connections is reduced, the burden on the server is reduced, and illegal elements are prevented from being connected after obtaining the IP address of the server. To the server, improve the security of the server.
附图说明DRAWINGS
图1为本申请连接建立方法第一实施例的流程示意图;1 is a schematic flowchart of a first embodiment of a method for establishing a connection according to the present application;
图2为本申请连接建立方法第二实施例的流程示意图;2 is a schematic flowchart of a second embodiment of a method for establishing a connection according to the present application;
图3为本申请连接建立方法第三实施例的流程示意图;3 is a schematic flowchart of a third embodiment of a method for establishing a connection according to the present application;
图4位本申请连接建立系统较佳实施例的功能示意图模块图;Figure 4 is a block diagram showing the function of the preferred embodiment of the connection establishment system of the present application;
图5是本申请实施例方案涉及的硬件运行环境的结构示意图。FIG. 5 is a schematic structural diagram of a hardware operating environment involved in an embodiment of the present application.
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The implementation, functional features and advantages of the present application will be further described with reference to the accompanying drawings.
具体实施方式detailed description
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。It is understood that the specific embodiments described herein are merely illustrative of the application and are not intended to be limiting.
本申请提供一种连接建立方法,参照图1,图1为本申请连接建立方法第一实施例的流程示意图。The present application provides a method for establishing a connection. Referring to FIG. 1, FIG. 1 is a schematic flowchart of a first embodiment of a method for establishing a connection according to the present application.
本申请实施例提供了连接建立方法的实施例,需要说明的是,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。The embodiment of the present application provides an embodiment of a connection establishment method. It should be noted that although the logical order is shown in the flowchart, in some cases, the illustrated or described may be performed in an order different from the ones herein. A step of.
连接建立方法可应用于服务器中,连接建立方法包括:The connection establishment method can be applied to the server, and the connection establishment method includes:
步骤S10,当服务器接收到登录请求后,验证所述登录请求,得到对应的验证数据,其中,所述登录请求是所述客户端侦测到登录请求后发送给所述服务器的。Step S10: After receiving the login request, the server verifies the login request, and obtains corresponding verification data, where the login request is sent by the client to the server after detecting the login request.
当客户端侦测到其用户触发的登录请求后,将登录请求发送给服务器。当服务器接收到客户端发送的登录请求后,服务器验证该登录请求,得到验证结果,并根据验证结果得到对应的验证数据。其中,该登录请求为客户端需要连接服务器时,客户端用户触发的。验证数据包括但不限于登录字符串,登录设备ID(身份标识号)号、登录用户名和消息ID号。通过该登录字符串可以确定发送登录请求的客户端是否存在与服务器建立连接的权限;登录设备ID号为客户端的身份标识,通过登录设备ID可以确定与服务器建立的客户端是哪一个客户端;登录用户名是触发该登录请求用户的标识,通过登录用户名,服务器可唯一确定触发该登录请求的用户;消息ID为客户端和服务器建立连接后,客户端和服务器之间所传输的数据的标识。在本实施例中,服务器可为XMPP(Extensible Messaging and Presence Protocol,可扩展通讯和表示协议)服务器。When the client detects a login request triggered by its user, it sends a login request to the server. After the server receives the login request sent by the client, the server verifies the login request, obtains the verification result, and obtains corresponding verification data according to the verification result. The login request is triggered by the client user when the client needs to connect to the server. The verification data includes, but is not limited to, a login string, a login device ID (identification number) number, a login user name, and a message ID number. The login string can determine whether the client that sends the login request has the right to establish a connection with the server; the login device ID number is the identity of the client, and the login device ID can determine which client the client established with the server is; The login user name is the identifier of the user who triggered the login request. The server can uniquely identify the user who triggered the login request by logging in the user name. The message ID is the data transmitted between the client and the server after the client and the server establish a connection. Logo. In this embodiment, the server can be XMPP (Extensible Messaging and Presence Protocol, a scalable communication and presentation protocol server.
进一步地,步骤S10包括:Further, step S10 includes:
步骤a,当所述服务器接收到登录请求后,在所述登录请求中提取登录用户名和登录密码。Step a, after the server receives the login request, extract the login user name and the login password in the login request.
进一步地,当服务器接收到客户端发送的登录请求后,在登录请求中提取登录用户名和登录密码。其中,该登录密码为客户端用户登录客户端时所需的密码。可以理解的是,当登录用户名和登录密码都正确时,用户才能成功登录客户端。Further, after the server receives the login request sent by the client, the login user name and the login password are extracted in the login request. The login password is the password required for the client user to log in to the client. Understandably, when the login user name and login password are correct, the user can successfully log in to the client.
步骤b,根据所述登录用户名和所述登录密码进行登录验证,得到对应的验证数据;Step b, performing login verification according to the login user name and the login password, to obtain corresponding verification data;
其中,当所述客户端侦测到所述登录请求后,读取配置信息,根据所述配置信息设置连接所述服务器的连接信息,根据所述连接信息将所述登录请求发送给所述服务器。After the client detects the login request, the configuration information is read, the connection information connected to the server is set according to the configuration information, and the login request is sent to the server according to the connection information. .
当服务器在登录请求中提取到登录用户名和登录密码后,服务器根据登录用户名和登录密码进行登录验证,得到与登录请求对应的验证数据。服务器根据登录用户名和登录密码进行登录验证具体过程为:服务器在其数据库中查找该登录用户名。若服务器在其数据库中查找到该登录用户名,服务器则确定登录用户名通过验证;若服务器在其数据库中未查找到该登录用户名,服务器则确定登录用户名未通过验证。服务器将登录密码与其数据库中预先存储的预设密码进行对比。若数据库中存在与登录密码一致的预设密码,服务器则确定登录密码通过验证;若数据库中未存在与登录密码一致的预设密码,服务器则确定登录密码未通过验证。After the server extracts the login user name and the login password in the login request, the server performs login verification according to the login user name and the login password, and obtains verification data corresponding to the login request. The server performs login verification based on the login user name and login password. The specific process is as follows: The server searches for the login user name in its database. If the server finds the login user name in its database, the server determines that the login user name is verified; if the server does not find the login user name in its database, the server determines that the login user name has not passed the verification. The server compares the login password with a pre-stored preset password in its database. If there is a preset password in the database that matches the login password, the server determines that the login password is verified; if the database does not have a preset password consistent with the login password, the server determines that the login password has not passed the verification.
当登录用户名和登录密码都通过验证时,服务器生成携带有登录字符串的验证数据;当登录用户名未通过验证,和/或登录密码未通过验证时,服务器生成未携带登录字符串的验证数据。When the login user name and the login password are verified, the server generates the verification data carrying the login string; when the login user name fails the verification, and/or the login password fails the verification, the server generates the verification data that does not carry the login string. .
进一步地,当客户端侦测到登录请求后,读取配置信息,根据配置信息确定与服务器建立连接的连接环境,并根据配置信息设置连接服务器的连接信息,根据连接信息,通过HTTP(HyperText Transfer Protocol,超文本传输协议)将登录请求发送给服务器。Further, when the client detects the login request, the configuration information is read, the connection environment established with the server is determined according to the configuration information, and the connection information of the connection server is set according to the configuration information, and the HTTP (HyperText) is used according to the connection information. Transfer Protocol, Hypertext Transfer Protocol) sends a login request to the server.
其中,连接环境包括但不限于测试环境和本地环境。本地环境为客户端与服务器连接的环境,测试环境为预先设置好的环境。配置信息包括客户端类型、服务器的IP地址、服务器的端口号、通信技术类型、通信数据传输类型和消息解析方法等。如在本实施例,通信技术类型可设置为java非阻塞式IO (java non-blocking IO);通信数据传输类型可设置为protobuf,protobuf是一个规定好的数据传播格式;消息解析方法可为在传输数据给服务器时,按照google protobuf协议将数据转换成报文。Among them, the connection environment includes but is not limited to the test environment and the local environment. The local environment is the environment where the client and the server are connected, and the test environment is a preset environment. The configuration information includes the client type, the server's IP address, the server's port number, the communication technology type, the communication data transmission type, and the message parsing method. As in this embodiment, the communication technology type can be set to java non-blocking IO (java non-blocking IO); communication data transmission type can be set to protobuf, protobuf is a specified data propagation format; message parsing method can be used to transfer data to the server, according to google The protobuf protocol converts data into messages.
连接信息为服务器的IP地址和端口号。客户端根据配置信息设置连接信息的过程为:第一步:将所读取的配置信息转成Java Map对象。其中,配置信息存放在client(客户端).properties中,采用key=value形式存储,properties表示一个持久的属性集,属性列表中每个键及其对应的值都是一个字符串。当客户端启动时,使用Java File类读取配置信息。为避免过多的I/O(Input/Output,输入/输出)读写操作影响客户端性能,客户端将每行key=value作为一个String(字符串)对象添加到一个List<String>对象list中,并将list进行遍历,依次取出key=value的String对象,然后把String转成数组,该数组只有两个元素[key,value],此时用一个Map<String key, String value>将数组对象转成Java Map对象。The connection information is the server's IP address and port number. The process of setting the connection information according to the configuration information by the client is: Step 1: Convert the read configuration information into Java. Map object. The configuration information is stored in the client (client).properties, stored in the form of key=value, and the properties represent a persistent set of attributes. Each key in the attribute list and its corresponding value are a string. Use Java when the client starts The File class reads the configuration information. To avoid excessive I/O (Input/Output) read/write operations affecting client performance, the client adds each row of key=value as a String object to a List<String> object list. In the middle, and the list is traversed, the String object of key=value is taken out in turn, and then the String is converted into an array. The array has only two elements [key, value], and a Map<String is used at this time. Key, String value> Converts the array object into a Java Map object.
第二步:客户端对其系统参数类成员变量赋值,以使Java Map对象中的数据都匹配到对应的成员变量。系统参数类System Config中定义了以下几个成员变量:①client:客户端模式;②transport:客户端、服务器之间的数据传输模式;③host:服务器的IP地址;④port:服务器的端口号;⑤ handlers:监听处理类。每个成员变量均有set(设置)和get(获取)方法,在本实施例中,利用反射技术获取System Config对象的所有方法,遍历后筛选出set开头、方法修饰类型为public或static、返回类型为void(空类型)的方法,方法名用substring(3)截取得到新的字符串,与Java Map对象中的key进行匹配得到对应的value值。若 value值为null(空),则进入下一个循环;若 value值不为null,则将value赋值给system Config对应的成员变量,直到Java Map对象中的数据都匹配赋值到对应的成员变量为止,完成客户端参数初始化赋值。其中,public表明该数据成员、成员函数是对所有用户开放的,所有用户都可以直接进行调用。static表示“全局”或者“静态”的意思,用来修饰成员变量和成员方法,也可以形成静态static代码块,但是Java语言中没有全局变量的概念。 Step 2: The client assigns a value to its system parameter class member variable to make Java The data in the Map object matches the corresponding member variable. System parameter class System The following member variables are defined in Config: 1client: client mode; 2transport: data transfer mode between client and server; 3host: server IP address; 4port: server port number; 5 Handlers: listens for processing classes. Each member variable has a set (set) and get (get) method. In this embodiment, the system is obtained by using reflection technology. All methods of the Config object, after traversing, filter out the beginning of the set, the method modification type is public or static, and the return type is void (empty type). The method name is substring(3) to get the new string, and Java. The key in the Map object is matched to get the corresponding value. If the value is null (null), then the next loop is entered; If the value is not null, the value is assigned to the member variable corresponding to system Config until Java. The data in the Map object is matched to the corresponding member variable, and the client parameter initialization is completed. Among them, public indicates that the data member and member function are open to all users, and all users can directly call it. Static means "global" or "static", used to modify member variables and member methods, can also form static static code blocks, but there is no concept of global variables in the Java language.
当客户端根据配置信息设置连接服务器的连接信息后,客户端执行封装和实例化操作,并启动监听线程,以通过该监听线程监听与服务器建立连接的过程,获取服务器返回的验证数据等。After the client sets the connection information of the connection server according to the configuration information, the client performs encapsulation and instantiation operations, and starts a listening thread to listen to the process of establishing a connection with the server through the listening thread, and obtain verification data returned by the server.
客户端执行封装和实例化操作的过程为:自定义一个延迟加载类ExtensionLoader<T>,使用泛型表示可以缓存任何类型的Java类;从缓存中取出其对应的ExtensionLoader<Client>对象;然后根据ExtensionLoader<Client>对象进行实例化操作并获得一个对象client;在缓存中查找ExtensionLoader<Client>对象对应的实例。若查找该实例,则返回该实例;若未查找到该实例,则读取配置信息。需要说明的是,配置信息也是采用key=value的格式进行数据存放,Client作为一个接口类,有一个实现类AbStract Client,AbStract Client有两个实现类Swing Client和Console Client,配置信息里面的信息就是swing=Swing Client类的绝对路径,console=Console Client类的绝对路径,同样是利用反射技术根据key得到对应的类名,然后调用Class.forName实例化Client的实例,并保存到缓存中。需要说明的是,反射技术是.NET中的重要机制。监听线程是一个类,封装和实例化客户端的过程是为了在创建连接过程中,监听线程能够更好的监听整个创建连接的过程。The process of the client performing the encapsulation and instantiation operations is: customizing a lazy loading class ExtensionLoader<T>, using a generic representation to cache any type of Java class; taking its corresponding ExtensionLoader<Client> object from the cache; The ExtensionLoader<Client> object is instantiated and gets an object client; look up the instance corresponding to the ExtensionLoader<Client> object in the cache. If the instance is looked up, the instance is returned; if the instance is not found, the configuration information is read. It should be noted that the configuration information is also stored in the format of key=value. The client is an interface class and has an implementation class AbStract. Client, AbStract Client has two implementation classes Swing Client and Console Client. The information in the configuration information is swing=Swing. Absolute path of the client class, console=Console The absolute path of the Client class is also obtained by using the reflection technique to get the corresponding class name according to the key, and then calling Class.forName to instantiate the instance of the Client and saving it to the cache. It should be noted that reflection technology is an important mechanism in .NET. The listener thread is a class that encapsulates and instantiates the client's process so that the listener thread can better listen to the entire process of creating a connection during the creation of the connection.
步骤S20,将所述验证数据发送给所述客户端,以供所述客户端在接收到所述验证数据,且根据所述验证数据确定所述登录请求对应的登录操作处于正常状态后,获取所述验证数据中的登录字符串,并将所述登录字符串转换成请求报文发送给所述服务器。In step S20, the verification data is sent to the client, so that the client obtains the verification data, and after determining that the login operation corresponding to the login request is in a normal state according to the verification data, obtain the verification data. The login string in the verification data is converted, and the login string is converted into a request message and sent to the server.
当服务器得到验证数据后,将验证数据发送给客户端,以供客户端在接收到验证数据,且根据验证数据确定登录请求对应的登录操作处于正常状态后,获取验证数据中的登录字符串,将登录字符串转换成请求报文发送给服务器。进一步地,当客户端接收到验证数据后,会将验证数据保存到其系统参数类中,以便于在建立与服务器连接过程中,在系统参数种类中获取登录字符串。After the server obtains the verification data, the verification data is sent to the client, so that the client receives the verification data, and determines that the login operation corresponding to the login request is in a normal state according to the verification data, and obtains the login string in the verification data. Convert the login string into a request message and send it to the server. Further, when the client receives the verification data, the verification data is saved into its system parameter class, so that the login string is obtained in the system parameter category during the process of establishing the connection with the server.
进一步地,步骤S20包括:Further, step S20 includes:
步骤c,将所述验证数据发送给所述客户端。Step c, sending the verification data to the client.
其中,当所述客户端接收到所述验证数据后,检测所述验证数据中是否存在登录字符串;After the client receives the verification data, detecting whether a login string exists in the verification data;
若检测到所述验证数据中存在登录字符串,则确定所述登录请求对应的登录操作处于正常状态,获取所述验证数据中的登录字符串,并将所述登录字符串转换成请求报文发送给所述服务器。If the login string is detected in the verification data, the login operation corresponding to the login request is determined to be in a normal state, the login string in the verification data is obtained, and the login string is converted into a request message. Sent to the server.
进一步地,当服务器将验证数据发送给客户端,客户端接收到该验证数据后,客户端检测验证数据中是否存在登录字符串。若检测到验证数据中存在登录字符串,客户端则确定登录请求对应的登录操作处于正常状态,并获取验证数据中的登录字符串,将登录字符串转换成请求报文,通过nio技术发送TCP(Transmission Control Protocol ,传输控制协议)连接给服务器,以将请求报文发送给服务器。nio技术提供了非阻塞型I/O 的异步输入输出机制,为提高系统的性能提供了可实现的基础机制。Further, when the server sends the verification data to the client, after the client receives the verification data, the client detects whether the login string exists in the verification data. If the login string is detected in the verification data, the client determines that the login operation corresponding to the login request is in a normal state, and obtains the login string in the verification data, converts the login string into a request packet, and sends the TCP through the nio technology. (Transmission The Control Protocol (Transmission Control Protocol) is connected to the server to send the request message to the server. Nio technology provides non-blocking I/O The asynchronous input and output mechanism provides an achievable basic mechanism for improving system performance.
进一步地,若检测到验证数据中未存在登录字符串,客户端则确定登录请求对应的登录操作处于异常状态,并关闭监听线程。当客户端确定登录操作处于异常状态后,客户端输出登录异常的提示信息,以提示用户登录异常。Further, if it is detected that the login string does not exist in the verification data, the client determines that the login operation corresponding to the login request is in an abnormal state, and closes the monitoring thread. After the client determines that the login operation is in an abnormal state, the client outputs a login abnormality prompt message to prompt the user to log in abnormally.
进一步地,所述将所述登录字符串转换成请求报文发送给所述服务器的步骤包括:Further, the step of converting the login string into a request message and sending the message to the server includes:
步骤d,根据所述登录字符串的长度进行位运算,以重组所述登录字符串,得到重组后的所述登录字符串。Step d: Perform a bit operation according to the length of the login string to recombine the login string to obtain the reassembled login string.
进一步地,客户端将登录字符串转换成请求报文后发送给服务器的过程可为:客户端获取登录字符串的长度,在for循环体中根据登录字符串的长度进行位运算,以重组登录字符串,得到重组后的登录字符串。Further, the process of the client converting the login string into the request message and sending the message to the server may be: the client obtains the length of the login string, performs a bit operation according to the length of the login string in the for loop body, and reorganizes the login. String, get the refactored login string.
步骤e,将重组后的所述登录字符串与所述预设质数进行取模运算,得到与所述登录字符串对应的数据报文。Step e: Perform modulo operation on the re-established login string and the preset prime number to obtain a data packet corresponding to the login string.
当客户端得到重组后的登录字符串后,将重组后的登录字符串与预设质数进行取模运算,得到与登录字符串对应的数据报文。其中,在本实施例中,预设质数为31。质数31是Java中规定的长度。可以理解的是,可以根据需要在Java代码中将预设质数修改为其它质数。After the client obtains the re-established login string, the re-composed login string is modulo-operated with the preset prime number to obtain a data packet corresponding to the login string. In this embodiment, the preset prime number is 31. The prime number 31 is the length specified in Java. It can be understood that the preset prime number can be modified to other prime numbers in the Java code as needed.
步骤f,通过预设协议将所述数据报文转换成请求报文发送给所述服务器。In step f, the data packet is converted into a request message and sent to the server by using a preset protocol.
当客户端得到与登录字符串对应的数据报文后,通过预设协议将数据报文转换成请求报文,并将该请求报文发送给服务器。其中,预设协议可为Google protobuf协议或者Apache Thrift协议。After the client obtains the data packet corresponding to the login string, the client converts the data packet into a request packet by using a preset protocol, and sends the request packet to the server. Among them, the default agreement can be Google Protobuf protocol or Apache Thrift protocol.
步骤S30,当所述服务器接收到所述请求报文后,检测所述请求报文是否符合建立连接的建立规则。Step S30, after the server receives the request message, it is detected whether the request message meets the establishment rule for establishing a connection.
当服务器接收到客户端发送的请求报文后,服务器检测该请求报文是否符合建立连接的建立规则。After receiving the request packet sent by the client, the server detects whether the request packet meets the establishment rule for establishing a connection.
进一步地,步骤S30包括:Further, step S30 includes:
步骤g,当所述服务器接收到所述请求报文后,获取所述请求报文中的登录字符串,并检测在数据库中是否查找到与所述请求报文中的登录字符串相同的预设字符串。Step g: After receiving the request message, the server acquires a login string in the request message, and detects whether a pre-login in the database is found to be the same as the login string in the request message. Set the string.
进一步地,服务器检测请求报文是否符合建立连接的建立规则的过程为:当服务器接收到请求报文后,服务器解析请求报文,获取请求报文中的登录字符串,并检测在其数据库中是否查找到与请求报文中的登录字符串相同的预设字符串。其中,该数据库可为mysql数据库或者RAM(Random-Access Memory,随机存取存储器)存储器。Further, the process of detecting whether the request packet meets the establishment rule of the connection is: after the server receives the request message, the server parses the request message, obtains the login string in the request message, and detects in the database. Whether to find the same preset string as the login string in the request message. Among them, the database can be mysql database or RAM (Random-Access Memory, random access memory) memory.
步骤h,若查找到所述预设字符串,则确定所述请求报文符合建立连接的建立规则。In step h, if the preset character string is found, it is determined that the request message meets the establishment rule for establishing a connection.
若在数据库中查找到与请求报文中的登录字符串相同的预设字符串,服务器确定请求报文符合建立连接的连接规则。If the same preset string as the login string in the request packet is found in the database, the server determines that the request message conforms to the connection rule for establishing the connection.
步骤i,若未查找到所述预设字符串,则确定所述请求报文未符合建立连接的建立规则。In step i, if the preset character string is not found, it is determined that the request message does not meet the establishment rule for establishing a connection.
若在数据库中未查找到与请求报文中的登录字符串相同的预设字符串,服务器确定请求报文未符合建立连接的连接规则。If the same preset string as the login string in the request packet is not found in the database, the server determines that the request packet does not meet the connection rule for establishing a connection.
步骤S40,若检测到所述请求报文符合所述建立规则,则建立与所述客户端之间的连接。Step S40: If it is detected that the request message meets the establishment rule, establish a connection with the client.
当服务器检测到请求报文符合建立连接的建立规则后,服务器建立与客户端之间的连接。当服务器和客户端之间建立连接后,客户端可与服务器进行数据传输,进行通信。After the server detects that the request message conforms to the establishment rule for establishing a connection, the server establishes a connection with the client. When a connection is established between the server and the client, the client can transmit data and communicate with the server.
本实施例通过当客户端侦测到登录请求后,将登录请求发送给服务器进行登录验证;当服务器接收到登录请求后,验证该登录请求,并返回验证数据给客户端;当客户端根据验证数据确定登录请求对应的登录操作处于正常状态后,获取验证数据中的登录字符串,将登录字符串转换成请求报文发送给服务器;当服务器接收到请求报文,且检测到该请求报文符合建立连接的建立规则后,服务器才建立与客户端之间的连接。通过在与客户端建立连接之前,先进行登录验证,通过验证后再建立连接,减少了无用连接的创建,减轻了服务器的负担,以及避免了非法分子在获取到服务器的IP地址后即可连接到服务器,提高了服务器的安全性。In this embodiment, after the client detects the login request, the login request is sent to the server for login verification; when the server receives the login request, the login request is verified, and the verification data is returned to the client; when the client is verified according to the verification After the data is determined that the login operation corresponding to the login request is in a normal state, the login string in the verification data is obtained, and the login string is converted into a request message and sent to the server; when the server receives the request message, and the request message is detected, After the establishment rules for establishing a connection are met, the server establishes a connection with the client. By establishing login authentication before establishing a connection with the client, and establishing a connection after verification, the creation of useless connections is reduced, the burden on the server is reduced, and illegal elements are prevented from being connected after obtaining the IP address of the server. To the server, improve the security of the server.
进一步地,提出本申请连接建立方法第二实施例。Further, a second embodiment of the connection establishment method of the present application is proposed.
所述连接建立方法第二实施例与所述连接建立方法第一实施例的区别在于,参照图2,连接建立方法还包括:The second embodiment of the connection establishment method is different from the first embodiment of the connection establishment method. Referring to FIG. 2, the connection establishment method further includes:
步骤S50,生成与所述客户端成功建立连接的第一提示信息,并将所述第一提示信息发送给所述客户端,以供所述客户端在接收到所述第一提示信息后监控与所述服务器之间的连接状态。Step S50: Generate first prompt information that successfully establishes a connection with the client, and send the first prompt information to the client, so that the client monitors after receiving the first prompt information. The status of the connection with the server.
当服务器与客户端成功建立连接后,服务器生成与客户端成功建立连接的第一提示信息,并将第一提示信息发送给客户端。当客户端接收到第一提示信息后,在其显示界面中输出第一提示信息,并在接收到第一提示信息后监控与服务器之间的连接状态。客户端输出第一提示信息的输出方式包括但不限于文字形式和语音形式。如客户端可在其显示界面中输出“成功连接”的文字信息,以输出第一提示信息。After the server successfully establishes a connection with the client, the server generates a first prompt information for successfully establishing a connection with the client, and sends the first prompt information to the client. After receiving the first prompt information, the client outputs the first prompt information in its display interface, and monitors the connection state with the server after receiving the first prompt information. The manner in which the client outputs the first prompt information includes, but is not limited to, a text form and a voice form. For example, the client can output the text information of “successful connection” in its display interface to output the first prompt information.
客户端监控与服务器之间的连接状态的过程为:客户端创建心跳包,并在创建心跳包后启动心跳包,通过该心跳包发送定时任务给服务器,以监控其与服务器之间的连接状态。当客户端启动心跳包后,客户端获取对应的心跳日志,并存储该心跳日志,以供用户根据该心跳日志确定客户端和服务器是否处于已连接状态。需要说明的是,客户端通过心跳包发送定时任务给服务器即为客户端不断向服务器发送连接请求。The process of monitoring the connection status between the client and the server is as follows: the client creates a heartbeat packet, and starts a heartbeat packet after creating the heartbeat packet, and sends a timing task to the server through the heartbeat packet to monitor the connection state between the client and the server. . After the client starts the heartbeat packet, the client obtains the corresponding heartbeat log and stores the heartbeat log, so that the user determines whether the client and the server are in the connected state according to the heartbeat log. It should be noted that the client sends a scheduled task to the server through the heartbeat packet, that is, the client continuously sends a connection request to the server.
本实施例通过当服务器与客户端成功建立连接后,发送服务器与客户端成功建立连接的第一提示信息给客户端,当客户端接收到第一提示信息后,监控其与服务器之间的连接状态,以便于客户端用户能够及时了解客户端与服务器之间的连接状态。In this embodiment, after the server successfully establishes a connection with the client, the sending server and the client successfully establish a first prompt information of the connection to the client, and when the client receives the first prompt information, monitor the connection between the server and the server. Status so that client users can keep abreast of the connection status between the client and the server.
进一步地,提出本申请连接建立方法第三实施例。Further, a third embodiment of the connection establishment method of the present application is proposed.
所述连接建立方法第三实施例与所述连接建立方法第一或第二实施例的区别在于,参照图3,连接建立方法还包括:The third embodiment of the connection establishment method is different from the first or second embodiment of the connection establishment method. Referring to FIG. 3, the connection establishment method further includes:
步骤S60,若检测到所述请求报文未符合所述建立规则,则拒绝与所述客户端建立连接,并生成第二提示信息。Step S60: If it is detected that the request message does not meet the establishment rule, the connection with the client is refused, and the second prompt information is generated.
若服务器检测到请求报文未符合建立连接的建立规则,服务器则拒绝与客户端建立连接,并生成建立连接失败的第二提示信息。If the server detects that the request message does not meet the establishment rule for establishing a connection, the server refuses to establish a connection with the client, and generates a second prompt message for establishing a connection failure.
步骤S70,将所述第二提示信息发送给所述客户端,以供所述客户端根据所述第二提示信息提示客户端用户连接建立失败。Step S70: Send the second prompt information to the client, so that the client prompts the client user that the connection establishment fails according to the second prompt information.
当服务器生成第二提示信息后,将第二提示信息发送给客户端。当客户端接收到第二提示信息后,在其显示界面中输出第二提示信息,以根据第二提示信息提示其用户与服务器之间的连接建立失败。需要说明的是,客户端输出第二提示信息的输出方式包括但不限于文字形式和语音形式。如客户端可在其显示界面中显示 “连接失败”的文字信息,以输出第二提示信息。After the server generates the second prompt information, the second prompt information is sent to the client. After receiving the second prompt information, the client outputs the second prompt information in its display interface to prompt the connection establishment failure between the user and the server according to the second prompt information. It should be noted that the output manner of the second prompt information output by the client includes, but is not limited to, a text form and a voice form. If the client can display in its display interface The text message "Connection failed" to output the second prompt message.
本实施例通过当服务器检测到请求报文未符合建立规则后,发送第二提示信息给客户端,以供客户端根据第二提示信息提示客户端用户与服务器之间的连接建立失败,以便于用户可根据需要决定是否重新建立连接。In this embodiment, when the server detects that the request packet does not meet the establishment rule, the second prompt information is sent to the client, so that the client prompts the connection establishment between the client user and the server to fail according to the second prompt information, so as to facilitate The user can decide whether to re-establish the connection as needed.
此外,参照图4,本申请还提供一种连接建立系统,所述连接建立系统包括服务器10和客户端20,所述服务器10包括:In addition, referring to FIG. 4, the present application further provides a connection establishment system, where the connection establishment system includes a server 10 and a client 20, and the server 10 includes:
验证模块11,用于当接收到登录请求后,验证所述登录请求,得到对应的验证数据;The verification module 11 is configured to: after receiving the login request, verify the login request, and obtain corresponding verification data;
第一发送模块12,用于将所述验证数据发送给所述客户端20;The first sending module 12 is configured to send the verification data to the client 20;
检测模块13,用于当接收到所述客户端20发送的请求报文后,检测所述请求报文是否符合建立连接的建立规则;The detecting module 13 is configured to: after receiving the request message sent by the client 20, check whether the request message meets the establishment rule for establishing a connection;
建立模块14,用于若检测到所述请求报文符合所述建立规则,则建立与所述客户端20之间的连接;The establishing module 14 is configured to establish a connection with the client 20 if it is detected that the request message meets the establishment rule;
所述客户端20包括:The client 20 includes:
第二发送模块21,用于在侦测到登录请求后,将所述登录请求发送给所述服务器10;The second sending module 21 is configured to send the login request to the server 10 after detecting the login request;
获取模块22,用于在接收到所述服务器10发送的验证数据,且根据所述验证数据确定所述登录请求对应的登录操作处于正常状态后,获取所述验证数据中的登录字符串;The obtaining module 22 is configured to: after receiving the verification data sent by the server 10, and determining, according to the verification data, that the login operation corresponding to the login request is in a normal state, acquiring a login string in the verification data;
转换模块23,用于将所述登录字符串转换成请求报文发送给所述服务器10。The conversion module 23 is configured to convert the login string into a request message and send the message to the server 10.
本实施例通过当第二发送模块21侦测到登录请求后,将登录请求发送给服务器10进行登录验证;当验证模块11接收到登录请求后,验证该登录请求,第一发送模块12返回验证数据给客户端20;当客户端20的获取模块22根据验证数据确定登录请求对应的登录操作处于正常状态后,获取验证数据中的登录字符串,转换模块23将登录字符串转换成请求报文发送给服务器10;当服务器10的检测模块13接收到请求报文,且检测到该请求报文符合建立连接的建立规则后,建立模块14才建立与客户端20之间的连接。通过在与客户端20建立连接之前,先进行登录验证,通过验证后再建立连接,减少了无用连接的创建,减轻了服务器10的负担,以及避免了非法分子在获取到服务器10的IP地址后即可连接到服务器10,提高了服务器10的安全性。In this embodiment, after the second sending module 21 detects the login request, the login request is sent to the server 10 for login verification. After the verification module 11 receives the login request, the login request is verified, and the first sending module 12 returns the verification. The data is sent to the client 20; when the obtaining module 22 of the client 20 determines that the login operation corresponding to the login request is in a normal state according to the verification data, the login string in the verification data is acquired, and the conversion module 23 converts the login string into the request message. The connection module 10 establishes a connection with the client 20 after the detection module 13 of the server 10 receives the request message and detects that the request message conforms to the establishment rule for establishing a connection. By performing login verification before establishing a connection with the client 20, establishing a connection after verification, the creation of useless connections is reduced, the burden on the server 10 is reduced, and the illegal molecules are prevented from acquiring the IP address of the server 10. It is possible to connect to the server 10, which improves the security of the server 10.
进一步地,所述验证模块11包括:Further, the verification module 11 includes:
提取单元,用于当接收到登录请求后,在所述登录请求中提取登录用户名和登录密码;An extracting unit, configured to: after receiving the login request, extract the login user name and the login password in the login request;
验证单元,用于根据所述登录用户名和所述登录密码进行登录验证,得到对应的验证数据;a verification unit, configured to perform login verification according to the login user name and the login password, to obtain corresponding verification data;
所述第二发送模块21还用于当侦测到所述登录请求后,读取配置信息,根据所述配置信息设置连接所述服务器10的连接信息,根据所述连接信息将所述登录请求发送给所述服务器10。The second sending module 21 is further configured to: after detecting the login request, read configuration information, set connection information connected to the server 10 according to the configuration information, and send the login request according to the connection information. Sent to the server 10.
进一步地,所述获取模块22包括:Further, the obtaining module 22 includes:
检测单元,用于当接收到所述验证数据后,检测所述验证数据中是否存在登录字符串;a detecting unit, configured to detect whether a login string exists in the verification data after receiving the verification data;
第一获取单元,用于若检测到所述验证数据中存在登录字符串,则确定所述登录请求对应的登录操作处于正常状态,获取所述验证数据中的登录字符串。The first obtaining unit is configured to: if it is detected that the login string exists in the verification data, determine that the login operation corresponding to the login request is in a normal state, and acquire a login string in the verification data.
进一步地,所述转换模块23包括:Further, the conversion module 23 includes:
运算单元,用于根据所述登录字符串的长度进行位运算,以重组所述登录字符串,得到重组后的所述登录字符串;将重组后的所述登录字符串与所述预设质数进行取模运算,得到与所述登录字符串对应的数据报文;An operation unit, configured to perform a bit operation according to the length of the login string to recombine the login string to obtain the reassembled login string; and the reassembled login string and the preset prime number Performing a modulo operation to obtain a data packet corresponding to the login string;
转换单元,用于通过预设协议将所述数据报文转换成请求报文发送给所述服务器10。And a converting unit, configured to convert the data packet into a request message and send the request message to the server 10 by using a preset protocol.
进一步地,所述检测模块13包括:Further, the detecting module 13 includes:
第二获取单元,用于当接收到所述请求报文后,获取所述请求报文中的登录字符串;a second acquiring unit, configured to acquire a login string in the request packet after receiving the request packet;
检测单元,用于检测在数据库中是否查找到与所述请求报文中的登录字符串相同的预设字符串;a detecting unit, configured to detect whether a preset character string that is the same as the login string in the request message is found in the database;
确定单元,用于若查找到所述预设字符串,则确定所述请求报文符合建立连接的建立规则;若未查找到所述预设字符串,则确定所述请求报文未符合建立连接的建立规则。a determining unit, configured to: if the preset character string is found, determine that the request message meets a setup rule for establishing a connection; if the preset character string is not found, determine that the request message does not meet the establishment The establishment rules for the connection.
进一步地,所述服务器10还包括:Further, the server 10 further includes:
第一生成模块,用于生成与所述客户端20成功建立连接的第一提示信息;a first generating module, configured to generate first prompt information that successfully establishes a connection with the client 20;
所述第一发送模块12还用于将所述第一提示信息发送给所述客户端20,以供所述客户端20在接收到所述第一提示信息后监控与所述服务器10之间的连接状态。The first sending module 12 is further configured to send the first prompt information to the client 20, so that the client 20 monitors the server 10 after receiving the first prompt information. Connection status.
进一步地,所述服务器10还包括:Further, the server 10 further includes:
第二生成模块,用于若检测到所述请求报文未符合所述建立规则,则拒绝与所述客户端20建立连接,并生成第二提示信息;a second generating module, if it is detected that the request packet does not meet the establishing rule, refuse to establish a connection with the client 20, and generate second prompt information;
所述第一发送模块12还用于将所述第二提示信息发送给所述客户端20,以供所述客户端20根据所述第二提示信息提示客户端用户建立连接失败。The first sending module 12 is further configured to send the second prompt information to the client 20, so that the client 20 prompts the client user to establish a connection failure according to the second prompt information.
需要说明的是,连接建立系统的各个实施例与上述连接建立方法的各实施例基本相同,在此不再详细赘述。It should be noted that the embodiments of the connection establishment system are basically the same as the embodiments of the foregoing connection establishment method, and details are not described herein again.
此外,本申请还提供一种连接建立设备。如图5所示,图5是本申请实施例方案涉及的硬件运行环境的结构示意图。In addition, the present application also provides a connection establishing device. As shown in FIG. 5, FIG. 5 is a schematic structural diagram of a hardware operating environment involved in an embodiment of the present application.
需要说明的是,图5即可为连接建立设备的硬件运行环境的结构示意图。本申请实施例连接建立设备可以是PC,便携计算机等终端设备。It should be noted that FIG. 5 can be a schematic structural diagram of a hardware running environment of the connection establishment device. The connection establishing device in the embodiment of the present application may be a terminal device such as a PC or a portable computer.
如图5所示,该连接建立设备可以包括:处理器1001,例如CPU,存储器1005,用户接口1003,通信总线1002。其中,通信总线1002用于实现这些组件之间的连接通信。用户接口1003可以包括显示屏(Display)、输入单元比如键盘(Keyboard),可选用户接口1003还可以包括标准的有线接口、无线接口。存储器1005可以是高速RAM存储器,也可以是稳定的存储器(non-volatile memory),例如磁盘存储器。存储器1005可选的还可以是独立于前述处理器1001的存储装置。As shown in FIG. 5, the connection establishing device may include a processor 1001, such as a CPU, a memory 1005, a user interface 1003, and a communication bus 1002. Among them, the communication bus 1002 is used to implement connection communication between these components. The user interface 1003 can include a display, an input unit such as a keyboard, and the optional user interface 1003 can also include a standard wired interface, a wireless interface. The memory 1005 may be a high speed RAM memory or a stable memory (non-volatile) Memory), such as disk storage. The memory 1005 can also optionally be a storage device independent of the aforementioned processor 1001.
可选地,连接建立设备还可以包括摄像头、RF(Radio Frequency,射频)电路,传感器、音频电路、WiFi模块等等。Optionally, the connection establishing device may further include a camera, RF (Radio) Frequency, RF) circuits, sensors, audio circuits, WiFi modules, and more.
本领域技术人员可以理解,图5中示出的连接建立设备结构并不构成对连接建立设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。It will be understood by those skilled in the art that the connection establishing device structure shown in FIG. 5 does not constitute a limitation of the connection establishing device, and may include more or less components than those illustrated, or combine some components or different components. Arrangement.
如图5所示,作为一种计算机存储介质的存储器1005中可以包括操作系统、网络通信模块、用户接口模块以及连接建立程序。其中,操作系统是管理和控制连接建立设备硬件和软件资源的程序,支持连接建立程序以及其它软件或程序的运行。As shown in FIG. 5, an operating system, a network communication module, a user interface module, and a connection establishment program may be included in the memory 1005 as a computer storage medium. Among them, the operating system is a program that manages and controls the connection to establish device hardware and software resources, and supports the connection establishment program and the operation of other software or programs.
在图5所示的连接建立设备中,用户接口1003主要用于连接客户端(用户端),与客户端进行数据通信;处理器1001可以用于调用存储器1005中存储的连接建立程序,并执行如上所述的连接建立方法的步骤。In the connection establishment device shown in FIG. 5, the user interface 1003 is mainly used to connect a client (user end) to perform data communication with the client; the processor 1001 can be used to call a connection establishment program stored in the memory 1005, and execute The steps of the connection establishment method as described above.
本申请连接建立设备具体实施方式与上述连接建立方法各实施例基本相同,在此不再赘述。The specific implementation manners of the connection establishment device of the present application are basically the same as the foregoing embodiments of the connection establishment method, and details are not described herein again.
此外,本申请实施例还提出一种计算机可读存储介质,所述计算机可读存储介质上存储有连接建立程序,所述连接建立程序被处理器执行时实现如上所述的连接建立方法的步骤。In addition, the embodiment of the present application further provides a computer readable storage medium, where the computer readable storage medium stores a connection establishment program, and the connection establishment program is executed by the processor to implement the steps of the connection establishment method as described above. .
本申请计算机可读存储介质具体实施方式与上述连接建立方法各实施例基本相同,在此不再赘述。The specific embodiment of the computer readable storage medium of the present application is substantially the same as the foregoing embodiment of the connection establishment method, and details are not described herein again.
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。It is to be understood that the term "comprises", "comprising", or any other variants thereof, is intended to encompass a non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes those elements. It also includes other elements that are not explicitly listed, or elements that are inherent to such a process, method, article, or device. An element that is defined by the phrase "comprising a ..." does not exclude the presence of additional equivalent elements in the process, method, item, or device that comprises the element.
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the embodiments of the present application are merely for the description, and do not represent the advantages and disadvantages of the embodiments.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the foregoing embodiment method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be through hardware, but in many cases, the former is better. Implementation. Based on such understanding, the technical solution of the present application, which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM, disk, The optical disc includes a number of instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the methods described in various embodiments of the present application.
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。The above is only a preferred embodiment of the present application, and is not intended to limit the scope of the patent application, and the equivalent structure or equivalent process transformations made by the specification and the drawings of the present application, or directly or indirectly applied to other related technical fields. The same is included in the scope of patent protection of this application.

Claims (20)

  1. 一种连接建立方法,其特征在于,所述已接入连接建立方法包括以下步骤: A connection establishment method, characterized in that the established connection establishment method comprises the following steps:
    当服务器接收到登录请求后,验证所述登录请求,得到对应的验证数据,其中,所述登录请求是所述客户端侦测到登录请求后发送给所述服务器的;After the server receives the login request, the login request is verified, and the corresponding verification data is obtained, where the login request is sent by the client to the server after detecting the login request;
    将所述验证数据发送给所述客户端,以供所述客户端在接收到所述验证数据,且根据所述验证数据确定所述登录请求对应的登录操作处于正常状态后,获取所述验证数据中的登录字符串,并将所述登录字符串转换成请求报文发送给所述服务器;And sending the verification data to the client, where the client obtains the verification data, and after determining that the login operation corresponding to the login request is in a normal state according to the verification data, acquiring the verification a login string in the data, and converting the login string into a request message to be sent to the server;
    当所述服务器接收到所述请求报文后,检测所述请求报文是否符合建立连接的建立规则;After the server receives the request message, it is detected whether the request message meets the establishment rule for establishing a connection;
    若检测到所述请求报文符合所述建立规则,则建立与所述客户端之间的连接。If it is detected that the request message meets the establishment rule, establishing a connection with the client.
  2. 如权利要求1所述的连接建立方法,其特征在于,所述当服务器接收到登录请求后,验证所述登录请求,得到对应的验证数据,其中,所述登录请求是所述客户端侦测到登录请求后发送给所述服务器的步骤包括:The connection establishment method according to claim 1, wherein after the server receives the login request, the login request is verified, and corresponding verification data is obtained, wherein the login request is the client detection. The steps to send to the server after the login request include:
    当所述服务器接收到登录请求后,在所述登录请求中提取登录用户名和登录密码;After the server receives the login request, extracting the login user name and the login password in the login request;
    根据所述登录用户名和所述登录密码进行登录验证,得到对应的验证数据;Performing login verification according to the login user name and the login password to obtain corresponding verification data;
    其中,当所述客户端侦测到所述登录请求后,读取配置信息,根据所述配置信息设置连接所述服务器的连接信息,根据所述连接信息将所述登录请求发送给所述服务器。 After the client detects the login request, the configuration information is read, the connection information connected to the server is set according to the configuration information, and the login request is sent to the server according to the connection information. .
  3. 如权利要求1所述的连接建立方法,其特征在于,所述将所述验证数据发送给所述客户端,以供所述客户端在接收到所述验证数据,且根据所述验证数据确定所述登录请求对应的登录操作处于正常状态后,获取所述验证数据中的登录字符串,并将所述登录字符串转换成请求报文发送给所述服务器的步骤包括:The connection establishing method according to claim 1, wherein the transmitting the verification data to the client, wherein the client receives the verification data, and determining according to the verification data After the login operation corresponding to the login request is in a normal state, the step of acquiring the login string in the verification data, and converting the login string into the request message and sending the message to the server includes:
    将所述验证数据发送给所述客户端;Sending the verification data to the client;
    其中,当所述客户端接收到所述验证数据后,检测所述验证数据中是否存在登录字符串;After the client receives the verification data, detecting whether a login string exists in the verification data;
    若检测到所述验证数据中存在登录字符串,则确定所述登录请求对应的登录操作处于正常状态,获取所述验证数据中的登录字符串,并将所述登录字符串转换成请求报文发送给所述服务器。If the login string is detected in the verification data, the login operation corresponding to the login request is determined to be in a normal state, the login string in the verification data is obtained, and the login string is converted into a request message. Sent to the server.
  4. 如权利要求3所述的连接建立方法,其特征在于,所述将所述登录字符串转换成请求报文发送给所述服务器的步骤包括:The connection establishment method according to claim 3, wherein the step of converting the login string into a request message and sending the message to the server comprises:
    根据所述登录字符串的长度进行位运算,以重组所述登录字符串,得到重组后的所述登录字符串;Performing a bit operation according to the length of the login string to recombine the login string to obtain the reassembled login string;
    将重组后的所述登录字符串与所述预设质数进行取模运算,得到与所述登录字符串对应的数据报文;Performing a modulo operation on the re-established login string and the preset prime number to obtain a data packet corresponding to the login string;
    通过预设协议将所述数据报文转换成请求报文发送给所述服务器。The data message is converted into a request message and sent to the server by using a preset protocol.
  5. 如权利要求1所述的连接建立方法,其特征在于,所述当所述服务器接收到所述请求报文后,检测所述请求报文是否符合建立连接的建立规则的步骤包括:The connection establishment method according to claim 1, wherein the step of detecting whether the request message meets the establishment rule of establishing a connection after the server receives the request message comprises:
    当所述服务器接收到所述请求报文后,获取所述请求报文中的登录字符串,并检测在数据库中是否查找到与所述请求报文中的登录字符串相同的预设字符串;After receiving the request message, the server acquires a login string in the request message, and detects whether a preset string that is the same as the login string in the request message is found in the database. ;
    若查找到所述预设字符串,则确定所述请求报文符合建立连接的建立规则;If the preset string is found, determining that the request message meets the establishment rule for establishing a connection;
    若未查找到所述预设字符串,则确定所述请求报文未符合建立连接的建立规则。If the preset character string is not found, it is determined that the request message does not meet the establishment rule for establishing a connection.
  6. 如权利要求1所述的连接建立方法,其特征在于,所述若检测到所述请求报文符合所述建立规则,则建立与所述客户端之间的连接的步骤之后,还包括:The connection establishment method according to claim 1, wherein the step of establishing a connection with the client after detecting that the request message meets the establishment rule further comprises:
    生成与所述客户端成功建立连接的第一提示信息,并将所述第一提示信息发送给所述客户端,以供所述客户端在接收到所述第一提示信息后监控与所述服务器之间的连接状态。Generating a first prompt information that successfully establishes a connection with the client, and sending the first prompt information to the client, where the client monitors and reports the first prompt information after receiving the first prompt information. The connection status between the servers.
  7. 如权利要求1所述的连接建立方法,其特征在于,所述当所述服务器接收到所述请求报文后,检测所述请求报文是否符合建立连接的建立规则的步骤之后,还包括:The connection establishment method according to claim 1, wherein after the step of detecting whether the request message meets the establishment rule of establishing a connection after the requesting the message, the server further includes:
    若检测到所述请求报文未符合所述建立规则,则拒绝与所述客户端建立连接,并生成第二提示信息;If it is detected that the request message does not meet the establishing rule, the connection with the client is refused, and the second prompt information is generated;
    将所述第二提示信息发送给所述客户端,以供所述客户端根据所述第二提示信息提示客户端用户建立连接失败。Sending the second prompt information to the client, so that the client prompts the client user to establish a connection failure according to the second prompt information.
  8. 如权利要求2所述的连接建立方法,其特征在于,所述当所述服务器接收到所述请求报文后,检测所述请求报文是否符合建立连接的建立规则的步骤之后,还包括:The connection establishment method according to claim 2, wherein after the step of detecting whether the request message meets the establishment rule of establishing a connection after the server receives the request message, the method further includes:
    若检测到所述请求报文未符合所述建立规则,则拒绝与所述客户端建立连接,并生成第二提示信息;If it is detected that the request message does not meet the establishing rule, the connection with the client is refused, and the second prompt information is generated;
    将所述第二提示信息发送给所述客户端,以供所述客户端根据所述第二提示信息提示客户端用户建立连接失败。Sending the second prompt information to the client, so that the client prompts the client user to establish a connection failure according to the second prompt information.
  9. 如权利要求3所述的连接建立方法,其特征在于,所述当所述服务器接收到所述请求报文后,检测所述请求报文是否符合建立连接的建立规则的步骤之后,还包括:The connection establishment method according to claim 3, wherein after the step of detecting whether the request message meets the establishment rule of establishing a connection after the requesting the message, the server further includes:
    若检测到所述请求报文未符合所述建立规则,则拒绝与所述客户端建立连接,并生成第二提示信息;If it is detected that the request message does not meet the establishing rule, the connection with the client is refused, and the second prompt information is generated;
    将所述第二提示信息发送给所述客户端,以供所述客户端根据所述第二提示信息提示客户端用户建立连接失败。Sending the second prompt information to the client, so that the client prompts the client user to establish a connection failure according to the second prompt information.
  10. 如权利要求4所述的连接建立方法,其特征在于,所述当所述服务器接收到所述请求报文后,检测所述请求报文是否符合建立连接的建立规则的步骤之后,还包括:The method for establishing a connection according to claim 4, wherein after the step of detecting whether the request packet meets the establishment rule of establishing a connection after the server receives the request message, the method further includes:
    若检测到所述请求报文未符合所述建立规则,则拒绝与所述客户端建立连接,并生成第二提示信息;If it is detected that the request message does not meet the establishing rule, the connection with the client is refused, and the second prompt information is generated;
    将所述第二提示信息发送给所述客户端,以供所述客户端根据所述第二提示信息提示客户端用户建立连接失败。Sending the second prompt information to the client, so that the client prompts the client user to establish a connection failure according to the second prompt information.
  11. 如权利要求5所述的连接建立方法,其特征在于,所述当所述服务器接收到所述请求报文后,检测所述请求报文是否符合建立连接的建立规则的步骤之后,还包括:The method for establishing a connection according to claim 5, wherein after the step of detecting whether the request message meets the establishment rule of establishing a connection after the server receives the request message, the method further includes:
    若检测到所述请求报文未符合所述建立规则,则拒绝与所述客户端建立连接,并生成第二提示信息;If it is detected that the request message does not meet the establishing rule, the connection with the client is refused, and the second prompt information is generated;
    将所述第二提示信息发送给所述客户端,以供所述客户端根据所述第二提示信息提示客户端用户建立连接失败。Sending the second prompt information to the client, so that the client prompts the client user to establish a connection failure according to the second prompt information.
  12. 如权利要求6所述的连接建立方法,其特征在于,所述当所述服务器接收到所述请求报文后,检测所述请求报文是否符合建立连接的建立规则的步骤之后,还包括:The connection establishment method according to claim 6, wherein after the step of detecting whether the request message meets the establishment rule of establishing a connection after the server receives the request message, the method further includes:
    若检测到所述请求报文未符合所述建立规则,则拒绝与所述客户端建立连接,并生成第二提示信息;If it is detected that the request message does not meet the establishing rule, the connection with the client is refused, and the second prompt information is generated;
    将所述第二提示信息发送给所述客户端,以供所述客户端根据所述第二提示信息提示客户端用户建立连接失败。Sending the second prompt information to the client, so that the client prompts the client user to establish a connection failure according to the second prompt information.
  13. 一种连接建立系统,其特征在于,所述连接建立系统包括服务器和客户端,所述服务器包括:A connection establishment system, characterized in that the connection establishment system comprises a server and a client, and the server comprises:
    验证模块,用于当接收到登录请求后,验证所述登录请求,得到对应的验证数据;a verification module, configured to verify the login request after receiving the login request, and obtain corresponding verification data;
    第一发送模块,用于将所述验证数据发送给所述客户端;a first sending module, configured to send the verification data to the client;
    检测模块,用于当接收到所述客户端发送的请求报文后,检测所述请求报文是否符合建立连接的建立规则;a detecting module, configured to: after receiving the request message sent by the client, detecting whether the request message meets the establishment rule for establishing a connection;
    建立模块,用于若检测到所述请求报文符合所述建立规则,则建立与所述客户端之间的连接;Establishing a module, if it is detected that the request message meets the establishment rule, establishing a connection with the client;
    所述客户端包括:The client includes:
    第二发送模块,用于在侦测到登录请求后,将所述登录请求发送给所述服务器;a second sending module, configured to send the login request to the server after detecting the login request;
    获取模块,用于在接收到所述服务器发送的验证数据,且根据所述验证数据确定所述登录请求对应的登录操作处于正常状态后,获取所述验证数据中的登录字符串;An obtaining module, configured to: after receiving the verification data sent by the server, and determining, according to the verification data, that the login operation corresponding to the login request is in a normal state, acquiring a login string in the verification data;
    转换模块,用于将所述登录字符串转换成请求报文发送给所述服务器。And a conversion module, configured to convert the login string into a request message and send the message to the server.
  14. 如权利要求13所述连接建立系统,其特征在于,所述验证模块包括:The connection establishment system of claim 13, wherein the verification module comprises:
    提取单元,用于当接收到登录请求后,在所述登录请求中提取登录用户名和登录密码;An extracting unit, configured to: after receiving the login request, extract the login user name and the login password in the login request;
    验证单元,用于根据所述登录用户名和所述登录密码进行登录验证,得到对应的验证数据;a verification unit, configured to perform login verification according to the login user name and the login password, to obtain corresponding verification data;
    所述第二发送模块还用于当侦测到所述登录请求后,读取配置信息,根据所述配置信息设置连接所述服务器的连接信息,根据所述连接信息将所述登录请求发送给所述服务器。The second sending module is further configured to: after detecting the login request, read configuration information, set connection information connected to the server according to the configuration information, and send the login request according to the connection information to The server.
  15. 如权利要求13所述连接建立系统,其特征在于,所述获取模块包括:The connection establishing system of claim 13, wherein the obtaining module comprises:
    检测单元,用于当接收到所述验证数据后,检测所述验证数据中是否存在登录字符串;a detecting unit, configured to detect whether a login string exists in the verification data after receiving the verification data;
    第一获取单元,用于若检测到所述验证数据中存在登录字符串,则确定所述登录请求对应的登录操作处于正常状态,获取所述验证数据中的登录字符串。The first obtaining unit is configured to: if it is detected that the login string exists in the verification data, determine that the login operation corresponding to the login request is in a normal state, and acquire a login string in the verification data.
  16. 如权利要求15所述连接建立系统,其特征在于,所述转换模块包括:The connection establishment system of claim 15, wherein the conversion module comprises:
    运算单元,用于根据所述登录字符串的长度进行位运算,以重组所述登录字符串,得到重组后的所述登录字符串;将重组后的所述登录字符串与所述预设质数进行取模运算,得到与所述登录字符串对应的数据报文;An operation unit, configured to perform a bit operation according to the length of the login string to recombine the login string to obtain the reassembled login string; and the reassembled login string and the preset prime number Performing a modulo operation to obtain a data packet corresponding to the login string;
    转换单元,用于通过预设协议将所述数据报文转换成请求报文发送给所述服务器。And a converting unit, configured to convert the data packet into a request message and send the request message to the server by using a preset protocol.
  17. 如权利要求13所述连接建立系统,其特征在于,所述检测模块包括:The connection establishing system according to claim 13, wherein the detecting module comprises:
    第二获取单元,用于当接收到所述请求报文后,获取所述请求报文中的登录字符串;a second acquiring unit, configured to acquire a login string in the request packet after receiving the request packet;
    检测单元,用于检测在数据库中是否查找到与所述请求报文中的登录字符串相同的预设字符串;a detecting unit, configured to detect whether a preset character string that is the same as the login string in the request message is found in the database;
    确定单元,用于若查找到所述预设字符串,则确定所述请求报文符合建立连接的建立规则;若未查找到所述预设字符串,则确定所述请求报文未符合建立连接的建立规则。a determining unit, configured to: if the preset character string is found, determine that the request message meets a setup rule for establishing a connection; if the preset character string is not found, determine that the request message does not meet the establishment The establishment rules for the connection.
  18. 如权利要求13所述连接建立系统,其特征在于,所述服务器10还包括:The connection establishment system of claim 13, wherein the server 10 further comprises:
    第一生成模块,用于生成与所述客户端成功建立连接的第一提示信息;a first generating module, configured to generate first prompt information that successfully establishes a connection with the client;
    所述第一发送模块还用于将所述第一提示信息发送给所述客户端,以供所述客户端在接收到所述第一提示信息后监控与所述服务器之间的连接状态。The first sending module is further configured to send the first prompt information to the client, so that the client monitors a connection state with the server after receiving the first prompt information.
  19. 一种连接建立设备,其特征在于,所述连接建立设备包括存储器、微处理器和存储在所述存储器上并可在所述微处理器上运行的连接建立程序,所述已接入连接建立程序被所述微处理器执行时实现如权利要求1所述的连接建立方法的步骤。A connection establishing device, characterized in that the connection establishing device comprises a memory, a microprocessor, and a connection establishing program stored on the memory and operable on the microprocessor, the connected connection is established The steps of the connection establishment method of claim 1 are implemented when the program is executed by the microprocessor.
  20. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有连接建立程序,所述已接入连接建立程序被处理器执行时实现如权利要求1所述的连接建立方法的步骤。 A computer readable storage medium, wherein the computer readable storage medium stores a connection establishment program, and the connected connection establishment program is executed by a processor to implement the connection establishment method according to claim 1. A step of.
PCT/CN2018/094106 2018-04-24 2018-07-02 Connection establishment method, system, and device, and computer readable storage medium WO2019205288A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810370940.8 2018-04-24
CN201810370940.8A CN108650243B (en) 2018-04-24 2018-04-24 Connection establishment method, system, device and computer readable storage medium

Publications (1)

Publication Number Publication Date
WO2019205288A1 true WO2019205288A1 (en) 2019-10-31

Family

ID=63747082

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/094106 WO2019205288A1 (en) 2018-04-24 2018-07-02 Connection establishment method, system, and device, and computer readable storage medium

Country Status (2)

Country Link
CN (1) CN108650243B (en)
WO (1) WO2019205288A1 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111008254A (en) * 2019-12-03 2020-04-14 北京锐安科技有限公司 Object creating method and device, computer equipment and storage medium
CN113094290A (en) * 2021-05-21 2021-07-09 珠海金山网络游戏科技有限公司 Program test system and method
CN114363028A (en) * 2021-12-27 2022-04-15 北京世纪互联宽带数据中心有限公司 Connection establishing method, client, server, equipment and storage medium
CN116684467A (en) * 2023-08-02 2023-09-01 武汉吧哒科技股份有限公司 Data acquisition method, electronic device and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106790056A (en) * 2016-12-20 2017-05-31 中国科学院苏州生物医学工程技术研究所 Reduce the method and system of the data theft risk of data bank
CN107249004A (en) * 2017-07-24 2017-10-13 广州市玄武无线科技股份有限公司 A kind of identity identifying method, device and client
CN107317791A (en) * 2016-12-15 2017-11-03 平安科技(深圳)有限公司 Login validation method, logging request method and Security Login System
CN107666470A (en) * 2016-07-28 2018-02-06 腾讯科技(深圳)有限公司 A kind of processing method and processing device of checking information
US20180091490A1 (en) * 2016-09-23 2018-03-29 Apple Inc. Authentication framework for a client of a remote database

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9749310B2 (en) * 2015-03-27 2017-08-29 Intel Corporation Technologies for authentication and single-sign-on using device security assertions

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107666470A (en) * 2016-07-28 2018-02-06 腾讯科技(深圳)有限公司 A kind of processing method and processing device of checking information
US20180091490A1 (en) * 2016-09-23 2018-03-29 Apple Inc. Authentication framework for a client of a remote database
CN107317791A (en) * 2016-12-15 2017-11-03 平安科技(深圳)有限公司 Login validation method, logging request method and Security Login System
CN106790056A (en) * 2016-12-20 2017-05-31 中国科学院苏州生物医学工程技术研究所 Reduce the method and system of the data theft risk of data bank
CN107249004A (en) * 2017-07-24 2017-10-13 广州市玄武无线科技股份有限公司 A kind of identity identifying method, device and client

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111008254A (en) * 2019-12-03 2020-04-14 北京锐安科技有限公司 Object creating method and device, computer equipment and storage medium
CN111008254B (en) * 2019-12-03 2023-08-29 北京锐安科技有限公司 Object creation method, device, computer equipment and storage medium
CN113094290A (en) * 2021-05-21 2021-07-09 珠海金山网络游戏科技有限公司 Program test system and method
CN113094290B (en) * 2021-05-21 2024-02-23 珠海金山数字网络科技有限公司 Program testing system and method
CN114363028A (en) * 2021-12-27 2022-04-15 北京世纪互联宽带数据中心有限公司 Connection establishing method, client, server, equipment and storage medium
CN114363028B (en) * 2021-12-27 2024-03-22 北京世纪互联宽带数据中心有限公司 Connection establishment method, client, server, device and storage medium
CN116684467A (en) * 2023-08-02 2023-09-01 武汉吧哒科技股份有限公司 Data acquisition method, electronic device and storage medium
CN116684467B (en) * 2023-08-02 2023-10-27 武汉吧哒科技股份有限公司 Data acquisition method, electronic device and storage medium

Also Published As

Publication number Publication date
CN108650243B (en) 2021-04-23
CN108650243A (en) 2018-10-12

Similar Documents

Publication Publication Date Title
WO2019205288A1 (en) Connection establishment method, system, and device, and computer readable storage medium
WO2022095730A1 (en) Service communication method, system and apparatus, and electronic device
CN111935169A (en) Business data access method, device, equipment and storage medium
WO2021003975A1 (en) Gateway interface test method, terminal device, storage medium and apparatus
WO2020220413A1 (en) Zero knowledge proving method and system for personal information, and storage medium
WO2019109957A1 (en) Esb-based service providing method, apparatus and device, and readable storage medium
WO2017054444A1 (en) System login method, server, system, and network attached storage device
WO2015069018A1 (en) System for secure login, and method and apparatus for same
WO2016033929A1 (en) Cloud data backup and recovery method
WO2020042464A1 (en) Data interaction method, apparatus and device, and readable storage medium
US20140325618A1 (en) System and method for delivering external data to a process running on a virtual machine
US8892602B2 (en) Secure configuration of authentication servers
WO2018035929A1 (en) Method and apparatus for processing verification code
WO2014112754A1 (en) Web service push method and web service push server and web service providing server performing same
WO2020042471A1 (en) Firewall policy verification method, system and device, and readable storage medium
WO2020077832A1 (en) Cloud desktop access method, apparatus and device, and storage medium
WO2019161598A1 (en) Method, apparatus and device for interacting instant messaging with mail, and storage medium
WO2021078062A1 (en) Ssl certificate verification method, apparatus and device, and computer storage medium
CN111181912A (en) Browser identifier processing method and device, electronic equipment and storage medium
CN111031037A (en) Authentication method and device for object storage service and electronic equipment
JP2002189646A (en) Repeating installation
WO2014137063A1 (en) Certification method using application, and system and apparatus therefor
WO2018019137A1 (en) Data backup method and terminal
WO2024012318A1 (en) Device access method and system and non-volatile computer storage medium
WO2015070401A1 (en) Privacy protection method and electronic device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18916929

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 21.01.2021.)

122 Ep: pct application non-entry in european phase

Ref document number: 18916929

Country of ref document: EP

Kind code of ref document: A1