@@ -25,6 +25,7 @@ import (
25
25
"github.com/getlantern/http-proxy-lantern/devicefilter"
26
26
lanternlisteners "github.com/getlantern/http-proxy-lantern/listeners"
27
27
"github.com/getlantern/http-proxy-lantern/mimic"
28
+ "github.com/getlantern/http-proxy-lantern/obfs4listener"
28
29
"github.com/getlantern/http-proxy-lantern/ping"
29
30
"github.com/getlantern/http-proxy-lantern/profilter"
30
31
"github.com/getlantern/http-proxy-lantern/redis"
54
55
serverId = flag .String ("serverid" , "" , "Server Id required for Pro-supporting servers" )
55
56
token = flag .String ("token" , "" , "Lantern token" )
56
57
tunnelPorts = flag .String ("tunnelports" , "" , "Comma seperated list of ports allowed for HTTP CONNECT tunnel. Allow all ports if empty." )
58
+ obfs4Addr = flag .String ("obfs4-addr" , "" , "Provide an address here in order to listen with obfs4" )
59
+ obfs4Dir = flag .String ("obfs4-dir" , "." , "Directory where obfs4 can store its files" )
57
60
)
58
61
59
62
func main () {
@@ -190,12 +193,26 @@ func main() {
190
193
mimic .SetServerAddr (addr )
191
194
}
192
195
196
+ if * obfs4Addr != "" {
197
+ l , err := obfs4listener .NewListener (* obfs4Addr , * obfs4Dir )
198
+ if err != nil {
199
+ log .Fatalf ("Unable to listen with obfs4: %v" , err )
200
+ }
201
+ go func () {
202
+ err := srv .Serve (l , func (addr string ) {
203
+ log .Debugf ("obfs4 listening at %v" , addr )
204
+ })
205
+ if err != nil {
206
+ log .Fatalf ("Error serving OBFS4: %v" , err )
207
+ }
208
+ }()
209
+ }
193
210
if * https {
194
- err = srv .ServeHTTPS (* addr , * keyfile , * certfile , initMimic )
211
+ err = srv .ListenAndServeHTTPS (* addr , * keyfile , * certfile , initMimic )
195
212
} else {
196
- err = srv .ServeHTTP (* addr , initMimic )
213
+ err = srv .ListenAndServeHTTP (* addr , initMimic )
197
214
}
198
215
if err != nil {
199
- log .Errorf ("Error serving: %v" , err )
216
+ log .Errorf ("Error serving HTTP(S) : %v" , err )
200
217
}
201
218
}
0 commit comments