Ticket #20451: 0001-Emit-a-CMETHOD-ERROR-or-SMETHOD-ERROR-when-failing-t.patch

File 0001-Emit-a-CMETHOD-ERROR-or-SMETHOD-ERROR-when-failing-t.patch, 2.8 KB (added by dcf, 2 years ago)
  • meek-client/meek-client.go

    From b6f9503994354fc4c923b6ace26a3bdcb500b211 Mon Sep 17 00:00:00 2001
    From: David Fifield <david@bamsoftware.com>
    Date: Fri, 31 Mar 2017 00:46:46 -0700
    Subject: [PATCH] Emit a CMETHOD-ERROR or SMETHOD-ERROR when failing to open
     log file.
    
    This causes a message to appear in tor's log. Otherwise, with no log
    file to write to, there's no indication of what the error was that
    caused the transport plugin to fail.
    
    https://bugs.torproject.org/20451
    ---
     meek-client/meek-client.go | 13 ++++++++-----
     meek-server/meek-server.go | 15 +++++++++------
     2 files changed, 17 insertions(+), 11 deletions(-)
    
    diff --git a/meek-client/meek-client.go b/meek-client/meek-client.go
    index 9de4056..61b2646 100644
    a b func main() { 
    363363        flag.StringVar(&options.URL, "url", "", "URL to request if no url= SOCKS arg")
    364364        flag.Parse()
    365365
     366        ptInfo, err = pt.ClientSetup(nil)
     367        if err != nil {
     368                log.Fatalf("error in ClientSetup: %s", err)
     369        }
     370
    366371        if logFilename != "" {
    367372                f, err := os.OpenFile(logFilename, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
    368373                if err != nil {
     374                        // If we fail to open the log, emit a message that will
     375                        // appear in tor's log.
     376                        pt.CmethodError(ptMethodName, fmt.Sprintf("error opening log file: %s", err))
    369377                        log.Fatalf("error opening log file: %s", err)
    370378                }
    371379                defer f.Close()
    func main() { 
    394402        httpTransport = *http.DefaultTransport.(*http.Transport)
    395403        httpTransport.Proxy = nil
    396404
    397         ptInfo, err = pt.ClientSetup(nil)
    398         if err != nil {
    399                 log.Fatalf("error in ClientSetup: %s", err)
    400         }
    401 
    402405        // Command-line proxy overrides managed configuration.
    403406        if options.ProxyURL == nil {
    404407                options.ProxyURL = ptInfo.ProxyURL
  • meek-server/meek-server.go

    diff --git a/meek-server/meek-server.go b/meek-server/meek-server.go
    index bf0f8a4..289393c 100644
    a b func main() { 
    347347        flag.IntVar(&port, "port", 0, "port to listen on")
    348348        flag.Parse()
    349349
     350        var err error
     351        ptInfo, err = pt.ServerSetup(nil)
     352        if err != nil {
     353                log.Fatalf("error in ServerSetup: %s", err)
     354        }
     355
    350356        if logFilename != "" {
    351357                f, err := os.OpenFile(logFilename, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
    352358                if err != nil {
     359                        // If we fail to open the log, emit a message that will
     360                        // appear in tor's log.
     361                        pt.SmethodError(ptMethodName, fmt.Sprintf("error opening log file: %s", err))
    353362                        log.Fatalf("error opening log file: %s", err)
    354363                }
    355364                defer f.Close()
    func main() { 
    366375                }
    367376        }
    368377
    369         var err error
    370         ptInfo, err = pt.ServerSetup(nil)
    371         if err != nil {
    372                 log.Fatalf("error in ServerSetup: %s", err)
    373         }
    374 
    375378        log.Printf("starting version %s (%s)", programVersion, runtime.Version())
    376379        listeners := make([]net.Listener, 0)
    377380        for _, bindaddr := range ptInfo.Bindaddrs {