Files
Akilan-website/public/technicalposts/p2prc-escaping-nat/index.html
2025-04-05 11:20:00 +01:00

77 lines
17 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html><html lang=en dir=auto><head><script src="/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=livereload" data-no-instant defer></script><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name=robots content="index, follow"><title>Draft for escaping NAT with reverse proxy P2PRC | Akilan</title>
<meta name=keywords content="P2PRC,NAT"><meta name=description content="Annoying NAT boo boo"><meta name=author content="Akilan Selvacoumar"><link rel=canonical href=http://localhost:1313/technicalposts/p2prc-escaping-nat/><link crossorigin=anonymous href=/assets/css/stylesheet.f49d66caae9ea0fd43f21f29e71a8d3e284517ed770f2aa86fa012953ad3c9ef.css integrity="sha256-9J1myq6eoP1D8h8p5xqNPihFF+13Dyqob6ASlTrTye8=" rel="preload stylesheet" as=style><link rel=icon href=http://localhost:1313/favicon.ico><link rel=icon type=image/png sizes=16x16 href=http://localhost:1313/favicon-16x16.png><link rel=icon type=image/png sizes=32x32 href=http://localhost:1313/favicon-32x32.png><link rel=apple-touch-icon href=http://localhost:1313/apple-touch-icon.png><link rel=mask-icon href=http://localhost:1313/safari-pinned-tab.svg><meta name=theme-color content="#2e2e33"><meta name=msapplication-TileColor content="#2e2e33"><link rel=alternate hreflang=en href=http://localhost:1313/technicalposts/p2prc-escaping-nat/><noscript><style>#theme-toggle,.top-link{display:none}</style><style>@media(prefers-color-scheme:dark){:root{--theme:rgb(29, 30, 32);--entry:rgb(46, 46, 51);--primary:rgb(218, 218, 219);--secondary:rgb(155, 156, 157);--tertiary:rgb(65, 66, 68);--content:rgb(196, 196, 197);--code-block-bg:rgb(46, 46, 51);--code-bg:rgb(55, 56, 62);--border:rgb(51, 51, 51)}.list{background:var(--theme)}.list:not(.dark)::-webkit-scrollbar-track{background:0 0}.list:not(.dark)::-webkit-scrollbar-thumb{border-color:var(--theme)}}</style></noscript><meta property="og:url" content="http://localhost:1313/technicalposts/p2prc-escaping-nat/"><meta property="og:site_name" content="Akilan"><meta property="og:title" content="Draft for escaping NAT with reverse proxy P2PRC"><meta property="og:description" content="Annoying NAT boo boo"><meta property="og:locale" content="en"><meta property="og:type" content="article"><meta property="article:section" content="technicalposts"><meta property="article:published_time" content="2021-10-11T00:00:00+00:00"><meta property="article:modified_time" content="2021-10-11T00:00:00+00:00"><meta property="article:tag" content="P2PRC"><meta property="article:tag" content="NAT"><meta name=twitter:card content="summary"><meta name=twitter:title content="Draft for escaping NAT with reverse proxy P2PRC"><meta name=twitter:description content="Annoying NAT boo boo"><script type=application/ld+json>{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Technical Posts","item":"http://localhost:1313/technicalposts/"},{"@type":"ListItem","position":2,"name":"Draft for escaping NAT with reverse proxy P2PRC","item":"http://localhost:1313/technicalposts/p2prc-escaping-nat/"}]}</script><script type=application/ld+json>{"@context":"https://schema.org","@type":"BlogPosting","headline":"Draft for escaping NAT with reverse proxy P2PRC","name":"Draft for escaping NAT with reverse proxy P2PRC","description":"Annoying NAT boo boo","keywords":["P2PRC","NAT"],"articleBody":"Abstract We focus here on escaping NAT for the project P2PRC. The intial plan is to use a middle server with an IPV4 address to escape NAT. The future plan would be to use a WebRTC approach to where we use a middle server to intansiate a direct p2p connection using UDP sockets with nodes behind NAT.\nArchitecture plan The server behind NAT would use a reverse proxy server with an IPV4 address to be a possible way to communicate with the outside world.\nEx:\nNAT | Server \u003c--\u003e Reverse Proxy server with \u003c--\u003e Clients | public IPV4 We use the libaray known as frp. “frp is A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.”\nThe server behind the NAT IPTable would be broadcasted through the reverse proxy. The mapping would be done automatically though P2PRC because the reverse proxy could have certain ports already taken.\nWe are introducting a new concept of detecting reverse proxies over P2PRC. We call this reverse_proxy_server.json and reverse_proxy_mapping.json. The reverse_proxy_server.json file is incharge of detecting all reverse proxy servers and the reverse_proxy_mapping.json is incharge of logging all the reverse proxy server mappings talking place.\nreverse_proxy_server.json { \"reverse_proxy_servers\": [ { \"Server_name\": , \"Address\": , \"Latency\": }, ... n ] } reverse_proxy_mapping.json { \"reverse_proxy_mappings\": [ { \"Server_name\": , \"Address\": , \"Type\": , \"blind_port\": }, ... n ] } Port allocation The function for port allocation would need certain modifications need to ensure that the port is not only free on the server but also on the on reverse proxy server. We are debate on this would occur as it requires further reading on the inner depths of frp. The idea scenario would be that the odds a 5 or 6 digit taken is a low probability.\nHow would the ip tables would look There would not be much change when a client looks at it. This only difference is that the client sees the address of the proxy server.\nEx:\n{ \"ip_address\": [ { \"ipv4\": \"\", \"ipv6\": \"\", \"latency\": 0, \"download\": 0, \"upload\": 0, \"serverport\": \"\" } ] } If the server is using a reverse proxy then the server port no should be decided by P2PRC to ensure that there is no scenario where the port is already taken.\nNew Cli Commands We will be introducing a new set of Cli commands. These cli commands would be incharge to starting the reverse proxy or connecting to the reverse proxy and various other function.\nstart reverse proxy (need public IPV4) p2prc -s --reverse-proxy This will start the reverse and autoamtically broadcast as a reverse proxy as well.\nconnecting to a reverse proxy p2prc -s --connect-reverse-proxy This will start p2prc as server and automatically set the server port and link it to the reverse proxy and any connections would go through the reverse proxy.\nListing all proxy servers avaliable p2prc --view-rps or p2prc --view-reverse-proxy-servers Listing all reverse proxy connection mapping p2prc --view-rpm or p2prc --view-reverse-proxy-mapping ","wordCount":"515","inLanguage":"en","datePublished":"2021-10-11T00:00:00Z","dateModified":"2021-10-11T00:00:00Z","author":{"@type":"Person","name":"Akilan Selvacoumar"},"mainEntityOfPage":{"@type":"WebPage","@id":"http://localhost:1313/technicalposts/p2prc-escaping-nat/"},"publisher":{"@type":"Organization","name":"Akilan","logo":{"@type":"ImageObject","url":"http://localhost:1313/favicon.ico"}}}</script></head><body id=top><script>localStorage.getItem("pref-theme")==="dark"?document.body.classList.add("dark"):localStorage.getItem("pref-theme")==="light"?document.body.classList.remove("dark"):window.matchMedia("(prefers-color-scheme: dark)").matches&&document.body.classList.add("dark")</script><header class=header><nav class=nav><div class=logo><a href=http://localhost:1313/ accesskey=h title="Akilan (Alt + H)">Akilan</a><div class=logo-switches><button id=theme-toggle accesskey=t title="(Alt + T)" aria-label="Toggle theme"><svg id="moon" width="24" height="18" viewBox="0 0 24 24" fill="none" stroke="currentcolor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg><svg id="sun" width="24" height="18" viewBox="0 0 24 24" fill="none" stroke="currentcolor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg></button></div></div><ul id=menu><li><a href=http://localhost:1313/about/ title=About><span>About</span></a></li><li><a href=http://localhost:1313/resume/ title=Resumé><span>Resumé</span></a></li><li><a href=http://localhost:1313/projects/ title=Projects><span>Projects</span></a></li><li><a href=http://localhost:1313/technicalposts/ title="Technical Posts"><span>Technical Posts</span></a></li><li><a href=http://localhost:1313/generalposts/ title="General Posts"><span>General Posts</span></a></li><li><a href=http://localhost:1313/papers/ title=Papers><span>Papers</span></a></li><li><a href=http://localhost:1313/chat/ title=Chat><span>Chat</span></a></li><li><a href=http://localhost:1313/hiking/ title=Hiking><span>Hiking</span></a></li></ul></nav></header><main class=main><article class=post-single><header class=post-header><div class=breadcrumbs><a href=http://localhost:1313/>Home</a>&nbsp;»&nbsp;<a href=http://localhost:1313/technicalposts/>Technical Posts</a></div><h1 class="post-title entry-hint-parent">Draft for escaping NAT with reverse proxy P2PRC</h1><div class=post-meta><span title='2021-10-11 00:00:00 +0000 UTC'>2021-11-10</span>&nbsp;·&nbsp;3 min&nbsp;·&nbsp;Akilan Selvacoumar&nbsp;|&nbsp;<a href=https://github.com/Akilan1999/Akilan-website/tree/master/content/technicalposts/P2PRC-Escaping-NAT.md rel="noopener noreferrer" target=_blank>Suggest Changes</a></div></header><div class=toc><details><summary accesskey=c title="(Alt + C)"><span class=details>Table of Contents</span></summary><div class=inner><ul><li><a href=#abstract aria-label=Abstract>Abstract</a></li><li><a href=#architecture-plan aria-label="Architecture plan">Architecture plan</a><ul><ul><li><a href=#reverse_proxy_serverjson aria-label=reverse_proxy_server.json>reverse_proxy_server.json</a></li><li><a href=#reverse_proxy_mappingjson aria-label=reverse_proxy_mapping.json>reverse_proxy_mapping.json</a></li></ul><li><a href=#port-allocation aria-label="Port allocation">Port allocation</a></li><li><a href=#how-would-the-ip-tables-would-look aria-label="How would the ip tables would look">How would the ip tables would look</a></li></ul></li><li><a href=#new-cli-commands aria-label="New Cli Commands">New Cli Commands</a></li></ul></div></details></div><div class=post-content><h2 id=abstract>Abstract<a hidden class=anchor aria-hidden=true href=#abstract>#</a></h2><p>We focus here on escaping NAT for the project P2PRC. The intial
plan is to use a middle server with an IPV4 address to escape NAT.
The future plan would be to use a WebRTC approach to where we
use a middle server to intansiate a direct p2p connection
using UDP sockets with nodes behind NAT.</p><h2 id=architecture-plan>Architecture plan<a hidden class=anchor aria-hidden=true href=#architecture-plan>#</a></h2><p>The server behind NAT would use a reverse proxy server with an IPV4 address
to be a possible way to communicate with the outside world.</p><p>Ex:</p><pre tabindex=0><code> NAT
|
Server &lt;--&gt; Reverse Proxy server with &lt;--&gt; Clients
| public IPV4
</code></pre><p>We use the libaray known as <a href=https://github.com/fatedier/frp>frp</a>.
&ldquo;frp is A fast reverse proxy to help you expose a local server behind a NAT
or firewall to the internet.&rdquo;</p><p>The server behind the NAT IPTable would be broadcasted through the reverse proxy.
The mapping would be done automatically though P2PRC because the reverse proxy
could have certain ports already taken.</p><p>We are introducting a new concept of detecting reverse proxies over P2PRC.
We call this <code>reverse_proxy_server.json</code> and <code>reverse_proxy_mapping.json</code>.
The <code>reverse_proxy_server.json</code> file is incharge of detecting all reverse
proxy servers and the <code>reverse_proxy_mapping.json</code> is incharge of logging
all the reverse proxy server mappings talking place.</p><h4 id=reverse_proxy_serverjson>reverse_proxy_server.json<a hidden class=anchor aria-hidden=true href=#reverse_proxy_serverjson>#</a></h4><pre tabindex=0><code>{
&#34;reverse_proxy_servers&#34;: [
{
&#34;Server_name&#34;: &lt;server name&gt;,
&#34;Address&#34;: &lt;remote address&gt;,
&#34;Latency&#34;: &lt;latency&gt;
}, ... n
]
}
</code></pre><h4 id=reverse_proxy_mappingjson>reverse_proxy_mapping.json<a hidden class=anchor aria-hidden=true href=#reverse_proxy_mappingjson>#</a></h4><pre tabindex=0><code>{
&#34;reverse_proxy_mappings&#34;: [
{
&#34;Server_name&#34;: &lt;server name&gt;,
&#34;Address&#34;: &lt;remote address&gt;,
&#34;Type&#34;: &lt;TCP or UDP&gt;,
&#34;blind_port&#34;: &lt;port no&gt;
}, ... n
]
}
</code></pre><h3 id=port-allocation>Port allocation<a hidden class=anchor aria-hidden=true href=#port-allocation>#</a></h3><p>The function for port allocation would need certain
modifications need to ensure that the port is not only free
on the server but also on the on reverse proxy server.
We are debate on this would occur as it requires
further reading on the inner depths of <a href=https://github.com/fatedier/frp>frp</a>.
The idea scenario would be that the odds a 5 or 6 digit
taken is a low probability.</p><h3 id=how-would-the-ip-tables-would-look>How would the ip tables would look<a hidden class=anchor aria-hidden=true href=#how-would-the-ip-tables-would-look>#</a></h3><p>There would not be much change when a client looks
at it. This only difference is that the client
see&rsquo;s the address of the proxy server.</p><p>Ex:</p><pre tabindex=0><code>{
&#34;ip_address&#34;: [
{
&#34;ipv4&#34;: &#34;&lt;reverse proxy address&gt;&#34;,
&#34;ipv6&#34;: &#34;&#34;,
&#34;latency&#34;: 0,
&#34;download&#34;: 0,
&#34;upload&#34;: 0,
&#34;serverport&#34;: &#34;&lt;server port no&gt;&#34;
}
]
}
</code></pre><p>If the server is using a reverse proxy then the server
port no should be decided by P2PRC to ensure that there
is no scenario where the port is already taken.</p><h2 id=new-cli-commands>New Cli Commands<a hidden class=anchor aria-hidden=true href=#new-cli-commands>#</a></h2><p>We will be introducing a new set of Cli commands.
These cli commands would be incharge to starting
the reverse proxy or connecting to the reverse proxy
and various other function.</p><ol><li>start reverse proxy (need public IPV4)</li></ol><pre tabindex=0><code>p2prc -s --reverse-proxy
</code></pre><p>This will start the reverse
and autoamtically broadcast
as a reverse proxy as well.</p><ol start=2><li>connecting to a reverse proxy</li></ol><pre tabindex=0><code>p2prc -s --connect-reverse-proxy &lt;proxy ip address&gt;
</code></pre><p>This will start p2prc as server
and automatically set the server port
and link it to the reverse proxy and
any connections would go through the
reverse proxy.</p><ol start=3><li>Listing all proxy servers avaliable</li></ol><pre tabindex=0><code>p2prc --view-rps or p2prc --view-reverse-proxy-servers
</code></pre><ol start=4><li>Listing all reverse proxy connection mapping</li></ol><pre tabindex=0><code>p2prc --view-rpm or p2prc --view-reverse-proxy-mapping
</code></pre></div><footer class=post-footer><ul class=post-tags><li><a href=http://localhost:1313/tags/p2prc/>P2PRC</a></li><li><a href=http://localhost:1313/tags/nat/>NAT</a></li></ul><nav class=paginav><a class=next href=http://localhost:1313/technicalposts/p2prc-automatic-ports/><span class=title>Next »</span><br><span>Automatic ports allocation P2PRC</span></a></nav></footer></article></main><footer class=footer><span>&copy; 2025 <a href=http://localhost:1313/>Akilan</a></span> ·
<span>Powered by
<a href=https://gohugo.io/ rel="noopener noreferrer" target=_blank>Hugo</a> &
<a href=https://github.com/adityatelange/hugo-PaperMod/ rel=noopener target=_blank>PaperMod</a></span></footer><a href=#top aria-label="go to top" title="Go to Top (Alt + G)" class=top-link id=top-link accesskey=g><svg viewBox="0 0 12 6" fill="currentcolor"><path d="M12 6H0l6-6z"/></svg>
</a><script>let menu=document.getElementById("menu");menu&&(menu.scrollLeft=localStorage.getItem("menu-scroll-position"),menu.onscroll=function(){localStorage.setItem("menu-scroll-position",menu.scrollLeft)}),document.querySelectorAll('a[href^="#"]').forEach(e=>{e.addEventListener("click",function(e){e.preventDefault();var t=this.getAttribute("href").substr(1);window.matchMedia("(prefers-reduced-motion: reduce)").matches?document.querySelector(`[id='${decodeURIComponent(t)}']`).scrollIntoView():document.querySelector(`[id='${decodeURIComponent(t)}']`).scrollIntoView({behavior:"smooth"}),t==="top"?history.replaceState(null,null," "):history.pushState(null,null,`#${t}`)})})</script><script>var mybutton=document.getElementById("top-link");window.onscroll=function(){document.body.scrollTop>800||document.documentElement.scrollTop>800?(mybutton.style.visibility="visible",mybutton.style.opacity="1"):(mybutton.style.visibility="hidden",mybutton.style.opacity="0")}</script><script>document.getElementById("theme-toggle").addEventListener("click",()=>{document.body.className.includes("dark")?(document.body.classList.remove("dark"),localStorage.setItem("pref-theme","light")):(document.body.classList.add("dark"),localStorage.setItem("pref-theme","dark"))})</script></body></html>