| 1 | package controlscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ |
| 2 | |
| 3 | import ( |
| 4 | "stringsscip-go gomod github.com/golang/go/src go1.15 strings/" |
| 5 | |
| 6 | "github.com/cretz/bine/torutilscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/" |
| 7 | ) |
| 8 | |
| 9 | // SetConf invokes SETCONF. |
| 10 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) SetConfscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#SetConf().(entries ...*KeyValscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#) error { |
| 11 | return c.sendSetConfscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#sendSetConf().("SETCONF", entries) |
| 12 | } |
| 13 | |
| 14 | // ResetConf invokes RESETCONF. |
| 15 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) ResetConfscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#ResetConf().(entries ...*KeyValscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#) error { |
| 16 | return c.sendSetConfscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#sendSetConf().("RESETCONF", entries) |
| 17 | } |
| 18 | |
| 19 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) sendSetConfscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#sendSetConf().(cmd string, entries []*KeyValscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#) error { |
| 20 | for _, entry := range entries { |
| 21 | cmd += " " + entry.Keyscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#Key. |
| 22 | if entry.ValSetscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#ValSet().() { |
| 23 | cmd += "=" + torutilscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/.EscapeSimpleQuotedStringIfNeededscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/EscapeSimpleQuotedStringIfNeeded().(entry.Valscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#Val.) |
| 24 | } |
| 25 | } |
| 26 | return c.sendRequestIgnoreResponsescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#sendRequestIgnoreResponse().(cmd) |
| 27 | } |
| 28 | |
| 29 | // GetConf invokes GETCONF and returns the values for the requested keys. |
| 30 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) GetConfscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#GetConf().(keys ...string) ([]*KeyValscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#, error) { |
| 31 | resp, err := c.SendRequestscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#SendRequest().("GETCONF %v", stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Joinscip-go gomod github.com/golang/go/src go1.15 strings/Join().(keys, " ")) |
| 32 | if err != nil { |
| 33 | return nil, err |
| 34 | } |
| 35 | data := resp.DataWithReplyscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Response#DataWithReply().() |
| 36 | ret := make([]*KeyValscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#, 0, len(data)) |
| 37 | for _, data := range data { |
| 38 | key, val, ok := torutilscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/.PartitionStringscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/PartitionString().(data, '=') |
| 39 | entry := &KeyValscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#{Keyscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#Key.: key} |
| 40 | if ok { |
| 41 | if entry.Valscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#Val., err = torutilscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/.UnescapeSimpleQuotedStringIfNeededscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/UnescapeSimpleQuotedStringIfNeeded().(val); err != nil { |
| 42 | return nil, err |
| 43 | } |
| 44 | if len(entry.Valscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#Val.) == 0 { |
| 45 | entry.ValSetAndEmptyscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#ValSetAndEmpty. = true |
| 46 | } |
| 47 | } |
| 48 | ret = append(ret, entry) |
| 49 | } |
| 50 | return ret, nil |
| 51 | } |
| 52 | |
| 53 | // SaveConf invokes SAVECONF. |
| 54 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) SaveConfscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#SaveConf().(force bool) error { |
| 55 | cmd := "SAVECONF" |
| 56 | if force { |
| 57 | cmd += " FORCE" |
| 58 | } |
| 59 | return c.sendRequestIgnoreResponsescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#sendRequestIgnoreResponse().(cmd) |
| 60 | } |
| 61 | |
| 62 | // LoadConf invokes LOADCONF. |
| 63 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) LoadConfscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#LoadConf().(conf string) error { |
| 64 | return c.sendRequestIgnoreResponsescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#sendRequestIgnoreResponse().("+LOADCONF\r\n%v\r\n.", conf) |
| 65 | } |