| 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 | // Signal invokes SIGNAL. |
| 10 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) Signalscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#Signal().(signal string) error { |
| 11 | return c.sendRequestIgnoreResponsescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#sendRequestIgnoreResponse().("SIGNAL %v", signal) |
| 12 | } |
| 13 | |
| 14 | // Quit invokes QUIT. |
| 15 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) Quitscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#Quit().() error { |
| 16 | return c.sendRequestIgnoreResponsescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#sendRequestIgnoreResponse().("QUIT") |
| 17 | } |
| 18 | |
| 19 | // MapAddresses invokes MAPADDRESS and returns mapped addresses. |
| 20 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) MapAddressesscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#MapAddresses().(addresses ...*KeyValscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#) ([]*KeyValscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#, error) { |
| 21 | cmd := "MAPADDRESS" |
| 22 | for _, address := range addresses { |
| 23 | cmd += " " + address.Keyscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#Key. + "=" + address.Valscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#Val. |
| 24 | } |
| 25 | resp, err := c.SendRequestscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#SendRequest().(cmd) |
| 26 | if err != nil { |
| 27 | return nil, err |
| 28 | } |
| 29 | data := resp.DataWithReplyscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Response#DataWithReply().() |
| 30 | ret := make([]*KeyValscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#, 0, len(data)) |
| 31 | for _, address := range data { |
| 32 | mappedAddress := &KeyValscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#{} |
| 33 | mappedAddress.Keyscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#Key., mappedAddress.Valscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#Val., _ = 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().(address, '=') |
| 34 | ret = append(ret, mappedAddress) |
| 35 | } |
| 36 | return ret, nil |
| 37 | } |
| 38 | |
| 39 | // GetInfo invokes GETINTO and returns values for requested keys. |
| 40 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) GetInfoscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#GetInfo().(keys ...string) ([]*KeyValscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#, error) { |
| 41 | resp, err := c.SendRequestscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#SendRequest().("GETINFO %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, " ")) |
| 42 | if err != nil { |
| 43 | return nil, err |
| 44 | } |
| 45 | ret := make([]*KeyValscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#, 0, len(resp.Datascip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Response#Data.)) |
| 46 | for _, val := range resp.Datascip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Response#Data. { |
| 47 | infoVal := &KeyValscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#{} |
| 48 | infoVal.Keyscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#Key., infoVal.Valscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#Val., _ = 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().(val, '=') |
| 49 | if infoVal.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().(infoVal.Valscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/KeyVal#Val.); err != nil { |
| 50 | return nil, err |
| 51 | } |
| 52 | ret = append(ret, infoVal) |
| 53 | } |
| 54 | return ret, nil |
| 55 | } |
| 56 | |
| 57 | // PostDescriptor invokes POSTDESCRIPTOR. |
| 58 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) PostDescriptorscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#PostDescriptor().(descriptor string, purpose string, cache string) error { |
| 59 | cmd := "+POSTDESCRIPTOR" |
| 60 | if purpose != "" { |
| 61 | cmd += " purpose=" + purpose |
| 62 | } |
| 63 | if cache != "" { |
| 64 | cmd += " cache=" + cache |
| 65 | } |
| 66 | cmd += "\r\n" + descriptor + "\r\n." |
| 67 | return c.sendRequestIgnoreResponsescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#sendRequestIgnoreResponse().(cmd) |
| 68 | } |
| 69 | |
| 70 | // UseFeatures invokes USEFEATURE. |
| 71 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) UseFeaturesscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#UseFeatures().(features ...string) error { |
| 72 | return c.sendRequestIgnoreResponsescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#sendRequestIgnoreResponse().("USEFEATURE " + stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Joinscip-go gomod github.com/golang/go/src go1.15 strings/Join().(features, " ")) |
| 73 | } |
| 74 | |
| 75 | // ResolveAsync invokes RESOLVE. |
| 76 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) ResolveAsyncscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#ResolveAsync().(address string, reverse bool) error { |
| 77 | cmd := "RESOLVE " |
| 78 | if reverse { |
| 79 | cmd += "mode=reverse " |
| 80 | } |
| 81 | return c.sendRequestIgnoreResponsescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#sendRequestIgnoreResponse().(cmd + address) |
| 82 | } |
| 83 | |
| 84 | // TakeOwnership invokes TAKEOWNERSHIP. |
| 85 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) TakeOwnershipscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#TakeOwnership().() error { |
| 86 | return c.sendRequestIgnoreResponsescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#sendRequestIgnoreResponse().("TAKEOWNERSHIP") |
| 87 | } |
| 88 | |
| 89 | // DropGuards invokes DROPGUARDS. |
| 90 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) DropGuardsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#DropGuards().() error { |
| 91 | return c.sendRequestIgnoreResponsescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#sendRequestIgnoreResponse().("DROPGUARDS") |
| 92 | } |