webXMPP

Check-in [ec8f5ea505]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Bring up, -ting subop handling for NAT accomodation
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:ec8f5ea505514ae6efc8558831ce031aa94dc2d5ce719d2653bbf38c30a2dd81
User & Date: vandyswa@gmail.com 2017-06-30 05:09:03
Context
2017-06-30
05:09
Merge branch 'master' of https://github.com/vandys/-webXMPP check-in: 04a597a22e user: vandyswa@gmail.com tags: master, trunk
05:09
Bring up, -ting subop handling for NAT accomodation check-in: ec8f5ea505 user: vandyswa@gmail.com tags: master, trunk
00:27
Merge branch 'master' of https://github.com/vandys/-webXMPP check-in: 4d5a71d733 user: vandyswa@gmail.com tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to etc/config.

36
37
38
39
40
41
42



43
44
45
46
47
48
49
    # TBD, permit only SMS services into this interface
    port 8092

# UDP Push, usually same port # as HTTP SSL (but HTTP is TCP,
#  this is UDP)
serve udp
    port 8091




# # messages to display at client
nmsg 15


# Username into HTTP server, with password
user test1







>
>
>







36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
    # TBD, permit only SMS services into this interface
    port 8092

# UDP Push, usually same port # as HTTP SSL (but HTTP is TCP,
#  this is UDP)
serve udp
    port 8091
    # 2.5 minutes, nicely short of the default Linux NAT
    #  timeout of 3 minutes.
    timeout 150

# # messages to display at client
nmsg 15


# Username into HTTP server, with password
user test1

Changes to main.py.

55
56
57
58
59
60
61


62
63
64
65
66
67
68

# Config file
def load_cfg(fn):
    c = chore.config.Config()

    # Web server config
    chore.www.add_config(c)



    # Top-level numeric singletons
    for f in ("nmsg", "poll1"):
	c.ints.add( (f,) )
    for f in ("pollslop",):
	c.floats.add( (f,) )








>
>







55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

# Config file
def load_cfg(fn):
    c = chore.config.Config()

    # Web server config
    chore.www.add_config(c)
    # Extra param for UDP services
    c.ints.add( ("serve", "timeout") )

    # Top-level numeric singletons
    for f in ("nmsg", "poll1"):
	c.ints.add( (f,) )
    for f in ("pollslop",):
	c.floats.add( (f,) )

Changes to notified.py.

187
188
189
190
191
192
193



194
195
196
197
198
199
200

        n.show()

    # Worry about the LEDs?
    if leds and (not blinking) and is_locked:
        blink()




# Endless execution, notification client
def run():
    global cfg, gen

    # Get a wrapper for our pong network connection
    conn = pong.Client(cfg.server, cfg.port, cfg.user, cfg.password)








>
>
>







187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203

        n.show()

    # Worry about the LEDs?
    if leds and (not blinking) and is_locked:
        blink()

    # Play sound
    os.system("paplay --volume=30000 %s" % (cfg.sound,))

# Endless execution, notification client
def run():
    global cfg, gen

    # Get a wrapper for our pong network connection
    conn = pong.Client(cfg.server, cfg.port, cfg.user, cfg.password)

Changes to udp.py.

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
...
163
164
165
166
167
168
169




170
171
172
173
174
175
176
	self.handler = self.user = self.pak = None

class UDP(object):
    def __init__(self, cfg, approot):
	global TIMEOUT, accounts

	self.approot = approot
	TIMEOUT = approot.config["poll1"]
	port = self.port = cfg["port"]
        self.conn = Serve(port)

	# Cache any UDP accounts
	for uname,d in approot.config["user"]:
	    if "password" not in d:
		continue
................................................................................
	    # Hold off on answering until timeout or
	    #  something arrives
	    # Unlike HTTP, we haven't spun up a thread for this
	    #  request, nor would it make sense to do so now.
	    # Instead, we create an instance with a "release"
	    #  method, and will directly answer the request
	    #  from that.




	    log(" queue for reply")
	    replier = Notify_Reply(self, user, pak)
	    user.await(TIMEOUT, replier, None, None)
	    return

	log(" notify unknown subop: " + subop)








|







 







>
>
>
>







68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
...
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
	self.handler = self.user = self.pak = None

class UDP(object):
    def __init__(self, cfg, approot):
	global TIMEOUT, accounts

	self.approot = approot
	TIMEOUT = cfg.get("timeout", 150)
	port = self.port = cfg["port"]
        self.conn = Serve(port)

	# Cache any UDP accounts
	for uname,d in approot.config["user"]:
	    if "password" not in d:
		continue
................................................................................
	    # Hold off on answering until timeout or
	    #  something arrives
	    # Unlike HTTP, we haven't spun up a thread for this
	    #  request, nor would it make sense to do so now.
	    # Instead, we create an instance with a "release"
	    #  method, and will directly answer the request
	    #  from that.
	    # We send back a vacuous "getting" subop to satisfy
	    #  NAT state (if any, but what're the odds?).
	    outpak = self.conn.pong(pak, "getting")
	    self.conn.reply(pak, outpak)
	    log(" queue for reply")
	    replier = Notify_Reply(self, user, pak)
	    user.await(TIMEOUT, replier, None, None)
	    return

	log(" notify unknown subop: " + subop)