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

iroh-relay: make it possible to disable captive portal #2178

Closed
link2xt opened this issue Apr 11, 2024 · 2 comments
Closed

iroh-relay: make it possible to disable captive portal #2178

link2xt opened this issue Apr 11, 2024 · 2 comments
Assignees
Labels
c-iroh-relay feat New feature or request
Milestone

Comments

@link2xt
Copy link
Contributor

link2xt commented Apr 11, 2024

There is an option captive_portal_port but in my case HTTP port is already taken by acmetool redirector service:

captive_portal_port: Option<u16>,

Having captive portal on any port other than 80 does not really make sense if I understand correctly its purpose (maybe to put it behind reverse proxy, but then I can configure nginx or whatever reverse proxy to respond however I want myself), so would be better if there was an option to just disable it. As a workaround I have moved it to an arbitrary port.

@github-project-automation github-project-automation bot moved this to 📋 Backlog in iroh Apr 11, 2024
@flub
Copy link
Contributor

flub commented Apr 12, 2024

Huh, yeah this is messy. It seems the captive portal can not be disabled at all as setting None will use DEFAULT_CAPTIVE_PORTAL_PORT which is 80. Setting it to an arbitrary port that is not exposed is indeed probably the best you can do to disable it for now.

It seems that netcheck uses the RelayUrl as-is for the captive portal. However you can't put the port number in the URL as then the relay client in iroh-net will also use it for the relay protocol. If the port is not specified in the URL the captive portal check will use the HTTP default port while the relay client will use the HTTPS default port.

It should be noted that the captive portal check is not really required to work. If it detects a captive portal it's a small optimisation which helps netcheck be a little bit more generic in finding a working connection, but in practice it probably doesn't do that much especially since we still only have 2 relay servers. This could make a little more difference once there are more than 2 relay servers, but even then.

I think I agree with your assessment that setting this to a custom port is only really useful for a reverse proxy. But indeed the response is so trivial that you might as well configure the proxy to respond itself directly.

It could be made more useful if we allowed a captive portal check on custom ports, maybe with a URL parameter like ?captive_port_port=123 in the RelayUrl. Not sure how useful that is.

Anyway, a lot of words because I wanted to write down what I figured out looking at this. We should indeed make it possible to disable the captive portal on the relay server.

@dignifiedquire dignifiedquire added feat New feature or request c-iroh-relay labels Apr 15, 2024
@dignifiedquire dignifiedquire added this to the v0.16.0 milestone Apr 29, 2024
@ramfox ramfox modified the milestones: v0.16.0, v0.17.0 May 13, 2024
@dignifiedquire dignifiedquire removed this from the v0.17.0 milestone May 22, 2024
@ramfox ramfox added this to the v0.18.0 milestone May 22, 2024
@flub flub self-assigned this May 30, 2024
@flub flub moved this from 📋 Backlog to 🏗 In progress in iroh May 30, 2024
@dignifiedquire dignifiedquire modified the milestones: v0.18.0, v0.19.0 Jun 6, 2024
github-merge-queue bot pushed a commit that referenced this issue Jun 18, 2024
…everse-proxy support (#2341)

## Description

This re-architects the relay-server binary. There is now a struct with
detailed configuration which runs the entire server and aborts the
server on drop. This simplifies running the server in various
situations, including tests. The configuration is now done using a
declarative struct, which supports more control over how it runs so it
can be more easily used behind a reverse proxy, without TLS etc.

This is aiming to fix #2177, #2179 and #2178.

## Breaking Changes

The configuration file format has changed, deployments will need to
updated. For the full format see `struct Config` in
`iroh-net/src/bin/iroh-relay.rs`. Here a summary:

- The 3 parts of the server now have an independent enable setting:
`enable_relay`, `enable_stun` and `enable_metrics`. If omitted they
default to `true`.
- The way to specify which addresses the server listens on has changed:
`http_bind_addr` is for the relay server, `stun_bind_addr` for the STUN
server, `metrics_bind_addr` is for the optional metrics server and
`tls.https_bind_addr` is for when TLS is enabled. Note these are now all
full socket addresses. All have sensible defaults if omitted.
- There are new options in `tls.cert_path` and `tls.key_path` which
allow more control over where the manual TLS keys are to be read from.
- `iroh_net::defaults::DEFAULT_RELAY_STUN_PORT` has been renamed to
`iroh_net::defaults::DEFAULT_STUN_PORT`.

TBD: some APIs changed as well.  Why are they not all private?


## Notes & open questions

* The `iroh_net::relay::iroh_relay` crate name is a bit weird. But
`iroh_net::relay::server` is already taken. Maybe `iroh_net::relay::bin`
could work, but that would be weird when using it from code in other
places.
* The `ServerConfig` struct is a declarative way of controlling the new
server interface. It's kind of nice to use. Bu it is a public API that
will be a breaking change every time it changes, and it will change.
Maybe it's worth creating a builder API for this. But maybe that's
something to only tackle when it is a real demand. I feel like the
`iroh_net::relay::server` builders are an attempt at doing this earlier
than needed.

## Change checklist

- [x] Self-review.
- [x] Documentation updates if relevant.
- [x] Tests if relevant.
- [x] All breaking changes documented.
@flub
Copy link
Contributor

flub commented Jun 18, 2024

Fixed by #2341. If not feel free to reopen

@flub flub closed this as completed Jun 18, 2024
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in iroh Jun 18, 2024
ppodolsky pushed a commit to izihawa/iroh that referenced this issue Jun 22, 2024
…everse-proxy support (n0-computer#2341)

## Description

This re-architects the relay-server binary. There is now a struct with
detailed configuration which runs the entire server and aborts the
server on drop. This simplifies running the server in various
situations, including tests. The configuration is now done using a
declarative struct, which supports more control over how it runs so it
can be more easily used behind a reverse proxy, without TLS etc.

This is aiming to fix n0-computer#2177, n0-computer#2179 and n0-computer#2178.

## Breaking Changes

The configuration file format has changed, deployments will need to
updated. For the full format see `struct Config` in
`iroh-net/src/bin/iroh-relay.rs`. Here a summary:

- The 3 parts of the server now have an independent enable setting:
`enable_relay`, `enable_stun` and `enable_metrics`. If omitted they
default to `true`.
- The way to specify which addresses the server listens on has changed:
`http_bind_addr` is for the relay server, `stun_bind_addr` for the STUN
server, `metrics_bind_addr` is for the optional metrics server and
`tls.https_bind_addr` is for when TLS is enabled. Note these are now all
full socket addresses. All have sensible defaults if omitted.
- There are new options in `tls.cert_path` and `tls.key_path` which
allow more control over where the manual TLS keys are to be read from.
- `iroh_net::defaults::DEFAULT_RELAY_STUN_PORT` has been renamed to
`iroh_net::defaults::DEFAULT_STUN_PORT`.

TBD: some APIs changed as well.  Why are they not all private?


## Notes & open questions

* The `iroh_net::relay::iroh_relay` crate name is a bit weird. But
`iroh_net::relay::server` is already taken. Maybe `iroh_net::relay::bin`
could work, but that would be weird when using it from code in other
places.
* The `ServerConfig` struct is a declarative way of controlling the new
server interface. It's kind of nice to use. Bu it is a public API that
will be a breaking change every time it changes, and it will change.
Maybe it's worth creating a builder API for this. But maybe that's
something to only tackle when it is a real demand. I feel like the
`iroh_net::relay::server` builders are an attempt at doing this earlier
than needed.

## Change checklist

- [x] Self-review.
- [x] Documentation updates if relevant.
- [x] Tests if relevant.
- [x] All breaking changes documented.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-iroh-relay feat New feature or request
Projects
Archived in project
Development

No branches or pull requests

4 participants