hmmm. it's not working
This commit is contained in:
parent
a024c9ece1
commit
24962f3524
28
main.go
28
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue