Skip to content

Commit

Permalink
Added a config var CURL_IPRESOLVE_V4 for forcing curl to ipv4
Browse files Browse the repository at this point in the history
Experimenting with this. Maybe this helps with timeouts
  • Loading branch information
Ninjasoturi committed Mar 15, 2024
1 parent 26eb802 commit 71c3ccb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions config/defaults-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"APIKEY_HASH":"",
"ENABLE_DDOS_PROTECTION": true,
"DDOS_MAXIMUM":"10",
"CURL_IPRESOLVE_V4": false,
"CURL_USEPROXY": false,
"CURL_PROXYSERVER":"http://example.com:8080",
"MAINTAINER":"",
Expand Down
14 changes: 11 additions & 3 deletions core/telegram/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ function edit_message($update, $message, $keys, $merge_args = false, $multicurl
* @param $id_val
* @param $text_val
* @param $markup_val
* @param null $chat_id
* @param int|null $chat_id
* @param mixed $merge_args
* @param $multicurl
*/
Expand Down Expand Up @@ -341,7 +341,7 @@ function edit_caption($update, $message, $keys, $merge_args = false, $multicurl
* @param $id_val
* @param $text_val
* @param $markup_val
* @param null $chat_id
* @param int|null $chat_id
* @param mixed $merge_args
* @param $multicurl
*/
Expand Down Expand Up @@ -649,7 +649,7 @@ function send_photo($chatObj, $media_content, $content_type, $text = '', $inline
* @param string $media_content content of the media file.
* @param bool $content_type true = photo file, false = file_id/url
* @param $markup_val
* @param null $chat_id
* @param int|null $chat_id
* @param mixed $merge_args
* @param $multicurl
*/
Expand Down Expand Up @@ -742,6 +742,10 @@ function curl_json_request($post_contents, $identifier)
if ($config->CURL_USEPROXY && !empty($config->CURL_PROXYSERVER)) {
curl_setopt($curl, CURLOPT_PROXY, $config->CURL_PROXYSERVER);
}
// Use only ipv4 if configured
if($config->CURL_IPRESOLVE_V4) {
curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
}

// Write to log.
if(is_array($post_contents)) debug_log(print_r($post_contents,true), '->');
Expand Down Expand Up @@ -806,6 +810,10 @@ function curl_json_multi_request($json)
if($config->CURL_USEPROXY && !empty($config->CURL_PROXYSERVER)) {
curl_setopt($curly[$id], CURLOPT_PROXY, $config->CURL_PROXYSERVER);
}
// Use only ipv4 if configured
if($config->CURL_IPRESOLVE_V4) {
curl_setopt($curly[$id], CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
}

// Curl post.
curl_setopt($curly[$id], CURLOPT_POST, true);
Expand Down

0 comments on commit 71c3ccb

Please sign in to comment.