feat: refactor configuration + html page template data
This commit is contained in:
@ -80,6 +80,11 @@ func (s *Server) handleRequest(ctx ssh.Context, srv *ssh.Server, req *gossh.Requ
|
||||
|
||||
addr := s.getSocketPath(sessionID)
|
||||
|
||||
if err := s.ensureFileDir(addr); err != nil {
|
||||
s.log("[ERROR] %+v", errors.WithStack(err))
|
||||
return false, []byte("internal server error")
|
||||
}
|
||||
|
||||
ln, err := net.Listen("unix", addr)
|
||||
if err != nil {
|
||||
s.log("[ERROR] %+v", errors.WithStack(err))
|
||||
@ -200,6 +205,15 @@ func (s *Server) getSocketPath(sessionID SessionID) string {
|
||||
return filepath.Join(s.opts.SockDir, fmt.Sprintf("%s.sock", sessionID))
|
||||
}
|
||||
|
||||
func (s *Server) ensureFileDir(file string) error {
|
||||
dir := filepath.Dir(file)
|
||||
if err := os.MkdirAll(dir, os.FileMode(0750)); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func generateToken(length int) (string, error) {
|
||||
chars := []rune(
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
|
||||
|
Reference in New Issue
Block a user