wbipfs

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2021 License: GPL-3.0 Imports: 20 Imported by: 1

README

A Golang and Command-Line Interface to IPFS

This package is a command-line tool named wbipfs saving webpage to IPFS. It also supports imports as a Golang package for a programmatic. Please report all bugs and issues on Github.

Installation

$ go get -u -v github.com/wabarc/wbipfs/cmd/wbipfs

Usage

Command-line
$ wbipfs --help
version: 0.1.0
date: 2020/09/19

Usage of wbipfs:
  -host string
        IPFS host (default "127.0.0.1")
  -mode string
        IPFS running mode supports daemon and pinner, daemon requires to run an ipfs standalone daemon. (default "pinner")
  -port uint
        IPFS port (default 5001)
  -tor
        Wayback webpage with Tor proxy, it requires tor executable
$ wbipfs https://www.google.com https://www.bbc.com

Output:
version: 0.1.0
date: 2020/09/19

https://www.google.com => https://ipfs.io/ipfs/QmSGvyuAGiwQHTeAzYEhfhhZbhvyCN6PX1kCq3vgwmkPmU
https://www.bbc.com => https://ipfs.io/ipfs/QmXvUs1ic7uPtfxn7iQHfbefzcrrmnSYP8YDE4BU6jEUab
Go package interfaces
package main

import (
	"fmt"

	"github.com/wabarc/wbipfs"
)

func main() {
        wbrc := &wbipfs.Archiver{}
        links := []string{"https://www.google.com", "https://www.bbc.com"}
        urls, _ := wbrc.Wayback(args)
        for orig, dest := range urls {
                fmt.Println(orig, "=>", dest)
        }
}

// Output:
// https://www.google.com => https://ipfs.io/ipfs/QmSAQ2DYMfRaPgnoWnAgyBYhJXEV5G4dApeukf6yYbnqyE
// https://www.bbc.com => https://ipfs.io/ipfs/QmUXFPSJEXcXaZB9WthxbkmYWvUw1JCiNYGWDAAr7jd88p

FAQ

Optional to disable JavaScript for some URI?

If you prefer to disable JavaScript on saving webpage, you could add environmental variables DISABLEJS_URIS and set the values with the following formats:

export DISABLEJS_URIS=wikipedia.org|eff.org/tags

It will disable JavaScript for domain of the wikipedia.org and path of the eff.org/tags if matching it.

Credits

License

This software is released under the terms of the GNU General Public License v3.0, see the LICENSE file for details.

Documentation

Overview

Package wbipfs implements the functionality to wayback webpage to the IPFS network https://ipfs.io

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pinner

func Pinner(source string) (string, error)

Pinner is the handle of put the file to IPFS by pinning service. It supports two slots which infura and pinata, you can apply a specific slot via WAYBACK_SLOT env. If you use the pinata slot, it requires WAYBACK_APIKEY and WAYBACK_SECRET environment variable.

func Publish

func Publish(s string) (string, error)

Types

type Archiver

type Archiver struct {
	UseTor  bool
	Timeout time.Duration

	IPFSHost string
	IPFSPort uint
	IPFSMode string // daemon and pinner, default: pinner
	// contains filtered or unexported fields
}

Archiver is core of the wbipfs.

func (*Archiver) Wayback

func (wbrc *Archiver) Wayback(ctx context.Context, input *url.URL) (dst string, err error)

Wayback is the handle of saving to IPFS.

type Daemon

type Daemon struct {
	Host string
	Port uint
}

Publish to IPFS use local daemon

func NewDaemon

func NewDaemon(host string, port uint) *Daemon

func (*Daemon) Transfer

func (dm *Daemon) Transfer(source string) (string, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL