Adjust app introduce port changinf logic and process file processing fuctnions + adjust drawio file diagramm

This commit is contained in:
Hepatica
2024-08-17 00:09:51 +02:00
parent 9215ad7a8f
commit 2356358163
8 changed files with 267 additions and 350 deletions

View File

@@ -1,181 +0,0 @@
<mxfile host="Electron" modified="2024-08-16T13:54:29.826Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/23.0.2 Chrome/120.0.6099.109 Electron/28.1.0 Safari/537.36" etag="ZUBuPSrFh_YRAVZYSngJ" version="23.0.2" type="device">
<diagram name="Page-1" id="Amrm0kvx0odSU5wdFRfC">
<mxGraphModel dx="527" dy="345" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="masuSCkF3HdqrZElRDKO-8" value="SpСloud&lt;br&gt;функциональность" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="310" y="90" width="160" height="30" as="geometry" />
</mxCell>
<mxCell id="masuSCkF3HdqrZElRDKO-9" value="Паблишь приложения функциональность&amp;nbsp;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="565" y="150" width="160" height="30" as="geometry" />
</mxCell>
<mxCell id="masuSCkF3HdqrZElRDKO-11" value="q1" style="ellipse;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="390" y="320" width="120" height="80" as="geometry" />
</mxCell>
<mxCell id="masuSCkF3HdqrZElRDKO-12" value="&amp;nbsp;Юзер посылает rar архив с своим приложением и его таргетом&amp;nbsp;&lt;br&gt;и прикрепляет auth токен в header" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="375" y="390" width="150" height="100" as="geometry" />
</mxCell>
<mxCell id="masuSCkF3HdqrZElRDKO-14" value="" style="endArrow=classic;html=1;rounded=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="1" target="masuSCkF3HdqrZElRDKO-15" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="500" y="360" as="sourcePoint" />
<mxPoint x="650" y="360" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="masuSCkF3HdqrZElRDKO-15" value="q2" style="ellipse;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="770" y="320" width="120" height="80" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-3" value="Юзер&amp;nbsp;" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" parent="1" vertex="1">
<mxGeometry x="80" y="180" width="30" height="60" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-4" value="Лимит" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=30;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="140" y="150" width="190" height="150" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-5" value="Лимит 6 приложений" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-4" vertex="1">
<mxGeometry y="30" width="190" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-6" value="Обязательно роль Team" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-4" vertex="1">
<mxGeometry y="60" width="190" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-7" value="Регистрация через дискорд" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-4" vertex="1">
<mxGeometry y="90" width="190" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-16" value="Пользователь может быть забанен" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-4" vertex="1">
<mxGeometry y="120" width="190" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-8" value="Лимиты" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=30;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="550" y="190" width="190" height="120" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-9" value="Dotnet 6 7 8&amp;nbsp; (Console + ASP)" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-8" vertex="1">
<mxGeometry y="30" width="190" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-10" value="Запустить свою монго дб на 100 мб (возможно добавлю)" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-8" vertex="1">
<mxGeometry y="60" width="190" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-11" value="Nuxt js (возможно добавлю)" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-8" vertex="1">
<mxGeometry y="90" width="190" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-12" value="&lt;div style=&quot;color: rgb(248, 248, 242); background-color: rgb(33, 33, 33); font-family: IBMPlexMono, &amp;quot;Courier New&amp;quot;, monospace, Consolas, &amp;quot;Courier New&amp;quot;, monospace; line-height: 18px;&quot;&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &lt;span style=&quot;color: #9cdcfe;&quot;&gt;&quot;target&quot;&lt;/span&gt;&lt;span style=&quot;color: #dcdcdc;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #ce9178;&quot;&gt;&quot;dotnet-6-console&quot;,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&quot;appName&quot;&lt;span style=&quot;color: rgb(220, 220, 220);&quot;&gt;:&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: rgb(206, 145, 120);&quot;&gt;&quot;TestApp&quot;&lt;/span&gt;&lt;span style=&quot;color: #ce9178;&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #dcdcdc;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;" style="shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;" parent="1" vertex="1">
<mxGeometry x="328" y="510" width="222" height="140" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-14" value="&amp;nbsp;Юзер получает статус загрузки своего приложения и айпи (если приложение должно работать с интернетом)" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="755" y="400" width="150" height="100" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-15" value="&lt;div style=&quot;background-color: rgb(33, 33, 33); line-height: 18px;&quot;&gt;&lt;div style=&quot;color: rgb(248, 248, 242); font-family: IBMPlexMono, &amp;quot;Courier New&amp;quot;, monospace, Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;{&lt;/div&gt;&lt;div style=&quot;color: rgb(248, 248, 242); font-family: IBMPlexMono, &amp;quot;Courier New&amp;quot;, monospace, Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&quot;status&quot;&lt;span style=&quot;color: rgb(220, 220, 220);&quot;&gt;:&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: rgb(206, 145, 120);&quot;&gt;&quot;success&quot;,&lt;/span&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;&quot;&gt;&lt;font face=&quot;IBMPlexMono, Courier New, monospace, Consolas, Courier New, monospace&quot; color=&quot;#f8f8f2&quot;&gt;&amp;nbsp; &lt;/font&gt;&lt;span style=&quot;color: rgb(156, 220, 254); font-family: IBMPlexMono, &amp;quot;Courier New&amp;quot;, monospace, Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(220, 220, 220); font-family: IBMPlexMono, &amp;quot;Courier New&amp;quot;, monospace, Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;:&lt;/span&gt; &lt;font face=&quot;IBMPlexMono, Courier New, monospace, Consolas, Courier New, monospace&quot; color=&quot;#ce9178&quot;&gt;&quot;https://test.almavid.ru&quot;&lt;/font&gt;&lt;/div&gt;&lt;div style=&quot;color: rgb(248, 248, 242); font-family: IBMPlexMono, &amp;quot;Courier New&amp;quot;, monospace, Consolas, &amp;quot;Courier New&amp;quot;, monospace;&quot;&gt;}&lt;/div&gt;&lt;/div&gt;" style="shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;" parent="1" vertex="1">
<mxGeometry x="725" y="490" width="255" height="150" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-17" value="SpСloud UI" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="355" y="700" width="160" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-18" value="" style="html=1;whiteSpace=wrap;strokeColor=none;fillColor=#0079D6;labelPosition=center;verticalLabelPosition=middle;verticalAlign=top;align=center;fontSize=12;outlineConnect=0;spacingTop=-6;fontColor=#FFFFFF;sketch=0;shape=mxgraph.sitemap.page;" parent="1" vertex="1">
<mxGeometry x="120" y="750" width="630" height="950" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-21" value="Зарегистрироваться" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="610" y="760" width="130" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-22" value="Ник пользователя" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="645" y="800" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-23" value="&lt;font style=&quot;font-size: 14px;&quot;&gt;Нагрузка сервера в данный момент CPU/RAM/Memory&lt;/font&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="368.75" y="1190" width="145" height="50" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-24" value="" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="161.25" y="1250" width="560" height="200" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-26" value="" style="line;strokeWidth=1;rotatable=0;dashed=0;labelPosition=right;align=left;verticalAlign=middle;spacingTop=0;spacingLeft=6;points=[];portConstraint=eastwest;" parent="1" vertex="1">
<mxGeometry x="163.75" y="1290" width="555" height="10" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-28" value="" style="html=1;points=[[0,0,0,0,5],[0,1,0,0,-5],[1,0,0,0,5],[1,1,0,0,-5]];perimeter=orthogonalPerimeter;outlineConnect=0;targetShapes=umlLifeline;portConstraint=eastwest;newEdgeStyle={&quot;curved&quot;:0,&quot;rounded&quot;:0};" parent="1" vertex="1">
<mxGeometry x="220" y="1250" width="10" height="200" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-29" value="Hepatica" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="163.75" y="1260" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-30" value="" style="html=1;points=[[0,0,0,0,5],[0,1,0,0,-5],[1,0,0,0,5],[1,1,0,0,-5]];perimeter=orthogonalPerimeter;outlineConnect=0;targetShapes=umlLifeline;portConstraint=eastwest;newEdgeStyle={&quot;curved&quot;:0,&quot;rounded&quot;:0};" parent="1" vertex="1">
<mxGeometry x="300" y="1250" width="10" height="200" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-31" value="" style="html=1;points=[[0,0,0,0,5],[0,1,0,0,-5],[1,0,0,0,5],[1,1,0,0,-5]];perimeter=orthogonalPerimeter;outlineConnect=0;targetShapes=umlLifeline;portConstraint=eastwest;newEdgeStyle={&quot;curved&quot;:0,&quot;rounded&quot;:0};" parent="1" vertex="1">
<mxGeometry x="375" y="1250" width="10" height="200" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-32" value="" style="html=1;points=[[0,0,0,0,5],[0,1,0,0,-5],[1,0,0,0,5],[1,1,0,0,-5]];perimeter=orthogonalPerimeter;outlineConnect=0;targetShapes=umlLifeline;portConstraint=eastwest;newEdgeStyle={&quot;curved&quot;:0,&quot;rounded&quot;:0};" parent="1" vertex="1">
<mxGeometry x="445" y="1250" width="10" height="200" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-33" value="" style="html=1;points=[[0,0,0,0,5],[0,1,0,0,-5],[1,0,0,0,5],[1,1,0,0,-5]];perimeter=orthogonalPerimeter;outlineConnect=0;targetShapes=umlLifeline;portConstraint=eastwest;newEdgeStyle={&quot;curved&quot;:0,&quot;rounded&quot;:0};" parent="1" vertex="1">
<mxGeometry x="510" y="1250" width="10" height="200" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-34" value="" style="html=1;points=[[0,0,0,0,5],[0,1,0,0,-5],[1,0,0,0,5],[1,1,0,0,-5]];perimeter=orthogonalPerimeter;outlineConnect=0;targetShapes=umlLifeline;portConstraint=eastwest;newEdgeStyle={&quot;curved&quot;:0,&quot;rounded&quot;:0};" parent="1" vertex="1">
<mxGeometry x="580" y="1250" width="10" height="200" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-35" value="AppUrl" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="230" y="1260" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-37" value="CpuUsage" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="308.75" y="1260" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-38" value="MemoryUsage" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="385" y="1260" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-39" value="Status" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="453.75" y="1260" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-40" value="&lt;font style=&quot;font-size: 14px;&quot;&gt;Окно для загрузки архива приложения&lt;/font&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="341.25" y="980" width="200" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-41" value="&lt;font style=&quot;font-size: 14px;&quot;&gt;Ссылка на видео гайд&lt;/font&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="335" y="1470" width="200" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-42" value="Как пользоваться SpCloud:https://www.youtube.com/watch?v=rUxyKA_-grg" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="161.25" y="1510" width="416.25" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-43" value="" style="verticalLabelPosition=bottom;aspect=fixed;html=1;shape=mxgraph.salesforce.data;" parent="1" vertex="1">
<mxGeometry x="1100" y="730" width="48.6" height="60" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-44" value="&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: center; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(27, 29, 30); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; float: none; display: inline !important;&quot;&gt;SpСloud db&lt;/span&gt;" style="text;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="1090" y="695" width="90" height="40" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-45" value="User" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=30;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="970" y="800" width="140" height="190" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-46" value="Id&lt;br&gt;" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-45" vertex="1">
<mxGeometry y="30" width="140" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-49" value="Name" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-45" vertex="1">
<mxGeometry y="60" width="140" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-47" value="AuthToken" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-45" vertex="1">
<mxGeometry y="90" width="140" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-50" value="IsBanned&lt;br&gt;AppLimitCount&lt;br&gt;" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-45" vertex="1">
<mxGeometry y="120" width="140" height="70" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-51" value="" style="whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
<mxGeometry x="359" y="1020" width="160" height="160" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-52" value="&lt;font style=&quot;font-size: 41px;&quot;&gt;SpСloud&lt;/font&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="409" y="830" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-53" value="App" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=30;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="1170" y="830" width="220" height="180" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-55" value="Name" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-53" vertex="1">
<mxGeometry y="30" width="220" height="30" as="geometry" />
</mxCell>
<mxCell id="siBud0lxFuAxErJTvobO-3" value="UserId" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" vertex="1" parent="vamjHUPJP5RwR4Vbvad3-53">
<mxGeometry y="60" width="220" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-56" value="Url" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-53" vertex="1">
<mxGeometry y="90" width="220" height="30" as="geometry" />
</mxCell>
<mxCell id="siBud0lxFuAxErJTvobO-1" value="UrlLocalMachine" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" vertex="1" parent="vamjHUPJP5RwR4Vbvad3-53">
<mxGeometry y="120" width="220" height="30" as="geometry" />
</mxCell>
<mxCell id="siBud0lxFuAxErJTvobO-2" value="Target" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" vertex="1" parent="vamjHUPJP5RwR4Vbvad3-53">
<mxGeometry y="150" width="220" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-58" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="vamjHUPJP5RwR4Vbvad3-49" target="vamjHUPJP5RwR4Vbvad3-55" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

View File

@@ -1,6 +1,6 @@
<mxfile host="Electron" modified="2024-08-16T13:54:12.850Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/23.0.2 Chrome/120.0.6099.109 Electron/28.1.0 Safari/537.36" etag="ycVdF7wh_OfIlrg_FKof" version="23.0.2" type="device">
<mxfile host="Electron" modified="2024-08-16T21:20:37.157Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/23.0.2 Chrome/120.0.6099.109 Electron/28.1.0 Safari/537.36" etag="PSu86GYPCNH2GZ5_TS_U" version="23.0.2" type="device">
<diagram name="Page-1" id="Amrm0kvx0odSU5wdFRfC">
<mxGraphModel dx="527" dy="345" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<mxGraphModel dx="1024" dy="597" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
@@ -68,7 +68,7 @@
<mxGeometry x="355" y="700" width="160" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-18" value="" style="html=1;whiteSpace=wrap;strokeColor=none;fillColor=#0079D6;labelPosition=center;verticalLabelPosition=middle;verticalAlign=top;align=center;fontSize=12;outlineConnect=0;spacingTop=-6;fontColor=#FFFFFF;sketch=0;shape=mxgraph.sitemap.page;" parent="1" vertex="1">
<mxGeometry x="120" y="750" width="630" height="950" as="geometry" />
<mxGeometry x="120" y="690" width="630" height="950" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-21" value="Зарегистрироваться" style="rounded=1;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="610" y="760" width="130" height="30" as="geometry" />
@@ -118,8 +118,8 @@
<mxCell id="vamjHUPJP5RwR4Vbvad3-39" value="Status" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="453.75" y="1260" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-40" value="&lt;font style=&quot;font-size: 14px;&quot;&gt;Окно для загрузки архива приложения&lt;/font&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="341.25" y="980" width="200" height="30" as="geometry" />
<mxCell id="vamjHUPJP5RwR4Vbvad3-40" value="&lt;font style=&quot;font-size: 14px;&quot;&gt;Окно для загрузки архива приложения&amp;nbsp;&lt;/font&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="335" y="940" width="200" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-41" value="&lt;font style=&quot;font-size: 14px;&quot;&gt;Ссылка на видео гайд&lt;/font&gt;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="335" y="1470" width="200" height="30" as="geometry" />
@@ -134,7 +134,7 @@
<mxGeometry x="1090" y="695" width="90" height="40" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-45" value="User" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=30;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="970" y="800" width="140" height="150" as="geometry" />
<mxGeometry x="970" y="800" width="140" height="190" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-46" value="Id&lt;br&gt;" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-45" vertex="1">
<mxGeometry y="30" width="140" height="30" as="geometry" />
@@ -145,8 +145,8 @@
<mxCell id="vamjHUPJP5RwR4Vbvad3-47" value="AuthToken" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-45" vertex="1">
<mxGeometry y="90" width="140" height="30" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-50" value="IsBanned&lt;br&gt;AppLimitCount&lt;br&gt;" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-45" vertex="1">
<mxGeometry y="120" width="140" height="30" as="geometry" />
<mxCell id="vamjHUPJP5RwR4Vbvad3-50" value="IsBanned&lt;br&gt;AppLimitCount&lt;br&gt;AppCount" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" parent="vamjHUPJP5RwR4Vbvad3-45" vertex="1">
<mxGeometry y="120" width="140" height="70" as="geometry" />
</mxCell>
<mxCell id="vamjHUPJP5RwR4Vbvad3-51" value="" style="whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
<mxGeometry x="359" y="1020" width="160" height="160" as="geometry" />
@@ -175,6 +175,12 @@
<mxCell id="vamjHUPJP5RwR4Vbvad3-58" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="vamjHUPJP5RwR4Vbvad3-49" target="vamjHUPJP5RwR4Vbvad3-55" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="siBud0lxFuAxErJTvobO-5" value="Обновить текущее приложение&amp;nbsp;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="365" y="980" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="siBud0lxFuAxErJTvobO-6" value="Загрузить новое приложение&amp;nbsp;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="450" y="980" width="60" height="30" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>

