only flush datachannel with nonzero bytes, which prevents Tor from marking the SOCKS for close (#12)

This commit is contained in:
Serene Han 2016-02-25 01:23:59 -08:00
parent 38999e02de
commit f3e0abe0e1
2 changed files with 10 additions and 6 deletions

View file

@ -101,7 +101,7 @@ func handler(conn *pt.SocksConn) error {
log.Println("handler fired:", conn)
remote, err := dialWebRTC()
if err != nil {
if err != nil || remote == nil {
conn.Reject()
return err
}
@ -123,6 +123,7 @@ func handler(conn *pt.SocksConn) error {
func acceptLoop(ln *pt.SocksListener) error {
defer ln.Close()
for {
log.Println("SOCKS listening...")
conn, err := ln.AcceptSocks()
if err != nil {
if e, ok := err.(net.Error); ok && e.Temporary() {