50 lines
978 B
Scheme
50 lines
978 B
Scheme
(import frontend
|
|
command-line
|
|
texts
|
|
spiffy
|
|
openssl
|
|
(chicken tcp))
|
|
|
|
(define -port- (make-parameter #f))
|
|
(define -certificate- (make-parameter #f))
|
|
(define -key- (make-parameter #f))
|
|
|
|
(command-line
|
|
print-help
|
|
(-h () "This help"
|
|
(print banner-line)
|
|
(newline)
|
|
(print "Command-line options:")
|
|
(print-help)
|
|
(newline)
|
|
(exit 0))
|
|
(-license () "Show licensing terms"
|
|
(print banner-line)
|
|
(newline)
|
|
(print license)
|
|
(exit 0))
|
|
""
|
|
"Configuration options:"
|
|
(-p (port) "Listen port"
|
|
(-port- (string->number port)))
|
|
(-c (cert) "Certificate"
|
|
(-certificate- cert))
|
|
(-k (key) "Private key"
|
|
(-key- key))
|
|
)
|
|
|
|
(define ssl? (and (-certificate-) (-key-) #t))
|
|
(define port (or (-port-) (if ssl? 443 80)))
|
|
|
|
(print banner-line)
|
|
(print "Port: " port)
|
|
(print "SSL: " ssl?)
|
|
(when ssl?
|
|
(print " Certificate:" (-certificate-))
|
|
(print " Key:" (-key-)))
|
|
|
|
(define listener
|
|
(if ssl?
|
|
(ssl-listen port)
|
|
(tcp-listen port)))
|
|
|