refactor: separate core components and improve session & server handling

This commit is contained in:
2025-02-06 22:14:13 +07:00
parent dc219e2f7f
commit 8a1604fde8
9 changed files with 556 additions and 287 deletions

22
server/handler.go Normal file
View File

@ -0,0 +1,22 @@
package server
import (
"fmt"
"golang.org/x/crypto/ssh"
"log"
"net"
"tunnel_pls/session"
)
func (s *Server) handleConnection(conn net.Conn) {
sshConn, chans, reqs, err := ssh.NewServerConn(conn, s.Config)
if err != nil {
log.Printf("failed to establish SSH connection: %v", err)
conn.Close()
return
}
fmt.Println("SSH connection established:", sshConn.User())
session.New(sshConn, chans, reqs)
}