From 7216b0a6aedbcad571180a33a02b24f0c1f0d176 Mon Sep 17 00:00:00 2001 From: Guilhem Fanton Date: Thu, 11 Apr 2019 16:40:56 +0200 Subject: [PATCH] fix(desktop): update desktop bridge --- .circleci/config.yml | 2 +- .../bridge/service/daemon/daemon.pb.json | 16 +- .../components/Screens/Accounts/Auth.js | 12 +- .../desktop/coreinterface/core.go | 2 +- client/react-native/desktop/daemon.go | 29 +- client/react-native/desktop/go.mod | 2 +- client/react-native/desktop/main.go | 46 ++- core/cmd/berty/daemon.go | 11 +- core/daemon/daemon.go | 30 +- core/daemon/daemon.pb.go | 364 ++++++++++++------ core/daemon/daemon.proto | 9 +- core/daemon/run.go | 8 +- 12 files changed, 345 insertions(+), 186 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1ec80bc8a5..a8f51a27b5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -99,7 +99,7 @@ jobs: generate: docker: - - image: bertychat/protoc:v8 + - image: bertychat/protoc:v9 working_directory: /go/src/berty.tech environment: GOPATH: /go diff --git a/client/react-native/common/bridge/service/daemon/daemon.pb.json b/client/react-native/common/bridge/service/daemon/daemon.pb.json index ea1fb9e34f..657a1f010a 100644 --- a/client/react-native/common/bridge/service/daemon/daemon.pb.json +++ b/client/react-native/common/bridge/service/daemon/daemon.pb.json @@ -26,7 +26,7 @@ "responseType": "GetPortResponse" }, "Initialize": { - "requestType": "Void", + "requestType": "Config", "responseType": "Void" }, "IsBotRunning": { @@ -50,7 +50,7 @@ "responseType": "Void" }, "Start": { - "requestType": "Config", + "requestType": "StartRequest", "responseType": "Void" }, "StartBot": { @@ -82,6 +82,14 @@ "Void": { "fields": {} }, + "StartRequest": { + "fields": { + "nickname": { + "type": "string", + "id": 1 + } + } + }, "NetworkConfig": { "fields": { "json": { @@ -205,10 +213,6 @@ "SwarmKeyPath": { "type": "string", "id": 24 - }, - "nickname": { - "type": "string", - "id": 25 } } }, diff --git a/client/react-native/common/components/Screens/Accounts/Auth.js b/client/react-native/common/components/Screens/Accounts/Auth.js index 0eba3876be..eea65cc5e3 100644 --- a/client/react-native/common/components/Screens/Accounts/Auth.js +++ b/client/react-native/common/components/Screens/Accounts/Auth.js @@ -81,12 +81,12 @@ class Auth extends PureComponent { return test } - init = async () => { + init = async (config) => { const { t, bridge } = this.props this.setState({ loading: true, message: t('core.initializing') }) try { - await bridge.initialize({}) + await bridge.initialize(config) } catch (err) { console.warn('initialize', err) } @@ -105,14 +105,14 @@ class Auth extends PureComponent { } } - start = async config => { + start = async nickname => { const { t, bridge } = this.props this.setState({ loading: true, message: t('daemon.initializing') }) try { - await bridge.start(config) + await bridge.start({ nickname }) } catch (error) { - throw error + console.warn(error) } } @@ -133,7 +133,7 @@ class Auth extends PureComponent { nickname = list[0] } - // await this.start(nickname) // @FIXME: implement this later + await this.start(nickname) // @FIXME: implement this later const context = await this.getRelayContext() getAvailableUpdate(context).then(update => { this.props.updateContext.setState(update) diff --git a/client/react-native/desktop/coreinterface/core.go b/client/react-native/desktop/coreinterface/core.go index ce807f7b63..8663a7df1c 100644 --- a/client/react-native/desktop/coreinterface/core.go +++ b/client/react-native/desktop/coreinterface/core.go @@ -127,7 +127,7 @@ func Start(nickname string) (interface{}, error) { cfg = cfg.WithNickname(nickname) cfg = cfg.WithLoggerDriver(&CliLogger{}) - return nil, core.Start(cfg) + return nil, fmt.Errorf("cannot start client") } func Restart() (interface{}, error) { diff --git a/client/react-native/desktop/daemon.go b/client/react-native/desktop/daemon.go index 32b119603c..1ea621123e 100644 --- a/client/react-native/desktop/daemon.go +++ b/client/react-native/desktop/daemon.go @@ -13,26 +13,26 @@ import ( ) type DaemonDesktop struct { - daemon *daemon.Daemon + bridge *daemon.Daemon server *grpc.Server conn *grpc.ClientConn } func NewDaemonDesktop() (*DaemonDesktop, error) { - daemon := daemon.New() + bridge := daemon.New() iogrpc := helper.NewIOGrpc() dialer := iogrpc.NewDialer() - listener := iogrpc.NewListener() + listener := iogrpc.Listener() dialOpts := append([]grpc.DialOption{ grpc.WithInsecure(), - grpc.WithDialer(icdialer), + grpc.WithDialer(dialer), }) gs := grpc.NewServer() - daemon.RegisterDaemonServer(gs, daemon) + daemon.RegisterDaemonServer(gs, bridge) conn, err := grpc.Dial("", dialOpts...) if err != nil { @@ -45,12 +45,12 @@ func NewDaemonDesktop() (*DaemonDesktop, error) { } }() - return &NativeBridge{ - daemon: daemon, + return &DaemonDesktop{ + bridge: bridge, server: gs, conn: conn, - } + }, nil } func stringPayload(message json.RawMessage) (string, error) { @@ -63,13 +63,14 @@ func stringPayload(message json.RawMessage) (string, error) { return payload, nil } -func (d *DaemonDesktop) Start(ctx context.Context, cfg *daemon.Config) error { - return d.daemon.Start(ctx, cfg) +func (d *DaemonDesktop) Initialize(ctx context.Context, req *daemon.Config) error { + _, err := d.bridge.Initialize(ctx, req) + return err } func (d *DaemonDesktop) handleMessages(_ *astilectron.Window, m bootstrap.MessageIn) (interface{}, error) { - method := m.name - encoded, err := stringPayload(m.payload) + method := m.Name + encoded, err := stringPayload(m.Payload) if err != nil { return nil, err } @@ -81,13 +82,13 @@ func (d *DaemonDesktop) handleMessages(_ *astilectron.Window, m bootstrap.Messag return &res, nil } -func (n *DaemonDesktop) Invoke(method string, msgIn string) (string, error) { +func (d *DaemonDesktop) Invoke(method string, msgIn string) (string, error) { in, err := helper.NewLazyMessage().FromBase64(msgIn) if err != nil { return "", err } out := helper.NewLazyMessage() - err := n.conn.Invoke(context.TODO(), method, in, out, helper.GrpcCallWithLazyCodec()) + err = d.conn.Invoke(context.TODO(), method, in, out, helper.GrpcCallWithLazyCodec()) return out.Base64(), err } diff --git a/client/react-native/desktop/go.mod b/client/react-native/desktop/go.mod index da7ec7346e..cba100cb63 100644 --- a/client/react-native/desktop/go.mod +++ b/client/react-native/desktop/go.mod @@ -12,10 +12,10 @@ require ( github.com/asticode/go-astilog v1.0.0 github.com/asticode/go-bindata v0.0.0-20151023091102-a0ff2567cfb7 // indirect github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 - github.com/pkg/errors v0.8.1 github.com/sam-kamerer/go-plister v0.0.0-20190202124357-57f251aa88ff // indirect github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0 go.uber.org/zap v1.9.1 + google.golang.org/grpc v1.19.0 ) replace berty.tech/core v0.0.0 => ../../../core diff --git a/client/react-native/desktop/main.go b/client/react-native/desktop/main.go index 263843cac4..6cd74e8bcb 100644 --- a/client/react-native/desktop/main.go +++ b/client/react-native/desktop/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "errors" "flag" "fmt" @@ -8,6 +9,8 @@ import ( "berty.tech/client/react-native/desktop/coreinterface" "berty.tech/core/daemon" + network_config "berty.tech/core/network/config" + "berty.tech/core/pkg/deviceinfo" "berty.tech/core/pkg/logmanager" "go.uber.org/zap" @@ -40,11 +43,19 @@ func getStorageDir() (string, error) { } func main() { + storagePath, err := getStorageDir() + if err != nil { + panic(err) + } - storagePath, error := getStorageDir() + if err = deviceinfo.SetStoragePath(storagePath); err != nil { + panic(err) + } + + fmt.Println(storagePath) sqlConfig := &daemon.SQLConfig{ - Path: opts.sql.path, - Key: opts.sql.key, + Path: fmt.Sprintf("%s/%s", storagePath, "berty.state.db"), + Key: "s3cur3", } config := &daemon.Config{ @@ -56,30 +67,28 @@ func main() { InitOnly: false, WithBot: false, Notification: true, - ApnsCerts: nil, - ApnsDevVoipCerts: nil, - FcmAPIKeys: nil, - PrivateKeyFile: nil, + ApnsCerts: []string{}, + ApnsDevVoipCerts: []string{}, + FcmAPIKeys: []string{}, + PrivateKeyFile: "", PeerCache: true, Identity: "", Bootstrap: network_config.DefaultBootstrap, NoP2P: false, BindP2P: []string{}, TransportP2P: []string{}, - Hop: false, + Hop: true, Ble: true, Mdns: true, DhtServer: true, PrivateNetwork: true, - SwarmKeyPath: true, - Nickname: "berty-desktop", + SwarmKeyPath: "", } // Init flag.Parse() t := true - logman, err := logmanager.New(logmanager.Opts{ RingSize: 10 * 1024 * 1024, LogLevel: "debug", @@ -94,16 +103,31 @@ func main() { zap.L().Debug("Berty desktop client started") astilog.SetDefaultLogger() + homepageUrl := "index.html" if homepage != nil { homepageUrl = *homepage } + startRequest := &daemon.StartRequest{ + Nickname: "daemon-desktop", + } + d, err := NewDaemonDesktop() if err != nil { panic(err) } + if err := d.Initialize(context.Background(), config); err != nil { + panic(err) + } + + if _, err := d.bridge.Start(context.Background(), startRequest); err != nil { + panic(err) + } + + zap.L().Debug("Berty desktop client started") + // Run bootstrap logger().Debug(fmt.Sprintf("Running app built at %s", BuiltAt)) if err := bootstrap.Run(bootstrap.Options{ diff --git a/core/cmd/berty/daemon.go b/core/cmd/berty/daemon.go index 7185552107..cdcb87710f 100644 --- a/core/cmd/berty/daemon.go +++ b/core/cmd/berty/daemon.go @@ -202,7 +202,10 @@ func runDaemon(opts *daemonOptions) error { DhtServer: opts.dhtServer, PrivateNetwork: opts.PrivateNetwork, SwarmKeyPath: opts.SwarmKeyPath, - Nickname: opts.nickname, + } + + startRequest := &daemon.StartRequest{ + Nickname: opts.nickname, } dlogger := zap.L().Named("daemon.grpc") @@ -233,7 +236,11 @@ func runDaemon(opts *daemonOptions) error { d.Notification = notification.NewDesktopNotification() } - if _, err := d.Start(context.Background(), config); err != nil { + if _, err := d.Initialize(context.Background(), config); err != nil { + return err + } + + if _, err := d.Start(context.Background(), startRequest); err != nil { return err } diff --git a/core/daemon/daemon.go b/core/daemon/daemon.go index 5f714b3357..3295bb2ac9 100644 --- a/core/daemon/daemon.go +++ b/core/daemon/daemon.go @@ -69,28 +69,33 @@ func getLocalIP() (string, error) { return localIP, nil } -func (d *Daemon) Start(ctx context.Context, cfg *Config) (*Void, error) { +// @TODO: implem this +func (d *Daemon) Initialize(ctx context.Context, cfg *Config) (*Void, error) { + d.config = cfg + return &Void{}, nil +} + +func (d *Daemon) Start(ctx context.Context, req *StartRequest) (*Void, error) { var err error - if cfg == nil { - return &Void{}, fmt.Errorf("core empty configuration") + if d.config == nil || d.config.SqlOpts == nil { + return &Void{}, errors.New("no config/SqlPath set, initialize first") } - currentAccount, _ := account.Get(d.rootContext, cfg.Nickname) + currentAccount, _ := account.Get(d.rootContext, req.Nickname) if currentAccount != nil { // daemon already started, no errors to return return &Void{}, fmt.Errorf("daemon already started") } - d.accountName = cfg.Nickname - d.config = cfg + d.accountName = req.Nickname initialState := account.StateDB{ BotMode: initialBotMode, LocalGRPC: initiallocalGRPC, } - d.appConfig, err = account.OpenStateDB(cfg.SqlOpts.Path, initialState) + d.appConfig, err = account.OpenStateDB(d.config.SqlOpts.Path, initialState) if err != nil { return &Void{}, errors.Wrap(err, "state DB init failed") } @@ -103,7 +108,7 @@ func (d *Daemon) Start(ctx context.Context, cfg *Config) (*Void, error) { var cctx context.Context cctx, d.cancel = context.WithCancel(d.rootContext) - return &Void{}, d.daemon(cctx, cfg) + return &Void{}, d.daemon(cctx, d.config, req.Nickname) } func (d *Daemon) DropDatabase(ctx context.Context, v *Void) (*Void, error) { @@ -173,15 +178,6 @@ func (d *Daemon) GetPort(context.Context, *Void) (*GetPortResponse, error) { }, nil } -// @TODO: implem this -func (d *Daemon) Initialize(context.Context, *Void) (*Void, error) { - // if err := setupLogger("debug", datastorePath, d.Logger); err != nil { - // return err - // } - - return &Void{}, fmt.Errorf("not implemented") -} - func (d *Daemon) IsBotRunning(context.Context, *Void) (*Void, error) { // currentAccount, _ := account.Get(d.rootContext, d.accountName) diff --git a/core/daemon/daemon.pb.go b/core/daemon/daemon.pb.go index a881f04bb5..3ff7677c31 100644 --- a/core/daemon/daemon.pb.go +++ b/core/daemon/daemon.pb.go @@ -63,6 +63,53 @@ func (m *Void) XXX_DiscardUnknown() { var xxx_messageInfo_Void proto.InternalMessageInfo +type StartRequest struct { + Nickname string `protobuf:"bytes,1,opt,name=nickname,proto3" json:"nickname,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *StartRequest) Reset() { *m = StartRequest{} } +func (m *StartRequest) String() string { return proto.CompactTextString(m) } +func (*StartRequest) ProtoMessage() {} +func (*StartRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_622b4ce7acb47fee, []int{1} +} +func (m *StartRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StartRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StartRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StartRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_StartRequest.Merge(m, src) +} +func (m *StartRequest) XXX_Size() int { + return m.Size() +} +func (m *StartRequest) XXX_DiscardUnknown() { + xxx_messageInfo_StartRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_StartRequest proto.InternalMessageInfo + +func (m *StartRequest) GetNickname() string { + if m != nil { + return m.Nickname + } + return "" +} + // @TODO: switch to protobuf message instead of json type NetworkConfig struct { Json string `protobuf:"bytes,1,opt,name=json,proto3" json:"json,omitempty"` @@ -75,7 +122,7 @@ func (m *NetworkConfig) Reset() { *m = NetworkConfig{} } func (m *NetworkConfig) String() string { return proto.CompactTextString(m) } func (*NetworkConfig) ProtoMessage() {} func (*NetworkConfig) Descriptor() ([]byte, []int) { - return fileDescriptor_622b4ce7acb47fee, []int{1} + return fileDescriptor_622b4ce7acb47fee, []int{2} } func (m *NetworkConfig) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -123,7 +170,7 @@ func (m *SQLConfig) Reset() { *m = SQLConfig{} } func (m *SQLConfig) String() string { return proto.CompactTextString(m) } func (*SQLConfig) ProtoMessage() {} func (*SQLConfig) Descriptor() ([]byte, []int) { - return fileDescriptor_622b4ce7acb47fee, []int{2} + return fileDescriptor_622b4ce7acb47fee, []int{3} } func (m *SQLConfig) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -192,7 +239,6 @@ type Config struct { DhtServer bool `protobuf:"varint,22,opt,name=dhtServer,proto3" json:"dhtServer,omitempty"` PrivateNetwork bool `protobuf:"varint,23,opt,name=PrivateNetwork,proto3" json:"PrivateNetwork,omitempty"` SwarmKeyPath string `protobuf:"bytes,24,opt,name=SwarmKeyPath,proto3" json:"SwarmKeyPath,omitempty"` - Nickname string `protobuf:"bytes,25,opt,name=nickname,proto3" json:"nickname,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -202,7 +248,7 @@ func (m *Config) Reset() { *m = Config{} } func (m *Config) String() string { return proto.CompactTextString(m) } func (*Config) ProtoMessage() {} func (*Config) Descriptor() ([]byte, []int) { - return fileDescriptor_622b4ce7acb47fee, []int{3} + return fileDescriptor_622b4ce7acb47fee, []int{4} } func (m *Config) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -399,13 +445,6 @@ func (m *Config) GetSwarmKeyPath() string { return "" } -func (m *Config) GetNickname() string { - if m != nil { - return m.Nickname - } - return "" -} - // @TODO: list all ports available type GetPortResponse struct { Port int32 `protobuf:"varint,1,opt,name=port,proto3" json:"port,omitempty"` @@ -418,7 +457,7 @@ func (m *GetPortResponse) Reset() { *m = GetPortResponse{} } func (m *GetPortResponse) String() string { return proto.CompactTextString(m) } func (*GetPortResponse) ProtoMessage() {} func (*GetPortResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_622b4ce7acb47fee, []int{4} + return fileDescriptor_622b4ce7acb47fee, []int{5} } func (m *GetPortResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -465,7 +504,7 @@ func (m *ListAccountsResponse) Reset() { *m = ListAccountsResponse{} } func (m *ListAccountsResponse) String() string { return proto.CompactTextString(m) } func (*ListAccountsResponse) ProtoMessage() {} func (*ListAccountsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_622b4ce7acb47fee, []int{5} + return fileDescriptor_622b4ce7acb47fee, []int{6} } func (m *ListAccountsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -503,6 +542,7 @@ func (m *ListAccountsResponse) GetAccounts() []string { func init() { proto.RegisterType((*Void)(nil), "berty.daemon.Void") + proto.RegisterType((*StartRequest)(nil), "berty.daemon.StartRequest") proto.RegisterType((*NetworkConfig)(nil), "berty.daemon.NetworkConfig") proto.RegisterType((*SQLConfig)(nil), "berty.daemon.SQLConfig") proto.RegisterType((*Config)(nil), "berty.daemon.Config") @@ -513,59 +553,60 @@ func init() { func init() { proto.RegisterFile("daemon/daemon.proto", fileDescriptor_622b4ce7acb47fee) } var fileDescriptor_622b4ce7acb47fee = []byte{ - // 827 bytes of a gzipped FileDescriptorProto + // 844 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xdd, 0x6e, 0x63, 0x35, - 0x10, 0x4e, 0x68, 0xf3, 0x37, 0x9b, 0xfe, 0xac, 0x5b, 0x76, 0x4d, 0x81, 0xa8, 0x3a, 0x08, 0x54, - 0x71, 0xd1, 0x55, 0xbb, 0x08, 0x2d, 0x8b, 0x40, 0xda, 0xa4, 0x4b, 0xa9, 0x5a, 0xb1, 0xe1, 0x04, - 0xf6, 0x82, 0x3b, 0xe7, 0x9c, 0x69, 0x63, 0x9a, 0xd8, 0x5e, 0x7b, 0xda, 0x12, 0x1e, 0x80, 0x1b, - 0x5e, 0x80, 0x47, 0xe2, 0x92, 0x47, 0x40, 0xe5, 0x45, 0x90, 0x7d, 0x92, 0x34, 0x27, 0xa4, 0x88, - 0xc3, 0xd5, 0xf1, 0x7c, 0x33, 0xdf, 0x8c, 0xfd, 0x79, 0xc6, 0x3a, 0xb0, 0x95, 0x0a, 0x1c, 0x69, - 0xf5, 0x24, 0xfb, 0xec, 0x1b, 0xab, 0x49, 0xb3, 0x66, 0x1f, 0x2d, 0x8d, 0xf7, 0x33, 0x2c, 0xaa, - 0xc2, 0xea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, 0x9a, 0x17, 0xfd, 0x9f, 0x78, 0xaf, 0x60, 0xfd, 0xbb, 0x9e, + 0xd5, 0xb7, 0x6f, 0x7e, 0x4a, 0xd0, 0x84, 0x77, 0x7d, 0x99, 0x3e, 0xda, 0xfa, 0xde, 0xa4, 0xf7, + 0xcf, 0xca, 0x78, 0x8a, 0xfe, 0x6d, 0x62, 0x16, 0x7b, 0x6a, 0xee, 0xfd, 0x76, 0xd7, 0x28, 0xfe, + 0x7e, 0xd7, 0x28, 0xfe, 0x71, 0xd7, 0x28, 0xfe, 0xfa, 0x67, 0xa3, 0xf0, 0xc3, 0x93, 0x8c, 0x46, + 0x98, 0xf4, 0x9e, 0x27, 0xda, 0xe2, 0xf8, 0x3b, 0xa1, 0x5b, 0x0e, 0x1f, 0x0a, 0x2f, 0xfe, 0x0e, + 0x00, 0x00, 0xff, 0xff, 0x49, 0xf4, 0x93, 0xfa, 0x3f, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -584,13 +625,13 @@ type DaemonClient interface { GetLocalGrpcInfos(ctx context.Context, in *Void, opts ...grpc.CallOption) (*Void, error) GetNetworkConfig(ctx context.Context, in *Void, opts ...grpc.CallOption) (*NetworkConfig, error) GetPort(ctx context.Context, in *Void, opts ...grpc.CallOption) (*GetPortResponse, error) - Initialize(ctx context.Context, in *Void, opts ...grpc.CallOption) (*Void, error) + Initialize(ctx context.Context, in *Config, opts ...grpc.CallOption) (*Void, error) IsBotRunning(ctx context.Context, in *Void, opts ...grpc.CallOption) (*Void, error) ListAccounts(ctx context.Context, in *Void, opts ...grpc.CallOption) (*ListAccountsResponse, error) Panic(ctx context.Context, in *Void, opts ...grpc.CallOption) (*Void, error) Restart(ctx context.Context, in *Void, opts ...grpc.CallOption) (*Void, error) SetCurrentRoute(ctx context.Context, in *Void, opts ...grpc.CallOption) (*Void, error) - Start(ctx context.Context, in *Config, opts ...grpc.CallOption) (*Void, error) + Start(ctx context.Context, in *StartRequest, opts ...grpc.CallOption) (*Void, error) StartBot(ctx context.Context, in *Void, opts ...grpc.CallOption) (*Void, error) StartLocalGRPC(ctx context.Context, in *Void, opts ...grpc.CallOption) (*Void, error) StopBot(ctx context.Context, in *Void, opts ...grpc.CallOption) (*Void, error) @@ -643,7 +684,7 @@ func (c *daemonClient) GetPort(ctx context.Context, in *Void, opts ...grpc.CallO return out, nil } -func (c *daemonClient) Initialize(ctx context.Context, in *Void, opts ...grpc.CallOption) (*Void, error) { +func (c *daemonClient) Initialize(ctx context.Context, in *Config, opts ...grpc.CallOption) (*Void, error) { out := new(Void) err := c.cc.Invoke(ctx, "/berty.daemon.Daemon/Initialize", in, out, opts...) if err != nil { @@ -697,7 +738,7 @@ func (c *daemonClient) SetCurrentRoute(ctx context.Context, in *Void, opts ...gr return out, nil } -func (c *daemonClient) Start(ctx context.Context, in *Config, opts ...grpc.CallOption) (*Void, error) { +func (c *daemonClient) Start(ctx context.Context, in *StartRequest, opts ...grpc.CallOption) (*Void, error) { out := new(Void) err := c.cc.Invoke(ctx, "/berty.daemon.Daemon/Start", in, out, opts...) if err != nil { @@ -766,13 +807,13 @@ type DaemonServer interface { GetLocalGrpcInfos(context.Context, *Void) (*Void, error) GetNetworkConfig(context.Context, *Void) (*NetworkConfig, error) GetPort(context.Context, *Void) (*GetPortResponse, error) - Initialize(context.Context, *Void) (*Void, error) + Initialize(context.Context, *Config) (*Void, error) IsBotRunning(context.Context, *Void) (*Void, error) ListAccounts(context.Context, *Void) (*ListAccountsResponse, error) Panic(context.Context, *Void) (*Void, error) Restart(context.Context, *Void) (*Void, error) SetCurrentRoute(context.Context, *Void) (*Void, error) - Start(context.Context, *Config) (*Void, error) + Start(context.Context, *StartRequest) (*Void, error) StartBot(context.Context, *Void) (*Void, error) StartLocalGRPC(context.Context, *Void) (*Void, error) StopBot(context.Context, *Void) (*Void, error) @@ -858,7 +899,7 @@ func _Daemon_GetPort_Handler(srv interface{}, ctx context.Context, dec func(inte } func _Daemon_Initialize_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Void) + in := new(Config) if err := dec(in); err != nil { return nil, err } @@ -870,7 +911,7 @@ func _Daemon_Initialize_Handler(srv interface{}, ctx context.Context, dec func(i FullMethod: "/berty.daemon.Daemon/Initialize", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DaemonServer).Initialize(ctx, req.(*Void)) + return srv.(DaemonServer).Initialize(ctx, req.(*Config)) } return interceptor(ctx, in, info, handler) } @@ -966,7 +1007,7 @@ func _Daemon_SetCurrentRoute_Handler(srv interface{}, ctx context.Context, dec f } func _Daemon_Start_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Config) + in := new(StartRequest) if err := dec(in); err != nil { return nil, err } @@ -978,7 +1019,7 @@ func _Daemon_Start_Handler(srv interface{}, ctx context.Context, dec func(interf FullMethod: "/berty.daemon.Daemon/Start", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DaemonServer).Start(ctx, req.(*Config)) + return srv.(DaemonServer).Start(ctx, req.(*StartRequest)) } return interceptor(ctx, in, info, handler) } @@ -1189,6 +1230,33 @@ func (m *Void) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *StartRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StartRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Nickname) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintDaemon(dAtA, i, uint64(len(m.Nickname))) + i += copy(dAtA[i:], m.Nickname) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + func (m *NetworkConfig) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1532,14 +1600,6 @@ func (m *Config) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintDaemon(dAtA, i, uint64(len(m.SwarmKeyPath))) i += copy(dAtA[i:], m.SwarmKeyPath) } - if len(m.Nickname) > 0 { - dAtA[i] = 0xca - i++ - dAtA[i] = 0x1 - i++ - i = encodeVarintDaemon(dAtA, i, uint64(len(m.Nickname))) - i += copy(dAtA[i:], m.Nickname) - } if m.XXX_unrecognized != nil { i += copy(dAtA[i:], m.XXX_unrecognized) } @@ -1629,6 +1689,22 @@ func (m *Void) Size() (n int) { return n } +func (m *StartRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Nickname) + if l > 0 { + n += 1 + l + sovDaemon(uint64(l)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + func (m *NetworkConfig) Size() (n int) { if m == nil { return 0 @@ -1767,10 +1843,6 @@ func (m *Config) Size() (n int) { if l > 0 { n += 2 + l + sovDaemon(uint64(l)) } - l = len(m.Nickname) - if l > 0 { - n += 2 + l + sovDaemon(uint64(l)) - } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -1877,6 +1949,92 @@ func (m *Void) Unmarshal(dAtA []byte) error { } return nil } +func (m *StartRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDaemon + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StartRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StartRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Nickname", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDaemon + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDaemon + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDaemon + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Nickname = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDaemon(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthDaemon + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthDaemon + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *NetworkConfig) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2738,38 +2896,6 @@ func (m *Config) Unmarshal(dAtA []byte) error { } m.SwarmKeyPath = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 25: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Nickname", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowDaemon - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthDaemon - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthDaemon - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Nickname = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipDaemon(dAtA[iNdEx:]) diff --git a/core/daemon/daemon.proto b/core/daemon/daemon.proto index c4a6b4606f..6e8b9a94f5 100644 --- a/core/daemon/daemon.proto +++ b/core/daemon/daemon.proto @@ -9,13 +9,13 @@ service Daemon { rpc GetLocalGrpcInfos (Void) returns (Void) {}; rpc GetNetworkConfig (Void) returns (NetworkConfig) {}; rpc GetPort (Void) returns (GetPortResponse) {}; - rpc Initialize (Void) returns (Void) {}; + rpc Initialize (Config) returns (Void) {}; rpc IsBotRunning (Void) returns (Void) {}; rpc ListAccounts (Void) returns (ListAccountsResponse) {}; rpc Panic (Void) returns (Void) {}; rpc Restart (Void) returns (Void) {}; rpc SetCurrentRoute (Void) returns (Void) {}; - rpc Start (Config) returns (Void) {}; + rpc Start (StartRequest) returns (Void) {}; rpc StartBot (Void) returns (Void) {}; rpc StartLocalGRPC (Void) returns (Void) {}; rpc StopBot (Void) returns (Void) {}; @@ -26,6 +26,10 @@ service Daemon { message Void {} +message StartRequest { + string nickname = 1; +} + // @TODO: switch to protobuf message instead of json message NetworkConfig { string json = 1; @@ -64,7 +68,6 @@ message Config { bool dhtServer = 22; bool PrivateNetwork = 23; string SwarmKeyPath = 24; - string nickname = 25; } // @TODO: list all ports available diff --git a/core/daemon/run.go b/core/daemon/run.go index 3fdf6d1f1a..dae5f1a5f7 100644 --- a/core/daemon/run.go +++ b/core/daemon/run.go @@ -10,13 +10,12 @@ import ( "berty.tech/core/network" network_config "berty.tech/core/network/config" "berty.tech/core/pkg/banner" - "berty.tech/core/pkg/deviceinfo" "berty.tech/core/pkg/logmanager" "berty.tech/core/push" "go.uber.org/zap" ) -func (d *Daemon) daemon(ctx context.Context, cfg *Config) error { +func (d *Daemon) daemon(ctx context.Context, cfg *Config, accountName string) error { var err error a := &account.Account{} @@ -24,13 +23,12 @@ func (d *Daemon) daemon(ctx context.Context, cfg *Config) error { _ = logmanager.G().LogRotate() }() - deviceinfo.SetStoragePath("/tmp") accountOptions := account.Options{ // account.WithJaegerAddrName(jaegerAddr, jaegerName+":node"), - account.WithJaegerAddrName("jaeger.berty.io:6831", cfg.Nickname+":mobile"), + account.WithJaegerAddrName("jaeger.berty.io:6831", accountName+":mobile"), account.WithRing(logmanager.G().Ring()), - account.WithName(cfg.Nickname), + account.WithName(accountName), account.WithPassphrase(cfg.SqlOpts.Key), account.WithDatabase(&account.DatabaseOptions{ Path: ".",