| /************************************************************************** | |
| * simpletun.c * | |
| * * | |
| * A simplistic, simple-minded, naive tunnelling program using tun/tap * | |
| * interfaces and TCP. Handles (badly) IPv4 for tun, ARP and IPv4 for * | |
| * tap. DO NOT USE THIS PROGRAM FOR SERIOUS PURPOSES. * | |
| * * | |
| * You have been warned. * | |
| * * | |
| * (C) 2009 Davide Brini. * | 
| import os | |
| import sys | |
| import traceback | |
| from functools import wraps | |
| from multiprocessing import Process, Queue | |
| def processify(func): | |
| '''Decorator to run a function as a process. | |
| Be sure that every argument and the return value | 
| // === Tokenizer | |
| class Tokens { | |
| constructor(tokens) { | |
| this.head = tokens[0]; | |
| this.tail = tokens.slice(1); | |
| } | |
| } | |
| class Tokenizer { | 
| try: | |
| from psycopg2cffi import compat | |
| compat.register() | |
| except ImportError: | |
| pass | |
| from pyutil.decorators import * | |
| import tempfile, psycopg2, psycopg2.extras | |
| def setup_test_table(conn): | 
| #!/usr/bin/python2 | |
| # -*- coding:utf-8 -*- | |
| import requests | |
| import time | |
| import hashlib | |
| from Crypto.Cipher import AES | |
| import base64 | |
| import json | 
| --- | |
| version: 1 | |
| disable_existing_loggers: False | |
| formatters: | |
| simple: | |
| format: "%(name)-20s%(levelname)-8s%(message)s" | |
| handlers: | |
| console: | |
| class: logging.StreamHandler | |
| level: DEBUG | 
** aiohttp now supports in its webframework websocket **
http://aiohttp.readthedocs.org/en/v0.14.1/web.html#websockets
This is a quick hack (ported from django-c10k) to get websocket working along side classic http with aiohttp web server. I think it would be better to inherit the aiohttp.web.RequestHandler and add the code to handle the upgrade in RequestHandler.start instead of overriding RequestHandler.transport.close in WebsocketResponse.
Anyway, it seems like it works.
requirements:
** aiohttp now supports in its webframework websocket **
http://aiohttp.readthedocs.org/en/v0.14.1/web.html#websockets
This is a quick hack (ported from django-c10k) to get websocket working along side classic http with aiohttp web server. I think it would be better to inherit the aiohttp.web.RequestHandler and add the code to handle the upgrade in RequestHandler.start instead of overriding RequestHandler.transport.close in WebsocketResponse.
Anyway, it seems like it works.
requirements:
** aiohttp now supports in its webframework websocket **
http://aiohttp.readthedocs.org/en/v0.14.1/web.html#websockets
This is a quick hack (ported from django-c10k) to get websocket working along side classic http with aiohttp web server. I think it would be better to inherit the aiohttp.web.RequestHandler and add the code to handle the upgrade in RequestHandler.start instead of overriding RequestHandler.transport.close in WebsocketResponse.
Anyway, it seems like it works.
requirements: