X7ROOT File Manager
Current Path:
/opt/alt/ruby18/lib64/ruby/1.8/webrick
opt
/
alt
/
ruby18
/
lib64
/
ruby
/
1.8
/
webrick
/
??
..
??
accesslog.rb
(2.25 KB)
??
cgi.rb
(6.92 KB)
??
compat.rb
(436 B)
??
config.rb
(3.13 KB)
??
cookie.rb
(3.03 KB)
??
htmlutils.rb
(584 B)
??
httpauth
??
httpauth.rb
(1.31 KB)
??
httpproxy.rb
(7.46 KB)
??
httprequest.rb
(9.99 KB)
??
httpresponse.rb
(7.96 KB)
??
https.rb
(1.64 KB)
??
httpserver.rb
(5.63 KB)
??
httpservlet
??
httpservlet.rb
(669 B)
??
httpstatus.rb
(3.51 KB)
??
httputils.rb
(9.96 KB)
??
httpversion.rb
(1.12 KB)
??
log.rb
(2.03 KB)
??
server.rb
(5.28 KB)
??
ssl.rb
(4.22 KB)
??
utils.rb
(2.54 KB)
??
version.rb
(351 B)
Editing: utils.rb
# # utils.rb -- Miscellaneous utilities # # Author: IPR -- Internet Programming with Ruby -- writers # Copyright (c) 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou # Copyright (c) 2002 Internet Programming with Ruby writers. All rights # reserved. # # $IPR: utils.rb,v 1.10 2003/02/16 22:22:54 gotoyuzo Exp $ require 'socket' require 'fcntl' begin require 'etc' rescue LoadError nil end module WEBrick module Utils def set_non_blocking(io) flag = File::NONBLOCK if defined?(Fcntl::F_GETFL) flag |= io.fcntl(Fcntl::F_GETFL) end io.fcntl(Fcntl::F_SETFL, flag) end module_function :set_non_blocking def set_close_on_exec(io) if defined?(Fcntl::FD_CLOEXEC) io.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) end end module_function :set_close_on_exec def su(user) if defined?(Etc) pw = Etc.getpwnam(user) Process::initgroups(user, pw.gid) Process::Sys::setgid(pw.gid) Process::Sys::setuid(pw.uid) else warn("WEBrick::Utils::su doesn't work on this platform") end end module_function :su def getservername host = Socket::gethostname begin Socket::gethostbyname(host)[0] rescue host end end module_function :getservername def create_listeners(address, port, logger=nil) unless port raise ArgumentError, "must specify port" end res = Socket::getaddrinfo(address, port, Socket::AF_UNSPEC, # address family Socket::SOCK_STREAM, # socket type 0, # protocol Socket::AI_PASSIVE) # flag last_error = nil sockets = [] res.each{|ai| begin logger.debug("TCPServer.new(#{ai[3]}, #{port})") if logger sock = TCPServer.new(ai[3], port) port = sock.addr[1] if port == 0 Utils::set_close_on_exec(sock) sockets << sock rescue => ex logger.warn("TCPServer Error: #{ex}") if logger last_error = ex end } raise last_error if sockets.empty? return sockets end module_function :create_listeners RAND_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789" + "abcdefghijklmnopqrstuvwxyz" def random_string(len) rand_max = RAND_CHARS.size ret = "" len.times{ ret << RAND_CHARS[rand(rand_max)] } ret end module_function :random_string end end
Upload File
Create Folder