INNER CODE UNIT · Go

handleSSHConnection

GoMudEngine/GoMud · main.go:1452

func handleSSHConnection(connDetails *connections.ConnectionDetails, reqs <-chan *ssh.Request, wg *sync.WaitGroup) {
	defer wg.Done()

	mudlog.Info("New SSH Connection", "connectionID", connDetails.ConnectionId(), "remoteAddr", connDetails.RemoteAddr().String())

	// Handle SSH channel requests (pty-req, window-change, shell, exec, etc.)
	// We run this in a goroutine so the read loop below can start immediately.
	go func() {
		for req := range reqs {
			switch req.Type {
			case "pty-req":
				// Parse terminal dimensions from the pty-req payload.
				// Payload: string term, uint32 cols, uint32 rows, uint32 width-px, uint32 height-px, string modes
				if len(req.Payload) >= 12 {
					// Skip the terminal name string: 4-byte length prefix + string bytes
					nameLen := int(req.Payload[0])<<24 | int(req.Payload[1])<<16 | int(req.Payload[2])<<8 | int(req.Payload[3])
					offset := 4 + nameLen
					if offset+8 <= len(req.Payload) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…