ZeroNetX / ZeroNet

ZeroNetX - Decentralized websites using Bitcoin crypto and BitTorrent network
https://zeronet.dev
Other
212 stars 32 forks source link

Resolve /ipfs/<address> and /ipns/<address> links #134

Open defder-su opened 2 years ago

defder-su commented 2 years ago

Problem

Large files (e.g., videos) are not very usable in ZeroNet. It makes sense to use IPFS for such static content. But how?

Current

Multiple sources are more or less useful (seeing Video section) for inlined content.

<video poster="img/TimeManDemo.png" controls preload="none" width=640 height=480> <source src="/ipfs/bafybeida5bicp23nuxyg3a763q5a3rdsa6yzazzojvwumkyyigroigs5mi/QmNhmdbsFL4gcQG44mFQtTStyzVNycUJsTF42pRTdt6w2s.m4v" type="video/mp4"> <source src="http://localhost:8080/ipfs/bafybeida5bicp23nuxyg3a763q5a3rdsa6yzazzojvwumkyyigroigs5mi/QmNhmdbsFL4gcQG44mFQtTStyzVNycUJsTF42pRTdt6w2s.m4v" type="video/mp4"> <source src="http://bafybeida5bicp23nuxyg3a763q5a3rdsa6yzazzojvwumkyyigroigs5mi.ipfs.localhost:48084/QmNhmdbsFL4gcQG44mFQtTStyzVNycUJsTF42pRTdt6w2s.m4v" type="video/mp4"> <source src="https://robotizing.net/ipfs/bafybeida5bicp23nuxyg3a763q5a3rdsa6yzazzojvwumkyyigroigs5mi/QmNhmdbsFL4gcQG44mFQtTStyzVNycUJsTF42pRTdt6w2s.m4v" type="video/mp4"> <source src="https://ipfs.io/ipfs/bafybeida5bicp23nuxyg3a763q5a3rdsa6yzazzojvwumkyyigroigs5mi/QmNhmdbsFL4gcQG44mFQtTStyzVNycUJsTF42pRTdt6w2s.m4v" type="video/mp4"> <img src="img/TimeManDemo.png"></img> </video>

But it looks like fortune-telling. Also, what about hyperlinks?

Solution

Namecoin domains are already friendly in ZeroNet. So, what about IPFS?

Developer could just use relative links like <a href=/ipfs/Qmcu5z3bdYkQwJnMK3bqdwnHzaqZuAYdjbMxyjTJSrQABX>. ZeroNet node should redirect all links with prefixes /ipfs/ and /ipns/ to IPFS gateway specified in config. Default value could be https://ipfs.io, and user can set other gateway or local IPFS node.

canewsin commented 2 years ago

Someone Created A Site to embed IPFS Videos http://127.0.0.1:43110/16pz3DbSRyz7D7e3qsxWMq98Z8VztJZN4j/ on ZeroNet, even though video links are expired, I cloned and replaced with my own, it works perfectly. Above is Original Site. try replacing your own links and try its usage if it works.

canewsin commented 2 years ago

Other networks will be supported in future including bittorrent file hosting etc.

defder-su commented 2 years ago

Someone Created A Site to embed IPFS Videos http://127.0.0.1:43110/16pz3DbSRyz7D7e3qsxWMq98Z8VztJZN4j/ on ZeroNet, even though video links are expired, I cloned and replaced with my own, it works perfectly. Above is Original Site. try replacing your own links and try its usage if it works.

http://127.0.0.1:43110/1Pab8NmuTNs3udrLiJeW4nKPaN2EzyB2VV/videobb.html works, by the way, but strictly using localhost:8080. What if user has IPFS node built in Brave (localhost:48084) or some private gateway? /ipfs/QmbnQ5FPFVDFvBQ1oTW6YskpbXKSD1c9nfFkhUFbxBL9cE looks better than http://localhost:8080/ipfs/QmbnQ5FPFVDFvBQ1oTW6YskpbXKSD1c9nfFkhUFbxBL9cE.

canewsin commented 2 years ago

Those cases should be handled by seperate plugin. If you're interested in making PR, it is always welcomed.

defder-su commented 2 years ago

That's not useful in plugin or in fork. Site developers can rely on the feature only when it's implemented on mainstream.

canewsin commented 2 years ago

Once There is a plugin, i will provide it in default plugins

defder-su commented 2 years ago

Built-in plugin, enabled by default?

canewsin commented 2 years ago

based on usage or user requirement, if it is beneficial to the network, then yes.

defder-su commented 2 years ago

Is it possible to represent plugin's preferences in /Config (which is also plugin)? Any example?

mx5kevin commented 2 years ago

IPFS a faulty system on which nothing is available. Maidsafe, lbry, storj, use a chunk technology where all always files have 4 copies, and stored chunks in another users PC. As secondary storege in ZeroNet network. It would be useful to integrate such a well-functioning technology. Or a technology where users get paid to seed data, and paid if downloading from a secondary storage. There is currently no such option if we does not have peers just seed without peers the content owners upload files to a decentralized file hosting system free way and the users pay with seeding to get stable coins to access this secondary storage. Or pay, file and website owners, who give extra disk space to get extra money from this. IPFS Paid storage system a scam with surreal high system requirements what use a pump and dump coin.

canewsin commented 2 years ago

@mx5kevin I was drafting blockchain based storage for efficient storage of files, this may solve this issue in future.

mx5kevin commented 2 years ago

I was drafting blockchain based storage for efficient storage of files, this may solve this issue in future.

The technology should be taken over from a working project where files are available non stop without 24/7 running servers.

