Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcery refactored devel branch #1

Open
wants to merge 517 commits into
base: devel
Choose a base branch
from
Open
Changes from 10 commits
Commits
Show all changes
517 commits
Select commit Hold shift + click to select a range
1f3d95c
moving more logs to trace
myleshorton Jun 3, 2016
a6a9800
Merge branch 'whitelistchained' of github.com:getlantern/lantern into…
oxtoacart Jun 3, 2016
e1c0c89
Turned more stuff down to TRACE logging
oxtoacart Jun 3, 2016
5a47173
Merge pull request #4502 from getlantern/whitelistchained
myleshorton Jun 3, 2016
b853610
Merge commit '1a3f8f9027a1d3aae38506765a1a61de8dac5328' into ops
oxtoacart Jun 4, 2016
f71e240
Pointing at latest http-proxy-lantern
oxtoacart Jun 4, 2016
0111f43
Merge commit '9527464257cc2346b89a4d308f412ad042520086' into ops
oxtoacart Jun 4, 2016
3262dac
Updated to new ops API
oxtoacart Jun 4, 2016
a2b7a2a
Merged from devel
oxtoacart Jun 4, 2016
f47a879
Merge commit '89a58f60ce6308b942262cc207da66bd91581fc1' into ops
oxtoacart Jun 4, 2016
c5b02a4
Moved fdcount to beginning of tests
oxtoacart Jun 4, 2016
fcf41ff
Removed bad fallback from default config
oxtoacart Jun 4, 2016
1eecf18
Merge pull request #4520 from getlantern/issue-4519
myleshorton Jun 4, 2016
a1f5c14
Merge branch 'devel' into ops
oxtoacart Jun 4, 2016
f7ddb21
fix dialDirect for issue 4500
Jun 4, 2016
9411e24
Removed borda
oxtoacart Jun 5, 2016
1f9f57f
Merge commit '22beae154f0be399d10fafdd5fc3cd064205e929' as 'src/githu…
oxtoacart Jun 5, 2016
963ca00
Added borda client to testpackages
oxtoacart Jun 5, 2016
7071b32
Added TLS ClientSessionCache in a few places to reduce TLS handshaking
oxtoacart Jun 5, 2016
5a09690
When no check function provided for dialer, return true
oxtoacart Jun 5, 2016
704332c
Changed timing on fdcount test to reduce spurious failures
oxtoacart Jun 5, 2016
1a5246d
Merge pull request #4525 from getlantern/tlscaching
myleshorton Jun 5, 2016
2415df8
Merge pull request #4524 from getlantern/chained-test-default
fffw Jun 5, 2016
48779de
Merge pull request #4521 from getlantern/issue-4500
fffw Jun 5, 2016
ef5da72
more reliable balancer check test
fffw Jun 6, 2016
b24d120
Merge pull request #4380 from getlantern/issue4268-fix
oxtoacart Jun 6, 2016
7496cf3
Not using DeviceID if it's not 6 bytes in length
oxtoacart Jun 7, 2016
08156b2
Merge commit '9b6d87c6e2f49cef6fa0a72544e9dcf3a3610ce5' into ops
oxtoacart Jun 7, 2016
ade58bc
Updated errors package, added some test packages
oxtoacart Jun 7, 2016
7655dea
Reenabled obfs4 test
oxtoacart Jun 7, 2016
ef4532e
Merge commit 'f5d74fc90217cbd702f8af641613ea72d74c5950' into ops
oxtoacart Jun 7, 2016
0877b85
Merge commit 'f368bbef9ecc713eaf8a8bbd34a722f714d8a59f' into ops
oxtoacart Jun 7, 2016
7ac6b8f
Updated to latest http-proxy
oxtoacart Jun 7, 2016
4efbac0
Merge commit '58e99cba9b02645fda70f451aabe110d99c12123' into ops
oxtoacart Jun 7, 2016
3b51b34
Grabbed latest http-proxy-lantern
oxtoacart Jun 7, 2016
02016fe
Removed getlantern/testify
oxtoacart Jun 7, 2016
f5ce9ea
Added more test packages
oxtoacart Jun 7, 2016
1c8d922
Added more test packages
oxtoacart Jun 7, 2016
cd18b40
Removed iniflags
oxtoacart Jun 7, 2016
b3e4749
Merged from devel
oxtoacart Jun 7, 2016
cb02d47
Merge commit 'deffe848a2cb80bb3a20223ebc84e68c6cb051e5' into ops
oxtoacart Jun 7, 2016
7ea9834
Merge commit '841d61d2c5d2293ec97cd720efbdae9cc1baeb69' into ops
oxtoacart Jun 7, 2016
9f288a6
Merge commit '22d407b032da88fed97872db947c4e1a4a375623' into ops
oxtoacart Jun 7, 2016
2cd4216
Resting right http-proxy package
oxtoacart Jun 7, 2016
87662a3
Using new golog.Errorf capability
oxtoacart Jun 7, 2016
7f8feec
Merge commit 'da01ba54094ed42a0e2ef2b6c513a2bb09a0a8d9' into ops
oxtoacart Jun 7, 2016
a85c97f
Merge commit '841333b91a8f99dce35a0ba684514a0106dc0959' into ops
oxtoacart Jun 7, 2016
ac9b073
Removed unnecessary test packages
oxtoacart Jun 7, 2016
3ca77ec
Merge commit 'b8fd45632ecf060fcb5199dabaac22d197987cbc' into ops
oxtoacart Jun 7, 2016
f32e1d0
Merge pull request #4363 from getlantern/ops
fffw Jun 8, 2016
6ad15e1
Merge commit 'c1e11d8473733fc2df37f1db184abf84f9f259b2' into connleak
oxtoacart Jun 8, 2016
805a50f
Removed old idletiming
oxtoacart Jun 8, 2016
dc132f5
Merge commit '7a9f4f5f4354c7f5e34a347a094c835914a32dd0' as 'src/githu…
oxtoacart Jun 8, 2016
6b70360
Fixed connection leak, using new idletiming API
oxtoacart Jun 8, 2016
43b2fb7
Added note about needing custom fork of go
oxtoacart Jun 8, 2016
356c7b5
Merge commit 'fa087136f5e4f8e7e42c43b6d3fb82359df959e3' into connleak
oxtoacart Jun 8, 2016
f7221b0
Merge pull request #4593 from getlantern/connleak
myleshorton Jun 8, 2016
411e622
Using custom Go in docker
oxtoacart Jun 9, 2016
ae0ef39
Sped up test target
oxtoacart Jun 9, 2016
5c2f9f0
Being smarter about rebuilding lantern
oxtoacart Jun 9, 2016
db40efe
Fully respect the stickyconfig flag
oxtoacart Jun 9, 2016
54b0269
Fixed fetcher_test
oxtoacart Jun 9, 2016
7de0afb
Merge commit '2e3b189e47f8f37fb910a171ad0de83c5dfd7a5e' into devel
oxtoacart Jun 9, 2016
2a26298
Merge pull request #4608 from getlantern/respectsticky
myleshorton Jun 9, 2016
f294615
Merge pull request #4600 from getlantern/fasttest
myleshorton Jun 9, 2016
95b0c36
Merge branch 'devel' of https://github.com/getlantern/lantern into devel
oxtoacart Jun 9, 2016
597dd67
Cleaned up logging of errors in pipeData
oxtoacart Jun 9, 2016
109042c
Fixed Makefile SOURCES for Mac
oxtoacart Jun 9, 2016
7f56045
Upgraded to latest gomobile
oxtoacart Jun 9, 2016
2eff257
Starting to use new netx package
oxtoacart Jun 10, 2016
0d1d7af
Refactored protected
oxtoacart Jun 10, 2016
62cedd3
Moved lantern-mobile back to its original spot
oxtoacart Jun 10, 2016
9ab47f4
Removed unneeded constant
oxtoacart Jun 10, 2016
3193d87
Fixed comment on Dial
oxtoacart Jun 10, 2016
79e3062
Ignoring EOF on reading from remote end while piping
oxtoacart Jun 12, 2016
a20a384
Changed origin to addr
oxtoacart Jun 12, 2016
036a1bb
Removed unused tlsdialer.DialWithDialer method
oxtoacart Jun 12, 2016
e9defbd
Merge pull request #4613 from getlantern/issue4554
Jun 12, 2016
f4a7375
Using interruptible bidirectional copying to keep idle connections fr…
oxtoacart Jun 15, 2016
b3f175a
Added hack to get lantern_test to pass
oxtoacart Jun 15, 2016
9150b96
Removed hack to get lantern_test to pass
oxtoacart Jun 15, 2016
7bdd91e
Fixed baked-in fallbacks
oxtoacart Jun 16, 2016
bf3bb4b
Merge pull request #4712 from getlantern/fixbakedin
oxtoacart Jun 16, 2016
c0d1e66
Merge branch 'devel' into issue4686
oxtoacart Jun 16, 2016
1e29bc1
Making netx test use ipv4
oxtoacart Jun 16, 2016
399037e
avoid panic when error hitting /startup fix #4633
fffw Jun 11, 2016
8b1022e
Merge pull request #4634 from getlantern/issue4633
fffw Jun 17, 2016
551bba5
Debugging netx
oxtoacart Jun 17, 2016
151ff4e
Fixed netx test failure on Linux
oxtoacart Jun 17, 2016
532a016
Running all tests again
oxtoacart Jun 17, 2016
5ca3b9d
netx.BidiCopy back to propagating original net errors
oxtoacart Jun 17, 2016
a250375
Addressed code review comments
oxtoacart Jun 17, 2016
f190aa4
handler now specifies write timeout to BidiCopy
oxtoacart Jun 17, 2016
acc2afe
BidiCopy test passing on Linux
oxtoacart Jun 17, 2016
160070f
Removed netx
oxtoacart Jun 20, 2016
f9de69c
Merge commit 'd02c77f506a4953e015f012634d6cc759cdc4ee9' as 'src/githu…
oxtoacart Jun 20, 2016
5964736
Fixed race condition in detour
oxtoacart Jun 20, 2016
f6f203b
Merge pull request #4707 from getlantern/issue4686
fffw Jun 21, 2016
11aa02b
updated bootstrap servers and masquerades
myleshorton Jun 23, 2016
ed76b30
Just added more details on the commit process.
myleshorton Jun 23, 2016
721e820
More notes on verifying the process.
myleshorton Jun 23, 2016
a8a3b4b
Update README.md
myleshorton Jun 23, 2016
0871d35
added git add of resources
myleshorton Jun 23, 2016
58a495a
Merge branch 'devel' of github.com:getlantern/lantern into devel
myleshorton Jun 23, 2016
6fafed1
balancer reset dialers right after new config is fetched
fffw Jun 24, 2016
02f2ac1
add test to cover resetting a balancer
fffw Jun 24, 2016
9580206
Add support for simulating autoupdates locally.
xiam Jun 29, 2016
d539fe3
Updating links
myleshorton Jul 1, 2016
34435b0
3.0.1
myleshorton Jul 1, 2016
0dda867
Update README.md
myleshorton Jul 1, 2016
7327113
Merge pull request #4848 from getlantern/feature/mock-autoupdates
myleshorton Jul 1, 2016
cf23ca3
Update README.md
myleshorton Jul 3, 2016
13f8a8b
updating to 3.0.4
myleshorton Jul 4, 2016
467cffd
extract method balancer.pickDialer
fffw Jul 5, 2016
e4e1d02
Merge pull request #4781 from getlantern/issue4705
oxtoacart Jul 5, 2016
0ff9507
Enabled borda reporting every 5 minutes for 1% of clients
oxtoacart Jul 6, 2016
f201d87
Merge pull request #4925 from getlantern/enableborda
fffw Jul 6, 2016
3e8adea
3.0.5
myleshorton Jul 6, 2016
79a537b
Update README.md
myleshorton Jul 6, 2016
40c1734
Increasing nofiles limit on UNIX systems
oxtoacart Jul 7, 2016
b45cc69
Merge pull request #4938 from getlantern/issue4928
myleshorton Jul 8, 2016
40344a2
Update README.md
myleshorton Jul 8, 2016
eefef40
3.0.6 link is 404
Jul 8, 2016
aafcbb9
Update README.md
myleshorton Jul 8, 2016
5f5f839
Just removing go 1.6 since we have the custom go build.
myleshorton Jul 11, 2016
d69f472
update to 3.0.7
myleshorton Jul 14, 2016
69d591a
lots of changes to fetch per-user proxies separately form global config
myleshorton Jul 21, 2016
3689a60
align balancer.lastDialTime in 64bit boundary
fffw Jul 6, 2016
bbabb70
linter
myleshorton Jul 21, 2016
d54d038
lots of changes to use a new config class for fetching, saving, etc w…
myleshorton Jul 21, 2016
d23fdbb
Fixed generic byte data
myleshorton Jul 21, 2016
1df1550
Merge pull request #5064 from getlantern/64bit-alignment
fffw Jul 22, 2016
c94b095
cleanups
myleshorton Jul 22, 2016
b03a168
Lots of changes to completely remove old config.go
myleshorton Jul 22, 2016
1f0f9a5
adding generating global config, removing yaml conf
myleshorton Jul 22, 2016
b63c2f5
more naming cleanups
myleshorton Jul 22, 2016
35d3a2b
fixed poll interval
myleshorton Jul 22, 2016
fc94184
added duration params
myleshorton Jul 22, 2016
5350f8d
fixed name
myleshorton Jul 22, 2016
a38a28b
lots of fixes to get the integration test working
myleshorton Jul 22, 2016
669a720
more naming fixes
myleshorton Jul 22, 2016
c3b1830
Added specific CA cert for auto-updates
myleshorton Jul 22, 2016
5db4055
Added comments and removed dead fields
myleshorton Jul 22, 2016
6a11475
removed yamlconf
myleshorton Jul 22, 2016
67cf93c
not used
myleshorton Jul 22, 2016
e740e6d
simplified this process a whole lot
myleshorton Jul 22, 2016
b83893f
moved boilerplate into config package
myleshorton Jul 23, 2016
76da387
cleaned up dispatch a little bit
myleshorton Jul 23, 2016
a958d0d
logging and global conf tweak
myleshorton Jul 23, 2016
a054b93
balancer don't retry same dialer if it was failed
fffw Jul 25, 2016
cec2b12
make it easier to spot issue from user logs
fffw Jul 25, 2016
65718b3
more cleanups and get global config from new location
myleshorton Jul 25, 2016
fe8103c
test cleanup
myleshorton Jul 26, 2016
5b9eaa2
fixed empty url check
myleshorton Jul 26, 2016
783ae3b
more simplifications
myleshorton Jul 26, 2016
e211908
Fixed names
myleshorton Jul 26, 2016
25ae0eb
Fixed incorrect logic for when we're not configured for proxying
myleshorton Jul 26, 2016
22640df
remove incorrect log
myleshorton Jul 26, 2016
3581a40
cleaned up locking
myleshorton Jul 26, 2016
cf04887
simpler flag processing
myleshorton Jul 26, 2016
028b9d2
Added loggly-sample-percentage command-line flag which defaults to sa…
oxtoacart Jul 26, 2016
aaf3673
tweaks to get tests working
myleshorton Jul 26, 2016
03726f8
Added message when we do report to Loggly
oxtoacart Jul 26, 2016
b19f95b
comments
myleshorton Jul 26, 2016
ca70822
change to use specific options
myleshorton Jul 26, 2016
041efe9
Merge pull request #5084 from getlantern/issue-5075
myleshorton Jul 27, 2016
b547fbd
fixed logs
myleshorton Jul 27, 2016
a1fca48
moved init stuff to config package
myleshorton Jul 27, 2016
813ab3c
made stuff more package private
myleshorton Jul 27, 2016
6c815a8
removed unnecessary go routine
myleshorton Jul 27, 2016
29b9bcf
removed log and fixed race in test
myleshorton Jul 28, 2016
a8968b8
attempt to fix race issues
myleshorton Jul 28, 2016
f326eee
actual fix for race issues
myleshorton Jul 28, 2016
4a8f264
put generated go file in generated folder
fffw Jul 28, 2016
fb5bac8
use correct template to generate config
fffw Jul 28, 2016
a2021e4
Merge branch 'devel' into issue5089
oxtoacart Jul 28, 2016
ab9cb07
Fixed deduplication for Loggly
oxtoacart Jul 28, 2016
f6ed999
Bumped up loggly sampling percentage
oxtoacart Jul 28, 2016
2b94cad
Added test for rate limiting
oxtoacart Jul 28, 2016
13b2d14
Added unit test for includeInSample
oxtoacart Jul 29, 2016
f75c884
Merge branch 'issue5089' into issue5096
oxtoacart Jul 29, 2016
4074691
Only configuring logging once
oxtoacart Jul 29, 2016
9154a52
Updated sampling algorithm back to original
oxtoacart Jul 29, 2016
4cf6126
Merge branch 'issue5089' into issue5096
oxtoacart Jul 29, 2016
56a4d36
Merge pull request #5099 from getlantern/issue5096
myleshorton Jul 30, 2016
6905970
Merge pull request #5090 from getlantern/issue5089
myleshorton Jul 30, 2016
bd822d7
updated during testing
myleshorton Aug 3, 2016
49ef327
Merge pull request #5097 from getlantern/issue-3567-generated
myleshorton Aug 3, 2016
cb9e104
reverse-merging from master
myleshorton Aug 3, 2016
76ef309
added back flag override support
myleshorton Aug 3, 2016
c2af99c
applyFlags return no error
fffw Aug 4, 2016
b91b7be
Merge pull request #5062 from getlantern/issue-3567
fffw Aug 4, 2016
fec55ba
Added translation comment.
myleshorton Aug 9, 2016
856a7f6
avoid calling multiple times when printing stack
fffw Jul 1, 2016
df90c5a
remove PRINT_STACK, no longer used
fffw Jul 2, 2016
8298106
another level of indention
fffw Jul 2, 2016
c76b05e
deduplicate golog code
fffw Jul 2, 2016
ea6360c
only print stack for FATAL and ERROR
fffw Jul 2, 2016
479e161
bring back original indention
fffw Aug 16, 2016
ba43a40
add back prefix for stack trace
fffw Aug 16, 2016
d78e584
use named parameter for PrintStack
fffw Aug 16, 2016
3317291
Merge pull request #4863 from getlantern/issue4803
oxtoacart Aug 16, 2016
73e0376
removed defunct projecttalk
myleshorton Nov 2, 2016
ee7929f
Merge pull request #5396 from getlantern/cfscanner
aranhoide Nov 4, 2016
dad3d74
Update README.md
Nov 15, 2016
d7bccd8
Update README.md
Nov 15, 2016
f05b8ff
Added separate beta section
myleshorton May 17, 2017
5e2b2d0
CAPS
myleshorton May 17, 2017
89bc343
Update README.md
myleshorton May 17, 2017
ea41d98
Update README.md
May 17, 2017
9572840
Added Used By badge
oxtoacart Jun 9, 2017
a18cd45
Added cloud yaml template
oxtoacart Feb 28, 2018
cc77aba
Update cloud.yaml
atavism Mar 2, 2018
0417f1d
Update cloud.yaml
atavism Mar 3, 2018
198046e
Update cloud.yaml
atavism Mar 13, 2018
14c7e0a
Update cloud.yaml
atavism Mar 17, 2018
f6a98cf
Update README.md
Jul 25, 2018
666f9a5
Update LICENSE
Nov 26, 2018
5048e62
Updated minimum required versions in README
myleshorton Apr 23, 2019
e46cebc
Merge pull request #8342 from getlantern/myleshorton-readme
myleshorton Apr 23, 2019
5a5d83a
adding archive
myleshorton Jun 20, 2019
7d7c846
moving to archive to make room for downloads
myleshorton Jun 20, 2019
313b412
more reshuffling
myleshorton Jun 20, 2019
507644a
removing a step
myleshorton Jun 20, 2019
56849f4
Update README.md
Jun 20, 2019
50d3527
Update README.md
Jun 20, 2019
10e8c0e
Added back beta links
myleshorton Jun 21, 2019
88520bb
Update README.md
Ghostwithout Jul 15, 2019
2ea216c
Update README.md
Ghostwithout Jul 15, 2019
2076ff9
Pointing to S3 instead of GitHub
oxtoacart Nov 3, 2019
c3eecaf
Fixed Linux links
oxtoacart Nov 3, 2019
8dc05ef
Only use s3 for now.
myleshorton Nov 3, 2019
84c89de
Update README.md
myleshorton Nov 3, 2019
96852c0
Update README.md
myleshorton Nov 3, 2019
651ec9e
Update README.md
Nov 12, 2019
15bffad
Update README.md
Ghostwithout Nov 27, 2019
3f7a634
Update README.md
Ghostwithout Dec 10, 2019
bc41f49
Update README.md
Ghostwithout Jan 1, 2020
e4cd60f
Update README.md
Feb 1, 2020
77d7a40
Update README.md
joesis Feb 1, 2020
6a63824
Update README.md
Feb 1, 2020
78baee7
Add Bitbucket links
joesis Feb 3, 2020
db8f0c7
Update README.md
Feb 3, 2020
799481c
Update README.md
Feb 3, 2020
2d97be5
Update README.md
Feb 3, 2020
1180c14
Switch main download link to GitLab
joesis Feb 9, 2020
ccb3079
Merge pull request #8371 from getlantern/joesis-patch-1
joesis Feb 9, 2020
1b846b2
version and link fix
myleshorton Feb 11, 2020
d05d3a7
Update README.md
Ghostwithout Feb 17, 2020
1eb4e84
'Refactored by Sourcery'
May 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -18,6 +18,9 @@

