diff --git a/src/github.com/getlantern/flashlight/logging/logging_test.go b/src/github.com/getlantern/flashlight/logging/logging_test.go index 2a828b7e5e..a9d0b6e41e 100644 --- a/src/github.com/getlantern/flashlight/logging/logging_test.go +++ b/src/github.com/getlantern/flashlight/logging/logging_test.go @@ -9,7 +9,6 @@ import ( "testing" "time" - "github.com/getlantern/eventual" "github.com/getlantern/go-loggly" "github.com/getlantern/golog" "github.com/stretchr/testify/assert" @@ -18,28 +17,19 @@ import ( // Test to make sure user agent registration, listening, etc is all working. func TestUserAgent(t *testing.T) { agent := "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.86 Safari/537.36" - userAgent := eventual.NewValue() - - listener := func(a string) { - userAgent.Set(a) - } // Do an initial register just to test the duplicate agent paths. RegisterUserAgent(agent) - AddUserAgentListener(listener) - go func() { - time.Sleep(200 * time.Millisecond) RegisterUserAgent(agent) }() - received, _ := userAgent.Get(4 * time.Second) - assert.Equal(t, agent, received.(string), "Unexpected agent!") + time.Sleep(200 * time.Millisecond) agents := getSessionUserAgents() - assert.True(t, strings.Contains(agents, "AppleWebKit"), "Expected agent not there!") + assert.True(t, strings.Contains(agents, "AppleWebKit"), "Expected agent not in "+agents) } type BadWriter struct{} diff --git a/src/github.com/getlantern/flashlight/logging/useragents.go b/src/github.com/getlantern/flashlight/logging/useragents.go index b674a6fcda..be095b14ab 100644 --- a/src/github.com/getlantern/flashlight/logging/useragents.go +++ b/src/github.com/getlantern/flashlight/logging/useragents.go @@ -11,16 +11,8 @@ var ( userAgents = make(map[string]int) agentsMutex = &sync.Mutex{} reg = regexp.MustCompile("^Go.*package http$") - listeners = make([]func(string), 0) ) -// AddUserAgentListener registers a listener for user agents. -func AddUserAgentListener(listener func(string)) { - agentsMutex.Lock() - defer agentsMutex.Unlock() - listeners = append(listeners, listener) -} - // RegisterUserAgent tries to find the User-Agent in the HTTP request // and keep track of the applications using Lantern during this session func RegisterUserAgent(agent string) { @@ -34,11 +26,6 @@ func RegisterUserAgent(agent string) { userAgents[agent] = n + 1 } else { userAgents[agent] = 1 - - // Only notify listeners when we have a new agent. - for _, f := range listeners { - f(agent) - } } } }()