1
0
mirror of https://code.semirocket.science/wrapsix synced 2024-09-20 07:11:06 +03:00
wrapsix/wrapsix.rb
xHire 4bc68edce5 Improved creating of a socket for the resolver
Written new mechanism of wrapper from scratch in C
* It listens to all ICMPv6 packets (for now) and translates them to ICMPv4 ones
* It can compute the checksum of the packet as well
2008-12-31 13:41:21 +01:00

66 lines
1.4 KiB
Ruby
Executable File

#!/usr/bin/env ruby
#####
## WrapSix
###
#> wrapsix.rb
#~ Description...
####
# Author: Michal Zima, 2008
# E-mail: xhire@tuxportal.cz
#####
### Hardcoded configuration => configured by system administrator
$config = {}
$config['config_file'] = 'conf/wrapsix.conf'
#------------------------------------------------------------------------------#
### Include all necessary libraries
require 'yaml'
require 'socket'
# WrapSix libs
require 'lib/resolver'
require 'lib/wrapper'
### Parse command line arguments if any
### Load configuration
configuration = YAML.load_file $config['config_file']
## Merge both configs
$config.merge! configuration # FIX: this overwrites those configs from command line!
#p $config
### Start logging facility (system wide one)
### Handle some signals
# todo: replace this with right variables
def exit
$resolver.exit if $config['resolver']
$wrapper.exit if $config['wrapper']
Process.exit
end
# TERM -KILL- QUIT INT
trap "INT" do; exit; end
trap "TERM" do; exit; end
trap "QUIT" do; exit; end
services = []
### Start DNS resolver function
if $config['resolver'] == 1
$resolver = Resolver.new
services << Thread.start do; $resolver.start; end
end
### Start IPv6-to-IPv4 wrapper
if $config['wrapper'] == 1
$wrapper = Wrapper.new
services << Thread.start do; $wrapper.start; end
end
### Start WrapSix
# in best conditions it would *never* stop
services.each do |srvc| srvc.join end