Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F138632
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
14 KB
Subscribers
None
View Options
diff --git a/.idea/libraries/GOPATH__sshtunnel_.xml b/.idea/libraries/GOPATH__sshtunnel_.xml
new file mode 100644
index 0000000..5aff23e
--- /dev/null
+++ b/.idea/libraries/GOPATH__sshtunnel_.xml
@@ -0,0 +1,17 @@
+<component name="libraryTable">
+ <library name="GOPATH <sshtunnel>">
+ <CLASSES>
+ <root url="file://$USER_HOME$/go/src/github.com" />
+ <root url="file://$USER_HOME$/go/src/golang.org" />
+ <root url="file://$USER_HOME$/go/src/sshtunnel" />
+ </CLASSES>
+ <SOURCES>
+ <root url="file://$USER_HOME$/go/src/github.com" />
+ <root url="file://$USER_HOME$/go/src/golang.org" />
+ <root url="file://$USER_HOME$/go/src/sshtunnel" />
+ </SOURCES>
+ <excluded>
+ <root url="file://$PROJECT_DIR$" />
+ </excluded>
+ </library>
+</component>
\ No newline at end of file
diff --git a/main.go b/app.go
similarity index 60%
rename from main.go
rename to app.go
index 2963315..c4f818e 100644
--- a/main.go
+++ b/app.go
@@ -1,161 +1,157 @@
-package main
+package sshtunnel
import (
+ "flag"
"strings"
"os"
"fmt"
"io"
"net"
- "log"
- "encoding/base64"
+ "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
+ 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
}
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)
- }
+ if e != nil {
+ panic(e)
+ }
}
-func main() {
- fout, err := os.OpenFile("C:\\Projects\\sshtunnel\\sshtunnel_log.log", os.O_RDWR | os.O_CREATE | os.O_APPEND, 0666)
- check(err)
- log.SetOutput(fout)
- localHostName, err := os.Hostname()
- check(err)
+
+func(c *Client) Start(){
+ //Get the command line arguments
+ remoteHostname := flag.String("remote-hostname", "motherbrain.unr.edu",
+ "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")
+
localEndpoint := &Endpoint{
- Host: localHostName,
+ Host: "localhost",
Port: 27013,
}
+
log.Println( "Host:", localEndpoint.Host, "Port:" , localEndpoint.Port)
serverEndpoint := &Endpoint{
- Host: "ubuntu.cse.unr.edu",
+ Host: *serverHostname,
Port: 22,
}
log.Println( "Host:", serverEndpoint.Host, "Port:" , serverEndpoint.Port)
remoteEndpoint := &Endpoint{
- Host: "motherbrain.unr.edu",
- Port: 27013,
+ Host: *remoteHostname,
+ Port: *remotePort,
}
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)
+
sshConfig := &ssh.ClientConfig{
- User: "",
+ User: credentials.Username,
HostKeyCallback: KeyPrint,
Auth: []ssh.AuthMethod{
- ssh.Password(""),
+ ssh.Password(credentials.Password),
},
}
tunnel := &SSHtunnel{
Config: sshConfig,
Local: localEndpoint,
Server: serverEndpoint,
Remote: remoteEndpoint,
}
- var currentNetworkHardwareName string
-
- interfaces, _ := net.Interfaces()
- for _, interf := range interfaces {
- if addrs, err := interf.Addrs(); err == nil {
- for index, addr := range addrs {
- log.Println("[", index, "]", interf.Name, ">", addr)
-
- log.Println("Use name : ", interf.Name)
- currentNetworkHardwareName = interf.Name
- }
- }
- }
-
- // extract the hardware information base on the interface name
- // capture above
- netInterface, err := net.InterfaceByName(currentNetworkHardwareName)
- check(err)
- log.Println(netInterface)
-
- name := netInterface.Name
- macAddress := netInterface.HardwareAddr
-
- log.Println("Hardware name : ", name)
- log.Println("MAC address : ", macAddress)
-
tunnel.Start()
- fout.Close()
-}
+}
\ No newline at end of file
diff --git a/hostname.go b/bin/hostname.go
similarity index 100%
rename from hostname.go
rename to bin/hostname.go
diff --git a/localMac_addr.go b/bin/localMac_addr.go
similarity index 99%
rename from localMac_addr.go
rename to bin/localMac_addr.go
index fec529b..31d779f 100644
--- a/localMac_addr.go
+++ b/bin/localMac_addr.go
@@ -1,70 +1,71 @@
package main
import (
"fmt"
"net"
"strings"
"os"
+ "log"
)
func main() {
// localMacAddr, err := net.()
// if err != nil{
// panic(err)
// }
// fmt.Println("Local MAC addr:",localMacAddr)
//
//
var currentIP, currentNetworkHardwareName string
currentIP = "134.197.41.183/22"
interfaces, _ := net.Interfaces()
for _, interf := range interfaces {
if addrs, err := interf.Addrs(); err == nil {
for index, addr := range addrs {
if addr.String() != "127.0.0.1/8" {
log.Println("[", index, "]", interf.Name, ">", addr)
// only interested in the name with current IP address
if strings.Contains(addr.String(), currentIP) {
log.Println("Use name : ", interf.Name)
currentNetworkHardwareName = interf.Name
}
}
}
}
}
log.Println("-------------------------------------------")
// extract the hardware information base on the interface name
// capture above
netInterface, err := net.InterfaceByName(currentNetworkHardwareName)
if err != nil {
fmt.Println(err)
}
name := netInterface.Name
macAddress := netInterface.HardwareAddr
log.Println("Hardware name : ", name)
log.Println("MAC address : ", macAddress)
// verify if the MAC address can be parsed properly
hwAddr, err := net.ParseMAC(macAddress.String())
if err != nil {
log.Println("No able to parse MAC address : ", err)
os.Exit(-1)
}
log.Println("Physical hardware address : %s \n", hwAddr.String())
}
// net.Interfaces() // returns an array of interfaces
// net.InterfaceByName(oneOfTheReturnedInterfaces)
// ^.HardwareAddr
diff --git a/test.manifest b/bin/main.exe.manifest
similarity index 97%
rename from test.manifest
rename to bin/main.exe.manifest
index 6667f32..c4d6dd4 100644
--- a/test.manifest
+++ b/bin/main.exe.manifest
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="SomeFunkyNameHere" type="win32"/>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
- </assembly>
+ </assembly>
\ No newline at end of file
diff --git a/bin/main.go b/bin/main.go
new file mode 100644
index 0000000..3579cba
--- /dev/null
+++ b/bin/main.go
@@ -0,0 +1,12 @@
+package main
+
+import (
+ "sshtunnel"
+)
+
+
+func main() {
+ var sshClient = &sshtunnel.Client{};
+
+ sshClient.Start()
+}
diff --git a/credentials.go b/credentials.go
new file mode 100644
index 0000000..e05d9cc
--- /dev/null
+++ b/credentials.go
@@ -0,0 +1,7 @@
+package sshtunnel
+
+
+type Credentials struct {
+ Username string
+ Password string
+}
diff --git a/rsrc.syso b/rsrc.syso
deleted file mode 100644
index a90f3de..0000000
Binary files a/rsrc.syso and /dev/null differ
diff --git a/sshtunnel_log.log b/sshtunnel_log.log
deleted file mode 100644
index c53beb2..0000000
--- a/sshtunnel_log.log
+++ /dev/null
@@ -1,20 +0,0 @@
-2017/04/18 11:08:01 Localhost
-2017/04/18 11:08:01 Host: localhost Port: 27013
-2017/04/18 11:08:01 Host: ubuntu.cse.unr.edu Port: 22
-2017/05/01 15:14:06 Host: ECC-FRONT-01 Port: 27013
-2017/05/01 15:14:06 Host: ubuntu.cse.unr.edu Port: 22
-2017/05/01 15:14:06 Host: motherbrain.unr.edu Port: 27013
-2017/05/01 15:14:06 [ 0 ] Ethernet > fe80::781e:62ac:a47b:1dca/64
-2017/05/01 15:14:06 Use name : Ethernet
-2017/05/01 15:14:06 [ 1 ] Ethernet > 134.197.41.183/22
-2017/05/01 15:14:06 Use name : Ethernet
-2017/05/01 15:14:06 [ 0 ] Loopback Pseudo-Interface 1 > ::1/128
-2017/05/01 15:14:06 Use name : Loopback Pseudo-Interface 1
-2017/05/01 15:14:06 [ 1 ] Loopback Pseudo-Interface 1 > 127.0.0.1/8
-2017/05/01 15:14:06 Use name : Loopback Pseudo-Interface 1
-2017/05/01 15:14:06 [ 0 ] isatap.rd.unr.edu > fe80::200:5efe:86c5:29b7/128
-2017/05/01 15:14:06 Use name : isatap.rd.unr.edu
-2017/05/01 15:14:06 -------------------------------------------
-2017/05/01 15:14:06 &{3 1280 isatap.rd.unr.edu 00:00:00:00:00:00:00:e0 pointtopoint|multicast}
-2017/05/01 15:14:06 Hardware name : isatap.rd.unr.edu
-2017/05/01 15:14:06 MAC address : 00:00:00:00:00:00:00:e0
diff --git a/test/test.exe b/test/test.exe
deleted file mode 100644
index b86ea41..0000000
Binary files a/test/test.exe and /dev/null differ
diff --git a/test/test.exe.manifest b/test/test.exe.manifest
deleted file mode 100644
index 6667f32..0000000
--- a/test/test.exe.manifest
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
- <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
- <assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="SomeFunkyNameHere" type="win32"/>
- <dependency>
- <dependentAssembly>
- <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
- </dependentAssembly>
- </dependency>
- </assembly>
diff --git a/test/test.go b/test/test.go
deleted file mode 100644
index 68e4b5e..0000000
--- a/test/test.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package main
-
-import (
- "github.com/lxn/walk"
- . "github.com/lxn/walk/declarative"
- "strings"
- "os"
-)
-
-
-
-
-
-func main() {
- var inTE, outTE *walk.TextEdit
-
- MainWindow{
- Title: "Login",
- MinSize: Size{350, 200},
- Layout: VBox{},
- Children: []Widget{
- HSplitter{
- Children: []Widget{
- Label{ Text: "Username"},
- LineEdit{ },
- //TextEdit{AssignTo: &inTE},
- //TextEdit{AssignTo: &inTE, ReadOnly: false},
- //TextEdit{AssignTo: &inTE},
-
- },
- },
- HSplitter{
- Children: []Widget{
- Label{ Text: "Password"},
- //TextEdit{AssignTo: &inTE},
- LineEdit{PasswordMode: true, },
- //TextEdit{AssignTo: &inTE, ReadOnly: false},
- //TextEdit{AssignTo: &inTE},
-
- },
- },
- PushButton{
- Text: "Cancel",
- OnClicked: func() {
- outTE.SetText(strings.ToUpper(inTE.Text()))
- os.Exit(0)
- },
- },
- PushButton{
- Text: "Login",
- OnClicked: func() {
- outTE.SetText(strings.ToUpper(inTE.Text()))
- os.Exit(0)
- },
- },
- },
- }.Run()
-}
diff --git a/windows_ui.go b/windows_ui.go
new file mode 100644
index 0000000..ccff359
--- /dev/null
+++ b/windows_ui.go
@@ -0,0 +1,61 @@
+// +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},
+ },
+ },
+ 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
Details
Attached
Mime Type
text/x-diff
Expires
Tue, May 6, 12:02 AM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15593
Default Alt Text
(14 KB)
Attached To
rST sshtunnel
Event Timeline
Log In to Comment