Skip to content

Commit

Permalink
add ContactInfo torrc parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcloughlin committed Oct 24, 2017
1 parent c242346 commit e7e787d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions torconfig/torrc.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ type optionHandler func(*Config, string) error
// optionHandlers is a map from keywords (lowercased) to the associated
// handler. Used by ParseTorrc.
var optionHandlers = map[string]optionHandler{
"nickname": nicknameHandler,
"orport": orPortHandler,
"nickname": nicknameHandler,
"orport": orPortHandler,
"contactinfo": contactInfoHandler,
}

// ParseTorrc parses Config from the given reader (in torrc format).
Expand Down Expand Up @@ -94,3 +95,9 @@ func orPortHandler(cfg *Config, args string) error {
cfg.ORPort = uint16(port)
return nil
}

// contactInfoHandler parses the "ContactInfo" line.
func contactInfoHandler(cfg *Config, args string) error {
cfg.Contact = args
return nil
}
1 change: 1 addition & 0 deletions torconfig/torrc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func TestParseTorrcFile(t *testing.T) {
expect := &Config{
Nickname: "JetpacksPlease",
ORPort: 9001,
Contact: "Harm Aarts <XXXX ET XXXX>",
}

assert.Equal(t, expect, cfg)
Expand Down

0 comments on commit e7e787d

Please sign in to comment.