diff --git a/Bindings/Client.go b/Bindings/Client.go index c46bdb5..32cd20e 100644 --- a/Bindings/Client.go +++ b/Bindings/Client.go @@ -135,11 +135,11 @@ func EscapeFirewall(HostOutsideNATIP string, HostOutsideNATPort string, internal //export MapPort func MapPort(Port string, DomainName string, ServerAddress string) *C.char { - entireAddress, _, err := abstractions.MapPort(Port, DomainName, ServerAddress) + Address, err := abstractions.MapPort(Port, DomainName, ServerAddress) if err != nil { return C.CString(err.Error()) } - return C.CString(entireAddress) + return C.CString(Address.EntireAddress) } // --------------------------------- Controlling Server ---------------------------------------- diff --git a/CONTRIBUTE.md.org b/CONTRIBUTE.md.org deleted file mode 100644 index c87ecca..0000000 --- a/CONTRIBUTE.md.org +++ /dev/null @@ -1,93 +0,0 @@ -* Contributing -:PROPERTIES: -:CUSTOM_ID: contributing -:END: -When contributing to this repository, please first discuss the change -you wish to make via issue, email, or any other method with the owners -of this repository before making a change. - -Please note we have a code of conduct, please follow it in all your -interactions with the project. - -** Pull Request Process -:PROPERTIES: -:CUSTOM_ID: pull-request-process -:END: -1. Ensure any install or build dependencies are removed before the end - of the layer when doing a build. -2. Update the appropriate docs before stating the changes you did. -3. You may merge the Pull Request in once you have the approval of - CODEOWNER, or if you do not have permission to do that, you may - request the second reviewer to merge it for you. - -** Code of conduct -:PROPERTIES: -:CUSTOM_ID: code-of-conduct -:END: -All projects(including mailing lists) at HWTechClub is required to -follow [[https://lunduke.com/pages/codeofconduct/][The Lunduke Code of -Conduct]]. - -*** The Lunduke Code of Conduct -:PROPERTIES: -:CUSTOM_ID: the-lunduke-code-of-conduct -:END: - -#+begin_quote -**** "Be Excellent to Each Other." -:PROPERTIES: -:CUSTOM_ID: be-excellent-to-each-other. -:END: -#+end_quote - -***** FAQ -:PROPERTIES: -:CUSTOM_ID: faq -:END: -*Q*: Wait. That's it? - -A: Yup. - -*Q*: But... but... it's only 5 words! - -A: It is? Cool! - -*Q*: Isn't that too short to be a viable Code of Conduct? - -A: Nah. - -*Q*: It's too vague! How would you enforce this?!? - -A: By being excellent to each other. - -*Q*: What if someone violates this Code of Conduct? - -A: I trust you to figure it out. - -*Q*: What if someone talks about politics I disagree with?!?!!? - -A: I know a guy who votes for Papa Smurf in every Presidential election. -He's a pretty cool dude. - -*Q*: I'm super angry about something! And a person likes the thing -making me angry! What do I do? - -A: I dunno. Try /hugs/? - -*Q*: Are virtual hugs (such as /"hugs"/ and animated .GIFs of teddy -bears hugging) excellent? - -A: Most excellent. - -*Q*: Huh. Seems so simple! - -A: I know, right? - -*Q*: I like you! - -A: I like you, too! - -/The Lunduke Code of Conduct is free for you to use however you like./ - -*Source*: [[https://lunduke.com/pages/codeofconduct/][The Lunduke Code -of Conduct]] diff --git a/Docs/index.html b/Docs/index.html index 500b37a..3a7bc84 100644 --- a/Docs/index.html +++ b/Docs/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + @@ -12,7 +12,7 @@ - + @@ -70,7 +70,7 @@
  • 3.0.17. Pulling plugin from a remote repo
  • 3.0.18. Deleting plugin from the plugin directory
  • 3.0.19. Added custom metadata about the current node
  • -
  • 3.0.20. MapPort and link to domain name
  • +
  • 3.0.20. MapPort and link to domain name
  • @@ -100,7 +100,8 @@
  • 5.3. Current languages supported
  • @@ -117,13 +118,13 @@
  • 9. Client mode
  • -
  • 10. Ideas for future potencial features +
  • 10. Ideas for future potencial features @@ -142,18 +143,18 @@

    1.1. Abstract

    -This project focuses on creating a framework for running heavy computational tasks that a regular -computer cannot handle easily. These tasks may include graphically demanding video games, rendering -3D animations, and performing complex protein folding simulations. The major focus of this project -is not on financial incentives but rather on building a robust and efficient peer-to-peer (P2P) -network to decentralise task execution and increase the computational bandwidth available for +This project focuses on creating a framework for running heavy computational tasks that a regular +computer cannot handle easily. These tasks may include graphically demanding video games, rendering +3D animations, and performing complex protein folding simulations. The major focus of this project +is not on financial incentives but rather on building a robust and efficient peer-to-peer (P2P) +network to decentralise task execution and increase the computational bandwidth available for such tasks.

    -The P2PRC framework serves as a foundation for decentralised rendering and computation, -providing insights into how tasks can be distributed efficiently across a network of peers. -Leveraging the P2PRC approach, this project extends its capabilities to handle a +The P2PRC framework serves as a foundation for decentralised rendering and computation, +providing insights into how tasks can be distributed efficiently across a network of peers. +Leveraging the P2PRC approach, this project extends its capabilities to handle a wider range of computationally intensive tasks.

    @@ -230,7 +231,7 @@ Go API to create and interact with the containers. to install docker GPU

    -
    +
     // Do ensure that the docker command does not need sudo to run
     sudo chmod 666 /var/run/docker.sock
     
    @@ -245,7 +246,7 @@ To set up the internal dependencies and build the entire go code into a single binary

    -
    +
     make install
     
    @@ -258,7 +259,7 @@ To set up P2PRC on Windows, simply run this batch file. Make sure you are not in admin mode when running this.

    -
    +
     .\install.bat
     
    @@ -269,7 +270,7 @@ are not in admin mode when running this.

    2.2.4. Add appropriate paths to .bashrc

    -
    +
     export P2PRC=/<PATH>/p2p-rendering-computation
     export PATH=/<PATH>/p2p-rendering-computation:${PATH}
     
    @@ -279,8 +280,8 @@ export PATH=/<PATH>/p2p-rendering-computation:${PATH}

    2.2.5. Set up configuration file

    -
    -make configfile
    +
    +make configfile 
     

    @@ -293,7 +294,7 @@ one.

    2.2.6. Test if binary works

    -
    +
     p2prc --help
     
    @@ -301,7 +302,7 @@ p2prc --help
    1. Output:
      -
      +
       NAME:
          p2p-rendering-computation - p2p cli application to create and access VMs in other servers
       
      @@ -364,8 +365,8 @@ GLOBAL OPTIONS:
       

      3.0.1. Start as a server

      -
      -p2prc -s
      +
      +p2prc -s 
       
      @@ -373,7 +374,7 @@ p2prc -s

      3.0.2. View server Specification

      -
      +
       p2prc --specs=<ip address>
       
      @@ -386,7 +387,7 @@ p2prc --specs=<ip address> use the --gpu if you know the other machine has a gpu.

      -
      +
       p2prc --touch=<server ip address> -p <number of ports> --gpu
       
      @@ -399,8 +400,8 @@ p2prc --touch=<server ip address> -p <number of ports> --gpu The docker id is present in the output where you create a container

      -
      -p2prc --rm=<server ip address> --id=<docker container id>
      +
      +p2prc --rm=<server ip address> --id=<docker container id> 
       
    @@ -408,8 +409,8 @@ p2prc --rm=<server ip address> --id=<docker container id>

    3.0.5. Adding servers to ip table

    -
    -p2prc --as=<server ip address you want to add>
    +
    +p2prc --as=<server ip address you want to add> 
     
    @@ -417,8 +418,8 @@ p2prc --as=<server ip address you want to add>

    3.0.6. Update ip table

    -
    -p2prc --us
    +
    +p2prc --us 
     
    @@ -426,8 +427,8 @@ p2prc --us

    3.0.7. List Servers

    -
    -p2prc --ls
    +
    +p2prc --ls 
     
    @@ -435,7 +436,7 @@ p2prc --ls

    3.0.8. View Network interfaces

    -
    +
     p2prc --ni
     
    @@ -444,7 +445,7 @@ p2prc --ni

    3.0.9. Viewing Containers created Client side

    -
    +
     p2prc --tc
     
    @@ -453,7 +454,7 @@ p2prc --tc

    3.0.10. Running plugin

    -
    +
     p2prc --plugin <plugin name> --id <container id or group id>
     
    @@ -462,7 +463,7 @@ p2prc --plugin <plugin name> --id <container id or group id>

    3.0.11. Create group

    -
    +
     p2prc --cgroup
     
    @@ -471,7 +472,7 @@ p2prc --cgroup

    3.0.12. Add container to group

    -
    +
     p2prc --group <group id> --id <container id>
     
    @@ -480,7 +481,7 @@ p2prc --group <group id> --id <container id>

    3.0.13. View groups

    -
    +
     p2prc --groups
     
    @@ -489,7 +490,7 @@ p2prc --groups

    3.0.14. View specific group

    -
    +
     p2prc --group <group id>
     
    @@ -498,8 +499,8 @@ p2prc --group <group id>

    3.0.15. Delete container from group

    -
    -p2prc --rmcgroup --group <group id> --id <container id>
    +
    +p2prc --rmcgroup --group <group id> --id <container id> 
     
    @@ -507,7 +508,7 @@ p2prc --rmcgroup --group <group id> --id <container id>

    3.0.16. Delete entire group

    -
    +
     p2prc --rmgroup <group id>
     
    @@ -516,7 +517,7 @@ p2prc --rmgroup <group id>

    3.0.17. Pulling plugin from a remote repo

    -
    +
     p2prc --pp <repo link>
     
    @@ -525,8 +526,8 @@ p2prc --pp <repo link>

    3.0.18. Deleting plugin from the plugin directory

    -
    -p2prc --rp <plugin name>
    +
    +p2prc --rp <plugin name> 
     
    @@ -534,16 +535,16 @@ p2prc --rp <plugin name>

    3.0.19. Added custom metadata about the current node

    -
    +
     p2prc --amd "custom metadata"
     
    -
    -

    3.0.20. MapPort and link to domain name

    +
    +

    3.0.20. MapPort and link to domain name

    -
    +
     p2prc --mp <port no to map> --dn <domain name to link Mapped port against>
     
    @@ -556,15 +557,15 @@ p2prc --mp <port no to map> --dn <domain name to link Mapped port again

    4. P2P Module Implementation

    -The P2P module is for managing server information within the network. -It maintains and updates the IP table, ensuring accuracy by preventing duplicates and removing -entries for unreachable servers. Furthermore, the module conducts speed tests on the listed servers -to determine upload and download speeds. This valuable information enables users to identify nearby +The P2P module is for managing server information within the network. +It maintains and updates the IP table, ensuring accuracy by preventing duplicates and removing +entries for unreachable servers. Furthermore, the module conducts speed tests on the listed servers +to determine upload and download speeds. This valuable information enables users to identify nearby servers with optimal performance, enhancing their overall network experience.

    -
    +

    p2pmoduleArch.png

    Figure 1: UML diagram of P2P module

    @@ -612,7 +613,7 @@ configuration module. "NAT": "<boolean representing if the node is behind NAT or not>", "EscapeImplementation": "<NAT traversal implementation>", "ProxyServer": "<If the node listed is acting as a proxy server>", - "UnSafeMode": <Unsafe mode if turned on will allow all nodes in the network public keys to be + "UnSafeMode": <Unsafe mode if turned on will allow all nodes in the network public keys to be added to that particular node>", "PublicKey": "<Public key of that particular node>", "CustomInformation": "<custom information passed in through all the nodes in the network>" @@ -665,7 +666,7 @@ from the TURN server. The flow below describes the workflow.
  • Call /FRPPort
  • -
    +
     http://<turn server ip>:<server port no>/FRPport
     
    @@ -759,11 +760,11 @@ p2prc.h p2prc.so Below are a sample set of commands to open the bindings implementation.

    -
    +
     # run
     cd Bindings/
     # list files
    -ls
    +ls 
     # search for file
     Client.go
     
    @@ -853,7 +854,7 @@ that convert a go object to JSON string initially and converts it to
  • A Pseudo code to refer to the common function implementation shape could be represented as:
    -
    +
     func <Function name> (output *C.char) {
           <response>,<error> := <P2PRC function name>(<parameters if needed>)
           if <error> != nil {
    @@ -871,14 +872,14 @@ func <Function name> (output *C.char) {
     

    5.3. Current languages supported

    -
      -
    • Python
    • -
    - -
    -

    5.3.1. Build sample python program

    -
    +
    +

    5.3.1. Python

    +
    +
    +
      +
    1. Build sample python program
      +

      The easier way

      @@ -907,10 +908,25 @@ scripted or used a reference point as proof of concept that P2PRC can be called from other programming languages.

      -
    -
    +
  • +
    +
    +

    5.3.2. Haskell

    +
    +

    +P2PRC officially supports Haskell bindings and will further support +project using Haskell to build orchestrators on top of P2PRC. +

    + +

    +Read more… +

    +
    +
    +
    +

    6. Config Implementation

    @@ -1015,7 +1031,7 @@ from the TURN server. The flow below describes the workflow.
  • Call /FRPPort
  • -
    +
     http://<turn server ip>:<server port no>/FRPport
     
    @@ -1051,8 +1067,8 @@ func main() { -
    -

    10. Ideas for future potencial features

    +
    +

    10. Ideas for future potencial features

    Consists of personal loideas for the future of P2PRC. @@ -1060,8 +1076,8 @@ At moment only has main contributors writiing to this.

    -
    -

    10.1. To support hetrogenous set of Nodes that cannot run P2PRC

    +
    +

    10.1. To support hetrogenous set of Nodes that cannot run P2PRC

    This stems from a personal issue I have when doing research @@ -1078,8 +1094,8 @@ network nodes.

    -
    -

    10.1.1. Assumptions:

    +
    +

    10.1.1. Assumptions:

    • I have a Morello board that cannot run P2PRC
    • @@ -1092,8 +1108,8 @@ as well look into custom tasks into the hetrogenous hardware.
    -
    -

    10.1.2. Set of interesting possible:

    +
    +

    10.1.2. Set of interesting possible:

    We build a cool set possibilities before and use this to build up the implementation @@ -1110,8 +1126,8 @@ weight hypervisors.

  • -
    -

    10.1.3. Implementation

    +
    +

    10.1.3. Implementation

    • To use implementations similar to socat to ensure we can bind address of local @@ -1125,7 +1141,7 @@ other nodes can access the Morello board who have permission access.
    -
    +

    P2PRCRemoteNodes.png

    Figure 2: Implementation idea (To be improved upon)

    @@ -1137,8 +1153,8 @@ other nodes can access the Morello board who have permission access.

    Author: Akilan

    -

    Created: 2025-01-21 Tue 21:04

    +

    Created: 2025-01-24 Fri 15:22

    Validate

    - + \ No newline at end of file diff --git a/Docs/docs.org b/Docs/index.org similarity index 98% rename from Docs/docs.org rename to Docs/index.org index 9e81540..f926c37 100644 --- a/Docs/docs.org +++ b/Docs/index.org @@ -351,9 +351,15 @@ p2prc --amd "custom metadata" #+end_example *** MapPort and link to domain name +Allows to expose remote ports from a machine in the P2P network. #+begin_example p2prc --mp --dn #+end_example +**** MapPort in remote machine +This is to ensure ports on remote machines on the P2PRC can be easily opened. +#+begin_example +p2prc --mp --dn --ra +#+end_example -------------- @@ -628,9 +634,9 @@ func (output *C.char) { :PROPERTIES: :CUSTOM_ID: current-languages-supported :END: -- Python +*** Python -*** Build sample python program +**** Build sample python program :PROPERTIES: :CUSTOM_ID: build-sample-python-program :END: @@ -657,6 +663,11 @@ folder can copied and created as a new git repo for P2PRC extensions scripted or used a reference point as proof of concept that P2PRC can be called from other programming languages. +*** Haskell +P2PRC officially supports Haskell bindings and will further support +project using Haskell to build orchestrators on top of P2PRC. + +[[https://p2prc.akilan.io/Docs/haskell][Read more...]] * Config Implementation :PROPERTIES: diff --git a/README.md.org b/README.md.org deleted file mode 100644 index c282bc8..0000000 --- a/README.md.org +++ /dev/null @@ -1,252 +0,0 @@ -#+begin_quote -[!TIP] Haskell bindings supported!: -[[https://p2prc.akilan.io/Docs/haskell/P2PRC.html][Bindings -documentaton]] - -#+end_quote - -#+begin_quote -[!NOTE] Fixing documentation to latest changes. If you have any -questions setting up P2PRC either -[[https://github.com/Akilan1999/p2p-rendering-computation/issues/new/choose][create -an issue]] or send me an email (me AT akilan dot io). Currently HEAD is -always intended to stay on a working state. It is recommended to always -use HEAD in your go.mod file. - -#+end_quote - -#+begin_html -

    -#+end_html - -#+begin_html -

    -#+end_html - -#+begin_html - -#+end_html - -#+begin_html - -#+end_html - -#+begin_html - -#+end_html - -This project aims to simplify self-hosting servers and streamline the -creation of distributed systems. The primary focus is to enable users to -design custom peer-to-peer networks for distributed computing, offering -full flexibility and control while abstracting away the complexities of -networking. - -** Key Features -:PROPERTIES: -:CUSTOM_ID: key-features -:END: -Simplified Self-Hosting Empower users to easily host nodes, whether on -personal computers behind NAT, custom hardware, or cloud-based -infrastructure. - -*** Custom Peer-to-Peer Networks -:PROPERTIES: -:CUSTOM_ID: custom-peer-to-peer-networks -:END: -Build a decentralised network tailored to user requirements, enabling -distributed task execution without the need for in-depth networking -knowledge. - -*** Heterogeneous Node Support -:PROPERTIES: -:CUSTOM_ID: heterogeneous-node-support -:END: -Harness a diverse array of nodes from personal computers to specialised -hardware---seamlessly integrated into a global node list. - -*** Abstracted Networking Layer -:PROPERTIES: -:CUSTOM_ID: abstracted-networking-layer -:END: -Networking details are completely abstracted, enabling users to focus on -developing bespoke task orchestration systems. No more manual -configuration of IPs, ports, or connection logic. - -*** Flexible Task Distribution -:PROPERTIES: -:CUSTOM_ID: flexible-task-distribution -:END: -Users acting as clients retain full control over how tasks are batched -and assigned to nodes, creating endless possibilities for optimising -performance based on specific use cases. - -** Latest tutorial -:PROPERTIES: -:CUSTOM_ID: latest-tutorial -:END: -[[https://www.youtube.com/watch?v=OMwCpedu5cs%22][[[https://i.ytimg.com/vi/OMwCpedu5cs/hqdefault.jpg]]]] - -#+begin_html - -#+end_html - -#+begin_html - -#+end_html - -#+begin_html - -#+end_html - -#+begin_html - -#+end_html - -#+begin_html - -#+end_html - -#+begin_html - -#+end_html - -** Extend your application with P2PRC -:PROPERTIES: -:CUSTOM_ID: extend-your-application-with-p2prc -:END: -#+begin_src go -package main - -import ( - "fmt" - "github.com/Akilan1999/p2p-rendering-computation/abstractions" -) - -func main() { - _, err := abstractions.Init(nil) - if err != nil { - fmt.Println(err) - return - } - - // start p2prc - _, err = abstractions.Start() - if err != nil { - fmt.Println(err) - return - } - - // Run server till termination - for { - - } -} -#+end_src - -#+begin_html - -#+end_html - -** Find out more -:PROPERTIES: -:CUSTOM_ID: find-out-more -:END: -As we are working on the open source project p2prc (i.e p2p network -designed for computation).If you are interested in participating as a -contributor or just providing feedback on new features to build or even -just curious about new features added to the project do file an Issue or -send an email to me@akilan.io. - -[[https://github.com/Gaurav-Gosain][[[https://api.star-history.com/svg?repos=Akilan1999/p2p-rendering-computation&type=Date]]]] diff --git a/abstractions/base.go b/abstractions/base.go index a6dafb9..979a99c 100644 --- a/abstractions/base.go +++ b/abstractions/base.go @@ -52,8 +52,8 @@ func Start() (*gin.Engine, error) { } // MapPort Creates a reverse proxy connection and maps the appropriate port -func MapPort(port string, domainName string, serverAddress string) (entireAddress string, mapPort string, err error) { - entireAddress, mapPort, err = server.MapPort(port, domainName, serverAddress) +func MapPort(port string, domainName string, serverAddress string) (response *client.ResponseMAPPort, err error) { + response, err = client.MAPPort(port, domainName, serverAddress) return } diff --git a/client/MAPPort.go b/client/MAPPort.go index e65776a..b20a4a7 100644 --- a/client/MAPPort.go +++ b/client/MAPPort.go @@ -3,21 +3,30 @@ package client import ( "github.com/Akilan1999/p2p-rendering-computation/config" "io/ioutil" + "net" "net/http" ) type ResponseMAPPort struct { - IPAddress string + IPAddress string + PortNo string + EntireAddress string } -func MAPPort(port string, domainName string) (*ResponseMAPPort, error) { +func MAPPort(port string, domainName string, ServerAddress string) (*ResponseMAPPort, error) { Config, err := config.ConfigInit(nil, nil) if err != nil { return nil, err } + URL := "http://0.0.0.0:" + Config.ServerPort + + if ServerAddress != "" { + URL = "http://" + ServerAddress + } + //if version == "version 6" { - URL := "http://0.0.0.0:" + Config.ServerPort + "/MAPPort?port=" + port + "&domain_name=" + domainName + URL = URL + "/MAPPort?port=" + port + "&domain_name=" + domainName //} else { // URL = "http://" + IP + ":" + serverPort + "/server_info" //} @@ -32,8 +41,15 @@ func MAPPort(port string, domainName string) (*ResponseMAPPort, error) { return nil, err } + host, Exposedport, err := net.SplitHostPort(string(byteValue)) + if err != nil { + return nil, err + } + var response ResponseMAPPort - response.IPAddress = string(byteValue) + response.IPAddress = host + response.PortNo = Exposedport + response.EntireAddress = string(byteValue) return &response, nil } diff --git a/cmd/action.go b/cmd/action.go index 6349d74..19e8d96 100644 --- a/cmd/action.go +++ b/cmd/action.go @@ -283,7 +283,7 @@ var CliAction = func(ctx *cli.Context) error { } if MAPPort != "" { - address, err := client.MAPPort(MAPPort, DomainName) + address, err := client.MAPPort(MAPPort, DomainName, RemoteAddress) if err != nil { return err } diff --git a/cmd/flags.go b/cmd/flags.go index 04b3996..486f9fb 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -30,6 +30,7 @@ var ( RemoveContainerGroup bool RemoveGroup string MAPPort string + RemoteAddress string DomainName string //FRPProxy bool // Generate only allowed in dev release @@ -43,7 +44,6 @@ var ( ) var AppConfigFlags = []cli.Flag{ - // Deprecated to be implemented using GRPC &cli.BoolFlag{ Name: "Server", Aliases: []string{"s"}, @@ -213,6 +213,13 @@ var AppConfigFlags = []cli.Flag{ EnvVars: []string{"MAPPORT"}, Destination: &MAPPort, }, + &cli.StringFlag{ + Name: "RemoteAddress", + Aliases: []string{"ra"}, + Usage: "Parameter for Map port for a remote address", + EnvVars: []string{"REMOTEADDRESS"}, + Destination: &RemoteAddress, + }, &cli.StringFlag{ Name: "DomainName", Aliases: []string{"dn"}, diff --git a/main.md.org b/main.md.org deleted file mode 100644 index 606d3f2..0000000 --- a/main.md.org +++ /dev/null @@ -1,40 +0,0 @@ -#+begin_html - -#+end_html - -* p2p-rendering-computation -:PROPERTIES: -:CUSTOM_ID: p2p-rendering-computation -:END: -#+begin_src go -import "github.com/Akilan1999/p2p-rendering-computation" -#+end_src - -** Index -:PROPERTIES: -:CUSTOM_ID: index -:END: -- [[#variables][Variables]] - -** Variables -:PROPERTIES: -:CUSTOM_ID: variables -:END: - -#+begin_src go -var List_servers, Ip_table bool -#+end_src - -Varaibles if mode is client - -#+begin_src go -var OS, Pull_location, Run_script string -#+end_src - -VERSION specifies the version of the platform - -#+begin_src go -var VERSION = "2.0.0" -#+end_src - -Generated by [[https://github.com/princjef/gomarkdoc][gomarkdoc]] diff --git a/server/server.go b/server/server.go index 4585dd2..8086d67 100644 --- a/server/server.go +++ b/server/server.go @@ -11,9 +11,7 @@ import ( "github.com/Akilan1999/p2p-rendering-computation/p2p/frp" "github.com/Akilan1999/p2p-rendering-computation/server/docker" "github.com/gin-gonic/gin" - "io" "io/ioutil" - "net" "net/http" "os/user" "strconv" @@ -195,7 +193,7 @@ func Server() (*gin.Engine, error) { r.GET("/MAPPort", func(c *gin.Context) { Ports := c.DefaultQuery("port", "0") DomainName := c.DefaultQuery("domain_name", "") - url, _, err := MapPort(Ports, DomainName, "") + url, _, err := MapPort(Ports, DomainName) if err != nil { c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", err)) } @@ -298,7 +296,7 @@ func Server() (*gin.Engine, error) { ProxyIpAddr.EscapeImplementation = "FRP" if config.BareMetal { - _, SSHPort, err := MapPort("22", "", "") + _, SSHPort, err := MapPort("22", "") if err != nil { return nil, err } @@ -375,33 +373,33 @@ func Server() (*gin.Engine, error) { return r, nil } -func MapPort(port string, domainName string, serverAddress string) (string, string, error) { +func MapPort(port string, domainName string) (string, string, error) { // if server address is provided to do call RESTAPI to remotely open port. - if serverAddress != "" { - requestURL := fmt.Sprintf("http://%v/MAPPort?port=%v&domain_name=%v", serverAddress, port, domainName) - req, err := http.NewRequest(http.MethodGet, requestURL, nil) - if err != nil { - return "", "", err - } - - res, err := http.DefaultClient.Do(req) - if err != nil { - return "", "", err - } - - resBody, err := io.ReadAll(res.Body) - if err != nil { - return "", "", err - } - - _, Exposedport, err := net.SplitHostPort(string(resBody)) - if err != nil { - return "", "", err - } - - return string(resBody), Exposedport, nil - } + //if serverAddress != "" { + // requestURL := fmt.Sprintf("http://%v/MAPPort?port=%v&domain_name=%v", serverAddress, port, domainName) + // req, err := http.NewRequest(http.MethodGet, requestURL, nil) + // if err != nil { + // return "", "", err + // } + // + // res, err := http.DefaultClient.Do(req) + // if err != nil { + // return "", "", err + // } + // + // resBody, err := io.ReadAll(res.Body) + // if err != nil { + // return "", "", err + // } + // + // _, Exposedport, err := net.SplitHostPort(string(resBody)) + // if err != nil { + // return "", "", err + // } + // + // return string(resBody), Exposedport, nil + //} //Get Server port based on the config file config, err := config.ConfigInit(nil, nil)