View File

@@ -1,10 +1,11 @@
#include "../httplib.h"
#include "../httplib.h"
//#include <windows.h>
//#include "Service/AuthorizationService.cpp"
//#include "Service/FileProcessingService.cpp"
#include "../Service/AuthorizationService.cpp"
#include "../Service/FileProcessingService.cpp"
#include "../Models/App.cpp"
//#include "Service/Logger.cpp"
class PublishController
@@ -20,6 +21,8 @@ private:
Logger& logger_;
int last_available_port = 8081;
//std::string publish_app_path = "C:/Temps/";// Todo delete if not needed
public:
@@ -29,49 +32,47 @@ public:
}
public:
void process_publish(const httplib::Request& req, httplib::Response& res)
std::string process_publish(const httplib::Request& req, App* app)
{
//if (this->authorization.is_user_authorized())
if (true)//Todo change to is user authorized
{
const auto& content = req.files.begin()->second.content;
const auto& content = req.files.begin()->second.content;
const auto& filename = this->publish_app_path + req.files.begin()->second.filename;
const auto& filename = this->publish_app_path + req.files.begin()->second.filename;
if (filename.size() >= 4 && filename.substr(filename.size() - 4) == ".rar") {
if (file_processing->save_file(filename, content)) {
if (filename.size() >= 4 && filename.substr(filename.size() - 4) == ".rar") {
//if (true) {//TODO UNCOMMIT WHEN STARING TO WRITE PUBLISH PROCESS
if (file_processing->save_file(filename, content)) {
std::string random_string = generate_random_string(20);//TODO VERY IMPORTANT CHANGE THIS RANDOM GENERATING TO GENERATE UNIQUE STRING
file_processing->unzip(filename, this->publish_app_path + app->get_user_id());//TODO UNCOMMIT WHEN STARING TO WRITE PUBLISH PROCESS
file_processing->unzip(filename, this->publish_app_path + random_string);
/*check_port_and_increase_if_not_available();
this->dotnet_publish(this->publish_app_path + random_string);
file_processing->adjust_nginx_configuration_and_reloud(app->get_name(), std::to_string(last_available_port));*/
res.set_content("File uploaded successfully: " + filename, "text/plain");
}
else {
res.status = 500;
res.set_content("Failed to save file, please ensure you are putting rar file"
+ filename, "text/plain");
}
//file_processing->create_service_file(app->get_name());//TODO UNCOMMIT WHEN STARING TO WRITE PUBLISH PROCESS
//this->dotnet_publish(this->publish_app_path + app->get_user_id(), last_available_port);//TODO UNCOMMIT WHEN STARING TO WRITE PUBLISH PROCESS
//Todo introduce old binary file
file_processing->delete_file(filename);
return "File uploaded successfully: " + filename;
}
else {
res.status = 400;
res.set_content("Invalid file type. Only .rar files are allowed.",
"text/plain");
return "Failed to save file, please ensure you are putting rar file" + filename;
}
}
else
{
//Todo add logging and exiting from function with bead request
else {
return "Invalid file type. Only .rar files are allowed." + filename;
}
}
private:
void dotnet_publish(const std::string& path)
{
void dotnet_publish(const std::string& path, int port)
{//Todo adjust to build setting from mongodb
std::string dll_file_name = file_processing->find_file_by_suffix(path, "exe");
//Todo introduce deleting old rar file after publishing
size_t pos = dll_file_name.find(".exe");
if (pos != std::string::npos) {
dll_file_name.replace(pos, 4, ".dll");
@@ -84,6 +85,41 @@ private:
commandThread.detach();
}
void check_port_and_increase_if_not_available()
{
while (true)
{
std::string port_str = std::to_string(last_available_port);
std::string command = "ss -tuln | grep :" + port_str;
auto request = std::async(std::launch::async, &PublishController::execute_command, this, command);
std::string response = request.get();
if (!response.empty())
{
last_available_port++;
}
else
{
break;
}
}
}
std::string execute_command(const std::string& command) {
std::array<char, 128> buffer;
std::string result;
std::shared_ptr<FILE> pipe(popen(command.c_str(), "r"), pclose);
if (!pipe) throw std::runtime_error("popen() failed!");
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
result += buffer.data();
}
return result;
}
static std::string generate_random_string(size_t length, const std::string& char_set = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") {
std::random_device rd;
std::mt19937 generator(rd());

View File

@@ -1,50 +1,29 @@
#include <string>
#ifndef APP_H
#define APP_H
class App {
private:
int id;
std::string name;
std::string authToken;
bool isBanned;
std::string user_id;
std::string url;
std::string url_on_local_machine;
std::string target;
public:
// Конструктор
App(int id, const std::string& name, const std::string& authToken, bool isBanned)
: id(id), name(name), authToken(authToken), isBanned(isBanned) {}
App(const std::string& name, const std::string& user_id, const std::string& url,
const std::string& url_on_local_machine, const std::string& target)
: name(name), user_id(user_id), url(url), url_on_local_machine(url_on_local_machine), target(target) {}
// Геттеры и сеттеры для Id
int getId() const {
return id;
}
std::string get_name() const { return name; }
std::string get_user_id() const { return user_id; }
std::string get_url() const { return url; }
std::string get_url_on_local_machine() const { return url_on_local_machine; }
std::string get_target() const { return target; }
void setId(int id) {
this->id = id;
}
// Геттеры и сеттеры для Name
std::string getName() const {
return name;
}
void setName(const std::string& name) {
this->name = name;
}
// Геттеры и сеттеры для AuthToken
std::string getAuthToken() const {
return authToken;
}
void setAuthToken(const std::string& authToken) {
this->authToken = authToken;
}
// Геттеры и сеттеры для IsBanned
bool getIsBanned() const {
return isBanned;
}
void setIsBanned(bool isBanned) {
this->isBanned = isBanned;
}
void set_name(const std::string& name) { this->name = name; }
void set_user_id(const std::string& user_id) { this->user_id = user_id; }
void set_url(const std::string& url) { this->url = url; }
void set_url_on_local_machine(const std::string& url_on_local_machine) { this->url_on_local_machine = url_on_local_machine; }
void set_target(const std::string& target) { this->target = target; }
};
#endif // APP_H

View File

@@ -21,29 +21,6 @@ public:
{
std::string auth_code_processed = extract_code(auth_code);
//std::string body = "client_id=1273414933874479185&"//Todo delete comments if not needed
// "client_secret=S_vG4frjlxWoi8mic_GlcxUO0aWxXwRJ&"
// "grant_type=authorization_code&"
// "code=" + auth_code_processed + "&"
// "redirect_uri=https://www.sp-donate.ru/pay/Hepatir";
//httplib::Headers headers = {
// {"Content-Type", "application/x-www-form-urlencoded"}
//};
//httplib::Client client("discord.com/api");
////// Выполняем простой GET-запрос на http://httpbin.org/get
////auto res = client.Get("/get");
//auto res = client.Post("/oauth2/token", headers, body, "application/x-www-form-urlencoded");
////auto res = client_.Post("/oauth2/token", headers, body, "application/x-www-form-urlencoded");
//if (res && res->status == 200) {
// return res->body;
//}
//else {
// return "Error: ";//Todo write handling this
//}
std::string command = "curl --location https://discord.com/api/oauth2/token "
"--header \"Content-Type: application/x-www-form-urlencoded\" "
"--data-urlencode \"client_id=1273414933874479185\" "
@@ -62,19 +39,6 @@ public:
auto me_request = std::async(std::launch::async, &DiscordService::execute_command, this, command);
//httplib::Headers headers = {
// {"Authorization", "Bearer " + access_token}
//};
//auto res = client_.Get("/users/@me", headers);
//if (res && res->status == 200) {
// return res->body;
//}
//else {
// return "Error: ";//Todo write handling this
//}
std::string user_id = extract_user_id(me_request.get());
return user_id;
@@ -107,35 +71,16 @@ public:
return result;
}
//std::string extract_user_id(const std::string& input) {
// std::string search_pattern = "\"discord_id\":\"";
// std::size_t start_pos = input.find(search_pattern);
// if (start_pos == std::string::npos) {
// throw std::runtime_error("discord_id not found");
// }
// start_pos += search_pattern.length(); // move to the start of the user_id
// std::size_t end_pos = input.find("\"", start_pos);
// if (end_pos == std::string::npos) {
// throw std::runtime_error("End of discord_id not found");
// }
// return input.substr(start_pos, end_pos - start_pos);
//}
std::string extract_code(const std::string& json_str) {
std::string key = "\"code\":";
size_t start = json_str.find(key);
if (start != std::string::npos) {
start += key.length();
// Пропускаем любые пробелы или символы ':'
while (start < json_str.length() && (json_str[start] == ' ' || json_str[start] == '\"' || json_str[start] == ':')) {
start++;
}
// Найти конец строки
size_t end = json_str.find('\"', start);
if (end != std::string::npos) {
return json_str.substr(start, end - start);
@@ -154,6 +99,6 @@ public:
return response.substr(start_pos, end_pos - start_pos);
}
}
return ""; // Вернуть пустую строку, если токен не найден
return "";
}
};

View File

@@ -7,6 +7,7 @@
#include <sys/stat.h>
#include "CommandService.cpp"
#include "Logger.cpp"
#include <string.h>
class FileProcessingService
{
Logger& logger_;
@@ -18,6 +19,79 @@ public:
}
void adjust_nginx_configuration_and_reloud(const std::string& filename, std::string port)
{
std::string file_path = "/etc/nginx/nginx.conf";
std::string new_text =
"server {\n"
" listen 443 ssl;\n"
" server_name " + filename + ".almavid.ru;\n\n"
" ssl_certificate /etc/letsencrypt/live/almavid.ru/fullchain.pem;\n"
" ssl_certificate_key /etc/letsencrypt/live/almavid.ru/privkey.pem;\n"
" ssl_protocols TLSv1 TLSv1.1 TLSv1.2;\n"
" ssl_ciphers HIGH:!aNULL:!MD5;\n\n"
" client_max_body_size 2G; // Allow file uploads up to 2GB\n\n"
" location / {\n"
" proxy_pass http://localhost:" + port + ";\n"
" proxy_set_header Host $host;\n"
" proxy_set_header X-Real-IP $remote_addr;\n"
" proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n"
" proxy_set_header X-Forwarded-Proto $scheme;\n\n"
" # Support for WebSocket\n"
" proxy_http_version 1.1;\n"
" proxy_set_header Upgrade $http_upgrade;\n"
" proxy_set_header Connection \"upgrade\";\n"
" }\n\n"
"}\n";
std::ofstream file(file_path, std::ios::app);
if (!file.is_open()) {
logger_.log(INFO, "Error: Could not open file " + file_path + strerror(errno) + '\n');
return;
}
file << new_text << '\n';
file.close();
// Reload Nginx to apply the changes
/*int result = std::system("sudo systemctl reload nginx");
if (result != 0) {
std::cerr << "Error: Failed to reload Nginx" << std::endl;
return 1;
}*/
std::string command = "sudo systemctl reload nginx";
std::thread commandThread(&CommandService::execute_command, command);
commandThread.join();
logger_.log(INFO, "Nginx reloaded successfully.");
}
void delete_file(const std::string& file_path) const
{
try {
// Delete the original file
if (std::filesystem::exists(file_path)) {
std::filesystem::remove(file_path);
logger_.log(INFO, "Deleted file: " + file_path);
}
// Delete the directory recursively//Todo test if method will not work
/*if (std::filesystem::exists(final_files_directory)) {
std::filesystem::remove_all(final_files_directory);
logger_.log(INFO, "Deleted directory: " + final_files_directory);
}*/
}
catch (const std::filesystem::filesystem_error& e) {
logger_.log(ERROR, "Error during deletion: " + std::string(e.what()));
}
}
bool save_file(const std::string& filename, const std::string& content) {
logger_.log(INFO, "Start saving file method");
@@ -35,6 +109,48 @@ public:
return ofs.good();
}
void create_service_file(std::string name)
{
logger_.log(INFO, "Start create_service_file");
std::string filename = "/etc/systemd/system/" + name + ".service";
std::ofstream serviceFile(filename);
if (serviceFile.is_open()) {
serviceFile << "[Unit]\n";
serviceFile << "Description=" << name << " Service\n";
serviceFile << "After=network.target\n\n";
serviceFile << "[Service]\n";
serviceFile << "ExecStart=/home/danilt2000/SpCloud/" + name + "/build/ " + name + "\n";
//serviceFile << "ExecStart=/home/danilt2000/SpCloud/SpCloudMain/build/SpCloudMain\n";
serviceFile << "WorkingDirectory=/home/danilt2000/SpCloud/" + name + "/build\n";
//serviceFile << "WorkingDirectory=/home/danilt2000/SpCloud/SpCloudMain/build\n";
serviceFile << "Restart=always\n";
serviceFile << "User=danilt2000\n";
serviceFile << "Environment=PATH=/usr/bin\n";
serviceFile << "Environment=NODE_ENV=production\n\n";
serviceFile << "[Install]\n";
serviceFile << "WantedBy=multi-user.target\n";
std::string command = "sudo systemctl daemon-reload";
std::thread commandThread(&CommandService::execute_command, command);
commandThread.join();
//Todo check service ->sudo systemctl status <service-name>.service
serviceFile.close();
logger_.log(INFO, "Service file " + filename + " created successfully.\n");
}
else {
logger_.log(INFO, "Unable to open file " + filename + " for writing: " + strerror(errno) + "\n");
}
}
void create_directory(const std::string& path) {
std::filesystem::create_directories(path);
}
@@ -60,8 +176,4 @@ public:
}
return ""; //todo add throwing exception
}
/*private:
std::mutex file_mutex; */// Мьютекс для синхронизации доступа к файлу
};

View File

@@ -86,6 +86,34 @@ public:
return "Success";
}
std::string is_app_name_free(std::string name)
{
std::string json_data = R"({
"dataSource": "SpCloudCluster",
"database": "SpCloud",
"collection": "Apps",
"filter": {
"name": ")" + name + R"("
}
})";
std::string command = "curl --location 'https://eu-central-1.aws.data.mongodb-api.com/app/data-zvcqvrr/endpoint/data/v1/action/findOne' "
"--header 'Content-Type: application/json' "
"--header 'api-key: Q1NfSCrruUAzsxdrjhZd3sjSwiqbdSFmCLeaCatZiuohUXsvEq9RtEAeG0JL2Jd7' "
"--data-raw '" + json_data + "'";
auto request = std::async(std::launch::async, &MongoDbService::execute_command, this, command);
std::string response = request.get();
if (response == "{\"document\":null}")
{
return "Success";
}
return "App name isn't free please select another one";
}
std::string add_app(std::string name, std::string user_id, std::string url, std::string url_on_local_mahcine, std::string target)
{
std::string json_data = R"({

View File

@@ -1,16 +1,12 @@
// SpCloudMain.cpp : Defines the entry point for the application.
//
// ReSharper disable CppClangTidyBugproneSuspiciousInclude
// ReSharper disable CppClangTidyBugproneSuspiciousInclude
#include "SpCloudMain.h"
#include "httplib.h"
#include "Controllers/PublishController.cpp"
#include "Service/DiscordService.cpp"
#include "Service/MongoDbService.cpp"
#include "Models/App.cpp"
//#include "Service/AuthorizationService.cpp"
//#include "Service/FileProcessingService.cpp"
using namespace std;
int main()
@@ -52,19 +48,37 @@ int main()
{
logger.log(INFO, "Start publish from main");
string is_user_can_publish_response = mongo_service.is_user_can_publish("khBuvDWPHOhPSiQNVQZm9PM0VF29dqAaDBjWX4BnxJKzRvg0Gm");//TODO UNCOMMENT AND FIX
std::string user_id = req.get_file_value("UserId").content;
std::string name = req.get_file_value("Name").content;
ranges::transform(name, name.begin(), [](unsigned char c) { return std::tolower(c); });
std::string target = req.get_file_value("Target").content;
std::string authorization_token = req.get_header_value("Authorization");
string is_user_can_publish_response = mongo_service.is_user_can_publish(authorization_token);
if (is_user_can_publish_response != "Success")
{
res.set_content(is_user_can_publish_response, "text/plain");//Todo add app address showing
res.set_content(is_user_can_publish_response, "text/plain");
return;
}
//publish_controller.process_publish(req, res);//TODO UNCOMMENT AND FIX
string is_app_name_response = mongo_service.is_app_name_free(name);
//mongo_service.add_app("test", "test", "test", "test", "test");//TODO UNCOMMENT AND FIX
if (is_app_name_response != "Success")
{
res.set_content(is_app_name_response, "text/plain");
return;
}
App* app = new App(name, user_id, "url", "local_url", target);
publish_controller.process_publish(req, app);
//mongo_service.add_app("test", "test", "test", "test", "test");//TODO UNCOMMENT AND FIX
delete app;
res.set_content("App is running on address ????", "text/plain");//Todo add app address showing
});
@@ -79,27 +93,5 @@ int main()
res.set_content(result, "text/plain");
});
/*httplib::Client cli("https://discord.com/api/oauth2/token");
std::string jsonData = R"({
"dataSource": "Cluster0",
"database": "myDatabase",
"collection": "items",
"document": {
"name": "Item Name",
"value": "Item Value"
}
})";
auto res = cli.Post("/app/data-abcde/endpoint/data/v1/action/insertOne", jsonData, "application/json");
if (res && res->status == 200) {
std::cout << "Success: " << res->body << std::endl;
}
else {
std::cerr << "Error: " << res.error() << std::endl;
}*/
svr.listen("0.0.0.0", 8081);
}