Skip to content

Commit

Permalink
fix bug updating UI textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
Todd Blose committed Feb 18, 2015
1 parent c2b52e7 commit a79c122
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
7 changes: 3 additions & 4 deletions src/github.com/getlantern/flashlight/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type UIServer struct {

requests chan *Client
connClose chan *Client // handles client disconnects
ProxiedSitesChan chan *proxiedsites.Config
ProxiedSitesChan chan *proxiedsites.ProxiedSites
ConfigUpdates chan *config.Config
}

Expand Down Expand Up @@ -137,9 +137,8 @@ func (srv UIServer) readClientMessage(client *Client) {
if err != nil {
break
}
log.Debugf("Received proxied sites update from client: %+v", &updates)
srv.ProxiedSites.Update(&updates)
srv.ProxiedSitesChan <- srv.ProxiedSites.Cfg
srv.ProxiedSitesChan <- srv.ProxiedSites
}
}

Expand Down Expand Up @@ -183,7 +182,7 @@ func (srv UIServer) processRequests() {
// wait for YAML config updates
case cfg := <-srv.ConfigUpdates:

if reflect.DeepEqual(cfg.Client.ProxiedSites, srv.ProxiedSites.Cfg) {
if reflect.DeepEqual(cfg.Client.ProxiedSites, srv.ProxiedSites.GetConfig()) {
// ignore conifg update if proxied sites list is unchanged
continue
}
Expand Down
14 changes: 9 additions & 5 deletions src/github.com/getlantern/proxiedsites/proxiedsites.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ var (

type Config struct {
// Global list of white-listed domains
Cloud []string
Cloud []string `json:"-"`

// User customizations
Additions []string `json:"Additions, omitempty"`
Deletions []string `json:"Deletions, omitempty"`
}

type ProxiedSites struct {
Cfg *Config
cfg *Config

// Corresponding global proxiedsites set
cloudSet *set.Set
Expand Down Expand Up @@ -93,7 +93,7 @@ func New(cfg *Config) *ProxiedSites {
sort.Strings(entries)

ps := &ProxiedSites{
Cfg: cfg,
cfg: cfg,
entries: entries,
cloudSet: cloudSet,
addSet: addSet,
Expand Down Expand Up @@ -149,13 +149,17 @@ func (ps *ProxiedSites) Update(cfg *Config) {
ps.delSet.Add(cfg.Deletions[i])
}

ps.Cfg.Deletions = set.StringSlice(ps.delSet)
ps.Cfg.Additions = set.StringSlice(ps.addSet)
ps.cfg.Deletions = set.StringSlice(ps.delSet)
ps.cfg.Additions = set.StringSlice(ps.addSet)

ps.entries = set.StringSlice(set.Difference(ps.addSet, ps.delSet))
go ps.updatePacFile()
}

func (ps *ProxiedSites) GetConfig() *Config {
return ps.cfg
}

func GetPacFile() string {
return PacFilePath
}
Expand Down

0 comments on commit a79c122

Please sign in to comment.