# Neither Denied nor Exposed: Fixing WebRTC Privacy Leaks
## 6 Implementation
### Gateway Implementation  
The gateway can either be a SOCKS [24] or a HTTP proxy, and while a plethora of programming languages can be used to develop such a software, there is no actual limitation about the implementation details. However, the main question that needs to be answered is what the delay is that this process adds to the webpage loading process. With that in mind, a high-performance programming language should be used, making the code-examining process a really quick task. For the sake of this work, we developed two different versions of an HTTP proxy: one written in C++ and one in Golang, two of the most high-performance server programming languages. Using the aforementioned implementations, we measured the time penalty produced by different webpages of various sizes (data volume) and characteristics. To dereference the induced time penalty from any network latency, the gateway runs in the same machine where the user is located.  
No less important, the gateway is able to examine the content of any webpage using either HTTP or HTTPS. Precisely, for HTTPS traffic, the gateway works as a transparent proxy, which acts as a man-in-the-middle (MITM) at the TLS tunnel, and thus is able to read the traffic even if the content is encrypted with TLS. Typically, a client would connect to a proxy by executing a CONNECT request, for instance \"CONNECT example.com:443 HTTP/1.1\", and open a P2P connection between the client and the destination web server.  
Using a modern programming language, the parsing of an average webpage's source code will be completed in a few milliseconds. Table 1 presents a comparison of Golang and C++ when it comes to processing text files of diverse sizes and characteristics. As observed, the results pertaining to both languages are almost identical, and even on much larger file sizes than the average webpage size which is \(\approx\)3 MB [25]. In addition, searching of certain keywords can be achieved in less than a second even in files of 100 MB that is \(\approx\)534 ms and \(\approx\)513 ms on average for C++ and Golang correspondingly. We should also mention that on each search the whole text file was examined, to reach the conclusion that the document is safe. However, if a malicious JavaScript was included in a document, the result would be obtained before reaching the end of the file, and thus the delay is expected to be even less. It is to be noted that the results reported in Table 1 have been acquired after conducting 500 searches per different text file size and computing the mean value. As observed in Table 1, the average value is almost half a second for files even thirty times as big as the size of the average webpage. This leads us to conclude that most of the delay of this gateway-based approach is expected to be mainly due to the bandwidth of the gateway and the network speed rather than the actual examination of the webpage's source code.  
\begin{table}
\begin{tabular}{c c c} \hline \multirow{2}{*}{**Filesize (MB)**} & \multicolumn{2}{c}{**Delay (ms)**} \\ \cline{2-3}  & **Golang** & **C++** \\ \hline
0.5 & 3 & 3 \\
1 & 6 & 6 \\
5 & 28 & 28 \\
10 & 56 & 58 \\
50 & 283 & 269 \\
100 & 513 & 534 \\ \hline \end{tabular}
\end{table}
Table 1: Performance comparison of C++ and Golang in file processing.