The obfs4 `iat-mode` parameter is now properly configurable.

It used to be that all of the bridge side parameters needed to be
manually specified together.  This was somewhat nonsensical, and the IAT
mode can now be set as the only obfs4 option in a `ServerTransportOptions`
torrc directive.

Thanks to dcf for reporting the issue.
merge-requests/3/head
Yawning Angel 8 years ago
parent 1df5c8ffe8
commit a7a2575cab

@ -1,4 +1,7 @@
Changes in version 0.0.7 - UNRELEASED:
- Support configuring the obfs4 IAT parameter as the sole
ServerTransportOption on bridges, and correctly checkpoint the argument
to the state file.
Changes in version 0.0.6 - 2016-01-25:
- Delay transport factory initialization till after logging has been

@ -119,7 +119,9 @@ func serverStateFromArgs(stateDir string, args *pt.Args) (*obfs4ServerState, err
js.DrbgSeed, seedOk = args.Get(seedArg)
iatStr, iatOk := args.Get(iatArg)
if !privKeyOk && !nodeIDOk && !seedOk && !iatOk {
// Either a private key, node id, and seed are ALL specified, or
// they should be loaded from the state file.
if !privKeyOk && !nodeIDOk && !seedOk {
if err := jsonServerStateFromFile(stateDir, &js); err != nil {
return nil, err
}
@ -129,11 +131,12 @@ func serverStateFromArgs(stateDir string, args *pt.Args) (*obfs4ServerState, err
return nil, fmt.Errorf("missing argument '%s'", nodeIDArg)
} else if !seedOk {
return nil, fmt.Errorf("missing argument '%s'", seedArg)
} else if !iatOk {
// Disable IAT if not specified.
return nil, fmt.Errorf("missing argument '%s'", iatArg)
} else {
// Parse and validate the iat-mode argument.
}
// The IAT mode should be independently configurable.
if iatOk {
// If the IAT mode is specified, attempt to parse and apply it
// as an override.
iatMode, err := strconv.Atoi(iatStr)
if err != nil {
return nil, fmt.Errorf("malformed iat-mode '%s'", iatStr)
@ -168,7 +171,8 @@ func serverStateFromJSONServerState(stateDir string, js *jsonServerState) (*obfs
return nil, err
}
return st, nil
// Write back the possibly updated server state.
return st, writeJSONServerState(stateDir, js)
}
func jsonServerStateFromFile(stateDir string, js *jsonServerState) error {
@ -215,11 +219,15 @@ func newJSONServerState(stateDir string, js *jsonServerState) (err error) {
js.DrbgSeed = st.drbgSeed.Hex()
js.IATMode = st.iatMode
return writeJSONServerState(stateDir, js)
}
func writeJSONServerState(stateDir string, js *jsonServerState) error {
var err error
var encoded []byte
if encoded, err = json.Marshal(js); err != nil {
return
return err
}
if err = ioutil.WriteFile(path.Join(stateDir, stateFile), encoded, 0600); err != nil {
return err
}

Loading…
Cancel
Save