-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
p2p: add start timestamp, net speed and misc
- Loading branch information
Showing
4 changed files
with
31 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,33 @@ | ||
package node | ||
|
||
import "os" | ||
import ( | ||
"os" | ||
|
||
"github.com/NetSepio/erebrus/util/pkg/speedtest" | ||
) | ||
|
||
type NodeStatus struct { | ||
Id string `json:"id"` | ||
HttpPort string `json:"httpPort"` | ||
Domain string `json:"domain"` | ||
Address string `json:"address"` | ||
Region string `json:"region"` | ||
Id string `json:"id"` | ||
HttpPort string `json:"httpPort"` | ||
Domain string `json:"domain"` | ||
Address string `json:"address"` | ||
Region string `json:"region"` | ||
DownloadSpeed float64 `json:"downloadSpeed"` | ||
UploadSpeed float64 `json:"uploadSpeed"` | ||
StartTimeStamp int64 `json:"startTimeStamp"` | ||
} | ||
|
||
func CreateNodeStatus(address string, id string) *NodeStatus { | ||
func CreateNodeStatus(address string, id string, startTimeStamp int64) *NodeStatus { | ||
speedtestResult, _ := speedtest.GetSpeedtestResults() | ||
nodeStatus := &NodeStatus{ | ||
HttpPort: os.Getenv("HTTP_PORT"), | ||
Domain: os.Getenv("DOMAIN"), | ||
Address: address, | ||
Region: os.Getenv("REGION"), | ||
Id: id, | ||
HttpPort: os.Getenv("HTTP_PORT"), | ||
Domain: os.Getenv("DOMAIN"), | ||
Address: address, | ||
Region: os.Getenv("REGION"), | ||
Id: id, | ||
DownloadSpeed: speedtestResult.DownloadSpeed, | ||
UploadSpeed: speedtestResult.UploadSpeed, | ||
StartTimeStamp: startTimeStamp, | ||
} | ||
return nodeStatus | ||
} |