-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add support for Fly.io deployments #167
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #167 +/- ##
==========================================
- Coverage 87.98% 87.87% -0.12%
==========================================
Files 44 45 +1
Lines 2356 2358 +2
==========================================
- Hits 2073 2072 -1
- Misses 283 286 +3
Continue to review full report in Codecov by Sentry.
|
guides/deploying/fly.md
Outdated
There are just two things you need to do: | ||
|
||
- configure a STUN server both on the client and server side | ||
- use custom Fly.io IP filter on the server side |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- use custom Fly.io IP filter on the server side | |
- use a custom Fly.io IP filter on the server side |
guides/deploying/fly.md
Outdated
- configure a STUN server both on the client and server side | ||
- use custom Fly.io IP filter on the server side | ||
|
||
In theory, configuring a STUN server just on a one side should be enough but we recommend to do it on both sides. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory, configuring a STUN server just on a one side should be enough but we recommend to do it on both sides. | |
In theory, configuring a STUN server just on one side should be enough but we recommend doing it on both sides. |
lib/ex_webrtc/ice/fly_ip_filter.ex
Outdated
This module defines a single function, which filters out IP addresses, | ||
which ICE Agent will use as its host candidates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- "filters out" to me sounds like it's rejecting these addresses rather than accepting them
- I feel like adding a bit more info about the function could be helpful
This module defines a single function, which filters out IP addresses, | |
which ICE Agent will use as its host candidates. | |
This module defines a single function, which filters IP addresses, | |
which ICE Agent will use as its host candidates. | |
It accepts only the IPv4 address that `fly-global-services` resolves to. |
which ICE Agent will use as its host candidates. | ||
""" | ||
|
||
@spec ip_filter(:inet.ip_address()) :: boolean() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] We could add a behaviour in ExICE. Then again, it's only one function -- up to you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's stay with the current version for know. In debugging and testing it's verry convenient to pass anonymous function instead of creating a module with a single function.
I thought about returning an anonymous function from ip_filter
and use ICEAgent.ip_filter
type in typespec but sounds like an overkill 🤔
guides/deploying/fly.md
Outdated
}); | ||
``` | ||
|
||
in Elixir code: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in Elixir code: | |
In Elixir code: |
guides/deploying/fly.md
Outdated
) | ||
``` | ||
|
||
in `runtime.exs`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in `runtime.exs`: | |
In `runtime.exs`: |
guides/deploying/fly.md
Outdated
end | ||
``` | ||
|
||
in fly.toml: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in fly.toml: | |
In fly.toml: |
```elixir | ||
ip_filter = Application.get_env(:your_app, :ice_ip_filter) | ||
|
||
{:ok, pc} = | ||
PeerConnection.start_link( | ||
ice_ip_filter: ip_filter, | ||
ice_servers: [%{urls: "stun:stun.l.google.com:19302"}] | ||
) | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] When :ice_ip_filter
is unset in the application, we're passing ice_ip_filter: nil
to PeerConnection
, which means
|> Keyword.put_new(:ice_ip_filter, fn _ -> true end) |
doesn't insert the default filter.
When we pass it to ICE, however, this line
https://github.com/elixir-webrtc/ex_ice/blob/4c5190687e11b28a8209f2c930895647d0b2a64c/lib/ex_ice/priv/ice_agent.ex#L137
makes it work again, as it gets the nil
stored in the keyword list and overrides it with the default filter.
I feel like this creates a kind of ambiguity and depends on ExICE not changing its behaviour of parsing options, which can potentially lead to hard-to-find errors in the future. To avoid this in this example, I would explicitly not insert ice_ip_filter
to the PC options when it's missing from the application's environment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
guides/deploying/fly.md
Outdated
``` | ||
|
||
That's it! | ||
No special UDP port exports or dedicated IP address needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No special UDP port exports or dedicated IP address needed. | |
No special UDP port exports or dedicated IP addresses are needed. |
No description provided.