diff --git a/ctlrpc.go b/ctlrpc.go index 94aafd0..0b930bb 100644 --- a/ctlrpc.go +++ b/ctlrpc.go @@ -13,12 +13,22 @@ type ControlRPC struct { } // Start a server -func (c *ControlRPC) Start(in *int, out *int) os.Error { +func (c *ControlRPC) Start(Id int64, out *int) os.Error { + server, exists := servers[Id] + if !exists { + return os.NewError("no such server") + } + _ = server return nil } // Stop a server -func (c *ControlRPC) Stop(in *int, out *int) os.Error { +func (c *ControlRPC) Stop(Id int64, out *int) os.Error { + server, exists := servers[Id] + if !exists { + return os.NewError("no such server") + } + _ = server return nil } @@ -30,7 +40,11 @@ type ConfigValue struct { // Set a config value func (c *ControlRPC) SetConfig(in *ConfigValue, out *ConfigValue) os.Error { - servers[in.Id].cfg.Set(in.Key, in.Value) + server, exists := servers[in.Id] + if !exists { + return os.NewError("no such server") + } + server.cfg.Set(in.Key, in.Value) out.Id = in.Id out.Key = in.Key out.Value = in.Value @@ -39,8 +53,12 @@ func (c *ControlRPC) SetConfig(in *ConfigValue, out *ConfigValue) os.Error { // Get a config value func (c *ControlRPC) GetConfig(in *ConfigValue, out *ConfigValue) os.Error { + server, exists := servers[in.Id] + if !exists { + return os.NewError("no such server") + } out.Id = in.Id out.Key = in.Key - out.Value = servers[in.Id].cfg.StringValue(in.Key) + out.Value = server.cfg.StringValue(in.Key) return nil }