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
This commit is contained in:
parent
f53924cfbd
commit
63954a3e62
2 changed files with 25 additions and 16 deletions
39
map.rb
39
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
|
||||
|
|
|
@ -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 \
|
||||
|
|
Loading…
Reference in a new issue