CN103973785A - Log reading system based on P2P and method thereof - Google Patents
Log reading system based on P2P and method thereof Download PDFInfo
- Publication number
- CN103973785A CN103973785A CN201410190073.1A CN201410190073A CN103973785A CN 103973785 A CN103973785 A CN 103973785A CN 201410190073 A CN201410190073 A CN 201410190073A CN 103973785 A CN103973785 A CN 103973785A
- Authority
- CN
- China
- Prior art keywords
- server
- log
- application program
- proxy server
- proxy
- Prior art date
- Legal status (The legal status 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 status listed.)
- Granted
Links
Landscapes
- Computer And Data Communications (AREA)
- Debugging And Monitoring (AREA)
Abstract
本发明公开了一种基于P2P的日志读取系统及其方法,包括:P2P代理服务器,安装在被读取日志的应用程序所在的终端上,用于根据所述应用程序所在的路径和所述应用程序对应的服务ID生成与所述应用程序一一对应的服务号,并将所述服务号注册到P2P服务器;P2P服务器,安装在具有公网IP的服务器上,用于维护和管理所述P2P代理服务器的服务号信息;P2P代理客户端,安装在开发人员设备上,用于接收用户的日志读取请求,并发送至所述P2P服务器;通过P2P服务器使所述服务号对应的P2P代理服务器与所述P2P代理客户端建立P2P连接来传送所述应用程序的日志信息,从而实现了远程实时读取到终端上的日志信息。
The present invention discloses a P2P-based log reading system and method thereof, comprising: a P2P proxy server installed on the terminal where the application program to be read is located, and used for according to the path of the application program and the The service ID corresponding to the application program generates a service number corresponding to the application program one by one, and registers the service number to the P2P server; the P2P server is installed on a server with a public network IP for maintaining and managing the The service number information of the P2P proxy server; the P2P proxy client, installed on the developer’s device, is used to receive the user’s log reading request and send it to the P2P server; the P2P proxy corresponding to the service number is enabled by the P2P server The server establishes a P2P connection with the P2P proxy client to transmit the log information of the application program, thereby realizing remote real-time reading of the log information on the terminal.
Description
技术领域 technical field
本发明涉及通信领域,尤其涉及的是一种基于P2P的日志读取系统及其方法。 The present invention relates to the communication field, in particular to a P2P-based log reading system and method thereof.
背景技术 Background technique
随着移动互联网的飞速发展,智能手机、智能电视、智能路由器、智能家居等各种智能终端设备层出不穷,随之也产生了亿万的智能终端应用程序。随着智能终端性能愈发地强大,也使得开发的智能终端应用程序越来越复杂,因此必须要日志系统来帮助追踪和查找应用程序中存在的BUG。 With the rapid development of the mobile Internet, various smart terminal devices such as smart phones, smart TVs, smart routers, and smart homes emerge in an endless stream, and hundreds of millions of smart terminal applications have also emerged. As the performance of smart terminals becomes more and more powerful, the developed smart terminal applications become more and more complex. Therefore, a log system is necessary to help track and find bugs in the applications.
传统的嵌入式日志系统基本都是以写文件的形式,将日志信息记录文件中,在需要查看的时候再读取相应的日志文件以获得日志信息。这种日志系统有个致命的弱点和不便,那就是无法远程(不在同一个局域网)读取日志信息,这样给多方联合开发的应用程序追踪和查找BUG的时候带来极大的困难,从而增加了巨大的沟通成本,同时也使得开发周期被拉长。这显然不能适应目前移动互联网飞速前进、智能终端应用程序迅速开发迭代的环境。且现有的日志系统传输日志信息方式麻烦,不够快捷。 The traditional embedded log system basically records the log information in the file in the form of writing files, and then reads the corresponding log file to obtain the log information when it needs to be viewed. This kind of log system has a fatal weakness and inconvenience, that is, it cannot read log information remotely (not in the same local area network), which brings great difficulties to applications jointly developed by multiple parties when tracking and finding bugs, thus increasing Incurred a huge communication cost, but also lengthened the development cycle. This obviously cannot adapt to the current environment where the mobile Internet is advancing rapidly and smart terminal applications are rapidly developing and iterating. Moreover, the existing log system transmits log information in a cumbersome manner and is not fast enough.
因此,现有技术还有待于改进和发展。 Therefore, the prior art still needs to be improved and developed.
发明内容 Contents of the invention
本发明要解决的技术问题在于,提供一种基于P2P的日志读取系统及其方法,旨在解决现有的日志系统无法远程实时读取日志信息、及传输日志信息麻烦缓慢的问题。 The technical problem to be solved by the present invention is to provide a P2P-based log reading system and its method, aiming to solve the problems that the existing log system cannot read log information remotely and in real time, and the transmission of log information is cumbersome and slow.
本发明解决技术问题所采用的技术方案如下: The technical solution adopted by the present invention to solve technical problems is as follows:
一种基于P2P的日志读取系统,其中,包括: A P2P-based log reading system, including:
P2P代理服务器,安装在被读取日志的应用程序所在的终端上,用于根据所述应用程序所在的路径和所述应用程序对应的服务ID生成与所述应用程序一一对应的服务号,并将所述服务号注册到P2P服务器; The P2P proxy server is installed on the terminal where the application program of the read log is located, and is used to generate a service number corresponding to the application program according to the path where the application program is located and the service ID corresponding to the application program, and register the service number with the P2P server;
P2P服务器,安装在具有公网IP的服务器上,用于维护和管理所述P2P代理服务器的服务号信息; The P2P server is installed on a server with a public network IP, and is used to maintain and manage the service number information of the P2P proxy server;
P2P代理客户端,安装在开发人员设备上,用于接收用户的日志读取请求,并发送至所述P2P服务器; The P2P proxy client is installed on the developer's device, and is used to receive the user's log reading request and send it to the P2P server;
所述P2P服务器还用于根据所述日志读取请求得出对应的服务号,并使所述服务号对应的P2P代理服务器与所述P2P代理客户端建立P2P连接;若P2P连接建立成功,所述P2P代理服务器读取所述应用程序的日志信息,并发送给所述P2P代理客户端进行读取;若P2P连接建立失败,则所述P2P代理服务器读取所述应用程序的日志信息,并通过所述P2P服务器中转发送给所述P2P代理客户端进行读取。 The P2P server is also used to obtain the corresponding service number according to the log reading request, and make the P2P proxy server corresponding to the service number establish a P2P connection with the P2P proxy client; if the P2P connection is established successfully, the The P2P proxy server reads the log information of the application program, and sends it to the P2P proxy client for reading; if the P2P connection fails to be established, the P2P proxy server reads the log information of the application program, and It is forwarded to the P2P proxy client through the P2P server for reading.
所述的基于P2P的日志读取系统,其中,还包括:第一加密模块,用于对所述P2P代理服务器与所述P2P代理客户端建立的P2P连接进行SSL加密。 The P2P-based log reading system further includes: a first encryption module, configured to perform SSL encryption on the P2P connection established between the P2P proxy server and the P2P proxy client.
所述的基于P2P的日志读取系统,其中,还包括: The P2P-based log reading system also includes:
第二加密模块,用于对所述P2P代理服务器将所述应用程序的日志信息通过所述P2P服务器中转发送给所述P2P代理客户端的数据传输进行SSL加密。 The second encryption module is configured to perform SSL encryption on the data transmission that the P2P proxy server forwards the log information of the application program to the P2P proxy client through the P2P server.
所述的基于P2P的日志读取系统,其中,所述P2P服务器,还用于将所述P2P代理客户端经网络地址转换映射后的IP和端口信息发送给所述P2P代理服务器,以使所述P2P代理服务器与所述P2P代理客户端建立P2P连接。 The P2P-based log reading system, wherein the P2P server is further configured to send the IP and port information of the P2P proxy client after network address translation mapping to the P2P proxy server, so that all The P2P proxy server establishes a P2P connection with the P2P proxy client.
一种采用上述的基于P2P的日志读取系统的日志读取方法,其中,包括步骤: A log reading method using the above-mentioned P2P-based log reading system, including steps:
A、P2P代理服务器根据其所在终端上的不同应用程序的路径和对应的服务ID生成一一对应的服务号,并将所述服务号注册至P2P服务器; A. The P2P proxy server generates a one-to-one corresponding service number according to the paths of different application programs on the terminal where it is located and the corresponding service ID, and registers the service number to the P2P server;
B、P2P代理客户端接收用户的日志读取请求,并发送至所述P2P服务器; B. The P2P proxy client receives the user's log reading request and sends it to the P2P server;
C、所述P2P服务器根据所述日志读取请求查询对应的应用程序的服务号,使所述服务号对应的P2P代理服务器与所述P2P代理客户端建立P2P连接;若P2P连接建立成功,所述P2P代理服务器读取所述应用程序的日志信息,并发送给所述P2P代理客户端进行读取;若P2P连接建立失败,则所述P2P代理服务器读取所述应用程序的日志信息,并通过所述P2P服务器中转发送给所述P2P代理客户端进行读取。 C. The P2P server queries the service number of the corresponding application program according to the log reading request, so that the P2P proxy server corresponding to the service number establishes a P2P connection with the P2P proxy client; if the P2P connection is established successfully, the The P2P proxy server reads the log information of the application program, and sends it to the P2P proxy client for reading; if the P2P connection fails to be established, the P2P proxy server reads the log information of the application program, and It is forwarded to the P2P proxy client through the P2P server for reading.
所述的日志读取方法,其中,所述步骤C还包括:对所述P2P代理服务器与所述P2P代理客户端建立的P2P连接进行SSL加密。 In the log reading method, the step C further includes: performing SSL encryption on the P2P connection established between the P2P proxy server and the P2P proxy client.
所述的日志读取方法,其中,所述步骤C还包括: The log reading method, wherein, the step C also includes:
对所述P2P代理服务器将所述应用程序的日志信息通过所述P2P服务器中转发送给所述P2P代理客户端的数据传输进行SSL加密。 SSL encryption is performed on the data transmission of the P2P proxy server forwarding the log information of the application program to the P2P proxy client through the P2P server.
所述的日志读取方法,其中,所述步骤C具体包括: The log reading method, wherein, the step C specifically includes:
所述P2P服务器将所述P2P代理客户端经网络地址转换映射后的IP和端口信息发送给所述P2P代理服务器,以使所述P2P代理服务器与所述P2P代理客户端建立P2P连接。 The P2P server sends the IP and port information of the P2P proxy client mapped by NAT to the P2P proxy server, so that the P2P proxy server establishes a P2P connection with the P2P proxy client.
本发明所提供的一种基于P2P的日志读取系统及其方法,有效地解决了现有的日志系统无法远程实时读取日志信息、及传输日志信息麻烦缓慢的问题,所述日志读取系统包括:P2P代理服务器,安装在被读取日志的应用程序所在的终端上,用于根据所述应用程序所在的路径和所述应用程序对应的服务ID生成与所述应用程序一一对应的服务号,并将所述服务号注册到P2P服务器;P2P服务器,安装在具有公网IP的服务器上,用于维护和管理所述P2P代理服务器的服务号信息;P2P代理客户端,安装在开发人员设备上,用于接收用户的日志读取请求,并发送至所述P2P服务器;所述P2P服务器还用于根据所述日志读取请求得出对应的服务号,并使所述服务号对应的P2P代理服务器与所述P2P代理客户端建立P2P连接;若P2P连接建立成功,所述P2P代理服务器读取所述应用程序的日志信息,并发送给所述P2P代理客户端进行读取;若P2P连接建立失败,则所述P2P代理服务器读取所述应用程序的日志信息,并通过所述P2P服务器中转发送给所述P2P代理客户端进行读取;通过P2P代理服务器与所述P2P代理客户端建立P2P连接来传输所述应用程序的日志信息;在检测到无法进行P2P连接的建立的情况下,P2P代理服务器读取所述应用程序的日志信息,并通过所述P2P服务器中转发送给所述P2P代理客户端,从而供P2P代理客户端读取所述应用程序的日志信息;使得终端和开发人员的设备能以任何方式连上互联网,开发人员就能远程实时读取到位于终端上的日志信息,从而实现了远程实时读取到位于终端上的日志信息。同时,所述日志系统在终端应用程序的配合下,能够动态地实现终端应用程序日志模块的开启、关闭和日志级别的转变等等,方便开发人员或维护人员获取足够的日志信息,迅速追踪和查找智能终端应用程序中的BUG,带来了大大的方便。 A P2P-based log reading system and method thereof provided by the present invention effectively solve the problem that the existing log system cannot read log information remotely and in real time, and the troublesome and slow transmission of log information, the log reading system Including: a P2P proxy server, installed on the terminal where the application program to be read is located, and used to generate a one-to-one corresponding service to the application program according to the path where the application program is located and the service ID corresponding to the application program number, and register the service number to the P2P server; the P2P server is installed on a server with a public network IP to maintain and manage the service number information of the P2P proxy server; the P2P proxy client is installed on the developer On the device, it is used to receive the user’s log reading request and send it to the P2P server; the P2P server is also used to obtain the corresponding service number according to the log reading request, and make the corresponding service number The P2P proxy server establishes a P2P connection with the P2P proxy client; if the P2P connection is established successfully, the P2P proxy server reads the log information of the application program and sends it to the P2P proxy client for reading; if the P2P Connection setup fails, then the P2P proxy server reads the log information of the application program, and forwards it to the P2P proxy client for reading through the P2P server; through the P2P proxy server and the P2P proxy client Establish a P2P connection to transmit the log information of the application program; when it is detected that the P2P connection cannot be established, the P2P proxy server reads the log information of the application program and forwards it to the P2P proxy client, so that the P2P proxy client can read the log information of the application program; so that the terminal and the developer's device can be connected to the Internet in any way, and the developer can remotely read the log on the terminal in real time information, thereby realizing remote real-time reading of log information located on the terminal. At the same time, with the cooperation of the terminal application program, the log system can dynamically realize the opening and closing of the log module of the terminal application program and the change of the log level, etc., so that developers or maintenance personnel can obtain sufficient log information, quickly track and Finding bugs in smart terminal applications brings great convenience.
附图说明 Description of drawings
图1为本发明提供的基于P2P的日志读取系统较佳实施例的结构图。 FIG. 1 is a structural diagram of a preferred embodiment of a P2P-based log reading system provided by the present invention.
图2为本发明提供的基于P2P的日志读取方法较佳实施例的流程图。 Fig. 2 is a flow chart of a preferred embodiment of the P2P-based log reading method provided by the present invention.
具体实施方式 Detailed ways
本发明提供一种基于P2P的日志读取系统及其方法,为使本发明的目的、技术方案及优点更加清楚、明确,以下参照附图并举实施例对本发明进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。 The present invention provides a P2P-based log reading system and method thereof. In order to make the purpose, technical solution and advantages of the present invention clearer and clearer, the present invention will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described here are only used to explain the present invention, not to limit the present invention.
请参阅图1,图1为本发明提供的基于P2P的日志读取系统较佳实施例的结构图,如图所示,所述基于P2P的日志读取系统包括: Please refer to Fig. 1, Fig. 1 is a structural diagram of a preferred embodiment of the P2P-based log reading system provided by the present invention, as shown in the figure, the P2P-based log reading system includes:
P2P代理服务器10,安装在被读取日志的应用程序所在的终端上,用于根据所述应用程序所在的路径和所述应用程序对应的服务ID生成与所述应用程序一一对应的服务号,并将所述服务号注册到P2P服务器20; P2P proxy server 10 is installed on the terminal where the application program that reads the log is located, and is used to generate a service number corresponding to the application program according to the path where the application program is located and the service ID corresponding to the application program , and register the service number to the P2P server 20;
P2P服务器20,安装在具有公网IP的服务器上,用于维护和管理所述P2P代理服务器10的服务号信息; P2P server 20, installed on the server with public network IP, is used for maintaining and managing the service number information of described P2P proxy server 10;
P2P代理客户端30,安装在开发人员设备上,用于接收用户的日志读取请求,并发送至所述P2P服务器20; The P2P proxy client 30 is installed on the developer's device, and is used to receive the user's log reading request and send it to the P2P server 20;
所述P2P服务器20还用于根据所述日志读取请求得出对应的服务号,并使所述服务号对应的P2P代理服务器10与所述P2P代理客户端30建立P2P连接;若P2P连接建立成功,所述P2P代理服务器10读取所述应用程序的日志信息,并发送给所述P2P代理客户端30进行读取;若P2P连接建立失败,则所述P2P代理服务器10读取所述应用程序的日志信息,并通过所述P2P服务器20中转发送给所述P2P代理客户端30进行读取。 The P2P server 20 is also used to obtain the corresponding service number according to the log reading request, and make the P2P proxy server 10 corresponding to the service number establish a P2P connection with the P2P proxy client 30; if the P2P connection is established If successful, the P2P proxy server 10 reads the log information of the application program and sends it to the P2P proxy client 30 for reading; if the P2P connection fails to be established, the P2P proxy server 10 reads the log information of the application program. The log information of the program is forwarded by the P2P server 20 to the P2P proxy client 30 for reading.
下面结合具体的实施例对所述日志读取系统进行详细说明。 The log reading system will be described in detail below in conjunction with specific embodiments.
关于P2P,即对等计算(Peer to Peer,简称P2P),可以简单的定义成通过直接交换来共享计算机资源和服务,而对等计算模型应用层形成的网络通常称为对等网络。本发明提供的日志系统是基于P2P来穿越NAT(Network Address Translation,网络地址转换)和防火墙将相关日志信息发送给开发人员或维护人员。所述P2P代理服务器10即P2P proxy server,是基于ICE协议采用C语言开发可移植于绝大部分智能终端的日志系统组件。所述ICE(Interactive Connectivity Establishment)是一种最全面的用于穿透NAT和多媒体通信的方法。它提供了一种找到两个终端之间最好路径的方法,它还解决了NAT所带来的各种各样的问题。所述P2P代理服务器10安装部署在应用程序所在的智能终端设备上,然后启动P2P proxy server,在启动P2P proxy server的时候要根据应用程序所在的路径(例如: /mnt/android/boa/boa.log),以及一个服务ID(用户自己设置的一个服务标识,服务标识由字母和数字组成,例如:myservice007),所述路径和服务ID共同构成了本智能终端设备上的一个日志服务(日志服务是指用户想要传输的日志信息的一个服务标识),P2P proxy server会根据所述路径和服务ID生成一个全局唯一的服务号并注册所述服务号到具有公网IP的服务器上的P2P服务器20。具体来说,一个服务ID用于对应标识某个终端上的某个应用程序,也就是说某个服务ID与某个应用程序对应。所述P2P代理服务器10根据某个应用程序在某个终端上的路径和对应的服务ID,然后生成与该应用程序一一对应的服务号,再将所述服务号注册到P2P服务器20。这样,即使在一个智能终端设备上有多个应用程序,通过各自对应的服务号也能提供对应的日志服务,能够获取到对应的日志信息。 Regarding P2P, that is, peer-to-peer computing (Peer to Peer, P2P for short), can be simply defined as sharing computer resources and services through direct exchange, and the network formed by the application layer of the peer-to-peer computing model is usually called a peer-to-peer network. The log system provided by the present invention is based on P2P to traverse NAT (Network Address Translation, Network Address Translation) and firewalls and send relevant log information to developers or maintenance personnel. The P2P proxy server 10 is a P2P proxy server, which is a log system component developed in C language based on the ICE protocol and can be transplanted to most intelligent terminals. The ICE (Interactive Connectivity Establishment) is the most comprehensive method for traversing NAT and multimedia communication. It provides a way to find the best path between two terminals, and it also solves various problems caused by NAT. The P2P proxy server 10 is installed and deployed on the smart terminal device where the application program is located, and then starts the P2P proxy server. When starting the P2P proxy server, the path where the application program is located (for example: /mnt/android/boa/boa. log), and a service ID (a service ID set by the user, the service ID consists of letters and numbers, for example: myservice007), the path and the service ID together constitute a log service (log service Refers to a service identifier of the log information that the user wants to transmit), the P2P proxy server will generate a globally unique service number based on the path and service ID and register the service number to the P2P server on the server with the public network IP 20. Specifically, a service ID is used to correspondingly identify a certain application program on a certain terminal, that is to say, a certain service ID corresponds to a certain application program. The P2P proxy server 10 generates a service number corresponding to the application program one by one according to the path of a certain application program on a certain terminal and the corresponding service ID, and then registers the service number to the P2P server 20 . In this way, even if there are multiple application programs on one smart terminal device, corresponding log services can be provided through their corresponding service numbers, and corresponding log information can be obtained.
为了进一步地实现服务号与不同终端上的不同应用程序的一一对应,P2P proxy server会根据所述路径、服务ID以及智能终端的一些信息(譬如硬件如CPU等信息)生成一个全局唯一的服务号并注册该服务号到具有公网IP的服务器上的P2P服务器20(即P2P server)。 In order to further realize the one-to-one correspondence between service numbers and different applications on different terminals, the P2P proxy server will generate a globally unique service based on the path, service ID and some information of the smart terminal (such as hardware such as CPU information) account and register the service account to the P2P server 20 (that is, the P2P server) on the server with the public network IP.
所述P2P服务器20,即P2P server,是基于ICE协议采用C语言开发可移植于绝大部分智能终端的日志系统组件,所述P2P服务器20,采用ANSI C语言来开发,使其具有较为广泛的可移植性和更好的性能。将P2P server安装部署在一台具有公网IP的服务器上,然后启动P2P server监听公网服务器上没有被其他程序占用且能够被外部网络访问的两个不同网络端口(例如25555和15555两个端口)。这样,所述P2P代理客户端30和P2P代理服务器10便可分别通过上述公网IP和不同端口访问所述P2P服务器20,进而进行数据交互。所述P2P服务器20用于维护所有P2P proxy server的注册信息,并对P2P proxy server进行管理。 The P2P server 20, that is, the P2P server, is based on the ICE protocol and uses the C language to develop log system components that can be transplanted to most intelligent terminals. The P2P server 20 is developed using the ANSI C language, so that it has a wide range of Portability and better performance. Install and deploy the P2P server on a server with a public network IP, and then start the P2P server to listen to two different network ports on the public network server that are not occupied by other programs and can be accessed by the external network (for example, two ports 25555 and 15555 ). In this way, the P2P proxy client 30 and the P2P proxy server 10 can respectively access the P2P server 20 through the public network IP and different ports, and then perform data interaction. The P2P server 20 is used to maintain the registration information of all P2P proxy servers and manage the P2P proxy servers.
所述P2P代理客户端30,即P2P proxy client,是基于ICE协议采用C语言开发可移植于绝大部分智能终端的日志系统组件,安装部署在开发人员的设备上。所述P2P proxy server安装于智能终端设备中,启动并配置指向需要监控的应用程序的日志文件。然后启动P2P proxy client监听本地端口(即开发人员设备上的端口)。然后可启动对应的读取日志的应用程序,并通过TCP协议连上本地端口,向P2P proxy client的本地端口发送读取某个应用程序的日志信息的请求。P2P proxy client收到请求后,就会连接上公网服务器上的P2P server并发送请求至P2P server。P2P server收到P2P proxy client的请求后,在给P2P proxy client响应该应用程序对应的服务号信息同时,也会将P2P proxy client的相关信息(譬如NAT映射后的IP和端口)发送给注册了所述服务号的P2P proxy server。P2P proxy client和P2P proxy server得到对方信息后,开始建立P2P连接,如果连接建立成功,那么P2P proxy server就会去读取所述服务号对应的应用程序的日志信息并将相应日志信息发送给P2P proxy client,P2P proxy client接收日志信息并将日志信息返回给用户读取日志的应用程序,从而实现了实时远程日志读取。关于读取日志信息的应用程序为开发人员编写的用来读取日志信息的程序,这乃现有技术,此处不做过多说明。 The P2P proxy client 30, that is, the P2P proxy client, is a log system component developed in C language based on the ICE protocol and can be transplanted to most smart terminals, and is installed and deployed on the developer's device. The P2P proxy server is installed in the intelligent terminal equipment, starts and configures log files pointing to the application programs that need to be monitored. Then start the P2P proxy client to listen on the local port (that is, the port on the developer's device). Then the corresponding application program for reading the log can be started, and the local port can be connected to the local port through the TCP protocol, and a request for reading the log information of a certain application program can be sent to the local port of the P2P proxy client. After receiving the request, the P2P proxy client will connect to the P2P server on the public network server and send the request to the P2P server. After receiving the request from the P2P proxy client, the P2P server will respond to the P2P proxy client with the service number information corresponding to the application, and will also send the relevant information of the P2P proxy client (such as the IP and port after NAT mapping) to the registered The P2P proxy server of the service account. After the P2P proxy client and the P2P proxy server get each other's information, they start to establish a P2P connection. If the connection is established successfully, the P2P proxy server will read the log information of the application program corresponding to the service number and send the corresponding log information to the P2P Proxy client, P2P proxy client receives log information and returns the log information to the application program that the user reads the log, thus realizing real-time remote log reading. The application program for reading log information is a program written by developers to read log information, which is the prior art, and will not be described here.
若P2P连接建立失败,则所述P2P代理服务器10读取所述应用程序的日志信息,并通过所述P2P服务器20中转发送给所述P2P代理客户端30进行读取。也就是说,如果P2P连接建立失败,那么P2P proxy server会将日志信息发送给P2P server并由P2P server 中转给P2P proxy client,从而实现远程实时的日志读取。 If the P2P connection fails to be established, the P2P proxy server 10 reads the log information of the application program, and forwards it to the P2P proxy client 30 through the P2P server 20 for reading. That is to say, if the P2P connection fails to be established, the P2P proxy server will send the log information to the P2P server and the P2P server will transfer the log information to the P2P proxy client, so as to realize remote real-time log reading.
总的来说,所述P2P代理客户端30,用于接受用户的读取某个应用程序的日志请求,解析用户的日志请求,并在P2P server的协助下和P2P proxy server建立起P2P连接来接收日志信息和发送相关日志请求,或是在检测到无法进行P2P连接的建立的情况下,将日志请求发送给P2P server,由P2P server中转其日志请求给P2P proxy server,和接收P2P server中转过来的日志信息。P2P proxy client的程序库方式,将提供一个核心接口get-logmessage给用户的应用程序调用。 In general, the P2P proxy client 30 is used to accept a user's log request for reading a certain application program, parse the user's log request, and establish a P2P connection with the P2P proxy server with the assistance of the P2P server. Receive log information and send related log requests, or send log requests to P2P server when it is detected that P2P connection cannot be established log information. The program library method of P2P proxy client will provide a core interface get-logmessage for the user's application program to call.
进一步地,所述的基于P2P的日志读取系统,还包括:第一加密模块,用于对所述P2P代理服务器10与所述P2P代理客户端30建立的P2P连接进行SSL加密。具体来说,就是对网络通信都采用SSL加密,确保通信消息的安全性。所述SSL(Secure Sockets Layer)是一种安全协议,在传输层中对网络通信进行加密,确保通信消息的安全性。 Further, the P2P-based log reading system further includes: a first encryption module, configured to perform SSL encryption on the P2P connection established between the P2P proxy server 10 and the P2P proxy client 30 . Specifically, SSL encryption is used for network communication to ensure the security of communication messages. The SSL (Secure Sockets Layer) is a security protocol that encrypts network communication in the transport layer to ensure the security of communication messages.
进一步地,所述的基于P2P的日志读取系统,还包括:第二加密模块,用于对所述P2P代理服务器10将所述应用程序的日志信息通过所述P2P服务器20中转发送给所述P2P代理客户端30的数据传输进行SSL加密。具体来说,在当P2P连接建立失败时,需要P2P服务器20来中转开发人员需要的应用程序的日志信息,那么对应的两方面的网络通信都要进行SSL加密,以提高消息的安全性。 Further, the P2P-based log reading system also includes: a second encryption module, configured to forward the log information of the application program to the P2P proxy server 10 through the P2P server 20 The data transmission of the P2P proxy client 30 is encrypted by SSL. Specifically, when the P2P connection fails to be established, the P2P server 20 is required to transfer the log information of the application program required by the developer, and then the corresponding two aspects of network communication must be encrypted by SSL to improve the security of the message.
进一步地,在建立P2P连接时,所述P2P服务器20,还用于将所述P2P代理客户端30经网络地址转换映射后的IP和端口信息发送给所述P2P代理服务器10,以使所述P2P代理服务器10与所述P2P代理客户端30建立P2P连接。 Further, when establishing a P2P connection, the P2P server 20 is also used to send the IP and port information of the P2P proxy client 30 mapped by network address translation to the P2P proxy server 10, so that the The P2P proxy server 10 establishes a P2P connection with the P2P proxy client 30 .
本发明提供的基于P2P的日志读取系统,是基于P2P的嵌入式日志系统,包括部署于公网的P2P server、部署于智能终端的P2P proxy server和部署于开发人员机器上的P2P proxy client,通过该日志系统,智能终端和开发人员的机器以任何方式连上互联网,开发人员就能远程实时读取到位于智能终端上的日志信息,使得开发人员或维护人员能够在任何能够接入互联网的地方,远程读取智能终端应用程序产生的日志信息或控制应用程序的日志行为,极大方便开发人员追踪和查找应用程序中的BUG,譬如可在任何能够接入互联网的地方和智能终端应用程序交互,读取其日志信息、关闭或开启其日志模块、改变其日志级别等等,极大方便开发人员追踪和查找应用程序中的BUG,特别是对于多方联合开发的应用程序,节省了大量的开发时间和成本。 The P2P-based log reading system provided by the present invention is a P2P-based embedded log system, including a P2P server deployed on a public network, a P2P proxy server deployed on an intelligent terminal, and a P2P proxy client deployed on a developer's machine. Through this log system, the smart terminal and the developer's machine are connected to the Internet in any way, and the developer can remotely read the log information on the smart terminal in real time, so that the developer or maintenance personnel can access the Internet in any Remotely read the log information generated by the smart terminal application or control the log behavior of the application, which greatly facilitates developers to track and find bugs in the application. Interaction, read its log information, close or open its log module, change its log level, etc., which greatly facilitates developers to track and find bugs in applications, especially for applications jointly developed by multiple parties, saving a lot of time development time and cost.
并且,本发明提供的日志系统可以很好的兼容传统的日志系统,原先部署在智能终端上的应用程序无需做任何修改,只要在智能终端设备启动P2P proxy server时配置指定应用程序的日志路径即可,这样开发人员就能远程读取该应用程序的日志信息。同时,新开发的智能终端应用程序可以配合P2P proxy server开放一些接口出来,开发人员就可以在应用程序运行的过程中,动态的给应用程序发送一些消息指令,让应用程序开启或关闭日志模块、调整日志模块的日志等级等等。 Moreover, the log system provided by the present invention can be well compatible with the traditional log system. The application program deployed on the smart terminal does not need to be modified in any way, as long as the log path of the specified application program is configured when the smart terminal device starts the P2P proxy server. Yes, so that developers can remotely read the application's log information. At the same time, the newly developed smart terminal application program can cooperate with the P2P proxy server to open some interfaces, and the developer can dynamically send some message instructions to the application program during the running process of the application program, so that the application program can enable or disable the log module, Adjust the log level of the log module, etc.
上述的日志读取系统是以可执行程序的方式来实现的,在实际应用时,本发明提供的基于P2P的日志读取系统还可以以程序库的方式来实现。简单来说,P2P proxy server的程序库方式,将提供一个核心接口start-proxy-server接口给用户的应用程序调用。P2P server的程序库方式,将提供一个核心接口start-server接口给用户的应用程序调用。P2P proxy client的程序库方式,将提供一个核心接口get-logmessage给用户的应用程序调用。开发人员采用程序库自己开发一个P2P server,这样可将自己编写一些回调函数传给P2P server程序库接口,这样P2P server在接收到请求或产生响应的时候会调用该回调函数,以便达到个性化需求,例如身份认证或统计分析等等。P2P server开发完成后,具体的安装部署和运行过程与可执行程序的方式一是一样的。开发人员读取日志的的应用程序调用程序库提供的start-server接口,并传入用户自己的回调函数和需要监听的端口,即可启动P2P server监听相应端口。开发人员引用本专利提供的程序库来开发一个P2P proxy server,P2P proxy server将作为应用程序的一个线程或子进程运行于智能终端设备上。这样可针对应用程序的特性提供一些回调函数给P2P proxy server程序库接口,使得P2P proxy server能够动态地调整应用程序的日志模块的开关、日志级别的改变等。具体来说,开发人员读取日志的应用程序调用程序库提供的start-proxy-server接口,并传入自己的回调函数,即可启动P2P proxy server,P2P proxy server会生成一个全局唯一的服务号并注册所述服务号到公网服务器上的P2P server。开发人员读取日志的应用程序调用程序库提供的get-logmessage,并传入自己的回调函数和需要获取日志的服务号,后续流程和上述可执行程序方式一样,此处不再详述。 The above-mentioned log reading system is implemented in the form of an executable program. In actual application, the P2P-based log reading system provided by the present invention can also be implemented in the form of a program library. To put it simply, the P2P proxy server program library method will provide a core interface start-proxy-server interface for the user's application program to call. The program library method of the P2P server will provide a core interface start-server interface for the user's application program to call. The program library method of P2P proxy client will provide a core interface get-logmessage for the user's application program to call. Developers use the program library to develop a P2P server by themselves, so that they can write some callback functions to the P2P server program library interface, so that the P2P server will call the callback function when it receives a request or generates a response, so as to meet individual needs , such as identity authentication or statistical analysis, etc. After the development of the P2P server is completed, the specific installation, deployment and operation process is the same as that of the executable program. The application program that the developer reads the log calls the start-server interface provided by the library, and passes in the user's own callback function and the port to be monitored to start the P2P server to monitor the corresponding port. Developers refer to the program library provided by this patent to develop a P2P proxy server, and the P2P proxy server will run on the smart terminal device as a thread or sub-process of the application program. In this way, some callback functions can be provided to the P2P proxy server program library interface according to the characteristics of the application program, so that the P2P proxy server can dynamically adjust the switch of the log module of the application program, the change of the log level, and the like. Specifically, the developer's application program that reads the log calls the start-proxy-server interface provided by the library and passes in its own callback function to start the P2P proxy server. The P2P proxy server will generate a globally unique service number And register the service number to the P2P server on the public network server. The application that the developer reads the log calls the get-logmessage provided by the library, and passes in its own callback function and the service number that needs to obtain the log. The subsequent process is the same as the above-mentioned executable program, and will not be described in detail here.
基于上述基于P2P的日志读取系统,本发明实施例还提供了一种基于P2P的日志读取方法,如图2所示,所述日志读取方法包括步骤: Based on the above P2P-based log reading system, the embodiment of the present invention also provides a P2P-based log reading method, as shown in Figure 2, the log reading method includes steps:
S100、P2P代理服务器根据其所在终端上的不同应用程序的路径和对应的服务ID生成一一对应的服务号,并将所述服务号注册至P2P服务器; S100, the P2P proxy server generates a one-to-one corresponding service number according to the paths of different application programs on the terminal where it is located and the corresponding service ID, and registers the service number to the P2P server;
S200、P2P代理客户端接收用户的日志读取请求,并发送至所述P2P服务器; S200, the P2P proxy client receives the user's log reading request, and sends it to the P2P server;
S300、所述P2P服务器根据所述日志读取请求查询对应的应用程序的服务号,使所述服务号对应的P2P代理服务器与所述P2P代理客户端建立P2P连接;若P2P连接建立成功,所述P2P代理服务器读取所述应用程序的日志信息,并发送给所述P2P代理客户端进行读取;若P2P连接建立失败,则所述P2P代理服务器读取所述应用程序的日志信息,并通过所述P2P服务器中转发送给所述P2P代理客户端进行读取。 S300. The P2P server queries the service number of the corresponding application program according to the log reading request, so that the P2P proxy server corresponding to the service number establishes a P2P connection with the P2P proxy client; if the P2P connection is established successfully, the The P2P proxy server reads the log information of the application program, and sends it to the P2P proxy client for reading; if the P2P connection fails to be established, the P2P proxy server reads the log information of the application program, and It is forwarded to the P2P proxy client through the P2P server for reading.
进一步地,所述步骤S300还包括:对所述P2P代理服务器与所述P2P代理客户端建立的P2P连接进行SSL加密。 Further, the step S300 also includes: performing SSL encryption on the P2P connection established between the P2P proxy server and the P2P proxy client.
进一步地,所述步骤S300还包括: Further, the step S300 also includes:
对所述P2P代理服务器将所述应用程序的日志信息通过所述P2P服务器中转发送给所述P2P代理客户端的数据传输进行SSL加密。 SSL encryption is performed on the data transmission of the P2P proxy server forwarding the log information of the application program to the P2P proxy client through the P2P server.
进一步地,所述步骤S300具体包括: Further, the step S300 specifically includes:
所述P2P服务器将所述P2P代理客户端经网络地址转换映射后的IP和端口信息发送给所述P2P代理服务器,以使所述P2P代理服务器与所述P2P代理客户端建立P2P连接。 The P2P server sends the IP and port information of the P2P proxy client mapped by NAT to the P2P proxy server, so that the P2P proxy server establishes a P2P connection with the P2P proxy client.
综上所述,本发明实施例提供的一种基于P2P的日志读取系统及其方法,包括:P2P代理服务器,安装在被读取日志的应用程序所在的终端上,用于根据所述应用程序所在的路径和所述应用程序对应的服务ID生成与所述应用程序一一对应的服务号,并将所述服务号注册到P2P服务器;P2P服务器,安装在具有公网IP的服务器上,用于维护和管理所述P2P代理服务器的服务号信息;P2P代理客户端,安装在开发人员设备上,用于接收用户的日志读取请求,并发送至所述P2P服务器;所述P2P服务器还用于根据所述日志读取请求得出对应的服务号,并使所述服务号对应的P2P代理服务器与所述P2P代理客户端建立P2P连接;若P2P连接建立成功,所述P2P代理服务器读取所述应用程序的日志信息并发送给所述P2P代理客户端进行读取;若P2P连接建立失败,则所述P2P代理服务器读取所述应用程序的日志信息,并通过所述P2P服务器中转发送给所述P2P代理客户端进行读取;通过P2P代理服务器与所述P2P代理客户端建立P2P连接来传输所述应用程序的日志信息,在检测到无法进行P2P连接的建立的情况下,P2P代理服务器读取所述应用程序的日志信息,并通过所述P2P服务器中转发送给所述P2P代理客户端,从而供P2P代理客户端读取所述应用程序的日志信息;从而使得终端和开发人员的设备能以任何方式连上互联网,开发人员就能远程实时读取到位于终端上的日志信息,从而实现了远程实时读取到位于终端上的日志信息,带来了大大的方便。 In summary, a P2P-based log reading system and method thereof provided by the embodiments of the present invention include: a P2P proxy server installed on the terminal where the application program to be read logs is located, for The path where the program is located and the service ID corresponding to the application program generate a service number corresponding to the application program one by one, and register the service number to the P2P server; the P2P server is installed on a server with a public network IP, Used to maintain and manage the service number information of the P2P proxy server; the P2P proxy client is installed on the developer's device, and is used to receive the user's log reading request and send it to the P2P server; the P2P server also It is used to obtain the corresponding service number according to the log reading request, and make the P2P proxy server corresponding to the service number establish a P2P connection with the P2P proxy client; if the P2P connection is established successfully, the P2P proxy server reads Get the log information of the application program and send it to the P2P proxy client for reading; if the P2P connection fails to be established, the P2P proxy server reads the log information of the application program and relays it through the P2P server Send to the P2P proxy client to read; establish a P2P connection with the P2P proxy client through the P2P proxy server to transmit the log information of the application program, and when it is detected that the P2P connection cannot be established, the P2P The proxy server reads the log information of the application program, and forwards it to the P2P proxy client through the P2P server, so that the P2P proxy client can read the log information of the application program; thus making the terminal and the developer The device can be connected to the Internet in any way, and developers can remotely read the log information on the terminal in real time, thus realizing the remote real-time reading of the log information on the terminal, which brings great convenience.
应当理解的是,本发明的应用不限于上述的举例,对本领域普通技术人员来说,可以根据上述说明加以改进或变换,所有这些改进和变换都应属于本发明所附权利要求的保护范围。 It should be understood that the application of the present invention is not limited to the above examples, and those skilled in the art can make improvements or transformations according to the above descriptions, and all these improvements and transformations should belong to the protection scope of the appended claims of the present invention.
Claims (8)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410190073.1A CN103973785B (en) | 2014-05-07 | 2014-05-07 | A kind of log read system and method based on P2P |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410190073.1A CN103973785B (en) | 2014-05-07 | 2014-05-07 | A kind of log read system and method based on P2P |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103973785A true CN103973785A (en) | 2014-08-06 |
CN103973785B CN103973785B (en) | 2018-06-19 |
Family
ID=51242818
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410190073.1A Expired - Fee Related CN103973785B (en) | 2014-05-07 | 2014-05-07 | A kind of log read system and method based on P2P |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103973785B (en) |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106506581A (en) * | 2015-09-03 | 2017-03-15 | Ls 产电株式会社 | Power system and the method for carrying out transmission data using power system |
CN107330063A (en) * | 2017-06-29 | 2017-11-07 | 环球智达科技(北京)有限公司 | The method exported for daily record |
CN107453889A (en) * | 2016-05-31 | 2017-12-08 | 腾讯科技(深圳)有限公司 | The method for uploading and device of a kind of journal file |
CN108418903A (en) * | 2018-05-28 | 2018-08-17 | 苏州德姆斯信息技术有限公司 | Embedded software daily record remote access system and access method |
CN110196793A (en) * | 2019-04-30 | 2019-09-03 | 武汉达梦数据库有限公司 | For the log analysis method and equipment in plug-in's data library |
CN115348316A (en) * | 2022-07-01 | 2022-11-15 | 江苏翌旭网络科技有限公司 | Method for communication between server and client |
CN116743738A (en) * | 2023-07-20 | 2023-09-12 | 北京道迩科技有限公司 | Log transmission method and device and electronic equipment |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20090249131A1 (en) * | 2008-03-28 | 2009-10-01 | Fujitsu Limited | Communication detection device, communication detection method, and communication detection program |
CN102594598A (en) * | 2012-02-16 | 2012-07-18 | 浪潮(北京)电子信息产业有限公司 | Log management system and implementation method thereof |
CN102724063A (en) * | 2012-05-11 | 2012-10-10 | 北京邮电大学 | Log collection server, data packet delivering and log clustering methods and network |
-
2014
- 2014-05-07 CN CN201410190073.1A patent/CN103973785B/en not_active Expired - Fee Related
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20090249131A1 (en) * | 2008-03-28 | 2009-10-01 | Fujitsu Limited | Communication detection device, communication detection method, and communication detection program |
CN102594598A (en) * | 2012-02-16 | 2012-07-18 | 浪潮(北京)电子信息产业有限公司 | Log management system and implementation method thereof |
CN102724063A (en) * | 2012-05-11 | 2012-10-10 | 北京邮电大学 | Log collection server, data packet delivering and log clustering methods and network |
Cited By (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106506581A (en) * | 2015-09-03 | 2017-03-15 | Ls 产电株式会社 | Power system and the method for carrying out transmission data using power system |
US10382546B2 (en) | 2015-09-03 | 2019-08-13 | Lsis Co., Ltd. | Power system and method for transferring data using the same |
CN106506581B (en) * | 2015-09-03 | 2019-12-20 | Ls 产电株式会社 | Power system and method for transmitting data using the same |
CN107453889A (en) * | 2016-05-31 | 2017-12-08 | 腾讯科技(深圳)有限公司 | The method for uploading and device of a kind of journal file |
CN107453889B (en) * | 2016-05-31 | 2019-06-07 | 腾讯科技(深圳)有限公司 | A kind of method for uploading and device of journal file |
CN107330063A (en) * | 2017-06-29 | 2017-11-07 | 环球智达科技(北京)有限公司 | The method exported for daily record |
CN108418903A (en) * | 2018-05-28 | 2018-08-17 | 苏州德姆斯信息技术有限公司 | Embedded software daily record remote access system and access method |
CN108418903B (en) * | 2018-05-28 | 2024-02-02 | 苏州德姆斯信息技术有限公司 | Remote access system and access method for embedded software log |
CN110196793A (en) * | 2019-04-30 | 2019-09-03 | 武汉达梦数据库有限公司 | For the log analysis method and equipment in plug-in's data library |
CN115348316A (en) * | 2022-07-01 | 2022-11-15 | 江苏翌旭网络科技有限公司 | Method for communication between server and client |
CN116743738A (en) * | 2023-07-20 | 2023-09-12 | 北京道迩科技有限公司 | Log transmission method and device and electronic equipment |
CN116743738B (en) * | 2023-07-20 | 2024-04-05 | 北京道迩科技有限公司 | Log transmission method and device and electronic equipment |
Also Published As
Publication number | Publication date |
---|---|
CN103973785B (en) | 2018-06-19 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103973785B (en) | A kind of log read system and method based on P2P | |
US9923978B2 (en) | Automated network service discovery and communication | |
WO2020057163A1 (en) | Mec platform deployment method and device | |
US20200412708A1 (en) | Link protocol agents for inter-application communications | |
CN106790420B (en) | A kind of more session channel method for building up and system | |
CN104506802B (en) | The method of video monitoring system, passing through NAT monitor video data | |
CN114124929B (en) | Cross-network data processing methods and devices | |
WO2016041322A1 (en) | Method of forwarding in-application traffic on smart mobile terminal | |
CN111831513B (en) | Log query method, device, electronic equipment and storage medium | |
CN104378410A (en) | A micro-private cloud storage and transmission system and method | |
KR20120071576A (en) | Method, device and system for real-time publish subscribe discovery based on distributed hash table | |
WO2019076282A1 (en) | Method and device for managing user | |
CN104010001A (en) | Method and system for connecting and communicating with the same kind of networking request in a mobile terminal | |
CN105553809A (en) | STUN tunnel management method and device | |
CN108989424A (en) | A kind of method and system remotely controlled | |
WO2009093308A1 (en) | Connection control method, connection control server device, connection control client device, and program | |
CN108833469A (en) | A terminal-to-terminal resource transmission method, device and terminal equipment | |
WO2023148124A1 (en) | Session management for redundant pdu sessions | |
CN101146130A (en) | A method and system for transmitting data between clients | |
CN111092958B (en) | A node access method, device, system and storage medium | |
US20240129291A1 (en) | Cross-Domain Secure Connect Transmission Method | |
CN110430478B (en) | Networking communication method, device, terminal equipment and storage medium | |
KR100597405B1 (en) | Data relay system and data relay method using socket application program | |
CN118041899A (en) | Remote control method, system and medium of terminal | |
CN111314477A (en) | P2P communication method, system, home gateway, electronic device and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20180619 |
|
CF01 | Termination of patent right due to non-payment of annual fee |