Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Blacklist in its own file, update from it on demand. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | master | trunk |
Files: | files | file ages | folders |
SHA3-256: | 93ec53def7bcb79717be4eb4228be79c |
User & Date: | ajv-899-334-8894@vsta.org 2018-03-13 02:29:10 |
Context
2018-03-13
| ||
03:59 | Support more subtleties of XMPP presence; "type" field basically means you're offline. Seem to be tracking Jane/Amri along with the n910's XMPP stack behavior. check-in: 6e2093a529 user: ajv-899-334-8894@vsta.org tags: master, trunk | |
02:29 | Blacklist in its own file, update from it on demand. check-in: 93ec53def7 user: ajv-899-334-8894@vsta.org tags: master, trunk | |
2018-03-12
| ||
14:59 | Fix typo. Include our own input in user history. check-in: a9af2b1f5e user: ajv-899-334-8894@vsta.org tags: master, trunk | |
Changes
Changes to main.py.
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
...
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
# Messaging key from Google for Firebase Cloud Messaging c.onearg.add( ("fcmkey",) ) # Lists of SMS peers, also a blacklist c.noarg.add( ("sms",) ) c.args.add( ("sms", "peers") ) c.mults.add( ("sms", "peers") ) c.args.add( ("sms", "blacklist") ) c.mults.add( ("sms", "blacklist") ) # Multiple of these, with sub-config c.onearg.add( ("user",) ) c.mults.add( ("user",) ) # Sub-config of "user", XMPP account(s) c.args.add( ("user", "account") ) ................................................................................ # Our timeout service thread self.timer = None # Callbacks when time expires # List of tuples; (expires-tm, call-fn, call-arg) self.timeouts = [] # SMS source filters, if any self.smsok = [] self.smsbad = [] if "sms" in cfg: for tup in cfg["sms"][1].get("peers"): for a in tup: self.smsok.append(chore.net.parseaddr(a)) for tup in cfg["sms"][1].get("blacklist"): for a in tup: self.smsbad.append(a) # Static/local authentication config? Can't mix with # an authentication server. if any(("password" in acct[1]) for acct in cfg["user"]): self.authentication.append(WebXMPP.auth_local) else: # Account server to get logged in & get cookie |
|
<
>
>
>
>
>
>
|
>
|
<
<
|
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
...
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
# Messaging key from Google for Firebase Cloud Messaging c.onearg.add( ("fcmkey",) ) # Lists of SMS peers, also a blacklist c.noarg.add( ("sms",) ) c.args.add( ("sms", "peers") ) c.mults.add( ("sms", "peers") ) c.onearg.add( ("sms", "blacklist") ) # Multiple of these, with sub-config c.onearg.add( ("user",) ) c.mults.add( ("user",) ) # Sub-config of "user", XMPP account(s) c.args.add( ("user", "account") ) ................................................................................ # Our timeout service thread self.timer = None # Callbacks when time expires # List of tuples; (expires-tm, call-fn, call-arg) self.timeouts = [] # Possibly restrict REST SMS submission by IP # SMS source filters, if any self.smsok = [] # List of bad phone #'s (SMS spam) and file which we # refresh from on demand self.smsbad = [] self.smsblack = None self.smsblatest = 0.0 if "sms" in cfg: subs = cfg["sms"][1] for tup in subs.get("peers"): for a in tup: self.smsok.append(chore.net.parseaddr(a)) self.smsblack = subs.get("blacklist") # Static/local authentication config? Can't mix with # an authentication server. if any(("password" in acct[1]) for acct in cfg["user"]): self.authentication.append(WebXMPP.auth_local) else: # Account server to get logged in & get cookie |
Changes to post.py.
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
..
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# HTML POST/PUT handling # # POST's put state back to us--usually a text to send. # # /msg.json - JSON of a message to send # /sms.json - JSON of a Flowroute-style SMS delivery # import sys, json from chore.utils import toascii import chore import acct_sms class POST_mixin(object): def __init__(self): self.dispatchers.append( ("POST", self.post_msg) ) self.dispatchers.append( ("POST", self.post_sms) ) # An SMS has arrived for us def post_sms(self, buf): # /sms.json if not self.path_match("sms.json"): return False,None ................................................................................ sys.exit(0) # Decode message payload msg = json.loads(buf) sys.stderr.write(" JSON result %s\n" % (msg,)) # Pre-filter for a in approot.smsbad: if a in msg.get("from", ""): sys.stderr.write("Blacklist SMS from %s\n" % (msg["from"],)) return True,self.send_result("", "text/html") # Hand it off acct_sms.incoming(msg) # If we error, they just re-deliver more times, so always # accept it, even if we have to log an issue with handling it. |
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
<
<
<
|
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
..
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# HTML POST/PUT handling # # POST's put state back to us--usually a text to send. # # /msg.json - JSON of a message to send # /sms.json - JSON of a Flowroute-style SMS delivery # import sys, json, os from chore.utils import toascii import chore import acct_sms class POST_mixin(object): def __init__(self): self.dispatchers.append( ("POST", self.post_msg) ) self.dispatchers.append( ("POST", self.post_sms) ) # Does SMS blacklisting apply to this message? def filtered(self, msg): approot = self.server.approot # No blacklist if approot.smsblack is None: return False # Refresh? try: st = os.stat(approot.smsblack) except: sys.stderr.write("SMS blacklist %s missing\n" % (approot.smsblack,)) return False if st.st_mtime > approot.smsblatest: sys.stderr.write("Reload SMS blacklist\n") approot.smsbad = [] f = open(approot.smsblack, "r") for l in f: l = l.strip() if not l: continue approot.smsbad.append(l) f.close() sys.stderr.write(" %d entries\n" % (len(approot.smsbad),)) approot.smsblatest = st.st_mtime # See if any blacklist pattern is found within sender mf = msg.get("from", "") res = any( (a in mf) for a in approot.smsbad ) if res: sys.stderr.write("SMS blacklist %s\n" % (mf,)) return res # An SMS has arrived for us def post_sms(self, buf): # /sms.json if not self.path_match("sms.json"): return False,None ................................................................................ sys.exit(0) # Decode message payload msg = json.loads(buf) sys.stderr.write(" JSON result %s\n" % (msg,)) # Pre-filter if self.filtered(msg): return True,self.send_result("", "text/html") # Hand it off acct_sms.incoming(msg) # If we error, they just re-deliver more times, so always # accept it, even if we have to log an issue with handling it. |