server.scm 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. ;;; server.scm -- SSH server API.
  2. ;; Copyright (C) 2013 Artyom V. Poptsov <poptsov.artyom@gmail.com>
  3. ;;
  4. ;; This file is a part of Guile-SSH.
  5. ;;
  6. ;; Guile-SSH is free software: you can redistribute it and/or
  7. ;; modify it under the terms of the GNU General Public License as
  8. ;; published by the Free Software Foundation, either version 3 of the
  9. ;; License, or (at your option) any later version.
  10. ;;
  11. ;; Guile-SSH is distributed in the hope that it will be useful, but
  12. ;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. ;; General Public License for more details.
  15. ;;
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with Guile-SSH. If not, see
  18. ;; <http://www.gnu.org/licenses/>.
  19. ;;; Commentary:
  20. ;; This module contains API that is used for SSH server.
  21. ;;
  22. ;; These methods are exported:
  23. ;;
  24. ;; %make-server
  25. ;; make-server
  26. ;; server-accept
  27. ;; server-set!
  28. ;; server-get
  29. ;; server-listen!
  30. ;; server-handle-key-exchange
  31. ;; server-message-get
  32. ;;; Code:
  33. (define-module (ssh server)
  34. #:use-module (ice-9 optargs)
  35. #:use-module (ssh log)
  36. #:export (server
  37. server?
  38. %make-server
  39. make-server
  40. server-accept
  41. server-set!
  42. server-get
  43. server-listen
  44. server-handle-key-exchange
  45. server-message-get))
  46. ;; Set a SSH option if it is specified by the user
  47. (define-macro (server-set-if-specified! option)
  48. `(if ,option (server-set! server (quote ,option) ,option)))
  49. (define* (make-server #:key bindaddr bindport hostkey dsakey rsakey banner
  50. log-verbosity blocking-mode)
  51. "Make a new SSH server with the specified configuration.\n
  52. Return a new SSH server."
  53. (let ((server (%make-server)))
  54. (server-set-if-specified! bindaddr)
  55. (server-set-if-specified! bindport)
  56. (server-set-if-specified! hostkey)
  57. (server-set-if-specified! dsakey)
  58. (server-set-if-specified! rsakey)
  59. (server-set-if-specified! banner)
  60. (server-set-if-specified! log-verbosity)
  61. (server-set-if-specified! blocking-mode)
  62. server))
  63. (load-extension "libguile-ssh" "init_server")
  64. ;;; server.scm ends here