admin管理员组

文章数量:1309955

I have a pretty broad question, so I hope stackoverflow is the right place to ask it.

I'm playing around with libp2p. Basically, I wish to build a cross-platform P2P filesharing application.

I have chosen the stack

  • Go + go-libp2p for the background service that does the actual heavy lifting
  • Flutter for the frontend as a cross-platform solution

I am able to spin up a libp2p node on linux just fine. However, on Android, I'm running into trouble with permissions (at least that's what it looks like) related to network interface discovery. It seems pretty similar to this issue in the "kubo" project

Unless I figure out a way to overcome this, that probably means that my node can reach out to other nodes, but won't be able to accept incoming requests. One could probably work around that with relays, but I don't want an application that's crippled that way from the start.

Existing projects like Syncthing seem to suggest that it is possible to implement P2P technology on Android, but Syncthing doesn't use libp2p and also I don't know if perhaps it uses relays as well. The code base is quite large and I'm only starting out with Go, so I haven't been able to figure that out.

So my question is: Did somebody manage to get a fully functional libp2p node to work on Android? How? Any advice?

For reference: My build is currently split in two steps: First I compile the Go server for Android/ARM64 (for my Pixel 6a at least), then I add that to the Flutter project's native binary dir, then I compile the Flutter project. I have a Kotlin service that runs the Go binary as a sub-process and I communicate between the Flutter UI and that Process via gRPC.

I'm aware of "gomobile", but I haven't looked at what exactly that solves. Unsure if that's just a thin wrapper that makes compiling for Android easier, or if its output is significantly differently to what can be done with "normal" Go. Should I look into that to find a solution?

For reference, the exact error I get when the libp2p node is integrated is

2025-02-02 16:07:21.471  5885-5985  System.out              com.example.filerequest_fe           I  Server output: 2025/02/02 16:07:21 Starting server version: 
2025-02-02 16:07:21.498  5885-5985  System.out              com.example.filerequest_fe           I  Server output: 2025-02-02T16:07:21.497Z ERROR   basichost   basic/basic_host.go:396 failed to resolve local interface addresses {"error": "route ip+net: netlinkrib: permission denied"}
2025-02-02 16:07:21.502  5885-5985  System.out              com.example.filerequest_fe           I  Server output: 2025/02/02 16:07:21 P2P node started with ID: 12D3KooWCSNkaqJTcaZarnkRtfo8arPYuRi4F7n6qYh3HWNSLqRH
2025-02-02 16:07:21.504  5885-5985  System.out              com.example.filerequest_fe           I  Server output: 2025/02/02 16:07:21 Listening on: /ip4/127.0.0.1/tcp/34361
2025-02-02 16:07:21.505  5885-5985  System.out              com.example.filerequest_fe           I  Server output: 2025/02/02 16:07:21 gRPC server listening on port 50051
2025-02-02 16:07:21.506  5885-5985  System.out              com.example.filerequest_fe           I  Server output: 2025-02-02T16:07:21.500Z ERROR   basichost   basic/basic_host.go:396 failed to resolve local interface addresses {"error": "route ip+net: netlinkrib: permission denied"}
2025-02-02 16:07:21.508  5885-5985  System.out              com.example.filerequest_fe           I  Server output: 2025-02-02T16:07:21.500Z ERROR   basichost   basic/basic_host.go:396 failed to resolve local interface addresses {"error": "route ip+net: netlinkrib: permission denied"}

本文标签: flutterHow to run a libp2p node on AndroidStack Overflow