mirror of
https://github.com/bobbimanners/emailler.git
synced 2025-03-03 22:29:28 +00:00
skeleton of netboot65 server
git-svn-id: http://svn.code.sf.net/p/netboot65/code@9 93682198-c243-4bdb-bd91-e943c89aac3b
This commit is contained in:
parent
6b7515df66
commit
f5887251dd
@ -5,6 +5,7 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
def log_msg(msg)
|
def log_msg(msg)
|
||||||
puts "#{Time.now} #{msg}"
|
puts "#{Time.now} #{msg}"
|
||||||
end
|
end
|
||||||
|
43
server/netboot65_tftp.rb
Normal file
43
server/netboot65_tftp.rb
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#
|
||||||
|
# minimal TFTP server implementation for use with netboot65
|
||||||
|
#
|
||||||
|
# Jonno Downes (jonno@jamtronix.com) - January, 2009
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
require 'socket'
|
||||||
|
class Netboot65TFTPServer
|
||||||
|
|
||||||
|
attr_reader :bootfile_dir,:port,:server_thread
|
||||||
|
def initialize(bootfile_dir,port=6969)
|
||||||
|
@bootfile_dir=bootfile_dir
|
||||||
|
@port=port
|
||||||
|
@server_thread=nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def start()
|
||||||
|
log_msg "TFTP: serving #{bootfile_dir} on port #{port}"
|
||||||
|
Socket.do_not_reverse_lookup = true
|
||||||
|
@server_thread=Thread.start do
|
||||||
|
|
||||||
|
loop do
|
||||||
|
socket=UDPSocket.open
|
||||||
|
socket.setsockopt Socket::SOL_SOCKET, Socket::SO_REUSEADDR, 1
|
||||||
|
log_msg "waiting for TFTP client to connect"
|
||||||
|
socket.bind(nil,port)
|
||||||
|
data,addr_info=socket.recvfrom(4096)
|
||||||
|
client_ip=addr_info[3]
|
||||||
|
client_port=addr_info[1]
|
||||||
|
log_msg "TFTP: connect from #{client_ip}:#{client_port}"
|
||||||
|
socket.close
|
||||||
|
end
|
||||||
|
end
|
||||||
|
#server_thread.join
|
||||||
|
end
|
||||||
|
|
||||||
|
def shutdown()
|
||||||
|
log_msg "TFTP: stopping"
|
||||||
|
server_thread.kill
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user