Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
obfs4-deprecated
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
leap
obfs4-deprecated
Commits
676e0428
Commit
676e0428
authored
11 years ago
by
Yawning Angel
Browse files
Options
Downloads
Patches
Plain Diff
Allow logging to be disabled (default).
Part of #6, still need to make logs nicer.
parent
66edb786
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
obfs4proxy/obfs4proxy.go
+26
-11
26 additions, 11 deletions
obfs4proxy/obfs4proxy.go
with
26 additions
and
11 deletions
obfs4proxy/obfs4proxy.go
+
26
−
11
View file @
676e0428
...
@@ -316,7 +316,14 @@ func ptGetStateDir() (dir string, err error) {
...
@@ -316,7 +316,14 @@ func ptGetStateDir() (dir string, err error) {
return
return
}
}
func
ptInitializeLogging
()
{
type
discardWriter
struct
{}
func
(
d
discardWriter
)
Write
(
p
[]
byte
)
(
n
int
,
err
error
)
{
return
len
(
p
),
nil
}
func
ptInitializeLogging
(
enable
bool
)
{
if
enable
{
dir
,
err
:=
ptGetStateDir
()
dir
,
err
:=
ptGetStateDir
()
if
err
!=
nil
||
dir
==
""
{
if
err
!=
nil
||
dir
==
""
{
return
return
...
@@ -327,6 +334,10 @@ func ptInitializeLogging() {
...
@@ -327,6 +334,10 @@ func ptInitializeLogging() {
log
.
Fatalf
(
"[ERROR] Failed to open log file: %s"
,
err
)
log
.
Fatalf
(
"[ERROR] Failed to open log file: %s"
,
err
)
}
}
log
.
SetOutput
(
f
)
log
.
SetOutput
(
f
)
}
else
{
var
d
discardWriter
log
.
SetOutput
(
d
)
}
}
}
func
generateServerParams
(
id
string
)
{
func
generateServerParams
(
id
string
)
{
...
@@ -371,7 +382,8 @@ func generateServerParams(id string) {
...
@@ -371,7 +382,8 @@ func generateServerParams(id string) {
func
main
()
{
func
main
()
{
// Some command line args.
// Some command line args.
genParams
:=
flag
.
String
(
"gen"
,
""
,
"Generate server params given a bridge fingerprint."
)
genParams
:=
flag
.
String
(
"genServerParams"
,
""
,
"Generate server params given a bridge fingerprint."
)
doLogging
:=
flag
.
Bool
(
"enableLogging"
,
false
,
"Log to TOR_PT_STATE_LOCATION/obfs4proxy.log"
)
flag
.
Parse
()
flag
.
Parse
()
if
*
genParams
!=
""
{
if
*
genParams
!=
""
{
generateServerParams
(
*
genParams
)
generateServerParams
(
*
genParams
)
...
@@ -379,7 +391,7 @@ func main() {
...
@@ -379,7 +391,7 @@ func main() {
}
}
// Initialize pt logging.
// Initialize pt logging.
ptInitializeLogging
()
ptInitializeLogging
(
*
doLogging
)
// Go through the pt protocol and initialize client or server mode.
// Go through the pt protocol and initialize client or server mode.
launched
:=
false
launched
:=
false
...
@@ -393,6 +405,9 @@ func main() {
...
@@ -393,6 +405,9 @@ func main() {
}
}
log
.
Println
(
"[INFO] obfs4proxy - Launched and listening"
)
log
.
Println
(
"[INFO] obfs4proxy - Launched and listening"
)
defer
func
()
{
log
.
Println
(
"[INFO] obfs4proxy - Terminated"
)
}()
// Handle termination notification.
// Handle termination notification.
numHandlers
:=
0
numHandlers
:=
0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment