Permalink
Browse files

Exporting server list to golang map

  • Loading branch information...
pulpofred
pulpofred committed Mar 10, 2016
1 parent 28dbd5c commit 7baf46ec5aafbd8d7b0aba0d1151a0a411b3c818
Showing with 39 additions and 2 deletions.
  1. +10 −0 fruho/add_from_file.tcl
  2. +2 −2 fruho/add_ibvpn.tcl
  3. +27 −0 fruho/model.tcl
@@ -114,6 +114,9 @@ proc ::from_file::ImportClicked {tab name} {
dict set ::model::Profiles $profileid profilename $newprofilename
dict set ::model::Profiles $profileid provider $name
# expose as an option to the user to export server list in various formats
# after 10000 [list temp-export-call $profileid planid_1]
# Delay in resolving server list domains - allow for completing the slist by appenders like in add_cyberghost
after 1000 go update-bulk-sitem $profileid
@@ -129,6 +132,13 @@ proc ::from_file::ImportClicked {tab name} {
}
}
proc temp-export-call {profileid planid} {
::model::slist-export-golang [::model::slist $profileid $planid]
}
# to eliminate obvious wrong file candidates upfront
proc are-selected-files-correct {files} {
if {$files eq ""} {
@@ -32,9 +32,9 @@ proc ::ibvpn::create-import-frame {tab} {
ttk::label $pconf.profilelabel -text "Profile name" -anchor e
ttk::entry $pconf.profileinput -textvariable ::${name}::newprofilename
ttk::label $pconf.profileinfo -foreground grey
ttk::label $pconf.usernamelabel -text "$dispname username" -anchor e
ttk::label $pconf.usernamelabel -text "Username (Email)" -anchor e
ttk::entry $pconf.usernameinput -textvariable ::${name}::username
ttk::label $pconf.usernameinfo -foreground grey -text "e.g. euahqiou"
ttk::label $pconf.usernameinfo -foreground grey -text ""
ttk::label $pconf.passwordlabel -text "$dispname password" -anchor e
ttk::entry $pconf.passwordinput -textvariable ::${name}::password
ttk::label $pconf.passwordinfo -foreground grey
@@ -362,6 +362,33 @@ proc ::model::sitem-by-id {profile planid sitem_id} {
return ""
}
proc ::model::slist-export-golang {slist} {
# TODO expose as an option for the user - exporting server list. Now we export to Golang map
set result ""
foreach sitem $slist {
set line ""
append line "Sitem\{\"[dict get $sitem id]\", \"[dict get $sitem ccode]\", \"[dict get $sitem country]\", \"[dict get $sitem city]\", \"[dict get $sitem ip]\", "
set ovses [dict get $sitem ovses]
append line "\[\]Ovs\{"
set ovslist {}
foreach ovs $ovses {
lappend ovslist "Ovs\{\"[dict get $ovs proto]\", \"[dict get $ovs port]\"\}"
}
append line [join $ovslist ", "]
append line "\}\},\n"
append result $line
}
puts stderr [log $result]
return $result
}
# [model now]
# return offset-ed current time, it may use previously saved time offset
# it should be server-originated UTC in seconds, if no offset use local time

0 comments on commit 7baf46e

Please sign in to comment.