| 1 | package controlscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ |
| 2 | |
| 3 | import ( |
| 4 | "contextscip-go gomod github.com/golang/go/src go1.15 context/" |
| 5 | "errorsscip-go gomod github.com/golang/go/src go1.15 errors/" |
| 6 | "strconvscip-go gomod github.com/golang/go/src go1.15 strconv/" |
| 7 | "stringsscip-go gomod github.com/golang/go/src go1.15 strings/" |
| 8 | "timescip-go gomod github.com/golang/go/src go1.15 time/" |
| 9 | |
| 10 | "github.com/cretz/bine/torutilscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/" |
| 11 | ) |
| 12 | |
| 13 | // EventCode represents an asynchronous event code (ref control spec 4.1). |
| 14 | type EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# string |
| 15 | |
| 16 | // Event codes |
| 17 | const ( |
| 18 | EventCodeAddrMapscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeAddrMap. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "ADDRMAP" |
| 19 | EventCodeBandwidthscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeBandwidth. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "BW" |
| 20 | EventCodeBuildTimeoutSetscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeBuildTimeoutSet. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "BUILDTIMEOUT_SET" |
| 21 | EventCodeCellStatsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeCellStats. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "CELL_STATS" |
| 22 | EventCodeCircuitscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeCircuit. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "CIRC" |
| 23 | EventCodeCircuitBandwidthscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeCircuitBandwidth. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "CIRC_BW" |
| 24 | EventCodeCircuitMinorscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeCircuitMinor. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "CIRC_MINOR" |
| 25 | EventCodeClientsSeenscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeClientsSeen. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "CLIENTS_SEEN" |
| 26 | EventCodeConfChangedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeConfChanged. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "CONF_CHANGED" |
| 27 | EventCodeConnBandwidthscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeConnBandwidth. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "CONN_BW" |
| 28 | EventCodeDescChangedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeDescChanged. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "DESCCHANGED" |
| 29 | EventCodeGuardscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeGuard. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "GUARD" |
| 30 | EventCodeHSDescscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeHSDesc. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "HS_DESC" |
| 31 | EventCodeHSDescContentscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeHSDescContent. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "HS_DESC_CONTENT" |
| 32 | EventCodeLogDebugscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeLogDebug. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "DEBUG" |
| 33 | EventCodeLogErrscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeLogErr. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "ERR" |
| 34 | EventCodeLogInfoscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeLogInfo. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "INFO" |
| 35 | EventCodeLogNoticescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeLogNotice. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "NOTICE" |
| 36 | EventCodeLogWarnscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeLogWarn. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "WARN" |
| 37 | EventCodeNetworkLivenessscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeNetworkLiveness. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "NETWORK_LIVENESS" |
| 38 | EventCodeNetworkStatusscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeNetworkStatus. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "NS" |
| 39 | EventCodeNewConsensusscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeNewConsensus. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "NEWCONSENSUS" |
| 40 | EventCodeNewDescscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeNewDesc. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "NEWDESC" |
| 41 | EventCodeORConnscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeORConn. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "ORCONN" |
| 42 | EventCodeSignalscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeSignal. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "SIGNAL" |
| 43 | EventCodeStatusClientscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeStatusClient. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "STATUS_CLIENT" |
| 44 | EventCodeStatusGeneralscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeStatusGeneral. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "STATUS_GENERAL" |
| 45 | EventCodeStatusServerscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeStatusServer. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "STATUS_SERVER" |
| 46 | EventCodeStreamscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeStream. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "STREAM" |
| 47 | EventCodeStreamBandwidthscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeStreamBandwidth. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "STREAM_BW" |
| 48 | EventCodeTokenBucketEmptyscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeTokenBucketEmpty. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "TB_EMPTY" |
| 49 | EventCodeTransportLaunchedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeTransportLaunched. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "TRANSPORT_LAUNCHED" |
| 50 | ) |
| 51 | |
| 52 | // EventCodeUnrecognized is a special event code that is only used with |
| 53 | // AddEventListener and RemoveEventListener to listen for events that are |
| 54 | // unrecognized by this library (i.e. UnrecognizedEvent). |
| 55 | var EventCodeUnrecognizedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeUnrecognized. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# = "<unrecognized>" |
| 56 | |
| 57 | var recognizedEventCodesscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/recognizedEventCodes. = []EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode#{ |
| 58 | EventCodeAddrMapscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeAddrMap., |
| 59 | EventCodeBandwidthscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeBandwidth., |
| 60 | EventCodeBuildTimeoutSetscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeBuildTimeoutSet., |
| 61 | EventCodeCellStatsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeCellStats., |
| 62 | EventCodeCircuitscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeCircuit., |
| 63 | EventCodeCircuitBandwidthscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeCircuitBandwidth., |
| 64 | EventCodeCircuitMinorscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeCircuitMinor., |
| 65 | EventCodeClientsSeenscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeClientsSeen., |
| 66 | EventCodeConfChangedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeConfChanged., |
| 67 | EventCodeConnBandwidthscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeConnBandwidth., |
| 68 | EventCodeDescChangedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeDescChanged., |
| 69 | EventCodeGuardscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeGuard., |
| 70 | EventCodeHSDescscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeHSDesc., |
| 71 | EventCodeHSDescContentscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeHSDescContent., |
| 72 | EventCodeLogDebugscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeLogDebug., |
| 73 | EventCodeLogErrscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeLogErr., |
| 74 | EventCodeLogInfoscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeLogInfo., |
| 75 | EventCodeLogNoticescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeLogNotice., |
| 76 | EventCodeLogWarnscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeLogWarn., |
| 77 | EventCodeNetworkLivenessscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeNetworkLiveness., |
| 78 | EventCodeNetworkStatusscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeNetworkStatus., |
| 79 | EventCodeNewConsensusscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeNewConsensus., |
| 80 | EventCodeNewDescscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeNewDesc., |
| 81 | EventCodeORConnscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeORConn., |
| 82 | EventCodeSignalscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeSignal., |
| 83 | EventCodeStatusClientscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeStatusClient., |
| 84 | EventCodeStatusGeneralscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeStatusGeneral., |
| 85 | EventCodeStatusServerscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeStatusServer., |
| 86 | EventCodeStreamscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeStream., |
| 87 | EventCodeStreamBandwidthscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeStreamBandwidth., |
| 88 | EventCodeTokenBucketEmptyscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeTokenBucketEmpty., |
| 89 | EventCodeTransportLaunchedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeTransportLaunched., |
| 90 | } |
| 91 | |
| 92 | var recognizedEventCodesByCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/recognizedEventCodesByCode. = mapEventCodesscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/mapEventCodes().() |
| 93 | |
| 94 | func mapEventCodesscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/mapEventCodes().() map[EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode#]struct{} { |
| 95 | ret := make(map[EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode#]struct{}, len(recognizedEventCodesscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/recognizedEventCodes.)) |
| 96 | for _, eventCode := range recognizedEventCodesscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/recognizedEventCodes. { |
| 97 | ret[eventCode] = struct{}{} |
| 98 | } |
| 99 | return ret |
| 100 | } |
| 101 | |
| 102 | // EventCodes returns a new slice of all event codes that are recognized (i.e. |
| 103 | // does not include EventCodeUnrecognized). |
| 104 | func EventCodesscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodes().() []EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { |
| 105 | ret := make([]EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode#, len(recognizedEventCodesscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/recognizedEventCodes.)) |
| 106 | copy(ret, recognizedEventCodesscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/recognizedEventCodes.) |
| 107 | return ret |
| 108 | } |
| 109 | |
| 110 | // ErrEventWaitSynchronousResponseOccurred is returned from EventWait (see docs) |
| 111 | var ErrEventWaitSynchronousResponseOccurredscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ErrEventWaitSynchronousResponseOccurred. = errorsscip-go gomod github.com/golang/go/src go1.15 errors/.Newscip-go gomod github.com/golang/go/src go1.15 errors/New().("Synchronous event occurred during EventWait") |
| 112 | |
| 113 | // EventWait waits for the predicate to be satisified or a non-event message to |
| 114 | // come through. If a non-event comes through, the error |
| 115 | // ErrEventWaitSynchronousResponseOccurred is returned. If there is an error in |
| 116 | // the predicate or if the context completes or there is an error internally |
| 117 | // handling the event, the error is returned. Otherwise, the event that true was |
| 118 | // returned from the predicate for is returned. |
| 119 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) EventWaitscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#EventWait().( |
| 120 | ctx contextscip-go gomod github.com/golang/go/src go1.15 context/.Contextscip-go gomod github.com/golang/go/src go1.15 context/Context#, events []EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode#, predicate func(Eventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Event#) (bool, error), |
| 121 | ) (Eventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Event#, error) { |
| 122 | eventCh := make(chan Eventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Event#, 10) |
| 123 | defer close(eventCh) |
| 124 | if err := c.AddEventListenerscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#AddEventListener().(eventCh, events...); err != nil { |
| 125 | return nil, err |
| 126 | } |
| 127 | defer c.RemoveEventListenerscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#RemoveEventListener().(eventCh, events...) |
| 128 | eventCtx, eventCancel := contextscip-go gomod github.com/golang/go/src go1.15 context/.WithCancelscip-go gomod github.com/golang/go/src go1.15 context/WithCancel().(ctx) |
| 129 | defer eventCancel() |
| 130 | errCh := make(chan error, 1) |
| 131 | go func() { errCh <- c.HandleEventsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#HandleEvents().(eventCtx) }() |
| 132 | for { |
| 133 | select { |
| 134 | case <-eventCtx.Donescip-go gomod github.com/golang/go/src go1.15 context/Context#Done().(): |
| 135 | return nil, eventCtx.Errscip-go gomod github.com/golang/go/src go1.15 context/Context#Err().() |
| 136 | case err := <-errCh: |
| 137 | return nil, err |
| 138 | case event := <-eventCh: |
| 139 | if ok, err := predicate(event); err != nil { |
| 140 | return nil, err |
| 141 | } else if ok { |
| 142 | return event, nil |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | // HandleEvents loops until the context is closed dispatching async events. Can |
| 149 | // dispatch events even after context is done and of course during synchronous |
| 150 | // request. This will always end with an error, either from ctx.Done() or from |
| 151 | // an error reading/handling the event. |
| 152 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) HandleEventsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#HandleEvents().(ctx contextscip-go gomod github.com/golang/go/src go1.15 context/.Contextscip-go gomod github.com/golang/go/src go1.15 context/Context#) error { |
| 153 | errCh := make(chan error, 1) |
| 154 | go func() { |
| 155 | for ctx.Errscip-go gomod github.com/golang/go/src go1.15 context/Context#Err().() == nil { |
| 156 | if err := c.HandleNextEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#HandleNextEvent().(); err != nil { |
| 157 | errCh <- err |
| 158 | break |
| 159 | } |
| 160 | } |
| 161 | }() |
| 162 | select { |
| 163 | case err := <-errCh: |
| 164 | return err |
| 165 | case <-ctx.Donescip-go gomod github.com/golang/go/src go1.15 context/Context#Done().(): |
| 166 | return ctx.Errscip-go gomod github.com/golang/go/src go1.15 context/Context#Err().() |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | // HandleNextEvent attempts to read and handle the next event. It will return on |
| 171 | // first message seen, event or not. Otherwise it will wait until there is a |
| 172 | // message read. |
| 173 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) HandleNextEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#HandleNextEvent().() error { |
| 174 | c.readLockscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#readLock..Lockscip-go gomod github.com/golang/go/src go1.15 sync/Mutex#Lock().() |
| 175 | defer c.readLockscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#readLock..Unlockscip-go gomod github.com/golang/go/src go1.15 sync/Mutex#Unlock().() |
| 176 | // We'll just peek for the next 3 bytes and see if they are async |
| 177 | byts, err := c.connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#conn..Rscip-go gomod github.com/golang/go/src go1.15 `net/textproto`/Reader#R..Peekscip-go gomod github.com/golang/go/src go1.15 bufio/Reader#Peek().(3) |
| 178 | if err != nil { |
| 179 | return err |
| 180 | } |
| 181 | statusCode, err := strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.Atoiscip-go gomod github.com/golang/go/src go1.15 strconv/Atoi().(string(byts)) |
| 182 | if err != nil || statusCode != StatusAsyncEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StatusAsyncEvent. { |
| 183 | return err |
| 184 | } |
| 185 | // Read the entire thing and handle it |
| 186 | resp, err := c.ReadResponsescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#ReadResponse().() |
| 187 | if err != nil { |
| 188 | return err |
| 189 | } |
| 190 | c.relayAsyncEventsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#relayAsyncEvents().(resp) |
| 191 | return nil |
| 192 | } |
| 193 | |
| 194 | // AddEventListener adds the given channel as an event listener for the given |
| 195 | // events. Then Tor is notified about which events should be listened to. |
| 196 | // Callers are expected to call RemoveEventListener for the channel and all |
| 197 | // event codes used here before closing the channel. If no events are provided, |
| 198 | // this is essentially a no-op. The EventCodeUnrecognized event code can be used |
| 199 | // to listen for unrecognized events. |
| 200 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) AddEventListenerscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#AddEventListener().(ch chan<- Eventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Event#, events ...EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode#) error { |
| 201 | c.addEventListenerToMapscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#addEventListenerToMap().(ch, events...) |
| 202 | // If there is an error updating the events, remove what we just added |
| 203 | err := c.sendSetEventsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#sendSetEvents().() |
| 204 | if err != nil { |
| 205 | c.removeEventListenerFromMapscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#removeEventListenerFromMap().(ch, events...) |
| 206 | } |
| 207 | return err |
| 208 | } |
| 209 | |
| 210 | // RemoveEventListener removes the given channel from being sent to by the given |
| 211 | // event codes. It is not an error to remove a channel from events |
| 212 | // AddEventListener was not called for. Tor is notified about events which may |
| 213 | // no longer be listened to. If no events are provided, this is essentially a |
| 214 | // no-op. |
| 215 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) RemoveEventListenerscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#RemoveEventListener().(ch chan<- Eventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Event#, events ...EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode#) error { |
| 216 | c.removeEventListenerFromMapscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#removeEventListenerFromMap().(ch, events...) |
| 217 | return c.sendSetEventsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#sendSetEvents().() |
| 218 | } |
| 219 | |
| 220 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) addEventListenerToMapscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#addEventListenerToMap().(ch chan<- Eventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Event#, events ...EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode#) { |
| 221 | c.eventListenersLockscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#eventListenersLock..Lockscip-go gomod github.com/golang/go/src go1.15 sync/RWMutex#Lock().() |
| 222 | defer c.eventListenersLockscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#eventListenersLock..Unlockscip-go gomod github.com/golang/go/src go1.15 sync/RWMutex#Unlock().() |
| 223 | for _, event := range events { |
| 224 | // Must completely replace the array, never mutate it |
| 225 | prevArr := c.eventListenersscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#eventListeners.[event] |
| 226 | newArr := make([]chan<- Eventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Event#, len(prevArr)+1) |
| 227 | copy(newArr, prevArr) |
| 228 | newArr[len(newArr)-1] = ch |
| 229 | c.eventListenersscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#eventListeners.[event] = newArr |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) removeEventListenerFromMapscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#removeEventListenerFromMap().(ch chan<- Eventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Event#, events ...EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode#) { |
| 234 | c.eventListenersLockscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#eventListenersLock..Lockscip-go gomod github.com/golang/go/src go1.15 sync/RWMutex#Lock().() |
| 235 | defer c.eventListenersLockscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#eventListenersLock..Unlockscip-go gomod github.com/golang/go/src go1.15 sync/RWMutex#Unlock().() |
| 236 | for _, event := range events { |
| 237 | arr := c.eventListenersscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#eventListeners.[event] |
| 238 | index := -1 |
| 239 | for i, listener := range arr { |
| 240 | if listener == ch { |
| 241 | index = i |
| 242 | break |
| 243 | } |
| 244 | } |
| 245 | if index != -1 { |
| 246 | if len(arr) == 1 { |
| 247 | delete(c.eventListenersscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#eventListeners., event) |
| 248 | } else { |
| 249 | // Must completely replace the array, never mutate it |
| 250 | newArr := make([]chan<- Eventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Event#, len(arr)-1) |
| 251 | copy(newArr, arr[:index]) |
| 252 | copy(newArr[index:], arr[index+1:]) |
| 253 | c.eventListenersscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#eventListeners.[event] = newArr |
| 254 | } |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) sendSetEventsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#sendSetEvents().() error { |
| 260 | c.eventListenersLockscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#eventListenersLock..RLockscip-go gomod github.com/golang/go/src go1.15 sync/RWMutex#RLock().() |
| 261 | cmd := "SETEVENTS" |
| 262 | for event := range c.eventListenersscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#eventListeners. { |
| 263 | cmd += " " + string(event) |
| 264 | } |
| 265 | c.eventListenersLockscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#eventListenersLock..RUnlockscip-go gomod github.com/golang/go/src go1.15 sync/RWMutex#RUnlock().() |
| 266 | return c.sendRequestIgnoreResponsescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#sendRequestIgnoreResponse().(cmd) |
| 267 | } |
| 268 | |
| 269 | func (c *Connscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#) relayAsyncEventsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#relayAsyncEvents().(resp *Responsescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Response#) { |
| 270 | var code, data string |
| 271 | var dataArray []string |
| 272 | if len(resp.Datascip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Response#Data.) == 1 { |
| 273 | // On single line, part up to space, newline, or EOL is the code, rest is data |
| 274 | if index := stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Indexscip-go gomod github.com/golang/go/src go1.15 strings/Index().(resp.Datascip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Response#Data.[0], " "); index != -1 { |
| 275 | code, data = resp.Datascip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Response#Data.[0][:index], resp.Datascip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Response#Data.[0][index+1:] |
| 276 | } else if index := stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Indexscip-go gomod github.com/golang/go/src go1.15 strings/Index().(resp.Datascip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Response#Data.[0], "\r\n"); index != -1 { |
| 277 | code, data = resp.Datascip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Response#Data.[0][:index], resp.Datascip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Response#Data.[0][index+2:] |
| 278 | } else { |
| 279 | code, data = resp.Datascip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Response#Data.[0], "" |
| 280 | } |
| 281 | } else if len(resp.Datascip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Response#Data.) > 0 { |
| 282 | // If there are multiple lines, the entire first line is the code |
| 283 | code, dataArray = resp.Datascip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Response#Data.[0], resp.Datascip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Response#Data.[1:] |
| 284 | } else { |
| 285 | // Otherwise, the reply line has the data |
| 286 | code, data, _ = 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().(resp.Replyscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Response#Reply., ' ') |
| 287 | } |
| 288 | // Only relay if there are chans |
| 289 | eventCode := EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode#(code) |
| 290 | c.eventListenersLockscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#eventListenersLock..RLockscip-go gomod github.com/golang/go/src go1.15 sync/RWMutex#RLock().() |
| 291 | chans := c.eventListenersscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#eventListeners.[eventCode] |
| 292 | if _, ok := recognizedEventCodesByCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/recognizedEventCodesByCode.[eventCode]; !ok { |
| 293 | chans = append(chans, c.eventListenersscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#eventListeners.[EventCodeUnrecognizedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeUnrecognized.]...) |
| 294 | } |
| 295 | c.eventListenersLockscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#eventListenersLock..RUnlockscip-go gomod github.com/golang/go/src go1.15 sync/RWMutex#RUnlock().() |
| 296 | if len(chans) == 0 { |
| 297 | return |
| 298 | } |
| 299 | // Parse the event and only send if known event |
| 300 | if event := ParseEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseEvent().(eventCode, data, dataArray); event != nil { |
| 301 | for _, ch := range chans { |
| 302 | // Just send, if closed or blocking, that's not our problem |
| 303 | ch <- event |
| 304 | } |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | // Zero on fail |
| 309 | func parseISOTimescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/parseISOTime().(str string) timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time# { |
| 310 | // Essentially time.RFC3339 but without 'T' or TZ info |
| 311 | const layout = "2006-01-02 15:04:05" |
| 312 | ret, err := timescip-go gomod github.com/golang/go/src go1.15 time/.Parsescip-go gomod github.com/golang/go/src go1.15 time/Parse().(layout, str) |
| 313 | if err != nil { |
| 314 | ret = timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time#{} |
| 315 | } |
| 316 | return ret |
| 317 | } |
| 318 | |
| 319 | // Zero on fail |
| 320 | func parseISOTime2Fracscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/parseISOTime2Frac().(str string) timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time# { |
| 321 | // Essentially time.RFC3339Nano but without TZ info |
| 322 | const layout = "2006-01-02T15:04:05.999999999" |
| 323 | ret, err := timescip-go gomod github.com/golang/go/src go1.15 time/.Parsescip-go gomod github.com/golang/go/src go1.15 time/Parse().(layout, str) |
| 324 | if err != nil { |
| 325 | ret = timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time#{} |
| 326 | } |
| 327 | return ret |
| 328 | } |
| 329 | |
| 330 | // Event is the base interface for all known asynchronous events. |
| 331 | type Eventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Event# interface { |
| 332 | Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Event#Code.() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# |
| 333 | } |
| 334 | |
| 335 | // ParseEvent returns an Event for the given code and data info. Raw is the raw |
| 336 | // single line if it is a single-line event (even if it has newlines), dataArray |
| 337 | // is the array of lines for multi-line events. Only one of the two needs to be |
| 338 | // set. The response is never nil, but may be UnrecognizedEvent. Format errors |
| 339 | // are ignored per the Tor spec. |
| 340 | func ParseEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseEvent().(code EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode#, raw string, dataArray []string) Eventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Event# { |
| 341 | switch code { |
| 342 | case EventCodeAddrMapscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeAddrMap.: |
| 343 | return ParseAddrMapEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseAddrMapEvent().(raw) |
| 344 | case EventCodeBandwidthscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeBandwidth.: |
| 345 | return ParseBandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseBandwidthEvent().(raw) |
| 346 | case EventCodeBuildTimeoutSetscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeBuildTimeoutSet.: |
| 347 | return ParseBuildTimeoutSetEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseBuildTimeoutSetEvent().(raw) |
| 348 | case EventCodeCellStatsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeCellStats.: |
| 349 | return ParseCellStatsEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseCellStatsEvent().(raw) |
| 350 | case EventCodeCircuitscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeCircuit.: |
| 351 | return ParseCircuitEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseCircuitEvent().(raw) |
| 352 | case EventCodeCircuitBandwidthscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeCircuitBandwidth.: |
| 353 | return ParseCircuitBandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseCircuitBandwidthEvent().(raw) |
| 354 | case EventCodeCircuitMinorscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeCircuitMinor.: |
| 355 | return ParseCircuitMinorEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseCircuitMinorEvent().(raw) |
| 356 | case EventCodeClientsSeenscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeClientsSeen.: |
| 357 | return ParseClientsSeenEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseClientsSeenEvent().(raw) |
| 358 | case EventCodeConfChangedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeConfChanged.: |
| 359 | return ParseConfChangedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseConfChangedEvent().(dataArray) |
| 360 | case EventCodeConnBandwidthscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeConnBandwidth.: |
| 361 | return ParseConnBandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseConnBandwidthEvent().(raw) |
| 362 | case EventCodeDescChangedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeDescChanged.: |
| 363 | return ParseDescChangedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseDescChangedEvent().(raw) |
| 364 | case EventCodeGuardscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeGuard.: |
| 365 | return ParseGuardEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseGuardEvent().(raw) |
| 366 | case EventCodeHSDescscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeHSDesc.: |
| 367 | return ParseHSDescEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseHSDescEvent().(raw) |
| 368 | case EventCodeHSDescContentscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeHSDescContent.: |
| 369 | return ParseHSDescContentEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseHSDescContentEvent().(raw) |
| 370 | case EventCodeLogDebugscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeLogDebug., EventCodeLogErrscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeLogErr., EventCodeLogInfoscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeLogInfo., EventCodeLogNoticescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeLogNotice., EventCodeLogWarnscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeLogWarn.: |
| 371 | return ParseLogEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseLogEvent().(code, raw) |
| 372 | case EventCodeNetworkLivenessscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeNetworkLiveness.: |
| 373 | return ParseNetworkLivenessEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseNetworkLivenessEvent().(raw) |
| 374 | case EventCodeNetworkStatusscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeNetworkStatus.: |
| 375 | return ParseNetworkStatusEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseNetworkStatusEvent().(raw) |
| 376 | case EventCodeNewConsensusscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeNewConsensus.: |
| 377 | return ParseNewConsensusEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseNewConsensusEvent().(raw) |
| 378 | case EventCodeNewDescscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeNewDesc.: |
| 379 | return ParseNewDescEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseNewDescEvent().(raw) |
| 380 | case EventCodeORConnscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeORConn.: |
| 381 | return ParseORConnEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseORConnEvent().(raw) |
| 382 | case EventCodeSignalscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeSignal.: |
| 383 | return ParseSignalEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseSignalEvent().(raw) |
| 384 | case EventCodeStatusClientscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeStatusClient., EventCodeStatusGeneralscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeStatusGeneral., EventCodeStatusServerscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeStatusServer.: |
| 385 | return ParseStatusEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseStatusEvent().(code, raw) |
| 386 | case EventCodeStreamscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeStream.: |
| 387 | return ParseStreamEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseStreamEvent().(raw) |
| 388 | case EventCodeStreamBandwidthscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeStreamBandwidth.: |
| 389 | return ParseStreamBandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseStreamBandwidthEvent().(raw) |
| 390 | case EventCodeTokenBucketEmptyscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeTokenBucketEmpty.: |
| 391 | return ParseTokenBucketEmptyEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseTokenBucketEmptyEvent().(raw) |
| 392 | case EventCodeTransportLaunchedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeTransportLaunched.: |
| 393 | return ParseTransportLaunchedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseTransportLaunchedEvent().(raw) |
| 394 | default: |
| 395 | return ParseUnrecognizedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseUnrecognizedEvent().(code, raw, dataArray) |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | // CircuitEvent is CIRC in spec. |
| 400 | type CircuitEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent# struct { |
| 401 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#Raw. string |
| 402 | CircuitIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#CircuitID. string |
| 403 | Statusscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#Status. string |
| 404 | Pathscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#Path. []string |
| 405 | BuildFlagsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#BuildFlags. []string |
| 406 | Purposescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#Purpose. string |
| 407 | HSStatescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#HSState. string |
| 408 | RendQueryscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#RendQuery. string |
| 409 | TimeCreatedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#TimeCreated. timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time# |
| 410 | Reasonscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#Reason. string |
| 411 | RemoteReasonscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#RemoteReason. string |
| 412 | SocksUsernamescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#SocksUsername. string |
| 413 | SocksPasswordscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#SocksPassword. string |
| 414 | } |
| 415 | |
| 416 | // ParseCircuitEvent parses the event. |
| 417 | func ParseCircuitEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseCircuitEvent().(raw string) *CircuitEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent# { |
| 418 | event := &CircuitEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#Raw.: raw} |
| 419 | event.CircuitIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#CircuitID., raw, _ = 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().(raw, ' ') |
| 420 | var ok bool |
| 421 | event.Statusscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#Status., raw, 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().(raw, ' ') |
| 422 | var attr string |
| 423 | first := true |
| 424 | for ok { |
| 425 | attr, raw, 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().(raw, ' ') |
| 426 | key, 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().(attr, '=') |
| 427 | switch key { |
| 428 | case "BUILD_FLAGS": |
| 429 | event.BuildFlagsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#BuildFlags. = stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Splitscip-go gomod github.com/golang/go/src go1.15 strings/Split().(val, ",") |
| 430 | case "PURPOSE": |
| 431 | event.Purposescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#Purpose. = val |
| 432 | case "HS_STATE": |
| 433 | event.HSStatescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#HSState. = val |
| 434 | case "REND_QUERY": |
| 435 | event.RendQueryscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#RendQuery. = val |
| 436 | case "TIME_CREATED": |
| 437 | event.TimeCreatedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#TimeCreated. = parseISOTime2Fracscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/parseISOTime2Frac().(val) |
| 438 | case "REASON": |
| 439 | event.Reasonscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#Reason. = val |
| 440 | case "REMOTE_REASON": |
| 441 | event.RemoteReasonscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#RemoteReason. = val |
| 442 | case "SOCKS_USERNAME": |
| 443 | event.SocksUsernamescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#SocksUsername. = val |
| 444 | case "SOCKS_PASSWORD": |
| 445 | event.SocksPasswordscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#SocksPassword. = val |
| 446 | default: |
| 447 | if first { |
| 448 | event.Pathscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#Path. = stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Splitscip-go gomod github.com/golang/go/src go1.15 strings/Split().(val, ",") |
| 449 | } |
| 450 | } |
| 451 | first = false |
| 452 | } |
| 453 | return event |
| 454 | } |
| 455 | |
| 456 | // Code implements Event.Code |
| 457 | func (*CircuitEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeCircuitscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeCircuit. } |
| 458 | |
| 459 | // StreamEvent is STREAM in spec. |
| 460 | type StreamEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent# struct { |
| 461 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#Raw. string |
| 462 | StreamIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#StreamID. string |
| 463 | Statusscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#Status. string |
| 464 | CircuitIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#CircuitID. string |
| 465 | TargetAddressscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#TargetAddress. string |
| 466 | TargetPortscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#TargetPort. int |
| 467 | Reasonscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#Reason. string |
| 468 | RemoteReasonscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#RemoteReason. string |
| 469 | Sourcescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#Source. string |
| 470 | SourceAddressscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#SourceAddress. string |
| 471 | SourcePortscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#SourcePort. int |
| 472 | Purposescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#Purpose. string |
| 473 | } |
| 474 | |
| 475 | // ParseStreamEvent parses the event. |
| 476 | func ParseStreamEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseStreamEvent().(raw string) *StreamEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent# { |
| 477 | event := &StreamEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#Raw.: raw} |
| 478 | event.StreamIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#StreamID., raw, _ = 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().(raw, ' ') |
| 479 | event.Statusscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#Status., raw, _ = 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().(raw, ' ') |
| 480 | event.CircuitIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#CircuitID., raw, _ = 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().(raw, ' ') |
| 481 | var ok bool |
| 482 | event.TargetAddressscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#TargetAddress., raw, 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().(raw, ' ') |
| 483 | if target, port, hasPort := torutilscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/.PartitionStringFromEndscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/PartitionStringFromEnd().(event.TargetAddressscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#TargetAddress., ':'); hasPort { |
| 484 | event.TargetAddressscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#TargetAddress. = target |
| 485 | event.TargetPortscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#TargetPort., _ = strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.Atoiscip-go gomod github.com/golang/go/src go1.15 strconv/Atoi().(port) |
| 486 | } |
| 487 | var attr string |
| 488 | for ok { |
| 489 | attr, raw, 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().(raw, ' ') |
| 490 | key, 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().(attr, '=') |
| 491 | switch key { |
| 492 | case "REASON": |
| 493 | event.Reasonscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#Reason. = val |
| 494 | case "REMOTE_REASON": |
| 495 | event.RemoteReasonscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#RemoteReason. = val |
| 496 | case "SOURCE": |
| 497 | event.Sourcescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#Source. = val |
| 498 | case "SOURCE_ADDR": |
| 499 | event.SourceAddressscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#SourceAddress. = val |
| 500 | if source, port, hasPort := torutilscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/.PartitionStringFromEndscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/PartitionStringFromEnd().(event.SourceAddressscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#SourceAddress., ':'); hasPort { |
| 501 | event.SourceAddressscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#SourceAddress. = source |
| 502 | event.SourcePortscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#SourcePort., _ = strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.Atoiscip-go gomod github.com/golang/go/src go1.15 strconv/Atoi().(port) |
| 503 | } |
| 504 | case "PURPOSE": |
| 505 | event.Purposescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#Purpose. = val |
| 506 | } |
| 507 | } |
| 508 | return event |
| 509 | } |
| 510 | |
| 511 | // Code implements Event.Code |
| 512 | func (*StreamEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeStreamscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeStream. } |
| 513 | |
| 514 | // ORConnEvent is ORCONN in spec. |
| 515 | type ORConnEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ORConnEvent# struct { |
| 516 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ORConnEvent#Raw. string |
| 517 | Targetscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ORConnEvent#Target. string |
| 518 | Statusscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ORConnEvent#Status. string |
| 519 | Reasonscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ORConnEvent#Reason. string |
| 520 | NumCircuitsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ORConnEvent#NumCircuits. int |
| 521 | ConnIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ORConnEvent#ConnID. string |
| 522 | } |
| 523 | |
| 524 | // ParseORConnEvent parses the event. |
| 525 | func ParseORConnEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseORConnEvent().(raw string) *ORConnEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ORConnEvent# { |
| 526 | event := &ORConnEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ORConnEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ORConnEvent#Raw.: raw} |
| 527 | event.Targetscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ORConnEvent#Target., raw, _ = 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().(raw, ' ') |
| 528 | var ok bool |
| 529 | event.Statusscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ORConnEvent#Status., raw, 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().(raw, ' ') |
| 530 | var attr string |
| 531 | for ok { |
| 532 | attr, raw, 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().(raw, ' ') |
| 533 | key, 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().(attr, '=') |
| 534 | switch key { |
| 535 | case "REASON": |
| 536 | event.Reasonscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ORConnEvent#Reason. = val |
| 537 | case "NCIRCS": |
| 538 | event.NumCircuitsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ORConnEvent#NumCircuits., _ = strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.Atoiscip-go gomod github.com/golang/go/src go1.15 strconv/Atoi().(val) |
| 539 | case "ID": |
| 540 | event.ConnIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ORConnEvent#ConnID. = val |
| 541 | } |
| 542 | } |
| 543 | return event |
| 544 | } |
| 545 | |
| 546 | // Code implements Event.Code |
| 547 | func (*ORConnEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ORConnEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ORConnEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeORConnscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeORConn. } |
| 548 | |
| 549 | // BandwidthEvent is BW in spec. |
| 550 | type BandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BandwidthEvent# struct { |
| 551 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BandwidthEvent#Raw. string |
| 552 | BytesReadscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BandwidthEvent#BytesRead. int64 |
| 553 | BytesWrittenscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BandwidthEvent#BytesWritten. int64 |
| 554 | } |
| 555 | |
| 556 | // ParseBandwidthEvent parses the event. |
| 557 | func ParseBandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseBandwidthEvent().(raw string) *BandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BandwidthEvent# { |
| 558 | event := &BandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BandwidthEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BandwidthEvent#Raw.: raw} |
| 559 | var temp string |
| 560 | temp, raw, _ = 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().(raw, ' ') |
| 561 | event.BytesReadscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BandwidthEvent#BytesRead., _ = strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.15 strconv/ParseInt().(temp, 10, 64) |
| 562 | temp, raw, _ = 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().(raw, ' ') |
| 563 | event.BytesWrittenscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BandwidthEvent#BytesWritten., _ = strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.15 strconv/ParseInt().(temp, 10, 64) |
| 564 | return event |
| 565 | } |
| 566 | |
| 567 | // Code implements Event.Code |
| 568 | func (*BandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BandwidthEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BandwidthEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeBandwidthscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeBandwidth. } |
| 569 | |
| 570 | // LogEvent is DEBUG, ERR, INFO, NOTICE, and WARN in spec. |
| 571 | type LogEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/LogEvent# struct { |
| 572 | Severityscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/LogEvent#Severity. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# |
| 573 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/LogEvent#Raw. string |
| 574 | } |
| 575 | |
| 576 | // ParseLogEvent parses the event. |
| 577 | func ParseLogEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseLogEvent().(severity EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode#, raw string) *LogEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/LogEvent# { |
| 578 | return &LogEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/LogEvent#{Severityscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/LogEvent#Severity.: severity, Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/LogEvent#Raw.: raw} |
| 579 | } |
| 580 | |
| 581 | // Code implements Event.Code |
| 582 | func (l *LogEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/LogEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/LogEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return l.Severityscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/LogEvent#Severity. } |
| 583 | |
| 584 | // NewDescEvent is NEWDESC in spec. |
| 585 | type NewDescEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NewDescEvent# struct { |
| 586 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NewDescEvent#Raw. string |
| 587 | Descsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NewDescEvent#Descs. []string |
| 588 | } |
| 589 | |
| 590 | // ParseNewDescEvent parses the event. |
| 591 | func ParseNewDescEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseNewDescEvent().(raw string) *NewDescEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NewDescEvent# { |
| 592 | return &NewDescEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NewDescEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NewDescEvent#Raw.: raw, Descsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NewDescEvent#Descs.: stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Splitscip-go gomod github.com/golang/go/src go1.15 strings/Split().(raw, " ")} |
| 593 | } |
| 594 | |
| 595 | // Code implements Event.Code |
| 596 | func (*NewDescEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NewDescEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NewDescEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeNewDescscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeNewDesc. } |
| 597 | |
| 598 | // AddrMapEvent is ADDRMAP in spec. |
| 599 | type AddrMapEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/AddrMapEvent# struct { |
| 600 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/AddrMapEvent#Raw. string |
| 601 | Addressscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/AddrMapEvent#Address. string |
| 602 | NewAddressscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/AddrMapEvent#NewAddress. string |
| 603 | ErrorCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/AddrMapEvent#ErrorCode. string |
| 604 | // Zero if no expire |
| 605 | Expiresscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/AddrMapEvent#Expires. timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time# |
| 606 | // Sans double quotes |
| 607 | Cachedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/AddrMapEvent#Cached. string |
| 608 | } |
| 609 | |
| 610 | // ParseAddrMapEvent parses the event. |
| 611 | func ParseAddrMapEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseAddrMapEvent().(raw string) *AddrMapEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/AddrMapEvent# { |
| 612 | event := &AddrMapEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/AddrMapEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/AddrMapEvent#Raw.: raw} |
| 613 | event.Addressscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/AddrMapEvent#Address., raw, _ = 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().(raw, ' ') |
| 614 | event.NewAddressscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/AddrMapEvent#NewAddress., raw, _ = 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().(raw, ' ') |
| 615 | var ok bool |
| 616 | // Skip local expiration, use UTC one later |
| 617 | _, raw, 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().(raw, ' ') |
| 618 | var attr string |
| 619 | for ok { |
| 620 | attr, raw, 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().(raw, ' ') |
| 621 | key, 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().(attr, '=') |
| 622 | switch key { |
| 623 | case "error": |
| 624 | event.ErrorCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/AddrMapEvent#ErrorCode. = val |
| 625 | case "EXPIRES": |
| 626 | val, _ = torutilscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/.UnescapeSimpleQuotedStringscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/UnescapeSimpleQuotedString().(val) |
| 627 | event.Expiresscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/AddrMapEvent#Expires. = parseISOTimescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/parseISOTime().(val) |
| 628 | case "CACHED": |
| 629 | event.Cachedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/AddrMapEvent#Cached., _ = 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) |
| 630 | } |
| 631 | } |
| 632 | return event |
| 633 | } |
| 634 | |
| 635 | // Code implements Event.Code |
| 636 | func (*AddrMapEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/AddrMapEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/AddrMapEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeAddrMapscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeAddrMap. } |
| 637 | |
| 638 | // DescChangedEvent is DESCCHANGED in spec. |
| 639 | type DescChangedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/DescChangedEvent# struct { |
| 640 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/DescChangedEvent#Raw. string |
| 641 | } |
| 642 | |
| 643 | // ParseDescChangedEvent parses the event. |
| 644 | func ParseDescChangedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseDescChangedEvent().(raw string) *DescChangedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/DescChangedEvent# { |
| 645 | return &DescChangedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/DescChangedEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/DescChangedEvent#Raw.: raw} |
| 646 | } |
| 647 | |
| 648 | // Code implements Event.Code |
| 649 | func (*DescChangedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/DescChangedEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/DescChangedEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeDescChangedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeDescChanged. } |
| 650 | |
| 651 | // StatusEvent is STATUS_CLIENT, STATUS_GENERAL, and STATUS_SERVER in spec. |
| 652 | type StatusEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StatusEvent# struct { |
| 653 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StatusEvent#Raw. string |
| 654 | Typescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StatusEvent#Type. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# |
| 655 | Severityscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StatusEvent#Severity. string |
| 656 | Actionscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StatusEvent#Action. string |
| 657 | Argumentsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StatusEvent#Arguments. map[string]string |
| 658 | } |
| 659 | |
| 660 | // ParseStatusEvent parses the event. |
| 661 | func ParseStatusEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseStatusEvent().(typ EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode#, raw string) *StatusEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StatusEvent# { |
| 662 | event := &StatusEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StatusEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StatusEvent#Raw.: raw, Typescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StatusEvent#Type.: typ, Argumentsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StatusEvent#Arguments.: map[string]string{}} |
| 663 | event.Severityscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StatusEvent#Severity., raw, _ = 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().(raw, ' ') |
| 664 | var ok bool |
| 665 | event.Actionscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StatusEvent#Action., raw, 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().(raw, ' ') |
| 666 | var attr string |
| 667 | for ok { |
| 668 | attr, raw, 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().(raw, ' ') |
| 669 | key, 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().(attr, '=') |
| 670 | event.Argumentsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StatusEvent#Arguments.[key], _ = 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) |
| 671 | } |
| 672 | return event |
| 673 | } |
| 674 | |
| 675 | // Code implements Event.Code |
| 676 | func (s *StatusEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StatusEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StatusEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return s.Typescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StatusEvent#Type. } |
| 677 | |
| 678 | // GuardEvent is GUARD in spec. |
| 679 | type GuardEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/GuardEvent# struct { |
| 680 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/GuardEvent#Raw. string |
| 681 | Typescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/GuardEvent#Type. string |
| 682 | Namescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/GuardEvent#Name. string |
| 683 | Statusscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/GuardEvent#Status. string |
| 684 | } |
| 685 | |
| 686 | // ParseGuardEvent parses the event. |
| 687 | func ParseGuardEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseGuardEvent().(raw string) *GuardEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/GuardEvent# { |
| 688 | event := &GuardEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/GuardEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/GuardEvent#Raw.: raw} |
| 689 | event.Typescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/GuardEvent#Type., raw, _ = 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().(raw, ' ') |
| 690 | event.Namescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/GuardEvent#Name., raw, _ = 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().(raw, ' ') |
| 691 | event.Statusscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/GuardEvent#Status., raw, _ = 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().(raw, ' ') |
| 692 | return event |
| 693 | } |
| 694 | |
| 695 | // Code implements Event.Code |
| 696 | func (*GuardEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/GuardEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/GuardEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeGuardscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeGuard. } |
| 697 | |
| 698 | // NetworkStatusEvent is NS in spec. |
| 699 | type NetworkStatusEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NetworkStatusEvent# struct { |
| 700 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NetworkStatusEvent#Raw. string |
| 701 | } |
| 702 | |
| 703 | // ParseNetworkStatusEvent parses the event. |
| 704 | func ParseNetworkStatusEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseNetworkStatusEvent().(raw string) *NetworkStatusEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NetworkStatusEvent# { |
| 705 | return &NetworkStatusEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NetworkStatusEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NetworkStatusEvent#Raw.: raw} |
| 706 | } |
| 707 | |
| 708 | // Code implements Event.Code |
| 709 | func (*NetworkStatusEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NetworkStatusEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NetworkStatusEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeNetworkStatusscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeNetworkStatus. } |
| 710 | |
| 711 | // StreamBandwidthEvent is STREAM_BW in spec. |
| 712 | type StreamBandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamBandwidthEvent# struct { |
| 713 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamBandwidthEvent#Raw. string |
| 714 | BytesReadscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamBandwidthEvent#BytesRead. int64 |
| 715 | BytesWrittenscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamBandwidthEvent#BytesWritten. int64 |
| 716 | Timescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamBandwidthEvent#Time. timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time# |
| 717 | } |
| 718 | |
| 719 | // ParseStreamBandwidthEvent parses the event. |
| 720 | func ParseStreamBandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseStreamBandwidthEvent().(raw string) *StreamBandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamBandwidthEvent# { |
| 721 | event := &StreamBandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamBandwidthEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamBandwidthEvent#Raw.: raw} |
| 722 | var temp string |
| 723 | temp, raw, _ = 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().(raw, ' ') |
| 724 | event.BytesReadscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamBandwidthEvent#BytesRead., _ = strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.15 strconv/ParseInt().(temp, 10, 64) |
| 725 | temp, raw, _ = 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().(raw, ' ') |
| 726 | event.BytesWrittenscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamBandwidthEvent#BytesWritten., _ = strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.15 strconv/ParseInt().(temp, 10, 64) |
| 727 | temp, raw, _ = 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().(raw, ' ') |
| 728 | temp, _ = torutilscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/.UnescapeSimpleQuotedStringscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/UnescapeSimpleQuotedString().(temp) |
| 729 | event.Timescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamBandwidthEvent#Time. = parseISOTime2Fracscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/parseISOTime2Frac().(temp) |
| 730 | return event |
| 731 | } |
| 732 | |
| 733 | // Code implements Event.Code |
| 734 | func (*StreamBandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamBandwidthEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/StreamBandwidthEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeStreamBandwidthscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeStreamBandwidth. } |
| 735 | |
| 736 | // ClientsSeenEvent is CLIENTS_SEEN in spec. |
| 737 | type ClientsSeenEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ClientsSeenEvent# struct { |
| 738 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ClientsSeenEvent#Raw. string |
| 739 | TimeStartedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ClientsSeenEvent#TimeStarted. timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time# |
| 740 | CountrySummaryscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ClientsSeenEvent#CountrySummary. map[string]int |
| 741 | IPVersionsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ClientsSeenEvent#IPVersions. map[string]int |
| 742 | } |
| 743 | |
| 744 | // ParseClientsSeenEvent parses the event. |
| 745 | func ParseClientsSeenEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseClientsSeenEvent().(raw string) *ClientsSeenEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ClientsSeenEvent# { |
| 746 | event := &ClientsSeenEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ClientsSeenEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ClientsSeenEvent#Raw.: raw} |
| 747 | var temp string |
| 748 | var ok bool |
| 749 | temp, raw, 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().(raw, ' ') |
| 750 | temp, _ = torutilscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/.UnescapeSimpleQuotedStringscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/torutil`/UnescapeSimpleQuotedString().(temp) |
| 751 | event.TimeStartedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ClientsSeenEvent#TimeStarted. = parseISOTimescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/parseISOTime().(temp) |
| 752 | strToMap := func(str string) map[string]int { |
| 753 | ret := map[string]int{} |
| 754 | for _, keyVal := range stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Splitscip-go gomod github.com/golang/go/src go1.15 strings/Split().(str, ",") { |
| 755 | key, 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().(keyVal, '=') |
| 756 | ret[key], _ = strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.Atoiscip-go gomod github.com/golang/go/src go1.15 strconv/Atoi().(val) |
| 757 | } |
| 758 | return ret |
| 759 | } |
| 760 | var attr string |
| 761 | for ok { |
| 762 | attr, raw, 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().(raw, ' ') |
| 763 | key, 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().(attr, '=') |
| 764 | switch key { |
| 765 | case "CountrySummary": |
| 766 | event.CountrySummaryscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ClientsSeenEvent#CountrySummary. = strToMap(val) |
| 767 | case "IPVersions": |
| 768 | event.IPVersionsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ClientsSeenEvent#IPVersions. = strToMap(val) |
| 769 | } |
| 770 | } |
| 771 | return event |
| 772 | } |
| 773 | |
| 774 | // Code implements Event.Code |
| 775 | func (*ClientsSeenEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ClientsSeenEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ClientsSeenEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeClientsSeenscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeClientsSeen. } |
| 776 | |
| 777 | // NewConsensusEvent is NEWCONSENSUS in spec. |
| 778 | type NewConsensusEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NewConsensusEvent# struct { |
| 779 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NewConsensusEvent#Raw. string |
| 780 | } |
| 781 | |
| 782 | // ParseNewConsensusEvent parses the event. |
| 783 | func ParseNewConsensusEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseNewConsensusEvent().(raw string) *NewConsensusEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NewConsensusEvent# { |
| 784 | return &NewConsensusEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NewConsensusEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NewConsensusEvent#Raw.: raw} |
| 785 | } |
| 786 | |
| 787 | // Code implements Event.Code |
| 788 | func (*NewConsensusEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NewConsensusEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NewConsensusEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeNewConsensusscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeNewConsensus. } |
| 789 | |
| 790 | // BuildTimeoutSetEvent is BUILDTIMEOUT_SET in spec. |
| 791 | type BuildTimeoutSetEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent# struct { |
| 792 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#Raw. string |
| 793 | Typescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#Type. string |
| 794 | TotalTimesscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#TotalTimes. int |
| 795 | Timeoutscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#Timeout. timescip-go gomod github.com/golang/go/src go1.15 time/.Durationscip-go gomod github.com/golang/go/src go1.15 time/Duration# |
| 796 | Xmscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#Xm. int |
| 797 | Alphascip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#Alpha. float32 |
| 798 | Quantilescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#Quantile. float32 |
| 799 | TimeoutRatescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#TimeoutRate. float32 |
| 800 | CloseTimeoutscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#CloseTimeout. timescip-go gomod github.com/golang/go/src go1.15 time/.Durationscip-go gomod github.com/golang/go/src go1.15 time/Duration# |
| 801 | CloseRatescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#CloseRate. float32 |
| 802 | } |
| 803 | |
| 804 | // ParseBuildTimeoutSetEvent parses the event. |
| 805 | func ParseBuildTimeoutSetEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseBuildTimeoutSetEvent().(raw string) *BuildTimeoutSetEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent# { |
| 806 | event := &BuildTimeoutSetEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#Raw.: raw} |
| 807 | var ok bool |
| 808 | event.Typescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#Type., raw, 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().(raw, ' ') |
| 809 | _, raw, 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().(raw, ' ') |
| 810 | var attr string |
| 811 | parseFloat := func(val string) float32 { |
| 812 | f, _ := strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.ParseFloatscip-go gomod github.com/golang/go/src go1.15 strconv/ParseFloat().(val, 32) |
| 813 | return float32(f) |
| 814 | } |
| 815 | for ok { |
| 816 | attr, raw, 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().(raw, ' ') |
| 817 | key, 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().(attr, '=') |
| 818 | switch key { |
| 819 | case "TOTAL_TIMES": |
| 820 | event.TotalTimesscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#TotalTimes., _ = strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.Atoiscip-go gomod github.com/golang/go/src go1.15 strconv/Atoi().(val) |
| 821 | case "TIMEOUT_MS": |
| 822 | if ms, err := strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.15 strconv/ParseInt().(val, 10, 64); err == nil { |
| 823 | event.Timeoutscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#Timeout. = timescip-go gomod github.com/golang/go/src go1.15 time/.Durationscip-go gomod github.com/golang/go/src go1.15 time/Duration#(ms) * timescip-go gomod github.com/golang/go/src go1.15 time/.Millisecondscip-go gomod github.com/golang/go/src go1.15 time/Millisecond. |
| 824 | } |
| 825 | case "XM": |
| 826 | event.Xmscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#Xm., _ = strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.Atoiscip-go gomod github.com/golang/go/src go1.15 strconv/Atoi().(val) |
| 827 | case "ALPHA": |
| 828 | event.Alphascip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#Alpha. = parseFloat(val) |
| 829 | case "CUTOFF_QUANTILE": |
| 830 | event.Quantilescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#Quantile. = parseFloat(val) |
| 831 | case "TIMEOUT_RATE": |
| 832 | event.TimeoutRatescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#TimeoutRate. = parseFloat(val) |
| 833 | case "CLOSE_MS": |
| 834 | if ms, err := strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.15 strconv/ParseInt().(val, 10, 64); err == nil { |
| 835 | event.CloseTimeoutscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#CloseTimeout. = timescip-go gomod github.com/golang/go/src go1.15 time/.Durationscip-go gomod github.com/golang/go/src go1.15 time/Duration#(ms) * timescip-go gomod github.com/golang/go/src go1.15 time/.Millisecondscip-go gomod github.com/golang/go/src go1.15 time/Millisecond. |
| 836 | } |
| 837 | case "CLOSE_RATE": |
| 838 | event.CloseRatescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#CloseRate. = parseFloat(val) |
| 839 | } |
| 840 | } |
| 841 | return event |
| 842 | } |
| 843 | |
| 844 | // Code implements Event.Code |
| 845 | func (*BuildTimeoutSetEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/BuildTimeoutSetEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeBuildTimeoutSetscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeBuildTimeoutSet. } |
| 846 | |
| 847 | // SignalEvent is SIGNAL in spec. |
| 848 | type SignalEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/SignalEvent# struct { |
| 849 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/SignalEvent#Raw. string |
| 850 | } |
| 851 | |
| 852 | // ParseSignalEvent parses the event. |
| 853 | func ParseSignalEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseSignalEvent().(raw string) *SignalEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/SignalEvent# { |
| 854 | return &SignalEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/SignalEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/SignalEvent#Raw.: raw} |
| 855 | } |
| 856 | |
| 857 | // Code implements Event.Code |
| 858 | func (*SignalEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/SignalEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/SignalEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeSignalscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeSignal. } |
| 859 | |
| 860 | // ConfChangedEvent is CONF_CHANGED in spec. |
| 861 | type ConfChangedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConfChangedEvent# struct { |
| 862 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConfChangedEvent#Raw. []string |
| 863 | } |
| 864 | |
| 865 | // ParseConfChangedEvent parses the event. |
| 866 | func ParseConfChangedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseConfChangedEvent().(raw []string) *ConfChangedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConfChangedEvent# { |
| 867 | // TODO: break into KeyVal and unescape strings |
| 868 | return &ConfChangedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConfChangedEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConfChangedEvent#Raw.: raw} |
| 869 | } |
| 870 | |
| 871 | // Code implements Event.Code |
| 872 | func (*ConfChangedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConfChangedEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConfChangedEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeConfChangedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeConfChanged. } |
| 873 | |
| 874 | // CircuitMinorEvent is CIRC_MINOR in spec. |
| 875 | type CircuitMinorEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent# struct { |
| 876 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#Raw. string |
| 877 | CircuitIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#CircuitID. string |
| 878 | Eventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#Event. string |
| 879 | Pathscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#Path. []string |
| 880 | BuildFlagsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#BuildFlags. []string |
| 881 | Purposescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#Purpose. string |
| 882 | HSStatescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#HSState. string |
| 883 | RendQueryscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#RendQuery. string |
| 884 | TimeCreatedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#TimeCreated. timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time# |
| 885 | OldPurposescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#OldPurpose. string |
| 886 | OldHSStatescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#OldHSState. string |
| 887 | } |
| 888 | |
| 889 | // ParseCircuitMinorEvent parses the event. |
| 890 | func ParseCircuitMinorEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseCircuitMinorEvent().(raw string) *CircuitMinorEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent# { |
| 891 | event := &CircuitMinorEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#Raw.: raw} |
| 892 | event.CircuitIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#CircuitID., raw, _ = 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().(raw, ' ') |
| 893 | var ok bool |
| 894 | event.Eventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#Event., raw, 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().(raw, ' ') |
| 895 | var attr string |
| 896 | first := true |
| 897 | for ok { |
| 898 | attr, raw, 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().(raw, ' ') |
| 899 | key, 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().(attr, '=') |
| 900 | switch key { |
| 901 | case "BUILD_FLAGS": |
| 902 | event.BuildFlagsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#BuildFlags. = stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Splitscip-go gomod github.com/golang/go/src go1.15 strings/Split().(val, ",") |
| 903 | case "PURPOSE": |
| 904 | event.Purposescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#Purpose. = val |
| 905 | case "HS_STATE": |
| 906 | event.HSStatescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#HSState. = val |
| 907 | case "REND_QUERY": |
| 908 | event.RendQueryscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#RendQuery. = val |
| 909 | case "TIME_CREATED": |
| 910 | event.TimeCreatedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#TimeCreated. = parseISOTime2Fracscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/parseISOTime2Frac().(val) |
| 911 | case "OLD_PURPOSE": |
| 912 | event.OldPurposescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#OldPurpose. = val |
| 913 | case "OLD_HS_STATE": |
| 914 | event.OldHSStatescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#OldHSState. = val |
| 915 | default: |
| 916 | if first { |
| 917 | event.Pathscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#Path. = stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Splitscip-go gomod github.com/golang/go/src go1.15 strings/Split().(val, ",") |
| 918 | } |
| 919 | } |
| 920 | first = false |
| 921 | } |
| 922 | return event |
| 923 | } |
| 924 | |
| 925 | // Code implements Event.Code |
| 926 | func (*CircuitMinorEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitMinorEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeCircuitMinorscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeCircuitMinor. } |
| 927 | |
| 928 | // TransportLaunchedEvent is TRANSPORT_LAUNCHED in spec. |
| 929 | type TransportLaunchedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TransportLaunchedEvent# struct { |
| 930 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TransportLaunchedEvent#Raw. string |
| 931 | Typescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TransportLaunchedEvent#Type. string |
| 932 | Namescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TransportLaunchedEvent#Name. string |
| 933 | Addressscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TransportLaunchedEvent#Address. string |
| 934 | Portscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TransportLaunchedEvent#Port. int |
| 935 | } |
| 936 | |
| 937 | // ParseTransportLaunchedEvent parses the event. |
| 938 | func ParseTransportLaunchedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseTransportLaunchedEvent().(raw string) *TransportLaunchedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TransportLaunchedEvent# { |
| 939 | event := &TransportLaunchedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TransportLaunchedEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TransportLaunchedEvent#Raw.: raw} |
| 940 | event.Typescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TransportLaunchedEvent#Type., raw, _ = 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().(raw, ' ') |
| 941 | event.Namescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TransportLaunchedEvent#Name., raw, _ = 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().(raw, ' ') |
| 942 | event.Addressscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TransportLaunchedEvent#Address., raw, _ = 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().(raw, ' ') |
| 943 | var temp string |
| 944 | temp, raw, _ = 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().(raw, ' ') |
| 945 | event.Portscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TransportLaunchedEvent#Port., _ = strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.Atoiscip-go gomod github.com/golang/go/src go1.15 strconv/Atoi().(temp) |
| 946 | return event |
| 947 | } |
| 948 | |
| 949 | // Code implements Event.Code |
| 950 | func (*TransportLaunchedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TransportLaunchedEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TransportLaunchedEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeTransportLaunchedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeTransportLaunched. } |
| 951 | |
| 952 | // ConnBandwidthEvent is CONN_BW in spec. |
| 953 | type ConnBandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConnBandwidthEvent# struct { |
| 954 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConnBandwidthEvent#Raw. string |
| 955 | ConnIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConnBandwidthEvent#ConnID. string |
| 956 | ConnTypescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConnBandwidthEvent#ConnType. string |
| 957 | BytesReadscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConnBandwidthEvent#BytesRead. int64 |
| 958 | BytesWrittenscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConnBandwidthEvent#BytesWritten. int64 |
| 959 | } |
| 960 | |
| 961 | // ParseConnBandwidthEvent parses the event. |
| 962 | func ParseConnBandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseConnBandwidthEvent().(raw string) *ConnBandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConnBandwidthEvent# { |
| 963 | event := &ConnBandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConnBandwidthEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConnBandwidthEvent#Raw.: raw} |
| 964 | ok := true |
| 965 | var attr string |
| 966 | for ok { |
| 967 | attr, raw, 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().(raw, ' ') |
| 968 | key, 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().(attr, '=') |
| 969 | switch key { |
| 970 | case "ID": |
| 971 | event.ConnIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConnBandwidthEvent#ConnID. = val |
| 972 | case "TYPE": |
| 973 | event.ConnTypescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConnBandwidthEvent#ConnType. = val |
| 974 | case "READ": |
| 975 | event.BytesReadscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConnBandwidthEvent#BytesRead., _ = strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.15 strconv/ParseInt().(val, 10, 64) |
| 976 | case "WRITTEN": |
| 977 | event.BytesWrittenscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConnBandwidthEvent#BytesWritten., _ = strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.15 strconv/ParseInt().(val, 10, 64) |
| 978 | } |
| 979 | } |
| 980 | return event |
| 981 | } |
| 982 | |
| 983 | // Code implements Event.Code |
| 984 | func (*ConnBandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConnBandwidthEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ConnBandwidthEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeConnBandwidthscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeConnBandwidth. } |
| 985 | |
| 986 | // CircuitBandwidthEvent is CIRC_BW in spec. |
| 987 | type CircuitBandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitBandwidthEvent# struct { |
| 988 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitBandwidthEvent#Raw. string |
| 989 | CircuitIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitBandwidthEvent#CircuitID. string |
| 990 | BytesReadscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitBandwidthEvent#BytesRead. int64 |
| 991 | BytesWrittenscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitBandwidthEvent#BytesWritten. int64 |
| 992 | Timescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitBandwidthEvent#Time. timescip-go gomod github.com/golang/go/src go1.15 time/.Timescip-go gomod github.com/golang/go/src go1.15 time/Time# |
| 993 | } |
| 994 | |
| 995 | // ParseCircuitBandwidthEvent parses the event. |
| 996 | func ParseCircuitBandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseCircuitBandwidthEvent().(raw string) *CircuitBandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitBandwidthEvent# { |
| 997 | event := &CircuitBandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitBandwidthEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitBandwidthEvent#Raw.: raw} |
| 998 | ok := true |
| 999 | var attr string |
| 1000 | for ok { |
| 1001 | attr, raw, 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().(raw, ' ') |
| 1002 | key, 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().(attr, '=') |
| 1003 | switch key { |
| 1004 | case "ID": |
| 1005 | event.CircuitIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitBandwidthEvent#CircuitID. = val |
| 1006 | case "READ": |
| 1007 | event.BytesReadscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitBandwidthEvent#BytesRead., _ = strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.15 strconv/ParseInt().(val, 10, 64) |
| 1008 | case "WRITTEN": |
| 1009 | event.BytesWrittenscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitBandwidthEvent#BytesWritten., _ = strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.15 strconv/ParseInt().(val, 10, 64) |
| 1010 | case "TIME": |
| 1011 | event.Timescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitBandwidthEvent#Time. = parseISOTime2Fracscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/parseISOTime2Frac().(val) |
| 1012 | } |
| 1013 | } |
| 1014 | return event |
| 1015 | } |
| 1016 | |
| 1017 | // Code implements Event.Code |
| 1018 | func (*CircuitBandwidthEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitBandwidthEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CircuitBandwidthEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeCircuitBandwidthscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeCircuitBandwidth. } |
| 1019 | |
| 1020 | // CellStatsEvent is CELL_STATS in spec. |
| 1021 | type CellStatsEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent# struct { |
| 1022 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#Raw. string |
| 1023 | CircuitIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#CircuitID. string |
| 1024 | InboundQueueIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#InboundQueueID. string |
| 1025 | InboundConnIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#InboundConnID. string |
| 1026 | InboundAddedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#InboundAdded. map[string]int |
| 1027 | InboundRemovedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#InboundRemoved. map[string]int |
| 1028 | InboundTimescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#InboundTime. map[string]int |
| 1029 | OutboundQueueIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#OutboundQueueID. string |
| 1030 | OutboundConnIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#OutboundConnID. string |
| 1031 | OutboundAddedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#OutboundAdded. map[string]int |
| 1032 | OutboundRemovedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#OutboundRemoved. map[string]int |
| 1033 | OutboundTimescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#OutboundTime. map[string]int |
| 1034 | } |
| 1035 | |
| 1036 | // ParseCellStatsEvent parses the event. |
| 1037 | func ParseCellStatsEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseCellStatsEvent().(raw string) *CellStatsEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent# { |
| 1038 | event := &CellStatsEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#Raw.: raw} |
| 1039 | ok := true |
| 1040 | var attr string |
| 1041 | toIntMap := func(val string) map[string]int { |
| 1042 | ret := map[string]int{} |
| 1043 | for _, v := range stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Splitscip-go gomod github.com/golang/go/src go1.15 strings/Split().(val, ",") { |
| 1044 | key, 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().(v, ':') |
| 1045 | ret[key], _ = strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.Atoiscip-go gomod github.com/golang/go/src go1.15 strconv/Atoi().(val) |
| 1046 | } |
| 1047 | return ret |
| 1048 | } |
| 1049 | for ok { |
| 1050 | attr, raw, 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().(raw, ' ') |
| 1051 | key, 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().(attr, '=') |
| 1052 | switch key { |
| 1053 | case "ID": |
| 1054 | event.CircuitIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#CircuitID. = val |
| 1055 | case "InboundQueue": |
| 1056 | event.InboundQueueIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#InboundQueueID. = val |
| 1057 | case "InboundConn": |
| 1058 | event.InboundConnIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#InboundConnID. = val |
| 1059 | case "InboundAdded": |
| 1060 | event.InboundAddedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#InboundAdded. = toIntMap(val) |
| 1061 | case "InboundRemoved": |
| 1062 | event.InboundRemovedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#InboundRemoved. = toIntMap(val) |
| 1063 | case "InboundTime": |
| 1064 | event.OutboundTimescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#OutboundTime. = toIntMap(val) |
| 1065 | case "OutboundQueue": |
| 1066 | event.OutboundQueueIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#OutboundQueueID. = val |
| 1067 | case "OutboundConn": |
| 1068 | event.OutboundConnIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#OutboundConnID. = val |
| 1069 | case "OutboundAdded": |
| 1070 | event.OutboundAddedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#OutboundAdded. = toIntMap(val) |
| 1071 | case "OutboundRemoved": |
| 1072 | event.OutboundRemovedscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#OutboundRemoved. = toIntMap(val) |
| 1073 | case "OutboundTime": |
| 1074 | event.OutboundTimescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#OutboundTime. = toIntMap(val) |
| 1075 | } |
| 1076 | } |
| 1077 | return event |
| 1078 | } |
| 1079 | |
| 1080 | // Code implements Event.Code |
| 1081 | func (*CellStatsEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/CellStatsEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeCellStatsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeCellStats. } |
| 1082 | |
| 1083 | // TokenBucketEmptyEvent is TB_EMPTY in spec. |
| 1084 | type TokenBucketEmptyEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TokenBucketEmptyEvent# struct { |
| 1085 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TokenBucketEmptyEvent#Raw. string |
| 1086 | BucketNamescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TokenBucketEmptyEvent#BucketName. string |
| 1087 | ConnIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TokenBucketEmptyEvent#ConnID. string |
| 1088 | ReadBucketEmptyscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TokenBucketEmptyEvent#ReadBucketEmpty. timescip-go gomod github.com/golang/go/src go1.15 time/.Durationscip-go gomod github.com/golang/go/src go1.15 time/Duration# |
| 1089 | WriteBucketEmptyscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TokenBucketEmptyEvent#WriteBucketEmpty. timescip-go gomod github.com/golang/go/src go1.15 time/.Durationscip-go gomod github.com/golang/go/src go1.15 time/Duration# |
| 1090 | LastRefilscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TokenBucketEmptyEvent#LastRefil. timescip-go gomod github.com/golang/go/src go1.15 time/.Durationscip-go gomod github.com/golang/go/src go1.15 time/Duration# |
| 1091 | } |
| 1092 | |
| 1093 | // ParseTokenBucketEmptyEvent parses the event. |
| 1094 | func ParseTokenBucketEmptyEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseTokenBucketEmptyEvent().(raw string) *TokenBucketEmptyEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TokenBucketEmptyEvent# { |
| 1095 | event := &TokenBucketEmptyEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TokenBucketEmptyEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TokenBucketEmptyEvent#Raw.: raw} |
| 1096 | var ok bool |
| 1097 | event.BucketNamescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TokenBucketEmptyEvent#BucketName., raw, 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().(raw, ' ') |
| 1098 | var attr string |
| 1099 | for ok { |
| 1100 | attr, raw, 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().(raw, ' ') |
| 1101 | key, 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().(attr, '=') |
| 1102 | switch key { |
| 1103 | case "ID": |
| 1104 | event.ConnIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TokenBucketEmptyEvent#ConnID. = val |
| 1105 | case "READ": |
| 1106 | i, _ := strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.15 strconv/ParseInt().(val, 10, 64) |
| 1107 | event.ReadBucketEmptyscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TokenBucketEmptyEvent#ReadBucketEmpty. = timescip-go gomod github.com/golang/go/src go1.15 time/.Durationscip-go gomod github.com/golang/go/src go1.15 time/Duration#(i) * timescip-go gomod github.com/golang/go/src go1.15 time/.Millisecondscip-go gomod github.com/golang/go/src go1.15 time/Millisecond. |
| 1108 | case "WRITTEN": |
| 1109 | i, _ := strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.15 strconv/ParseInt().(val, 10, 64) |
| 1110 | event.WriteBucketEmptyscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TokenBucketEmptyEvent#WriteBucketEmpty. = timescip-go gomod github.com/golang/go/src go1.15 time/.Durationscip-go gomod github.com/golang/go/src go1.15 time/Duration#(i) * timescip-go gomod github.com/golang/go/src go1.15 time/.Millisecondscip-go gomod github.com/golang/go/src go1.15 time/Millisecond. |
| 1111 | case "LAST": |
| 1112 | i, _ := strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.ParseIntscip-go gomod github.com/golang/go/src go1.15 strconv/ParseInt().(val, 10, 64) |
| 1113 | event.LastRefilscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TokenBucketEmptyEvent#LastRefil. = timescip-go gomod github.com/golang/go/src go1.15 time/.Durationscip-go gomod github.com/golang/go/src go1.15 time/Duration#(i) * timescip-go gomod github.com/golang/go/src go1.15 time/.Millisecondscip-go gomod github.com/golang/go/src go1.15 time/Millisecond. |
| 1114 | } |
| 1115 | } |
| 1116 | return event |
| 1117 | } |
| 1118 | |
| 1119 | // Code implements Event.Code |
| 1120 | func (*TokenBucketEmptyEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TokenBucketEmptyEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/TokenBucketEmptyEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeTokenBucketEmptyscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeTokenBucketEmpty. } |
| 1121 | |
| 1122 | // HSDescEvent is HS_DESC in spec. |
| 1123 | type HSDescEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent# struct { |
| 1124 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#Raw. string |
| 1125 | Actionscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#Action. string |
| 1126 | Addressscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#Address. string |
| 1127 | AuthTypescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#AuthType. string |
| 1128 | HSDirscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#HSDir. string |
| 1129 | DescIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#DescID. string |
| 1130 | Reasonscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#Reason. string |
| 1131 | Replicascip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#Replica. int |
| 1132 | HSDirIndexscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#HSDirIndex. string |
| 1133 | } |
| 1134 | |
| 1135 | // ParseHSDescEvent parses the event. |
| 1136 | func ParseHSDescEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseHSDescEvent().(raw string) *HSDescEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent# { |
| 1137 | event := &HSDescEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#Raw.: raw} |
| 1138 | event.Actionscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#Action., raw, _ = 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().(raw, ' ') |
| 1139 | event.Addressscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#Address., raw, _ = 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().(raw, ' ') |
| 1140 | event.AuthTypescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#AuthType., raw, _ = 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().(raw, ' ') |
| 1141 | var ok bool |
| 1142 | event.HSDirscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#HSDir., raw, 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().(raw, ' ') |
| 1143 | var attr string |
| 1144 | first := true |
| 1145 | for ok { |
| 1146 | attr, raw, 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().(raw, ' ') |
| 1147 | key, val, valOk := 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().(attr, '=') |
| 1148 | switch key { |
| 1149 | case "REASON": |
| 1150 | event.Reasonscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#Reason. = val |
| 1151 | case "REPLICA": |
| 1152 | event.Replicascip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#Replica., _ = strconvscip-go gomod github.com/golang/go/src go1.15 strconv/.Atoiscip-go gomod github.com/golang/go/src go1.15 strconv/Atoi().(val) |
| 1153 | case "HSDIR_INDEX": |
| 1154 | event.HSDirIndexscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#HSDirIndex. = val |
| 1155 | default: |
| 1156 | if first && !valOk { |
| 1157 | event.DescIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#DescID. = attr |
| 1158 | } |
| 1159 | } |
| 1160 | first = false |
| 1161 | } |
| 1162 | return event |
| 1163 | } |
| 1164 | |
| 1165 | // Code implements Event.Code |
| 1166 | func (*HSDescEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeHSDescscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeHSDesc. } |
| 1167 | |
| 1168 | // HSDescContentEvent is HS_DESC_CONTENT in spec. |
| 1169 | type HSDescContentEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescContentEvent# struct { |
| 1170 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescContentEvent#Raw. string |
| 1171 | Addressscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescContentEvent#Address. string |
| 1172 | DescIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescContentEvent#DescID. string |
| 1173 | HSDirscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescContentEvent#HSDir. string |
| 1174 | Descriptorscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescContentEvent#Descriptor. string |
| 1175 | } |
| 1176 | |
| 1177 | // ParseHSDescContentEvent parses the event. |
| 1178 | func ParseHSDescContentEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseHSDescContentEvent().(raw string) *HSDescContentEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescContentEvent# { |
| 1179 | event := &HSDescContentEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescContentEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescContentEvent#Raw.: raw} |
| 1180 | event.Addressscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescContentEvent#Address., raw, _ = 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().(raw, ' ') |
| 1181 | event.DescIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescContentEvent#DescID., raw, _ = 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().(raw, ' ') |
| 1182 | newlineIndex := stringsscip-go gomod github.com/golang/go/src go1.15 strings/.Indexscip-go gomod github.com/golang/go/src go1.15 strings/Index().(raw, "\r\n") |
| 1183 | if newlineIndex != -1 { |
| 1184 | event.HSDirscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescContentEvent#HSDir., event.Descriptorscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescContentEvent#Descriptor. = raw[:newlineIndex], raw[newlineIndex+2:] |
| 1185 | } |
| 1186 | return event |
| 1187 | } |
| 1188 | |
| 1189 | // Code implements Event.Code |
| 1190 | func (*HSDescContentEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescContentEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescContentEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeHSDescContentscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeHSDescContent. } |
| 1191 | |
| 1192 | // NetworkLivenessEvent is NETWORK_LIVENESS in spec. |
| 1193 | type NetworkLivenessEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NetworkLivenessEvent# struct { |
| 1194 | Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NetworkLivenessEvent#Raw. string |
| 1195 | } |
| 1196 | |
| 1197 | // ParseNetworkLivenessEvent parses the event. |
| 1198 | func ParseNetworkLivenessEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseNetworkLivenessEvent().(raw string) *NetworkLivenessEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NetworkLivenessEvent# { |
| 1199 | return &NetworkLivenessEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NetworkLivenessEvent#{Rawscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NetworkLivenessEvent#Raw.: raw} |
| 1200 | } |
| 1201 | |
| 1202 | // Code implements Event.Code |
| 1203 | func (*NetworkLivenessEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NetworkLivenessEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/NetworkLivenessEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return EventCodeNetworkLivenessscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeNetworkLiveness. } |
| 1204 | |
| 1205 | // UnrecognizedEvent is any unrecognized event code. |
| 1206 | type UnrecognizedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/UnrecognizedEvent# struct { |
| 1207 | EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/UnrecognizedEvent#EventCode. EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# |
| 1208 | RawSingleLinescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/UnrecognizedEvent#RawSingleLine. string |
| 1209 | RawMultiLinescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/UnrecognizedEvent#RawMultiLine. []string |
| 1210 | } |
| 1211 | |
| 1212 | // ParseUnrecognizedEvent creates an unrecognized event with the given values. |
| 1213 | func ParseUnrecognizedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/ParseUnrecognizedEvent().(eventCode EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode#, rawSingleLine string, rawMultiLine []string) *UnrecognizedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/UnrecognizedEvent# { |
| 1214 | return &UnrecognizedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/UnrecognizedEvent#{EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/UnrecognizedEvent#EventCode.: eventCode, RawSingleLinescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/UnrecognizedEvent#RawSingleLine.: rawSingleLine, RawMultiLinescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/UnrecognizedEvent#RawMultiLine.: rawMultiLine} |
| 1215 | } |
| 1216 | |
| 1217 | // Code implements Event.Code |
| 1218 | func (u *UnrecognizedEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/UnrecognizedEvent#) Codescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/UnrecognizedEvent#Code().() EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCode# { return u.EventCodescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/UnrecognizedEvent#EventCode. } |