35 lines
973 B
Crystal
35 lines
973 B
Crystal
require "./networkd"
|
|
|
|
networkd = NetworkD.new "network"
|
|
|
|
# --deny <in|out> <service> <url>
|
|
# --allow <in|ou> <service> <url>
|
|
# --redirect <service> <service>
|
|
# --redirect <service-name> <new-service-name> <origin-url> <dest-url>
|
|
|
|
networkd.parse_cli ARGV
|
|
puts networkd.to_s
|
|
|
|
networkd.loop do |event|
|
|
puts "there is an event!"
|
|
case event
|
|
when IPC::Event::Connection
|
|
puts "\033[32mConnection:\033[00m fd #{event.connection.fd}"
|
|
when IPC::Event::Disconnection
|
|
puts "\033[32mDisconnection:\033[00m fd #{event.connection.fd}"
|
|
when IPC::Event::ExtraSocket
|
|
puts "\033[32mExtrasocket:\033[00m fd #{event.connection.fd}"
|
|
when IPC::Event::Switch
|
|
puts "\033[31mSwitch\033[00m"
|
|
when IPC::Exception
|
|
puts "\033[31mException\033[00m"
|
|
when IPC::Event::Message
|
|
puts "\033[32mthere is a message\033[00m"
|
|
puts event.message.to_s
|
|
|
|
networkd.service_lookup event.message, event.connection
|
|
end
|
|
end
|
|
|
|
# pp! rules.authorized? Rule::Direction::In, "authd", "tls:192.168.0.42"
|