Skip to content

Commit c19d0fb

Browse files
Merge pull request #413 from RiRe/patch-4
Add possibility to specify source IP address
2 parents 676c7db + 3c99945 commit c19d0fb

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Protocols/EPP/eppConnection.php

+19
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ class eppConnection {
184184
*/
185185
protected $connectionComment = null;
186186

187+
/**
188+
* @var null|string
189+
*/
190+
protected $sourceIpAddr = null;
191+
187192
/**
188193
* @var null|string
189194
*/
@@ -374,6 +379,11 @@ public function connect($hostname = null, $port = null) {
374379
stream_context_set_option($context, 'ssl', 'verify_peer', $this->verify_peer);
375380
}
376381
}
382+
if ($this->sourceIpAddr && filter_var($this->sourceIpAddr, FILTER_VALIDATE_IP)) {
383+
stream_context_set_option($context, 'socket', 'bindto', $this->sourceIpAddr . ":0");
384+
} else if (defined("METAREGISTRAR_EPP_SOURCE_IPADDR") && filter_var(METAREGISTRAR_EPP_SOURCE_IPADDR, FILTER_VALIDATE_IP)) {
385+
stream_context_set_option($context, 'socket', 'bindto', METAREGISTRAR_EPP_SOURCE_IPADDR . ":0");
386+
}
377387
$this->sslContext = $context;
378388
}
379389
$this->connection = stream_socket_client($this->hostname.':'.$this->port, $errno, $errstr, $this->timeout, STREAM_CLIENT_CONNECT, $this->sslContext);
@@ -1297,6 +1307,15 @@ public function setConnectionComment($connectionComment) {
12971307
return $this;
12981308
}
12991309

1310+
/**
1311+
* @param null|string $sourceIpAddr
1312+
* @return eppConnection
1313+
*/
1314+
public function setsourceIpAddr($sourceIpAddr) {
1315+
$this->sourceIpAddr = $sourceIpAddr;
1316+
return $this;
1317+
}
1318+
13001319

13011320

13021321

0 commit comments

Comments
 (0)