Page MenuHomePhabricator

No OneTemporary

diff --git a/app.go b/app.go
index c4f818e..58faf2c 100644
--- a/app.go
+++ b/app.go
@@ -1,157 +1,177 @@
package sshtunnel
import (
"flag"
"strings"
"os"
"fmt"
"io"
"net"
"encoding/base64"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/agent"
"log"
)
type Client struct {
}
type Endpoint struct {
Host string
Port int
}
func KeyPrint(dialAddr string, addr net.Addr, key ssh.PublicKey) error {
fmt.Printf("%s %s %s\n", strings.Split(dialAddr, ":")[0], key.Type(), base64.StdEncoding.EncodeToString(key.Marshal()))
return nil
}
func (endpoint *Endpoint) String() string {
return fmt.Sprintf("%s:%d", endpoint.Host, endpoint.Port)
}
type SSHtunnel struct {
Local *Endpoint
Server *Endpoint
Remote *Endpoint
Config *ssh.ClientConfig
+ ServerConnection *ssh.ServerConfig
}
func (tunnel *SSHtunnel) Start() error {
listener, err := net.Listen("tcp", tunnel.Local.String())
if err != nil {
return err
}
defer listener.Close()
for {
conn, err := listener.Accept()
if err != nil {
return err
}
go tunnel.forward(conn)
}
}
func (tunnel *SSHtunnel) forward(localConn net.Conn) {
serverConn, err := ssh.Dial("tcp", tunnel.Server.String(), tunnel.Config)
if err != nil {
fmt.Printf("Server dial error: %s\n", err)
return
}
remoteConn, err := serverConn.Dial("tcp", tunnel.Remote.String())
if err != nil {
fmt.Printf("Remote dial error: %s\n", err)
return
}
copyConn:=func(writer, reader net.Conn) {
_, err:= io.Copy(writer, reader)
if err != nil {
fmt.Printf("io.Copy error: %s", err)
}
}
go copyConn(localConn, remoteConn)
go copyConn(remoteConn, localConn)
}
func SSHAgent() ssh.AuthMethod {
if sshAgent, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK")); err == nil {
return ssh.PublicKeysCallback(agent.NewClient(sshAgent).Signers)
}
return nil
}
func check(e error) {
if e != nil {
panic(e)
}
}
func(c *Client) Start(){
//Get the command line arguments
- remoteHostname := flag.String("remote-hostname", "motherbrain.unr.edu",
+ remoteHostname := flag.String("remote-hostname", "172.28.128.230",
"Remote hostname.")
remotePort := flag.Int("remote-port", 27013,
"The remote port bound through the server.")
//The intermediary server for port binding
serverHostname := flag.String("server", "ubuntu.cse.unr.edu", "a string")
+ flag.Parse()
+
+ // 27013
+ serverEndpoint := &Endpoint{
+ Host: *serverHostname,
+ Port: 22,
+
+ }
localEndpoint := &Endpoint{
Host: "localhost",
Port: 27013,
}
- log.Println( "Host:", localEndpoint.Host, "Port:" , localEndpoint.Port)
+ remoteEndpoint := &Endpoint{
+ Host: *remoteHostname,
+ Port: *remotePort,
+ }
- serverEndpoint := &Endpoint{
- Host: *serverHostname,
- Port: 22,
+ //5555
+ localEndpoint2 := &Endpoint{
+ Host: "localhost",
+ Port: 5555,
}
- log.Println( "Host:", serverEndpoint.Host, "Port:" , serverEndpoint.Port)
- remoteEndpoint := &Endpoint{
+ remoteEndpoint2 := &Endpoint{
Host: *remoteHostname,
- Port: *remotePort,
+ Port: 5555,
}
- log.Println( "Host:", remoteEndpoint.Host, "Port:" , remoteEndpoint.Port)
//credChan := make(chan Credentials)
var passwordForm= NewPasswordForm()
//passwordForm.SetChan(credChan)
passwordForm.Show();
credentials := passwordForm.Credentials
- log.Printf("Connecting to %s, User: %s ", *remoteHostname, credentials.Username)
+ 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: localEndpoint,
Server: serverEndpoint,
Remote: remoteEndpoint,
}
+ tunnel2 := &SSHtunnel{
+ Config: sshConfig,
+ Local: localEndpoint2,
+ Server: serverEndpoint,
+ Remote: remoteEndpoint2,
+ }
+
+ go tunnel2.Start()
tunnel.Start()
+
}
\ No newline at end of file
diff --git a/bin/main.manifest b/bin/main.manifest
new file mode 100644
index 0000000..e69de29
diff --git a/windows_ui.go b/windows_ui.go
index ccff359..0037dcb 100644
--- a/windows_ui.go
+++ b/windows_ui.go
@@ -1,61 +1,71 @@
// +build windows,!linux
package sshtunnel
import (
. "github.com/lxn/walk/declarative"
"github.com/lxn/walk"
)
type PasswordForm struct {
Credentials *Credentials
}
func NewPasswordForm() *PasswordForm {
return &PasswordForm{}
}
func (p *PasswordForm) Show(){
var mainWindow *walk.MainWindow
var usernameLE, passwordLE *walk.LineEdit
p.Credentials = &Credentials{Username:"Test"}
MainWindow{
AssignTo: &mainWindow,
Title: "Login",
MinSize: Size{250, 150},
Layout: VBox{},
Children: []Widget{
HSplitter{
Children: []Widget{
Label{ Text: "Username"},
LineEdit{ AssignTo: &usernameLE },
},
},
HSplitter{
Children: []Widget{
Label{ Text: "Password"},
- LineEdit{PasswordMode: true, AssignTo: &passwordLE},
+ LineEdit{PasswordMode: true,
+ AssignTo: &passwordLE,
+ OnKeyDown: func(key walk.Key) {
+ if key == walk.KeyReturn {
+ p.Credentials.Username = usernameLE.Text()
+ p.Credentials.Password = passwordLE.Text()
+ mainWindow.Close()
+ }
+ },
+ },
+
},
},
PushButton{
Text: "Login",
OnClicked: func() {
p.Credentials.Username = usernameLE.Text()
p.Credentials.Password = passwordLE.Text()
mainWindow.Close()
},
},
PushButton{
Text: "Cancel",
OnClicked: func() {
mainWindow.Close()
},
},
},
}.Run()
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Dec 22, 10:44 AM (13 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14757
Default Alt Text
(5 KB)

Event Timeline