initUserAgent function

Future<void> initUserAgent()

Initializes the default user agent based on the package information.

This should be called early in the application lifecycle, typically during the initialization of the libp2p node.

Implementation

Future<void> initUserAgent() async {
  try {
    final os = Platform.operatingSystem;
    final arch = Platform.version.split(' ').last;
    defaultUserAgent = 'dart-libp2p/$os/$arch';
  } catch (e) {
    // If we can't get the package info, just use the default
    defaultUserAgent = 'dart-libp2p';
  }
}