diff --git a/.drone.yml b/.drone.yml index 2c4a583..c55c25d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,7 +14,6 @@ pipeline: - wget https://git.openprivacy.ca/openprivacy/buildfiles/raw/master/tor/tor -P tmp/ - chmod a+x tmp/tor - go mod download - - go get -u quality: when: repo: openprivacy/connectivity diff --git a/.gitignore b/.gitignore index a0787cc..abeeb44 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,4 @@ tor/tor/ vendor/ *.cover.out tmp/ -testing/tor/torrc testing/tor/* \ No newline at end of file diff --git a/proxy_acn.go b/proxy_acn.go index 0a3958a..809f5b6 100644 --- a/proxy_acn.go +++ b/proxy_acn.go @@ -2,6 +2,7 @@ package connectivity import ( "net" + "sync" ) // ProxyACN because there is rarely a problem that can't be solved by another layer of indirection. @@ -11,6 +12,10 @@ import ( // ProxyACN - a wrapper around an ACN that allows safe replacement of a running ACN that is transparent to callers. type ProxyACN struct { acn ACN + + // All operations on the underlying acn are assumed to be thread safe, however changing the actual + // acn in ReplaceACN will lock to force an ordering of Close and Callback + lock sync.Mutex } func NewProxyACN(acn ACN) ProxyACN { @@ -21,6 +26,8 @@ func NewProxyACN(acn ACN) ProxyACN { // ReplaceACN closes down the current ACN and replaces it with a new ACN. func (p *ProxyACN) ReplaceACN(acn ACN) { + p.lock.Lock() + defer p.lock.Unlock() p.acn.Close() acn.SetStatusCallback(p.acn.Callback()) p.acn = acn