Permalink
Browse files

Initial commit

  • Loading branch information...
hypatia2 committed Aug 17, 2015
1 parent 74fcc45 commit ad274205076d37e4bedf472e1587272c836170b9
Showing with 8,731 additions and 1 deletion.
  1. +10 −0 .gitignore
  2. +24 −0 API.md
  3. +340 −0 LICENSE
  4. +1 −1 README.md
  5. BIN base-tcl
  6. +342 −0 bootstrap.tcl
  7. +132 −0 build.tcl
  8. +286 −0 fruho/add_from_file.tcl
  9. +134 −0 fruho/add_securitykiss.tcl
  10. +5 −0 fruho/bootstrap.lst
  11. +32 −0 fruho/certs/8b010802.0
  12. +2 −0 fruho/exclude/fruho
  13. +9 −0 fruho/exclude/usr/share/applications/fruho.desktop
  14. BIN fruho/exclude/usr/share/icons/hicolor/16x16/apps/fruho.png
  15. BIN fruho/exclude/usr/share/icons/hicolor/24x24/apps/fruho.png
  16. BIN fruho/exclude/usr/share/icons/hicolor/32x32/apps/fruho.png
  17. BIN fruho/exclude/usr/share/icons/hicolor/48x48/apps/fruho.png
  18. BIN fruho/exclude/usr/share/icons/hicolor/64x64/apps/fruho.png
  19. +42 −0 fruho/exclude/usr/share/icons/hicolor/scalable/apps/fruho.svg
  20. BIN fruho/images/16/attention.png
  21. BIN fruho/images/16/bang.png
  22. BIN fruho/images/16/connect.png
  23. BIN fruho/images/16/connecting.gif
  24. BIN fruho/images/16/disconnect.png
  25. BIN fruho/images/16/download.gif
  26. BIN fruho/images/16/downloading.gif
  27. BIN fruho/images/16/empty.png
  28. BIN fruho/images/16/error.gif
  29. BIN fruho/images/16/external.png
  30. BIN fruho/images/16/feedback.png
  31. BIN fruho/images/16/flag/DE.png
  32. BIN fruho/images/16/flag/EMPTY.png
  33. BIN fruho/images/16/flag/FR.png
  34. BIN fruho/images/16/flag/GB.png
  35. BIN fruho/images/16/flag/PL.png
  36. BIN fruho/images/16/flag/UK.png
  37. BIN fruho/images/16/flag/US.png
  38. BIN fruho/images/16/globe.png
  39. BIN fruho/images/16/info.png
  40. BIN fruho/images/16/logo.png
  41. BIN fruho/images/16/logo_cyberghost.png
  42. BIN fruho/images/16/logo_from_file.gif
  43. BIN fruho/images/16/logo_securitykiss.png
  44. BIN fruho/images/16/ok.gif
  45. BIN fruho/images/16/question.png
  46. BIN fruho/images/16/servers.png
  47. BIN fruho/images/16/settings.png
  48. BIN fruho/images/16/tick.png
  49. BIN fruho/images/16/updating.png
  50. BIN fruho/images/16/warning.png
  51. BIN fruho/images/24/connect.png
  52. BIN fruho/images/24/connecting.gif
  53. BIN fruho/images/24/disconnect.png
  54. BIN fruho/images/24/empty.png
  55. BIN fruho/images/24/feedback.png
  56. BIN fruho/images/24/flag/DE.png
  57. BIN fruho/images/24/flag/EMPTY.png
  58. BIN fruho/images/24/flag/FR.png
  59. BIN fruho/images/24/flag/GB.png
  60. BIN fruho/images/24/flag/PL.png
  61. BIN fruho/images/24/flag/UK.png
  62. BIN fruho/images/24/flag/US.png
  63. BIN fruho/images/24/globe.png
  64. BIN fruho/images/24/logo.png
  65. BIN fruho/images/24/options.png
  66. BIN fruho/images/24/servers.png
  67. BIN fruho/images/24/settings.png
  68. BIN fruho/images/32/connect.png
  69. BIN fruho/images/32/disconnect.png
  70. BIN fruho/images/32/downlink.png
  71. BIN fruho/images/32/globe.png
  72. BIN fruho/images/32/logo.png
  73. BIN fruho/images/32/servers.png
  74. BIN fruho/images/32/status/connected.png
  75. BIN fruho/images/32/status/connecting.gif
  76. BIN fruho/images/32/status/disconnected.png
  77. BIN fruho/images/32/status/unknown.png
  78. BIN fruho/images/32/uplink.png
  79. BIN fruho/images/64/flag/DE.png
  80. BIN fruho/images/64/flag/EMPTY.png
  81. BIN fruho/images/64/flag/FR.png
  82. BIN fruho/images/64/flag/GB.png
  83. BIN fruho/images/64/flag/PL.png
  84. BIN fruho/images/64/flag/UK.png
  85. BIN fruho/images/64/flag/US.png
  86. BIN fruho/images/64/logo.png
  87. +2,603 −0 fruho/main.tcl
  88. +41 −0 fruho/messages.txt
  89. +349 −0 fruho/model.tcl
  90. +45 −0 fruho/ovpn/config.ovpn
  91. +9 −0 fruhod/exclude/etc/fruhod/keys/signer_public.pem
  92. +68 −0 fruhod/exclude/etc/init.d/fruhod
  93. +35 −0 fruhod/exclude/fruhod.postinst
  94. 0 fruhod/exclude/fruhod.postrm
  95. +6 −0 fruhod/exclude/fruhod.preinst
  96. +27 −0 fruhod/exclude/fruhod.prerm
  97. +590 −0 fruhod/main.tcl
  98. +114 −0 fruhod/model.tcl
  99. +142 −0 fruhod/omgmt.tcl
  100. +2 −0 run.bat
  101. +3 −0 run.sh
  102. BIN sdx.kit
  103. +199 −0 sklib/anigif.tcl
  104. +70 −0 sklib/cmd.tcl
  105. +565 −0 sklib/csp.tcl
  106. +327 −0 sklib/https.tcl
  107. +495 −0 sklib/i18n.tcl
  108. +85 −0 sklib/img.tcl
  109. +190 −0 sklib/inicfg.tcl
  110. +107 −0 sklib/linuxdeps.tcl
  111. +394 −0 sklib/ovconf.tcl
  112. +806 −0 sklib/skutil.tcl
  113. +100 −0 sklib/unix.tcl
