enable proxy when host is relay and on relayed hosts, add relay related feilds to api host model

This commit is contained in:
Abhishek Kondur
2023-01-09 23:03:23 +05:30
parent 6100f8a466
commit d373e90597
6 changed files with 31 additions and 15 deletions

View File

@@ -59,6 +59,7 @@ func CreateHostRelay(relay models.HostRelayRequest) (relayHost *models.Host, rel
return
}
relayHost.IsRelay = true
relayHost.ProxyEnabled = true
relayHost.RelayedHosts = relay.RelayedHosts
err = UpsertHost(relayHost)
if err != nil {
@@ -76,6 +77,7 @@ func SetRelayedHosts(setRelayed bool, relayHostID string, relayedHostIDs []strin
if setRelayed {
host.IsRelayed = true
host.RelayedBy = relayHostID
host.ProxyEnabled = true
} else {
host.IsRelayed = false
host.RelayedBy = ""
@@ -154,8 +156,10 @@ func ValidateRelay(relay models.RelayRequest) error {
return err
}
// TODO
func ValidateHostRelay(relay models.HostRelayRequest) error {
if len(relay.RelayedHosts) == 0 {
return errors.New("relayed hosts are empty")
}
return nil
}