hmmm. it's not working

This commit is contained in:
Jeff Carr 2025-03-12 07:44:35 -05:00
parent a024c9ece1
commit 24962f3524
1 changed files with 21 additions and 7 deletions

28
main.go
View File

@ -109,6 +109,7 @@ func doME(pm *Portmap, gus net.Listener) {
src, err := gus.Accept() src, err := gus.Accept()
if err != nil { if err != nil {
log.Printf("Failed to accept client connection: %v\n", err) log.Printf("Failed to accept client connection: %v\n", err)
pm.Enabled = false
return return
} }
@ -121,19 +122,22 @@ func doME(pm *Portmap, gus net.Listener) {
// Read one line // Read one line
line, err := reader.ReadString('\n') line, err := reader.ReadString('\n')
if err != nil { if err != nil {
log.Info("Error reading line:", err) log.Info("gus src", src.RemoteAddr(), "read error:", err)
return 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) parts := strings.Fields(line)
if len(parts) != 3 { if len(parts) != 3 {
return continue
} }
if parts[0] != "/me" { if parts[0] != "/me" {
return continue
} }
if parts[1] != "hostname" { if parts[1] != "hostname" {
return continue
} }
hostname := parts[2] hostname := parts[2]
msg := fmt.Sprintf("got hostname %s for %s", hostname, src.RemoteAddr()) 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" { if hostname == "framebook.wit.com" {
// Handle the connection in a separate goroutine // 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")
} }
} }
} }