Maidsafe, lbry, storj use a technology like this. Bit Torrent have a great new idea where users get paid for seedig an paying when downloading. The method is effective to ban hit and run users. It would be important for this to act as additional storage to existing technology and be anonymous.

This is very good as a secondary storage. But it would be important for the user to delete the files because unfortunately there are very bad implementations like steemit. The other problem is that it is not solved to always have a fixed 4 copy on the network which do not disappear until then the user does not delete them. What I still see as a problem is that these networks do not work among users or need high hardwares. It is my opinion that all users should be involved in the operation of a secondary storage without without separate software, setup, or without high system requirements. With coins if there is a reward system it would be important to be a stable coin. In the crypto market the coins are highly manipulated and the price fluctuation is too high (pump and dumps). And on the network, anonymity is as important as Monero do it. On the blockchain not to be able to trace people back.

defder-su commented 2 years ago
  1. IPFS resources becomes inaccessible. I think that's because users usually view IPFS resources through public gateways and, even when no, there is no pinning by default.
  2. But all the same with optional files in ZeroNet, despite users usually install local node.
  3. Torrents usually more sustainable. Publishers are more responsible. Users usually install torrent-client.
  4. SkyNet and other systems based on payments work while publisher pays. But what about long-term?

What about IPFS?

defder-su commented 2 years ago

I have made a prototype of LinkIPFS plugin. But I don't want the current version to build-in. Perhaps it should be a proxy, not redirector.

yanmaani commented 2 years ago

IPFS is a joke created to sell cryptocurrency. Use BitTorrent instead.

If you want IPFS, it raises the question of why you don't just use IPFS instead.

If you're going to make such a plugin, it should at least not use a gateway, but should locally ship a node.

defder-su commented 2 years ago

I used IPFS for many years well before FileCoin.

Certainly, we should facilitate using local nodes or own gateways instead of standard gateways. That's the point.

Using links like /ipfs/QmbnQ5FPFVDFvBQ1oTW6YskpbXKSD1c9nfFkhUFbxBL9cE in web pages, site developers are able to use same html code for www (gateway on domain), ipfs (easily when no gateway subdomains, but also doable with that) and zeronet (with the plugin) sites.

defder-su commented 2 years ago

[Offtop] Also, torrents are usually much more long-lived for another reason. Even with local node, IPFS uses disk space (typically, in small system drive, I suppose) as cache. Torrents are automatically pinned, if I may say so, typically using external drives with a lot of space. So, the difference is more cultural than technical. Torrent users are more responsible, IPFS users believe on magic of new technologies. But no, Google will not save info for us, Wayback Machine will not do it, and IPFS especially will not until we invest. We are responsible for saving info that consider as valuable. Summing up, IPFS could become more useful with some auto-pin technique (in big drive).

yanmaani commented 2 years ago

It's not true that IPFS chronologically predates Filecoin; according to Protocol Labs, the Filecoin whitepaper came out the same month as the IPFS one, and they came up with the ideas at the same time too. Note also that they sought funding from YC - this funding comes with the expectation of profit. Do you think that IPFS is a charity project, totally unrelated to Filecoin?

"Automatic pinning" is not the only reason why BitTorrent is superior. (In fact, BitTorrent does less in this respect than what it could do - compare to e.g. DC++.) You forget that BitTorrent implementations are way more efficient (use less resources, better peer discovery, faster downloads). In addition, there is a diversity of implementations, most of which can be embedded as libraries. This is not true for IPFS where you have to run a node, which also happens to be extremely resource-intensive because of the low quality of the code.

I think that "facilitating" the use of local nodes is not enough. The plugin ought to bundle/embed a node, so that it always interacts with the protocol directly, and no gateway is ever needed. Otherwise, what's the point? You're just using the ZeroNet daemon as a shell around a website, that can shut down or censor you at will. What's the gain from running a proxy from localhost to ipfs.io?

I still don't see why or how any of this would be an improvement over BitTorrent, which is a serious technology that people have tried and failed to censor for decades. There are obvious advantages to combining BitTorrent and ZeroNet - BitTorrent is explicitly a "dumb file transfer" protocol which doesn't try to do anything else, while ZeroNet focuses mainly on the hypertext aspects such as having interesting APIs and so on and so forth. This isn't the case for IPFS, which clearly tries to be its own thing.

If you want IPFS, why you don't just use IPFS instead?

canewsin commented 2 years ago

@defder-su You can override websocket cmds to serve ipfs files see the below link for example, plugin can be configured to handle ipfs links with actionfileget overrides. https://github.com/ZeroNetX/ZeroNet-Plugins/blob/d3cbe172712951f43bb6589e92e9e9eeb86c3172/Cors/CorsPlugin.py#L30

    # Add cors support for file commands
    def corsFuncWrapper(self, func_name, to, inner_path, *args, **kwargs):
        if inner_path.startswith("cors-"):
            cors_address, cors_inner_path = getCorsPath(self.site, inner_path)

            req_self = copy.copy(self)
            req_self.site = self.server.sites.get(cors_address)  # Change the site to the merged one
            if not req_self.site:
                return {"error": "No site found"}

            func = getattr(super(UiWebsocketPlugin, req_self), func_name)
            back = func(to, cors_inner_path, *args, **kwargs)
            return back
        else:
            func = getattr(super(UiWebsocketPlugin, self), func_name)
            return func(to, inner_path, *args, **kwargs)

    def actionFileGet(self, to, inner_path, *args, **kwargs):
        return self.corsFuncWrapper("actionFileGet", to, inner_path, *args, **kwargs)
defder-su commented 2 years ago

I need some time (perhaps, many days) and will answer later.