mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Add unsafe logging
This commit is contained in:
parent
e521a7217a
commit
f58c865d82
4 changed files with 31 additions and 8 deletions
|
@ -376,6 +376,7 @@ func main() {
|
||||||
var certFilename, keyFilename string
|
var certFilename, keyFilename string
|
||||||
var disableGeoip bool
|
var disableGeoip bool
|
||||||
var metricsFilename string
|
var metricsFilename string
|
||||||
|
var unsafeLogging bool
|
||||||
|
|
||||||
flag.StringVar(&acmeEmail, "acme-email", "", "optional contact email for Let's Encrypt notifications")
|
flag.StringVar(&acmeEmail, "acme-email", "", "optional contact email for Let's Encrypt notifications")
|
||||||
flag.StringVar(&acmeHostnamesCommas, "acme-hostnames", "", "comma-separated hostnames for TLS certificate")
|
flag.StringVar(&acmeHostnamesCommas, "acme-hostnames", "", "comma-separated hostnames for TLS certificate")
|
||||||
|
@ -388,13 +389,18 @@ func main() {
|
||||||
flag.BoolVar(&disableTLS, "disable-tls", false, "don't use HTTPS")
|
flag.BoolVar(&disableTLS, "disable-tls", false, "don't use HTTPS")
|
||||||
flag.BoolVar(&disableGeoip, "disable-geoip", false, "don't use geoip for stats collection")
|
flag.BoolVar(&disableGeoip, "disable-geoip", false, "don't use geoip for stats collection")
|
||||||
flag.StringVar(&metricsFilename, "metrics-log", "", "path to metrics logging output")
|
flag.StringVar(&metricsFilename, "metrics-log", "", "path to metrics logging output")
|
||||||
|
flag.BoolVar(&unsafeLogging, "unsafe-logging", false, "prevent logs from being scrubbed")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
var metricsFile io.Writer
|
var metricsFile io.Writer
|
||||||
var logOutput io.Writer = os.Stderr
|
var logOutput io.Writer = os.Stderr
|
||||||
//We want to send the log output through our scrubber first
|
if unsafeLogging {
|
||||||
|
log.SetOutput(logOutput)
|
||||||
|
} else {
|
||||||
|
// We want to send the log output through our scrubber first
|
||||||
log.SetOutput(&safelog.LogScrubber{Output: logOutput})
|
log.SetOutput(&safelog.LogScrubber{Output: logOutput})
|
||||||
|
}
|
||||||
|
|
||||||
log.SetFlags(log.LstdFlags | log.LUTC)
|
log.SetFlags(log.LstdFlags | log.LUTC)
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,7 @@ func main() {
|
||||||
logFilename := flag.String("log", "", "name of log file")
|
logFilename := flag.String("log", "", "name of log file")
|
||||||
logToStateDir := flag.Bool("logToStateDir", false, "resolve the log file relative to tor's pt state dir")
|
logToStateDir := flag.Bool("logToStateDir", false, "resolve the log file relative to tor's pt state dir")
|
||||||
keepLocalAddresses := flag.Bool("keepLocalAddresses", false, "keep local LAN address ICE candidates")
|
keepLocalAddresses := flag.Bool("keepLocalAddresses", false, "keep local LAN address ICE candidates")
|
||||||
|
unsafeLogging := flag.Bool("unsafe-logging", false, "prevent logs from being scrubbed")
|
||||||
max := flag.Int("max", DefaultSnowflakeCapacity,
|
max := flag.Int("max", DefaultSnowflakeCapacity,
|
||||||
"capacity for number of multiplexed WebRTC peers")
|
"capacity for number of multiplexed WebRTC peers")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
@ -119,8 +120,12 @@ func main() {
|
||||||
defer logFile.Close()
|
defer logFile.Close()
|
||||||
logOutput = logFile
|
logOutput = logFile
|
||||||
}
|
}
|
||||||
|
if *unsafeLogging {
|
||||||
|
log.SetOutput(logOutput)
|
||||||
|
} else {
|
||||||
// We want to send the log output through our scrubber first
|
// We want to send the log output through our scrubber first
|
||||||
log.SetOutput(&safelog.LogScrubber{Output: logOutput})
|
log.SetOutput(&safelog.LogScrubber{Output: logOutput})
|
||||||
|
}
|
||||||
|
|
||||||
log.Println("\n\n\n --- Starting Snowflake Client ---")
|
log.Println("\n\n\n --- Starting Snowflake Client ---")
|
||||||
|
|
||||||
|
|
|
@ -408,12 +408,14 @@ func main() {
|
||||||
var stunURL string
|
var stunURL string
|
||||||
var logFilename string
|
var logFilename string
|
||||||
var rawBrokerURL string
|
var rawBrokerURL string
|
||||||
|
var unsafeLogging bool
|
||||||
|
|
||||||
flag.UintVar(&capacity, "capacity", 10, "maximum concurrent clients")
|
flag.UintVar(&capacity, "capacity", 10, "maximum concurrent clients")
|
||||||
flag.StringVar(&rawBrokerURL, "broker", defaultBrokerURL, "broker URL")
|
flag.StringVar(&rawBrokerURL, "broker", defaultBrokerURL, "broker URL")
|
||||||
flag.StringVar(&relayURL, "relay", defaultRelayURL, "websocket relay URL")
|
flag.StringVar(&relayURL, "relay", defaultRelayURL, "websocket relay URL")
|
||||||
flag.StringVar(&stunURL, "stun", defaultSTUNURL, "stun URL")
|
flag.StringVar(&stunURL, "stun", defaultSTUNURL, "stun URL")
|
||||||
flag.StringVar(&logFilename, "log", "", "log filename")
|
flag.StringVar(&logFilename, "log", "", "log filename")
|
||||||
|
flag.BoolVar(&unsafeLogging, "unsafe-logging", false, "prevent logs from being scrubbed")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
var logOutput io.Writer = os.Stderr
|
var logOutput io.Writer = os.Stderr
|
||||||
|
@ -426,8 +428,12 @@ func main() {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
logOutput = io.MultiWriter(os.Stderr, f)
|
logOutput = io.MultiWriter(os.Stderr, f)
|
||||||
}
|
}
|
||||||
//We want to send the log output through our scrubber first
|
if unsafeLogging {
|
||||||
|
log.SetOutput(logOutput)
|
||||||
|
} else {
|
||||||
|
// We want to send the log output through our scrubber first
|
||||||
log.SetOutput(&safelog.LogScrubber{Output: logOutput})
|
log.SetOutput(&safelog.LogScrubber{Output: logOutput})
|
||||||
|
}
|
||||||
|
|
||||||
log.Println("starting")
|
log.Println("starting")
|
||||||
|
|
||||||
|
|
|
@ -214,12 +214,14 @@ func main() {
|
||||||
var acmeHostnamesCommas string
|
var acmeHostnamesCommas string
|
||||||
var disableTLS bool
|
var disableTLS bool
|
||||||
var logFilename string
|
var logFilename string
|
||||||
|
var unsafeLogging bool
|
||||||
|
|
||||||
flag.Usage = usage
|
flag.Usage = usage
|
||||||
flag.StringVar(&acmeEmail, "acme-email", "", "optional contact email for Let's Encrypt notifications")
|
flag.StringVar(&acmeEmail, "acme-email", "", "optional contact email for Let's Encrypt notifications")
|
||||||
flag.StringVar(&acmeHostnamesCommas, "acme-hostnames", "", "comma-separated hostnames for TLS certificate")
|
flag.StringVar(&acmeHostnamesCommas, "acme-hostnames", "", "comma-separated hostnames for TLS certificate")
|
||||||
flag.BoolVar(&disableTLS, "disable-tls", false, "don't use HTTPS")
|
flag.BoolVar(&disableTLS, "disable-tls", false, "don't use HTTPS")
|
||||||
flag.StringVar(&logFilename, "log", "", "log file to write to")
|
flag.StringVar(&logFilename, "log", "", "log file to write to")
|
||||||
|
flag.BoolVar(&unsafeLogging, "unsafe-logging", false, "prevent logs from being scrubbed")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
log.SetFlags(log.LstdFlags | log.LUTC)
|
log.SetFlags(log.LstdFlags | log.LUTC)
|
||||||
|
@ -233,8 +235,12 @@ func main() {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
logOutput = f
|
logOutput = f
|
||||||
}
|
}
|
||||||
//We want to send the log output through our scrubber first
|
if unsafeLogging {
|
||||||
|
log.SetOutput(logOutput)
|
||||||
|
} else {
|
||||||
|
// We want to send the log output through our scrubber first
|
||||||
log.SetOutput(&safelog.LogScrubber{Output: logOutput})
|
log.SetOutput(&safelog.LogScrubber{Output: logOutput})
|
||||||
|
}
|
||||||
|
|
||||||
if !disableTLS && acmeHostnamesCommas == "" {
|
if !disableTLS && acmeHostnamesCommas == "" {
|
||||||
log.Fatal("the --acme-hostnames option is required")
|
log.Fatal("the --acme-hostnames option is required")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue