Ticket #25471: 0001-Log-to-state-dir.patch

File 0001-Log-to-state-dir.patch, 1.3 KB (added by arlolra, 18 months ago)
  • client/snowflake.go

    From fd884545e231797d7d34071e4812c69ca338175a Mon Sep 17 00:00:00 2001
    From: Arlo Breault <arlolra@gmail.com>
    Date: Thu, 8 Mar 2018 16:05:33 -0500
    Subject: [PATCH] Log to state dir
    
    ---
     client/snowflake.go | 10 ++++++++++
     1 file changed, 10 insertions(+)
    
    diff --git a/client/snowflake.go b/client/snowflake.go
    index b958a7f..e75b902 100644
    a b import ( 
    1010        "net"
    1111        "os"
    1212        "os/signal"
     13        "path"
    1314        "strings"
    1415        "sync"
    1516        "syscall"
    func main() { 
    126127        brokerURL := flag.String("url", "", "URL of signaling broker")
    127128        frontDomain := flag.String("front", "", "front domain")
    128129        logFilename := flag.String("log", "", "name of log file")
     130        logToStateDir := flag.Bool("logToStateDir", false, "resolve the log file relative to tor's pt state dir")
    129131        max := flag.Int("max", DefaultSnowflakeCapacity,
    130132                "capacity for number of multiplexed WebRTC peers")
    131133        flag.Parse()
    132134
    133135        webrtc.SetLoggingVerbosity(1)
    134136        log.SetFlags(log.LstdFlags | log.LUTC)
     137
    135138        if *logFilename != "" {
     139                if *logToStateDir {
     140                        stateDir, err := pt.MakeStateDir()
     141                        if err != nil {
     142                                log.Fatal(err)
     143                        }
     144                        *logFilename = path.Join(stateDir, *logFilename)
     145                }
    136146                logFile, err := os.OpenFile(*logFilename,
    137147                        os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
    138148                if err != nil {