Skip to content

Commit

Permalink
Merge branch 'websocket-ox' into integration/websocket-ox-issue-2213
Browse files Browse the repository at this point in the history
  • Loading branch information
xiam committed Feb 20, 2015
2 parents 861c9ae + 0db1416 commit 58555ab
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
23 changes: 18 additions & 5 deletions src/github.com/getlantern/flashlight/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,40 @@ import (
"net/http"
"path"
"path/filepath"
"runtime"

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

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

var (
log = golog.LoggerFor("ui")

l net.Listener
fs http.FileSystem
server *http.Server
uiaddr string
l net.Listener
fs http.FileSystem
server *http.Server
uiaddr string
localResourcesPath string

r = http.NewServeMux()
)

// Assume the default directory containing UI assets is
// a sibling directory to this file's directory.
func init() {
_, curDir, _, ok := runtime.Caller(1)
if !ok {
log.Errorf("Unable to determine caller directory")
return
}
localResourcesPath = filepath.Join(curDir, LocalUIDir)
}

func Handle(p string, handler http.Handler) string {
r.Handle(p, handler)
return path.Join(uiaddr, p)
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

0 comments on commit 58555ab

Please sign in to comment.