Skip to content

Commit

Permalink
Merge 353db6a into 5d45823
Browse files Browse the repository at this point in the history
  • Loading branch information
oxtoacart committed Feb 20, 2015
2 parents 5d45823 + 353db6a commit 75b3506
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 32 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,16 @@ The script `tagandbuild.bash` tags and runs crosscompile.bash.

Note - ./crosscompile.bash omits debug symbols to keep the build smaller.

### Linux
### Building on Linux

crosscompile currently can't target Linux, so you will need to manually build on
Linux using `./linuxcompile.bash`.
Cross-compilation targeting Linux is currently not supported, so Linux releases
need to be built on Linux. There are some build prerequisites that you can pick
up with:

See https://github.com/getlantern/lantern/issues/2235.

`sudo apt-get install libgtk-3-dev libappindicator3-dev`

### Packaging for OS X
Lantern on OS X is packaged as the `Lantern.app` app bundle, distributed inside
of a drag-and-drop dmg installer. The app bundle and dmg can be created using
Expand Down
23 changes: 15 additions & 8 deletions src/github.com/getlantern/flashlight/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,21 +296,28 @@ func (cfg Config) cloudPollSleepTime() time.Duration {
return time.Duration((CloudConfigPollInterval.Nanoseconds() / 2) + rand.Int63n(CloudConfigPollInterval.Nanoseconds()))
}

func (cfg Config) fetchCloudConfig() ([]byte, error) {
func (cfg Config) fetchCloudConfig() (bytes []byte, err error) {
log.Debugf("Fetching cloud config from: %s", cfg.CloudConfig)
// Try it unproxied first
bytes, err := cfg.doFetchCloudConfig("")
if err != nil && cfg.IsDownstream() {
// If that failed, try it proxied
bytes, err = cfg.doFetchCloudConfig(cfg.Addr)

if cfg.IsDownstream() {
// Clients must always proxy the request
if cfg.Addr == "" {
err = fmt.Errorf("No proxyAddr")
} else {
bytes, err = cfg.doFetchCloudConfig(cfg.Addr)
}
} else {
bytes, err = cfg.doFetchCloudConfig("")
}
if err != nil {
return nil, fmt.Errorf("Unable to read yaml from %s: %s", cfg.CloudConfig, err)
bytes = nil
err = fmt.Errorf("Unable to read yaml from %s: %s", cfg.CloudConfig, err)
}
return bytes, err
return
}

func (cfg Config) doFetchCloudConfig(proxyAddr string) ([]byte, error) {
log.Tracef("doFetchCloudConfig via '%s'", proxyAddr)
client, err := util.HTTPClient(cfg.CloudConfigCA, proxyAddr)
if err != nil {
return nil, fmt.Errorf("Unable to initialize HTTP client: %s", err)
Expand Down
22 changes: 17 additions & 5 deletions src/github.com/getlantern/flashlight/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import (
"net/http"
"path"
"path/filepath"
"runtime"

"github.com/getlantern/golog"
"github.com/getlantern/tarfs"
"github.com/skratchdot/open-golang/open"
)

const (
localResourcesPath = "../lantern-ui/app"
LocalUIDir = "../../../lantern-ui/app"
)

var (
Expand All @@ -29,11 +30,22 @@ var (
)

func init() {
absLocalResourcesPath, err := filepath.Abs(localResourcesPath)
if err != nil {
absLocalResourcesPath = localResourcesPath
// Assume the default directory containing UI assets is
// a sibling directory to this file's directory.
localResourcesPath := ""
_, curDir, _, ok := runtime.Caller(1)
if !ok {
log.Errorf("Unable to determine caller directory")
} else {
localResourcesPath = filepath.Join(curDir, LocalUIDir)
absLocalResourcesPath, err := filepath.Abs(localResourcesPath)
if err != nil {
absLocalResourcesPath = localResourcesPath
}
log.Debugf("Creating tarfs filesystem that prefers local resources at %v", absLocalResourcesPath)
}
log.Debugf("Creating tarfs filesystem that prefers local resources at %v", absLocalResourcesPath)

var err error
fs, err = tarfs.New(Resources, localResourcesPath)
if err != nil {
panic(fmt.Errorf("Unable to open tarfs filesystem: %v", err))
Expand Down
3 changes: 2 additions & 1 deletion src/github.com/getlantern/flashlight/ui/ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func (c *UIChannel) write() {
c.m.Lock()
for _, conn := range c.conns {
conn.ws.Close()
delete(c.conns, conn.id)
}
c.m.Unlock()
}()
Expand Down Expand Up @@ -144,7 +145,7 @@ func (c *wsconn) read() {
_, b, err := c.ws.ReadMessage()
if err != nil {
if err != io.EOF {
log.Debugf("Error reading from UI: %v", err)
log.Errorf("Error reading from UI: %v", err)
}
return
}
Expand Down
6 changes: 1 addition & 5 deletions src/github.com/getlantern/proxiedsites/proxiedsites.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,7 @@ func toSet(s []string) set.Interface {

// toStrings converts a set into a slice of strings
func toStrings(s set.Interface) []string {
sl := s.List()
l := make([]string, len(sl))
for i, s := range sl {
l[i] = s.(string)
}
l := set.StringSlice(s)
sort.Strings(l)
return l
}
Expand Down
22 changes: 12 additions & 10 deletions src/github.com/getlantern/tarfs/tarfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"math"
"net/http"
"os"
"path"
"path/filepath"
"strings"
"time"
Expand Down Expand Up @@ -118,27 +119,28 @@ func (fs *FileSystem) SubDir(dir string) *FileSystem {
//
// Note - the implementation of local reads is not optimized and is primarily
// intended for development-time usage.
func (fs *FileSystem) Get(path string) ([]byte, error) {
path = filepath.Clean(path)
func (fs *FileSystem) Get(p string) ([]byte, error) {
p = path.Clean(p)
log.Tracef("Getting %v", p)
if fs.local != "" {
b, err := ioutil.ReadFile(filepath.Join(fs.local, path))
b, err := ioutil.ReadFile(filepath.Join(fs.local, p))
if err != nil {
if !os.IsNotExist(err) {
log.Debugf("Error accessing resource %v on filesystem: %v", path, err)
log.Debugf("Error accessing resource %v on filesystem: %v", p, err)
return nil, err
}
log.Tracef("Resource %v does not exist on filesystem, using embedded resource instead", path)
log.Tracef("Resource %v does not exist on filesystem, using embedded resource instead", p)
} else {
log.Tracef("Using local resource %v", path)
log.Tracef("Using local resource %v", p)
return b, nil
}
}
b, found := fs.files[path]
b, found := fs.files[p]
if !found {
err := fmt.Errorf("%v not found", path)
err := fmt.Errorf("%v not found", p)
return nil, err
}
log.Tracef("Using embedded resource %v", path)
log.Tracef("Using embedded resource %v", p)
return b, nil
}

Expand Down Expand Up @@ -204,7 +206,7 @@ type FakeFile struct {
}

func (f *FakeFile) Name() string {
_, name := filepath.Split(f.Path)
_, name := path.Split(f.Path)
return name
}

Expand Down

0 comments on commit 75b3506

Please sign in to comment.