commit 4812b9a8b6c0b1798b7980d0a7f04d25dae4b396
Author: David Fifield <da...@bamsoftware.com>
Date:   Thu Dec 25 21:33:41 2014 -0800

    Reduce meek-client sessionIdLength to 8 from 32, and strip trailing '='.
    
    This reduces the encoded length of a session ID from 44 bytes down to
    12. If we have 1000 simultaneous users, and they're all idle and polling
    at 5 requests/s, then this change saves 1000*(44-12)/5 = 6.4 KB/s.
    According to https://trac.torproject.org/projects/tor/ticket/12778, the
    header length is about 413 bytes, so the shorter session ID saves about
    7% in the header.
---
 meek-client/meek-client.go |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/meek-client/meek-client.go b/meek-client/meek-client.go
index 862f154..c02c784 100644
--- a/meek-client/meek-client.go
+++ b/meek-client/meek-client.go
@@ -42,6 +42,7 @@ import (
        "net/url"
        "os"
        "os/signal"
+       "strings"
        "syscall"
        "time"
 )
@@ -54,7 +55,7 @@ const (
        // long-lived session. We split a TCP stream across multiple HTTP
        // requests, and those with the same session ID belong to the same
        // stream.
-       sessionIdLength = 32
+       sessionIdLength = 8
        // The size of the largest chunk of data we will read from the SOCKS
        // port before forwarding it in a request, and the maximum size of a
        // body we are willing to handle in a reply.
@@ -249,7 +250,7 @@ func genSessionId() string {
        if err != nil {
                panic(err.Error())
        }
-       return base64.StdEncoding.EncodeToString(buf)
+       return strings.TrimRight(base64.StdEncoding.EncodeToString(buf), "=")
 }
 
 // Callback for new SOCKS requests.



_______________________________________________
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits

Reply via email to