Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Reverse iframe #2169

Closed
11 of 23 tasks
purplesyringa opened this issue Aug 20, 2019 · 92 comments
Closed
11 of 23 tasks

Proposal: Reverse iframe #2169

purplesyringa opened this issue Aug 20, 2019 · 92 comments

Comments

@purplesyringa
Copy link
Contributor

purplesyringa commented Aug 20, 2019

Abstract

Currently ZeroNet uses a wrapper for sidebar and notifications UI, and embeds site content with an iframe. This proposal fixes some issues caused by iframing by embedding ZeroNet UI into site content.

Rationale

Overview

Current architecture:

┌─────────────────────────────────────────────────────┐
│ WRAPPER (src/Ui/template/wrapper.html)              │
│ Stores secrets (e.g. wrapper key)                   │
│ ┌─────────────────────────────────────────────────┐ │
│ │ WS UPLINK                                       │ │
│ │ UiWebsocket API                                 │ │
│ └─────────────────────────────────────────────────┘ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ NOTIFICATIONS (<div>)                           │ │
│ │ ╔═════════════════════════════════════════════╗ │ │
│ │ ║ SITE NOTIFICATIONS (<div>)                  ║ │ │
│ │ ║ Unsafe content (possible XSS)               ║ │ │
│ │ ╚═════════════════════════════════════════════╝ │ │
│ │ ┌─────────────────────────────────────────────┐ │ │
│ │ │ WRAPPER NOTIFICATIONS (<div>)               │ │ │
│ │ │ Safe content (no leaking or spoofing)       │ │ │
│ │ └─────────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────┘ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ SIDEBAR (<div>)                                 │ │
│ │ Site and key management, safe                   │ │
│ │ ╔═════════════════════════════════════════════╗ │ │
│ │ ║ SITE DATA                                   ║ │ │
│ │ ║ Title, description, donate links, etc.      ║ │ │
│ │ ╚═════════════════════════════════════════════╝ │ │
│ └─────────────────────────────────────────────────┘ │
│ ╔═════════════════════════════════════════════════╗ │
│ ║ IFRAME SANDBOX                                  ║ │
│ ║ Unsafe content (managed by site code)           ║ │
│ ╚═════════════════════════════════════════════════╝ │
└─────────────────────────────────────────────────────┘

Safety layers are separated with double border.

No software has zero bugs. This includes security issues. There are many possible attack points here:

  • Site notifications (protected by manual escaping) were exploited by me, revealing site private keys;
  • Sidebar content (protected by manual escaping) wasn't exploited according to my sources, but it's still a valid point of attack;
  • Iframe sandbox (protected by browser) is in theory unbreakable, but still adds unnecessary complexity;
  • The final attack point is the external iframe (in case the wrapper is in an iframe itself). This was exploited by me once.

Proposed architecture;

┌─────────────────────────────────────────────────────┐
│ HTML PAGE                                           │
│ ┌─────────────────────────────────────────────────┐ │
│ │ PREFIX (shadow DOM)                             │ │
│ │ Practically invisible to site content           │ │
│ │ ┌─────────────────────────────────────────────┐ │ │
│ │ │ SITE NOTIFICATIONS (<div>)                  │ │ │
│ │ │ Unsafe content (possible XSS)               │ │ │
│ │ └─────────────────────────────────────────────┘ │ │
│ │ ╔═════════════════════════════════════════════╗ │ │
│ │ ║ WRAPPER NOTIFICATIONS (<iframe>)            ║ │ │
│ │ ║ Safe content (no leaking or spoofing)       ║ │ │
│ │ ╚═════════════════════════════════════════════╝ │ │
│ │ ╔═════════════════════════════════════════════╗ │ │
│ │ ║ SIDEBAR (iframe)                            ║ │ │
│ │ ║ Site and key management                     ║ │ │
│ │ ║ ╔═════════════════════════════════════════╗ ║ │ │
│ │ ║ ║ GATE (iframe)                           ║ ║ │ │
│ │ ║ ║ ┌─────────────────────────────────────┐ ║ ║ │ │
│ │ ║ ║ │ WS UPLINK                           │ ║ ║ │ │
│ │ ║ ║ │ UiWebsocket API (ADMIN)             │ ║ ║ │ │
│ │ ║ ║ └─────────────────────────────────────┘ ║ ║ │ │
│ │ ║ ╚═════════════════════════════════════════╝ ║ │ │
│ │ ╚═════════════════════════════════════════════╝ │ │
│ │ ╔═════════════════════════════════════════════╗ │ │
│ │ ║ GATE (iframe)                               ║ │ │
│ │ ║ ┌─────────────────────────────────────────┐ ║ │ │
│ │ ║ │ WS UPLINK                               │ ║ │ │
│ │ ║ │ UiWebsocket API (site)                  │ ║ │ │
│ │ ║ └─────────────────────────────────────────┘ ║ │ │
│ │ ╚═════════════════════════════════════════════╝ │ │
│ └─────────────────────────────────────────────────┘ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ SITE DATA                                       │ │
│ │ Unsafe content (managed by site code)           │ │
│ └─────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────┘

