@@ -67,13 +67,13 @@ func TestProxying(t *testing.T) {
67
67
// We have to write out a config file so that Lantern doesn't try to use the
68
68
// default config, which would go to some remote proxies that can't talk to
69
69
// our fake config server.
70
- err = writeConfig (configAddr )
70
+ err = writeConfig ()
71
71
if ! assert .NoError (t , err ) {
72
72
return
73
73
}
74
74
75
75
// Starts the Lantern App
76
- err = startApp (t )
76
+ err = startApp (t , configAddr )
77
77
if ! assert .NoError (t , err ) {
78
78
return
79
79
}
@@ -138,15 +138,14 @@ func startConfigServer(t *testing.T) (string, error) {
138
138
if err != nil {
139
139
return "" , fmt .Errorf ("Unable to listen for config server connection: %v" , err )
140
140
}
141
- configAddr := l .Addr ().String ()
142
141
go func () {
143
- err := http .Serve (l , http .HandlerFunc (serveConfig (t , configAddr )))
142
+ err := http .Serve (l , http .HandlerFunc (serveConfig (t )))
144
143
assert .NoError (t , err , "Unable to serve config" )
145
144
}()
146
- return configAddr , nil
145
+ return l . Addr (). String () , nil
147
146
}
148
147
149
- func serveConfig (t * testing.T , configAddr string ) func (http.ResponseWriter , * http.Request ) {
148
+ func serveConfig (t * testing.T ) func (http.ResponseWriter , * http.Request ) {
150
149
return func (resp http.ResponseWriter , req * http.Request ) {
151
150
obfs4 := atomic .LoadUint32 (& useOBFS4 ) == 1
152
151
version := "1"
@@ -159,7 +158,7 @@ func serveConfig(t *testing.T, configAddr string) func(http.ResponseWriter, *htt
159
158
return
160
159
}
161
160
162
- cfg , err := buildConfig (configAddr , obfs4 )
161
+ cfg , err := buildConfig (obfs4 )
163
162
if err != nil {
164
163
t .Error (err )
165
164
resp .WriteHeader (http .StatusInternalServerError )
@@ -175,22 +174,22 @@ func serveConfig(t *testing.T, configAddr string) func(http.ResponseWriter, *htt
175
174
}
176
175
}
177
176
178
- func writeConfig (configAddr string ) error {
177
+ func writeConfig () error {
179
178
filename := "lantern-9999.99.99.yaml"
180
179
err := os .Remove (filename )
181
180
if err != nil && ! os .IsNotExist (err ) {
182
181
return fmt .Errorf ("Unable to delete existing yaml config: %v" , err )
183
182
}
184
183
185
- cfg , err := buildConfig (configAddr , false )
184
+ cfg , err := buildConfig (false )
186
185
if err != nil {
187
186
return err
188
187
}
189
188
190
189
return ioutil .WriteFile (filename , cfg , 0644 )
191
190
}
192
191
193
- func buildConfig (configAddr string , obfs4 bool ) ([]byte , error ) {
192
+ func buildConfig (obfs4 bool ) ([]byte , error ) {
194
193
bytes , err := ioutil .ReadFile ("./config-template.yaml" )
195
194
if err != nil {
196
195
return nil , fmt .Errorf ("Could not read config %v" , err )
@@ -201,8 +200,6 @@ func buildConfig(configAddr string, obfs4 bool) ([]byte, error) {
201
200
if err != nil {
202
201
return nil , fmt .Errorf ("Could not unmarshal config %v" , err )
203
202
}
204
- cfg .CloudConfig = "http://" + configAddr
205
- cfg .FrontedCloudConfig = cfg .CloudConfig
206
203
207
204
srv := cfg .Client .ChainedServers ["fallback-template" ]
208
205
srv .AuthToken = Token
@@ -236,8 +233,11 @@ func buildConfig(configAddr string, obfs4 bool) ([]byte, error) {
236
233
return out , nil
237
234
}
238
235
239
- func startApp (t * testing.T ) error {
236
+ func startApp (t * testing.T , configAddr string ) error {
237
+ configURL := "http://" + configAddr
240
238
flags := map [string ]interface {}{
239
+ "cloudconfig" : configURL ,
240
+ "frontedconfig" : configURL ,
241
241
"addr" : LocalProxyAddr ,
242
242
"headless" : true ,
243
243
"proxyall" : true ,
0 commit comments