A non-transitory computer-readable storage medium which stores a computer program, wherein the computer program comprises program instructions, and when the program instructions are executed by an apparatus for a terminal application to access a Network Attached Storage (NAS), the apparatus performs following steps:
- when receiving a request for the terminal application to access the NAS, sending a first establishment request for a first hole punching connection between the apparatus and the NAS to the NAS, and receiving a second establishment request for a second hole punching connection between the apparatus and the terminal application sent by the terminal application, wherein the terminal application and the NAS simultaneously initiate the first hole punching connection and the second hole punching connection;
- monitoring whether the first hole punching connection and the second hole punching connection are successfully established;
- and
- after the second hole punching connection and the first hole punching connection are successfully established, performing data transmission between the terminal application and the NAS based on successfully established hole punching connections,
- wherein monitoring whether the second hole punching connection is successfully established comprises:
- extracting information about a port and a public IP address of the NAS for establishing a hole punching connection;
- sending the information about the port of the NAS for establishing the hole punching connection to the terminal application, wherein the terminal application monitors a port of the terminal application for establishing the hole punching connection and sends a hole punching connection request to the port of the NAS for establishing the hole punching connection;
- and
- when the terminal application monitors that the port of the terminal application for establishing the hole punching connection has a connection which is established or a hole punching connection corresponding to the hole punching connection request sent to the port of the NAS is successfully established, judging that the second hole punching connection is successfully established, and feeding back information about that the second hole punching connection is successfully established to the apparatus;
- wherein monitoring whether the first hole punching connection is successfully established comprises:
- extracting information about the port and a public IP address of the terminal application for establishing the hole punching connection;
- sending the information about the port of the terminal application for establishing the hole punching connection to the NAS, wherein the NAS checks whether the port of the NAS for establishing the hole punching connection has a connection which is established and the NAS sends a hole punching connection request to the port of the terminal application for establishing the hole punching connection;
- and
- when the NAS monitors that the port of the NAS for establishing the hole punching connection has a connection which is established or a hole punching connection corresponding to the hole punching connection request sent to the port the terminal application is successfully established, determining that the first hole punching connection is successfully established, and feeding back information about that the first hole punching connection is successfully established to the apparatus,
- wherein, before the performing data transmission between the terminal application and the NAS based on successfully established hole punching connections, the steps further comprises:
- when a Network Address Translation (NAT) environment of the terminal application and a NAT environment of the NAS are a symmetric NAT environment, judging that the second hole punching connection and the first hole punching connection are unsuccessfully established,
- when the second hole punching connection and the first hole punching connection are both unsuccessfully established, receiving a relay connection request sent by the terminal application and sending a request for establishing a relay connection to the NAS;
- and
- establishing a relay connection with the terminal application and a relay connection with the NAS respectively, and performing data transmission between the terminal application and the NAS based on the relay connections.