Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Comments #1658

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions pkg/visor/remote_hypervisor.go

This file was deleted.

21 changes: 0 additions & 21 deletions pkg/visor/rpc_client_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,13 @@ func isDone(ctx context.Context) bool {

// ServeRPCClient repetitively dials to a remote dmsg address and serves a RPC server to that address.
func ServeRPCClient(ctx context.Context, log logrus.FieldLogger, dmsgC *dmsg.Client, rpcS *rpc.Server, rAddr dmsg.Addr, errCh chan<- error) {
//func ServeRPCClient(ctx context.Context, log logrus.FieldLogger, autoPeerIP string, dmsgC *dmsg.Client, rpcS *rpc.Server, rAddr dmsg.Addr, errCh chan<- error) {
const maxBackoff = time.Second * 5
retry := netutil.NewRetrier(log, netutil.DefaultInitBackoff, maxBackoff, netutil.DefaultTries, netutil.DefaultFactor)
// pubkey := cipher.PubKey{}
for {
var conn net.Conn
err := retry.Do(ctx, func() (rErr error) {
log.Info("Dialing...")
addr := dmsg.Addr{PK: rAddr.PK, Port: rAddr.Port}
/*
if autoPeerIP != "" {
hvkey, err := FetchHvPk(autoPeerIP)
if err != nil {
log.Error("error autopeering")
} else {
hvkey = strings.TrimSuffix(hvkey, "\n")
hypervisorPKsSlice := strings.Split(hvkey, ",")
for _, pubkeyString := range hypervisorPKsSlice {
//use pubkey.Set as validation or to convert the string to a pubkey
if err := pubkey.Set(pubkeyString); err != nil {
log.Warnf("Cannot add %s PK as remote hypervisor PK due to: %s", pubkeyString, err)
continue
}
addr.PK = pubkey
}
}
}
*/
conn, rErr = dmsgC.Dial(ctx, addr)
return rErr
})
Expand Down
58 changes: 1 addition & 57 deletions pkg/visor/visor.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ type Visor struct {
// produced by concurrent parts of modules
runtimeErrors chan error

isServicesHealthy *internalHealthInfo
// autoPeer bool // autoPeer=true tells the visor to query the http endpoint of the hypervisor on the local network for the hypervisor's public key when connectio to the hypervisor is lost
// autoPeerIP string // autoPeerCmd is the command string used to return the public key of the hypervisor
isServicesHealthy *internalHealthInfo
remoteVisors map[cipher.PubKey]Conn // remote hypervisors the visor is attempting to connect to
connectedHypervisors map[cipher.PubKey]bool // remote hypervisors the visor is currently connected to
allowedPorts map[int]bool
Expand Down Expand Up @@ -183,10 +181,6 @@ func run(conf *visorconfig.V1) error {
}
}

// if isAutoPeer {
// conf = initAutopeer(conf)
// }

if logLvl != "" {
//validate & set log level
_, err := logging.LevelFromString(logLvl)
Expand Down Expand Up @@ -320,10 +314,6 @@ func NewVisor(ctx context.Context, conf *visorconfig.V1) (*Visor, bool) {
if !v.processRuntimeErrs() {
return nil, false
}
// if isAutoPeer {
// v.autoPeer = true
// v.autoPeerIP = autoPeerIP
// }
log.Info("Startup complete.")
return v, true
}
Expand All @@ -350,52 +340,6 @@ func (v *Visor) isStunReady() bool {
}
}

/*
func initAutopeer(conf *visorconfig.V1) *visorconfig.V1 {
log := mLog.PackageLogger("visor:autopeer")

if !isAutoPeer {
log.WithError(fmt.Errorf("erroneous initialization")).Error("error autopeering")
return conf
}
//autopeering should only happen when there is no local or remote hypervisor set in the config.
//and hence can be disabled by setting these. the visor may still be invoked with autopeering flag.
if conf.Hypervisor != nil {
isAutoPeer = false
log.Info("Local hypervisor running, disabling autopeer")
return conf
}

if len(conf.Hypervisors) > 0 {
isAutoPeer = false
log.Info("%d Remote hypervisor(s) set in config; disabling autopeer", len(conf.Hypervisors))
log.Info(conf.Hypervisors)
return conf
}

log.Info("Autopeer: ", isAutoPeer)
hvkey, err := FetchHvPk(autoPeerIP)
if err != nil {
log.WithError(err).Error("error autopeering")
return conf
}

pubkey := cipher.PubKey{}
hvkey = strings.TrimSpace(hvkey)
hypervisorPKsSlice := strings.Split(hvkey, ",")
for _, pubkeyString := range hypervisorPKsSlice {
if err := pubkey.Set(pubkeyString); err != nil {
log.Warnf("Cannot add %s PK as remote hypervisor PK due to: %s", pubkeyString, err)
continue
}
log.Infof("%s PK added as remote hypervisor PK", pubkeyString)
conf.Hypervisors = append(conf.Hypervisors, pubkey)
}

return conf
}
*/

func initLogger() *logging.MasterLogger {
mLog := logging.NewMasterLogger()
if syslogAddr != "" {
Expand Down
Loading