From 8f1278192804d3b3e44008b946e3c2d7d4252802 Mon Sep 17 00:00:00 2001 From: Akilan Date: Wed, 25 Jan 2023 01:12:36 +0000 Subject: [PATCH] fixed changes to spwan docker container --- server/server.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/server/server.go b/server/server.go index df71181..edced7b 100644 --- a/server/server.go +++ b/server/server.go @@ -18,6 +18,12 @@ import ( func Server() error { r := gin.Default() + //Get Server port based on the config file + config, err := config.ConfigInit() + if err != nil { + return err + } + // update IPTable with new port and ip address and update ip table var ProxyIpAddr p2p.IpAddress var lowestLatencyIpAddress p2p.IpAddress @@ -30,10 +36,6 @@ func Server() error { // Speed test with 50 mbps r.GET("/50", func(c *gin.Context) { // Get Path from config - config, err := config.ConfigInit() - if err != nil { - c.String(http.StatusOK, fmt.Sprint(err)) - } c.File(config.SpeedTestFile) }) @@ -119,7 +121,7 @@ func Server() error { } // Ensures that FRP is triggered only if a proxy address is provided - if ProxyIpAddr.Ipv4 != "" && c.Request.Host != "localhost:8088" && c.Request.Host != "0.0.0.0:8088" { + if ProxyIpAddr.Ipv4 != "" && c.Request.Host != "localhost:"+config.ServerPort && c.Request.Host != "0.0.0.0:"+config.ServerPort { resp, err = frp.StartFRPCDockerContainer(ProxyIpAddr.Ipv4, lowestLatencyIpAddress.ServerPort, resp) if err != nil { c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", err)) @@ -158,12 +160,6 @@ func Server() error { c.String(http.StatusOK, strconv.Itoa(port)) }) - //Get Server port based on the config file - config, err := config.ConfigInit() - if err != nil { - return err - } - // If there is a proxy port specified // then starts the FRP server //if config.FRPServerPort != "0" {