aboutsummaryrefslogtreecommitdiff
path: root/ipfs.go
blob: e9c5a42622b5c730563de6e3464945dfb41357b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main

import (
	"fmt"

	"git.kiefte.eu/lapingvino/infodump/message"
	shell "github.com/ipfs/go-ipfs-api"
)

func TestIPFSGateway(gateway string) error {
	// Test the IPFS gateway
	fmt.Println("Testing IPFS gateway...")
	ipfs := shell.NewShell(gateway)
	_, err := ipfs.ID()
	return err
}

func SetIPFSGateway() {
	// Set the IPFS gateway
	fmt.Println("Enter the IPFS gateway: ")
	var gateway string
	fmt.Scanln(&gateway)
	// Test the IPFS gateway
	err := TestIPFSGateway(gateway)
	if err != nil {
		fmt.Println(err)
		return
	} else {
		fmt.Println("IPFS gateway set to: ", gateway)
		message.IPFSGateway = gateway
	}
}