Sure, it might look more difficult at the first glance, but security comes with a cost.

Resulting HTML

The resulting HTML (the one that browser receives) consists of a prefix and the real site .html file.

Prefix

Prefix is a "magic" HTML code that sets up an analogue of what was a wrapper by creating a shadow DOM node. This ensures that the sidebar and notifications are shown correctly, independent of main site styles, and that it doesn't affect the site itself.

Gate

A gate is an iframe that acts like a gate between UiWebsocket and its user. The gate handler uses the referrer to check what permissions the websocket must have.

Fixed issues / added features

Implementation status

  • Prefix
  • Gate
  • 0 button
  • Sidebar
  • Debug logs
  • Notifications
  • Modified panel
  • Old wrapper compatiblity
  • Local storage
  • Wrapper commands
    • innerReady [compat]
    • innerLoaded & wrapperInnerLoaded [compat]
    • wrapperNotification, wrapperConfirm, wrapperPrompt, wrapperProgress
    • wrapperSetViewport [compat]
    • wrapperSetTitle [compat]
    • wrapperReload [compat]
    • wrapperGetLocalStorage & wrapperSetLocalStorage
    • wrapperPushState, wrapperReplaceState, wrapperGetState [compat]
    • wrapperGetAjaxKey
    • wrapperOpenWindow [compat]
    • wrapperPermissionAdd
    • wrapperRequestFullscreen [compat]
    • wrapperWebNotification & wrapperCloseWebNotification [compat]

ETA: at most 1 week if no major issues are found

@purplesyringa
Copy link
Contributor Author

@purplesyringa
Copy link
Contributor Author

I've first predicted compatiblity issues, but, surprisingly, latest Firefox and Chrome in both Incognito and classic mode work well.

@purplesyringa
Copy link
Contributor Author

I've found a minor issue with pushState/replaceState: sites could pretend as other sites because http://127.0.0.1:43110/talk.zeronetwork.bit and http://127.0.0.1:43110/me.zeronetwork.bit are same-origin. This can, however, be fixed by overriding history.pushState.

@github-zeronet
Copy link

Nice presentation. Very hard to get your head around without something to kick the tires on. Hopefully it won't take much effort to get make the concept testable enough to validate it doesn't break apps or core ZN functionality like the side bar.

Does this impact the URL at all? Currently, the Angular app needs to set the base href so references work. Otherwise, they try to access content from the root. e.g., "/site.css".

In reality, it needs to do some parsing of the URL so you don't have to hard code the site address. There is a current issue right now with .bit domains that I haven't tested with an app because I don't have a .bit domain. I just know it is an issue today with relative referencing.

It's not clear if this prefix concept in the DOM can have an impact today. One thing that makes this challenging to predict up-front is you can't realistically know what all the third party libraries are doing in a Node-based app until you see an error. You have the core ones used to build a basic Angular, React or Vue app, then you have a bunch more you add for app functionality (such as charting). Later, we upgrade these, hoping they don't break.

What's the minimal you can do (time wise) to be able to have a branch where we can test the highest risk portions of the design, such as the new PREFIX (shadow DOM)? It doesn't have to do everything or provide new functionality. And, for testing, can still rely on NOSANDBOX, so long as it provides a way to test new scenarios. Just need to see validate it doesn't breaks apps.

@purplesyringa
Copy link
Contributor Author

