PinShare is a Decentralised Pinning Service for IPFS, built on libp2p to assist the clustering of IPFS Content for curators building a library or knowledge stacks and as a basis to build advanced data pipelines from. It's a peer-to-peer application designed to securely share files by vetting them through The Security Consensus before their metadata is advertised to other peers on the network. PinShare can be customised to serve different community needs or data pools as seperate libraries, simply by changing the config and running seperate instances of PinShare.
- P2P Networking: Built on
go-libp2pfor robust and decentralized communication. - Automated File Ingestion: Watches a designated folder for new files to process automatically.
- Security First: Integrates with VirusTotal to scan files before they are shared. It checks for existing reports by hash and can submit new files for analysis.
- File Type Validation: A configurable allowlist ensures only permitted file types are processed.
- Metadata Propagation: Uses libp2p PubSub to efficiently broadcast metadata of safe files to all connected peers.
- REST API: Exposes an API for programmatic interaction, defined with OpenAPI.
The lifecycle of a file in PinShare follows these steps:
- File Drop: A user places a file into the configured
uploaddirectory. - Detection: The application's file watcher detects the new file.
- Validation: The file's extension is checked against a list of allowed types. If not allowed, it's rejected.
- Hashing: A SHA256 hash of the file is computed.
- VirusTotal Check:
- PinShare first queries VirusTotal with the file's hash to check for a pre-existing scan report.
- If a report exists and shows zero detections, the file is considered safe.
- If no report exists, PinShare uses a headless browser (
chromedp) to upload the file to VirusTotal for a new scan.
- Verdict & Action:
- Safe: If the file is cleared by VirusTotal (0 detections), its metadata is added to the local
metadata.jsonstore. - Unsafe/Rejected: If the file is flagged as malicious or is an invalid type, it is moved to the
rejectfolder.
- Safe: If the file is cleared by VirusTotal (0 detections), its metadata is added to the local
- Metadata Sharing: Once a file is confirmed safe, its metadata is broadcast over the configured libp2p PubSub topic.
- Peer Action: Other peers in the network receive this metadata and can use it to fetch the file from the advertising peer.
-
Preview Release is v0.1.2
-
The docker image contains all dependancies required to run PinShare.
-
docker run -it -v $(pwd):/opt/pinshare/data ghcr.io/cypherpunk-labs/pinshare:latest
- Go (latest version recommended)
- Docker/Podman (latest version recommended)
- IPFS Desktop (latest version recommended)
- A local installation of Google Chrome or Chromium (required for VirusTotal integration).
-
Clone the repository:
git clone https://github.com/cypherpunk-labs/PinShare.git cd PinShare -
Build the application:
go build -o pinshare ./cmd/pinshare
PinShare is configured via config/config.yaml. You can copy the example file and modify it to suit your needs.
Key configuration settings:
uploadFolder: Directory to watch for new files (e.g.,./data/uploads).cacheFolder: Directory for temporary/cached files (e.g.,./data/cache).rejectFolder: Directory where unsafe or invalid files are moved (e.g.,./data/rejects).metaDataFile: Path to the JSON file storing metadata of safe files (e.g.,./data/metadata.json).identityKeyFile: Path to store the libp2p node's private key (e.g.,./data/identity.key).libp2pPort: Port for the libp2p host to listen on.metadataTopicID: The PubSub topic name for sharing metadata.
To start the service, simply run the compiled binary:
./pinshareThis will start the libp2p node, initialize the file watcher, and launch the API server. You will see logs indicating the node's status and peer connections.
PinShare includes subcommands for specific tasks and debugging.
-
Run
./pinshare --helpfor a full list of available commands. -
Example: Test the headless browser integration by checking a known hash on VirusTotal.
# The hash must exist on VirusTotal for this to work ./pinshare testcdp 275a021bbfb6489e54d471899f7db9d1663fc695ec2fe2a2c4538aabf651fd0f
The service exposes a RESTful API for management and queries. The API is defined using the OpenAPI specification.
- API Specification: See
docs/spec/basemetadata.openapi.spec.yamlfor the full contract. - The API server starts automatically when you run the main application.
The integration with VirusTotal currently relies on web scraping using chromedp. This approach is inherently fragile and may break if VirusTotal changes its website's HTML structure or selectors. This is a known risk and a more robust API-based integration is a future goal.