Version 1.1.0
This commit is contained in:
		
							parent
							
								
									15803714a8
								
							
						
					
					
						commit
						aab3524082
					
				@ -17,7 +17,7 @@ func forward(localConn net.Conn, config *ssh.ClientConfig) {
 | 
			
		||||
	// Loop for retries:
 | 
			
		||||
	for {
 | 
			
		||||
 | 
			
		||||
		// Try to connect to the SSD server:
 | 
			
		||||
		// Try to connect to the SSH server:
 | 
			
		||||
		if sshClientConn, err := ssh.Dial(`tcp`, serverAddrString, config); err != nil {
 | 
			
		||||
 | 
			
		||||
			// Failed:
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										15
									
								
								Main.go
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								Main.go
									
									
									
									
									
								
							@ -1,18 +1,33 @@
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"golang.org/x/crypto/ssh"
 | 
			
		||||
	"runtime"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func main() {
 | 
			
		||||
 | 
			
		||||
	// Show the current version:
 | 
			
		||||
	fmt.Println(`SSHTunnel v1.1.0`)
 | 
			
		||||
 | 
			
		||||
	// Allow Go to use all CPUs:
 | 
			
		||||
	runtime.GOMAXPROCS(runtime.NumCPU())
 | 
			
		||||
 | 
			
		||||
	// Read the configuration from the command-line args:
 | 
			
		||||
	readFlags()
 | 
			
		||||
 | 
			
		||||
	// Check if the password was provided:
 | 
			
		||||
	for true {
 | 
			
		||||
		if password == `` {
 | 
			
		||||
			// Promt for the password:
 | 
			
		||||
			fmt.Println(`Please provide the password for the connection:`)
 | 
			
		||||
			fmt.Scanln(&password)
 | 
			
		||||
		} else {
 | 
			
		||||
			break
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Create the SSH configuration:
 | 
			
		||||
	config := &ssh.ClientConfig{
 | 
			
		||||
		User: username,
 | 
			
		||||
 | 
			
		||||
@ -8,7 +8,7 @@ func readFlags() {
 | 
			
		||||
	flag.StringVar(&serverAddrString, `server`, `127.0.0.1:22`, `The (remote) SSH server, e.g. 'my.host.com', 'my.host.com:22', '127.0.0.1:22', 'localhost:22'.`)
 | 
			
		||||
	flag.StringVar(&localAddrString, `local`, `127.0.0.1:50000`, `The local end-point of the tunnel, e.g. '127.0.0.1:50000', 'localhost:50000'.`)
 | 
			
		||||
	flag.StringVar(&remoteAddrString, `remote`, `127.0.0.1:27017`, `The remote side end-point (e.g. on the machine with the SSH server), e.g. a MongoDB (port 27017) '127.0.0.1:27017', a web server '127.0.0.1:80'`)
 | 
			
		||||
	flag.StringVar(&username, `user`, `username`, `The user's name for the SSD server.`)
 | 
			
		||||
	flag.StringVar(&password, `pwd`, `password`, `The user's password for the SSD server.`)
 | 
			
		||||
	flag.StringVar(&username, `user`, `username`, `The user's name for the SSH server.`)
 | 
			
		||||
	flag.StringVar(&password, `pwd`, ``, `The user's password for the SSH server.`)
 | 
			
		||||
	flag.Parse()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user