[tor-bugs] #18666 [Stem]: ExitPolicy constructor inconsistent

Tor Bug Tracker & Wiki blackhole at torproject.org
Mon Mar 28 21:29:52 UTC 2016


#18666: ExitPolicy constructor inconsistent
-----------------------+----------------------------
 Reporter:  Sebastian  |          Owner:  atagar
     Type:  defect     |         Status:  closed
 Priority:  Medium     |      Milestone:
Component:  Stem       |        Version:
 Severity:  Normal     |     Resolution:  worksforme
 Keywords:             |  Actual Points:
Parent ID:             |         Points:
 Reviewer:             |        Sponsor:
-----------------------+----------------------------
Changes (by atagar):

 * status:  new => closed
 * resolution:   => worksforme


Comment:

 Hi Sebastian, definitely confusing that the behavior is different and this
 took me a while to figure out. Your calls are incorrect and I was more
 puzzled why the first was **working** than why the second was not.

 The **ExitPolicy** class takes a list of rules. For example...

 {{{
 ExitPolicy('reject *:80', 'accept *:*')
 }}}

 Your comma is within the quotes. If you moved it out of the quotes it
 would work as intended...

 {{{
 >>> str(stem.exit_policy.ExitPolicy('reject *:*',))
 'reject *:*'

 >>> str(stem.exit_policy.ExitPolicy('reject6 *:*',))
 'reject [0000:0000:0000:0000:0000:0000:0000:0000]/0:*'
 }}}

 So why the difference in behavior with your calls? Reason is short
 circuiting. The 'reject6 *:*,' does the following...

 1. Split on the comma so there's two rules to parse: ["reject6 *:*", ""]
 2. It parses 'reject6 *:*'. That's fine.
 3. It parses "". That gives you the stacktrace you're seeing.

 As for the 'reject *:*' it does the following...

 1. Split on the comma so there's two rules to parse: ["reject *:*", ""]
 2. It parses 'reject *:*'. That's fine.
 3. Since it just parsed a full wildcard rule there's no reason to read
 anything further so we don't attempt to parse the "".

 Looks like everything is working as intended. Feel free to reopen if you
 have any questions or would like something tweaked.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/18666#comment:1>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list