@@ -0,0 +1,10 @@
/build
/dist
/lib
/fruhod/builddate.txt
/fruhod/buildver.txt
/fruho/builddate.txt
/fruho/buildver.txt
/fruho/images/flag
/sklib/*.html
24 API.md
@@ -0,0 +1,24 @@
## FBAPI - Fruho Backend API
/check-for-updates
/ip
/dns-resolve
...
## VPAPI - VPN Provider API
This is the API defined and used by the Fruho program to import VPN configurations and plan definitions from third party VPN services. This also applies to Fruho as an interim VPN service so it must be implemented on bootstrap hosts along with FBAPI
All calls must be HTTPS with username and password passed via Basic Authentication
GET /api/config
Result: config.ovpn with inline CA and optionally KEY and CERT
GET /api/plans
Result: JSON plan description with server list
POST /api/cert
Input: CSR or PUBKEY posted in body request
Result: signed CRT
340 LICENSE

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -1,2 +1,2 @@
# fruhoapp
Fruho - Universal VPN Client
Fruho - Universal VPN client
BIN +2.38 MB base-tcl
Binary file not shown.
@@ -0,0 +1,342 @@
# This should be the preamble to every application
# It makes it possible to run as starpack or as a sourced script
if {![catch {package require starkit}]} {
#this is to initialize starkit variables
starkit::startup
}
set builddate [clock format [clock seconds] -gmt 1]
proc ex {args} {
return [exec -- {*}$args >&@ stdout]
}
# only for text files, assumes utf-8 encoding
proc slurp {path} {
set fd [open $path r]
fconfigure $fd -encoding utf-8
set data [read $fd]
close $fd
return $data
}
proc spit {path content} {
set fd [open $path w]
puts -nonewline $fd $content
close $fd
}
proc generalize-arch {arch} {
switch -glob $arch {
i?86 {return ix86}
x86_64 {return x86_64}
default {error "Unrecognized CPU architecture"}
}
}
proc this-arch {} {
return [generalize-arch $::tcl_platform(machine)]
}
proc this-os {} {
switch -glob $::tcl_platform(os) {
Linux {return linux}
Windows* {return win32}
default {error "Unrecognized OS"}
}
}
package require http
package require vfs::zip
proc platforminfo {} {
puts "Script name: $::argv0"
puts "Arguments:\n[join $::argv \n]"
puts "Current directory: [pwd]"
puts "This is Tcl version $::tcl_version , patchlevel $::tcl_patchLevel"
puts "[info nameofexecutable] is [info tclversion] patch [info patchlevel]"
puts "Directory(s) where package require will search:"
puts "$::auto_path"
puts "tcl_libPath = $::tcl_libPath" ;# May want to skip this one
puts "tcl_library = $::tcl_library"
puts "info library = [info library]"
puts "Shared libraries are expected to use the extension [info sharedlibextension]"
puts "platform information:"
parray ::tcl_platform
}
proc install-fpm {} {
if {[catch {exec fpm --version}] == 1} {
puts "Installing fpm"
ex sudo apt-get update --fix-missing
ex sudo apt-get -fy install git ruby-dev gcc rpm
#ex sudo apt-get -fy install rubygems
#ex sudo apt-get -fy install rubygems-integration
ex sudo gem install fpm
} else {
puts "fpm already present"
}
}
# also in sklib
proc unzip {zipfile {destdir .}} {
set mntfile [vfs::zip::Mount $zipfile $zipfile]
foreach f [glob [file join $zipfile *]] {
file copy $f $destdir
}
vfs::zip::Unmount $mntfile $zipfile
}
# convert pkg-name-1.2.3 into "pkg-name 1.2.3" or
# convert linux-ix86 into "linux ix86"
proc split-last-dash {s} {
set dashpos [string last - $s]
if {$dashpos > 0} {
return [string replace $s $dashpos $dashpos " "]
} else {
error "Wrong name to split: $s. It should contain at least one dash"
}
}
# Package presence is checked in the following order:
# 1. is pkg-ver in lib? => copy to build dir
# 2. is pkg-ver in teapot-cache? => prepare, unpack to lib dir, delete other versions in lib dir
# 3. is pkg-ver in tepot repo? => fetch to teapot-cache dir
# first prepare-pkg and copy from lib to build
proc copy-pkg {os arch pkgname ver proj} {
prepare-pkg $os $arch $pkgname $ver
set libdir [file join build $proj $os-$arch $proj.vfs lib]
#puts "Copying package $pkgname-$ver to $libdir"
if {\
[catch {file copy -force [file join lib $os-$arch $pkgname-$ver] $libdir}] &&\
[catch {file copy -force [file join lib generic $pkgname-$ver] $libdir}]} {
#if both copy attempts failed raise error
error "Could not find $pkgname-$ver neither in lib/$os-$arch nor lib/generic"
}
}
proc suffix_exec {os} {
array set os_suffix {
linux .bin
win32 .exe
}
return $os_suffix($os)
}
# recursively copy contents of the $from dir to the $to dir
# while overwriting items in $to if necessary
# ignore files matching glob pattern $ignore
proc copy-merge {from to {ignore ""}} {
file mkdir $to
foreach f [glob [file join $from *]] {
set tail [file tail $f]
if {![string match $ignore $tail]} {
if {[file isdirectory $f]} {
set new_to [file join $to $tail]
file mkdir $new_to
copy-merge $f $new_to
} else {
file copy -force $f $to
}
}
}
}
proc build {os arch_exact proj base {packages {}}} {
set arch [generalize-arch $arch_exact]
puts "\nStarting build ($os $arch $proj $base $packages)"
if {![file isdirectory $proj]} {
puts "Could not find project dir $proj"
return
}
set bld [file join build $proj $os-$arch]
puts "Cleaning build dir $bld"
file delete -force $bld
file mkdir [file join $bld $proj.vfs lib]
# we don't copy base-tcl/tk to build folder. Having it in lib is enough - hence prepare-pkg
prepare-pkg $os $arch {*}[split-last-dash $base]
foreach pkgver $packages {
copy-pkg $os $arch {*}[split-last-dash $pkgver] $proj
}
set vfs [file join $bld $proj.vfs]
puts "Copying project source files to VFS dir: $vfs"
copy-merge $proj $vfs exclude
set cmd [list [info nameofexecutable] sdx.kit wrap [file join $bld $proj[suffix_exec $os]] -vfs [file join $bld $proj.vfs] -runtime [file join lib $os-$arch $base]]
puts "Building starpack $proj"
puts $cmd
ex {*}$cmd
}
proc run {proj} {
ex [info nameofexecutable] [file join build $proj [this-os]-[this-arch] $proj.vfs main.tcl]
}
proc prepare-lib {pkgname ver} {
set dest [file join lib generic $pkgname-$ver]
file delete -force $dest
file mkdir $dest
copy-merge $pkgname $dest
pkg_mkIndex $dest
}
proc doc {path} {
package require doctools
::doctools::new mydtp -format html
set path [file normalize $path]
set dest [file join [file dir $path] [file root [file tail $path]].html]
spit $dest [mydtp format [slurp $path]]
}
# tarch - teapot specific architecture like linux-glibc2.3-x86_64
proc tarch {os arch} {
#TODO macosx
switch -exact $os {
linux {return $os-glibc2.3-$arch}
win32 {return $os-$arch}
default {error "Unrecognized os: $os"}
}
}
proc ctype2ext {ctype} {
switch -glob $ctype {
*application/x-zip* {return .zip}
*application/octet-stream* {return ""}
*text/plain* {return .tcl}
default {error "Unrecognized Content-Type: $ctype"}
}
}
# return random 0 <= x < $n
proc rand-int {n} {
return [expr {round(floor(rand()*$n))}]
}
# return 9-digit random integer
proc rand-big {} {
return [expr {100000000 + [rand-int 900000000]}]
}
# return the path to the cached package
proc teacup-fetch {os arch pkgname ver} {
set nv $pkgname-$ver
if {[string match base-* $pkgname]} {
set type application
set tarch_list [list [tarch $os $arch]]
} else {
set type package
set tarch_list [list tcl [tarch $os $arch]]
}
set tcdir [teapot-cache]
foreach tarch $tarch_list {
set tcpath /$type/name/$pkgname/ver/$ver/arch/$tarch
set tcpath_local [file normalize ../teapot-cache$tcpath]
foreach ext {.tcl .zip ""} {
set f $tcpath_local/$nv$ext
if {[file isfile $f]} {
puts stderr "Found cached $f"
return $f
}
}
}
foreach tarch $tarch_list {
set tcpath /$type/name/$pkgname/ver/$ver/arch/$tarch
set tcpath_local [file normalize ../teapot-cache$tcpath]
puts stderr "Fetching $nv-$tarch"
try {
set tmpfile /tmp/teacup_fetch_[rand-big]
set url http://teapot.activestate.com$tcpath/file
puts stderr "Fetching url: $url"
set tok [http::geturl $url -channel [open $tmpfile w]]
upvar #0 $tok state
if {[http::ncode $tok] == 200} {
array set meta [http::meta $tok]
puts stderr "Content-Type: $meta(Content-Type)"
set ext [ctype2ext $meta(Content-Type)]
puts stderr "ext=$ext"
file mkdir $tcpath_local
file rename -force $tmpfile $tcpath_local/$nv$ext
return $tcpath_local/$nv$ext
} else {
puts stderr "Fetching ERROR: Received http response: [http::code $tok]"
}
} on error {e1 e2} {
puts stderr "Could not fetch $nv ERROR: $e1 $e2"
} finally {
catch {set fd $state(-channel); close $fd;}
catch {file delete $tmpfile}
http::cleanup $tok
}
}
error "Could not fetch $nv"
}
proc teapot-cache {} {
set tcdir [file normalize ../teapot-cache]
if {![file isdir $tcdir]} {
ex git clone https://github.com/fruho/teapot-cache $tcdir
}
return $tcdir
}
proc prepare-pkg {os arch pkgname ver} {
file mkdir [file join lib $os-$arch]
set target_path_depend [file join lib $os-$arch $pkgname-$ver]
set target_path_indep [file join lib generic $pkgname-$ver]
# nothing to do if pkg exists in lib dir, it may be file or dir
if {[file exists $target_path_depend]} {
#puts "Already prepared: $target_path_depend"
return
}
if {[file exists $target_path_indep]} {
#puts "Already prepared: $target_path_indep"
return
}
set localpkg [teacup-fetch $os $arch $pkgname $ver]
puts "Preparing package $pkgname-$ver to place in lib folder"
switch -glob $localpkg {
*/application/*/arch/* {
file copy -force $localpkg $target_path_depend
return
}
*/package/*/arch/tcl/*.tcl {
file mkdir $target_path_indep
file copy $localpkg $target_path_indep
pkg_mkIndex $target_path_indep
return
}
*/package/*/arch/tcl/*.zip {
file mkdir $target_path_indep
#puts stderr "Unzipping to $target_path_indep"
unzip $localpkg $target_path_indep
return
}
*/package/*.zip {
file mkdir $target_path_depend
#puts stderr "Unzipping to $target_path_depend"
unzip $localpkg $target_path_depend
return
}
default {error "Could not determine what to do with $localpkg"}
}
}
#platforminfo
source build.tcl
Oops, something went wrong.

0 comments on commit ad27420

Please sign in to comment.