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

33 lines
14 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>Automatic ports allocation P2PRC | Akilan</title>
<meta name=keywords content="P2PRC,Ports,TCP,Automatic"><meta name=description content="Allocating ports to plugins P2PRC"><meta name=author content="Akilan Selvacoumar"><link rel=canonical href=http://localhost:1313/technicalposts/p2prc-automatic-ports/><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-automatic-ports/><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-automatic-ports/"><meta property="og:site_name" content="Akilan"><meta property="og:title" content="Automatic ports allocation P2PRC"><meta property="og:description" content="Allocating ports to plugins P2PRC"><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-03T00:00:00+00:00"><meta property="article:modified_time" content="2021-10-03T00:00:00+00:00"><meta property="article:tag" content="P2PRC"><meta property="article:tag" content="Ports"><meta property="article:tag" content="TCP"><meta property="article:tag" content="Automatic"><meta name=twitter:card content="summary"><meta name=twitter:title content="Automatic ports allocation P2PRC"><meta name=twitter:description content="Allocating ports to plugins P2PRC"><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":"Automatic ports allocation P2PRC","item":"http://localhost:1313/technicalposts/p2prc-automatic-ports/"}]}</script><script type=application/ld+json>{"@context":"https://schema.org","@type":"BlogPosting","headline":"Automatic ports allocation P2PRC","name":"Automatic ports allocation P2PRC","description":"Allocating ports to plugins P2PRC","keywords":["P2PRC","Ports","TCP","Automatic"],"articleBody":"Automatic port allocations P2PRC would be in-charge to set to the ports to various TCP ports opened. Due to this implementation the plugin being executed is copied to the tmp directory with a unique UUID.\nCommand: ls /tmp output: Semantic _ 2e6d76c4-0ed1-4b55-9385-79a58d4f0492_p2prc-vscode-browser 7b631e08-62ee-4c1c-a2a4-c05857b9aa7d_p2prc-vscode-browser Once the copy of the plugin is added to the /tmp directory the site.yml file inside the appropriate yaml is modified with the appropriate ports assigned to the container.\nEx: Create container called c1 with an automatic generated TCP port 3313 (external) - 3313 (internal) Assumption of plugin p1 exists. p1 has one server which needs to be mapped to a free open TCP port in container c1. Below shows an implementation of a sample site.yml file. --- - hosts: all tasks: - name: start vscode code server shell: sh server.sh 0.0.0.0:{{index . 0}} Notice there is the following {{index . 0}}. {{index . 0}} does not belong to Ansible but rather is a way to mention where to add the external free port of the container. We use the golang template library to parse and populate the site.yml with the appropriate open ports. An array of ints which consists of open free ports are sent to the site.yml. 0 in {{index . 0}} refers to the index in the int array passed on.\nAfter the port is automatically its ready to run !\n--- - hosts: all tasks: - name: start vscode code server shell: sh server.sh 0.0.0.0:3313 Sample plugins implemented: VSCode Plugin based on PR: https://github.com/Akilan1999/p2p-rendering-computation/pull/73 ","wordCount":"252","inLanguage":"en","datePublished":"2021-10-03T00:00:00Z","dateModified":"2021-10-03T00:00:00Z","author":{"@type":"Person","name":"Akilan Selvacoumar"},"mainEntityOfPage":{"@type":"WebPage","@id":"http://localhost:1313/technicalposts/p2prc-automatic-ports/"},"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">Automatic ports allocation P2PRC</h1><div class=post-meta><span title='2021-10-03 00:00:00 +0000 UTC'>2021-03-10</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;Akilan Selvacoumar&nbsp;|&nbsp;<a href=https://github.com/Akilan1999/Akilan-website/tree/master/content/technicalposts/P2PRC-automatic-ports.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=#automatic-port-allocations aria-label="Automatic port allocations">Automatic port allocations</a><ul><li><a href=#ex aria-label=Ex:>Ex:</a></li><li><a href=#sample-plugins-implemented aria-label="Sample plugins implemented:">Sample plugins implemented:</a></li></ul></li><li><a href=#based-on-pr aria-label="based on PR: https://github.com/Akilan1999/p2p-rendering-computation/pull/73">based on PR: https://github.com/Akilan1999/p2p-rendering-computation/pull/73</a></li></ul></div></details></div><div class=post-content><h2 id=automatic-port-allocations>Automatic port allocations<a hidden class=anchor aria-hidden=true href=#automatic-port-allocations>#</a></h2><p>P2PRC would be in-charge to set to the ports to various TCP ports
opened. Due to this implementation the plugin being executed is
copied to the tmp directory with a unique UUID.</p><pre tabindex=0><code>Command: ls /tmp
output: Semantic &lt;UUID&gt;_&lt;Plugin Name&gt;
2e6d76c4-0ed1-4b55-9385-79a58d4f0492_p2prc-vscode-browser
7b631e08-62ee-4c1c-a2a4-c05857b9aa7d_p2prc-vscode-browser
</code></pre><p>Once the copy of the plugin is added to the /tmp directory
the site.yml file inside the appropriate yaml is modified
with the appropriate ports assigned to the container.</p><h3 id=ex>Ex:<a hidden class=anchor aria-hidden=true href=#ex>#</a></h3><ol><li>Create container called c1 with an automatic generated TCP port
3313 (external) - 3313 (internal)</li><li>Assumption of plugin p1 exists. p1 has one server which needs to
be mapped to a free open TCP port in container c1. Below shows
an implementation of a sample site.yml file.</li></ol><pre tabindex=0><code>---
- hosts: all
tasks:
- name: start vscode code server
shell: sh server.sh 0.0.0.0:{{index . 0}}
</code></pre><p>Notice there is the following {{index . 0}}. {{index . 0}} does not belong to
Ansible but rather is a way to mention where to add the external free port
of the container. We use the golang <a href=https://pkg.go.dev/text/template>template library</a>
to parse and populate the site.yml with the appropriate open ports. An array of ints
which consists of open free ports are sent to the site.yml. 0 in {{index . 0}} refers
to the index in the int array passed on.</p><p>After the port is automatically it&rsquo;s ready to run !</p><pre tabindex=0><code>---
- hosts: all
tasks:
- name: start vscode code server
shell: sh server.sh 0.0.0.0:3313
</code></pre><h3 id=sample-plugins-implemented>Sample plugins implemented:<a hidden class=anchor aria-hidden=true href=#sample-plugins-implemented>#</a></h3><ul><li><a href=https://github.com/Akilan1999/p2prc-vscode-browser>VSCode Plugin</a></li></ul><h2 id=based-on-pr>based on PR: <a href=https://github.com/Akilan1999/p2p-rendering-computation/pull/73>https://github.com/Akilan1999/p2p-rendering-computation/pull/73</a><a hidden class=anchor aria-hidden=true href=#based-on-pr>#</a></h2></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/ports/>Ports</a></li><li><a href=http://localhost:1313/tags/tcp/>TCP</a></li><li><a href=http://localhost:1313/tags/automatic/>Automatic</a></li></ul><nav class=paginav><a class=prev href=http://localhost:1313/technicalposts/p2prc-escaping-nat/><span class=title>« Prev</span><br><span>Draft for escaping NAT with reverse proxy P2PRC</span>
</a><a class=next href=http://localhost:1313/technicalposts/p2prc-ast/><span class=title>Next »</span><br><span>Extension of P2PRC to create your own modification</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>