What's the minimal you can do (time wise) to be able to have a branch where we can test the highest risk portions of the design, such as the new PREFIX (shadow DOM)?

If you're asking for a high-risk PoC (meaning unsafe, i.e. can be abused by sites), it'll probably be finished today (it's 9am for me). By now, ZeroTalk, static sites, ZeroSites and ZeroHello all mostly work (except localStorage stuff and such).

@purplesyringa
Copy link
Contributor Author

Ok, so, are there any sites using wrapperWebNotification / wrapperCloseWebNotification` at all yet? I have only one, but it's not released yet, and I don't know other people using these commands, so I don't think it makes sense to support them.

@filips123
Copy link
Contributor

@imachug That commands should probably be available, but marked as deprecated and removed on next major version.

Also, how would you prevent CORS? Because all sites would be on same origin, any site would be able to access all data from other sites even without permission.


I think that this would be good improvement. This would also allow Progressive Web Apps with Web Manifests and Service Workers available.

Can you share your unsafe PoC when it is available? I would like to test it.

@purplesyringa
Copy link
Contributor Author

That commands should probably be available, but marked as deprecated and removed on next major version.

Sure, but innerLoaded, wrapperPushState and wrapperReplaceState are still useful, so we can probably leave them (or remove in two major versions or something)

@HelloZeroNet

Also, how would you prevent CORS? Because all sites would be on same origin, any site would be able to access all data from other sites even without permission.

We'd compare Origin/Referer to the request URL, and if it doesn't match, we'd use X-Frame-Options and Content-Security-Policy for iframes and just 403 Forbidden for data.

Can you share your unsafe PoC when it is available? I would like to test it.

Sure, ping me tomorrow if I forget to send you a link.

@purplesyringa
Copy link
Contributor Author

purplesyringa commented Aug 21, 2019

I'm currently a bit stuck with site-in-site (aka picture-in-picture) mode implementation. Good old 3 years old StackOverflow thread without an answer. Please tell me if you know how to fix that issue.

@purplesyringa
Copy link
Contributor Author

Unfortunately I couldn't find a way to fix that issue, so I'm switching to another architecture:

┌─────────────────────────────────────────────────────┐
│ HTML PAGE                                           │
│ Secret (wrapper key [site])                         │
│ ┌─────────────────────────────────────────────────┐ │
│ │ PREFIX (shadow DOM)                             │ │
│ │ Practically invisible to site content           │ │
│ │ ┌─────────────────────────────────────────────┐ │ │
│ │ │ SITE NOTIFICATIONS (<div>)                  │ │ │
│ │ │ Unsafe content (possible XSS)               │ │ │
│ │ └─────────────────────────────────────────────┘ │ │
│ │ ╔═════════════════════════════════════════════╗ │ │
│ │ ║ WRAPPER NOTIFICATIONS (<iframe>)            ║ │ │
│ │ ║ Safe content (no leaking or spoofing)       ║ │ │
│ │ ╚═════════════════════════════════════════════╝ │ │
│ │ ╔═════════════════════════════════════════════╗ │ │
│ │ ║ SIDEBAR (iframe)                            ║ │ │
│ │ ║ Site and key management                     ║ │ │
│ │ ║ Secret (wrapper key [ADMIN])                ║ │ │
│ │ ║ ┌─────────────────────────────────────────┐ ║ │ │
│ │ ║ │ WS UPLINK                               │ ║ │ │
│ │ ║ │ UiWebsocket API (ADMIN)                 │ ║ │ │
│ │ ║ └─────────────────────────────────────────┘ ║ │ │
│ │ ╚═════════════════════════════════════════════╝ │ │
│ │ ┌─────────────────────────────────────────────┐ │ │
│ │ │ WS UPLINK                                   │ │ │
│ │ │ UiWebsocket API (site)                      │ │ │
│ │ └─────────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────┘ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ SITE DATA                                       │ │
│ │ Unsafe content (managed by site code)           │ │
│ └─────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────┘

Basically, we're getting rid of iframe gate and using wrapper key instead. This architecture is still secure, but is more error-prone, so I should be careful enough.

@filips123
Copy link
Contributor

What is different between site and wrapper notifications? Could both of them use DIV or IFRAME or even be in same element?

@purplesyringa
Copy link
Contributor Author

Site notifications are possibly insecure and don't store sensitive information; wrapper notifications are always secure and may store sensitive information. For example, Database was rebuilt notification is a site notification, while Enter private key: [...] (you get it when you press Sign & publish) is a wrapper notification.

It's unsafe to use div for wrapper notifications. But it's possible to use iframe for site notifications, though that's overcomplicated and slow.

@purplesyringa
Copy link
Contributor Author

@filips123 Forgot to ping you

@purplesyringa
Copy link
Contributor Author

I've noticed that a lot of wrapper code uses jQuery. We probably don't want to pollute sites' environment, so I'm trying to port as much code as possible to Vanilla JS.

@purplesyringa
Copy link
Contributor Author

Making sidebar work turned out to be a bit more difficult than expected, so you'll have to wait a bit.

@HelloZeroNet
Copy link
Owner

HelloZeroNet commented Aug 22, 2019

Looking good, but the history access could be problematic and probably there is multiple ways to recover the original function, eg. using an iframe:

history.pushState = console.log
ƒ log() { [native code] }
$("<iframe id='itemp'>hello</iframe>").appendTo(document.body)[0].contentWindow.history.pushState
ƒ pushState() { [native code] }

@purplesyringa
Copy link
Contributor Author

Sure; but what would you do after getting pushState? pushState "", "", "http://facebook.com" because http://facebook.com and about:blank are not same-origin.

@filips123
Copy link
Contributor

@imachug Maybe changing URL to address of another ZeroNet site. All sites would be on the same origin but I don't know if HTTP CORS headers actually prevent this.

@purplesyringa
Copy link
Contributor Author

@filips123 Eh, that's why we're replacing pushState. If you're referring to nofish'es iframe PoC, it won't work because http://127.0.0.1:43110 and about:blank aren't same-origin.

@filips123
Copy link
Contributor

filips123 commented Aug 22, 2019

@imachug Ok, this makes sense. And you probably can't open http://127.0.0.1:43110 in iframe, right?

Also, would it be possible to differentiate between legitimate and malicious iframes? Because site can use iframe to just display other content on it (embedded game, sidebar... hosted on it) or to attack different site.

@purplesyringa
Copy link
Contributor Author

Ok, this makes sense. And you probably can't open http://127.0.0.1:43110 in iframe, right?

Well, it's possible (site-in-site case), but it's restricted, so you can't call pushState anyhow.

Also, would it be possible to differentiate between legitimate and malicious iframes? Because site can use iframe to just display other content on it (embedded game, sidebar... hosted on it) or to attack different site.

It's impossible to attack a site with an iframe because there's a sandbox. The only way of communication is postMessage. I'm still thinking about issues, but I don't see any yet.

@HelloZeroNet
Copy link
Owner

Sure; but what would you do after getting pushState? pushState "", "", "http://facebook.com" because http://facebook.com and about:blank are not same-origin.

You are right, but it works this way:

> history.replaceState = "nope"
> history.replaceState = $("<iframe id='itemp'>hello</iframe>").appendTo(document.body)[0].contentWindow.history.replaceState
> history.replaceState("", "", "/AnyUrl")
> window.location.href
"http://127.0.0.1:43110/AnyUrl"

@purplesyringa
Copy link
Contributor Author

What browser are you using? That sounds like a major issue

@HelloZeroNet
Copy link
Owner

Chrome, but just tested and also works in FF

@purplesyringa
Copy link
Contributor Author

Do you have any ideas how to solve this? Switching to site_address.zero or a similar way would help here (and solve other problems too), but that won't work well with proxies and is also a major change.

@HelloZeroNet
Copy link
Owner

Not really, maybe we could setup a setInterval that monitors the window.top.location, but it's pretty hackish

@filips123
Copy link
Contributor

@HelloZeroNet What if the site would somehow delete/replace setInterval?

@purplesyringa
Copy link
Contributor Author

@filips123 The prefix code is run before site code, so we can save setInterval beforehand.

@github-zeronet
Copy link

@github-zeronet Yeah we might not be on the same page due to my admittedly poor understanding of how the current system works ...

Not noise at all. I love diverse perspectives in a complex conversation. Your understanding of DNS is good, and that does count.

@purplesyringa
Copy link
Contributor Author

So we're going to use an extension/PAC. Ok. That will probably work and won't be difficult to implement. curl will stop working, but that should still be easily fixable with curl -H"Host: talk.zeronetwork.bit" 127.0.0.1:43110 or whatever. Now, what do we do with proxies? Will the proxies have to ask the user to install the plugin? How will the plugin know what proxy to use? Will there be a configuration setting (if so, what if I need to use both proxy and localhost at once to deploy a site)? If it'll be configurable with an URL (i.e. talk.zeronetwork.bit.zn.amorgan.xyz), how will we learn what part is a ZeroNet domain and which part is Clearnet one? Should we split by .bit. and thus disallow such names as bitco.no (or similar)?

@filips123
Copy link
Contributor

filips123 commented Aug 23, 2019

it'll be configurable with an URL (i.e. talk.zeronetwork.bit.zn.amorgan.xyz), how will we learn what part is a ZeroNet domain and which part is Clearnet one?

Proxy owner should specify which part is real clear net domain. Or alternatively (preferely) program should detect this automatically.

@filips123
Copy link
Contributor

@KilowattJunkie Regarding custom URL schemes: How would browser know to send HTTP request to zhttp scheme? Also, Android Chrome doesn't recognize bit and instead opens Google search.

@github-zeronet
Copy link

github-zeronet commented Aug 23, 2019

@filips123

I like to look at what can be done before discussing what should be done. we didn't get far enough to talk about all the incredible things that can be done with a ZN DNS: site configuration, domain issuance, DNS like functionality like CNAME and MX if we can ever introduce ZN SMTP, etc,...

@imachug did a great job at looking at possibilities! We may put ZN DNS on a side burner for now, but I'll be thinking about all the incredible possibilities in the meantime thanks to imachug's imagination.

As for relays, I think ultimately we can package nginx or httpd in a Docker with ZN to make deployment very easy, providing any out-of-the-box reverse proxy and URL rewriting config needed. This also allows it to be deployed on more platforms.

@github-zeronet
Copy link

At the end of the day, we need 1000 developers! lol

@filips123
Copy link
Contributor

filips123 commented Aug 23, 2019

@github-zeronet I partially agree with you. However, PAC file is something that should nort be so hard, as there are only few issues with it (actually some of them are a bit harder to do). This would also enable easier integrations with other incredible things in the future.

But I don't think ZN specific DNS would be useful. It would be better to just integrate it with other existing DNS projects (#2049).

Also, requiring user to use Docker isn't good. Docker could be hard to install, specially on Windows, where, if you don't have Pro versions, you have to install both VirtualBox and Docker Toolbox.

@April93
Copy link

April93 commented Aug 23, 2019

I don't have any particular comments to make other than: ideally the resolution to the problem should get everyone on the same page, and allow for "clean" urls (no 127.0.0.1:port business in the nav bar).

As it stands I and others use a .pac file to redirect http://zero/address/, http://domainname.bit/, and http://name.zeroid/ addresses to their proper counterparts. I've attached the .pac file I use below (renamed to add a .txt extension to allow upload). something like: http://address.zeronet/ would work fine IMO, and if it works for direct addresses (not just domains) as well then that'd solve a lot of the linking problems. But if there's an extra step in setup, I'm not sure everyone would do it? That seems to be the problem right now.

IE advanced users have no problem setting up the .pac and whatever else to allow links to work, but I always have to be careful to change it back to the native solution to ensure everyone can use the link. Any "optional" steps would still have that problem.

zeronet.pac

@purplesyringa
Copy link
Contributor Author

So looks like we have two equivalent solutions here:

Proxy

It looks like a special .pac file is not required, we can set localhost:43110 as the proxy address. This requires a minor modification in ZeroNet core, but it's simple.

DNS

We'd set localhost:53 (or an equivalent DoH port) as DNS server.


They are basically the same with the feature set we currently have. There might be some good usecases for DNS in the future, but I don't see any features now, @github-zeronet:

site configuration

How exactly would we utilize DNS? AFAIK the same is possible with proxy.

domain issuance

Domain resolving is done by ZeroNet in both cases, so it's not a difference.

DNS like functionality like CNAME

...but why?

and MX if we can ever introduce ZN SMTP, etc...

This is possible without DNS, see ZeroMailProxy.


If the solutions are about the same, I'd use proxy: it looks like it's easier to install and can be easily set per-browser (instead of at OS level).

@filips123
Copy link
Contributor

filips123 commented Aug 24, 2019

@imachug Other possibly may be browser extension. It isn't so powerful, but it may be easier for users to use.

I'd first support PAC file and proxy which are most easiest way to implement (and both of them are related to each other). But later, we should also implement other ways to do this, such as DNS, extensions and system programs. Of that possiblities, extension should probably be implement first.

@HelloZeroNet
Copy link
Owner

Actually there is already a browser extension, but it's also using the pac file, so there is no difference:
https://github.com/goldenratio/zeronet-protocol-crx

@filips123
Copy link
Contributor

filips123 commented Aug 24, 2019

@HelloZeroNet With last update 3 years ago and old available for Chrome. Not good solution because of that, but something like this should be made to be official. There should be extension like this, but for more browser, regularly updated with latest specs and official. I will try to make and release PoC of this but I need to wait until we standardize hostname (or other) solution. Here I would still like something like .zeronet TLD or alternatively custom protocol schemes.

@github-zeronet
Copy link

github-zeronet commented Aug 24, 2019

@filips123 ... requiring user to use Docker isn't good. Docker could be hard to install, specially on Windows, where, if you don't have Pro versions, you have to install both VirtualBox and Docker Toolbox.

This was just to make installing relays easier. Not for normal users. Not a requirement for anyone. Who in their right mind would run a Relay on Windows, anyway? lol

@github-zeronet
Copy link

github-zeronet commented Aug 25, 2019

If the solutions are about the same, I'd use proxy: it looks like it's easier to install and can be easily set per-browser (instead of at OS level).

That was all potential future state if we had ZN DNS. Not needed at all for our current feature.

If I understand ZeroMailProxy, its purpose is to allow a client, such as Thunderbird, to send/receive email for you through the equiv of the ZeroMail site via SMTP/POP3 protocols. Correct?

ZeroMail is a nice temporary way to solve a problem. It has limitations preventing it from being a long-term solution in its current state. I'm thinking more from a blank slate how to send email in a decentralized way with ZeroNet as the backbone.

OFFTOPIC: POSSIBLE FUTURE ZERONET DNS/SMTP

So, let's say I own the "safemail.yu" ZN domain. I'd want a way that people could send email to its users, like "[email protected]". But, the sender should not have to have a user account on that domain. So, I'd provide an ZN SMTP server at a site address they could use to route email to those users. The DNS record would provide an MX record pointing to that site. I'm basically pondering how this could be done on ZN, w/o clearnet.

Any domain owner would have the ability to setup an email server (special type of site) that its users could receive email to (with its own storage and other rules). Anyone would be able to send email to these users, even if they did not create a user at that domain.

There's a lot more going on in my head, such as offline mesh networks with intermittent connectivity to the Internet, apps to people, apps to apps, people to apps communications in addition to people to people, decentralized autonomous message storage (in this case, the owner of a SMTP relay would control storage, forwarding and other policies for their domain, and not rely on limitations of ZeroMail.)

@purplesyringa
Copy link
Contributor Author

@HelloZeroNet I have managed to make a browser extension to access ZeroNet via e.g. talk.zeronetwork.bit.zeronet / 0talkfrmwvbnsoof4iokay9euxtbtjiptsg699gc.zeronet. Everything works well but this new address syntax (i.e. .zeronet TLD instead of zero/ / zero:// prefix and .bit.zeronet instead of .bit) make it incompatible with existing sites. Do you accept this syntax and do you think we'll be able to modify existing (official) sites to support this syntax?

@HelloZeroNet
Copy link
Owner

HelloZeroNet commented Dec 12, 2019

Is redirecting /zero/1anysite -> 0anysite.zeronet and talk.zeronetwork.bit -> talk.zeronetwork.bit.zeronet not possible with the extension or what the reason of the incompatibility?

@purplesyringa
Copy link
Contributor Author

It is possible but I think both zero/ and .bit will result in incompatibilities. For example, zero local host can be used by web developers (or just as a LAN domain in a big corporation) and .bit domains are available not for ZeroNet only.

@filips123
Copy link
Contributor

filips123 commented Dec 12, 2019

Another possibility could be to use zero:// protocol as IPFS and Swarm do, but this won't make it possible to use ZeroNet with other protocols in the future, as handler won't be able to distinguish between them. But with .zeronet TLD, you could use both http://domain.bit.zeronet, ftp://domain.bit.zeronet, gopher://domain.bit.zeronet...

Using zero:// could look cleaner, but with it, it won't be possible to handle more protocols. And most browsers won't let you directly type zero://domain.bit as it will just redirect to search.

@HelloZeroNet
Copy link
Owner

HelloZeroNet commented Dec 12, 2019

The .zeronet postfix looks good for me, I just wondering what the reason of the incompatibility.

@purplesyringa
Copy link
Contributor Author

I could support .bit and zero/ as well but I still hope we'll get rid of them soon. Is that ok?

@filips123
Copy link
Contributor

I don't see a reason why you should support them. Even if we get rid f them later, we can also get rid of them now. Users would have to change anyway.

@purplesyringa
Copy link
Contributor Author

The problem is backward compatibility (oh well). Even if we get ZeroHello, ZeroTalk and such working correctly, it might be a pain to make other sites apply fixes.

@HelloZeroNet
Copy link
Owner

Existing sites will automatically convert http://127.0.0.1:43110/1anysite to http://zero/1anysite, so if you don't redirect it in the plugin, then you will break links on all exsting site.

@purplesyringa
Copy link
Contributor Author

I can support zero/ and .bit but such links would have to be redirected twice (http://zero/1anysite -> http://0anysite.zeronet -> http://127.0.0.1:43110) so this would be kind of inefficent so I'd still ask you to use .zeronet by default (say, in case the plugin is installed).

@HelloZeroNet
Copy link
Owner

I meant not internal proxy redirect, but actual http location: header redirect. So you would have to redirect once and not for every request.
But sure, I'm up to turn the links to .zeronet TLD ones if someone visits the site on that url.

@purplesyringa
Copy link
Contributor Author

So you would have to redirect once and not for every request.

Oh, that makes sense. I'll implement that soon (around tomorrow).

But sure, I'm up to turn the links to .zeronet TLD ones if someone visits the site on that url.

Great!

@krzysztof113
Copy link

Let me also add some noise :)
Different approach:
example.bit.zeronet.io:43110 points to 127.0.0.1 as a wilcard. Zeronet gets host in header. Origin is unique per subdomain.
When the proxy, extension or wildcard hosts is supported it's handled with those. When not, relies on clearnet DNS (I know it's a problem).

@filips123
Copy link
Contributor

Ideally, both *.zeronet and *.zeronet.some.tld should be supported. Some other decentralized systems (Onion, IPFS...) are also doing it in simialar way.

Just note that it should be possible to access sites from port 80 and 443, and not 43110. Using 43110 as port number was probably meant to separate ZeroNet UI and prevent conflicts with other servers that may run on port 80. But as hostnames will be now separated, it should be possible to access sites as normal clearnet sites, from port 80 and 443 (and other ports for other services). This would also enable adding CNAME/A/AAAA and TXT record
to clearnet domain, and accessing site publically with normal domain. Solution (with some problems in macOS) for this would be to use 127.43.11.0:80 as default host of ZeroNet UI. See #2214 (comment) for more details.

And instead of *.zeronet.io, it might be better to use *.zeronet.link. Because zeronet.io would be used as normal website and (your) zeronet.link would be used for proxy. For example, ENS and IPFS are also doing this in similar way, where eth.link is just proxy to resolve and handle ENS domains.

Then, browser plugin or local program would set *.zeronet and *.zeronet.link as wilcard for local ZeroNet instance. Additionally, DNS records should also be set to local IP (127.43.11.0:80). So when ZeroNet will be installed, and user will access example.bit.zeronet or example.bit.zeronet.link, it will be automatically forwarded to local ZeroNet instance. And when ZeroNet won't be installed, zeronet.link will have public record to instead use some reliable public ZeroNet proxy(ies).

@krzysztof113
Copy link

To bind on ports below 1024 admin/root rights are needed and on Android it's not even possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants