Skip to content

Commit 30a5473

Browse files
committed
Merge pull request #46 from getlantern/obfs4
Add obfs4 support to proxy
2 parents cca008b + a14b82d commit 30a5473

File tree

6 files changed

+229
-93
lines changed

6 files changed

+229
-93
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ http-proxy.raw
3434
test/data/http-proxy.raw
3535

3636
loader
37+
obfs4_bridgeline.txt
38+
obfs4_state.json
39+

http_proxy.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/getlantern/http-proxy-lantern/devicefilter"
2626
lanternlisteners "github.com/getlantern/http-proxy-lantern/listeners"
2727
"github.com/getlantern/http-proxy-lantern/mimic"
28+
"github.com/getlantern/http-proxy-lantern/obfs4listener"
2829
"github.com/getlantern/http-proxy-lantern/ping"
2930
"github.com/getlantern/http-proxy-lantern/profilter"
3031
"github.com/getlantern/http-proxy-lantern/redis"
@@ -54,6 +55,8 @@ var (
5455
serverId = flag.String("serverid", "", "Server Id required for Pro-supporting servers")
5556
token = flag.String("token", "", "Lantern token")
5657
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")
5760
)
5861

5962
func main() {
@@ -190,12 +193,26 @@ func main() {
190193
mimic.SetServerAddr(addr)
191194
}
192195

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+
}
193210
if *https {
194-
err = srv.ServeHTTPS(*addr, *keyfile, *certfile, initMimic)
211+
err = srv.ListenAndServeHTTPS(*addr, *keyfile, *certfile, initMimic)
195212
} else {
196-
err = srv.ServeHTTP(*addr, initMimic)
213+
err = srv.ListenAndServeHTTP(*addr, initMimic)
197214
}
198215
if err != nil {
199-
log.Errorf("Error serving: %v", err)
216+
log.Errorf("Error serving HTTP(S): %v", err)
200217
}
201218
}

0 commit comments

Comments
 (0)