Version 1.1.0

This commit is contained in:
Thorsten Sommer 2015-09-23 20:30:44 +02:00
parent 15803714a8
commit aab3524082
3 changed files with 18 additions and 3 deletions

View File

@ -17,7 +17,7 @@ func forward(localConn net.Conn, config *ssh.ClientConfig) {
// Loop for retries: // Loop for retries:
for { 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 { if sshClientConn, err := ssh.Dial(`tcp`, serverAddrString, config); err != nil {
// Failed: // Failed:

15
Main.go
View File

@ -1,18 +1,33 @@
package main package main
import ( import (
"fmt"
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
"runtime" "runtime"
) )
func main() { func main() {
// Show the current version:
fmt.Println(`SSHTunnel v1.1.0`)
// Allow Go to use all CPUs: // Allow Go to use all CPUs:
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())
// Read the configuration from the command-line args: // Read the configuration from the command-line args:
readFlags() 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: // Create the SSH configuration:
config := &ssh.ClientConfig{ config := &ssh.ClientConfig{
User: username, User: username,

View File

@ -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(&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(&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(&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(&username, `user`, `username`, `The user's name for the SSH server.`)
flag.StringVar(&password, `pwd`, `password`, `The user's password for the SSD server.`) flag.StringVar(&password, `pwd`, ``, `The user's password for the SSH server.`)
flag.Parse() flag.Parse()
} }