Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 48 lines (30 sloc) 0.883 kb
b47098c @rep testbroker
authored
1 import sys
6d6be7d @rep fix
authored
2 import feedbroker
b47098c @rep testbroker
authored
3 from feedbroker import *
67e38be @rep log level only if __main__, testbroker simpler
authored
4 logging.basicConfig(level=logging.DEBUG)
b47098c @rep testbroker
authored
5
6
7 FeedConnOrig = FeedConn
8 FeedBrokerOrig = FeedBroker
9
10
11 class FeedBroker(FeedBrokerOrig):
12 def initdb(self):
13 pass
14
15
16 class FeedConn(FeedConnOrig):
17 def auth(self, ident, hash):
18 self.checkauth([{'identifier': str(ident), 'secret': 'secretsecret'},], hash)
19
20 def checkauth(self, r, hash):
67e38be @rep log level only if __main__, testbroker simpler
authored
21 akobj = r[0]
22 akhash = hashlib.sha1('{0}{1}'.format(self.rand, akobj['secret'])).digest()
23 self.idents.add(akobj['identifier'])
24 logging.info('Auth success by {0}, {1}.'.format(akobj['identifier'], self.conn.addr))
b47098c @rep testbroker
authored
25
26 self.io_in(b'')
27
28 def may_publish(self, chan):
29 return True
30
31 def may_subscribe(self, chan):
32 return True
33
34
6d6be7d @rep fix
authored
35 feedbroker.FeedConn = FeedConn
36 feedbroker.FeedBroker = FeedBroker
37
38
b47098c @rep testbroker
authored
39 def main():
40 fb = FeedBroker()
41
42 loop()
43 return 0
44
45 if __name__ == '__main__':
46 sys.exit(main())
47
Something went wrong with that request. Please try again.