Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F134934
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
View Options
diff --git a/app.go b/app.go
index c503fa7..d76150b 100644
--- a/app.go
+++ b/app.go
@@ -1,90 +1,91 @@
package sshtunnel
import (
"flag"
"log"
"golang.org/x/crypto/ssh"
"sync"
"os/exec"
"os"
"io"
)
func (c *Client) Start() {
var wg sync.WaitGroup
//The intermediary server for port binding
serverHostname := flag.String("server", "ubuntu.cse.unr.edu", "a string")
execPath := flag.String("exec", "", "a binary to execute after connecting.")
logFile := flag.String("log", "log.txt", "logfile location")
lf, err := os.OpenFile(*logFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
log.Fatalf("error opening file: %v", err)
}
defer lf.Close()
mw := io.MultiWriter(os.Stdout, lf)
log.SetOutput(mw)
var endpoints EndpointsFlag
flag.Var(&endpoints, "endpoints", "Local and remote endpoints")
flag.Parse()
if len(endpoints) < 1 {
log.Printf("No endpoints defined: %d\n", len(endpoints))
endpoints = make(EndpointsFlag, 0)
endpoints = append(endpoints, "5555:172.28.128.230:5555") // MATLAB
endpoints = append(endpoints, "25734:172.28.128.230:25734") // SolidWorks
endpoints = append(endpoints, "25735:172.28.128.230:25735") // SolidWorks
endpoints = append(endpoints, "7788:134.197.20.21:7788") // MATHCAD
+ endpoints = append(endpoints, "7789:134.197.20.21:7789") // MATHCAD
}
localE, remoteE := ParseEndpointsFromArray(endpoints)
log.Printf("localE: %v remoteE: %v", localE, remoteE)
// 27013
serverEndpoint := &Endpoint{
Host: *serverHostname,
Port: 22,
}
log.Printf("Endpoints: %v serverEndpoint: %v\n", endpoints, serverEndpoint)
var passwordForm = NewPasswordForm()
passwordForm.Show()
credentials := passwordForm.Credentials
log.Printf("Connecting to %s, User: %s ", *serverHostname, credentials.Username)
sshConfig := &ssh.ClientConfig{
User: credentials.Username,
HostKeyCallback: KeyPrint,
Auth: []ssh.AuthMethod{
ssh.Password(credentials.Password),
},
}
tunnel := &SSHtunnel{
Config: sshConfig,
Local: localE,
Server: serverEndpoint,
Remote: remoteE,
}
wg.Add(1)
go func() {
defer wg.Done()
tunnel.Start()
}()
if len(*execPath) > 0 {
cmd := exec.Command(*execPath)
err := cmd.Start()
if err != nil {
log.Fatal(err)
}
}
wg.Wait()
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Jan 24, 12:42 PM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14940
Default Alt Text
(2 KB)
Attached To
rST sshtunnel
Event Timeline
Log In to Comment