git.cweiske.de
/
shpub.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add option to list all configured server connections
[shpub.git]
/
src
/
shpub
/
Command
/
Connect.php
diff --git
a/src/shpub/Command/Connect.php
b/src/shpub/Command/Connect.php
index bd1606eb849c96f6d64b99d616ac37c4907d41a2..b59de5ce10a668bebd91738b87de11af9fd87933 100644
(file)
--- a/
src/shpub/Command/Connect.php
+++ b/
src/shpub/Command/Connect.php
@@
-65,12
+65,18
@@
class Command_Connect
}
$this->cfg->hosts[$hostKey] = $host;
$this->cfg->save();
}
$this->cfg->hosts[$hostKey] = $host;
$this->cfg->save();
+ echo "Server configuration $hostKey saved successfully.\n";
}
protected function fetchAccessToken(
$host, $userUrl, $code, $redirect_uri, $state
) {
$req = new \HTTP_Request2($host->endpoints->token, 'POST');
}
protected function fetchAccessToken(
$host, $userUrl, $code, $redirect_uri, $state
) {
$req = new \HTTP_Request2($host->endpoints->token, 'POST');
+ if (version_compare(PHP_VERSION, '5.6.0', '<')) {
+ //correct ssl validation on php 5.5 is a pain, so disable
+ $req->setConfig('ssl_verify_host', false);
+ $req->setConfig('ssl_verify_peer', false);
+ }
$req->setHeader('Content-Type: application/x-www-form-urlencoded');
$req->setBody(
http_build_query(
$req->setHeader('Content-Type: application/x-www-form-urlencoded');
$req->setBody(
http_build_query(
@@
-125,9
+131,20
@@
class Command_Connect
protected function getHttpServerData()
{
protected function getHttpServerData()
{
- //FIXME: get IP from SSH_CONNECTION
$ip = '127.0.0.1';
$port = 12345;
$ip = '127.0.0.1';
$port = 12345;
+
+ if (isset($_SERVER['SSH_CONNECTION'])) {
+ $parts = explode(' ', $_SERVER['SSH_CONNECTION']);
+ if (count($parts) >= 3) {
+ $ip = $parts[2];
+ }
+ }
+ if (strpos($ip, ':') !== false) {
+ //ipv6
+ $ip = '[' . $ip . ']';
+ }
+
$redirect_uri = 'http://' . $ip . ':' . $port . '/callback';
$socketStr = 'tcp://' . $ip . ':' . $port;
return [$redirect_uri, $socketStr];
$redirect_uri = 'http://' . $ip . ':' . $port . '/callback';
$socketStr = 'tcp://' . $ip . ':' . $port;
return [$redirect_uri, $socketStr];
@@
-136,6
+153,11
@@
class Command_Connect
protected function verifyAuthCode($host, $code, $state, $redirect_uri, $me)
{
$req = new \HTTP_Request2($host->endpoints->authorization, 'POST');
protected function verifyAuthCode($host, $code, $state, $redirect_uri, $me)
{
$req = new \HTTP_Request2($host->endpoints->authorization, 'POST');
+ if (version_compare(PHP_VERSION, '5.6.0', '<')) {
+ //correct ssl validation on php 5.5 is a pain, so disable
+ $req->setConfig('ssl_verify_host', false);
+ $req->setConfig('ssl_verify_peer', false);
+ }
$req->setHeader('Content-Type: application/x-www-form-urlencoded');
$req->setBody(
http_build_query(
$req->setHeader('Content-Type: application/x-www-form-urlencoded');
$req->setBody(
http_build_query(