Display httpd URLs supporting HTTPS

This commit is contained in:
Kentaro Goto 2021-04-27 14:49:37 +09:00 коммит произвёл Kentaro Goto
Родитель 8361675e3a
Коммит f18e1752dc
1 изменённых файлов: 10 добавлений и 3 удалений

Просмотреть файл

@ -347,13 +347,20 @@ def httpd
options[:Port] ||= 8080 # HTTP Alternate
options[:DocumentRoot] = argv.shift || '.'
s = nil
options[:StartCallback] = Proc.new do
options[:StartCallback] = proc {
logger = s.logger
logger.info("To access this server, open this file in a browser:")
s.listeners.each do |listener|
if options[:SSLEnable]
addr = listener.addr
addr[3] = "127.0.0.1" if addr[3] == "0.0.0.0"
addr[3] = "::1" if addr[3] == "::"
logger.info(" https://#{Addrinfo.new(addr).inspect_sockaddr}")
else
logger.info(" http://#{listener.connect_address.inspect_sockaddr}")
end
end
}
s = WEBrick::HTTPServer.new(options)
shut = proc {s.shutdown}
siglist = %w"TERM QUIT"