### Prerequisites

* [Custom fork of Go](https://github.com/getlantern/go/tree/lantern) is
currently required. We'll eventually switch to Go 1.7 which supports what we
need due to [this](https://github.com/golang/go/issues/13998).
* An OSX or Linux host. Building on Windows is only partially supported with
the help of [Cygwin](https://www.cygwin.com/).
* [Git](https://git-scm.com/downloads) - `brew install git`, `apt-get install git`, etc
15 changes: 7 additions & 8 deletions src/github.com/getlantern/flashlight/client/chained.go
Original file line number Diff line number Diff line change
@@ -14,10 +14,12 @@ import (
"github.com/getlantern/withtimeout"
)

// Close connections idle for a period to avoid dangling connections.
// 1 hour is long enough to avoid interrupt normal connections but short enough
// to eliminate "too many open files" error.
var idleTimeout = 1 * time.Hour
// Close connections idle for a period to avoid dangling connections. 45 seconds
// is long enough to avoid interrupt normal connections but shorter than the
// idle timeout on the server to avoid running into closed connection problems.
// 45 seconds is also longer than the MaxIdleTime on our http.Transport, so it
// doesn't interfere with that.
var idleTimeout = 45 * time.Second

// Lantern internal sites won't be used as check target.
var internalSiteSuffixes = []string{"getlantern.org", "getiantem.org", "lantern.io"}
@@ -123,10 +125,7 @@ func (s *chainedServer) dialer(deviceID string) (*balancer.Dialer, error) {
return nil, op.FailIf(err)
}
conn = idletiming.Conn(conn, idleTimeout, func() {
log.Debugf("Proxy connection to %s via %s idle for %v, closing", addr, conn.RemoteAddr(), idleTimeout)
if err := conn.Close(); err != nil {
log.Debugf("Unable to close connection: %v", err)
}
log.Debugf("Proxy connection to %s via %s idle for %v, closed", addr, conn.RemoteAddr(), idleTimeout)
})
return conn, nil
},
10 changes: 4 additions & 6 deletions src/github.com/getlantern/flashlight/client/handler.go
Original file line number Diff line number Diff line change
@@ -70,12 +70,12 @@ func (client *Client) intercept(resp http.ResponseWriter, req *http.Request, op
closeConns := func() {
if clientConn != nil {
if closeErr := clientConn.Close(); closeErr != nil {
log.Debugf("Error closing the out connection: %s", closeErr)
log.Tracef("Error closing the out connection: %s", closeErr)
}
}
if connOut != nil {
if closeErr := connOut.Close(); closeErr != nil {
log.Debugf("Error closing the client connection: %s", closeErr)
log.Tracef("Error closing the client connection: %s", closeErr)
}
}
}
@@ -114,13 +114,11 @@ func (client *Client) intercept(resp http.ResponseWriter, req *http.Request, op
// pipeData pipes data between the client and proxy connections. It's also
// responsible for responding to the initial CONNECT request with a 200 OK.
func pipeData(clientConn net.Conn, connOut net.Conn, op *ops.Op, closeFunc func()) {
writeErrCh := make(chan error)
writeErrCh := make(chan error, 1)
// Start piping from client to proxy
op.Go(func() {
_, writeErr := io.Copy(connOut, clientConn)
if writeErr != nil {
writeErrCh <- writeErr
}
writeErrCh <- writeErr
})

// Then start copying from proxy to client.
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ func defaultDialFactory(s *ChainedServerInfo, deviceID string) (dialFN, error) {
forceProxy := ForceChainedProxyAddr != ""
addr := s.Addr
if forceProxy {
log.Errorf("Forcing proxying to server at %v instead of configured server at %v", ForceChainedProxyAddr, s.Addr)
log.Debugf("Forcing proxying to server at %v instead of configured server at %v", ForceChainedProxyAddr, s.Addr)
addr = ForceChainedProxyAddr
}

2 changes: 2 additions & 0 deletions src/github.com/getlantern/flashlight/client/reverseproxy.go
Original file line number Diff line number Diff line change
@@ -18,7 +18,9 @@ import (
func (client *Client) newReverseProxy(bal *balancer.Balancer) *httputil.ReverseProxy {
transport := &http.Transport{
TLSHandshakeTimeout: 40 * time.Second,
MaxIdleTime: 30 * time.Second,
}
transport.EnforceMaxIdleTime()

// TODO: would be good to make this sensitive to QOS, which
// right now is only respected for HTTPS connections. The
4 changes: 4 additions & 0 deletions src/github.com/getlantern/flashlight/proxied/proxied.go
Original file line number Diff line number Diff line change
@@ -387,6 +387,10 @@ func chained(rootCA string, persistent bool) (http.RoundTripper, error) {
ClientSessionCache: clientSessionCache,
},
}
if persistent {
tr.MaxIdleTime = 30 * time.Second
tr.EnforceMaxIdleTime()
}

if rootCA != "" {
caCert, err := keyman.LoadCertificateFromPEMBytes([]byte(rootCA))
5 changes: 1 addition & 4 deletions src/github.com/getlantern/fronted/direct.go
Original file line number Diff line number Diff line change
@@ -234,10 +234,7 @@ func (d *direct) dialWith(in chan *Masquerade, network string) (net.Conn, bool,

log.Trace("Wrapping connecting in idletiming connection")
conn = idletiming.Conn(conn, idleTimeout, func() {
log.Tracef("Connection to %v idle for %v, closing", conn.RemoteAddr(), idleTimeout)
if err := conn.Close(); err != nil {
log.Tracef("Unable to close connection: %v", err)
}
log.Tracef("Connection to %v idle for %v, closed", conn.RemoteAddr(), idleTimeout)
})
log.Trace("Returning connection")
return conn, true, nil
2 changes: 1 addition & 1 deletion src/github.com/getlantern/http-proxy-lantern
6 changes: 1 addition & 5 deletions src/github.com/getlantern/http-proxy/forward/forward.go
Original file line number Diff line number Diff line change
@@ -47,11 +47,7 @@ func New(opts *Options) filters.Filter {
return nil, err
}

idleConn := idletiming.Conn(conn, opts.IdleTimeout, func() {
if conn != nil {
conn.Close()
}
})
idleConn := idletiming.Conn(conn, opts.IdleTimeout, nil)
return idleConn, err
}

Original file line number Diff line number Diff line change
@@ -108,11 +108,7 @@ func (f *httpConnectHandler) intercept(op ops.Op, w http.ResponseWriter, req *ht
errorf(op, "Unable to dial %v: %v", req.Host, err)
return
}
connOut := idletiming.Conn(connOutRaw, f.IdleTimeout, func() {
if connOutRaw != nil {
connOutRaw.Close()
}
})
connOut := idletiming.Conn(connOutRaw, f.IdleTimeout, nil)

// Pipe data through CONNECT tunnel
closeConns := func() {
8 changes: 1 addition & 7 deletions src/github.com/getlantern/http-proxy/listeners/idleconn.go
Original file line number Diff line number Diff line change
@@ -27,13 +27,7 @@ func (l *idleConnListener) Accept() (c net.Conn, err error) {
return nil, err
}

iConn := idletiming.Conn(
conn,
l.idleTimeout,
func() {
conn.Close()
},
)
iConn := idletiming.Conn(conn, l.idleTimeout, nil)

sac, _ := conn.(WrapConnEmbeddable)
return &idleConn{
113 changes: 89 additions & 24 deletions src/github.com/getlantern/idletiming/idletiming_conn.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,10 @@
package idletiming

import (
"errors"
"io"
"net"
"sync"
"sync/atomic"
"time"

@@ -13,23 +16,22 @@ import (
var (
epoch = time.Unix(0, 0)
log = golog.LoggerFor("idletiming")

// ErrIdled is return when attempting to use a network connection that was
// closed because of idling.
ErrIdled = errors.New("Use of idled network connection")
)

// Conn creates a new net.Conn wrapping the given net.Conn that times out after
// the specified period. Read and Write calls will timeout if they take longer
// than the indicated idleTimeout.
// the specified period. Once a connection has timed out, any pending reads or
// writes will return io.EOF and the underlying connection will be closed.
//
// idleTimeout specifies how long to wait for inactivity before considering
// connection idle.
//
// onIdle is a required function that's called if a connection idles.
// idletiming.Conn does not close the underlying connection on idle, you have to
// do that in your onIdle callback.
// If onIdle is specified, it will be called to indicate when the connection has
// idled and been closed.
func Conn(conn net.Conn, idleTimeout time.Duration, onIdle func()) *IdleTimingConn {
if onIdle == nil {
panic("onIdle is required")
}

c := &IdleTimingConn{
conn: conn,
idleTimeout: idleTimeout,
@@ -50,7 +52,10 @@ func Conn(conn net.Conn, idleTimeout time.Duration, onIdle func()) *IdleTimingCo
atomic.StoreInt64(&c.lastActivityTime, time.Now().UnixNano())
continue
case <-timer.C:
onIdle()
c.Close()
if onIdle != nil {
onIdle()
}
return
case <-c.closedCh:
return
@@ -70,11 +75,15 @@ type IdleTimingConn struct {
writeDeadline int64
lastActivityTime int64

conn net.Conn
idleTimeout time.Duration
halfIdleTimeout time.Duration
activeCh chan bool
closedCh chan bool
conn net.Conn
idleTimeout time.Duration
halfIdleTimeout time.Duration
activeCh chan bool
closedCh chan bool
closeMutex sync.RWMutex // prevents Close() from interfering with io operations
closed bool
hasReadAfterIdle int32
hasWrittenAfterIdle int32
}

// TimesOutIn returns how much time is left before this connection will time
@@ -91,6 +100,13 @@ func (c *IdleTimingConn) TimesOutAt() time.Time {

// Read implements the method from io.Reader
func (c *IdleTimingConn) Read(b []byte) (int, error) {
c.closeMutex.RLock()
defer c.closeMutex.RUnlock()

if err := c.checkClosed(&c.hasReadAfterIdle); err != nil {
return 0, err
}

totalN := 0
readDeadline := time.Unix(0, atomic.LoadInt64(&c.readDeadline))

@@ -132,6 +148,13 @@ func (c *IdleTimingConn) Read(b []byte) (int, error) {

// Write implements the method from io.Reader
func (c *IdleTimingConn) Write(b []byte) (int, error) {
c.closeMutex.RLock()
defer c.closeMutex.RUnlock()

if err := c.checkClosed(&c.hasWrittenAfterIdle); err != nil {
return 0, err
}

totalN := 0
writeDeadline := time.Unix(0, atomic.LoadInt64(&c.writeDeadline))

@@ -174,6 +197,15 @@ func (c *IdleTimingConn) Write(b []byte) (int, error) {
// Close this IdleTimingConn. This will close the underlying net.Conn as well,
// returning the error from calling its Close method.
func (c *IdleTimingConn) Close() error {
c.closeMutex.Lock()
defer c.closeMutex.Unlock()

if err := c.checkClosed(nil); err != nil {
return err
}

c.closed = true

select {
case c.closedCh <- true:
// close accepted
@@ -184,14 +216,27 @@ func (c *IdleTimingConn) Close() error {
}

func (c *IdleTimingConn) LocalAddr() net.Addr {
c.closeMutex.RLock()
defer c.closeMutex.RUnlock()

return c.conn.LocalAddr()
}

func (c *IdleTimingConn) RemoteAddr() net.Addr {
c.closeMutex.RLock()
defer c.closeMutex.RUnlock()

return c.conn.RemoteAddr()
}

func (c *IdleTimingConn) SetDeadline(t time.Time) error {
c.closeMutex.RLock()
defer c.closeMutex.RUnlock()

if err := c.checkClosed(nil); err != nil {
return err
}

if err := c.SetReadDeadline(t); err != nil {
log.Tracef("Unable to set read deadline: %v", err)
}
@@ -202,30 +247,50 @@ func (c *IdleTimingConn) SetDeadline(t time.Time) error {
}

func (c *IdleTimingConn) SetReadDeadline(t time.Time) error {
// zero value means no time out
if t.IsZero() {
t = epoch
c.closeMutex.RLock()
defer c.closeMutex.RUnlock()

if err := c.checkClosed(nil); err != nil {
return err
}

atomic.StoreInt64(&c.readDeadline, t.UnixNano())
return nil
}

func (c *IdleTimingConn) SetWriteDeadline(t time.Time) error {
// zero value means no time out
if t.IsZero() {
t = epoch
c.closeMutex.RLock()
defer c.closeMutex.RUnlock()

if err := c.checkClosed(nil); err != nil {
return err
}

atomic.StoreInt64(&c.writeDeadline, t.UnixNano())
return nil
}

func (c *IdleTimingConn) markActive(n int) bool {
if n > 0 {
c.activeCh <- true
select {
case c.activeCh <- true:
// ok
default:
// still waiting to process previous markActive
}
return true
} else {
return false
}
return false
}

func (c *IdleTimingConn) checkClosed(hasDone *int32) error {
if c.closed {
if hasDone != nil && atomic.CompareAndSwapInt32(hasDone, 0, 1) {
return io.EOF
}
return ErrIdled
}
return nil
}

func isTimeout(err error) bool {
15 changes: 9 additions & 6 deletions src/github.com/getlantern/idletiming/idletiming_listener.go
Original file line number Diff line number Diff line change
@@ -13,9 +13,8 @@ import (
// connection idle. Note - the actual timeout may be up to twice idleTimeout,
// depending on timing.
//
// onIdle is a required function that's called if a connection idles.
// idletiming.Conn does not close the underlying connection on idle, you have to
// do that in your onIdle callback.
// If onIdle is specified, it will be called to indicate when the connection has
// idled and been closed.
func Listener(listener net.Listener, idleTimeout time.Duration, onIdle func(conn net.Conn)) net.Listener {
if onIdle == nil {
panic("onIdle is required")
@@ -33,9 +32,13 @@ type idleTimingListener struct {
func (l *idleTimingListener) Accept() (c net.Conn, err error) {
c, err = l.orig.Accept()
if err == nil {
c = Conn(c, l.idleTimeout, func() {
l.onIdle(c)
})
var onIdle func()
if l.onIdle != nil {
onIdle = func() {
l.onIdle(c)
}
}
c = Conn(c, l.idleTimeout, onIdle)
}
return
}
25 changes: 12 additions & 13 deletions src/github.com/getlantern/idletiming/idletiming_test.go
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import (
"time"

"github.com/getlantern/fdcount"
"github.com/stretchr/testify/assert"
)

var (
@@ -39,9 +40,6 @@ func TestWrite(t *testing.T) {
addr := l.Addr().String()
il := Listener(l, serverTimeout, func(conn net.Conn) {
atomic.StoreInt32(&listenerIdled, 1)
if err := conn.Close(); err != nil {
t.Errorf("Unable to close connection: %v", err)
}
})
defer func() {
if err := il.Close(); err != nil {
@@ -76,9 +74,6 @@ func TestWrite(t *testing.T) {

c := Conn(conn, clientTimeout, func() {
atomic.StoreInt32(&connIdled, 1)
if err := conn.Close(); err != nil {
t.Fatalf("Unable to close connection: %v", err)
}
})

// Write messages
@@ -107,6 +102,12 @@ func TestWrite(t *testing.T) {
t.Errorf("Conn failed to idle!")
}

time.Sleep(slightlyMoreThanClientTimeout)
_, err = c.Write(make([]byte, 10))
assert.Equal(t, io.EOF, err, "1st write after idle should return io.EOF")
_, err = c.Write(make([]byte, 10))
assert.Equal(t, ErrIdled, err, "2nd write after idle should return ErrIdled")

connTimesOutIn := c.TimesOutIn()
if connTimesOutIn > 0 {
t.Errorf("TimesOutIn returned bad value, should have been negative, but was: %s", connTimesOutIn)
@@ -124,8 +125,8 @@ func TestRead(t *testing.T) {
t.Fatal(err)
}

listenerIdled := int32(0)
connIdled := int32(0)
listenerIdled := int32(0)

l, err := net.Listen("tcp", "localhost:0")
if err != nil {
@@ -134,9 +135,6 @@ func TestRead(t *testing.T) {

il := Listener(l, serverTimeout, func(conn net.Conn) {
atomic.StoreInt32(&listenerIdled, 1)
if err := conn.Close(); err != nil {
t.Fatalf("Unable to close connection: %v", err)
}
})
defer func() {
if err := il.Close(); err != nil {
@@ -176,9 +174,6 @@ func TestRead(t *testing.T) {

c := Conn(conn, clientTimeout, func() {
atomic.StoreInt32(&connIdled, 1)
if err := conn.Close(); err != nil {
t.Fatalf("Unable to close connection: %v", err)
}
})

// Read messages (we use a buffer matching the message size to make sure
@@ -214,6 +209,10 @@ func TestRead(t *testing.T) {
if atomic.LoadInt32(&connIdled) == 0 {
t.Errorf("Conn failed to idle!")
}
_, err = c.Read(make([]byte, 10))
assert.Equal(t, io.EOF, err, "1st read after idle should return io.EOF")
_, err = c.Read(make([]byte, 10))
assert.Equal(t, ErrIdled, err, "2nd read after idle should return ErrIdled")

time.Sleep(9 * slightlyMoreThanClientTimeout)
if atomic.LoadInt32(&listenerIdled) == 0 {