Skip to content

Commit 6a488e1

Browse files
committed
get torrent file using ipfs gateway with fixed address (127.0.0.1) to fix app behind firewall [ci skip] [circleci skip]
1 parent 7eb1574 commit 6a488e1

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

Diff for: service/torrent.go

+3-10
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,10 @@ func Get_Torrent_From_Ipfs(mhash string) (data []byte, err error) {
8585
/////////////////////////////////
8686
// get the file first
8787
//url := app.GlogchainConfigGlobal.IpFsGateway + "/ipfs/" + mhash
88-
////log.Println("url", url)
89-
//resp, err := http.Get(url)
90-
//if err != nil {
91-
// log.Println(err.Error())
92-
// return
93-
//}
94-
//defer resp.Body.Close()
9588

96-
// get from api instead of from gateway
97-
url := app.GlogchainConfigGlobal.IpFsAPI + "/api/v0/get?arg=" + mhash
89+
// remember to config ipfs ( ipfs service ) to listen on 0.0.0.0 so that it can be accessed behind firewall,
90+
// behind firewall: 127.0.0.1, external still accessed via app.GlogchainConfigGlobal.IpFsGateway
91+
url := "http://127.0.0.1:8080/ipfs/" + mhash
9892
//log.Println("url", url)
9993
resp, err := http.Get(url)
10094
if err != nil {
@@ -103,7 +97,6 @@ func Get_Torrent_From_Ipfs(mhash string) (data []byte, err error) {
10397
}
10498
defer resp.Body.Close()
10599

106-
107100
/////////////////////////////////
108101
// load to torrent
109102
//r := bytes.NewReader(data)

0 commit comments

Comments
 (0)