diff --git a/src/danog/MadelineProto/DataCenter.php b/src/danog/MadelineProto/DataCenter.php index 3d2a6656..39f0010f 100644 --- a/src/danog/MadelineProto/DataCenter.php +++ b/src/danog/MadelineProto/DataCenter.php @@ -406,7 +406,7 @@ class DataCenter $combos = \array_unique($combos, SORT_REGULAR); } /* @var $context \Amp\ConnectContext */ - $context = $context ?? (new ConnectContext())->withMaxAttempts(1)->withConnectTimeout(1000 * $this->settings->getTimeout()); + $context = $context ?? (new ConnectContext())->withMaxAttempts(1)->withConnectTimeout(1000 * $this->settings->getTimeout())->withBindTo($this->settings->getBindTo()); foreach ($combos as $combo) { foreach ([true, false] as $useDoH) { $ipv6Combos = [ diff --git a/src/danog/MadelineProto/Settings/Connection.php b/src/danog/MadelineProto/Settings/Connection.php index 8b831512..f0d16722 100644 --- a/src/danog/MadelineProto/Settings/Connection.php +++ b/src/danog/MadelineProto/Settings/Connection.php @@ -91,6 +91,11 @@ class Connection extends SettingsAbstract */ protected bool $useDoH = true; + /** + * Bind on specific address and port. + */ + private ?string $bindTo = null; + /** * Subdomains of web.telegram.org for https protocol. */ @@ -623,4 +628,28 @@ class Connection extends SettingsAbstract return $this; } + + /** + * Get bind on specific address and port. + * + * @return ?string + */ + public function getBindTo(): ?string + { + return $this->bindTo; + } + + /** + * Set bind on specific address and port. + * + * @param ?string $bindTo Bind on specific address and port. + * + * @return self + */ + public function setBindTo(?string $bindTo): self + { + $this->bindTo = $bindTo; + + return $this; + } }