improving client/server info command
This commit is contained in:
@@ -9,7 +9,23 @@ import (
|
||||
// GetInfo return the relevant repo specific info to the client
|
||||
func (Server *GVCServer) GetInfo(context echo.Context) error {
|
||||
repo := context.Param("repoName")
|
||||
return context.JSON(http.StatusAccepted, repo)
|
||||
config := Server.Config
|
||||
var repoInfo RepoInfoRequest // Create an engine struct that contains basic server info as well as all repo info
|
||||
for _, knownRepo := range config.Repos {
|
||||
if knownRepo.RepoName == repo {
|
||||
repoInfo.BindIP = config.BindIP
|
||||
repoInfo.Port = config.Port
|
||||
repoInfo.RawPort = config.RawPort
|
||||
repoInfo.Version = config.Version
|
||||
repoInfo.Repo = knownRepo
|
||||
clients := repoInfo.Repo.KnownClients
|
||||
for _, client := range clients { // Blank out the client keys
|
||||
client.Key = ""
|
||||
}
|
||||
repoInfo.Repo.KnownClients = clients
|
||||
}
|
||||
}
|
||||
return context.JSONPretty(http.StatusAccepted, repoInfo, " ")
|
||||
}
|
||||
|
||||
// Hello just verifies the server is running //TODO remove this, just extra shit we are sending
|
||||
|
@@ -10,3 +10,12 @@ type GVCServer struct {
|
||||
Config config.GvcServerConfig //contains our full server config
|
||||
Echo *echo.Echo // Contains our web server instance
|
||||
}
|
||||
|
||||
// RepoInfoRequest is for when a client requests info about a repo
|
||||
type RepoInfoRequest struct {
|
||||
Version string
|
||||
Port int // The port that the server will listed on
|
||||
BindIP string // What IP to bind the server to. If empty will bind to all interfaces
|
||||
RawPort int // The optional TCP port that the server will send raw files over
|
||||
Repo config.RepoConfig //IMPORTANT: We need to blank out the client keys when sending
|
||||
}
|
||||
|
Reference in New Issue
Block a user