From 63954a3e621085d5866b109f9e74b5a4da16c3a5 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Wed, 13 Jan 2010 23:46:48 +0000 Subject: [PATCH] sshfs-mapper: improve map parser for the ruby version. git-svn-id: https://websvn.glenux.net/svn/Upoc/sshfs-mapper/trunk@1508 eaee96b3-f302-0410-b096-c6cfd47f7835 --- map.rb | 39 +++++++++++++++++++++++---------------- sshfs-mapper | 2 ++ 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/map.rb b/map.rb index 717ef32..a1c4b56 100644 --- a/map.rb +++ b/map.rb @@ -7,29 +7,34 @@ module SshfsMapper @host = nil @port = 22 @user = nil - @map = {} + @engine = :arcfour + @maps = {} end def parse() puts "Parsing map #{@path}" - File.open( @path ) do |f| - f.each do |line| - case line - when /^MAP\s*=\s*(\S+)\s*(\S+)\s*$/ then - @map[$1] = $2 - when /^REMOTE_HOST\s*=\s*(\S+)\s*$/ then + f = File.open( @path ) + f.each do |line| + case line + when /^\s*REMOTE_USER\s*=\s*(.*)\s*$/ + @user = $1 + when /^\s*REMOTE_PORT\s*=\s*(.*)\s*$/ + @port = $1.to_i + when /^\s*REMOTE_HOST\s*=\s*(.*)\s*$/ + @host = $1 + when /^\s*REMOTE_CYPHER\s*=\s*(.*)\s*$/ + idx = ["arcfour", "aes-256-cbc"].index( $1 ) + if not idx.nil? then @host = $1 - when /^REMOTE_PORT\s*=\s*(\S+)\s*$/ then - @port = $1 - when /^REMOTE_USER\s*=\s*(\S+)\s*$/ then - @user = $1 - when /^\s*$/ then - # skip - else - puts "unexpectd line '#{line}'" end + when /^\s*MAP\s*=\s*(.*)\s+(.*)\s*$/ + @maps[$1] = $2 + else + puts "dropping #{line}" end end + f.close + # end def is_alive? @@ -41,7 +46,9 @@ module SshfsMapper end def connect() - puts "Connecting map #{@path}" + puts "[#{File.basename @path}] Connecting..." + puts " #{@user}@#{@host}:#{@port}" + puts " maps = #{@maps}" # do something # test server connection # mount diff --git a/sshfs-mapper b/sshfs-mapper index 4da2603..2c22e1f 100644 --- a/sshfs-mapper +++ b/sshfs-mapper @@ -40,6 +40,8 @@ do_mount() { -o reconnect \ -o workaround=all \ -o cache_timeout=240 \ + -o ServerAliveInterval 15 \ + -o no_readahead \ -o Ciphers=arcfour \ -o Port=$remoteport \ $remotedir \