mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-05-09 18:31:43 +00:00
Allow binding to ports <1024 on non-linux builds (#136)
* Allow binding to ports <1024 on non-linux builds This seems to be only a restriction on Linux and Mac versions older then Mojave * Fix port check on djui_panel_join_ip_parse_port
This commit is contained in:
parent
b72344c6e4
commit
a957ce2aa0
2 changed files with 8 additions and 4 deletions
|
|
@ -27,7 +27,11 @@ static bool djui_panel_host_port_valid(void) {
|
||||||
port += (*buffer - '0');
|
port += (*buffer - '0');
|
||||||
buffer++;
|
buffer++;
|
||||||
}
|
}
|
||||||
|
#if __linux__
|
||||||
return port >= 1024 && port <= 65535;
|
return port >= 1024 && port <= 65535;
|
||||||
|
#else
|
||||||
|
return port <= 65535;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void djui_panel_host_port_text_change(struct DjuiBase* caller) {
|
static void djui_panel_host_port_text_change(struct DjuiBase* caller) {
|
||||||
|
|
|
||||||
|
|
@ -52,13 +52,13 @@ static bool djui_panel_join_ip_parse_spacer(char** msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool djui_panel_join_ip_parse_port(char** msg) {
|
static bool djui_panel_join_ip_parse_port(char** msg) {
|
||||||
int num = 0;
|
int port = 0;
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
char c = **msg;
|
char c = **msg;
|
||||||
if (c >= '0' && c <= '9') {
|
if (c >= '0' && c <= '9') {
|
||||||
// is number
|
// is number
|
||||||
num *= 10;
|
port *= 10;
|
||||||
num += (c - '0');
|
port += (c - '0');
|
||||||
*msg = *msg + 1;
|
*msg = *msg + 1;
|
||||||
} else if (i == 0) {
|
} else if (i == 0) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -67,7 +67,7 @@ static bool djui_panel_join_ip_parse_port(char** msg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return num >= 1024 && num <= 65535;
|
return port <= 65535;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool djui_panel_join_ip_valid(char* buffer) {
|
static bool djui_panel_join_ip_valid(char* buffer) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue