mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-19 21:13:12 -07:00
Disable Don't Fragment for StreamConnection
This commit is contained in:
parent
7481cd1bce
commit
5b705e9176
4 changed files with 18 additions and 11 deletions
|
@ -116,6 +116,7 @@ typedef struct chiaki_takion_connect_info_t
|
||||||
ChiakiLog *log;
|
ChiakiLog *log;
|
||||||
struct sockaddr *sa;
|
struct sockaddr *sa;
|
||||||
size_t sa_len;
|
size_t sa_len;
|
||||||
|
bool ip_dontfrag;
|
||||||
ChiakiTakionCallback cb;
|
ChiakiTakionCallback cb;
|
||||||
void *cb_user;
|
void *cb_user;
|
||||||
bool enable_crypt;
|
bool enable_crypt;
|
||||||
|
|
|
@ -151,6 +151,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_senkusha_run(ChiakiSenkusha *senkusha, uint
|
||||||
memcpy(takion_info.sa, session->connect_info.host_addrinfo_selected->ai_addr, takion_info.sa_len);
|
memcpy(takion_info.sa, session->connect_info.host_addrinfo_selected->ai_addr, takion_info.sa_len);
|
||||||
err = set_port(takion_info.sa, htons(SENKUSHA_PORT));
|
err = set_port(takion_info.sa, htons(SENKUSHA_PORT));
|
||||||
assert(err == CHIAKI_ERR_SUCCESS);
|
assert(err == CHIAKI_ERR_SUCCESS);
|
||||||
|
takion_info.ip_dontfrag = true;
|
||||||
|
|
||||||
takion_info.enable_crypt = false;
|
takion_info.enable_crypt = false;
|
||||||
takion_info.protocol_version = 7;
|
takion_info.protocol_version = 7;
|
||||||
|
|
|
@ -142,6 +142,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_stream_connection_run(ChiakiStreamConnectio
|
||||||
memcpy(takion_info.sa, session->connect_info.host_addrinfo_selected->ai_addr, takion_info.sa_len);
|
memcpy(takion_info.sa, session->connect_info.host_addrinfo_selected->ai_addr, takion_info.sa_len);
|
||||||
err = set_port(takion_info.sa, htons(STREAM_CONNECTION_PORT));
|
err = set_port(takion_info.sa, htons(STREAM_CONNECTION_PORT));
|
||||||
assert(err == CHIAKI_ERR_SUCCESS);
|
assert(err == CHIAKI_ERR_SUCCESS);
|
||||||
|
takion_info.ip_dontfrag = false;
|
||||||
|
|
||||||
takion_info.enable_crypt = true;
|
takion_info.enable_crypt = true;
|
||||||
takion_info.protocol_version = 9;
|
takion_info.protocol_version = 9;
|
||||||
|
|
|
@ -245,23 +245,27 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_takion_connect(ChiakiTakion *takion, Chiaki
|
||||||
goto error_sock;
|
goto error_sock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(info->ip_dontfrag)
|
||||||
|
{
|
||||||
#if __APPLE__
|
#if __APPLE__
|
||||||
CHIAKI_LOGW(takion->log, "Don't fragment is not supported on macOS, MTU values may be incorrect.");
|
CHIAKI_LOGW(takion->log, "Don't fragment is not supported on macOS, MTU values may be incorrect.");
|
||||||
#else
|
#else
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
const DWORD dontfragment_val = 1;
|
const DWORD dontfragment_val = 1;
|
||||||
r = setsockopt(takion->sock, IPPROTO_IP, IP_DONTFRAGMENT, (const void *)&dontfragment_val, sizeof(dontfragment_val));
|
r = setsockopt(takion->sock, IPPROTO_IP, IP_DONTFRAGMENT, (const void *)&dontfragment_val, sizeof(dontfragment_val));
|
||||||
#else
|
#else
|
||||||
const int mtu_discover_val = IP_PMTUDISC_DO;
|
const int mtu_discover_val = IP_PMTUDISC_DO;
|
||||||
r = setsockopt(takion->sock, IPPROTO_IP, IP_MTU_DISCOVER, (const void *)&mtu_discover_val, sizeof(mtu_discover_val));
|
r = setsockopt(takion->sock, IPPROTO_IP, IP_MTU_DISCOVER, (const void *) &mtu_discover_val, sizeof(mtu_discover_val));
|
||||||
|
#endif
|
||||||
|
if(r < 0)
|
||||||
|
{
|
||||||
|
CHIAKI_LOGE(takion->log, "Takion failed to setsockopt IP_MTU_DISCOVER: %s", strerror(errno));
|
||||||
|
ret = CHIAKI_ERR_NETWORK;
|
||||||
|
goto error_sock;
|
||||||
|
}
|
||||||
|
CHIAKI_LOGI(takion->log, "Takion enabled Don't Fragment Bit");
|
||||||
#endif
|
#endif
|
||||||
if(r < 0)
|
|
||||||
{
|
|
||||||
CHIAKI_LOGE(takion->log, "Takion failed to setsockopt IP_MTU_DISCOVER: %s", strerror(errno));
|
|
||||||
ret = CHIAKI_ERR_NETWORK;
|
|
||||||
goto error_sock;
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
r = connect(takion->sock, info->sa, info->sa_len);
|
r = connect(takion->sock, info->sa, info->sa_len);
|
||||||
if(r < 0)
|
if(r < 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue