pushed commit for remote map port

This commit is contained in:
2025-01-24 22:35:50 +00:00
parent 88a4e02e30
commit 4479a79912
11 changed files with 176 additions and 513 deletions

View File

@@ -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
}