Handle generated errors in client

This commit is contained in:
Shane Howearth 2019-09-24 09:00:13 +10:00 committed by Cecylia Bocovich
parent 78a37844b2
commit b26c7a7a73
3 changed files with 28 additions and 14 deletions

View file

@ -56,18 +56,18 @@ func Handler(socks SocksConnector, snowflakes SnowflakeCollector) error {
// Exchanges bytes between two ReadWriters.
// (In this case, between a SOCKS and WebRTC connection.)
func copyLoop(a, b io.ReadWriter) {
func copyLoop(WebRTC, SOCKS io.ReadWriter) {
var wg sync.WaitGroup
wg.Add(2)
go func() {
if _, err := io.Copy(ORPort, WebRTC); err != nil {
log.Printf("copying WebRTC to ORPort resulted in error: %v", err)
if _, err := io.Copy(SOCKS, WebRTC); err != nil {
log.Printf("copying WebRTC to SOCKS resulted in error: %v", err)
}
wg.Done()
}()
go func() {
if _, err := io.Copy(WebRTC, ORPort); err != nil {
log.Printf("copying ORPort to WebRTC resulted in error: %v", err)
if _, err := io.Copy(WebRTC, SOCKS); err != nil {
log.Printf("copying SOCKS to WebRTC resulted in error: %v", err)
}
wg.Done()
}()