summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go28
1 files changed, 21 insertions, 7 deletions
diff --git a/main.go b/main.go
index ebb0cbc..42dffc3 100644
--- a/main.go
+++ b/main.go
@@ -109,6 +109,7 @@ func doME(pm *Portmap, gus net.Listener) {
src, err := gus.Accept()
if err != nil {
log.Printf("Failed to accept client connection: %v\n", err)
+ pm.Enabled = false
return
}
@@ -121,19 +122,22 @@ func doME(pm *Portmap, gus net.Listener) {
// Read one line
line, err := reader.ReadString('\n')
if err != nil {
- log.Info("Error reading line:", err)
- return
+ log.Info("gus src", src.RemoteAddr(), "read error:", err)
+ continue
+ }
+ if !strings.HasPrefix(line, "/me") {
+ log.Printf("gus Received %d invalid bytes\n", len(line))
+ continue
}
- log.Info("gus got Received:", line)
parts := strings.Fields(line)
if len(parts) != 3 {
- return
+ continue
}
if parts[0] != "/me" {
- return
+ continue
}
if parts[1] != "hostname" {
- return
+ continue
}
hostname := parts[2]
msg := fmt.Sprintf("got hostname %s for %s", hostname, src.RemoteAddr())
@@ -142,7 +146,17 @@ func doME(pm *Portmap, gus net.Listener) {
if hostname == "framebook.wit.com" {
// Handle the connection in a separate goroutine
- go handleConnection(src, pm.Dest, int(pm.Localport))
+ log.Info("RUNNING DIAL")
+ dest, err := net.Dial("tcp", where)
+ if err != nil {
+ log.Printf("Failed to connect to %s %v", where, err)
+ continue
+ }
+ defer dest.Close()
+
+ log.Info("IOCOPY START")
+ ioCopy(src, dest)
+ log.Info("IOCOPY END")
}
}
}