[tor-commits] [obfs4/master] Write an example obfs4 bridge line to "obfs4_bridgeline.txt".

yawning at torproject.org yawning at torproject.org
Wed Sep 24 16:03:00 UTC 2014


commit 514c3c6053ee3a2d3a842fd59b623ef432d93b7d
Author: Yawning Angel <yawning at torproject.org>
Date:   Wed Sep 24 16:00:42 2014 +0000

    Write an example obfs4 bridge line to "obfs4_bridgeline.txt".
    
    Write an example client bridge line suitable for use with the running
    obfs4 server instance to "obfs4_bridgeline.txt" for the convenience of
    bridge operators.
---
 ChangeLog                     |    3 +++
 doc/obfs4proxy.1              |    9 ++++++++-
 transports/obfs4/statefile.go |   38 +++++++++++++++++++++++++++++++++++---
 3 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6f91c92..e42ed86 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
 Changes in version 0.0.2 - UNRELEASED
+ - Write an example client bridge line suitable for use with the running obfs4
+   server instance to "obfs4_bridgeline.txt" for the convenience of bridge
+   operators.
  - Add a man page for obfs4proxy.
 
 Changes in version 0.0.1 - 2014-09-03
diff --git a/doc/obfs4proxy.1 b/doc/obfs4proxy.1
index bda677a..e442946 100644
--- a/doc/obfs4proxy.1
+++ b/doc/obfs4proxy.1
@@ -1,4 +1,4 @@
-.TH OBFS4PROXY 1 "2014-09-06"
+.TH OBFS4PROXY 1 "2014-09-24"
 .SH NAME
 obfs4proxy \- pluggable transport proxy for Tor, implementing obfs4
 .SH SYNOPSIS
@@ -53,6 +53,13 @@ The Bridge (server) auto-generated obfs4 bridge parameters file.  This file
 will not be created if the administrator specifies them in the \fBtorrc\fR
 via a \fBServerTransportOptions\fR directive.
 .RE
+.PP
+\fIDataDirectory\fR\fB/pt_state/obfs4_bridgeline.txt\fR
+.RS 4
+The Bridge (server) obfs4 bridge's client parameters.  This file is created
+and contains the \fBBridge\fR directive a client should add to their
+\fBtorrc\fR to connect to the running server's obfs4 instance.
+.RE
 .SH "CONFORMING TO"
 Tor Pluggable Transport Specification
 .SH NOTES
diff --git a/transports/obfs4/statefile.go b/transports/obfs4/statefile.go
index 8690178..1e00f32 100644
--- a/transports/obfs4/statefile.go
+++ b/transports/obfs4/statefile.go
@@ -42,7 +42,8 @@ import (
 )
 
 const (
-	stateFile = "obfs4_state.json"
+	stateFile  = "obfs4_state.json"
+	bridgeFile = "obfs4_bridgeline.txt"
 )
 
 type jsonServerState struct {
@@ -91,10 +92,10 @@ func serverStateFromArgs(stateDir string, args *pt.Args) (*obfs4ServerState, err
 		js.IATMode = iatMode
 	}
 
-	return serverStateFromJSONServerState(&js)
+	return serverStateFromJSONServerState(stateDir, &js)
 }
 
-func serverStateFromJSONServerState(js *jsonServerState) (*obfs4ServerState, error) {
+func serverStateFromJSONServerState(stateDir string, js *jsonServerState) (*obfs4ServerState, error) {
 	var err error
 
 	st := new(obfs4ServerState)
@@ -112,6 +113,11 @@ func serverStateFromJSONServerState(js *jsonServerState) (*obfs4ServerState, err
 	}
 	st.iatMode = js.IATMode
 
+	// Generate a human readable summary of the configured endpoint.
+	if err = newBridgeFile(stateDir, st); err != nil {
+		return nil, err
+	}
+
 	return st, nil
 }
 
@@ -170,3 +176,29 @@ func newJSONServerState(stateDir string, js *jsonServerState) (err error) {
 
 	return nil
 }
+
+func newBridgeFile(stateDir string, st *obfs4ServerState) (err error) {
+	const prefix = "# obfs4 torrc client bridge line\n" +
+		"#\n" +
+		"# This file is an automatically generated bridge line based on\n" +
+		"# the current obfs4proxy configuration.  EDITING IT WILL HAVE\n" +
+		"# NO EFFECT.\n" +
+		"#\n" +
+		"# Before distributing this Bridge, edit the placeholder fields\n" +
+		"# to contain the actual values:\n" +
+		"#  <IP ADDRESS>  - The public IP address of your obfs4 bridge.\n" +
+		"#  <PORT>        - The TCP/IP port of your obfs4 bridge.\n" +
+		"#  <FINGERPRINT> - The bridge's fingerprint.\n\n"
+
+	bridgeLine := fmt.Sprintf("Bridge obfs4 <IP ADDRESS>:<PORT> <FINGERPRINT> node-id=%s public-key=%s iat-mode=%d\n",
+		st.nodeID.Hex(),
+		st.identityKey.Public().Hex(),
+		st.iatMode)
+
+	tmp := []byte(prefix + bridgeLine)
+	if err = ioutil.WriteFile(path.Join(stateDir, bridgeFile), tmp, 0600); err != nil {
+		return err
+	}
+
+	return nil
+}



More information about the tor-commits mailing list