-
-
Notifications
You must be signed in to change notification settings - Fork 21k
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
[3.2] DTLS support + optional ENet encryption #35091
Conversation
core/io/net_socket.h
Outdated
@@ -61,7 +61,7 @@ class NetSocket : public Reference { | |||
virtual Error connect_to_host(IP_Address p_addr, uint16_t p_port) = 0; | |||
virtual Error poll(PollType p_type, int timeout) const = 0; | |||
virtual Error recv(uint8_t *p_buffer, int p_len, int &r_read) = 0; | |||
virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) = 0; | |||
virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port, bool peek = false) = 0; |
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.
Should be p_peek
.
@@ -155,6 +158,9 @@ void register_core_types() { | |||
ClassDB::register_class<StreamPeerTCP>(); | |||
ClassDB::register_class<TCP_Server>(); | |||
ClassDB::register_class<PacketPeerUDP>(); | |||
ClassDB::register_class<UDPServer>(); |
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.
We have TCP_Server
and UDPServer
using different naming conventions. The former should be fixed, breaking compat in 4.0, I guess?
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.
The former should be fixed, breaking compat in 4.0, I guess?
Yeah, I agree, TCP_Server
should become TCPServer
@@ -38,6 +38,53 @@ static void my_debug(void *ctx, int level, | |||
fflush(stdout); | |||
} | |||
|
|||
void SSLContextMbedTLS::print_mbedtls_error(int ret) { |
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.
Should be p_ret
.
thirdparty/enet/godot.cpp
Outdated
virtual Error bind(IP_Address p_ip, uint16_t p_port) = 0; | ||
virtual Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP_Address p_ip, uint16_t p_port) = 0; | ||
virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) = 0; | ||
virtual int set_option(ENetSocketOption option, int value) = 0; |
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.
p_value
.
Due the fact the Godot 4.0 will take a long tike to became stable again, is there any chance to to see DTLS support and ENet encryption on 3.2 branch? |
This comment has been minimized.
This comment has been minimized.
19fddd1
to
d3eae91
Compare
@akien-mga I think this is ready now. I shall write documentation along with the post (we might want to wait for that, hopefully tomorrow). |
meh... I failed the rebase... will update ASAP |
0616ddc
to
ffe3fe5
Compare
UDP sockets can be "connected" to filter packets from a specific source. In case of a bound socket (e.g. server), a new socket can be created on the same address/port that will receive all packets that are not filtered by a more specific socket (e.g. the previously connect socket). This way, a UDPServer can listen to new packets, and return a new PacketPeerUDP when receiving one, knowing that is a "new client".
Custom instance implementation via the mbedtls module.
Non-DTLS implementation uses plain NetSocket for performance as before.
This is awesome! I've always loved enet's simplicity but the lack of encryption was a big negative for it. Would it be possible to extract the server part into a standalone C library so we can make lightweight servers in other languages? |
Well, not really, the DTLS implementation is in C++ and largely relies on Godot data structures, if you need a C implementation you are probably better off making one from scratch. |
What do you mean by "from the 3.2 version"? Did you check out my branch or
did you try to apply the patch to 3.2? It seems that you are missing some
changes.
What build options are you using?
…On Sat, Feb 29, 2020, 11:08 rieniter ***@***.***> wrote:
hello, I can't compile this module from 3.2 version
[image: 2020-02-29_162245]
<https://user-images.githubusercontent.com/34160378/75605513-17819d80-5b16-11ea-8212-11b243c9d8df.png>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#35091?email_source=notifications&email_token=AAM4C3SM7QD4DEEMF3PNQR3RFDPDPA5CNFSM4KGF4N6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENLV72Y#issuecomment-592928747>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAM4C3XYJPTQWPP5F6AYKKDRFDPDPANCNFSM4KGF4N6A>
.
|
Hello, thank you for your reply. I'm still a noober, so let me explain what i was done: |
I see, it won't work like that, you can either checkout my branch directly (e.g.): |
Thank you, it worked great ! |
8eb193d
to
69c1805
Compare
I have done lots of tests with DTLS in Godot 3.2. So far everything works pretty well. Is there any way to help on this? any test?? I would love to see PR merged. |
@Malkverbena The |
Let's get this merged for 3.2.2-beta2 and tested further. Thanks! |
@akien-mga does it works for beta4? |
It's merged since beta2, so it's in beta4 too. Whether it works as you expect it to is for you as a user to ascertain ;) |
@akien-mga does not work for me, i used certificate generator for certs, can it cause problemes ? |
@akien-mga used same code from this site https://godotengine.org/article/enet-dtls-encryption |
Please open an issue with a sample project that can trigger the bug. |
DTLS
ENet
thirdparty/enet/godot.cpp
to allow optional socket upgrade to DTLS.NetworkedMultiplayerENet
now supports optional DTLS encryption via theset_dtls_enabled
function. Allows setting key/certificate/verify options.Closes #19110