i want to use specific tcp\dup socketopts.
in my case i want to use IP_TRANSPARENT SOCKET.
this is the page of tproxy documentation:
the option in the kernel ic constant number 19.
i have seen some examples on with setsockopt like this
http://pastie.org/314914 or the code in bottom.
but i am unable to understand how am i suppose to set the constant?
i have looked at the ruby source code and didnt found anywhere the word
IP_TRANSPARENT so i suppose it wasnt integrated into the source.
any suggestions?
Thanks,
Eliezer
require ‘socket’
opt = [1, 500_000].pack(“I_2”)
sock = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
sockaddr = Socket.pack_sockaddr_in(3232, ‘192.168.1.10’)
sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_RCVTIMEO, opt)
puts “sockopt = #{sock.getsockopt(Socket::SOL_SOCKET,
Socket::SO_RCVTIMEO).inspect}”
sock.connect(sockaddr)
#this tells the server at 192.168.1.10:3232 to wait 10 seconds before
responding, so we should get a timeout on our socket
sock.write(“10\r\n”)
start_time = Time.now
result = sock.gets
time = Time.now - start_time
puts “read: #{sock.gets} after: #{time} seconds”
#no timeout occured, this read returns after 10 seconds