Documentation ¶
Overview ¶
Example (Flags) ¶
package main import ( "flag" "fmt" "moul.io/u" "berty.tech/berty/v2/go/internal/initutil" ) func main() { // init manager manager, err := initutil.New(nil) if err != nil { panic(err) } defer manager.Close(nil) // configure flags fmt.Println("before", u.JSON(manager.Node.GRPC)) fs := flag.NewFlagSet("test", flag.ExitOnError) manager.SetupLocalProtocolServerFlags(fs) manager.SetupRemoteNodeFlags(fs) manager.SetupDefaultGRPCListenersFlags(fs) err = fs.Parse([]string{"-store.inmem", "-p2p.min-backoff=2m10s", "-node.remote-addr=1.2.3.4:5678"}) if err != nil { panic(err) } fmt.Println("after ", u.JSON(manager.Node.GRPC)) }
Output: before {} after {"RemoteAddr":"1.2.3.4:5678","Listeners":"/ip4/127.0.0.1/tcp/9091/grpc"}
Example (Noflags) ¶
package main import ( "context" "flag" "fmt" "os" "berty.tech/berty/v2/go/internal/initutil" "berty.tech/weshnet/pkg/protocoltypes" ) func main() { // disable ressources manager for the sake of this example os.Setenv("LIBP2P_RCMGR", "false") // init manager ctx := context.Background() manager, err := initutil.New(nil) if err != nil { panic(err) } defer manager.Close(nil) fs := flag.NewFlagSet("", flag.ExitOnError) manager.SetupLocalProtocolServerFlags(fs) manager.SetupRemoteNodeFlags(fs) fs.Parse([]string{}) // configure manager without flags manager.Node.GRPC.Listeners = "" manager.Node.Protocol.DisableIPFSNetwork = true manager.Datastore.InMemory = true // start a local berty protocol server _, err = manager.GetLocalProtocolServer() if err != nil { panic(err) } // build a client for the previously created protocol server client, err := manager.GetProtocolClient() if err != nil { panic(err) } // retrieve config ret, err := client.ServiceGetConfiguration(ctx, &protocoltypes.ServiceGetConfiguration_Request{}) if err != nil { panic(err) } // check that the reply is valid (cannot check hardcoded value, since it's random) fmt.Println(ret.AccountPK != nil) }
Output: go-libp2p resource manager protection disabled true
Index ¶
- Constants
- type Manager
- func (m *Manager) AdvancedHelp() string
- func (m *Manager) Close(prog *progress.Progress) error
- func (m *Manager) DisableIPFSNetwork()
- func (m *Manager) GetAccountIPFSDatastoreSalt() ([]byte, error)
- func (m *Manager) GetAccountMessengerDBSalt() ([]byte, error)
- func (m *Manager) GetAccountRootDatastoreSalt() ([]byte, error)
- func (m *Manager) GetAccountStorageKey() ([]byte, error)
- func (m *Manager) GetAppDataDir() (string, error)
- func (m *Manager) GetContext() context.Context
- func (m *Manager) GetDirectoryServiceDB() (*gorm.DB, error)
- func (m *Manager) GetGRPCClientConn() (*grpc.ClientConn, error)
- func (m *Manager) GetGRPCListeners() []berty_grpcutil.Listener
- func (m *Manager) GetGRPCServer() (*grpc.Server, *grpcgw.ServeMux, error)
- func (m *Manager) GetLifecycleManager() *lifecycle.Manager
- func (m *Manager) GetLocalIPFS() (ipfsutil.ExtendedCoreAPI, *ipfs_core.IpfsNode, error)
- func (m *Manager) GetLocalMessengerServer() (messengertypes.MessengerServiceServer, error)
- func (m *Manager) GetLocalProtocolServer() (weshnet.Service, error)
- func (m *Manager) GetLogger() (*zap.Logger, error)
- func (m *Manager) GetMessengerClient() (messengertypes.MessengerServiceClient, error)
- func (m *Manager) GetMessengerDB() (*gorm.DB, error)
- func (m *Manager) GetMetricsRegistry() (prometheus.Registerer, error)
- func (m *Manager) GetNotificationManager() (notification.Manager, error)
- func (m *Manager) GetOrbitDB() (*weshnet.WeshOrbitDB, error)
- func (m *Manager) GetProtocolClient() (protocoltypes.ProtocolServiceClient, error)
- func (m *Manager) GetRendezvousRotationBase() (time.Duration, error)
- func (m *Manager) GetReplicationDB() (*gorm.DB, error)
- func (m *Manager) GetRootDatastore() (datastore.Batching, error)
- func (m *Manager) GetRotationInterval() (rp *rendezvous.RotationInterval, err error)
- func (m *Manager) GetSharedDataDir() (string, error)
- func (m *Manager) RunWorkers() error
- func (m *Manager) SetBleDriver(d proximity.ProximityDriver)
- func (m *Manager) SetDevicePushKeyPath(keyPath string)
- func (m *Manager) SetLifecycleManager(manager *lifecycle.Manager)
- func (m *Manager) SetLogger(logger *zap.Logger)
- func (m *Manager) SetMDNSLocker(mlock sync.Locker)
- func (m *Manager) SetNBDriver(d proximity.ProximityDriver)
- func (m *Manager) SetNetManager(netmanager *netmanager.NetManager)
- func (m *Manager) SetNotificationManager(manager notification.Manager)
- func (m *Manager) SetupDatastoreFlags(fs *flag.FlagSet)
- func (m *Manager) SetupDefaultGRPCAccountListenersFlags(fs *flag.FlagSet)
- func (m *Manager) SetupDefaultGRPCListenersFlags(fs *flag.FlagSet)
- func (m *Manager) SetupEmptyGRPCListenersFlags(fs *flag.FlagSet)
- func (m *Manager) SetupInitTimeout(fs *flag.FlagSet)
- func (m *Manager) SetupLocalIPFSFlags(fs *flag.FlagSet)
- func (m *Manager) SetupLocalMessengerServerFlags(fs *flag.FlagSet)
- func (m *Manager) SetupLocalProtocolServerFlags(fs *flag.FlagSet)
- func (m *Manager) SetupLoggingFlags(fs *flag.FlagSet)
- func (m *Manager) SetupMetricsFlags(fs *flag.FlagSet)
- func (m *Manager) SetupNotificationManagerFlags(fs *flag.FlagSet)
- func (m *Manager) SetupPresetFlags(fs *flag.FlagSet)
- func (m *Manager) SetupProtocolAuth(fs *flag.FlagSet)
- func (m *Manager) SetupRemoteNodeFlags(fs *flag.FlagSet)
- type ManagerOpts
Examples ¶
Constants ¶
View Source
const ( FlagNameP2PBootstrap = "p2p.bootstrap" FlagNameP2PDHT = "p2p.dht" FlagNameP2PMDNS = "p2p.mdns" FlagNameP2PStaticRelays = "p2p.static-relays" FlagNameP2PRDVP = "p2p.rdvp" FlagNameP2PBLE = "p2p.ble" FlagNameP2PNearby = "p2p.nearby" FlagNameP2PMultipeerConnectivity = "p2p.multipeer-connectivity" FlagNameP2PTinderDiscover = "p2p.tinder-discover" FlagNameP2PTinderDHTDriver = "p2p.tinder-dht-driver" FlagNameP2PTinderRDVPDriver = "p2p.tinder-rdvp-driver" FlagNameP2PTinderLocalDiscoveryDriver = "p2p.tinder-localdiscovery-driver" FlagNameP2PDisableDiscoverAddrsFilter = "p2p.disc-disable-filter" FlagValueP2PDHTDisabled = "none" FlagValueP2PDHTClient = "client" FlagValueP2PDHTServer = "server" FlagValueP2PDHTAuto = "auto" FlagValueP2PDHTAutoServer = "autoserver" FlagValueP2PDHTNetworkLAN = "lan" FlagValueP2PDHTNetworkWAN = "wan" FlagValueP2PDHTNetworkDual = "dual" // both lan & wan )
View Source
const ( KeywordDefault string = ":default:" KeywordNone string = ":none:" )
View Source
const ( FlagNameNodeListeners = "node.listeners" FlagNameNodeAccountListeners = "node.account.listeners" FlagNameAllowInsecureService = "node.service-insecure" FlagValueNodeListeners = "/ip4/127.0.0.1/tcp/9091/grpc" FlagValueNodeAccountListeners = "/ip4/127.0.0.1/tcp/9092/grpc" PerformancePreset = "performance" AnonymityPreset = "anonymity" VolatilePreset = "volatile" TorDisabled = "disabled" TorOptional = "optional" TorRequired = "required" )
View Source
const ( DefaultBertyGroupMetadataStoreType = "berty_group_metadata" DefaultBertyGroupMessageStoreType = "berty_group_messages" )
View Source
const DefaultLoggingFilters = "info+:bty*,-*.grpc,error+:*"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct { // Session contains metadata for the current running session. Session struct { // Kind is a string describing the context of the app. // When set, it is appended to the session-specific logging file. // It follows the following format: '${driver}.${package}.${command}'. // Examples: // cli.daemon -> `go run ./cmd/berty daemon` // cli.mini -> `go run ./cmd/berty mini` // cli.rdvp -> `go run ./cmd/rdvp` // mobile.messenger -> Berty Messenger app using the bertybridge Kind string `json:"Kind,omitempty"` // ID is an auto-generated UUID that can be used by Tyber. ID string `json:"ID,omitempty"` } `json:"Session,omitempty"` Logging struct { DefaultLoggerStreams []logutil.Stream Native bool `json:"Native,omitempty"` StderrFormat string `json:"StderrFormat,omitempty"` StderrFilters string `json:"StderrFilters,omitempty"` FilePath string `json:"FilePath,omitempty"` FileFilters string `json:"FileFilters,omitempty"` RingFilters string `json:"RingFilters,omitempty"` RingSize uint `json:"RingSize,omitempty"` TyberAutoAttach string `json:"TyberAutoAttach,omitempty"` // contains filtered or unexported fields } `json:"Logging,omitempty"` Metrics struct { Listener string `json:"Listener,omitempty"` Pedantic bool `json:"Pedantic,omitempty"` // contains filtered or unexported fields } `json:"Metrics,omitempty"` Datastore struct { AppDir string `json:"AppDir,omitempty"` SharedDir string `json:"SharedDir,omitempty"` InMemory bool `json:"InMemory,omitempty"` // contains filtered or unexported fields } `json:"Datastore,omitempty"` Node struct { Preset string `json:"preset"` Protocol struct { SwarmListeners string `json:"SwarmListeners,omitempty"` IPFSAPIListeners string `json:"IPFSAPIListeners,omitempty"` IPFSWebUIListener string `json:"IPFSWebUIListener,omitempty"` Announce string `json:"Announce,omitempty"` Bootstrap string `json:"Bootstrap,omitempty"` DHT string `json:"DHT,omitempty"` DHTNetwork string `json:"DHTNetwork,omitempty"` DHTRandomWalk bool `json:"DHTRandomWalk,omitempty"` NoAnnounce string `json:"NoAnnounce,omitempty"` TinderDiscover bool `json:"TinderDiscover,omitempty"` TinderDHTDriver bool `json:"TinderDHTDriver,omitempty"` TinderRDVPDriver bool `json:"TinderRDVPDriver,omitempty"` TinderLocalDiscoveryDriver bool `json:"TinderLocalDiscoveryDriver,omitempty"` AutoRelay bool `json:"Relay,omitempty"` StaticRelays string `json:"StaticRelays,omitempty"` LowWatermark int `json:"LowWatermark,omitempty"` HighWatermark int `json:"HighWatermark,omitempty"` MDNS struct { Enable bool `json:"Enable,omitempty"` DriverLocker sync.Locker NetAddrs mdns.NetAddrs } `json:"MDNS,omitempty"` Ble struct { Enable bool `json:"Enable,omitempty"` Driver proximity.ProximityDriver } `json:"Ble,omitempty"` Nearby struct { Enable bool `json:"Enable,omitempty"` Driver proximity.ProximityDriver } `json:"Nearby,omitempty"` MultipeerConnectivity bool `json:"MultipeerConnectivity,omitempty"` MinBackoff time.Duration `json:"MinBackoff,omitempty"` MaxBackoff time.Duration `json:"MaxBackoff,omitempty"` DisableIPFSNetwork bool `json:"DisableIPFSNetwork,omitempty"` RdvpMaddrs string `json:"RdvpMaddrs,omitempty"` AuthSecret string `json:"AuthSecret,omitempty"` AuthPublicKey string `json:"AuthPublicKey,omitempty"` PollInterval time.Duration `json:"PollInterval,omitempty"` PushPlatformToken string `json:"PushPlatformToken,omitempty"` DevicePushKeyPath string `json:"DevicePushKeyPath,omitempty"` RendezvousRotationBase time.Duration `json:"RendezvousRotationBase,omitempty"` NetManager *netmanager.NetManager // internal DisableDiscoverFilterAddrs bool ServiceID string // contains filtered or unexported fields } Messenger struct { DisableGroupMonitor bool `json:"DisableGroupMonitor,omitempty"` DisplayName string `json:"DisplayName,omitempty"` DisableNotifications bool `json:"DisableNotifications,omitempty"` RebuildSqlite bool `json:"RebuildSqlite,omitempty"` MessengerSqliteOpts string `json:"MessengerSqliteOpts,omitempty"` ExportPathToRestore string `json:"ExportPathToRestore,omitempty"` // contains filtered or unexported fields } Replication struct { // contains filtered or unexported fields } DirectoryService struct { // contains filtered or unexported fields } GRPC struct { RemoteAddr string `json:"RemoteAddr,omitempty"` Listeners string `json:"Listeners,omitempty"` AccountListeners string `json:"AccountListeners,omitempty"` // contains filtered or unexported fields } `json:"GRPC,omitempty"` ServiceInsecureMode bool `json:"ServiceInsecureMode,omitempty"` } `json:"Node,omitempty"` InitTimeout time.Duration `json:"InitTimeout,omitempty"` // contains filtered or unexported fields }
func New ¶
func New(opts *ManagerOpts) (*Manager, error)
func (*Manager) AdvancedHelp ¶ added in v2.195.2
func (*Manager) DisableIPFSNetwork ¶
func (m *Manager) DisableIPFSNetwork()
func (*Manager) GetAccountIPFSDatastoreSalt ¶ added in v2.431.0
func (*Manager) GetAccountMessengerDBSalt ¶ added in v2.431.0
func (*Manager) GetAccountRootDatastoreSalt ¶ added in v2.431.0
func (*Manager) GetAccountStorageKey ¶ added in v2.331.0
func (*Manager) GetAppDataDir ¶ added in v2.431.0
func (*Manager) GetContext ¶
func (*Manager) GetDirectoryServiceDB ¶ added in v2.452.0
func (*Manager) GetGRPCClientConn ¶
func (m *Manager) GetGRPCClientConn() (*grpc.ClientConn, error)
func (*Manager) GetGRPCListeners ¶ added in v2.190.1
func (m *Manager) GetGRPCListeners() []berty_grpcutil.Listener
func (*Manager) GetGRPCServer ¶
func (*Manager) GetLifecycleManager ¶ added in v2.145.0
func (*Manager) GetLocalIPFS ¶ added in v2.141.0
func (*Manager) GetLocalMessengerServer ¶
func (m *Manager) GetLocalMessengerServer() (messengertypes.MessengerServiceServer, error)
func (*Manager) GetLocalProtocolServer ¶
func (*Manager) GetMessengerClient ¶
func (m *Manager) GetMessengerClient() (messengertypes.MessengerServiceClient, error)
func (*Manager) GetMetricsRegistry ¶ added in v2.182.0
func (m *Manager) GetMetricsRegistry() (prometheus.Registerer, error)
func (*Manager) GetNotificationManager ¶ added in v2.190.1
func (m *Manager) GetNotificationManager() (notification.Manager, error)
func (*Manager) GetOrbitDB ¶ added in v2.141.0
func (m *Manager) GetOrbitDB() (*weshnet.WeshOrbitDB, error)
func (*Manager) GetProtocolClient ¶
func (m *Manager) GetProtocolClient() (protocoltypes.ProtocolServiceClient, error)
func (*Manager) GetRendezvousRotationBase ¶ added in v2.322.0
func (*Manager) GetReplicationDB ¶ added in v2.311.2
func (*Manager) GetRotationInterval ¶ added in v2.367.0
func (m *Manager) GetRotationInterval() (rp *rendezvous.RotationInterval, err error)
func (*Manager) GetSharedDataDir ¶ added in v2.431.0
func (*Manager) RunWorkers ¶
func (*Manager) SetBleDriver ¶ added in v2.260.0
func (m *Manager) SetBleDriver(d proximity.ProximityDriver)
Set the Java Android BLE driver
func (*Manager) SetDevicePushKeyPath ¶ added in v2.305.0
func (*Manager) SetLifecycleManager ¶ added in v2.190.1
func (*Manager) SetMDNSLocker ¶ added in v2.337.0
Set mdns locker
func (*Manager) SetNBDriver ¶ added in v2.269.0
func (m *Manager) SetNBDriver(d proximity.ProximityDriver)
Set the Java Android Nearby driver
func (*Manager) SetNetManager ¶ added in v2.463.0
func (m *Manager) SetNetManager(netmanager *netmanager.NetManager)
Set network manager
func (*Manager) SetNotificationManager ¶ added in v2.190.1
func (m *Manager) SetNotificationManager(manager notification.Manager)
func (*Manager) SetupDatastoreFlags ¶
func (*Manager) SetupDefaultGRPCAccountListenersFlags ¶ added in v2.350.0
func (*Manager) SetupDefaultGRPCListenersFlags ¶ added in v2.141.1
func (*Manager) SetupEmptyGRPCListenersFlags ¶ added in v2.141.1
func (*Manager) SetupInitTimeout ¶ added in v2.221.2
func (*Manager) SetupLocalIPFSFlags ¶ added in v2.141.0
func (*Manager) SetupLocalMessengerServerFlags ¶
func (*Manager) SetupLocalProtocolServerFlags ¶
func (*Manager) SetupLoggingFlags ¶
func (*Manager) SetupMetricsFlags ¶ added in v2.182.0
func (*Manager) SetupNotificationManagerFlags ¶ added in v2.190.1
func (*Manager) SetupPresetFlags ¶ added in v2.195.2
func (*Manager) SetupProtocolAuth ¶ added in v2.154.0
func (*Manager) SetupRemoteNodeFlags ¶
type ManagerOpts ¶ added in v2.297.0
type ManagerOpts struct { DoNotSetDefaultDir bool DefaultLoggerStreams []logutil.Stream NativeKeystore accountutils.NativeKeystore AccountID string }
Click to show internal directories.
Click to hide internal directories.