mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 00:50:18 +01:00 
			
		
		
		
	Support colon notation in host config definition
This commit is contained in:
		
							parent
							
								
									280f48cd18
								
							
						
					
					
						commit
						3a2c00dbcb
					
				@ -457,10 +457,10 @@ class Runtime
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function getSSHConfig()
 | 
					    public function getSSHConfig()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $sshConfig = $this->getEnvOption('ssh', ['port' => '22', 'flags' => '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no']);
 | 
					        $sshConfig = $this->getEnvOption('ssh', ['flags' => '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!array_key_exists('port', $sshConfig)) {
 | 
					        if (!array_key_exists('port', $sshConfig)) {
 | 
				
			||||||
            $sshConfig['port'] = '22';
 | 
					            $sshConfig['port'] = $this->getHostPort();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!array_key_exists('flags', $sshConfig)) {
 | 
					        if (!array_key_exists('flags', $sshConfig)) {
 | 
				
			||||||
@ -470,6 +470,17 @@ class Runtime
 | 
				
			|||||||
        return $sshConfig;
 | 
					        return $sshConfig;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Get the current Host Port or default ssh port
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @return integer
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function getHostPort()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $info = explode(':', $this->getWorkingHost());
 | 
				
			||||||
 | 
					        return isset($info[1]) ? $info[1] : '22';
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Gets a Temporal File name
 | 
					     * Gets a Temporal File name
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -119,6 +119,20 @@ class RuntimeTest extends TestCase
 | 
				
			|||||||
        $this->assertEquals('-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no', $sshConfig['flags']);
 | 
					        $this->assertEquals('-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no', $sshConfig['flags']);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function testSSHConfigPortDefinedInHostNotation()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $runtime = new Runtime();
 | 
				
			||||||
 | 
					        $runtime->setWorkingHost('223.12.24.64:1056');
 | 
				
			||||||
 | 
					        $sshConfig = $runtime->getSSHConfig();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->assertEquals('1056', $sshConfig['port']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $runtime->setWorkingHost('223.12.24.64');
 | 
				
			||||||
 | 
					        $sshConfig = $runtime->getSSHConfig();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->assertEquals('22', $sshConfig['port']);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function testSSHConfigEmptyOptions()
 | 
					    public function testSSHConfigEmptyOptions()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $runtime = new Runtime();
 | 
					        $runtime = new Runtime();
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user